/** * This function is beign used to load info that's needed for the login page. * it will try to auto-login, this can only be used while ingame, the web browser sends additional cookie information that's also stored in the open_ring db. * We will compare the values and if they match, the user will be automatically logged in! * @author Daan Janssens, mentored by Matthew Lagoe */ function login() { global $INGAME_WEBPATH; global $WEBPATH; if (helpers::check_if_game_client()) { //check if you are logged in ingame, this should auto login $result = Helpers::check_login_ingame(); if ($result) { //handle successful login $_SESSION['user'] = $result['name']; $_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); } throw new SystemExit(); } } $pageElements['ingame_webpath'] = $INGAME_WEBPATH; $GETString = ""; foreach ($_GET as $key => $value) { $GETString = $GETString . $key . '=' . $value . "&"; } if ($GETString != "") { $GETString = '?' . $GETString; } $pageElements['getstring'] = $GETString; return $pageElements; }
/** * checks if entered values before registering are valid. * @param $values array with Username,Password, ConfirmPass and Email. * @return string Info: Returns a string, if input data is valid then "success" is returned, else an array with errors */ public function check_Register($values) { // check values if (isset($values["Username"]) and isset($values["Password"]) and isset($values["ConfirmPass"]) and isset($values["Email"])) { $user = Users::checkUser($values["Username"]); $pass = Users::checkPassword($values["Password"]); $cpass = Users::confirmPassword($pass, $values["Password"], $values["ConfirmPass"]); $email = Users::checkEmail($values["Email"]); } else { $user = ""; $pass = ""; $cpass = ""; $email = ""; } if (helpers::check_if_game_client() or isset($FORCE_INGAME)) { if (isset($_POST["TaC"])) { $tac = "success"; } } else { $tac = "success"; } if ($user == "success" and $pass == "success" and $cpass == "success" and $email == "success" and $tac == "success") { return "success"; } else { global $TOS_URL; $pageElements = array('USERNAME' => $user, 'PASSWORD' => $pass, 'CPASSWORD' => $cpass, 'EMAIL' => $email, 'TOS_URL' => $TOS_URL); if ($user != "success") { $pageElements['USERNAME_ERROR'] = 'TRUE'; } else { $pageElements['USERNAME_ERROR'] = 'FALSE'; } if ($pass != "success") { $pageElements['PASSWORD_ERROR'] = 'TRUE'; } else { $pageElements['PASSWORD_ERROR'] = 'FALSE'; } if ($cpass != "success") { $pageElements['CPASSWORD_ERROR'] = 'TRUE'; } else { $pageElements['CPASSWORD_ERROR'] = 'FALSE'; } if ($email != "success") { $pageElements['EMAIL_ERROR'] = 'TRUE'; } else { $pageElements['EMAIL_ERROR'] = 'FALSE'; } if (isset($_POST["TaC"])) { $pageElements['TAC_ERROR'] = 'FALSE'; } else { $pageElements['TAC_ERROR'] = 'TRUE'; } return $pageElements; } }
/** * workhorse of the website, it loads the template and shows it or returns th html. * it uses smarty to load the $template, but before displaying the template it will pass the $vars to smarty. Also based on your language settings a matching * array of words & sentences for that page will be loaded. In case the $returnHTML parameter is set to true, it will return the html instead of displaying the template. * * @param $template the name of the template(page) that we want to load. * @param $vars an array of variables that should be loaded by smarty before displaying or returning the html. * @param $returnHTML (default=false) if set to true, the html that should have been displayed, will be returned. * @return in case $returnHTML=true, it returns the html of the template being loaded. */ public static function loadTemplate($template, $vars = array(), $returnHTML = false) { //error_log(print_r($_GET,true)); //error_log(print_r($_POST,true)); global $AMS_LIB; global $SITEBASE; global $AMS_TRANS; global $INGAME_LAYOUT; global $AMS_CACHEDIR; global $AMS_PLUGINS; // define('SMARTY_SPL_AUTOLOAD',1); require_once $AMS_LIB . '/smarty/libs/Smarty.class.php'; spl_autoload_register('__autoload'); $smarty = new Smarty(); $smarty->setCompileDir($SITEBASE . '/templates_c/'); $smarty->setCacheDir($AMS_CACHEDIR); $smarty->setConfigDir($SITEBASE . '/configs/'); // turn smarty debugging on/off $smarty->debugging = false; // caching must be disabled for multi-language support $smarty->caching = false; $smarty->cache_lifetime = 300; $smarty->addPluginsDir($AMS_PLUGINS); if (function_exists('apc_cache_info')) { // production //$smarty->caching = true; //$smarty->setCachingType("apc"); //$smarty->compile_check = false; } // needed by smarty. helpers::create_folders(); global $FORCE_INGAME; // if ingame, then use the ingame templates if (helpers::check_if_game_client() or $FORCE_INGAME) { $smarty->template_dir = $AMS_LIB . '/ingame_templates/'; $smarty->setConfigDir($AMS_LIB . '/configs'); $variables = parse_ini_file($AMS_LIB . '/configs/ingame_layout.ini', true); foreach ($variables[$INGAME_LAYOUT] as $key => $value) { $smarty->assign($key, $value); } } else { $smarty->template_dir = $SITEBASE . '/templates/'; $smarty->setConfigDir($SITEBASE . '/configs'); } foreach ($vars as $key => $value) { $smarty->assign($key, $value); } // load page specific variables that are language dependent $variables = Helpers::handle_language(); if ($template != 'layout_plugin') { foreach ($variables[$template] as $key => $value) { $smarty->assign($key, $value); } } // load ams content variables that are language dependent foreach ($variables['ams_content'] as $key => $value) { $smarty->assign($key, $value); } //load ams content variables that are language dependent foreach ($variables['ams_content'] as $key => $value) { $smarty->assign($key, $value); } $id = session_id(); $smarty->assign("sessionid", $id); $dbl = new DBLayer("lib"); $statement = $dbl->executeWithoutParams("SELECT * FROM settings"); $rows = $statement->fetchAll(); foreach ($rows as &$value) { $smarty->assign($value['Setting'], $value['Value']); } // smarty inheritance for loading the matching wrapper layout (with the matching menu bar) if (isset($vars['permission']) && $vars['permission'] == 3) { $inherited = "extends:layout_admin.tpl|"; } else { if (isset($vars['permission']) && $vars['permission'] == 2) { $inherited = "extends:layout_mod.tpl|"; } else { if (isset($vars['permission']) && $vars['permission'] == 1) { $inherited = "extends:layout_user.tpl|"; } else { $inherited = ""; } } } // if $returnHTML is set to true, return the html by fetching the template else display the template. if ($returnHTML == true) { return $smarty->fetch($inherited . $template . '.tpl'); } else { $smarty->display($inherited . $template . '.tpl'); } }