$authval = $myga->authenticateUser($username, $passcode);
msg_send($cl_queue, MSG_AUTH_USER_TOKEN, $authval);
break;
+
+ case MSG_GET_OTK_PNG:
+ if(!isset($msg["username"])) {
+ msg_send($cl_queue, MSG_GET_OTK_PNG, false);
+ } else {
+ $username = $msg["username"];
+ $sql = "select users_otk from users where users_username='$username'";
+ $dbo = getDatabase();
+ $res = $dbo->query($sql);
+ $otk = "";
+ foreach($res as $row) {
+ $otk = $row["users_otk"];
+ }
+
+ if($otk == "") {
+ msg_send($cl_queue, MSG_GET_OTK_PNG, false);
+ } else {
+ $hand = fopen("otks/$otk.png", "rb");
+ $data = fread($hand, filesize("otks/$otk.png"));
+ fclose($hand);
+ msg_send($cl_queue, MSG_GET_OTK_PNG, $data);
+ unlink("otks/$otk.png");
+ $sql = "update users set users_otk='' where users_username='$username'";
+ $dbo->query($sql);
+ }
+ }
+
+ break;
case MSG_ADD_USER_TOKEN:
echo "Call to add user token\n";
if(!isset($msg["username"])) {
global $myga;
$myga->setUser($username, $tokentype, "", $hexkey);
- msg_send($cl_queue, MSG_ADD_USER_TOKEN, $myga->createUrl($username));
+ $url = $myga->createUrl($username);
+ mkdir("otks");
+ $otk = generateRandomString();
+ system("qrencode -o otks/$otk.png $url");
+
+ $sql = "update users set users_otk='$otk' where users_username='$username'";
+ $dbo = getDatabase();
+ $res = $dbo->query($sql);
+
+ msg_send($cl_queue, MSG_ADD_USER_TOKEN, true);
}
break;
case MSG_DELETE_USER: