hg/feature/cdb-packed
botanic 10 years ago
commit fe8cb3595a

@ -36,6 +36,11 @@ class Helpers {
$smarty -> caching = false; $smarty -> caching = false;
$smarty -> cache_lifetime = 5; $smarty -> cache_lifetime = 5;
if (function_exists('apc_cache_info')) {
// production
$smarty->compile_check = false;
}
// needed by smarty. // needed by smarty.
helpers :: create_folders (); helpers :: create_folders ();
global $FORCE_INGAME; global $FORCE_INGAME;

@ -3,12 +3,12 @@
/** /**
* Global and Local Hooks for the API key Management plugin * Global and Local Hooks for the API key Management plugin
* Global Hooks are defined with the prefix(name of the plugin) * Global Hooks are defined with the prefix(name of the plugin)
* Local Hooks are defined with normal function name * Local Hooks are defined with normal function name
* *
* All the Global Hooks are called during the page load * All the Global Hooks are called during the page load
* and Local Hooks are called according to conditions * and Local Hooks are called according to conditions
* *
* @author shubham meena mentored by Matthew Lagoe * @author shubham meena mentored by Matthew Lagoe
*/ */
// Global variable to store the data which is // Global variable to store the data which is
@ -27,7 +27,7 @@ function api_key_management_hook_display()
global $return_set; global $return_set;
// to display plugin name in menu bar // to display plugin name in menu bar
$return_set['menu_display'] = 'API Key Management'; $return_set['menu_display'] = 'API Key Management';
} }
/** /**
* Local Hook to validate the posted data * Local Hook to validate the posted data
@ -37,12 +37,12 @@ function hook_validate( $var )
if ( isset( $var ) && !empty( $var ) ) if ( isset( $var ) && !empty( $var ) )
{ {
return true; return true;
} }
else else
{ {
return false; return false;
} }
} }
/** /**
* Local Hook to set the POST variables and validate them * Local Hook to set the POST variables and validate them
@ -51,7 +51,7 @@ function hook_variables()
{ {
global $var_set; global $var_set;
global $return_set; global $return_set;
if ( hook_validate( $_POST['expDate'] ) && hook_validate( $_POST['sp_name'] ) && hook_validate( $_POST['api_type'] ) if ( hook_validate( $_POST['expDate'] ) && hook_validate( $_POST['sp_name'] ) && hook_validate( $_POST['api_type'] )
&& hook_validate( $_POST['character_name'] ) ) && hook_validate( $_POST['character_name'] ) )
{ {
@ -63,12 +63,12 @@ function hook_variables()
$var_set['AddedOn'] = date( "Y-m-d H:i:s" ); $var_set['AddedOn'] = date( "Y-m-d H:i:s" );
$var_set['Items'] = ''; $var_set['Items'] = '';
$return_set['gen_key_validate'] = 'true'; $return_set['gen_key_validate'] = 'true';
} }
else else
{ {
$return_set['gen_key_validate'] = 'false'; $return_set['gen_key_validate'] = 'false';
} }
} }
/** /**
* Global Hook to create table of the API_key_management * Global Hook to create table of the API_key_management
@ -108,12 +108,12 @@ function api_key_management_hook_create_tb()
-- --
ALTER TABLE `ams_api_keys` ALTER TABLE `ams_api_keys`
ADD CONSTRAINT `ams_api_keys_ibfk_1` FOREIGN KEY (`User`) REFERENCES `ryzom_ams`.`ams_user` (`Login`);"; ADD CONSTRAINT `ams_api_keys_ibfk_1` FOREIGN KEY (`User`) REFERENCES `ryzom_ams`.`ams_user` (`Login`);";
$dbl -> executeWithoutParams( $sql ); $dbl -> executeWithoutParams( $sql );
} }
/** /**
* Hook to store data to database which is sent as post * Hook to store data to database which is sent as post
* method from the forms in this plugin * method from the forms in this plugin
* It also calls the local hook * It also calls the local hook
*/ */
@ -121,63 +121,63 @@ function api_key_management_hook_store_db()
{ {
global $var_set; global $var_set;
global $return_set; global $return_set;
// if the form been submited move forward // if the form been submited move forward
if ( @hook_validate( $_POST['gen_key'] ) ) { if ( @hook_validate( $_POST['gen_key'] ) ) {
// local hook to validate the POST variables // local hook to validate the POST variables
hook_variables(); hook_variables();
// if validation successfull move forward // if validation successfull move forward
if ( $return_set['gen_key_validate'] == 'true' && $_GET['plugin_action'] == 'generate_key' ) if ( $return_set['gen_key_validate'] == 'true' && $_GET['plugin_action'] == 'generate_key' )
{ {
// this part generated the access token // this part generated the access token
include 'generate_key.php'; include 'generate_key.php';
$var_set['AccessToken'] = generate_key :: randomToken( 56, false, true, false ); $var_set['AccessToken'] = generate_key :: randomToken( 56, false, true, false );
// database connection // database connection
$db = new DBLayer( 'lib' ); $db = new DBLayer( 'lib' );
// insert the form data to the database // insert the form data to the database
$db -> insert( 'ams_api_keys', $var_set ); $db -> insert( 'ams_api_keys', $var_set );
// redirect to the the main page with success code // redirect to the the main page with success code
// 1 refers to the successfull addition of key to the database // 1 refers to the successfull addition of key to the database
header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=1" ); header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=1" );
exit; throw new SystemExit();
} }
} }
} }
/** /**
* Global Hook to load the data from db and set it * Global Hook to load the data from db and set it
* into the global array to return it to the template * into the global array to return it to the template
*/ */
function api_key_management_hook_load_db() function api_key_management_hook_load_db()
{ {
global $var_set; global $var_set;
global $return_set; global $return_set;
$db = new DBLayer( 'lib' ); $db = new DBLayer( 'lib' );
if ( isset( $_SESSION['user'] ) ) if ( isset( $_SESSION['user'] ) )
{ {
// returns the registered keys // returns the registered keys
$sth = $db -> select( 'ams_api_keys', array( 'user' => $_SESSION['user'] ), 'User = :user' ); $sth = $db -> select( 'ams_api_keys', array( 'user' => $_SESSION['user'] ), 'User = :user' );
$row = $sth -> fetchAll(); $row = $sth -> fetchAll();
$return_set['api_keys'] = $row; $return_set['api_keys'] = $row;
// fetch the character from the array to compare // fetch the character from the array to compare
$com = array_column( $return_set['api_keys'], 'UserCharacter' ); $com = array_column( $return_set['api_keys'], 'UserCharacter' );
// returns the characters with respect to the user id in the ring_tool->characters // returns the characters with respect to the user id in the ring_tool->characters
$db = new DBLayer( 'ring' ); $db = new DBLayer( 'ring' );
$sth = $db -> selectWithParameter( 'char_name', 'characters' , array(), '1' ); $sth = $db -> selectWithParameter( 'char_name', 'characters' , array(), '1' );
$row = $sth -> fetch(); $row = $sth -> fetch();
// loop through the character list and remove the character if already have an api key // loop through the character list and remove the character if already have an api key
$return_set['characters'] = array_diff( $row, $com ); $return_set['characters'] = array_diff( $row, $com );
} }
} }
/** /**
* Global Hook to update or delete the data from db * Global Hook to update or delete the data from db
@ -186,24 +186,24 @@ function api_key_management_hook_update_db()
{ {
global $var_set; global $var_set;
global $return_set; global $return_set;
$db = new DBLayer( 'lib' ); $db = new DBLayer( 'lib' );
if ( isset( $_GET['delete_id'] ) ) if ( isset( $_GET['delete_id'] ) )
{ {
// removes the registered key using get variable which contains the id of the registered key // removes the registered key using get variable which contains the id of the registered key
$db -> delete( 'ams_api_keys', array( 'SNo' => $_GET['delete_id'] ), 'SNo = :SNo' ); $db -> delete( 'ams_api_keys', array( 'SNo' => $_GET['delete_id'] ), 'SNo = :SNo' );
// redirecting to the API_key_management plugins template with success code // redirecting to the API_key_management plugins template with success code
// 2 refers to the succssfull delete condition // 2 refers to the succssfull delete condition
header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=2" ); header( "Location: index.php?page=layout_plugin&&name=API_key_management&&success=2" );
exit; throw new SystemExit();
} }
} }
/** /**
* Global Hook to return global variables which contains * Global Hook to return global variables which contains
* the content to use in the smarty templates * the content to use in the smarty templates
* *
* @return $return_set global array returns the template data * @return $return_set global array returns the template data
*/ */
function api_key_management_hook_return_global() function api_key_management_hook_return_global()

