Example #1
0
 function change_user($db_user, $db_pass, $db_database = '')
 {
     if ($db_database != '') {
         $res = @mysql_change_user($db_user, $db_pass, $db_database, $this->linkid);
     } else {
         $res = @mysql_change_user($db_user, $db_pass, $this->database, $this->linkid);
     }
     if (!$res) {
         return false;
     }
     $this->user = $db_user;
     $this->password = $db_pass;
     if ($db_database != '') {
         $this->database = $db_database;
     }
     return true;
 }
 public function setUser($user = null)
 {
     $user = empty($user) ? null : $user;
     $return = false;
     if (func_num_args() > 1) {
         $this->setPassword(func_get_arg(1));
     }
     if ($user !== $this->getUser()) {
         if ($this->isConnected()) {
             if (!mysql_change_user($user, $this->getPassword(), $this->getDatabase(), $this->getConnection())) {
                 $this->throwException('Could not change users on MySQL connection: ' . $this->error());
             }
         }
         $return = $this->_user = $user;
     }
     return $return;
 }
Example #3
0
 function changeUser($user, $password)
 {
     /* 改变活动连接中登录的用户 */
     return mysql_change_user($user, $password, $this->DBName, $this->LinkId);
 }
}
if (!mysql_select_db($db, $con)) {
    printf("FAILURE: [%d] %s\n", mysql_errno(), mysql_error());
}
$res = mysql_query("SELECT DATABASE() AS db, CURRENT_USER AS user", $con);
if (!$res) {
    printf("FAILURE: [%d] %s\n", mysql_errno(), mysql_error());
}
if ($error = _conv_checkUserAndDB($con, $user, $db, mysql_fetch_assoc($res))) {
    print $error;
} else {
    print "SUCCESS: user and db are correct\n";
}
mysql_free_result($res);
if (function_exists('mysql_change_user')) {
    $ret = mysql_change_user($user_nobody, $pass_nobody, $db, $con);
    if ($ret) {
        print "SUCCESS - mysql_change_user(user, pass, db, con)\n";
    } else {
        print "FAILURE - mysql_change_user(user, pass, db, con)\n";
    }
    $res = mysql_query("SELECT DATABASE() AS db, CURRENT_USER AS user", $con);
    if (!$res) {
        printf("FAILURE: [%d] %s\n", mysql_errno(), mysql_error());
    }
    if ($error = _conv_checkUserAndDB($con, $user_nobody, $db, mysql_fetch_assoc($res))) {
        print $error;
    }
}
mysql_close($con);
?>
Example #5
0
	function ChangeUser($username, $password, $conexao){
		$this->username = $username;
		$this->password = $password;
		$this->conexao  = $conexao;
		return @mysql_change_user($this->username, $this->password, $this->conexao);
	}
Example #6
0
 public function ChangUser($user, $pass, $db = "", $pconnect = false)
 {
     $this->DB_user = $user;
     $this->DB_pass = $pass;
     if (function_exists("mysql_change_user")) {
         if (empty($db)) {
             $result = mysql_change_user($user, $pass);
         } else {
             $result = mysql_change_user($user, $pass, $db);
         }
     } else {
         $this->ReConnect($pconnect, $db);
     }
     return $result;
 }