Die, don't exit

This commit is contained in:
kaetemi 2014-09-03 07:06:43 +02:00
parent 6d98bb0493
commit 50a3791553
44 changed files with 579 additions and 581 deletions

View file

@ -827,4 +827,4 @@ class Smarty_Internal_Utility {
}
?>
?>

View file

@ -4,14 +4,14 @@
* This can be done by providing id using $_GET global variable of the plugin which
* we want to activate. After getting id we update the respective plugin with status
* activate which here means '1' .
*
* @author Shubham Meena, mentored by Matthew Lagoe
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function activate_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to activate
@ -22,20 +22,20 @@ function activate_plugin() {
{
// if result is successfull it redirects and shows success message
header( "Location: index.php?page=plugins&result=3" );
exit;
}
die();
}
else
{
//if result is unsuccessfull it redirects and throws error
//if result is unsuccessfull it redirects and throws error
header( "Location: index.php?page=plugins&result=4" );
exit;
}
}
die();
}
}
else
{
//if $_GET variable is not set it redirects and shows error
header( "Location: index.php?page=plugins&result=4" );
exit;
}
}
die();
}
}
}

View file

@ -9,7 +9,7 @@ function add_sgroup(){
global $INGAME_WEBPATH;
global $WEBPATH;
if(WebUsers::isLoggedIn()){
//check if admin
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
@ -20,7 +20,7 @@ function add_sgroup(){
$imap_mailserver = filter_var($_POST['IMAP_MailServer'], FILTER_SANITIZE_STRING);
$imap_username = filter_var($_POST['IMAP_Username'], FILTER_SANITIZE_STRING);
$imap_password = filter_var($_POST['IMAP_Password'], FILTER_SANITIZE_STRING);
//create a new support group
$result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password);
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
@ -41,12 +41,12 @@ function add_sgroup(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}

View file

@ -11,7 +11,7 @@ function add_user(){
global $INGAME_WEBPATH;
$params = Array('Username' => $_POST["Username"], 'Password' => $_POST["Password"], 'ConfirmPass' => $_POST["ConfirmPass"], 'Email' => $_POST["Email"]);
$webUser = new WebUsers();
//check if the POST variables are valid, before actual registering
$result = $webUser->check_Register($params);
@ -30,14 +30,14 @@ function add_user(){
if(Helpers::check_if_game_client()){
//if registering ingame then we have to set the header and dont need to reload the template.
header('Location: email_sent.php');
exit;
die();
}
$pageElements['status'] = $status;
$pageElements['no_visible_elements'] = 'TRUE';
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;
helpers :: loadtemplate( 'register_feedback', $pageElements);
exit;
}elseif ($_POST['page']=="settings"){
die();
}elseif (isset($_POST['page']) && $_POST['page']=="settings"){
// pass error and reload template accordingly
$result['prevUsername'] = $_POST["Username"];
$result['prevPassword'] = $_POST["Password"];
@ -45,7 +45,7 @@ function add_user(){
$result['prevEmail'] = $_POST["Email"];
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'settings', $result);
exit;
die();
}else{
// pass error and reload template accordingly
$result['prevUsername'] = $_POST["Username"];
@ -55,37 +55,35 @@ function add_user(){
$result['no_visible_elements'] = 'TRUE';
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;
helpers :: loadtemplate( 'register', $result);
exit;
die();
}
}
//use the valid userdata to create the new user.
function write_user($newUser){
//create salt here, because we want it to be the same on the web/server
$hashpass = crypt($newUser["pass"], WebUsers::generateSALT());
$params = array(
'Login' => $newUser["name"],
'Password' => $hashpass,
'Email' => $newUser["mail"]
'Email' => $newUser["mail"]
);
try{
//make new webuser
$user_id = WebUsers::createWebuser($params['Login'], $params['Password'], $params['Email']);
//Create the user on the shard + in case shard is offline put copy of query in query db
//returns: ok, shardoffline or liboffline
$result = WebUsers::createUser($params, $user_id);
Users::createPermissions(array($newUser["name"]));
}catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
exit;
die();
}
return $result;
}

View file

@ -9,7 +9,7 @@ function add_user_to_sgroup(){
global $INGAME_WEBPATH;
global $WEBPATH;
if(WebUsers::isLoggedIn()){
//check if the that executed the task is an admin.
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user'])) && isset($_POST['target_id'])){
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING);
@ -24,7 +24,7 @@ function add_user_to_sgroup(){
//return error message.
$result['RESULT_OF_ADDING'] = "NOT_MOD_OR_ADMIN";
}
}else{
$result['RESULT_OF_ADDING'] = "USER_NOT_EXISTING";
}
@ -40,18 +40,18 @@ function add_user_to_sgroup(){
}else{
header("Location: ".$WEBPATH."?page=show_sgroup&id=".$id);
}
exit;
die();
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -7,14 +7,14 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_info(){
try{
//if logged in
if(WebUsers::isLoggedIn()){
if(isset($_POST['target_id'])){
// check if the user who executed this function is the person of whom the information is or if it's a mod/admin.
// check if the user who executed this function is the person of whom the information is or if it's a mod/admin.
if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) ) ){
if($_POST['target_id'] == $_SESSION['id']){
//if the info is of the executing user himself
@ -24,21 +24,21 @@ function change_info(){
$webUser = new WebUsers($_POST['target_id']);
$target_username = $webUser->getUsername();
}
$webUser = new WebUsers($_POST['target_id']);
//use current info to check for changes
$current_info = $webUser->getInfo();
$current_info['FirstName'] = filter_var($current_info['FirstName'], FILTER_SANITIZE_STRING);
$current_info['LastName'] = filter_var($current_info['LastName'], FILTER_SANITIZE_STRING);
$current_info['Country'] = filter_var($current_info['Country'], FILTER_SANITIZE_STRING);
$current_info['Gender'] = filter_var($current_info['Gender'], FILTER_SANITIZE_NUMBER_INT);
$updated = false;
$values = Array();
$values['user'] = $target_username;
//make the query that will update the data.
$query = "UPDATE ams_user SET ";
if(($_POST['FirstName'] != "") && ($_POST['FirstName'] != $current_info['FirstName'])){
@ -72,7 +72,7 @@ function change_info(){
}
$updated = true;
$values['gender'] = filter_var($_POST['Gender'], FILTER_SANITIZE_NUMBER_INT);
}
}
//finish the query!
$query = $query . "WHERE Login = :user";
@ -80,7 +80,7 @@ function change_info(){
if($updated){
//execute the query in the web DB.
$dbw = new DBLayer("web");
$dbw->execute($query,$values);
$dbw->execute($query,$values);
}
//reload the settings inc function before recalling the settings template.
@ -97,29 +97,29 @@ function change_info(){
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
helpers :: loadtemplate( 'settings', $result);
exit;
die();
}else{
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: The form was not filled in correclty
header("Location: index.php?page=settings");
exit;
}
die();
}
}else{
//ERROR: user is not logged in
header("Location: index.php");
exit;
die();
}
}catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
exit;
}
die();
}
}

View file