@ -33,13 +33,6 @@ CREATE TABLE IF NOT EXISTS `ams_querycache` (
`db` varchar(80) NOT NULL `db` varchar(80) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `ams_querycache`
--
INSERT INTO `ams_querycache` (`SID`, `type`, `query`, `db`) VALUES
(1, 'createUser', '["admin","WyId5UERpuB4U","localhost@localhost"]', 'shard');
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --
@ -298,13 +291,6 @@ CREATE TABLE IF NOT EXISTS `ticket_user` (
`ExternId` int(10) unsigned NOT NULL `ExternId` int(10) unsigned NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
--
-- Dumping data for table `ticket_user`
--
INSERT INTO `ticket_user` (`TUserId`, `Permission`, `ExternId`) VALUES
(1, 3, 1);
-- -------------------------------------------------------- -- --------------------------------------------------------
-- --

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

@ -9,7 +9,7 @@ function add_sgroup(){
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
global $WEBPATH; global $WEBPATH;
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
//check if admin //check if admin
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$name = filter_var($_POST['Name'],FILTER_SANITIZE_STRING); $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_mailserver = filter_var($_POST['IMAP_MailServer'], FILTER_SANITIZE_STRING);
$imap_username = filter_var($_POST['IMAP_Username'], FILTER_SANITIZE_STRING); $imap_username = filter_var($_POST['IMAP_Username'], FILTER_SANITIZE_STRING);
$imap_password = filter_var($_POST['IMAP_Password'], FILTER_SANITIZE_STRING); $imap_password = filter_var($_POST['IMAP_Password'], FILTER_SANITIZE_STRING);
//create a new support group //create a new support group
$result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password); $result['RESULT_OF_ADDING'] = Support_Group::createSupportGroup($name, $tag, $groupemail, $imap_mailserver, $imap_username, $imap_password);
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); $result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
@ -30,6 +30,7 @@ function add_sgroup(){
require($SITEBASE . '/inc/sgroup_list.php'); require($SITEBASE . '/inc/sgroup_list.php');
$result= array_merge($result, sgroup_list()); $result= array_merge($result, sgroup_list());
return $result; return $result;
header("Cache-Control: max-age=1");
/*if (Helpers::check_if_game_client()) { /*if (Helpers::check_if_game_client()) {
header("Location: ".$INGAME_WEBPATH."?page=sgroup_list"); header("Location: ".$INGAME_WEBPATH."?page=sgroup_list");
}else{ }else{
@ -40,13 +41,15 @@ function add_sgroup(){
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

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

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

@ -6,15 +6,15 @@
* @author Daan Janssens, mentored by Matthew Lagoe * @author Daan Janssens, mentored by Matthew Lagoe
*/ */
function change_receivemail(){ function change_receivemail(){
try{ try{
//if logged in //if logged in
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
global $WEBPATH; global $WEBPATH;
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
if(isset($_POST['target_id'])){ 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. //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']) ){ 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); $user_id = filter_var($_POST['target_id'], FILTER_SANITIZE_NUMBER_INT);
@ -23,36 +23,41 @@ function change_receivemail(){
WebUsers::setReceiveMail($user_id, $receiveMail); WebUsers::setReceiveMail($user_id, $receiveMail);
} }
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Cache-Control: max-age=1");
header("Location: ".$INGAME_WEBPATH."?page=settings&id=".$user_id); header("Location: ".$INGAME_WEBPATH."?page=settings&id=".$user_id);
}else{ }else{
header("Cache-Control: max-age=1");
header("Location: ".$WEBPATH."?page=settings&id=".$user_id); header("Location: ".$WEBPATH."?page=settings&id=".$user_id);
} }
exit; throw new SystemExit();
}else{ }else{
//ERROR: permission denied! //ERROR: permission denied!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: The form was not filled in correclty //ERROR: The form was not filled in correclty
header("Cache-Control: max-age=1");
header("Location: index.php?page=settings"); header("Location: index.php?page=settings");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: user is not logged in //ERROR: user is not logged in
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
}catch (PDOException $e) { }catch (PDOException $e) {
//go to error page or something, because can't access website db //go to error page or something, because can't access website db
print_r($e); print_r($e);
exit; throw new SystemExit();
} }
} }

