Syncing basics, need refactoring though
This commit is contained in:
parent
24587c1d6e
commit
229f76c3e8
3 changed files with 73 additions and 2 deletions
65
code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php
Normal file
65
code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
class Sync{
|
||||
|
||||
/**
|
||||
*
|
||||
* Function syncdata
|
||||
*
|
||||
* @takes Nothing
|
||||
* @return array $values
|
||||
*
|
||||
* Info: Runs functions to finish syncing data when shard is offline
|
||||
*
|
||||
*/
|
||||
static public function syncdata () {
|
||||
|
||||
global $LIBDBHOST;
|
||||
global $LIBDBPORT;
|
||||
global $LIBDBNAME;
|
||||
global $LIBDBUSERNAME;
|
||||
global $LIBDBPASSWORD;
|
||||
|
||||
global $SHARDDBHOST;
|
||||
global $SHARDDBPORT;
|
||||
global $SHARDDBNAME;
|
||||
global $SHARDDBUSERNAME;
|
||||
global $SHARDDBPASSWORD;
|
||||
|
||||
try {
|
||||
$dbl = new PDO("mysql:host=$LIBDBHOST;port=$LIBDBPORT;dbname=$LIBDBNAME", $LIBDBUSERNAME, $LIBDBPASSWORD);
|
||||
$dbl->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$statement = $dbl->prepare("SELECT * FROM ams_querycache");
|
||||
$statement->execute();
|
||||
$rows = $statement->fetchAll();
|
||||
|
||||
$dbs = new PDO("mysql:host=$SHARDDBHOST;port=$SHARDDBPORT;dbname=$SHARDDBNAME", $SHARDDBUSERNAME, $SHARDDBPASSWORD);
|
||||
$dbs->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
foreach ($rows as $record) {
|
||||
|
||||
switch($record['type']) {
|
||||
case 'createPermissions':
|
||||
case 'user_edit':
|
||||
case 'createUser':
|
||||
$query = json_decode($record['query']);
|
||||
//make connection with and put into shard db
|
||||
$statement = $dbs->prepare("INSERT INTO user (Login, Password, Email) VALUES (?, ?, ?)");
|
||||
$statement->execute($query);
|
||||
|
||||
$statement = $dbl->prepare("DELETE FROM ams_querycache WHERE SID=:SID");
|
||||
$query = array('SID' => $record['SID']);
|
||||
$statement->execute($query);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
print('Syncing completed');
|
||||
}
|
||||
catch (PDOException $e) {
|
||||
print('Something went wrong!');
|
||||
print_r($e);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -236,7 +236,7 @@ class Users{
|
|||
return $salt;
|
||||
}
|
||||
|
||||
function create_Server_User($params)
|
||||
/*function create_Server_User($params)
|
||||
{
|
||||
try {
|
||||
$hostname = 'localhost';
|
||||
|
@ -254,7 +254,7 @@ class Users{
|
|||
return "fail";
|
||||
}
|
||||
// createPermissions(array($login));
|
||||
}
|
||||
}*/
|
||||
|
||||
function createUser($values){
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
|
||||
require( '../libinclude.php' );
|
||||
require( '../../www/config.php' );
|
||||
|
||||
Sync::syncdata();
|
Loading…
Reference in a new issue