@ -7,13 +7,13 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_mail(){
try{
//if logged in
if(WebUsers::isLoggedIn()){
if(isset($_POST['target_id'])){
//check if the user who executed this function is the person of whom the emailaddress is or if it's a mod/admin.
if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
if($_POST['target_id'] == $_SESSION['id']){
@ -24,22 +24,22 @@ function change_mail(){
$webUser = new WebUsers($_POST['target_id']);
$target_username = $webUser->getUsername();
}
$webUser = new WebUsers($_POST['target_id']);
//check if emailaddress is valid.
$reply = $webUser->checkEmail($_POST['NewEmail']);
global $SITEBASE;
require_once($SITEBASE . '/inc/settings.php');
$result = settings();
if ( $reply != "success" ){
$result['EMAIL_ERROR'] = 'TRUE';
}else{
$result['EMAIL_ERROR'] = 'FALSE';
}
$result['prevNewEmail'] = filter_var($_POST["NewEmail"], FILTER_SANITIZE_EMAIL);
if ($reply== "success"){
//if validation was successful, update the emailaddress
$status = WebUsers::setEmail($target_username, filter_var($_POST["NewEmail"], FILTER_SANITIZE_EMAIL) );
@ -58,8 +58,8 @@ function change_mail(){
}
}
helpers :: loadtemplate( 'settings', $result);
exit;
die();
}else{
$result['EMAIL'] = $reply;
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
@ -72,32 +72,32 @@ function change_mail(){
}
}
helpers :: loadtemplate( 'settings', $result);
exit;
die();
}
}else{
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: The form was not filled in correclty
header("Location: index.php?page=settings");
exit;
}
die();
}
}else{
//ERROR: user is not logged in
header("Location: index.php");
exit;
die();
}
}catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
exit;
die();
}
}

View file

@ -7,11 +7,11 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_password(){
try{
//if logged in
if(WebUsers::isLoggedIn()){
if(isset($_POST['target_id'])){
$adminChangesOther = false;
//if target_id is the same as session id or is admin
@ -27,7 +27,7 @@ function change_password(){
$adminChangesOther = true;
$_POST["CurrentPass"] = "dummypass";
}
$webUser = new WebUsers($_POST['target_id']);
$params = Array( 'user' => $target_username, 'CurrentPass' => $_POST["CurrentPass"], 'NewPass' => $_POST["NewPass"], 'ConfirmNewPass' => $_POST["ConfirmNewPass"], 'adminChangesOther' => $adminChangesOther);
$result = $webUser->check_change_password($params);
@ -47,10 +47,10 @@ function change_password(){
$succresult['username'] = $_SESSION['user'];
$succresult['target_id'] = $_POST['target_id'];
helpers :: loadtemplate( 'settings', $succresult);
exit;
die();
}else{
$result['prevCurrentPass'] = filter_var($_POST["CurrentPass"], FILTER_SANITIZE_STRING);
$result['prevNewPass'] = filter_var($_POST["NewPass"], FILTER_SANITIZE_STRING);
$result['prevConfirmNewPass'] = filter_var($_POST["ConfirmNewPass"], FILTER_SANITIZE_STRING);
@ -62,35 +62,35 @@ function change_password(){
global $SITEBASE;
require_once($SITEBASE . '/inc/settings.php');
$settings = settings();
$result = array_merge($result,$settings);
helpers :: loadtemplate( 'settings', $result);
exit;
die();
}
}else{
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: The form was not filled in correclty
header("Location: index.php?page=settings");
exit;
}
die();
}
}else{
//ERROR: user is not logged in
header("Location: index.php");
exit;
die();
}
}catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
exit;
die();
}
}

View file

@ -6,15 +6,15 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function change_receivemail(){
try{
//if logged in
global $INGAME_WEBPATH;
global $WEBPATH;
if(WebUsers::isLoggedIn()){
if(isset($_POST['target_id'])){
//check if the user who executed this function is the person of whom the setting is or if it's a mod/admin.
if( ( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) && isset($_POST['ReceiveMail']) ){
$user_id = filter_var($_POST['target_id'], FILTER_SANITIZE_NUMBER_INT);
@ -27,32 +27,32 @@ function change_receivemail(){
}else{
header("Location: ".$WEBPATH."?page=settings&id=".$user_id);
}
exit;
die();
}else{
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: The form was not filled in correclty
header("Location: index.php?page=settings");
exit;
}
die();
}
}else{
//ERROR: user is not logged in
header("Location: index.php");
exit;
die();
}
}catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
exit;
die();
}
}

View file

@ -10,12 +10,12 @@ function create_ticket(){
global $INGAME_WEBPATH;
global $WEBPATH;
if(WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])){
if(isset($_POST['target_id'])){
//if target_id is the same as session id or is admin
if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
$category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT);
$title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING);
$content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING);
@ -35,33 +35,33 @@ function create_ticket(){
}else{
header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id);
}
exit;
die();
}catch (PDOException $e) {
//ERROR: LIB DB is not online!
print_r($e);
exit;
die();
header("Location: index.php");
exit;
die();
}
}else{
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: The form was not filled in correclty
header("Location: index.php?page=create_ticket");
exit;
}
die();
}
}else{
//ERROR: user is not logged in
header("Location: index.php");
exit;
}
die();
}
}

View file

@ -4,15 +4,15 @@
* This can be done by providing id using $_GET global variable of the plugin which
* we want to activate. After getting id we update the respective plugin with status
* deactivate which here means '0'.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function deactivate_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to deactivate
@ -20,24 +20,24 @@ function deactivate_plugin() {
$db = new DBLayer( 'lib' );
$result = $db -> update( "plugins", array( 'Status' => '0' ), "Id = $id" );
if ( $result )
{
// if result is successfull it redirects and shows success message
{
// if result is successfull it redirects and shows success message
header( "Location: index.php?page=plugins&result=5" );
exit;
}
die();
}
else
{
// if result is unsuccessfull it redirects and shows success message
// if result is unsuccessfull it redirects and shows success message
header( "Location: index.php?page=plugins&result=6" );
exit;
}
}
die();
}
}
else
{
//if $_GET variable is not set it redirects and shows error
//if $_GET variable is not set it redirects and shows error
header( "Location: index.php?page=plugins&result=6" );
exit;
}
}
die();
}
}
}

View file

@ -3,49 +3,49 @@
* This function is used in deleting plugins.
* It removes the plugin from the codebase as well as
* from the Database. When user request to delete a plugin
* id of that plugin is sent in $_GET global variable.
*
* @author Shubham Meena, mentored by Matthew Lagoe
* id of that plugin is sent in $_GET global variable.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function delete_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to delete after filtering
$id = filter_var( $_GET['id'], FILTER_SANITIZE_FULL_SPECIAL_CHARS );
$db = new DBLayer( 'lib' );
$sth = $db -> selectWithParameter( "FileName", "plugins", array( 'id' => $id ), "Id=:id" );
$name = $sth -> fetch();
if ( is_dir( "$name[FileName]" ) )
{
// removing plugin directory from the code base
if ( Plugincache::rrmdir( "$name[FileName]" ) )
{
$db -> delete( 'plugins', array( 'id' => $id ), "Id=:id" );
//if result successfull redirect and show success message
header( "Location: index.php?page=plugins&result=2" );
exit;
}
die();
}
else
{
// if result unsuccessfull redirect and show error message
// if result unsuccessfull redirect and show error message
header( "Location: index.php?page=plugins&result=0" );
exit;
}
}
}
die();
}
}
}
else
{
// if result unsuccessfull redirect and show error message
// if result unsuccessfull redirect and show error message
header( "Location: index.php?page=plugins&result=0" );
exit;
}
}
}
die();
}
}
}

View file