@ -10,12 +10,12 @@ function create_ticket(){
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
global $WEBPATH; global $WEBPATH;
if(WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])){ if(WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])){
if(isset($_POST['target_id'])){ if(isset($_POST['target_id'])){
//if target_id is the same as session id or is admin //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'])) ){ if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
$category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT); $category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT);
$title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING); $title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING);
$content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING); $content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING);
@ -31,37 +31,43 @@ function create_ticket(){
$ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(),0, $_POST); $ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(),0, $_POST);
//redirect to the new ticket. //redirect to the new ticket.
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Cache-Control: max-age=1");
header("Location: ".$INGAME_WEBPATH."?page=show_ticket&id=".$ticket_id); header("Location: ".$INGAME_WEBPATH."?page=show_ticket&id=".$ticket_id);
}else{ }else{
header("Cache-Control: max-age=1");
header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id); header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id);
} }
exit; throw new SystemExit();
}catch (PDOException $e) { }catch (PDOException $e) {
//ERROR: LIB DB is not online! //ERROR: LIB DB is not online!
print_r($e); print_r($e);
exit; throw new SystemExit();
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: permission denied! //ERROR: permission denied!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: The form was not filled in correclty //ERROR: The form was not filled in correclty
header("Cache-Control: max-age=1");
header("Location: index.php?page=create_ticket"); header("Location: index.php?page=create_ticket");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: user is not logged in //ERROR: user is not logged in
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

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

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

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

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

@ -10,7 +10,7 @@ function modify_email_of_sgroup(){
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
global $WEBPATH; global $WEBPATH;
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
//check if user is an admin //check if user is an admin
if( Ticket_User::isAdmin(unserialize($_SESSION['ticket_user'])) && isset($_POST['target_id'])){ 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); $group = Support_Group::getGroup($sgroupid);
$groupemail = filter_var($_POST['GroupEmail'],FILTER_SANITIZE_STRING); $groupemail = filter_var($_POST['GroupEmail'],FILTER_SANITIZE_STRING);
if(Users::validEmail($groupemail) || $groupemail == ""){ 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->setGroupEmail($groupemail);
$group->setIMAP_MailServer(filter_var($_POST['IMAP_MailServer'],FILTER_SANITIZE_STRING)); $group->setIMAP_MailServer(filter_var($_POST['IMAP_MailServer'],FILTER_SANITIZE_STRING));
$group->setIMAP_Username(filter_var($_POST['IMAP_Username'],FILTER_SANITIZE_STRING)); $group->setIMAP_Username(filter_var($_POST['IMAP_Username'],FILTER_SANITIZE_STRING));
//encrypt password! //encrypt password!
global $cfg; global $cfg;
$crypter = new MyCrypt($cfg['crypt']); $crypter = new MyCrypt($cfg['crypt']);
@ -36,7 +36,7 @@ function modify_email_of_sgroup(){
}else{ }else{
$result['RESULT_OF_MODIFYING'] = "EMAIL_NOT_VALID"; $result['RESULT_OF_MODIFYING'] = "EMAIL_NOT_VALID";
} }
$result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission(); $result['permission'] = unserialize($_SESSION['ticket_user'])->getPermission();
$result['no_visible_elements'] = 'FALSE'; $result['no_visible_elements'] = 'FALSE';
$result['username'] = $_SESSION['user']; $result['username'] = $_SESSION['user'];
@ -44,23 +44,26 @@ function modify_email_of_sgroup(){
//require_once($SITEBASE . 'inc/show_sgroup.php'); //require_once($SITEBASE . 'inc/show_sgroup.php');
//$result= array_merge($result, show_sgroup()); //$result= array_merge($result, show_sgroup());
//helpers :: loadtemplate( 'show_sgroup', $result); //helpers :: loadtemplate( 'show_sgroup', $result);
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Location: ".$INGAME_WEBPATH."?page=show_sgroup&id=".$sgroupid); header("Location: ".$INGAME_WEBPATH."?page=show_sgroup&id=".$sgroupid);
}else{ }else{
header("Location: ".$WEBPATH."?page=show_sgroup&id=".$sgroupid); header("Location: ".$WEBPATH."?page=show_sgroup&id=".$sgroupid);
} }
exit; throw new SystemExit();
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

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

@ -2,16 +2,16 @@
/** /**
* This function is used in installing updates for plugins. * This function is used in installing updates for plugins.
* It takes id of the plugin whose update is available using * 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. * 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() { function update_plugin() {
// if logged in // if logged in
if ( WebUsers :: isLoggedIn() ) { if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) ) if ( isset( $_GET['id'] ) )
{ {
// id of plugin to update // id of plugin to update
@ -19,20 +19,21 @@ function update_plugin() {
$db = new DBLayer( 'lib' ); $db = new DBLayer( 'lib' );
$sth = $db -> executeWithoutParams( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id=$id" ); $sth = $db -> executeWithoutParams( "SELECT * FROM plugins INNER JOIN updates ON plugins.Id=updates.PluginId Where plugins.Id=$id" );
$row = $sth -> fetch(); $row = $sth -> fetch();
// replacing update in the database // replacing update in the database
Plugincache :: rrmdir( $row['FileName'] ); Plugincache :: rrmdir( $row['FileName'] );
Plugincache :: zipExtraction( $row['UpdatePath'], rtrim( $row['FileName'], strtolower( $row['Name'] ) ) ); Plugincache :: zipExtraction( $row['UpdatePath'], rtrim( $row['FileName'], strtolower( $row['Name'] ) ) );
$db -> update( "plugins", array( 'Info' => $row['UpdateInfo'] ), "Id=$row[Id]" ); $db -> update( "plugins", array( 'Info' => $row['UpdateInfo'] ), "Id=$row[Id]" );
// deleting the previous update // deleting the previous update
$db -> delete( "updates", array( 'id' => $row['s.no'] ), "s.no=:id" ); $db -> delete( "updates", array( 'id' => $row['s.no'] ), "s.no=:id" );
// if update is installed succesffully redirect to show success message // if update is installed succesffully redirect to show success message
header("Cache-Control: max-age=1");
header( "Location: index.php?page=plugins&result=8" ); header( "Location: index.php?page=plugins&result=8" );
exit; throw new SystemExit();
} }
} }
} }

@ -11,48 +11,52 @@ function change_permission(){
global $WEBPATH; global $WEBPATH;
//if logged in //if logged in
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
//check if user who executed this function is an admin //check if user who executed this function is an admin
if(ticket_user::isAdmin(unserialize($_SESSION['ticket_user']))){ 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) //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 ){ 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); $user_id = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
$value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT); $value = filter_var($_GET['value'], FILTER_SANITIZE_NUMBER_INT);
//execute change. //execute change.
Ticket_User::change_permission(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value); Ticket_User::change_permission(Ticket_User::constr_ExternId($user_id)->getTUserId(), $value);
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Location: ".$INGAME_WEBPATH."?page=show_user&id=".$user_id); header("Location: ".$INGAME_WEBPATH."?page=show_user&id=".$user_id);
}else{ }else{
header("Location: ".$WEBPATH."?page=show_user&id=".$user_id); header("Location: ".$WEBPATH."?page=show_user&id=".$user_id);
} }
exit; throw new SystemExit();
}else{ }else{
//ERROR: GET PARAMS not given or trying to change admin //ERROR: GET PARAMS not given or trying to change admin
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Location: ".$INGAME_WEBPATH."?page=show_user&id=".$user_id); header("Location: ".$INGAME_WEBPATH."?page=show_user&id=".$user_id);
}else{ }else{
header("Location: ".$WEBPATH."?page=show_user&id=".$user_id); header("Location: ".$WEBPATH."?page=show_user&id=".$user_id);
} }
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

@ -11,44 +11,46 @@ function createticket(){
if(WebUsers::isLoggedIn()){ 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. //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'])){ 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 //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']))) ){ if(($_GET['user_id'] != $_SESSION['id']) && ( ! ticket_user::isMod(unserialize($_SESSION['ticket_user']))) ){
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
}else{ }else{
//if user_id is given, then set it as the target_id //if user_id is given, then set it as the target_id
$result['target_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT); $result['target_id'] = filter_var($_GET['user_id'], FILTER_SANITIZE_NUMBER_INT);
} }
}else{ }else{
//set session_id as target_id //set session_id as target_id
$result['target_id'] = $_SESSION['id']; $result['target_id'] = $_SESSION['id'];
} }
if(Helpers::check_if_game_client()){ if(Helpers::check_if_game_client()){
//get all additional info, which is needed for adding the extra info page //get all additional info, which is needed for adding the extra info page
$result[] = $_GET; $result[] = $_GET;
$result['ingame'] = true; $result['ingame'] = true;
} }
//create array of category id & names //create array of category id & names
$catArray = Ticket_Category::getAllCategories(); $catArray = Ticket_Category::getAllCategories();
$result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" ); $result['category'] = Gui_Elements::make_table_with_key_is_id($catArray, Array("getName"), "getTCategoryId" );
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH;
return $result; return $result;
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

@ -17,12 +17,13 @@ function login() {
$_SESSION['id'] = WebUsers::getId($result['name']); $_SESSION['id'] = WebUsers::getId($result['name']);
$_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id'])); $_SESSION['ticket_user'] = serialize(Ticket_User::constr_ExternId($_SESSION['id']));
//go back to the index page. //go back to the index page.
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header('Location: ' . $INGAME_WEBPATH); header('Location: ' . $INGAME_WEBPATH);
} else { } else {
header('Location: ' . $WEBPATH); header('Location: ' . $WEBPATH);
} }
exit; throw new SystemExit();
} }
} }
$pageElements['ingame_webpath'] = $INGAME_WEBPATH; $pageElements['ingame_webpath'] = $INGAME_WEBPATH;

@ -3,37 +3,38 @@
/** /**
* function plugins to get * function plugins to get
* plugins from the Database using pagination object * plugins from the Database using pagination object
* *
* @author shubham meena mentored by Matthew Lagoe * @author shubham meena mentored by Matthew Lagoe
*/ */
function plugins() function plugins()
{ {
if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) { if ( Ticket_User :: isMod( unserialize( $_SESSION['ticket_user'] ) ) ) {
$pagination = new Pagination( "SELECT * FROM plugins", "lib", 5, "Plugincache" ); $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['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['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast(); $pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent(); $pageResult['currentPage'] = $pagination -> getCurrent();
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH; $pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online // check if shard is online
try { try {
$dbs = new DBLayer( "shard" ); $dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online"; $pageResult['shard'] = "online";
} }
catch( PDOException $e ) { catch( PDOException $e ) {
$pageResult['shard'] = "offline"; $pageResult['shard'] = "offline";
} }
return( $pageResult ); return( $pageResult );
} else { } else {
// ERROR: No access! // ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header( "Location: index.php?page=error" ); header( "Location: index.php?page=error" );
exit; throw new SystemExit();
} }
} }

@ -2,8 +2,8 @@
/** /**
* function plugins_update to get * function plugins_update to get
* plugins updates from the Database using pagination object. * 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() function plugins_update()
@ -14,23 +14,24 @@ function plugins_update()
$pageResult['links'] = $pagination -> getLinks( 5 ); $pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast(); $pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent(); $pageResult['currentPage'] = $pagination -> getCurrent();
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH; $pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online // check if shard is online
try { try {
$dbs = new DBLayer( "shard" ); $dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online"; $pageResult['shard'] = "online";
} }
catch( PDOException $e ) { catch( PDOException $e ) {
$pageResult['shard'] = "offline"; $pageResult['shard'] = "offline";
} }
return( $pageResult ); return( $pageResult );
} else { } else {
// ERROR: No access! // ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header( "Location: index.php?page=error" ); header( "Location: index.php?page=error" );
exit; throw new SystemExit();
} }
} }

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

@ -12,8 +12,9 @@ function settings(){
if(($_GET['id'] != $_SESSION['id']) && (!Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) ){ if(($_GET['id'] != $_SESSION['id']) && (!Ticket_User::isMod(unserialize($_SESSION['ticket_user']))) ){
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
}else{ }else{
$webUser = new Webusers($_GET['id']); $webUser = new Webusers($_GET['id']);
$result = $webUser->getInfo(); $result = $webUser->getInfo();
@ -47,7 +48,8 @@ function settings(){
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Location: index.php"); header("Location: index.php");
exit; header("Cache-Control: max-age=1");
throw new SystemExit();
} }
} }

@ -8,20 +8,21 @@
function sgroup_list(){ function sgroup_list(){
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
global $WEBPATH; global $WEBPATH;
//if logged in //if logged in
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ if(Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
//if delete GET var is set and user is admin, then delete the groups entry. //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']))){ if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT); $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
$result['delete'] = Support_Group::deleteSupportGroup( $delete_id); $result['delete'] = Support_Group::deleteSupportGroup( $delete_id);
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Location: ".$INGAME_WEBPATH."?page=sgroup_list"); header("Location: ".$INGAME_WEBPATH."?page=sgroup_list");
}else{ }else{
header("Location: ".$WEBPATH."?page=sgroup_list"); header("Location: ".$WEBPATH."?page=sgroup_list");
} }
exit; throw new SystemExit();
} }
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE"; $result['isAdmin'] = "TRUE";
@ -33,13 +34,15 @@ function sgroup_list(){
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

@ -14,33 +14,33 @@ function show_queue(){
global $WEBPATH; global $WEBPATH;
//if logged in & queue id is given //if logged in & queue id is given
if(WebUsers::isLoggedIn() && isset($_GET['get'])){ if(WebUsers::isLoggedIn() && isset($_GET['get'])){
if( Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){ if( Ticket_User::isMod(unserialize($_SESSION['ticket_user']))){
//the queue you want to see. //the queue you want to see.
$result['queue_view'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING); $result['queue_view'] = filter_var($_GET['get'], FILTER_SANITIZE_STRING);
$user_id = unserialize($_SESSION['ticket_user'])->getTUserId(); $user_id = unserialize($_SESSION['ticket_user'])->getTUserId();
$queueArray = array(); $queueArray = array();
$queue_handler = new Ticket_Queue_handler(); $queue_handler = new Ticket_Queue_handler();
//Pagination Base Links //Pagination Base Links
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
$result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=".$result['queue_view'] ; $result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=".$result['queue_view'] ;
}else{ }else{
$result['pagination_base_link'] = $WEBPATH."?page=show_queue&get=".$result['queue_view'] ; $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()) { if (Helpers::check_if_game_client()) {
$result['getURL'] = $INGAME_WEBPATH."?page=show_queue&get=" . $result['queue_view']; $result['getURL'] = $INGAME_WEBPATH."?page=show_queue&get=" . $result['queue_view'];
}else{ }else{
$result['getURL'] = $WEBPATH."?page=show_queue&get=" . $result['queue_view']; $result['getURL'] = $WEBPATH."?page=show_queue&get=" . $result['queue_view'];
} }
if(isset($_GET['pagenum'])){ if(isset($_GET['pagenum'])){
$result['getURL'] = $result['getURL'] . "&pagenum=".$_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'])){ 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); $userid = filter_var($_GET['userid'], FILTER_SANITIZE_NUMBER_INT);
$groupid = filter_var($_GET['groupid'], 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); $who = filter_var($_GET['who'], FILTER_SANITIZE_STRING);
//create the custom queue //create the custom queue
$queue_handler->CreateQueue($userid, $groupid, $what, $how, $who); $queue_handler->CreateQueue($userid, $groupid, $what, $how, $who);
if (Helpers::check_if_game_client()) { 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; $result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}else{ }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_userid'] = $userid;
$result['prev_created_groupid'] = $groupid; $result['prev_created_groupid'] = $groupid;
$result['prev_created_what'] = $what; $result['prev_created_what'] = $what;
$result['prev_created_how'] = $how; $result['prev_created_how'] = $how;
$result['prev_created_who'] = $who; $result['prev_created_who'] = $who;
$result['getURL'] = $result['getURL'] . "&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who; $result['getURL'] = $result['getURL'] . "&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
} }
//if an action is set //if an action is set
if(isset($_POST['action'])){ if(isset($_POST['action'])){
switch($_POST['action']){ switch($_POST['action']){
@ -74,12 +74,12 @@ function show_queue(){
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id); $result['ACTION_RESULT'] = Ticket::assignTicket($user_id, $ticket_id);
break; break;
case "unAssignTicket": case "unAssignTicket":
$ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT); $ticket_id = filter_var($_POST['ticket_id'], FILTER_SANITIZE_NUMBER_INT);
$result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id); $result['ACTION_RESULT'] = Ticket::unAssignTicket($user_id, $ticket_id);
break; break;
case "create_queue": case "create_queue":
$userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT); $userid = filter_var($_POST['userid'], FILTER_SANITIZE_NUMBER_INT);
if (isset($_POST['groupid'])) { if (isset($_POST['groupid'])) {
@ -95,7 +95,7 @@ function show_queue(){
if (Helpers::check_if_game_client()) { 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; $result['pagination_base_link'] = $INGAME_WEBPATH."?page=show_queue&get=create&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
}else{ }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_userid'] = $userid;
$result['prev_created_groupid'] = $groupid; $result['prev_created_groupid'] = $groupid;
@ -103,20 +103,20 @@ function show_queue(){
$result['prev_created_how'] = $how; $result['prev_created_how'] = $how;
$result['prev_created_who'] = $who; $result['prev_created_who'] = $who;
$result['getURL'] = $result['getURL'] . "&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who; $result['getURL'] = $result['getURL'] . "&userid=".$userid."&groupid=".$groupid."&what=".$what."&how=".$how."&who=".$who;
break; break;
} }
} }
$queueArray = $queue_handler->getTickets($result['queue_view'], $user_id); $queueArray = $queue_handler->getTickets($result['queue_view'], $user_id);
//pagination //pagination
$result['links'] = $queue_handler->getPagination()->getLinks(5); $result['links'] = $queue_handler->getPagination()->getLinks(5);
$result['lastPage'] = $queue_handler->getPagination()->getLast(); $result['lastPage'] = $queue_handler->getPagination()->getLast();
$result['currentPage'] = $queue_handler->getPagination()->getCurrent(); $result['currentPage'] = $queue_handler->getPagination()->getCurrent();
//if queue_view is a valid parameter value //if queue_view is a valid parameter value
if ($queueArray != "ERROR"){ 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")); $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++; $i++;
} }
$result['user_id'] = unserialize($_SESSION['ticket_user'])->getTUserId(); $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['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")); $result['teamlist'] = Gui_Elements::make_table(Ticket_User::getModsAndAdmins(), Array("getTUserId","getExternId"), Array("tUserId","externId"));
$i = 0; $i = 0;
@ -143,25 +143,28 @@ function show_queue(){
global $INGAME_WEBPATH; global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH;
return $result; return $result;
}else{ }else{
//ERROR: Doesn't exist! //ERROR: Doesn't exist!
$_SESSION['error_code'] = "404"; $_SESSION['error_code'] = "404";
header("Cache-Control: max-age=1");
header("Location: ams?page=error"); header("Location: ams?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

@ -15,24 +15,25 @@ function show_sgroup(){
if( isset($_GET['id'])){ if( isset($_GET['id'])){
//['target_id'] holds the id of the group! //['target_id'] holds the id of the group!
$result['target_id'] = filter_var($_GET['id'], FILTER_SANITIZE_NUMBER_INT); $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 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']))){ if(isset($_GET['delete']) && Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT); $delete_id = filter_var($_GET['delete'], FILTER_SANITIZE_NUMBER_INT);
$result['delete'] = Support_Group::deleteUserOfSupportGroup( $delete_id, $result['target_id'] ); $result['delete'] = Support_Group::deleteUserOfSupportGroup( $delete_id, $result['target_id'] );
header("Cache-Control: max-age=1");
if (Helpers::check_if_game_client()) { if (Helpers::check_if_game_client()) {
header("Location: ".$INGAME_WEBPATH."?page=show_sgroup&id=" . $result['target_id']); header("Location: ".$INGAME_WEBPATH."?page=show_sgroup&id=" . $result['target_id']);
}else{ }else{
header("Location: ".$WEBPATH."?page=show_sgroup&id=" . $result['target_id']); header("Location: ".$WEBPATH."?page=show_sgroup&id=" . $result['target_id']);
} }
exit; throw new SystemExit();
} }
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE"; $result['isAdmin'] = "TRUE";
} }
$group = Support_Group::getGroup($result['target_id']); $group = Support_Group::getGroup($result['target_id']);
$result['groupsname'] = $group->getName(); $result['groupsname'] = $group->getName();
$result['groupemail'] = $group->getGroupEmail(); $result['groupemail'] = $group->getGroupEmail();
@ -58,26 +59,29 @@ function show_sgroup(){
} }
return $result; return $result;
}else{ }else{
//ERROR: No page specified! //ERROR: No page specified!
$_SESSION['error_code'] = "404"; $_SESSION['error_code'] = "404";
header("Cache-Control: max-age=1");
header("Location: ams?page=error"); header("Location: ams?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

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

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

@ -8,14 +8,14 @@
function show_user(){ function show_user(){
//if logged in //if logged in
if(WebUsers::isLoggedIn()){ if(WebUsers::isLoggedIn()){
//Users can only browse their own user page, while mods/admins can browse all user pages //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']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) || $_GET['id'] == $_SESSION['id'] ){
if(isset($_GET['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{ }else{
$result['target_id'] = $_SESSION['id']; $result['target_id'] = $_SESSION['id'];
} }
$webUser = new WebUsers($result['target_id']); $webUser = new WebUsers($result['target_id']);
$result['target_name'] = $webUser->getUsername(); $result['target_name'] = $webUser->getUsername();
@ -25,28 +25,30 @@ function show_user(){
$result['lastName'] = $info['LastName']; $result['lastName'] = $info['LastName'];
$result['country'] = $info['Country']; $result['country'] = $info['Country'];
$result['gender'] = $info['Gender']; $result['gender'] = $info['Gender'];
$ticket_user = Ticket_User::constr_ExternId($result['target_id']); $ticket_user = Ticket_User::constr_ExternId($result['target_id']);
$result['userPermission'] = $ticket_user->getPermission(); $result['userPermission'] = $ticket_user->getPermission();
if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){ if(Ticket_User::isAdmin(unserialize($_SESSION['ticket_user']))){
$result['isAdmin'] = "TRUE"; $result['isAdmin'] = "TRUE";
} }
$ticketlist = Ticket::getTicketsOf($ticket_user->getTUserId()); $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")); $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; global $INGAME_WEBPATH;
$result['ingame_webpath'] = $INGAME_WEBPATH; $result['ingame_webpath'] = $INGAME_WEBPATH;
return $result; return $result;
}else{ }else{
//ERROR: No access! //ERROR: No access!
$_SESSION['error_code'] = "403"; $_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error"); header("Location: index.php?page=error");
exit; throw new SystemExit();
} }
}else{ }else{
//ERROR: not logged in! //ERROR: not logged in!
header("Cache-Control: max-age=1");
header("Location: index.php"); header("Location: index.php");
exit; throw new SystemExit();
} }
} }

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

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

@ -14,10 +14,14 @@
// load required pages and turn error reporting on/off // load required pages and turn error reporting on/off
error_reporting( E_ALL ); error_reporting( E_ALL );
ini_set( 'display_errors', 'on' ); ini_set( 'display_errors', 'on' );
class SystemExit extends Exception {}
try {
if (!file_exists( '../is_installed')) { if (!file_exists( '../is_installed')) {
header("Cache-Control: max-age=1"); header("Cache-Control: max-age=1");
header('Location: ../setup', true, 303); header('Location: ../setup', true, 303);
die(); throw new SystemExit();
} }
require( '../config.php' ); require( '../config.php' );
@ -129,3 +133,6 @@ foreach( $hook_content as $key => $value )
// load the template with the variables in the $return array // load the template with the variables in the $return array
helpers :: loadTemplate( $page , $return ); helpers :: loadTemplate( $page , $return );
}
catch (SystemExit $e) { /* do nothing */ }

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

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

