+ message_die(GENERAL_ERROR, "YubiCloud authentication not configured. Add \$Config['YubiCloud']['ClientID'] and \$Config['YubiCloud']['SecretKey'] to your config.");
+ }
+ if (!$key = $_GET['OTP']) message_die(GENERAL_ERROR, "Please add in URL ?OTP=, then put your cursor at right of the = and press your YubiKey button");
+ $yubi = new Auth_Yubico($Config['YubiCloud']['ClientID'], $Config['YubiCloud']['SecreyKey']);
+ if (!$data = $yubi->parsePasswordOTP($key)) {
+ message_die(GENERAL_ERROR, "This is not an YubiKey OTP.");
+ }
+ $prefix = $data['prefix'];
+ $auth = $yubi->verify($key);
+ if (@PEAR::isError($auth)) {
+ if ($auth->getMessage() == 'REPLAYED_OTP') message_die("This OTP has already been used.");
- if (!$db->sql_query($sql)) message_die(SQL_ERROR, "Impossible de mettre à jour la session", '', __LINE__, __FILE__, $sql);
- }
-}
-
-function nbc () {
-//Renvoi du nombre d'usagers connectés
- global $db, $Config;
- $sql = "SELECT count(*) FROM " . TABLE_SESSIONS . " WHERE online=1 AND `Where` = $Config[ResourceID]";
- if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Impossible d'obtenir le nombre d'utilisateurs connectés sur le site web", '', __LINE__, __FILE__, $sql);
- $row = $db->sql_fetchrow($result);
- return $row[0];
-}
-
-function get_info ($info)
-//Renvoie une variable de la session
-{
- global $db;
- $sql = "SELECT $info FROM " . TABLE_SESSIONS . " WHERE session_id LIKE '$_SESSION[ID]'";
+ if (!$db->sql_query($sql)) message_die(SQL_ERROR, "Impossible de mettre à jour la session", '', __LINE__, __FILE__, $sql);
+ }
+}
+
+function nbc () {
+//Renvoi du nombre d'usagers connectés
+ global $db, $Config;
+ $sql = "SELECT count(*) FROM " . TABLE_SESSIONS . " WHERE online=1 AND `Where` = $Config[ResourceID]";
+ if ( !($result = $db->sql_query($sql)) ) message_die(SQL_ERROR, "Impossible d'obtenir le nombre d'utilisateurs connectés sur le site web", '', __LINE__, __FILE__, $sql);
+ $row = $db->sql_fetchrow($result);
+ return $row[0];
+}
+
+function get_info ($info)
+//Renvoie une variable de la session
+{
+ global $db;
+ $sql = "SELECT $info FROM " . TABLE_SESSIONS . " WHERE session_id LIKE '$_SESSION[ID]'";