@ -1,9 +1,9 @@
<?php
function forgot_password(){
$email = filter_var($_POST["Email"], FILTER_SANITIZE_EMAIL);
$target_id = WebUsers::getIdFromEmail($email);
if ($target_id == "FALSE"){
//the email address doesn't exist.
@ -11,27 +11,27 @@ function forgot_password(){
$result['EMAIL_ERROR'] = 'TRUE';
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'forgot_password', $result);
exit;
die();
}
$webUser = new WebUsers($target_id);
$target_username = $webUser->getUsername();
$target_hashedPass = $webUser->getHashedPass();
$hashed_key = hash('sha512',$target_hashedPass);
if ( isset( $_COOKIE['Language'] ) ) {
if ( isset( $_COOKIE['Language'] ) ) {
$lang = $_COOKIE['Language'];
}else{
global $DEFAULT_LANGUAGE;
$lang = $DEFAULT_LANGUAGE;
}
global $AMS_TRANS;
$variables = parse_ini_file( $AMS_TRANS . '/' . $lang . '.ini', true );
$mailText = array();
foreach ( $variables['email'] as $key => $value ){
$mailText[$key] = $value;
}
//create the reset url
global $WEBPATH;
$resetURL = $WEBPATH . "?page=reset_password&user=". $target_username . "&email=" . $email . "&key=" . $hashed_key;
@ -44,7 +44,7 @@ function forgot_password(){
$result['prevEmail'] = $email;
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'forgot_password', $result);
exit;
die();
}
}

View file

@ -3,11 +3,11 @@
/**
* This module contains the function to install plugins
* or check if the uploaded file is an update for a plugin.
*
*
* When user uploads a file with .zip extension(neccessary requirement)
* steps that should perform:
* steps that should perform:
* --> Check if the file type is .zip.
* --> Extract it to a temp folder.
* --> Extract it to a temp folder.
* --> Check for the .info file. If not exists throw error
* --> Extract the information from the .info file.
* --> Check for the plugin name already exists or not.
@ -16,35 +16,35 @@
* --> if UpdateInfo not found throw error.
* --> if UpdateInfo found add the update to the ryzom_ams_lib.updates table.
* --> if it's not an update and plugin with same name already exists throw error.
* --> if plugin with same name not present provide option to install plugin
*
* --> if plugin with same name not present provide option to install plugin
*
* @author Shubham Meena, mentored by Matthew Lagoe
*
*/
*
*/
/**
* This function is used in installing plugins or adding updates
* for previously installed plugins.
*
*
*/
function install_plugin() {
$result = array();
// if logged in
if ( WebUsers :: isLoggedIn() ) {
// path of temporary folder for storing files
$temp_path = "../../ams_lib/temp";
// create a temp directory if not exist
// temp folder where we first store all uploaded plugins before install
if ( !file_exists( "$temp_path" ) )
{
mkdir( $temp_path );
}
}
// checking the server if file is uploaded or not
if ( ( isset( $_FILES["file"] ) ) && ( $_FILES["file"]["size"] > 0 ) )
{
@ -53,26 +53,26 @@ function install_plugin() {
$dir = trim( $_FILES["file"]["name"], ".zip" );
$target_path = "../../ams_lib/plugins/$dir"; //path in which the zip extraction is to be done
$destination = "../../ams_lib/plugins/";
// scanning plugin folder if plugin with same name is already exists or not
$x = checkForUpdate( $dir, $destination, $fileTmpLoc, $temp_path );
if ( $x == '1' )
{
echo "update found";
exit();
}
die();
}
else if ( $x == '2' )
{
echo "Plugin already exists with same name .";
exit();
}
die();
}
else if ( $x == '3' )
{
echo "Update info is not present in the update";
exit();
}
die();
}
// checking for the command to install plugin is given or not
if ( !isset( $_POST['install_plugin'] ) )
{
@ -80,30 +80,30 @@ function install_plugin() {
{
if ( move_uploaded_file( $fileTmpLoc, $temp_path . "/" . $fileName ) ) {
echo "$fileName upload is complete.</br>" . "<button type='submit' class='btn btn-primary' style='margin-left:5px; margin-top:10px;' name='install_plugin'>Install Plugin</button></br>";
exit();
}
die();
}
else
{
echo "Error in uploading file.";
exit();
}
}
die();
}
}
else
{
echo "Please select a file with .zip extension to upload.";
exit();
}
}
die();
}
}
else
{
// calling function to unzip archives
if ( zipExtraction( $temp_path . "/" . $fileName , $destination ) )
{
if ( file_exists( $target_path . "/.info" ) )
{
$result = readPluginFile( ".info", $target_path );
// sending all info to the database
$install_result = array();
$install_result['FileName'] = $target_path;
@ -112,52 +112,52 @@ function install_plugin() {
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) )
{
$install_result['Permission'] = 'admin';
}
}
else
{
$install_result['Permission'] = 'user';
}
}
$install_result['Info'] = json_encode( $result );
// connection with the database
$dbr = new DBLayer( "lib" );
$dbr -> insert( "plugins", $install_result );
// if everything is successfull redirecting to the plugin template
header( "Location: index.php?page=plugins&result=1" );
exit;
}
die();
}
else
{
// file .info not exists
rmdir( $target_path );
header( "Location: index.php?page=install_plugin&result=2" );
exit;
}
die();
}
} else
{
// extraction failed
header( "Location: index.php?page=install_plugin&result=0" );
exit;
}
}
}
die();
}
}
}
else
{
echo "Please Browse for a file before clicking the upload button";
exit();
}
}
}
die();
}
}
}
/**
* function to unzip the zipped files
*
*
* @param $target_path path to the target zipped file
* @param $destination path to the destination
* @return boolean
* @return boolean
*/
function zipExtraction( $target_path, $destination )
{
@ -168,31 +168,31 @@ function zipExtraction( $target_path, $destination )
{
$zip -> close();
return true;
}
}
else
{
$zip -> close();
return false;
}
}
}
}
}
}
/**
* function to read text files and extract
* the information into an array
*
*
* -----------------------------------------------------------
* format:
* -----------------------------------------------------------
* PluginName = Name of the plugin
* PluginName = Name of the plugin
* Version = version of the plugin
* Type = type of the plugin
* TemplatePath = path to the template
* Description = Description of the plugin ,it's functionality
* -----------------------------------------------------------
*
*
* reads only files with name .info
*
*
* @param $fileName file to read
* @param $target_path path to the folder containing .info file
* @return array containing above information in array(value => key)
@ -205,17 +205,17 @@ function readPluginFile( $fileName, $target_path )
$line_of_text = fgets( $file_handle );
$parts = array_map( 'trim', explode( '=', $line_of_text, 2 ) );
@$result[$parts[0]] = $parts[1];
}
}
fclose( $file_handle );
return $result;
}
}
/**
* function to check for updates or
* function to check for updates or
* if the same plugin already exists
* also, if the update founds ,check for the UpdateInfo in the .info file.
* also, if the update founds ,check for the UpdateInfo in the .info file.
* Update is saved in the temp directory with pluginName_version.zip
*
*
* @param $fileName file which is uploaded in .zip extension
* @param $findPath where we have to look for the installed plugins
* @param $tempFile path for the temporary file
@ -234,23 +234,23 @@ function checkForUpdate( $fileName, $findPath, $tempFile, $tempPath )
if ( !file_exists( $tempPath . "/test" ) )
{
mkdir( $tempPath . "/test" );
}
}
// extracting the update
if ( zipExtraction( $tempFile, $tempPath . "/test/" ) )
{
$result = readPluginFile( ".info", $tempPath . "/test/" . $fileName );
// check for the version for the plugin
$db = new DBLayer( "lib" );
$sth = $db -> select( "plugins", array( 'Name' => $result['PluginName'] ), "Name = :Name" );
$info = $sth -> fetch();
$info['Info'] = json_decode( $info['Info'] );
// the two versions from main plugin and the updated part
$new_version = explode( '.', $result['Version'] );
$pre_version = explode( '.', $info['Info'] -> Version );
// For all plugins we have used semantic versioning
// Format: X.Y.Z ,X->Major, Y->Minor, Z->Patch
// change in the X Y & Z values refer the type of change in the plugin.
@ -265,22 +265,22 @@ function checkForUpdate( $fileName, $findPath, $tempFile, $tempPath )
// removing the uploaded file
Plugincache :: rrmdir( $tempPath . "/test/" . $fileName );
return '2'; //plugin already exists
}
}
else
{
// check for update info if exists
if ( !array_key_exists( 'UpdateInfo', $result ) )
{
return '3'; //update info tag not found
}
return '3'; //update info tag not found
}
else
{
// check if update already exists
if ( pluginUpdateExists( $info['Id'], $tempPath . "/" . trim( $fileName, ".zip" ) . "_" . $result['Version'] . ".zip" ) )
{
echo "Update already exists";
exit;
}
die();
}
else {
// removing the preivous update
$dbr = new DBLayer( "lib" );
@ -294,23 +294,23 @@ function checkForUpdate( $fileName, $findPath, $tempFile, $tempPath )
$update['UpdateInfo'] = json_encode( $result );
$dbr -> insert( "updates", $update );
header( "Location: index.php?page=plugins&result=7" );
exit;
}
}
}
}
}
}
}
}
die();
}
}
}
}
}
}
}
}
/**
* Function to check for the update of a plugin already exists
*
*
* @param $pluginId id of the plugin for which update is available
* @param $updatePath path of the new update
* @return boolean True if update already exists else False
*
* @return boolean True if update already exists else False
*
*/
function PluginUpdateExists( $pluginId, $updatePath )
{
@ -320,10 +320,10 @@ function PluginUpdateExists( $pluginId, $updatePath )
if ( $updatePath == $row['UpdatePath'] )
{
return true;
}
}
else
{
rmdir( $row['UpdatePath'] );
return false;
}
}
}

