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);
23 $message["username"] = $username;
24 $message["token"] = $token;
26 msg_send($sr_queue, MSG_SET_USER_TOKEN, $message, true, true, $msg_err);
27 echo "message sent\n";
29 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
30 echo "message received?\n";
36 function setUserPass($username, $password) {
37 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
40 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
44 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
47 // TODO we need to setup a client queue sem lock here
49 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
50 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
52 $message["username"] = $username;
53 $message["password"] = $password;
55 msg_send($sr_queue, MSG_SET_USER_PASSWORD, $message, true, true, $msg_err);
56 echo "message sent\n";
58 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
59 echo "message received?\n";
64 function authUserPass($username, $password) {
65 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
68 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
72 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
75 // TODO we need to setup a client queue sem lock here
77 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
78 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
80 $message["username"] = $username;
81 $message["password"] = $password;
83 msg_send($sr_queue, MSG_AUTH_USER_PASSWORD, $message, true, true, $msg_err);
84 echo "message sent\n";
86 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
87 echo "message received?\n";
92 function deleteUser($username) {
93 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
96 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
100 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
103 // TODO we need to setup a client queue sem lock here
105 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
106 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
108 $message["username"] = $username;
110 msg_send($sr_queue, MSG_DELETE_USER, $message, true, true, $msg_err);
111 echo "message sent\n";
113 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
114 echo "message received?\n";
119 function setUserRealName($username, $realname) {
120 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
123 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
127 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
130 // TODO we need to setup a client queue sem lock here
132 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
133 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
135 $message["username"] = $username;
136 $message["realname"] = $realname;
138 msg_send($sr_queue, MSG_SET_USER_REALNAME, $message, true, true, $msg_err);
139 echo "message sent\n";
141 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
142 echo "message received?\n";
147 function authUserToken($username, $passcode) {
148 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
151 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
155 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
158 // TODO we need to setup a client queue sem lock here
160 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
161 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
164 $message["username"] = $username;
165 $message["passcode"] = $passcode;
167 msg_send($sr_queue, MSG_AUTH_USER, $message, true, true, $msg_err);
168 echo "message sent\n";
170 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
171 echo "message received?\n";
177 function addUser($username) {
178 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
181 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
185 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
189 // TODO we need to setup a client queue sem lock here
191 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
192 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
195 $message["username"] = $username;
197 msg_send($sr_queue, MSG_ADD_USER_TOKEN, $message, true, true, $msg_err);
198 echo "message sent\n";
200 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
201 echo "message received?\n";
208 function setTokenType($username, $tokentype) {
209 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
212 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
216 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
220 // TODO we need to setup a client queue sem lock here
222 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
223 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
227 $message["username"] = $username;
228 $message["tokentype"] = $tokentype;
230 msg_send($sr_queue, MSG_ADD_USER, $message, true, true, $msg_err);
231 echo "message sent\n";
233 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
234 echo "message received?\n";