Exemplo n.º 1
0
 /**
  * Returns a db_name -> dbInfo array
  * 
  * @return array
  */
 function getDbList()
 {
     $returnArray = array();
     $this->db->query("SELECT login,pass,db, bck_mode, bck_dir FROM db ORDER BY db;");
     if ($this->db->num_rows()) {
         while ($this->db->next_record()) {
             $db = $this->db->f("db");
             list($dbu, $dbn) = split_mysql_database_name($db);
             $returnArray[$db] = array("user" => $dbu, "bck_mode" => $this->db->f("bck_mode"), "bck_dir" => $this->db->f("bck_dir"), "login" => $this->db->f("login"), "pass" => $this->db->f("pass"));
         }
     }
     return $returnArray;
 }
Exemplo n.º 2
0
 /** Returns the details of a user's database.
  * $dbn is the name of the database (after the _) or nothing for the database "$user"
  * @return string returns an associative array as follow : 
  *  "db" => Name of the database 
  *  "bck" => Current bckup mode 
  *  "dir" => Backup directory
  *  "size" => Size of the database (in bytes)
  *  "pass" => Password of the user
  *  "history" => Number of backup we keep
  *  "gzip" => Does we compress the dumps ?
  *  Returns FALSE if the user has no database of if the database does not exist.
  */
 function get_mysql_details($dbn)
 {
     global $db, $err, $bro, $mem, $cuid;
     $root = getuserpath();
     $err->log("mysql", "get_mysql_details");
     $pos = strpos($dbn, '_');
     if ($pos === false) {
         $dbname = $dbn;
     } else {
         $dbncomp = explode('_', $dbn);
         $dbname = $dbn;
         $dbn = $dbncomp[1];
     }
     $size = $this->get_db_size($dbname);
     $db->query("SELECT login,pass,db, bck_mode, bck_gzip, bck_dir, bck_history FROM db WHERE uid='{$cuid}' AND db='{$dbname}';");
     if (!$db->num_rows()) {
         $err->raise("mysql", _("Database %s not found"), $dbn);
         return array("enabled" => false);
     }
     $db->next_record();
     list($dbu, $dbn) = split_mysql_database_name($db->f("db"));
     return array("enabled" => true, "login" => $db->f("login"), "db" => $db->f("db"), "name" => $dbn, "bck" => $db->f("bck_mode"), "dir" => substr($db->f("bck_dir"), strlen($root)), "size" => $size, "pass" => $db->f("pass"), "history" => $db->f("bck_history"), "gzip" => $db->f("bck_gzip"));
 }