@ -10,7 +10,7 @@
$MY_PATH = dirname(__FILE__); $MY_PATH = dirname(__FILE__);
if(file_exists("parser.stop")) { if(file_exists("parser.stop")) {
exit(0); die();
} }
require_once("class/mySQL_class.php"); require_once("class/mySQL_class.php");
@ -58,7 +58,7 @@
require_once("class/Stats_class.php"); require_once("class/Stats_class.php");
$atom_insert = array(); $atom_insert = array();
$_CACHE = new ValueCache(); $_CACHE = new ValueCache();
//new generator for API xml files. //new generator for API xml files.
@ -109,7 +109,7 @@
$stop_time = $microstop[0] + $microstop[1]; $stop_time = $microstop[0] + $microstop[1];
#$log->logf("Expired time: ".($stop_time - $start_time)); #$log->logf("Expired time: ".($stop_time - $start_time));
#foreach($chars as $cid) { #foreach($chars as $cid) {
#STEP 1: load and register atoms #STEP 1: load and register atoms
@ -149,7 +149,7 @@
#$log->logf("Expired time: ".($stop_time - $start_time)); #$log->logf("Expired time: ".($stop_time - $start_time));
#$log->logi("Driving data... ",false); #$log->logi("Driving data... ",false);
#STEP 2: drive data #STEP 2: drive data
$_CACHE->setChar($cdata); $_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"); $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->logf("Expired time: ".($stop_time - $start_time));
#$log->logi("Clearing atom data [PASS ".$dtrun."]... ",false); #$log->logi("Clearing atom data [PASS ".$dtrun."]... ",false);
//clear atom state for completed objectives //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)"); #$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) { if(sizeof($DBc->longQuery) > 0) {
$log->logf("Longer queries: ".var_export($DBc->longQuery,true)); $log->logf("Longer queries: ".var_export($DBc->longQuery,true));
} }
#$log->logf("Run complete; exiting..."); #$log->logf("Run complete; exiting...");
$log->close(); $log->close();
exit(0); die();
?> ?>

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

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

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

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

Loading…
Cancel
Save