View file

@ -14,7 +14,7 @@ function login(){
//check if the filtered sent POST data returns a match with the DB
$result = WebUsers::checkLoginMatch($login_value, $password);
if( $result != "fail"){
//handle successful login
$_SESSION['user'] = $result['Login'];
@ -22,11 +22,11 @@ function login(){
$_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id']));
$user = new WebUsers($_SESSION['id']);
$_SESSION['Language'] = $user->getLanguage();
$GETString = "";
foreach($_GET as $key => $value){
$GETString = $GETString . $key . '=' . $value . "&";
}
}
if($GETString != ""){
$GETString = '?'.$GETString;
}
@ -38,21 +38,21 @@ function login(){
}else{
header( 'Location: '. $WEBPATH . $GETString);
}
exit;
die();
}else{
//handle login failure
$result = Array();
$result['login_error'] = 'TRUE';
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'login', $result);
exit;
}
die();
}
}catch (PDOException $e) {
//go to error page or something, because can't access website db
print_r($e);
exit;
die();
}
}

View file

@ -10,7 +10,7 @@ function modify_email_of_sgroup(){
global $INGAME_WEBPATH;
global $WEBPATH;
if(WebUsers::isLoggedIn()){
//check if user is an admin
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user'])) && isset($_POST['target_id'])){
@ -18,11 +18,11 @@ function modify_email_of_sgroup(){
$group = Support_Group::getGroup($sgroupid);
$groupemail = filter_var($_POST['GroupEmail'],FILTER_SANITIZE_STRING);
if(Users::validEmail($groupemail) || $groupemail == ""){
$password = filter_var($_POST['IMAP_Password'],FILTER_SANITIZE_STRING);
$password = filter_var($_POST['IMAP_Password'],FILTER_SANITIZE_STRING);
$group->setGroupEmail($groupemail);
$group->setIMAP_MailServer(filter_var($_POST['IMAP_MailServer'],FILTER_SANITIZE_STRING));
$group->setIMAP_Username(filter_var($_POST['IMAP_Username'],FILTER_SANITIZE_STRING));
//encrypt password!
global $cfg;
$crypter = new MyCrypt($cfg['crypt']);
@ -36,7 +36,7 @@ function modify_email_of_sgroup(){
}else{
$result['RESULT_OF_MODIFYING'] = "EMAIL_NOT_VALID";
}
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user'];
@ -49,18 +49,18 @@ function modify_email_of_sgroup(){
}else{
header("Location: ".$WEBPATH."?page=show_sgroup&id=".$sgroupid);
}
exit;
die();
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -11,14 +11,14 @@ function reply_on_ticket(){
global $WEBPATH;
//if logged in
if(WebUsers::isLoggedIn() && isset($_POST['ticket_id'])){
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($ticket_id);
//check if the user who executed this function is a mod/admin or the topic creator himself.
if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
try{
$author = unserialize($_SESSION['ticket_user'])->getTUserId();
if(isset($_POST['Content'])){
@ -27,18 +27,18 @@ function reply_on_ticket(){
$content="";
}
$hidden = 0;
if(isset($_POST['hidden']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$hidden = 1;
}
//create the reply
Ticket::createReply($content, $author, $ticket_id, $hidden);
//try to update the status & priority in case these are set.
if(isset($_POST['ChangeStatus']) && isset($_POST['ChangePriority']) && Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$newStatus = filter_var($_POST['ChangeStatus'], FILTER_SANITIZE_NUMBER_INT);
$newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT);
$newPriority = filter_var($_POST['ChangePriority'], FILTER_SANITIZE_NUMBER_INT);
Ticket::updateTicketStatusAndPriority($ticket_id,$newStatus, $newPriority, $author);
}
if (Helpers::check_if_game_client()) {
@ -46,25 +46,25 @@ function reply_on_ticket(){
}else{
header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id);
}
exit;
die();
}catch (PDOException $e) {
//ERROR: LIB DB is not online!
print_r($e);
//header("Location: index.php");
exit;
die();
}
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -5,7 +5,7 @@ function reset_password(){
$email = filter_var($_GET["email"], FILTER_SANITIZE_EMAIL);
$user = filter_var($_GET["user"], FILTER_SANITIZE_STRING);
$key = filter_var($_GET["key"], FILTER_SANITIZE_STRING);
$password = filter_var($_POST['NewPass'], FILTER_SANITIZE_STRING);
$confirmpass = filter_var($_POST['ConfirmNewPass'], FILTER_SANITIZE_STRING);
@ -24,12 +24,12 @@ function reset_password(){
}
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'reset_success', $result);
exit;
}
die();
}
$GETString = "";
foreach($_GET as $key => $value){
$GETString = $GETString . $key . '=' . $value . "&";
}
}
if($GETString != ""){
$GETString = '?'.$GETString;
}
@ -38,7 +38,7 @@ function reset_password(){
$result['prevConfirmNewPass'] = $confirmpass;
$result['no_visible_elements'] = 'TRUE';
helpers :: loadtemplate( 'reset_password', $result);
exit;
die();
}
}
}

View file

@ -2,16 +2,16 @@
/**
* This function is used in installing updates for plugins.
* It takes id of the plugin whose update is available using
* $_GET global variable and then extract the update details
* $_GET global variable and then extract the update details
* from db and then install it in the plugin.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function update_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to update
@ -19,20 +19,20 @@ function update_plugin() {
$db = new DBLayer( 'lib' );
$sth = $db -> executeWithoutParams( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id=$id" );
$row = $sth -> fetch();
// replacing update in the database
Plugincache :: rrmdir( $row['FileName'] );
Plugincache :: zipExtraction( $row['UpdatePath'], rtrim( $row['FileName'], strtolower( $row['Name'] ) ) );
$db -> update( "plugins", array( 'Info' => $row['UpdateInfo'] ), "Id=$row[Id]" );
// deleting the previous update
$db -> delete( "updates", array( 'id' => $row['s.no'] ), "s.no=:id" );
// if update is installed succesffully redirect to show success message
header( "Location: index.php?page=plugins&result=8" );
exit;
}
}
die();
}
}
}

View file

@ -11,15 +11,15 @@ function change_permission(){
global $WEBPATH;
//if logged in
if(WebUsers::isLoggedIn()){
//check if user who executed this function is an admin
if(ticket_user::isAdmin(unserialize($_SESSION['ticket_user']))){
//in case the $_GET['value'] is smaller than 4 and the user whoes permission is being changed is different from the admin(id 1)
if(isset($_GET['user_id']) && isset($_GET['value']) && $_GET['user_id'] != 1 && $_GET['value'] < 4 ){
$user_id = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
$value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT);
//execute change.
Ticket_User::change_permission(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value);
if (Helpers::check_if_game_client()) {
@ -27,9 +27,9 @@ function change_permission(){
}else{
header("Location: ".$WEBPATH."?page=show_user&id=".$user_id);
}
exit;
die();
}else{
//ERROR: GET PARAMS not given or trying to change admin
if (Helpers::check_if_game_client()) {
@ -37,22 +37,22 @@ function change_permission(){
}else{
header("Location: ".$WEBPATH."?page=show_user&id=".$user_id);
}
exit;
die();
}
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -11,44 +11,44 @@ function createticket(){
if(WebUsers::isLoggedIn()){
//in case user_id-GET param set it's value as target_id, if no user_id-param is given, use the session id.
if(isset($_GET['user_id'])){
//check if you are a mod/admin or you try to create a ticket for your own, if this is not the case redirect to error page
if(($_GET['user_id'] != $_SESSION['id']) && ( ! ticket_user::isMod(unserialize($_SESSION['ticket_user']))) ){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}else{
//if user_id is given, then set it as the target_id
$result['target_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
}
}else{
//set session_id as target_id
$result['target_id'] = $_SESSION['id'];
}
if(Helpers::check_if_game_client()){
//get all additional info, which is needed for adding the extra info page
$result[] = $_GET;
$result['ingame'] = true;
}
//create array of category id & names
$catArray = Ticket_Category::getAllCategories();
$result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" );
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -7,10 +7,10 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function dashboard(){
//if logged in
if(WebUsers::isLoggedIn()){
//is Mod
if(ticket_user::isMod(unserialize($_SESSION['ticket_user']))){
//return useful information about the status of the ticket system.
@ -25,20 +25,20 @@ function dashboard(){
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -22,7 +22,7 @@ function login() {
} else {
header('Location: ' . $WEBPATH);
}
exit;
die();
}
}
$pageElements['ingame_webpath'] = $INGAME_WEBPATH;

View file

@ -3,37 +3,37 @@
/**
* function plugins to get
* plugins from the Database using pagination object
*
* @author shubham meena mentored by Matthew Lagoe
*
* @author shubham meena mentored by Matthew Lagoe
*/
function plugins()
{
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) {
$pagination = new Pagination( "SELECT * FROM plugins", "lib", 5, "Plugincache" );
$pageResult['plug'] = Gui_Elements :: make_table( $pagination -> getElements(), Array( "getId", "getPluginName", "getPluginType", "getPluginPermission", "getPluginStatus", "getPluginInfo" ), Array( "id", "plugin_name", "plugin_type", "plugin_permission", "plugin_status", "plugin_info" ) );
$pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent();
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online
try {
$dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online";
}
}
catch( PDOException $e ) {
$pageResult['shard'] = "offline";
}
}
return( $pageResult );
} else {
// ERROR: No access!
$_SESSION['error_code'] = "403";
header( "Location: index.php?page=error" );
exit;
}
die();
}
}

