renamed files
authorpaulr <me@pjr.cc>
Mon, 6 Dec 2010 06:12:52 +0000 (17:12 +1100)
committerpaulr <me@pjr.cc>
Mon, 6 Dec 2010 06:12:52 +0000 (17:12 +1100)
authserver/authd/authd.php
authserver/lib/authClient.php
authserver/www/admin.php
authserver/www/admin_actions.php [moved from authserver/www/actions.php with 81% similarity]

index 3a52041..3f723e5 100644 (file)
@@ -50,27 +50,28 @@ if($pid == -1) {
                                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);
                                        }
                                }
index 58de4ec..e1b941f 100644 (file)
@@ -55,7 +55,7 @@ class GAAuthClient {
                return $msg;
        }
        
-       function getOtkPng($username) {
+       function getOtkPng($otk) {
                global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
                
                
@@ -71,7 +71,8 @@ class GAAuthClient {
                $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);
index fa6f6df..b47978f 100644 (file)
@@ -29,13 +29,13 @@ foreach($users as $user) {
        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>";
@@ -45,7 +45,7 @@ foreach($users as $user) {
 } 
 ?>
 </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
similarity index 81%
rename from authserver/www/actions.php
rename to authserver/www/admin_actions.php
index 2d2ca9c..d6a224c 100644 (file)
@@ -17,9 +17,9 @@ if(isset($_REQUEST["action"])) {
                        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);
@@ -27,13 +27,13 @@ if(isset($_REQUEST["action"])) {
                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":
@@ -56,11 +56,13 @@ if(isset($_REQUEST["action"])) {
                        $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;
        }