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

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

@ -3,12 +3,12 @@
/**
* Global and Local Hooks for the API key Management 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
* 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
@ -27,7 +27,7 @@ function api_key_management_hook_display()
global $return_set;
// to display plugin name in menu bar
$return_set['menu_display'] = 'API Key Management';
}
}
/**
* Local Hook to validate the posted data
@ -37,12 +37,12 @@ function hook_validate( $var )
if ( isset( $var ) && !empty( $var ) )
{
return true;
}
}
else
{
return false;
}
}
}
}
/**
* Local Hook to set the POST variables and validate them
@ -51,7 +51,7 @@ function hook_variables()
{
global $var_set;
global $return_set;
if ( hook_validate( $_POST['expDate'] ) && hook_validate( $_POST['sp_name'] ) && hook_validate( $_POST['api_type'] )
&& hook_validate( $_POST['character_name'] ) )
{
@ -63,12 +63,12 @@ function hook_variables()
$var_set['AddedOn'] = date( "Y-m-d H:i:s" );
$var_set['Items'] = '';
$return_set['gen_key_validate'] = 'true';
}
}
else
{
$return_set['gen_key_validate'] = 'false';
}
}
}
}
/**
* 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`
ADD CONSTRAINT `ams_api_keys_ibfk_1` FOREIGN KEY (`User`) REFERENCES `ryzom_ams`.`ams_user` (`Login`);";
$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
* It also calls the local hook
*/
@ -121,63 +121,63 @@ function api_key_management_hook_store_db()
{
global $var_set;
global $return_set;
// if the form been submited move forward
if ( @hook_validate( $_POST['gen_key'] ) ) {
// local hook to validate the POST variables
hook_variables();
// if validation successfull move forward
if ( $return_set['gen_key_validate'] == 'true' && $_GET['plugin_action'] == 'generate_key' )
{
// this part generated the access token
include 'generate_key.php';
$var_set['AccessToken'] = generate_key :: randomToken( 56, false, true, false );
// database connection
$db = new DBLayer( 'lib' );
// insert the form data to the database
$db -> insert( 'ams_api_keys', $var_set );
// redirect to the the main page with success code
// 1 refers to the successfull addition of key to the database
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
*/
function api_key_management_hook_load_db()
{
global $var_set;
global $return_set;
$db = new DBLayer( 'lib' );
if ( isset( $_SESSION['user'] ) )
{
// returns the registered keys
$sth = $db -> select( 'ams_api_keys', array( 'user' => $_SESSION['user'] ), 'User = :user' );
$row = $sth -> fetchAll();
$return_set['api_keys'] = $row;
// fetch the character from the array to compare
$com = array_column( $return_set['api_keys'], 'UserCharacter' );
// returns the characters with respect to the user id in the ring_tool->characters
$db = new DBLayer( 'ring' );
$sth = $db -> selectWithParameter( 'char_name', 'characters' , array(), '1' );
$row = $sth -> fetch();
// loop through the character list and remove the character if already have an api key
$return_set['characters'] = array_diff( $row, $com );
}
}
}
}
/**
* 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 $return_set;
$db = new DBLayer( 'lib' );
if ( isset( $_GET['delete_id'] ) )
{
// 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' );
// redirecting to the API_key_management plugins template with success code
// 2 refers to the succssfull delete condition
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
* the content to use in the smarty templates
*
*
* @return $return_set global array returns the template data
*/
function api_key_management_hook_return_global()

@ -33,13 +33,6 @@ CREATE TABLE IF NOT EXISTS `ams_querycache` (
`db` varchar(80) NOT NULL
) 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
) 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
* we want to activate. After getting id we update the respective plugin with status
* activate which here means '1' .
*
* @author Shubham Meena, mentored by Matthew Lagoe
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function activate_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to activate
@ -21,21 +21,24 @@ function activate_plugin() {
if ( $result )
{
// if result is successfull it redirects and shows success message
header("Cache-Control: max-age=1");
header( "Location: index.php?page=plugins&result=3" );
exit;
}
throw new SystemExit();
}
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" );
exit;
}
}
throw new SystemExit();
}
}
else
{
//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" );
exit;
}
}
throw new SystemExit();
}
}
}

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

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

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

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

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

