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["tokenstring"] = $token;
26 msg_send($sr_queue, MSG_SET_USER_TOKEN, $message, true, true, $msg_err);
28 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
32 function setUserPass($username, $password) {
33 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
36 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
40 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
43 // TODO we need to setup a client queue sem lock here
45 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
46 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
48 $message["username"] = $username;
49 $message["password"] = $password;
51 msg_send($sr_queue, MSG_SET_USER_PASSWORD, $message, true, true, $msg_err);
53 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
58 function getOtkPng($username) {
59 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
62 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
66 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
69 // TODO we need to setup a client queue sem lock here
71 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
72 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
74 $message["username"] = $username;
75 msg_send($sr_queue, MSG_GET_OTK_PNG, $message, true, true, $msg_err);
77 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
83 function authUserPass($username, $password) {
84 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
87 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
91 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
94 // TODO we need to setup a client queue sem lock here
96 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
97 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
99 $message["username"] = $username;
100 $message["password"] = $password;
102 msg_send($sr_queue, MSG_AUTH_USER_PASSWORD, $message, true, true, $msg_err);
104 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
108 function deleteUser($username) {
109 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
112 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
116 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
119 // TODO we need to setup a client queue sem lock here
121 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
122 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
124 $message["username"] = $username;
126 msg_send($sr_queue, MSG_DELETE_USER, $message, true, true, $msg_err);
128 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
134 function setUserRealName($username, $realname) {
135 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
138 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
142 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
145 // TODO we need to setup a client queue sem lock here
147 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
148 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
150 $message["username"] = $username;
151 $message["realname"] = $realname;
153 msg_send($sr_queue, MSG_SET_USER_REALNAME, $message, true, true, $msg_err);
155 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
159 function getUsers() {
160 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
163 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
167 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);
175 msg_send($sr_queue, MSG_GET_USERS, "", true, true, $msg_err);
177 msg_receive($cl_queue, 0, $msg_type, 524288, $msg);
182 function authUserToken($username, $passcode) {
183 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
186 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
190 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
193 // TODO we need to setup a client queue sem lock here
195 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
196 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
199 $message["username"] = $username;
200 $message["passcode"] = $passcode;
202 msg_send($sr_queue, MSG_AUTH_USER_TOKEN, $message, true, true, $msg_err);
203 echo "message sent\n";
205 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
210 function addUser($username, $tokentype="", $hexkey="") {
211 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
214 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
218 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
222 // TODO we need to setup a client queue sem lock here
224 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
225 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
228 $message["username"] = $username;
229 if($tokentype!="") $message["tokentype"] = $tokentype;
230 if($hexkey!="") $message["hexkey"] = $hexkey;
232 msg_send($sr_queue, MSG_ADD_USER_TOKEN, $message, true, true, $msg_err);
234 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);
239 function setUserTokenType($username, $tokentype) {
240 global $MSG_QUEUE_KEY_ID_SERVER, $MSG_QUEUE_KEY_ID_CLIENT;
243 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_SERVER)) {
247 if(!msg_queue_exists($MSG_QUEUE_KEY_ID_CLIENT)) {
251 // TODO we need to setup a client queue sem lock here
253 $cl_queue = msg_get_queue($MSG_QUEUE_KEY_ID_CLIENT);
254 $sr_queue = msg_get_queue($MSG_QUEUE_KEY_ID_SERVER);
258 $message["username"] = $username;
259 $message["tokentype"] = $tokentype;
261 msg_send($sr_queue, MSG_SET_USER_TOKEN_TYPE, $message, true, true, $msg_err);
263 msg_receive($cl_queue, 0, $msg_type, 16384, $msg);