diff --git a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php index 0a223bc48..e9d4c8748 100644 --- a/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php +++ b/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/sync.php @@ -19,70 +19,71 @@ class Sync{ $pid = pcntl_fork(); } $pidfile = '/tmp/ams_cron_pid'; - if(isset($pid)) { - // We're the main process. - } else { - if(!file_exists($pidfile)) { - $pid = getmypid(); - $file = fopen($pidfile, 'w'); - - fwrite($file, $pid); - fclose($file); - - try { - $dbl = new DBLayer("lib"); - $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache"); - $rows = $statement->fetchAll(); - foreach ($rows as $record) { + + if(isset($pid)) { + // We're the main process. + } else { + if(!file_exists($pidfile)) { + $pid = getmypid(); + $file = fopen($pidfile, 'w'); - $db = new DBLayer($record['db']); - switch($record['type']) { - case 'createPermissions': - $decode = json_decode($record['query']); - $values = array('username' => $decode[0]); - //make connection with and put into shard db & delete from the lib - $sth = $db->execute("SELECT UId FROM user WHERE Login= :username;", $values); - $result = $sth->fetchAll(); - foreach ($result as $UId) { - $ins_values = array('id' => $UId['UId']); - $db->execute("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES (:id, 'r2', 'OPEN');", $ins_values); - $db->execute("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES (:id , 'ryzom_open', 'OPEN');", $ins_values); - } - break; - case 'change_pass': - $decode = json_decode($record['query']); - $values = array('user' => $decode[0], 'pass' => $decode[1]); - //make connection with and put into shard db & delete from the lib - $db->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values); - break; - case 'change_mail': - $decode = json_decode($record['query']); - $values = array('user' => $decode[0], 'mail' => $decode[1]); - //make connection with and put into shard db & delete from the lib - $db->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values); - break; - case 'createUser': - $decode = json_decode($record['query']); - $values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] ); - //make connection with and put into shard db & delete from the lib - $db->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values); - break; + fwrite($file, $pid); + fclose($file); + + try { + $dbl = new DBLayer("lib"); + $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache"); + $rows = $statement->fetchAll(); + foreach ($rows as $record) { + + $db = new DBLayer($record['db']); + switch($record['type']) { + case 'createPermissions': + $decode = json_decode($record['query']); + $values = array('username' => $decode[0]); + //make connection with and put into shard db & delete from the lib + $sth = $db->execute("SELECT UId FROM user WHERE Login= :username;", $values); + $result = $sth->fetchAll(); + foreach ($result as $UId) { + $ins_values = array('id' => $UId['UId']); + $db->execute("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES (:id, 'r2', 'OPEN');", $ins_values); + $db->execute("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES (:id , 'ryzom_open', 'OPEN');", $ins_values); + } + break; + case 'change_pass': + $decode = json_decode($record['query']); + $values = array('user' => $decode[0], 'pass' => $decode[1]); + //make connection with and put into shard db & delete from the lib + $db->execute("UPDATE user SET Password = :pass WHERE Login = :user",$values); + break; + case 'change_mail': + $decode = json_decode($record['query']); + $values = array('user' => $decode[0], 'mail' => $decode[1]); + //make connection with and put into shard db & delete from the lib + $db->execute("UPDATE user SET Email = :mail WHERE Login = :user",$values); + break; + case 'createUser': + $decode = json_decode($record['query']); + $values = array('login' => $decode[0], 'pass' => $decode[1], 'mail' => $decode[2] ); + //make connection with and put into shard db & delete from the lib + $db->execute("INSERT INTO user (Login, Password, Email) VALUES (:login, :pass, :mail)",$values); + break; + } + $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); + } + if ($display == true) { + print('Syncing completed'); } - $dbl->execute("DELETE FROM ams_querycache WHERE SID=:SID",array('SID' => $record['SID'])); - } - if ($display == true) { - print('Syncing completed'); } - } - catch (PDOException $e) { - if ($display == true) { - print('Something went wrong! The shard is probably still offline!'); - print_r($e); + catch (PDOException $e) { + if ($display == true) { + print('Something went wrong! The shard is probably still offline!'); + print_r($e); + } } + unlink($pidfile); } - unlink($pidfile); - } - } + } } } diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php index dadf4cc5e..d30d9714f 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/ryzommanage/autoload/webusers.php @@ -185,7 +185,7 @@ class WebUsers extends Users{ * check if the user is logged in. * @return true or false */ - public function isLoggedIn(){ + public static function isLoggedIn(){ if(isset($_SESSION['user'])){ return true; } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php index cd6d38ed3..621bb0e06 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/autoload/webusers.php @@ -215,7 +215,7 @@ class WebUsers extends Users{ * check if the user is logged in. * @return true or false */ - public function isLoggedIn(){ + public static function isLoggedIn(){ if(isset($_SESSION['user'])){ return true; } diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php index 6d3265b28..17bc62985 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php +++ b/code/ryzom/tools/server/ryzom_ams/www/html/inc/show_queue.php @@ -82,7 +82,11 @@ function show_queue(){ case "create_queue": $userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT); - $groupid = filter_var($_POST['groupid'], FILTER_SANITIZE_NUMBER_INT); + if (isset($_POST['groupid'])) { + $groupid = filter_var($_POST['groupid'], FILTER_SANITIZE_NUMBER_INT); + } else { + $groupid = 0; + } $what = filter_var($_POST['what'], FILTER_SANITIZE_STRING); $how = filter_var($_POST['how'], FILTER_SANITIZE_STRING); $who = filter_var($_POST['who'], FILTER_SANITIZE_STRING); diff --git a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl index 6cb2069fa..5c8c9c31a 100644 --- a/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl +++ b/code/ryzom/tools/server/ryzom_ams/www/html/templates/show_queue.tpl @@ -16,29 +16,29 @@
Show tickets to - + - +