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 getUsers() {
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);
163 msg_send($sr_queue, MSG_GET_USERS, "", true, true, $msg_err);
164 echo "message sent\n";
166 msg_receive($cl_queue, 0, $msg_type, 524288, $msg);
167 echo "message received?\n";
173 function authUserToken($username, $passcode) {
174 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
177 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
181 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
184 // TODO we need to setup a client queue sem lock here
186 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
187 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
190 $message["username"] = $username;
191 $message["passcode"] = $passcode;
193 msg_send($sr_queue, MSG_AUTH_USER_TOKEN, $message, true, true, $msg_err);
194 echo "message sent\n";
196 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
201 function addUser($username, $tokentype="", $hexkey="") {
202 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
205 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
209 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
213 // TODO we need to setup a client queue sem lock here
215 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
216 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
219 $message["username"] = $username;
220 if($tokentype!="") $message["tokentype"] = $tokentype;
221 if($hexkey!="") $message["hexkey"] = $hexkey;
223 msg_send($sr_queue, MSG_ADD_USER_TOKEN, $message, true, true, $msg_err);
225 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
230 function setTokenType($username, $tokentype) {
231 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
234 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
238 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
242 // TODO we need to setup a client queue sem lock here
244 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
245 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
249 $message["username"] = $username;
250 $message["tokentype"] = $tokentype;
252 msg_send($sr_queue, MSG_ADD_USER, $message, true, true, $msg_err);
253 echo "message sent\n";
255 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
256 echo "message received?\n";