1 | <? |
---|
2 | require('./conf/config.php'); |
---|
3 | /******************************************************************************************* |
---|
4 | * |
---|
5 | * |
---|
6 | * addUserDB($idLogin) |
---|
7 | * delUserDB($idLogin) |
---|
8 | * addUserCMD($user, $command) |
---|
9 | * selectUserCMD($idLogin) |
---|
10 | * delUserCMD($user, $command) |
---|
11 | * addUserService($user, $service) |
---|
12 | * selectUserService($idLogin) |
---|
13 | * delUserService($user, $service) |
---|
14 | * addUserCMDSwitch($command, $user, $switch) |
---|
15 | * selectUserCMDSwitch($command, $user,$switch) |
---|
16 | * delUserCMDSwitch($command, $user, $switch) |
---|
17 | * |
---|
18 | * |
---|
19 | ********************************************************************************************/ |
---|
20 | |
---|
21 | |
---|
22 | |
---|
23 | |
---|
24 | |
---|
25 | function auth_user($idLogin, $passwdUser) { |
---|
26 | |
---|
27 | |
---|
28 | $resultat = selectUser($idLogin) ; |
---|
29 | |
---|
30 | if ( !is_string($resultat) ) { |
---|
31 | |
---|
32 | while ( $row = mysql_fetch_assoc($resultat) ) { |
---|
33 | |
---|
34 | if ( $row['passwdUser'] == md5($passwdUser) ) { |
---|
35 | return 1; |
---|
36 | }else{ |
---|
37 | $buffer = "Authentification FOR USER $idLogin [FAILED]: error password"; |
---|
38 | return $buffer; |
---|
39 | } |
---|
40 | } |
---|
41 | }else{ |
---|
42 | $buffer = "Authentification FOR USER $idLogin [FAILED]: $resultat"; |
---|
43 | return $buffer; |
---|
44 | } |
---|
45 | |
---|
46 | return "Authentification Web Klask: [FAILED]"; |
---|
47 | } |
---|
48 | |
---|
49 | |
---|
50 | |
---|
51 | |
---|
52 | function addUserDB($idLogin, $passwdUser) { |
---|
53 | //connect DB |
---|
54 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
55 | if (!$link) { |
---|
56 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
57 | return $buffer; |
---|
58 | } |
---|
59 | |
---|
60 | |
---|
61 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
62 | if (!$db_selected) { |
---|
63 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
64 | } |
---|
65 | |
---|
66 | //Check if user exist |
---|
67 | |
---|
68 | if ( ctrlUnixAccount($idLogin) == 0 ) { |
---|
69 | |
---|
70 | $buffer = "L'utilisateur n'existe pas sur dans le fichier /etc/passwd"; |
---|
71 | return $buffer ; |
---|
72 | } |
---|
73 | |
---|
74 | //TODO: to clean |
---|
75 | //md5 du mot de passe; si auth ldap md5 chaine vide |
---|
76 | //echo "LibUser.AddUser " . md5($passwdUser) . " @- md5 saisie ". md5("adm") ." MD5 adm et passwd base ". $row['passwdUser'] ."<BR>"; |
---|
77 | $passwdUser= md5($passwdUser); |
---|
78 | //$sql= "INSERT INTO USER VALUE('$adminApp', '$passwdAdminApp');"; |
---|
79 | |
---|
80 | //Add user |
---|
81 | //echo "libUser.addUser " . $passwdUser ."<BR>"; |
---|
82 | $sql = "INSERT INTO USER VALUE('$idLogin', '$passwdUser');"; |
---|
83 | |
---|
84 | if (mysql_query($sql, $link)) { |
---|
85 | $buffer = 1; |
---|
86 | } else { |
---|
87 | $buffer = "Create USER $idLogin: [FAILED] :" . mysql_error() ; |
---|
88 | } |
---|
89 | |
---|
90 | return $buffer; |
---|
91 | } |
---|
92 | |
---|
93 | |
---|
94 | function selectUser($idLogin) { |
---|
95 | //connect DB |
---|
96 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
97 | if (!$link) { |
---|
98 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
99 | return $buffer; |
---|
100 | } |
---|
101 | |
---|
102 | |
---|
103 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
104 | if (!$db_selected) { |
---|
105 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
106 | } |
---|
107 | |
---|
108 | |
---|
109 | if (empty($idLogin)) { |
---|
110 | $sql = "SELECT * FROM USER"; |
---|
111 | |
---|
112 | }else{ |
---|
113 | $sql = "SELECT * FROM USER WHERE idUser='$idLogin'; "; |
---|
114 | } |
---|
115 | |
---|
116 | |
---|
117 | if ($result = mysql_query($sql, $link)) { |
---|
118 | //test if $return is_array |
---|
119 | return $result ; |
---|
120 | |
---|
121 | } else { |
---|
122 | $buffer = "SELECT USER $idLogin: [FAILED] :" . mysql_error() ; |
---|
123 | return $buffer ; |
---|
124 | } |
---|
125 | |
---|
126 | |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | |
---|
132 | |
---|
133 | |
---|
134 | function delUserDB($idLogin) { |
---|
135 | |
---|
136 | //connect DB |
---|
137 | $buffer = ""; |
---|
138 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
139 | if (!$link) { |
---|
140 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
141 | return $buffer; |
---|
142 | } |
---|
143 | |
---|
144 | |
---|
145 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
146 | if (!$db_selected) { |
---|
147 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
148 | } |
---|
149 | |
---|
150 | if ( $idLogin == $GLOBALS['adminApp'] ) { |
---|
151 | $buffer = "DELETE USER $idLogin : [FAILED] : CAN'T DELETE USER ADMIN APPLICATION"; |
---|
152 | return $buffer ; |
---|
153 | } |
---|
154 | |
---|
155 | //Before del user of Table USER, del user in all others Table |
---|
156 | //Del user from CMDUSER |
---|
157 | $sql = "DELETE FROM CMDUSER WHERE idUser = '$idLogin';"; |
---|
158 | |
---|
159 | if (mysql_query($sql, $link)) { |
---|
160 | $buffer .= "DELETE USER $idLogin FROM TABLE CMDUSER: [OK]<BR />"; |
---|
161 | |
---|
162 | } else { |
---|
163 | $buffer = "DELETE USER $idLogin FROM TABLE CMDUSER: [FAILED] :" . mysql_error() ; |
---|
164 | return $buffer; |
---|
165 | } |
---|
166 | |
---|
167 | |
---|
168 | |
---|
169 | |
---|
170 | //Del user from CMDSWITCH |
---|
171 | $sql = "DELETE FROM CMDSWITCH WHERE idUser = '$idLogin';"; |
---|
172 | |
---|
173 | if (mysql_query($sql, $link)) { |
---|
174 | $buffer .= "DELETE USER $idLogin FROM TABLE CMDSWITCH: [OK]<BR />"; |
---|
175 | } else { |
---|
176 | $buffer = "DELETE USER $idLogin FROM TABLE CMDSWITCH: [FAILED] :" . mysql_error() ; |
---|
177 | return $buffer; |
---|
178 | } |
---|
179 | |
---|
180 | //del user from SERVICEUSER |
---|
181 | $sql = "DELETE FROM SERVICEUSER WHERE idUser = '$idLogin';"; |
---|
182 | |
---|
183 | if (mysql_query($sql, $link)) { |
---|
184 | $buffer .= "DELETE USER $idLogin FROM TABLE SERVICEUSER: [OK]<BR />"; |
---|
185 | } else { |
---|
186 | $buffer = "DELETE USER $idLogin FROM TABLE SERVICEUSER: [FAILED] :" . mysql_error() ; |
---|
187 | return $buffer; |
---|
188 | } |
---|
189 | |
---|
190 | |
---|
191 | //Del user |
---|
192 | $sql = "DELETE FROM USER WHERE idUser = '$idLogin';"; |
---|
193 | |
---|
194 | if (mysql_query($sql, $link)) { |
---|
195 | $buffer .= "DELETE USER $idLogin FROM TABLE USER: [OK] <BR />"; |
---|
196 | } else { |
---|
197 | $buffer = "DELETE USER $idLogin FROM TABLE USER: [FAILED] :" . mysql_error() ; |
---|
198 | return $buffer; |
---|
199 | } |
---|
200 | |
---|
201 | return $buffer; |
---|
202 | } |
---|
203 | |
---|
204 | |
---|
205 | function addUserCMD($user, $command) { |
---|
206 | |
---|
207 | //connect DB |
---|
208 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
209 | if (!$link) { |
---|
210 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
211 | return $buffer; |
---|
212 | } |
---|
213 | |
---|
214 | |
---|
215 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
216 | if (!$db_selected) { |
---|
217 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
218 | } |
---|
219 | |
---|
220 | |
---|
221 | //add power for user in table cmdUser |
---|
222 | $sql = "INSERT INTO CMDUSER VALUE('$command' , '$user' );"; |
---|
223 | |
---|
224 | if (mysql_query($sql, $link)) { |
---|
225 | $buffer = 1; |
---|
226 | } else { |
---|
227 | $buffer = "ADD SERVICE $command FOR $user: [FAILED] :" . mysql_error() ; |
---|
228 | return $buffer; |
---|
229 | } |
---|
230 | |
---|
231 | return $buffer; |
---|
232 | } |
---|
233 | |
---|
234 | |
---|
235 | function selectUserCMD($idLogin, $idPower) { |
---|
236 | |
---|
237 | //connect DB |
---|
238 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
239 | if (!$link) { |
---|
240 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
241 | return $buffer; |
---|
242 | } |
---|
243 | |
---|
244 | |
---|
245 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
246 | if (!$db_selected) { |
---|
247 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
248 | } |
---|
249 | |
---|
250 | |
---|
251 | |
---|
252 | if (empty($idLogin) && empty($idPower) ) { |
---|
253 | $sql = "SELECT * FROM CMDUSER"; |
---|
254 | }else{ |
---|
255 | if ( !empty($idLogin) && empty($idPower) ) { |
---|
256 | $sql = "SELECT * FROM CMDUSER WHERE idUser='$idLogin'; "; |
---|
257 | }else{ |
---|
258 | if ( empty($idService) && !empty($idPower) ) { |
---|
259 | $sql = "SELECT * FROM CMDUSER WHERE idPower='$idPower'; "; |
---|
260 | }else{ |
---|
261 | $sql = "SELECT * FROM CMDUSER WHERE idUser='$idLogin' AND idPower='$idPower'; "; |
---|
262 | } |
---|
263 | } |
---|
264 | } |
---|
265 | |
---|
266 | if ($result = mysql_query($sql, $link)) { |
---|
267 | //test if $return is_array |
---|
268 | return $result ; |
---|
269 | |
---|
270 | } else { |
---|
271 | $buffer = "SELECT POWERFOR USER $idLogin: [FAILED] :" . mysql_error() ; |
---|
272 | return $buffer ; |
---|
273 | } |
---|
274 | |
---|
275 | } |
---|
276 | |
---|
277 | |
---|
278 | function delUserCMD($user, $command) { |
---|
279 | |
---|
280 | //connect DB |
---|
281 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
282 | if (!$link) { |
---|
283 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
284 | return $buffer; |
---|
285 | } |
---|
286 | |
---|
287 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
288 | if (!$db_selected) { |
---|
289 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
290 | } |
---|
291 | |
---|
292 | if ( $user == $GLOBALS['adminApp'] ) { |
---|
293 | $buffer = "DELETE RIGHT FOR $idLogin : [FAILED] : CAN'T DELETE RIGHT FOR USER ADMIN APPLICATION"; |
---|
294 | return $buffer ; |
---|
295 | } |
---|
296 | |
---|
297 | |
---|
298 | //del power for user in table cmdUser |
---|
299 | $sql = "DELETE FROM CMDUSER WHERE idUser='$user' |
---|
300 | AND idPower='$command' ;"; |
---|
301 | |
---|
302 | if (mysql_query($sql, $link)) { |
---|
303 | $buffer =1; |
---|
304 | } else { |
---|
305 | $buffer = "DELETE SERVICE $command FOR $user: [FAILED] :" . mysql_error() ; |
---|
306 | return $buffer; |
---|
307 | } |
---|
308 | |
---|
309 | return $buffer; |
---|
310 | } |
---|
311 | |
---|
312 | function addUserService($user, $service) { |
---|
313 | |
---|
314 | //connect DB |
---|
315 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
316 | if (!$link) { |
---|
317 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
318 | return $buffer; |
---|
319 | } |
---|
320 | |
---|
321 | |
---|
322 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
323 | if (!$db_selected) { |
---|
324 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
325 | } |
---|
326 | |
---|
327 | |
---|
328 | |
---|
329 | //add service for user |
---|
330 | $sql = "INSERT INTO SERVICEUSER VALUE('$user', '$service');"; |
---|
331 | |
---|
332 | if (mysql_query($sql, $link)) { |
---|
333 | $buffer = 1; |
---|
334 | } else { |
---|
335 | $buffer = "ADD SERVICE $service FOR $user: [FAILED] :" . mysql_error() ; |
---|
336 | return $buffer; |
---|
337 | } |
---|
338 | |
---|
339 | return $buffer; |
---|
340 | } |
---|
341 | |
---|
342 | |
---|
343 | function selectUserService($idLogin, $idService) { |
---|
344 | |
---|
345 | //connect DB |
---|
346 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
347 | if (!$link) { |
---|
348 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
349 | return $buffer; |
---|
350 | } |
---|
351 | |
---|
352 | |
---|
353 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
354 | if (!$db_selected) { |
---|
355 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
356 | } |
---|
357 | |
---|
358 | |
---|
359 | |
---|
360 | if (empty($idLogin) && empty($idService) ) { |
---|
361 | $sql = "SELECT * FROM SERVICEUSER"; |
---|
362 | }else{ |
---|
363 | if ( !empty($idLogin) && empty($idService) ) { |
---|
364 | |
---|
365 | $sql = "SELECT * FROM SERVICEUSER WHERE idUser='$idLogin'; "; |
---|
366 | }else{ |
---|
367 | if ( empty($idLogin) && !empty($idService) ) { |
---|
368 | |
---|
369 | $sql = "SELECT * FROM SERVICEUSER WHERE idService='$idService'; "; |
---|
370 | }else{ |
---|
371 | $sql = "SELECT * FROM SERVICEUSER WHERE idService='$idService' AND idUser='$idLogin'; "; |
---|
372 | } |
---|
373 | } |
---|
374 | } |
---|
375 | |
---|
376 | |
---|
377 | if ($result = mysql_query($sql, $link)) { |
---|
378 | //test if $return is_array |
---|
379 | return $result ; |
---|
380 | |
---|
381 | } else { |
---|
382 | $buffer = "SELECT SERVICE FOR USER $idLogin: [FAILED] :" . mysql_error() ; |
---|
383 | return $buffer ; |
---|
384 | } |
---|
385 | |
---|
386 | } |
---|
387 | |
---|
388 | |
---|
389 | |
---|
390 | |
---|
391 | |
---|
392 | |
---|
393 | function delUserService($user, $service) { |
---|
394 | |
---|
395 | //connect DB |
---|
396 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
397 | if (!$link) { |
---|
398 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
399 | return $buffer; |
---|
400 | } |
---|
401 | |
---|
402 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
403 | if (!$db_selected) { |
---|
404 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
405 | } |
---|
406 | |
---|
407 | |
---|
408 | |
---|
409 | |
---|
410 | //del service for user |
---|
411 | $sql = "DELETE FROM SERVICEUSER WHERE idUser='$user' |
---|
412 | AND idService='$service';"; |
---|
413 | |
---|
414 | if (mysql_query($sql, $link)) { |
---|
415 | $buffer = "DELETE SERVICE $service FOR $user: [OK] <BR />"; |
---|
416 | } else { |
---|
417 | $buffer = "DELETE SERVICE $service FOR $user: [FAILED] :" . mysql_error() ; |
---|
418 | return $buffer; |
---|
419 | } |
---|
420 | |
---|
421 | return $buffer; |
---|
422 | } |
---|
423 | |
---|
424 | function addUserCMDSwitch($command, $user, $switch) { |
---|
425 | //connect DB |
---|
426 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
427 | if (!$link) { |
---|
428 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
429 | return $buffer; |
---|
430 | } |
---|
431 | |
---|
432 | |
---|
433 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
434 | if (!$db_selected) { |
---|
435 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
436 | } |
---|
437 | |
---|
438 | |
---|
439 | |
---|
440 | //add power for user for switch |
---|
441 | $sql = "INSERT INTO CMDSWITCH VALUES('$command', '$switch', '$user');"; |
---|
442 | |
---|
443 | if (mysql_query($sql, $link)) { |
---|
444 | $buffer = "ADD POWER $command FOR $user ON $switch: [OK] <BR />"; |
---|
445 | } else { |
---|
446 | $buffer = "ADD POWER $command FOR $user ON $switch: [FAILED] :" . mysql_error() ; |
---|
447 | return $buffer; |
---|
448 | } |
---|
449 | |
---|
450 | return $buffer; |
---|
451 | } |
---|
452 | |
---|
453 | |
---|
454 | function selectUserCMDSwitch($idPower, $idLogin,$idSwitch) { |
---|
455 | |
---|
456 | //connect DB |
---|
457 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
458 | if (!$link) { |
---|
459 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
460 | return $buffer; |
---|
461 | } |
---|
462 | |
---|
463 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
464 | if (!$db_selected) { |
---|
465 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
466 | } |
---|
467 | |
---|
468 | |
---|
469 | if ( empty($idSwitch) && empty($idLogin) && empty($idPower) ) { |
---|
470 | $sql = "SELECT * FROM CMDSWITCH"; |
---|
471 | |
---|
472 | }else{ |
---|
473 | if ( !empty($idSwitch) && !empty($idLogin) && !empty($idPower) ) { |
---|
474 | $sql = "SELECT * FROM CMDSWITCH |
---|
475 | WHERE idSwitch='$idSwitch' |
---|
476 | AND idLogin='$idLogin' |
---|
477 | AND idPower='$command';"; |
---|
478 | }else{ |
---|
479 | if ( !empty($idSwitch) && empty($idLogin) && empty($idPower) ) { |
---|
480 | $sql = "SELECT * FROM SERVICESWITCH |
---|
481 | WHERE idSwitch='$idSwitch';"; |
---|
482 | }else{ |
---|
483 | if ( !empty($idSwitch) && !empty($idLogin) && empty($idPower) ) { |
---|
484 | $sql = "SELECT * FROM SERVICESWITCH |
---|
485 | WHERE idSwitch='$idSwitch' |
---|
486 | AND idLogin='$idLogin';"; |
---|
487 | }else{ |
---|
488 | if ( !empty($idSwitch) && empty($idLogin) && !empty($idPower) ) { |
---|
489 | $sql = "SELECT * FROM SERVICESWITCH |
---|
490 | WHERE idSwitch='$idSwitch' |
---|
491 | AND idPower='$idPower';"; |
---|
492 | }else{ |
---|
493 | if ( !empty($idLogin) && empty($idSwitch) && empty($idPower) ) { |
---|
494 | $sql = "SELECT * FROM SERVICESWITCH |
---|
495 | WHERE idLogin='$idLogin';"; |
---|
496 | }else{ |
---|
497 | if ( !empty($idLogin) && empty($idSwitch) && !empty($idPower) ) { |
---|
498 | $sql = "SELECT * FROM SERVICESWITCH |
---|
499 | WHERE idLogin='$idLogin' |
---|
500 | AND idPower='$idPower';"; |
---|
501 | }else{ |
---|
502 | if ( !empty($idPower) && empty($idLogin) && empty($idSwitch) ) { |
---|
503 | $sql = "SELECT * FROM SERVICESWITCH |
---|
504 | WHERE idPower='$idPower';"; |
---|
505 | } |
---|
506 | } |
---|
507 | } |
---|
508 | } |
---|
509 | } |
---|
510 | } |
---|
511 | } |
---|
512 | } |
---|
513 | |
---|
514 | if (mysql_query($sql, $link)) { |
---|
515 | $buffer = 1 ; |
---|
516 | }else{ |
---|
517 | $buffer = "SELECT SWITCH $idSwitch for SERVICE $idService : [FAILED] :" . mysql_error() ; |
---|
518 | } |
---|
519 | |
---|
520 | } |
---|
521 | |
---|
522 | |
---|
523 | function delUserCMDSwitch($command, $user, $switch) { |
---|
524 | //connect DB |
---|
525 | $link = mysql_connect($GLOBALS['hostDB'], $GLOBALS['userDB'], $GLOBALS['passwdDB']); |
---|
526 | if (!$link) { |
---|
527 | $buffer = "Connexion [FAILED]: " . mysql_error() ; |
---|
528 | return $buffer; |
---|
529 | } |
---|
530 | |
---|
531 | $db_selected = @mysql_select_db($GLOBALS['nameDB'], $link); |
---|
532 | if (!$db_selected) { |
---|
533 | $buffer .= "Impossible de sélectionner la base de données :$nameDB" . mysql_error(); |
---|
534 | } |
---|
535 | |
---|
536 | |
---|
537 | |
---|
538 | //del power for user for switch |
---|
539 | $sql = "DELETE FROM CMDSWITCH VALUES('$command', '$switch', '$user');"; |
---|
540 | |
---|
541 | if (mysql_query($sql, $link)) { |
---|
542 | $buffer = "DELETE POWER $command FOR $user ON $switch: [OK]"; |
---|
543 | } else { |
---|
544 | $buffer = "DELETE POWER $command FOR $user ON $switch: [FAILED] :" . mysql_error() ; |
---|
545 | return $buffer; |
---|
546 | } |
---|
547 | |
---|
548 | return $buffer; |
---|
549 | } |
---|
550 | |
---|
551 | |
---|
552 | ?> |
---|