Merged in botanic/rc-botanic-webdev/rc-botanic-webdev (pull request #33)

fixed php warnings and errors
This commit is contained in:
Matthew Lagoe 2013-10-23 18:08:15 -07:00
commit 9ee6e5e4eb
5 changed files with 81 additions and 76 deletions

View file

@ -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;
}
$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);
}
}
unlink($pidfile);
}
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');
}
}
catch (PDOException $e) {
if ($display == true) {
print('Something went wrong! The shard is probably still offline!');
print_r($e);
}
}
unlink($pidfile);
}
}
}
}

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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);

View file

@ -16,29 +16,29 @@
<form id="create_queue" class="form-vertical" method="post" action="index.php?page=show_queue&get=create" style="margin:0px 0px 0px;">
Show
<select style="width: 136px;" name="what">
<option value="all" {if $prev_created_what eq "all"}selected="selected"{/if}>all</option>
<option value="waiting_for_support" {if $prev_created_what eq "waiting_for_support"}selected="selected"{/if}>waiting for support</option>
<option value="waiting_for_users" {if $prev_created_what eq "waiting_for_users"}selected="selected"{/if}>waiting for user</option>
<option value="closed" {if $prev_created_what eq "closed"}selected="selected"{/if}>closed</option>
<option value="all" {if isset($prev_created_what) eq "all"}selected="selected"{/if}>all</option>
<option value="waiting_for_support" {if isset($prev_created_what) eq "waiting_for_support"}selected="selected"{/if}>waiting for support</option>
<option value="waiting_for_users" {if isset($prev_created_what) eq "waiting_for_users"}selected="selected"{/if}>waiting for user</option>
<option value="closed" {if isset($prev_created_what) eq "closed"}selected="selected"{/if}>closed</option>
</select>
tickets
<select style="width: 110px;" name="how">
<option value="assigned" {if $prev_created_how eq "assigned"}selected="selected"{/if}>assigned</option>
<option value="not_assigned" {if $prev_created_how eq "not_assigned"}selected="selected"{/if}>not assigned</option>
<option value="assigned" {if isset($prev_created_how) eq "assigned"}selected="selected"{/if}>assigned</option>
<option value="not_assigned" {if isset($prev_created_how) eq "not_assigned"}selected="selected"{/if}>not assigned</option>
</select>
to
<select style="width: 140px;" name="who" onchange="aimedforwhochanged(this.value);">
<option value="user" {if $prev_created_who eq "user"}selected="selected"{/if}>user</option>
<option value="support_group" {if $prev_created_who eq "support_group"}selected="selected"{/if}>support group</option>
<option value="user" {if isset($prev_created_who) eq "user"}selected="selected"{/if}>user</option>
<option value="support_group" {if isset($prev_created_who) eq "support_group"}selected="selected"{/if}>support group</option>
</select>
<span id="userList" {if $prev_created_who eq "user"}style="display:inline;"{else if $prev_created_who eq "support_group"}style="display:none;"{else}style="display:inline;"{/if}>
<span id="userList" {if isset($prev_created_who) eq "user"}style="display:inline;"{else if isset($prev_created_who) eq "support_group"}style="display:none;"{else}style="display:inline;"{/if}>
<select style="width: 140px;" name="userid">
{foreach from=$teamlist item=member}
<option value="{$member.tUserId}" {if isset($prev_created_userid)} {if $prev_created_userid eq $member.tUserId}selected="selected"{/if}{else if $user_id eq $member.tUserId}selected="selected"{/if}>{$member.name}</option>
{/foreach}
</select>
</span>
<span id="supportGroupList" {if $prev_created_who eq "user"}style="display:none;"{else if $prev_created_who eq "support_group"}style="display:inline;"{else}style="display:none;"{/if}>
<span id="supportGroupList" {if isset($prev_created_who) eq "user"}style="display:none;"{else if isset($prev_created_who) eq "support_group"}style="display:inline;"{else}style="display:none;"{/if}>
<select style="width: 140px;" name="groupid">
{foreach from=$grouplist item=group}
<option value="{$group.sGroupId}" {if $prev_created_groupid eq $group.sGroupId}selected="selected"{/if}>{$group.name}</option>