Changeset 2616 for alternc/trunk/bureau/class/m_mysql.php
- Timestamp:
- 11/30/09 07:01:34 (4 years ago)
- File:
-
- 1 edited
-
alternc/trunk/bureau/class/m_mysql.php (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
alternc/trunk/bureau/class/m_mysql.php
r2615 r2616 63 63 */ 64 64 function alternc_password_policy() { 65 return array("mysql _users"=>"MySQL users");65 return array("mysql"=>"MySQL users"); 66 66 } 67 67 … … 252 252 */ 253 253 function put_mysql_details($password) { 254 global $db,$err,$mem,$cuid ;254 global $db,$err,$mem,$cuid,$admin; 255 255 $err->log("mysql","put_mysql_details"); 256 256 $db->query("SELECT * FROM db WHERE uid='$cuid';"); … … 266 266 return false; 267 267 } 268 269 // Check this password against the password policy using common API : 270 if (is_callable(array($admin,"checkPolicy"))) { 271 if (!$admin->checkPolicy("mysql",$login,$password)) { 272 return false; // The error has been raised by checkPolicy() 273 } 274 } 275 268 276 // Update all the "pass" fields for this user : 269 277 $db->query("UPDATE db SET pass='$password' WHERE uid='$cuid';"); … … 278 286 */ 279 287 function new_mysql($password) { 280 global $db,$err,$mem,$cuid ;288 global $db,$err,$mem,$cuid,$admin; 281 289 $err->log("mysql","new_mysql"); 282 290 if (strlen($password)>16) { … … 291 299 $login=$mem->user["login"]; 292 300 $dbname=$mem->user["login"]; 301 302 // Check this password against the password policy using common API : 303 if (is_callable(array($admin,"checkPolicy"))) { 304 if (!$admin->checkPolicy("mysql",$login,$password)) { 305 return false; // The error has been raised by checkPolicy() 306 } 307 } 308 293 309 // OK, creation now... 294 310 $db->query("INSERT INTO db (uid,login,pass,db) VALUES ('$cuid','".$login."','$password','".$dbname."');"); … … 457 473 } 458 474 475 476 /* ------------------------------------------------------------ */ 477 /** 478 * Create a new user in MySQL rights tables 479 * @param $usern the username (we will add _[alternc-account] to it) 480 * @param $password The password for this username 481 * @param $passconf The password confirmation 482 * @return TRUE if the user has been created in MySQL or FALSE if an error occurred 483 **/ 459 484 function add_user($usern,$password,$passconf) { 460 global $db,$err,$quota,$mem,$cuid ;485 global $db,$err,$quota,$mem,$cuid,$admin; 461 486 $err->log("mysql","add_user",$usern); 462 487 … … 487 512 } 488 513 514 // Check this password against the password policy using common API : 515 if (is_callable(array($admin,"checkPolicy"))) { 516 if (!$admin->checkPolicy("mysql",$user,$password)) { 517 return false; // The error has been raised by checkPolicy() 518 } 519 } 489 520 490 521 // We create the user account (the "file" right is the only one we need globally to be able to use load data into outfile) … … 495 526 } 496 527 528 529 530 /* ------------------------------------------------------------ */ 531 /** 532 * Delete a new user in MySQL rights tables 533 * @param $user the username (we will add _[alternc-account] to it) to delete 534 * @return TRUE if the user has been deleted in MySQL or FALSE if an error occurred 535 **/ 497 536 function del_user($user) { 498 537 global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE; … … 519 558 } 520 559 560 561 /* ------------------------------------------------------------ */ 562 /** 563 * Return the list of the database rights of user $user 564 * @param $user the username 565 * @return array An array of database name and rights 566 **/ 521 567 function get_user_dblist($user) { 522 568 global $db,$err,$mem,$cuid,$L_MYSQL_DATABASE; … … 537 583 } 538 584 585 586 587 /* ------------------------------------------------------------ */ 588 /** 589 * Set the access rights of user $user to database $dbn to be rights $rights 590 * @param $user the username to give rights to 591 * @param $dbn The database to give rights to 592 * @param $rights The rights as an array of MySQL keywords (insert, select ...) 593 * @return boolean TRUE if the rights has been applied or FALSE if an error occurred 594 * 595 **/ 539 596 function set_user_rights($user,$dbn,$rights) { 540 597 global $mem, $db; … … 581 638 } 582 639 583 584 // On remet à zéro tous les droits de l'utilisateur 640 // We reset all user rights on this DB : 585 641 $db->query("SELECT * FROM mysql.db WHERE User = '$usern' AND Db = '$dbname';"); 586 642 if($db->num_rows()) … … 594 650 } 595 651 652 653 596 654 } /* Class m_mysql */ 597 655
Note: See TracChangeset
for help on using the changeset viewer.