@ -10,12 +10,12 @@ function create_ticket(){
global $INGAME_WEBPATH;
global $WEBPATH;
if(WebUsers::isLoggedIn() && isset($_SESSION['ticket_user'])){
if(isset($_POST['target_id'])){
//if target_id is the same as session id or is admin
if( ($_POST['target_id'] == $_SESSION['id']) || Ticket_User::isMod(unserialize($_SESSION['ticket_user'])) ){
$category = filter_var($_POST['Category'], FILTER_SANITIZE_NUMBER_INT);
$title = filter_var($_POST['Title'], FILTER_SANITIZE_STRING);
$content = filter_var($_POST['Content'], FILTER_SANITIZE_STRING);
@ -31,37 +31,43 @@ function create_ticket(){
$ticket_id = Ticket::create_Ticket($title, $content, $category, $author, unserialize($_SESSION['ticket_user'])->getTUserId(),0, $_POST);
//redirect to the new ticket.
if (Helpers::check_if_game_client()) {
header("Cache-Control: max-age=1");
header("Location: ".$INGAME_WEBPATH."?page=show_ticket&id=".$ticket_id);
}else{
header("Cache-Control: max-age=1");
header("Location: ".$WEBPATH."?page=show_ticket&id=".$ticket_id);
}
exit;
throw new SystemExit();
}catch (PDOException $e) {
//ERROR: LIB DB is not online!
print_r($e);
exit;
throw new SystemExit();
header("Cache-Control: max-age=1");
header("Location: index.php");
exit;
throw new SystemExit();
}
}else{
//ERROR: permission denied!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
exit;
throw new SystemExit();
}
}else{
//ERROR: The form was not filled in correclty
header("Cache-Control: max-age=1");
header("Location: index.php?page=create_ticket");
exit;
}
throw new SystemExit();
}
}else{
//ERROR: user is not logged in
header("Cache-Control: max-age=1");
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
* we want to activate. After getting id we update the respective plugin with status
* deactivate which here means '0'.
*
* @author Shubham Meena, mentored by Matthew Lagoe
*
* @author Shubham Meena, mentored by Matthew Lagoe
*/
function deactivate_plugin() {
// if logged in
if ( WebUsers :: isLoggedIn() ) {
if ( isset( $_GET['id'] ) )
{
// id of plugin to deactivate
@ -20,24 +20,28 @@ function deactivate_plugin() {
$db = new DBLayer( 'lib' );
$result = $db -> update( "plugins", array( 'Status' => '0' ), "Id = $id" );
if ( $result )
{
// if result is successfull it redirects and shows success message
{
// if result is successfull it redirects and shows success message
header("Cache-Control: max-age=1");
header( "Location: index.php?page=plugins&result=5" );
exit;
}
throw new SystemExit();
}
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" );
exit;
}
}
throw new SystemExit();
}
}
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" );
exit;
}
}
throw new SystemExit();
}
}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -2,8 +2,8 @@
/**
* function plugins_update to get
* plugins updates from the Database using pagination object.
*
* @author shubham meena mentored by Matthew Lagoe
*
* @author shubham meena mentored by Matthew Lagoe
*/
function plugins_update()
@ -14,23 +14,24 @@ function plugins_update()
$pageResult['links'] = $pagination -> getLinks( 5 );
$pageResult['lastPage'] = $pagination -> getLast();
$pageResult['currentPage'] = $pagination -> getCurrent();
global $INGAME_WEBPATH;
$pageResult['ingame_webpath'] = $INGAME_WEBPATH;
// check if shard is online
try {
$dbs = new DBLayer( "shard" );
$pageResult['shard'] = "online";
}
}
catch( PDOException $e ) {
$pageResult['shard'] = "offline";
}
}
return( $pageResult );
} else {
// ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
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);
$user = filter_var($_GET["user"], FILTER_SANITIZE_STRING);
$key = filter_var($_GET["key"], FILTER_SANITIZE_STRING);
$target_id = WebUsers::getId($user);
$webUser = new WebUsers($target_id);
if( (WebUsers::getIdFromEmail($email) == $target_id) && (hash('sha512',$webUser->getHashedPass()) == $key) ){
//you are allowed on the page!
$GETString = "";
foreach($_GET as $key => $value){
$GETString = $GETString . $key . '=' . $value . "&";
}
}
if($GETString != ""){
$GETString = '?'.$GETString;
}
$pageElements['getstring'] = $GETString;
return $pageElements;
}else{
global $WEBPATH;
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
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']))) ){
//ERROR: No access!
$_SESSION['error_code'] = "403";
header("Cache-Control: max-age=1");
header("Location: index.php?page=error");
exit;
throw new SystemExit();
}else{
$webUser = new Webusers($_GET['id']);
$result = $webUser->getInfo();
@ -47,7 +48,8 @@ function settings(){
}else{
//ERROR: not logged in!
header("Location: index.php");
exit;
header("Cache-Control: max-age=1");
throw new SystemExit();
}
}

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

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

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

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

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

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

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

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

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

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

@ -14,10 +14,14 @@
// load required pages and turn error reporting on/off
error_reporting( E_ALL );
ini_set( 'display_errors', 'on' );
class SystemExit extends Exception {}
try {
if (!file_exists( '../is_installed')) {
header("Cache-Control: max-age=1");
header('Location: ../setup', true, 303);
die();
throw new SystemExit();
}
require( '../config.php' );
@ -129,3 +133,6 @@ foreach( $hook_content as $key => $value )
// load the template with the variables in the $return array
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 .= ryzom_render_login_form($name, false);
echo ryzom_app_render(_t('app_'.APP_NAME), $c);
exit;
die();
}
return false;
}
@ -118,7 +118,7 @@ function ryzom_app_authenticate(&$user, $ask_login=true, $welcome_message='', $w
$user['id'] = ryzom_get_user_id($cid, $user['char_name'], $user['creation_date'], $user);
$user['gender'] = ryzom_get_user_gender($user['id']);
$user['ig'] = $ig;
$user['lang'] = $_SESSION['lang'];
if (!isset($user['groups']))

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

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

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

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

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

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

Loading…
Cancel
Save