View file

@ -2,8 +2,8 @@
/**
* function plugins_update to get
* plugins updates from the Database using pagination object.
*
* @author shubham meena mentored by Matthew Lagoe
*
* @author shubham meena mentored by Matthew Lagoe
*/
function plugins_update()
@ -14,23 +14,23 @@ function plugins_update()
$pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent();
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online
try {
$dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online";
}
}
catch( PDOException $e ) {
$pageResult['shard'] = "offline";
}
}
return( $pageResult );
} else {
// ERROR: No access!
$_SESSION['error_code'] = "403";
header( "Location: index.php?page=error" );
exit;
}
die();
}
}

View file

@ -4,28 +4,28 @@ function reset_password(){
$email = filter_var($_GET["email"], FILTER_SANITIZE_EMAIL);
$user = filter_var($_GET["user"], FILTER_SANITIZE_STRING);
$key = filter_var($_GET["key"], FILTER_SANITIZE_STRING);
$target_id = WebUsers::getId($user);
$webUser = new WebUsers($target_id);
if( (WebUsers::getIdFromEmail($email) == $target_id) && (hash('sha512',$webUser->getHashedPass()) == $key) ){
//you are allowed on the page!
$GETString = "";
foreach($_GET as $key => $value){
$GETString = $GETString . $key . '=' . $value . "&";
}
}
if($GETString != ""){
$GETString = '?'.$GETString;
}
$pageElements['getstring'] = $GETString;
return $pageElements;
}else{
global $WEBPATH;
$_SESSION['error_code'] = "403";
header("Location: ".$WEBPATH."?page=error");
exit;
die();
}
}
}

View file

@ -13,7 +13,7 @@ function settings(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}else{
$webUser = new Webusers($_GET['id']);
$result = $webUser->getInfo();
@ -47,7 +47,7 @@ function settings(){
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}

View file

@ -8,10 +8,10 @@
function sgroup_list(){
global $INGAME_WEBPATH;
global $WEBPATH;
//if logged in
//if logged in
if(WebUsers::isLoggedIn()){
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
//if delete GET var is set and user is admin, then delete the groups entry.
if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
@ -21,7 +21,7 @@ function sgroup_list(){
}else{
header("Location: ".$WEBPATH."?page=sgroup_list");
}
exit;
die();
}
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE";
@ -34,12 +34,12 @@ function sgroup_list(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -14,33 +14,33 @@ function show_queue(){
global $WEBPATH;
//if logged in & queue id is given
if(WebUsers::isLoggedIn() && isset($_GET['get'])){
if( Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
//the queue you want to see.
$result['queue_view'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING);
$user_id = unserialize($_SESSION['ticket_user'])->getTUserId();
$queueArray = array();
$queueArray = array();
$queue_handler = new Ticket_Queue_handler();
//Pagination Base Links
if (Helpers::check_if_game_client()) {
$result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=".$result['queue_view'] ;
}else{
$result['pagination_base_link'] = $WEBPATH."?page=show_queue&get=".$result['queue_view'] ;
}
//form url to keep the getters constant
//form url to keep the getters constant
if (Helpers::check_if_game_client()) {
$result['getURL'] = $INGAME_WEBPATH."?page=show_queue&get=" . $result['queue_view'];
}else{
$result['getURL'] = $WEBPATH."?page=show_queue&get=" . $result['queue_view'];
}
if(isset($_GET['pagenum'])){
$result['getURL'] = $result['getURL'] . "&pagenum=".$_GET['pagenum'];
}
if(isset($_GET['get']) && ($_GET['get'] == "create") && isset($_GET['userid']) && isset($_GET['groupid']) && isset($_GET['what']) && isset($_GET['how']) && isset($_GET['who'])){
$userid = filter_var($_GET['userid'], FILTER_SANITIZE_NUMBER_INT);
$groupid = filter_var($_GET['groupid'], FILTER_SANITIZE_NUMBER_INT);
@ -49,24 +49,24 @@ function show_queue(){
$who = filter_var($_GET['who'], FILTER_SANITIZE_STRING);
//create the custom queue
$queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
if (Helpers::check_if_game_client()) {
$result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}else{
$result['pagination_base_link'] = $WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}
$result['prev_created_userid'] = $userid;
$result['prev_created_groupid'] = $groupid;
$result['prev_created_what'] = $what;
$result['prev_created_how'] = $how;
$result['prev_created_who'] = $who;
$result['getURL'] = $result['getURL'] . "&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}
//if an action is set
if(isset($_POST['action'])){
switch($_POST['action']){
@ -74,12 +74,12 @@ function show_queue(){
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id);
break;
case "unAssignTicket":
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id);
break;
case "create_queue":
$userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT);
if (isset($_POST['groupid'])) {
@ -95,7 +95,7 @@ function show_queue(){
if (Helpers::check_if_game_client()) {
$result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}else{
$result['pagination_base_link'] = $WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
$result['pagination_base_link'] = $WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}
$result['prev_created_userid'] = $userid;
$result['prev_created_groupid'] = $groupid;
@ -103,20 +103,20 @@ function show_queue(){
$result['prev_created_how'] = $how;
$result['prev_created_who'] = $who;
$result['getURL'] = $result['getURL'] . "&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
break;
}
}
$queueArray = $queue_handler->getTickets($result['queue_view'], $user_id);
//pagination
$result['links'] = $queue_handler->getPagination()->getLinks(5);
$result['lastPage'] = $queue_handler->getPagination()->getLast();
$result['currentPage'] = $queue_handler->getPagination()->getCurrent();
//if queue_view is a valid parameter value
if ($queueArray != "ERROR"){
$result['tickets'] = Gui_Elements::make_table($queueArray, Array("getTId","getTitle","getTimestamp","getAuthor()->getExternId","getTicket_Category()->getName","getStatus","getStatusText","getAssigned","getForwardedGroupName","getForwardedGroupId"), Array("tId","title","timestamp","authorExtern","category","status","statusText","assigned","forwardedGroupName","forwardedGroupId"));
@ -130,8 +130,8 @@ function show_queue(){
$i++;
}
$result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId();
//Queue creator field info
//Queue creator field info
$result['grouplist'] = Gui_Elements::make_table(Support_Group::getGroups(), Array("getSGroupId","getName"), Array("sGroupId","name"));
$result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), Array("getTUserId","getExternId"), Array("tUserId","externId"));
$i = 0;
@ -143,25 +143,25 @@ function show_queue(){
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: Doesn't exist!
$_SESSION['error_code'] = "404";
header("Location: ams?page=error");
exit;
die();
}
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -8,23 +8,23 @@
function show_reply(){
//if logged in
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
$result['reply_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$reply = new Ticket_Reply();
$reply->load_With_TReplyId($result['reply_id']);
$ticket = new Ticket();
$ticket->load_With_TId($reply->getTicket());
//check if the user is allowed to see the reply
if(( $ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId() && ! $reply->getHidden()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) )){
$content = new Ticket_Content();
$content->load_With_TContentId($reply->getContent());
$author = new Ticket_User();
$author->load_With_TUserId($reply->getAuthor());
$result['hidden'] = $reply->getHidden();
$result['ticket_id'] = $reply->getTicket();
$result['reply_timestamp'] = $reply->getTimestamp();
@ -39,16 +39,16 @@ function show_reply(){
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -15,7 +15,7 @@ function show_sgroup(){
if( isset($_GET['id'])){
//['target_id'] holds the id of the group!
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
//if the $_GET['delete'] var is set and the user executing is an admin, an entry will be deleted out of the support group.
if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
@ -25,14 +25,14 @@ function show_sgroup(){
}else{
header("Location: ".$WEBPATH."?page=show_sgroup&id=" . $result['target_id']);
}
exit;
die();
}
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE";
}
$group = Support_Group::getGroup($result['target_id']);
$result['groupsname'] = $group->getName();
$result['groupemail'] = $group->getGroupEmail();
@ -58,26 +58,26 @@ function show_sgroup(){
}
return $result;
}else{
//ERROR: No page specified!
$_SESSION['error_code'] = "404";
header("Location: ams?page=error");
exit;
die();
}
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -10,13 +10,13 @@
function show_ticket(){
//if logged in
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
$result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId();
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($result['ticket_id']);
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'] ))){
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'] ))){
if(isset($_POST['action'])){
switch($_POST['action']){
case "forward":
@ -32,18 +32,18 @@ function show_ticket(){
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::unAssignTicket($result['user_id'], $ticket_id);
break;
}
}
}
}
if(($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) )){
$show_as_admin = false;
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$show_as_admin = true;
}
$entire_ticket = Ticket::getEntireTicket( $result['ticket_id'],$show_as_admin);
Ticket_Log::createLogEntry($result['ticket_id'],unserialize($_SESSION['ticket_user'])->getTUserId(), 3);
$result['ticket_tId'] = $entire_ticket['ticket_obj']->getTId();
@ -78,16 +78,16 @@ function show_ticket(){
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -6,18 +6,18 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function show_ticket_info(){
//if logged in
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($result['ticket_id']);
if( $target_ticket->hasInfo() && (($target_ticket->getAuthor() == unserialize($_SESSION['ticket_user'])->getTUserId()) || Ticket_User::isMod(unserialize($_SESSION['ticket_user']) ))){
$result['ticket_title'] = $target_ticket->getTitle();
$result['ticket_author'] = $target_ticket->getAuthor();
$ticket_info = new Ticket_Info();
$ticket_info->load_With_Ticket($result['ticket_id']);
$result['shard_id'] = $ticket_info->getShardId();
@ -38,23 +38,23 @@ function show_ticket_info(){
$result['user_id'] = $ticket_info->getUser_Id();
global $IMAGELOC_WEBPATH;
$result['IMAGELOC_WEBPATH'] = $IMAGELOC_WEBPATH;
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$result['isMod'] = "TRUE";
}
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
}
}
die();
}
}

View file

@ -10,15 +10,15 @@ function show_ticket_log(){
global $WEBPATH;
//if logged in
if(WebUsers::isLoggedIn() && isset($_GET['id'])){
//only allow admins to browse the log!
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$result['ticket_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$target_ticket = new Ticket();
$target_ticket->load_With_TId($result['ticket_id']);
$result['ticket_title'] = $target_ticket->getTitle();
//return all logs related to a ticket.
$ticket_logs = Ticket_Log::getLogsOfTicket( $result['ticket_id']);
$log_action_array = Ticket_Log::getActionTextArray();
@ -56,23 +56,23 @@ function show_ticket_log(){
$result['ticket_logs'][$i]['query'] = $author . " " . $log_action_array[$log['action']] . " " . $query_backpart;
$result['ticket_logs'][$i]['timestamp_elapsed'] = Gui_Elements::time_elapsed_string($log['timestamp']);
$i++;
}
}
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$result['isMod'] = "TRUE";
}
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
}
}
die();
}
}

View file

@ -8,14 +8,14 @@
function show_user(){
//if logged in
if(WebUsers::isLoggedIn()){
//Users can only browse their own user page, while mods/admins can browse all user pages
if( !isset($_GET['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id'] ){
if(isset($_GET['id'])){
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT);
}else{
$result['target_id'] = $_SESSION['id'];
$result['target_id'] = $_SESSION['id'];
}
$webUser = new WebUsers($result['target_id']);
$result['target_name'] = $webUser->getUsername();
@ -25,28 +25,28 @@ function show_user(){
$result['lastName'] = $info['LastName'];
$result['country'] = $info['Country'];
$result['gender'] = $info['Gender'];
$ticket_user = Ticket_User::constr_ExternId($result['target_id']);
$result['userPermission'] = $ticket_user->getPermission();
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE";
}
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId());
$result['ticketlist'] = Gui_Elements::make_table($ticketlist, Array("getTId","getTimestamp","getTitle","getStatus","getStatusText","getStatusText","getCategoryName"), Array("tId","timestamp","title","status","statustext","statusText","category"));
global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH;
return $result;
}else{
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
die();
}
}
}

View file

@ -6,19 +6,19 @@
* @author Daan Janssens, mentored by Matthew Lagoe
*/
function syncing(){
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
//return a paginated version of all unsynced changes.
$pagination = new Pagination("SELECT * FROM ams_querycache","lib",5,"Querycache");
$pageResult['liblist'] = Gui_Elements::make_table($pagination->getElements() , Array("getSID","getType"), Array("id","type"));
$pageResult['links'] = $pagination->getLinks(5);
$pageResult['lastPage'] = $pagination->getLast();
$pageResult['currentPage'] = $pagination->getCurrent();
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
//check if shard is online
try{
$dbs = new DBLayer("shard");
@ -31,6 +31,6 @@ function syncing(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}
}

View file

@ -6,19 +6,19 @@
*/
function userlist(){
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
$pagination = new Pagination(WebUsers::getAllUsersQuery(),"web",10,"WebUsers");
$pageResult['userlist'] = Gui_Elements::make_table($pagination->getElements() , Array("getUId","getUsername","getEmail"), Array("id","username","email"));
$pageResult['links'] = $pagination->getLinks(5);
$pageResult['lastPage'] = $pagination->getLast();
$pageResult['currentPage'] = $pagination->getCurrent();
$i = 0;
foreach( $pageResult['userlist'] as $user ){
$pageResult['userlist'][$i]['permission'] = Ticket_User::constr_ExternId($pageResult['userlist'][$i]['id'])->getPermission();
$i++;
}
if (Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$pageResult['isAdmin'] = "TRUE";
}
@ -31,6 +31,6 @@ function userlist(){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Location: index.php?page=error");
exit;
die();
}
}

View file

@ -101,7 +101,7 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='', $w
$c .= '<div style="text-align: center"><strong style="color: #FF5555">'._t($user['message']).'</strong></div><br />';
$c .= ryzom_render_login_form($name, false);
echo ryzom_app_render(_t('app_'.APP_NAME), $c);
exit;
die();
}
return false;
}
@ -118,7 +118,7 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='', $w
$user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date'], $user);
$user['gender'] = ryzom_get_user_gender($user['id']);
$user['ig'] = $ig;
$user['lang'] = $_SESSION['lang'];
if (!isset($user['groups']))

View file

@ -121,14 +121,14 @@ if(!function_exists('_i')){
function _i($img, $alt=''){
if (substr($img, strlen($img)-4) == '.tga') // img from client texture : ig only
return $img;
if (is_file(RYAPI_PATH.'/data/icons/'.$img.'.png'))
$img = RYAPI_URL.'/data/icons/'.$img.'.png';
else if (is_file(RYAPP_PATH.'/data/icons/'.$img.'.png'))
$img = RYAPP_URL.'/data/icons/'.$img.'.png';
else
$img = 'view_remove';
if ($alt)
return '<img src="'.$img.'" title="'.$alt.'" alt="'.utf8_decode($alt).'" />';
else
@ -272,30 +272,30 @@ function ryzom_absolute_time($timestamp) {
/***
*
*
* Ryzom utilities
*
*
*
*
* ***/
function ryzom_generate_password($length=8, $level=2, $oneofeach=false) {
$validchars[1] = "0123456789abcdfghjkmnpqrstvwxyz";
$validchars[2] = "0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$validchars[3] = "0123456789_!@#$%&*()-=+/abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_!@#$%&*()-=+/";
$password = "";
$counter = 0;
while ($counter < $length) {
$actChar = substr($validchars[$level], rand(0, strlen($validchars[$level])-1), 1);
// if $oneofeach then All character must be different (slower)
if (!$oneofeach || !strstr($password, $actChar)) {
$password .= $actChar;
$counter++;
}
}
return $password;
}
@ -304,7 +304,7 @@ function file_get_contents_cached($fn, $cache_time=300) {
global $ryzom_bench_text;
$lfn = 'tmp/'.strtr($fn, ':/.?&=', '____________');
// get the new file from internet every $cache_time (default=5min)
if (file_exists($lfn) && filesize($lfn) > 0 && time() < filemtime($lfn) + $cache_time) {
$content = file_get_contents($lfn);
@ -328,10 +328,10 @@ function ryzom_redirect($url, $group='', $extra_lua='') {
$lua .= 'getUI("ui:interface:'.$group.':content:html"):browse("'.str_replace('&', '&amp;', $url).'")';
}
echo '<lua>'.$lua.'</lua>';
exit();
die();
} else {
header('Location: '.$url);
exit();
die();
}
}
@ -357,12 +357,12 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
$bt1 = explode('[', $bt[$level]);
else
$bt1 = array('');
if (isset($bt[$level+1]))
$bt2 = explode('[', $bt[$level+1]);
else
$bt2 = array('');
$c = '';
if ($value !== pNULL) {
$c .= '<font color="#FFFFFF">'.$var.' : </font>';
@ -381,8 +381,8 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
*
* Lua tools
*
* ***/
* ***/
class ryLua {
static private $lua = array();
@ -390,7 +390,7 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
static private $indent;
static private $indentend;
static private $linkTargetId = 0;
static function add($code, $indent=NULL) {
if ($indent !== NULL)
self::$indent += $indent;
@ -398,7 +398,7 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
$a = $tabs.str_replace("\n", "\n ".$tabs, $code);
self::$lua[] = $a;
}
static function addEnd($code, $indent=NULL) {
if ($indent !== NULL)
self::$indentend += $indent;
@ -406,8 +406,8 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
$a = $tabs.str_replace("\n", "\n ".$tabs, $code);
self::$luaend[] = $a;
}
static function get($ig) {
ryLogger::getInstance()->addPrint(implode("\n", self::$lua), '#FF00FF');
$ret = ($ig)?"<lua>\n".implode("\n", self::$lua)."\n</lua>":'';
@ -421,16 +421,16 @@ function p($var, $value=pNULL, $color='#FFFF00', $level=0) {
self::$luaend = array();
return $ret;
}
static function text($text) {
return str_replace('"', '\"', $text);
}
static function url($base_params=null, $add_params=array()) {
return str_replace('&', '&amp;', _url($base_params, $add_params));
}
function openLink($text, $target='webig', $base_params=array(), $add_params=array(), $urllua='', $runlua='')
{
$url = self::url($base_params, $add_params);
@ -448,7 +448,7 @@ END;
return '<a href="ah:lua&openLink'.$id.'()">'.$text.'</a>';
return $text;
}
static function link($id, $luacode, $text) {
$lua = <<<END
function runLua{$id}()
@ -460,7 +460,7 @@ END;
return '<a href="ah:lua&runLua'.$id.'()">'.$text.'</a>';
return $text;
}
}
?>

View file

@ -10,7 +10,7 @@
$MY_PATH = dirname(__FILE__);
if(file_exists("parser.stop")) {
exit(0);
die();
}
require_once("class/mySQL_class.php");
@ -58,7 +58,7 @@
require_once("class/Stats_class.php");
$atom_insert = array();
$_CACHE = new ValueCache();
//new generator for API xml files.
@ -109,7 +109,7 @@
$stop_time = $microstop[0] + $microstop[1];
#$log->logf("Expired time: ".($stop_time - $start_time));
#foreach($chars as $cid) {
#STEP 1: load and register atoms
@ -149,7 +149,7 @@
#$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logi("Driving data... ",false);
#STEP 2: drive data
$_CACHE->setChar($cdata);
$res = $DBc->sendSQL("SELECT sum(at_value) as anz FROM ach_task,ach_player_task WHERE at_id=apt_task AND apt_player='".$cdata['cid']."'","ARRAY");
@ -266,7 +266,7 @@ for($dtrun=0;$dtrun<2;$dtrun++) {
#$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logi("Clearing atom data [PASS ".$dtrun."]... ",false);
//clear atom state for completed objectives
#$DBc->sendSQL("DELETE FROM ach_player_atom WHERE EXISTS (SELECT * FROM ach_player_objective,ach_atom WHERE atom_id=apa_atom AND apa_player='".$cdata['cid']."' AND atom_objective=apo_objective)");
@ -357,8 +357,8 @@ for($dtrun=0;$dtrun<2;$dtrun++) {
if(sizeof($DBc->longQuery) > 0) {
$log->logf("Longer queries: ".var_export($DBc->longQuery,true));
}
#$log->logf("Run complete; exiting...");
$log->close();
exit(0);
?>
die();
?>

View file

@ -34,8 +34,8 @@
}
echo "</open>";
echo "</objectives>";
echo "</ryzom_progress>";
exit(0);
?>
die();
?>

View file

@ -47,7 +47,7 @@
}
$_USER = new RUser();
//create database connection
$DBc = new mySQL($_CONF['mysql_error']);
@ -106,8 +106,8 @@
print_cat($iter3);
echo "</category>";
}
echo "</ryzom_achievements>";
exit(0);
?>
die();
?>

View file

@ -46,32 +46,32 @@ if ( isset( $_GET['search'] ) && isset( $_GET['format'] ) )
{
// getting the headers when the request is sent
$header = getallheaders();
// this block is to get the posted data
$fp = fopen( 'php://input', 'r' );
$rawData = stream_get_contents( $fp );
$userd = json_decode( $rawData, true );
// authenticate the user using data we get from server
appAuthenticateRest( $user, $userd );
// create a ryzom user object whose achievements we have to send in response
$_USER = new RyzomUser( $user );
require_once( "include/ach_render_web.php" );
$c .= ach_render();
$response = $c;
// sending the response
echo( $response );
exit;
}
}
die();
}
}
else
{
echo 'Invalid response';
exit;
}
die();
}
@ -100,10 +100,10 @@ $_USER = new RyzomUser( $user );
if ( $_USER -> isIG() ) {
require_once( "include/ach_render_ig.php" );
}
}
else {
require_once( "include/ach_render_web.php" );
}
}
// require_once("fb/facebook.php");
@ -115,15 +115,15 @@ if ( !$_USER -> isIG() ) {
* 'secret' => $_CONF['fb_secret'],
* 'cookie' => true
* ));
*
*
* #code taken from facebook tutorial
*
*
* // Get the url to redirect for login to facebook
* // and request permission to write on the user's wall.
* $login_url = $facebook->getLoginUrl(
* array('scope' => 'publish_stream')
* );
*
*
* // If not authenticated, redirect to the facebook login dialog.
* // The $login_url will take care of redirecting back to us
* // after successful login.
@ -136,21 +136,21 @@ if ( !$_USER -> isIG() ) {
* $DBc->sqlQuery("INSERT INTO ach_fb_token (aft_player,aft_token,aft_date,aft_allow) VALUES ('".$_USER->getID()."','".$DBc->sqlEscape($facebook->getAccessToken())."','".time()."','1') ON DUPLICATE KEY UPDATE aft_token='".$DBc->sqlEscape($facebook->getAccessToken())."', aft_date='".time()."'");
* }
*/
}
}
if ( !$_USER -> isIG && $_CONF['enable_webig'] == false ) {
$c .= ach_render_forbidden( false );
}
}
elseif ( $_USER -> isIG && $_CONF['enable_offgame'] == false ) {
$c .= ach_render_forbidden( true );
}
}
else {
$c .= ach_render();
}
}
echo ryzom_app_render( strtoupper( get_translation( 'ach_app_name', $_USER -> getLang() ) ), $c, $_USER -> isIG() );

View file

@ -51,7 +51,7 @@ class JoinShardCb extends CRingSessionManagerWeb
function getShardsResult($userId, $resultStr)
{
global $getShardListCallback;
$onlineShardsBySessionId = array();
$resultArray = split(';', $resultStr);
foreach ($resultArray as $shardInfo)
@ -63,7 +63,7 @@ class JoinShardCb extends CRingSessionManagerWeb
$getShardListCallback($onlineShardsBySessionId);
}
}
// External use
$FSHostLuaMode = false;
$FSHostResultStr = 0;
@ -123,7 +123,7 @@ function joinShardFromId( $userId, $domainId, $destSessionId )
$addr = split(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
// request join to the session manager
$joinShard = new JoinShardCb;
$res = "";
@ -132,14 +132,14 @@ function joinShardFromId( $userId, $domainId, $destSessionId )
$charId = ($userId<<4) + $charSlot;
echo "Requesting teleportation of $charId/$userId to shard session ".$destSessionId."...<br>";
$joinShard->joinSession($charId, $destSessionId, $domainInfo["domain_name"]);
// wait the the return message
if ($joinShard->waitCallback() == false)
{
// Note: the answer is a joinSessionResult message
echo "No response from server, joinShard failed<br>";
}
exit;
die();
}
/**
@ -151,7 +151,7 @@ function getShardList($userId, $domainId)
$addr = split(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
// request get to the session manager
$joinShard = new JoinShardCb;
$res = "";
@ -160,13 +160,13 @@ function getShardList($userId, $domainId)
$charId = ($userId<<4)+15;
echo "Retrieving online shards for $charId...<br>";
$joinShard->getShards($charId);
// wait the the return message
if ($joinShard->waitCallback() == false)
{
echo "No response from server, getShards failed<br>";
}
exit;
die();
}
/**
@ -182,7 +182,7 @@ function displayAllShards(&$onlineShardsBySessionId)
echo "Invalid cookie !";
die();
}
// List all shards of the domain, including offline ones
global $DBName, $DBHost, $DBUserName, $DBPassword;
$link = mysqli_connect($DBHost, $DBUserName, $DBPassword) or die("Can't connect to nel database");
@ -208,10 +208,10 @@ function displayAllShards(&$onlineShardsBySessionId)
echo "<input type='submit' name='button' value='Teleport' />";
echo "</form><br>";
}
//echo "<input type='submit' name='button' value='Teleport' />";
//echo "</form></font>";
exit;
die();
}
@ -226,19 +226,19 @@ function joinMainland($userId, $domainId)
$addr = split(":", $domainInfo["session_manager_address"]);
$RSMHost = $addr[0];
$RSMPort = $addr[1];
// request get to the session manager
$joinsShard = new JoinShardCb;
$res = "";
$joinsShard->connect($RSMHost, $RSMPort, $res);
// set the shard Id to allow any character (by using the special value '15')
$charId = ($userId<<4)+15;
$charId = ($userId<<4)+15;
global $FSHostLuaMode, $verbose;
if ($FSHostLuaMode && $verbose)
echo "Joining a mainland shard for $charId...<br>";
$joinsShard->joinMainland($charId, $domainInfo["domain_name"]);
// wait the the return message
if ($joinsShard->waitCallback() == false)
{