mirror of
https://port.numenaute.org/aleajactaest/khanat-code-old.git
synced 2024-11-27 09:16:18 +00:00
Register seems to work :) Next step permissions and login
This commit is contained in:
parent
6f7cf4c1ed
commit
b0889ebc4b
3 changed files with 97 additions and 44 deletions
|
@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,10 +5,20 @@
|
||||||
// Variables for database access
|
// Variables for database access
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
// where we can find the mysql database
|
// where we can find the mysql database
|
||||||
$DBHOST = 'localhost' ;
|
|
||||||
$DBNAME = 'nel' ;
|
$WEBDBHOST = 'localhost';
|
||||||
$DBUSERNAME = 'shard' ;
|
$WEBDBPORT = '3306';
|
||||||
$DBPASSWORD = '' ;
|
$WEBDBNAME = 'ryzom_ams';
|
||||||
|
$WEBDBUSERNAME = 'shard';
|
||||||
|
$WEBDBPASSWORD = '' ;
|
||||||
|
|
||||||
|
$SHARDDBHOST = 'localhost' ;
|
||||||
|
$SHARDDBPORT = '3306';
|
||||||
|
$SHARDDBNAME = 'nel' ;
|
||||||
|
$SHARDDBUSERNAME = 'shard' ;
|
||||||
|
$SHARDDBPASSWORD = '' ;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// If true= the server will add automatically unknown user in the database
|
// If true= the server will add automatically unknown user in the database
|
||||||
// (in nel.user= nel.permission= ring.ring_user and ring.characters
|
// (in nel.user= nel.permission= ring.ring_user and ring.characters
|
||||||
|
|
|
@ -31,50 +31,36 @@ function add_user(){
|
||||||
|
|
||||||
|
|
||||||
function write_user($newUser){
|
function write_user($newUser){
|
||||||
$login = $newUser["name"];
|
global $WEBDBHOST;
|
||||||
$pass = $newUser["pass"];
|
global $WEBDBPORT;
|
||||||
$email = $newUser["mail"];
|
global $WEBDBNAME;
|
||||||
|
global $WEBDBUSERNAME;
|
||||||
|
global $WEBDBPASSWORD;
|
||||||
|
global $SHARDDBHOST;
|
||||||
|
global $SHARDDBPORT;
|
||||||
|
global $SHARDDBNAME;
|
||||||
|
global $SHARDDBUSERNAME;
|
||||||
|
global $SHARDDBPASSWORD;
|
||||||
|
|
||||||
|
$values["name"] = $newUser["name"];
|
||||||
|
$values["pass"] = $newUser["pass"];
|
||||||
|
$values["mail"] = $newUser["mail"];
|
||||||
|
|
||||||
|
$values["webhost"] = $WEBDBHOST;
|
||||||
|
$values["webport"] = $WEBDBPORT;
|
||||||
|
$values["webdbname"] = $WEBDBNAME;
|
||||||
|
$values["webusername"] = $WEBDBUSERNAME;
|
||||||
|
$values["webpassword"] = $WEBDBPASSWORD ;
|
||||||
|
|
||||||
$salt = Users::generateSALT();
|
$values["shardhost"] = $SHARDDBHOST;
|
||||||
$hashpass = crypt($pass, $salt);
|
$values["shardport"] = $SHARDDBPORT;
|
||||||
|
$values["sharddbname"] = $SHARDDBNAME;
|
||||||
$params = array(
|
$values["shardusername"] = $SHARDDBUSERNAME;
|
||||||
$login,
|
$values["shardpassword"] = $SHARDDBPASSWORD;
|
||||||
$hashpass,
|
|
||||||
$email
|
|
||||||
);
|
|
||||||
|
|
||||||
$result = Users :: create_Server_User($params);
|
|
||||||
//test purpose
|
|
||||||
$result = "fail";
|
|
||||||
|
|
||||||
$hostname = 'localhost';
|
$result = Users :: createUser($values);
|
||||||
$port = '3306';
|
|
||||||
$dbname = 'ryzom_ams';
|
|
||||||
$username = 'shard';
|
|
||||||
$password = '';
|
|
||||||
|
|
||||||
$dbh = new PDO("mysql:host=$hostname;port=$port;dbname=$dbname", $username, $password);
|
|
||||||
$dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
|
||||||
try {
|
|
||||||
$statement = $dbh->prepare("INSERT INTO ams_user (Login, Password, Email) VALUES (?, ?, ?)");
|
|
||||||
$statement->execute($params);
|
|
||||||
|
|
||||||
if($result == "fail"){
|
|
||||||
print('so far');
|
|
||||||
$params = array("type" => "createUser","query" => json_encode(array($login,$pass,$email)));
|
|
||||||
$statement = $dbh->prepare("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)");
|
|
||||||
$statement->execute($params);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (PDOException $e) {
|
|
||||||
//go to error page or something
|
|
||||||
print_r($e);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// add user locally here
|
|
||||||
print('Awesome');
|
print('Awesome');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue