|
|
@ -255,6 +255,63 @@ class Users{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// createPermissions(array($login));
|
|
|
|
// createPermissions(array($login));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function createUser($values){
|
|
|
|
|
|
|
|
$login = $values["name"];
|
|
|
|
|
|
|
|
$pass = $values["pass"];
|
|
|
|
|
|
|
|
$email = $values["mail"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$webhost = $values["webhost"];
|
|
|
|
|
|
|
|
$webport = $values["webport"];
|
|
|
|
|
|
|
|
$webdbname = $values["webdbname"];
|
|
|
|
|
|
|
|
$webusername = $values["webusername"];
|
|
|
|
|
|
|
|
$webpassword = $values["webpassword"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$shardhost = $values["shardhost"];
|
|
|
|
|
|
|
|
$shardport = $values["shardport"];
|
|
|
|
|
|
|
|
$sharddbname = $values["sharddbname"];
|
|
|
|
|
|
|
|
$shardusername = $values["shardusername"];
|
|
|
|
|
|
|
|
$shardpassword = $values["shardpassword"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$salt = Users::generateSALT();
|
|
|
|
|
|
|
|
$hashpass = crypt($pass, $salt);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
|
|
|
|
$login,
|
|
|
|
|
|
|
|
$hashpass,
|
|
|
|
|
|
|
|
$email
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
//make connection with web db
|
|
|
|
|
|
|
|
$dbw = new PDO("mysql:host=$webhost;port=$webport;dbname=$webdbname", $webusername, $webpassword);
|
|
|
|
|
|
|
|
$dbw->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//put into web db
|
|
|
|
|
|
|
|
$statement = $dbw->prepare("INSERT INTO ams_user (Login, Password, Email) VALUES (?, ?, ?)");
|
|
|
|
|
|
|
|
$statement->execute($params);
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
//make connection with and put into shard db
|
|
|
|
|
|
|
|
$dbs = new PDO("mysql:host=$shardhost;port=$shardport;dbname=$sharddbname", $shardusername, $shardpassword);
|
|
|
|
|
|
|
|
$dbs->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
|
|
|
|
|
|
$statement = $dbs->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)");
|
|
|
|
|
|
|
|
$statement->execute($params);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (PDOException $e) {
|
|
|
|
|
|
|
|
//print_r($e);
|
|
|
|
|
|
|
|
//oh noooz, the shard is offline! Put in query queue at web db!
|
|
|
|
|
|
|
|
$params = array("type" => "createUser","query" => json_encode(array($login,$pass,$email)));
|
|
|
|
|
|
|
|
$statement = $dbw->prepare("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)");
|
|
|
|
|
|
|
|
$statement->execute($params);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}catch (PDOException $e) {
|
|
|
|
|
|
|
|
//go to error page or something, because can't access website db
|
|
|
|
|
|
|
|
print_r($e);
|
|
|
|
|
|
|
|
exit;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|