Ignore:
Timestamp:
05/18/11 22:39:42 (3 years ago)
Author:
fufroma
Message:

Bon $dbu était utilisé a qques endroits, je renomme mon objet pour être sur

File:
1 edited

Legend:

Unmodified
Added
Removed
  • alternc/trunk/bureau/class/m_mysql.php

    r2943 r2944  
    8989// TODO BUG BUG BUG 
    9090// c'est pas étanche : $db se retrouve avec Database de $sql->dbu . Danger, faut comprendre pourquoi 
    91     $this->Database = "alternc"; 
     91// Si on veux que ca marche, il faut Database=alternc. 
     92    $this->Database = "mysql"; 
    9293    $this->HumanHostname = $human_hostname; 
    9394 
     
    9798 
    9899class m_mysql { 
    99   var $dbu; 
     100  var $dbus; 
    100101 
    101102  /*---------------------------------------------------------------------------*/ 
     
    104105  */ 
    105106  function m_mysql() { 
    106     $this->dbu = new DBU_mysql(); 
     107    $this->dbus = new DBU_mysql(); 
    107108  } 
    108109 
     
    218219      $pa=addslashes($db->f("pass")); 
    219220    } 
    220     if ($this->dbu->query("CREATE DATABASE `$dbname`;")) { 
     221    if ($this->dbus->query("CREATE DATABASE `$dbname`;")) { 
    221222      // Ok, database does not exist, quota is ok and dbname is compliant. Let's proceed 
    222223      $db->query("INSERT INTO db (uid,login,pass,db,bck_mode) VALUES ('$cuid','$lo','$pa','$dbname',0);"); 
    223224      // give everything but GRANT on db.* 
    224225      // we assume there's already a user 
    225       $this->dbu->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$lo."'@'$this->client'"); 
     226      $this->dbus->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$lo."'@'$this->client'"); 
    226227      return true; 
    227228    } else { 
     
    253254    // Ok, database exists and dbname is compliant. Let's proceed 
    254255    $db->query("DELETE FROM db WHERE uid='$cuid' AND db='$dbname';"); 
    255     $this->dbu->query("DROP DATABASE `$dbname`;"); 
     256    $this->dbus->query("DROP DATABASE `$dbname`;"); 
    256257    $db->query("SELECT COUNT(*) AS cnt FROM db WHERE uid='$cuid';"); 
    257258    $db->next_record(); 
    258     $this->dbu->query("REVOKE ALL PRIVILEGES ON `".$dbname."`.* FROM '".$login."'@'$this->client'"); 
    259     if ($this->dbu->f("cnt")==0) { 
    260       $this->dbu->query("DELETE FROM mysql.user WHERE User='".$login."';"); 
    261       $this->dbu->query("FLUSH PRIVILEGES;"); 
     259    $this->dbus->query("REVOKE ALL PRIVILEGES ON `".$dbname."`.* FROM '".$login."'@'$this->client'"); 
     260    if ($this->dbus->f("cnt")==0) { 
     261      $this->dbus->query("DELETE FROM mysql.user WHERE User='".$login."';"); 
     262      $this->dbus->query("FLUSH PRIVILEGES;"); 
    262263    } 
    263264    return true; 
     
    343344    // Update all the "pass" fields for this user :  
    344345    $db->query("UPDATE db SET pass='$password' WHERE uid='$cuid';"); 
    345     $this->dbu->query("SET PASSWORD FOR '$login'@'$this->client' = PASSWORD('$password')"); 
     346    $this->dbus->query("SET PASSWORD FOR '$login'@'$this->client' = PASSWORD('$password')"); 
    346347    return true; 
    347348  } 
     
    388389    $db->query("INSERT INTO db (uid,login,pass,db) VALUES ('$cuid','".$login."','$password','".$dbname."');"); 
    389390    // give everything but GRANT on $user.* 
    390     $this->dbu->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$login."'@'$this->client' IDENTIFIED BY '".addslashes($password)."'"); 
    391     $this->dbu->query("CREATE DATABASE `".$dbname."`;"); 
     391    $this->dbus->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$login."'@'$this->client' IDENTIFIED BY '".addslashes($password)."'"); 
     392    $this->dbus->query("CREATE DATABASE `".$dbname."`;"); 
    392393    return true; 
    393394  } 
     
    444445    global $db,$err; 
    445446     
    446     $this->dbu->query("SHOW TABLE STATUS FROM `$dbname`;"); 
     447    $this->dbus->query("SHOW TABLE STATUS FROM `$dbname`;"); 
    447448    $size = 0; 
    448449    while ($db->next_record()) { 
     
    530531 
    531532    // We create the user account (the "file" right is the only one we need globally to be able to use load data into outfile) 
    532     $this->dbu->query("GRANT file ON *.* TO '$user'@'$this->client' IDENTIFIED BY '$pass';"); 
     533    $this->dbus->query("GRANT file ON *.* TO '$user'@'$this->client' IDENTIFIED BY '$pass';"); 
    533534    // We add him to the user table  
    534535    $db->query("INSERT INTO dbusers (uid,name) VALUES($cuid,'$user');"); 
     
    563564    } 
    564565 
    565     $this->dbu->query("SET PASSWORD FOR '$user'@'$this->client' = PASSWORD('$pass')"); 
     566    $this->dbus->query("SET PASSWORD FOR '$user'@'$this->client' = PASSWORD('$pass')"); 
    566567    return true; 
    567568  } 
     
    591592 
    592593    // Ok, database exists and dbname is compliant. Let's proceed 
    593     $this->dbu->query("REVOKE ALL PRIVILEGES ON *.* FROM '".$mem->user["login"]."_$user'@'$this->client';"); 
    594     $this->dbu->query("DELETE FROM mysql.db WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
    595     $this->dbu->query("DELETE FROM mysql.user WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
    596     $this->dbu->query("FLUSH PRIVILEGES"); 
    597     $this->dbu->query("DELETE FROM dbusers WHERE uid='$cuid' AND name='".$mem->user["login"]."_$user';"); 
     594    $this->dbus->query("REVOKE ALL PRIVILEGES ON *.* FROM '".$mem->user["login"]."_$user'@'$this->client';"); 
     595    $this->dbus->query("DELETE FROM mysql.db WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
     596    $this->dbus->query("DELETE FROM mysql.user WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';"); 
     597    $this->dbus->query("FLUSH PRIVILEGES"); 
     598    $this->dbus->query("DELETE FROM dbusers WHERE uid='$cuid' AND name='".$mem->user["login"]."_$user';"); 
    598599    return true; 
    599600  } 
     
    614615 
    615616    for ( $i=0 ; $i<count($dblist) ; $i++ ) { 
    616       $this->dbu->query("SELECT Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv FROM mysql.db WHERE User='".$mem->user["login"].($user?"_":"").$user."' AND Host='$this->client' AND Db='".$dblist[$i]["db"]."';"); 
    617       if ($this->dbu->next_record()) 
    618         $r[]=array("db"=>$dblist[$i]["name"], "select"=>$this->dbu->f("Select_priv"), "insert"=>$this->dbu->f("Insert_priv"),   "update"=>$this->dbu->f("Update_priv"), "delete"=>$this->dbu->f("Delete_priv"), "create"=>$this->dbu->f("Create_priv"), "drop"=>$this->dbu->f("Drop_priv"), "references"=>$this->dbu->f("References_priv"), "index"=>$this->dbu->f("Index_priv"), "alter"=>$this->dbu->f("Alter_priv"), "create_tmp"=>$this->dbu->f("Create_tmp_table_priv"), "lock"=>$this->dbu->f("Lock_tables_priv")); 
     617      $this->dbus->query("SELECT Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv FROM mysql.db WHERE User='".$mem->user["login"].($user?"_":"").$user."' AND Host='$this->client' AND Db='".$dblist[$i]["db"]."';"); 
     618      if ($this->dbus->next_record()) 
     619        $r[]=array("db"=>$dblist[$i]["name"], "select"=>$this->dbus->f("Select_priv"), "insert"=>$this->dbus->f("Insert_priv"), "update"=>$this->dbus->f("Update_priv"), "delete"=>$this->dbus->f("Delete_priv"), "create"=>$this->dbus->f("Create_priv"), "drop"=>$this->dbus->f("Drop_priv"), "references"=>$this->dbus->f("References_priv"), "index"=>$this->dbus->f("Index_priv"), "alter"=>$this->dbus->f("Alter_priv"), "create_tmp"=>$this->dbus->f("Create_tmp_table_priv"), "lock"=>$this->dbus->f("Lock_tables_priv")); 
    619620      else 
    620621        $r[]=array("db"=>$dblist[$i]["name"], "select"=>"N", "insert"=>"N", "update"=>"N", "delete"=>"N", "create"=>"N", "drop"=>"N", "references"=>"N", "index"=>"N", "alter"=>"N", "Create_tmp"=>"N", "lock"=>"N" ); 
     
    678679 
    679680    // We reset all user rights on this DB :  
    680     $this->dbu->query("SELECT * FROM mysql.db WHERE User = '$usern' AND Db = '$dbname';"); 
    681     if($this->dbu->num_rows()) 
    682       $this->dbu->query("REVOKE ALL PRIVILEGES ON $dbname.* FROM '$usern'@'$this->client';"); 
     681    $this->dbus->query("SELECT * FROM mysql.db WHERE User = '$usern' AND Db = '$dbname';"); 
     682    if($this->dbus->num_rows()) 
     683      $this->dbus->query("REVOKE ALL PRIVILEGES ON $dbname.* FROM '$usern'@'$this->client';"); 
    683684    if( $strrights ){ 
    684685      $strrights=substr($strrights,0,strlen($strrights)-1); 
    685       $this->dbu->query("GRANT $strrights ON $dbname.* TO '$usern'@'$this->client';");       
    686     } 
    687     $this->dbu->query("FLUSH PRIVILEGES"); 
     686      $this->dbus->query("GRANT $strrights ON $dbname.* TO '$usern'@'$this->client';");       
     687    } 
     688    $this->dbus->query("FLUSH PRIVILEGES"); 
    688689    return TRUE; 
    689690  } 
Note: See TracChangeset for help on using the changeset viewer.