3 require_once("lib.php");
7 function setUserToken($username, $token) {
8 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
11 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
15 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
18 // TODO we need to setup a client queue sem lock here
20 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
21 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
25 function setUserPass($username, $password) {
26 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
29 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
33 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
36 // TODO we need to setup a client queue sem lock here
38 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
39 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
43 function authUserPass($username, $password) {
44 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
47 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
51 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
54 // TODO we need to setup a client queue sem lock here
56 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
57 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
61 function deleteUser($username) {
62 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
65 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
69 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
72 // TODO we need to setup a client queue sem lock here
74 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
75 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
79 function setUserRealName($username, $realname) {
80 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
83 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
87 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
90 // TODO we need to setup a client queue sem lock here
92 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
93 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
97 function authUserToken($username, $passcode) {
98 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
101 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
105 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
108 // TODO we need to setup a client queue sem lock here
110 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
111 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
114 $message["user"] = $username;
115 $message["passcode"] = $passcode;
117 msg_send($sr_queue, MSG_AUTH_USER, $message, true, true, $msg_err);
118 echo "message sent\n";
120 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
121 echo "message received?\n";
127 function addUser($username) {
128 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
131 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
135 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
139 // TODO we need to setup a client queue sem lock here
141 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
142 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
145 $message["username"] = $username;
147 msg_send($sr_queue, MSG_ADD_USER, $message, true, true, $msg_err);
148 echo "message sent\n";
150 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
151 echo "message received?\n";
158 function setTokenType($username, $tokentype) {
159 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
162 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
166 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
170 // TODO we need to setup a client queue sem lock here
172 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
173 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
176 $message["username"] = $username;