global $myga;
msg_send($cl_queue, MSG_DELETE_USER, $myga->deleteUser($username));
}
+ break;
case MSG_AUTH_USER_PASSWORD:
// TODO
echo "Call to auth user pass\n";
msg_send($cl_queue, MSG_SET_USER_TOKEN_TYPE, $myga->setTokenType($username, $tokentype));
// TODO now set token
- break;
+ break;
+ case MSG_GET_USERS:
+ // TODO this needs to be better
+ $sql = "select * from users";
+
+ $dbo = getDatabase();
+ $res = $dbo->query($sql);
+
+ $users = "";
+ $i = 0;
+ foreach($res as $row) {
+ $users[$i]["username"] = $row["users_username"];
+ $users[$i]["realname"] = $row["users_realname"];
+ if($row["users_password"]!="") {
+ $users[$i]["haspass"] = true;
+ } else {
+ $users[$i]["haspass"] = false;
+ }
+ echo "user: ".$users[$i]["username"]." has tdata: \"".$row["users_tokendata"]."\"\n";
+ if($row["users_tokendata"]!="") {
+ $users[$i]["hastoken"] = true;
+ } else {
+ $users[$i]["hastoken"] = false;
+ }
+ $i++;
+ }
+ msg_send($cl_queue, GET_USERS, $users);
+
+ // TODO now set token
+ break;
}
}
}
+ function getUsers() {
+ global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
+
+
+ if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
+ return false;
+ }
+
+ if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
+ return false;
+ }
+ // TODO we need to setup a client queue sem lock here
+
+ $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
+ $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
+
+ msg_send($sr_queue, MSG_GET_USERS, "", true, true, $msg_err);
+ echo "message sent\n";
+
+ msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
+ echo "message received?\n";
+ print_r($msg);
+
+ return $msg;
+ }
+
function authUserToken($username, $passcode) {
global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
define("MSG_SET_USER_REALNAME", 6);
define("MSG_SET_USER_TOKEN", 7);
define("MSG_SET_USER_TOKEN_TYPE", 8);
+define("MSG_GET_USERS", 9);
if(file_exists("../../lib/ga4php.php")) require_once("../../lib/ga4php.php");
if(file_exists("../lib/ga4php.php")) require_once("../lib/ga4php.php");
echo "\tsetname: setname <username> <realname> - sets the real name for a user\n";
echo "\tsettoken: settoken <username> <tokenkey> - sets the key (hex) for a token\n";
echo "\tsettype: settype <username> <tokentype> - sets a token type for a user\n";
+ echo "\tgetusers: getusers - gets a list of users\n";
return 0;
}
case "settype":
$myAC->setUserTokenType($argv[2], $argv[3]);
break;
+ case "getusers":
+ $myAC->getUsers();
+ break;
}
?>
\ No newline at end of file
// the function used inside the class to put the data into the
// datastore using the overloaded data saving class
function internalPutData($username, $data) {
- $enco = base64_encode(serialize($data));
+ if($data == "") $enco = "";
+ else $enco = base64_encode(serialize($data));
return $this->putData($username, $enco);
}
// self explanitory?
function deleteUser($username) {
// oh, we need to figure out how to do thi?
- $data = $this->internalGetData($username);
- $data["tokenkey"] = "";
- $this->internalPutData($username);
+ $this->internalPutData($username, "");
}
// user has input their user name and some code, authenticate