mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-11-30 07:35:59 +00:00
added db parameter to the syncing
This commit is contained in:
parent
e4d6228055
commit
3c2b2ef53d
4 changed files with 16 additions and 17 deletions
|
@ -18,33 +18,31 @@ class Sync{
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
$statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache");
|
$statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache");
|
||||||
$rows = $statement->fetchAll();
|
$rows = $statement->fetchAll();
|
||||||
$dbs = new DBLayer("shard");
|
|
||||||
foreach ($rows as $record) {
|
foreach ($rows as $record) {
|
||||||
|
|
||||||
|
$db = new DBLayer($record['db']);
|
||||||
switch($record['type']) {
|
switch($record['type']) {
|
||||||
case 'createPermissions':
|
case 'createPermissions':
|
||||||
case 'change_pass':
|
case 'change_pass':
|
||||||
$decode = json_decode($record['query']);
|
$decode = json_decode($record['query']);
|
||||||
$values = array('user' => $decode[0], 'pass' => $decode[1]);
|
$values = array('user' => $decode[0], 'pass' => $decode[1]);
|
||||||
//make connection with and put into shard db & delete from the lib
|
//make connection with and put into shard db & delete from the lib
|
||||||
$dbs->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values);
|
$db->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values);
|
||||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
|
||||||
break;
|
break;
|
||||||
case 'change_mail':
|
case 'change_mail':
|
||||||
$decode = json_decode($record['query']);
|
$decode = json_decode($record['query']);
|
||||||
$values = array('user' => $decode[0], 'mail' => $decode[1]);
|
$values = array('user' => $decode[0], 'mail' => $decode[1]);
|
||||||
//make connection with and put into shard db & delete from the lib
|
//make connection with and put into shard db & delete from the lib
|
||||||
$dbs->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values);
|
$db->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values);
|
||||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
|
||||||
break;
|
break;
|
||||||
case 'createUser':
|
case 'createUser':
|
||||||
$decode = json_decode($record['query']);
|
$decode = json_decode($record['query']);
|
||||||
$values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] );
|
$values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] );
|
||||||
//make connection with and put into shard db & delete from the lib
|
//make connection with and put into shard db & delete from the lib
|
||||||
$dbs->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values);
|
$db->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values);
|
||||||
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
$dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID']));
|
||||||
}
|
}
|
||||||
print('Syncing completed');
|
print('Syncing completed');
|
||||||
}
|
}
|
||||||
|
|
|
@ -296,8 +296,8 @@ class Users{
|
||||||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||||
try {
|
try {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "createUser",
|
$dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "createUser",
|
||||||
"query" => json_encode(array($values["name"],$values["pass"],$values["mail"]))));
|
"query" => json_encode(array($values["name"],$values["pass"],$values["mail"])), "db" => "shard"));
|
||||||
ticket_user::createTicketUser( $user_id , 1 );
|
ticket_user::createTicketUser( $user_id , 1 );
|
||||||
return "shardoffline";
|
return "shardoffline";
|
||||||
}catch (PDOException $e) {
|
}catch (PDOException $e) {
|
||||||
|
@ -380,8 +380,8 @@ class Users{
|
||||||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||||
try {
|
try {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_pass",
|
$dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "change_pass",
|
||||||
"query" => json_encode(array($values["user"],$values["pass"]))));
|
"query" => json_encode(array($values["user"],$values["pass"])), "db" => "shard"));
|
||||||
return "shardoffline";
|
return "shardoffline";
|
||||||
}catch (PDOException $e) {
|
}catch (PDOException $e) {
|
||||||
return "liboffline";
|
return "liboffline";
|
||||||
|
@ -403,8 +403,8 @@ class Users{
|
||||||
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
//oh noooz, the shard is offline! Put in query queue at ams_lib db!
|
||||||
try {
|
try {
|
||||||
$dbl = new DBLayer("lib");
|
$dbl = new DBLayer("lib");
|
||||||
$dbl->execute("INSERT INTO ams_querycache (type, query) VALUES (:type, :query)",array("type" => "change_mail",
|
$dbl->execute("INSERT INTO ams_querycache (type, query, db) VALUES (:type, :query, :db)",array("type" => "change_mail",
|
||||||
"query" => json_encode(array($values["user"],$values["mail"]))));
|
"query" => json_encode(array($values["user"],$values["mail"])), "db" => "shard"));
|
||||||
return "shardoffline";
|
return "shardoffline";
|
||||||
}catch (PDOException $e) {
|
}catch (PDOException $e) {
|
||||||
return "liboffline";
|
return "liboffline";
|
||||||
|
|
|
@ -19,7 +19,7 @@ $cfg['db']['lib']['name'] = 'ryzom_ams_lib';
|
||||||
$cfg['db']['lib']['user'] = 'shard';
|
$cfg['db']['lib']['user'] = 'shard';
|
||||||
$cfg['db']['lib']['pass'] = '';
|
$cfg['db']['lib']['pass'] = '';
|
||||||
|
|
||||||
$cfg['db']['shard']['host'] = 'localhosti';
|
$cfg['db']['shard']['host'] = 'localhost';
|
||||||
$cfg['db']['shard']['port'] = '3306';
|
$cfg['db']['shard']['port'] = '3306';
|
||||||
$cfg['db']['shard']['name'] = 'nel';
|
$cfg['db']['shard']['name'] = 'nel';
|
||||||
$cfg['db']['shard']['user'] = 'shard';
|
$cfg['db']['shard']['user'] = 'shard';
|
||||||
|
|
|
@ -42,7 +42,8 @@
|
||||||
CREATE TABLE ams_querycache (
|
CREATE TABLE ams_querycache (
|
||||||
`SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
`SID` INT NOT NULL AUTO_INCREMENT PRIMARY KEY ,
|
||||||
`type` VARCHAR( 64 ) NOT NULL ,
|
`type` VARCHAR( 64 ) NOT NULL ,
|
||||||
`query` VARCHAR( 512 ) NOT NULL
|
`query` VARCHAR( 512 ) NOT NULL,
|
||||||
|
`db` VARCHAR( 80 ) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue