break;
case MSG_GET_OTK_PNG:
- if(!isset($msg["username"])) {
+ if(!isset($msg["otk"])) {
msg_send($cl_queue, MSG_GET_OTK_PNG, false);
} else {
- $username = $msg["username"];
- $sql = "select users_otk from users where users_username='$username'";
+ $otk = $msg["otk"];
+ $sql = "select users_username from users where users_otk='$otk'";
$dbo = getDatabase();
$res = $dbo->query($sql);
- $otk = "";
+ $username = "";
foreach($res as $row) {
- $otk = $row["users_otk"];
+ $username = $row["users_username"];
}
- if($otk == "") {
+ if($username == "") {
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);
- unlink("otks/$otk.png");
- $sql = "update users set users_otk='' where users_username='$username'";
- $dbo->query($sql);
+ //unlink("otks/$otk.png");
+ //$sql = "update users set users_otk='' where users_username='$username'";
+ //$dbo->query($sql);
+ error_log("senting otk, fsize: ".filesize("otks/$otk.png")." $otk ");
msg_send($cl_queue, MSG_GET_OTK_PNG, $data);
}
}
return $msg;
}
- function getOtkPng($username) {
+ function getOtkPng($otk) {
global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
$cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
$sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
- $message["username"] = $username;
+ $message["otk"] = $otk;
+ error_log("sending message, $otk");
msg_send($sr_queue, MSG_GET_OTK_PNG, $message, true, true, $msg_err);
msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
if($user["realname"] == "") $realname = "";
else $realname = $user["realname"];
- if($user["haspass"]) $haspass = "Yes <input type=\"password\" name=\"password\"> <a href=\"index.php?action=deletepass&username=$username\">Delete Password</a>";
+ if($user["haspass"]) $haspass = "Yes <input type=\"password\" name=\"password\"> <a href=\"?action=deletepass&username=$username\">Delete Password</a>";
else $haspass = "No <input type=\"password\" name=\"password\">";
if($user["hastoken"]) $hastoken = "Yes";
else $hastoken = "No";
- if($user["otk"]!="") $otk = "<a href=\"index.php?action=getotk&username=$username\">Get</a>";
+ if($user["otk"]!="") $otk = "<a href=\"?action=getotkimg&otk=".$user["otk"]."\">Get</a>";
else $otk = "Already Claimed";
$delete = "<a href=\"?action=delete&username=$username\">Delete</a>";
}
?>
</table><br>
-<form method="post" action="?action=createuser">Create User: <input type="text" name="username"> <input type="submit" value="Create"></form>
+<form method="post" action="?action=createuser">Create User(s) - Enter a comma seperated list of names: <input type="text" name="username" size="120"> <input type="submit" value="Create"></form>
<hr><h2>Radius Clients</h2>
Not yet implemented
if($myAC->authUserPass($username, $password)) {
$_SESSION["loggedin"] = true;
$_SESSION["username"] = $username;
- header("Location: index.php");
+ header("Location: admin.php");
} else {
- header("Location: index.php?message=loginfail");
+ header("Location: admin.php?message=loginfail");
}
exit(0);
case "logout":
$_SESSION["loggedin"] = false;
$_SESSION["username"] = "";
- header("Location: index.php");
+ header("Location: admin.php");
exit(0);
break;
case "createuser":
$username = $_REQUEST["username"];
$myAC->addUser($username);
- header("Location: index.php");
+ header("Location: admin.php");
exit(0);
break;
case "update":
$username = $_REQUEST["username"];
$myAC->setUserPass($username, "");
break;
- case "getotk":
- $username = $_REQUEST["username"];
- $otk = $myAC->getOtkPng($username);
+ case "getotkimg":
+
+ $otk = $_REQUEST["otk"];
+ error_log("requesting otk, $otk");
+ $otk_img = $myAC->getOtkPng($otk);
header("Content-type: image/png");
- echo $otk;
+ echo $otk_img;
exit(0);
break;
}