diff --git a/includes/class.achievement.php b/includes/class.achievement.php index 4ef68740..ef6498c8 100644 --- a/includes/class.achievement.php +++ b/includes/class.achievement.php @@ -68,7 +68,7 @@ class Achievement extends BaseType return $this->criteria[$idx]; } - public function addSelfToJScript(&$gAchievements) + public function addGlobalsToJScript(&$gAchievements) { $gAchievements[$this->Id] = array( 'icon' => $this->template['iconString'], @@ -92,13 +92,13 @@ class Achievement extends BaseType if (isset($lookup['item'])) { $rewItems = new ItemList(array(['i.entry', $lookup['item']])); - $rewItems->addSelfToJScript($gItems); + $rewItems->addGlobalsToJScript($gItems); } if (isset($lookup['title'])) { $rewTitles = new TitleList(array(['Id', $lookup['title']])); - $rewTitles->addSelfToJScript($gTitles); + $rewTitles->addGlobalsToJScript($gTitles); } } @@ -194,7 +194,7 @@ class Achievement extends BaseType return array( "n" => Util::localizedString($this->template, 'name'), "s" => $this->template['faction'], - "t" => TYPEID_ACHIEVEMENT, + "t" => TYPE_ACHIEVEMENT, "ti" => $this->Id ); } @@ -255,13 +255,13 @@ class AchievementList extends BaseTypeList if (isset($lookup['item'])) { $rewItems = new ItemList(array(['i.entry', array_unique($lookup['item'])])); - $rewItems->addSelfToJScript($gItems); + $rewItems->addGlobalsToJScript($gItems); } if (isset($lookup['title'])) { $rewTitles = new TitleList(array(['Id', array_unique($lookup['title'])])); - $rewTitles->addSelfToJScript($gTitles); + $rewTitles->addGlobalsToJScript($gTitles); } } diff --git a/includes/class.item.php b/includes/class.item.php index b6168f08..539d45af 100644 --- a/includes/class.item.php +++ b/includes/class.item.php @@ -159,7 +159,7 @@ class Item extends BaseType ); } - public function addSelfToJScript(&$gItems) + public function addGlobalsToJScript(&$gItems) { $gItems[$this->Id] = array( 'name' => $this->name, diff --git a/includes/class.quest.php b/includes/class.quest.php index 04792911..edd21d34 100644 --- a/includes/class.quest.php +++ b/includes/class.quest.php @@ -59,7 +59,7 @@ class Quest extends BaseType { return array( "n" => Util::localizedString($this->template, 'Title'), - "t" => TYPEID_QUEST, + "t" => TYPE_QUEST, "ti" => $this->Id, "c" => $this->cat1, "c2" => $this->cat2 @@ -138,7 +138,7 @@ class Quest extends BaseType if ($tId = $this->template['RewardTitleId']) { $title = new Title($tId); - $title->addSelfToJScript($gTitles); + $title->addGlobalsToJScript($gTitles); } } } @@ -194,19 +194,19 @@ class QuestList extends BaseTypeList if (!empty($items)) { $items = new ItemList(array(['i.entry', $items])); - $items->addSelfToJScript($gItems); + $items->addGlobalsToJScript($gItems); } if (!empty($spells)) { $spells = new SpellList(array(['id', $spells])); - $spells->addSelfToJScript($gSpells); + $spells->addGlobalsToJScript($gSpells); } if (!empty($titles)) { $titles = new TitleList(array(['id', $titles])); - $titles->addSelfToJScript($gTitles); + $titles->addGlobalsToJScript($gTitles); } } } diff --git a/includes/class.spell.php b/includes/class.spell.php index 96520016..52cc3615 100644 --- a/includes/class.spell.php +++ b/includes/class.spell.php @@ -928,7 +928,7 @@ class Spell extends BaseType ); } - public function addSelfToJScript(&$gSpells) + public function addGlobalsToJScript(&$gSpells) { // if the spell creates an item use the itemIcon instead if ($this->template['effect1CreateItemId']) diff --git a/includes/class.title.php b/includes/class.title.php index 8881df0b..044fc489 100644 --- a/includes/class.title.php +++ b/includes/class.title.php @@ -49,7 +49,7 @@ class Title extends BaseType return $data; } - public function addSelfToJScript(&$gTitles) + public function addGlobalsToJScript(&$gTitles) { $gTitles[$this->Id] = ['name' => Util::jsEscape($this->name[GENDER_MALE])]; diff --git a/includes/defines.php b/includes/defines.php index bfb19b1c..19b1bb86 100644 --- a/includes/defines.php +++ b/includes/defines.php @@ -8,22 +8,22 @@ if (!defined('AOWOW_REVISION')) */ // TypeIds -define('TYPEID_NPC', 1); -define('TYPEID_OBJECT', 2); -define('TYPEID_ITEM', 3); -define('TYPEID_ITEMSET', 4); -define('TYPEID_QUEST', 5); -define('TYPEID_SPELL', 6); -define('TYPEID_ZONE', 7); -define('TYPEID_FACTION', 8); -define('TYPEID_PET', 9); -define('TYPEID_ACHIEVEMENT', 10); -define('TYPEID_TITLE', 11); -define('TYPEID_EVENT', 12); -define('TYPEID_CLASS', 13); -define('TYPEID_RACE', 14); -define('TYPEID_SKILL', 15); -define('TYPEID_CURRENCY', 17); +define('TYPE_NPC', 1); +define('TYPE_OBJECT', 2); +define('TYPE_ITEM', 3); +define('TYPE_ITEMSET', 4); +define('TYPE_QUEST', 5); +define('TYPE_SPELL', 6); +define('TYPE_ZONE', 7); +define('TYPE_FACTION', 8); +define('TYPE_PET', 9); +define('TYPE_ACHIEVEMENT', 10); +define('TYPE_TITLE', 11); +define('TYPE_EVENT', 12); +define('TYPE_CLASS', 13); +define('TYPE_RACE', 14); +define('TYPE_SKILL', 15); +define('TYPE_CURRENCY', 17); define('CACHETYPE_PAGE', 0); define('CACHETYPE_TOOLTIP', 1); diff --git a/includes/utilities.php b/includes/utilities.php index 968eee8f..0f2e4030 100644 --- a/includes/utilities.php +++ b/includes/utilities.php @@ -33,7 +33,7 @@ class BaseType public function getListviewData() { } // should return data to extend global js variables for a certain type (e.g. g_items) - public function addSelfToJScript(&$ref) { } + public function addGlobalsToJScript(&$ref) { } // should return data to extend global js variables for the rewards provided by this type (e.g. g_titles) public function addRewardsToJscript(&$ref1, &$ref2 = null, &$ref3 = null) { } @@ -142,11 +142,11 @@ class BaseTypeList return $data; } - public function addSelfToJScript(&$ref) + public function addGlobalsToJScript(&$ref) { // no extra queries required, just call recursively foreach ($this->container as $type) - $type->addSelfToJScript($ref); + $type->addGlobalsToJScript($ref); } public function addRewardsToJScript(&$ref1, &$ref2 = null, &$ref3 = null) @@ -177,7 +177,7 @@ class Lang public static function load($loc) { - if (@(include('localization/locale_'.$loc.'.php')) !== 1) + if (@(require 'localization/locale_'.$loc.'.php')) !== 1 die('File for localization '.$loc.' not found.'); foreach ($lang as $k => $v) diff --git a/index.php b/index.php index ddc7a7d8..c270d2e3 100644 --- a/index.php +++ b/index.php @@ -5,12 +5,12 @@ define('AOWOW_REVISION', 12); if (!file_exists('config/config.php')) { $cwDir = /*$_SERVER['DOCUMENT_ROOT']; //*/getcwd(); - include 'setup/setup.php'; + require 'setup/setup.php'; exit; } // include all necessities, set up basics -include 'includes/kernel.php'; +require 'includes/kernel.php'; switch ($pageCall) { @@ -58,13 +58,13 @@ switch ($pageCall) case 'zone': case 'zones': if (file_exists('pages/'.$pageCall.'.php')) - include 'pages/'.$pageCall.'.php'; + require 'pages/'.$pageCall.'.php'; else - include 'pages/error.php'; + require 'pages/error.php'; break; case 'talent': // tool: talent calculator case 'petcalc': // tool: pet talent calculator - include 'pages/talent.php'; + require 'pages/talent.php'; break; /* called by script */ case 'contactus': @@ -91,11 +91,11 @@ switch ($pageCall) break; case 'search': // tool: quick search case 'data': // dataset-loader - include $pageCall.'.php'; + require $pageCall.'.php'; break; /* other */ case '': // no parameter given -> MainPage - include 'pages/main.php'; + require 'pages/main.php'; break; case 'latest-comments': case 'latest-screenshots': @@ -105,25 +105,25 @@ switch ($pageCall) case 'missing-videos': case 'unrated-comments': case 'random': - include 'pages/miscTools.php'; + require 'pages/miscTools.php'; break; case 'setup': if (User::isInGroup(U_GROUP_EMPLOYEE)) { - include 'setup/syncronize.php'; + require 'setup/syncronize.php'; break; } case 'build': if (User::isInGroup(U_GROUP_EMPLOYEE) && !empty($pageParam)) { - include 'setup/tools/dataset-assembler/'.$pageParam.'.php'; + require 'setup/tools/dataset-assembler/'.$pageParam.'.php'; break; } default: // unk parameter given -> ErrorPage if (isset($_GET['power'])) die('$WowheadPower.register(0, '.User::$localeId.', {})'); else // in conjunction with a propper rewriteRule in .htaccess... - include 'pages/error.php'; + require 'pages/error.php'; break; } diff --git a/pages/account.php b/pages/account.php new file mode 100644 index 00000000..0935458b --- /dev/null +++ b/pages/account.php @@ -0,0 +1,330 @@ + 'activate_usernamelength', + 'ACCT_PASSWORD_LENGTH' => 'activate_passwordlength', + 'ACCT_USERNAME_SYMBOLS' => 'activate_invalidusername', + 'ACCT_PASSWORD_SYMBOLS' => 'activate_invalidpassword', + 'ACCT_EMAIL_SYMBOLS' => 'signup_emailinvalid', + + 'ACCT_PASSWORDS_NOT_EQUAL' => 'signup_passwordsnotequal', + 'ACCT_USERNAME_EXISTS' => 'activate_usernameinuse', + 'ACCT_NO_SUCH_ACCT' => 'signin_un_or_pass_fail', + 'ACCT_IP_LOCKED' => 'signin_ip_locked', + + 'ACCT_SIGNUP_BLOCKED' => 'signup_blocked', + 'ACCT_SIGNIN_BLOCKED' => 'signin_blocked', + + 'ACCT_INTERNAL_ERROR' => 'internal_error', +)); + +enum(array( // UserPropsLimits + 'USERNAME_LENGTH_MIN' => 4, + 'USERNAME_LENGTH_MAX' => 16, + 'PASSWORD_LENGTH_MIN' => 6, + 'PASSWORD_LENGTH_MAX' => 16, +)); +*/ + +if (!in_array($pageParam, array('dashboard', '', 'signin', 'signup', 'signout', 'signin_do', 'signup_do', 'forgotpassword', 'forgotusername'))) + require 'error.php'; + +function signin() +{ + if (!isset($_POST['username']) || !isset($_POST['password'])) + return Lang::$account['userNotFound']; + + $username = $_POST['username']; + $password = $_POST['password']; + $remember = $_POST['remember_me'] == 'yes'; + + // handle login try limitation + $ipBan = DB::Auth()->selectRow('SELECT ip, count, UNIX_TIMESTAMP(unbanDate) as unbanDate FROM ?_account_bannedIPs WHERE type = 0 AND ip = ?s', + $_SERVER['REMOTE_ADDR'] + ); + + if (!$ipBan) // no entry exists; set count to 1 + DB::Auth()->query('INSERT INTO ?_account_bannedIPs VALUES (?s, 0, 1, FROM_UNIXTIME(?))', + $_SERVER['REMOTE_ADDR'], + time() + $GLOBALS['AoWoWconf']['loginFailTime'] + ); + else if ($ipBan['unbanDate'] < time()) // ip has accumulated counts but time expired; reset count to 1 + DB::Auth()->query('INSERT IGNORE INTO ?_account_bannedIPs VALUES (?s, 0, 1, ?)', + $_SERVER['REMOTE_ADDR'], + time() + $GLOBALS['AoWoWconf']['loginFailTime'] + ); + else // entry already exists; increment count + DB::Auth()->query('UPDATE ?_account_bannedIPs SET count = count + 1, unbanDate = FROM_UNIXTIME(?) WHERE ip = ?s', + time() + $GLOBALS['AoWoWconf']['loginFailTime'], + $_SERVER['REMOTE_ADDR'] + ); + + $id = DB::Auth()->SelectCell('SELECT id FROM ?_account WHERE user = ?', + Util::sqlEscape($username) + ); + + if (!$id) + return Lang::$account['userNotFound']; + + User::init($id); + + switch (User::Auth($password)) + { + case AUTH_OK: + DB::Auth()->query('DELETE FROM ?_account_bannedIPs WHERE type = 0 AND ip = ?s', + $_SERVER['REMOTE_ADDR'] + ); + DB::Auth()->query('UPDATE ?_account SET lastLogin = FROM_UNIXTIME(?), timeout = FROM_UNIXTIME(?) WHERE id = ?', + time(), + $remember ? 0 : time() + $GLOBALS['AoWoWconf']['sessionTimeout'], + $id + ); + User::writeCookie(); // overwrites the current user + return; + case AUTH_BANNED: + User::writeCookie(); + return Lang::$account['userBanned']; + case AUTH_WRONGPASS: + User::destroy(); + return Lang::$account['wrongPass']; + case AUTH_IPBANNED: + User::destroy(); + return sprintf(Lang::$account['loginsExceeded'], round($GLOBALS['AoWoWconf']['loginFailTime'] / 60)); + default: + return; + } +} + +function signup() +{ +/* $username = Get(GET_STRING, 'username', 'POST'); + $password = Get(GET_STRING, 'password', 'POST'); + $pwd2 = Get(GET_STRING, 'password2', 'POST'); + $email = Get(GET_STRING, 'email', 'POST'); + $remember = Get(GET_BOOL, 'remember_me', 'POST'); + + if($password != $pwd2) + { + $this->acct_error = ACCT_PASSWORDS_NOT_EQUAL; + $this->type = 'signup'; + return; + } + + // Check length + if(strlen($username) > USERNAME_LENGTH_MAX || strlen($username) < USERNAME_LENGTH_MIN) + { + $this->acct_error = ACCT_USERNAME_LENGTH; + $this->type = 'signup'; + return; + } + if(strlen($password) > PASSWORD_LENGTH_MAX || strlen($password) < PASSWORD_LENGTH_MIN) + { + $this->acct_error = ACCT_PASSWORD_LENGTH; + $this->type = 'signup'; + return; + } + + // Check symbols + if(preg_match('/[^\w\d]/i', $username)) + { + $this->acct_error = ACCT_USERNAME_SYMBOLS; + $this->type = 'signup'; + return; + } + if(preg_match('/[^\w\d!"#\$%]/', $password)) + { + $this->acct_error = ACCT_PASSWORD_SYMBOLS; + $this->type = 'signup'; + return; + } + if(!preg_match('/^([a-z0-9._-]+)(\+[a-z0-9._-]+)?(@[a-z0-9.-]+\.[a-z]{2,4})$/i', $email)) + { + $this->acct_error = ACCT_EMAIL_SYMBOLS; + $this->type = 'signup'; + return; + } + + // After 5 signup tries in a row, + // or after a single successful signup, + // the signup feature is blocked for 3 min + // and the time is expanded to full-time block. + + DB::Realm()->Query('DELETE FROM account_ip_signup WHERE ip = ? AND time <= ?d', $_SERVER['REMOTE_ADDR'], time() - 3*MINUTE); + DB::Realm()->Query('INSERT IGNORE INTO account_ip_signup (ip,time,tries) VALUES (?,?d,?d)', $_SERVER['REMOTE_ADDR'], time(), 0); + $tries = DB::Realm()->SelectCell('SELECT tries FROM account_ip_signup WHERE ip = ?', $_SERVER['REMOTE_ADDR']); + if($tries >= 5) + { + DB::Realm()->Query('UPDATE account_ip_signup SET time = ?d WHERE ip = ?', time(), $_SERVER['REMOTE_ADDR']); + $this->acct_error = ACCT_SIGNUP_BLOCKED; + $this->type = 'signup'; + return; + } + DB::Realm()->Query('UPDATE account_ip_signup SET tries = tries + 1 WHERE ip = ?', $_SERVER['REMOTE_ADDR']); + + $result = DB::Realm()->SelectCell('SELECT 1 FROM account WHERE username = ?', $username); + if($result) + { + $this->acct_error = ACCT_USERNAME_EXISTS; + $this->type = 'signup'; + return; + } + + DB::Realm()->Query('UPDATE account_ip_signup SET tries = tries + 5 WHERE ip = ?', $_SERVER['REMOTE_ADDR']); + $id = DB::Realm()->Query(' + INSERT INTO account (username,sha_pass_hash,email,joindate,expansion,last_ip) + VALUES (?,?,?,NOW(),?d,?) + ', + strtoupper($username), + $hash = AccountPage::CreateHash($username, $password), + strtolower($email), + 2, + $_SERVER['REMOTE_ADDR'] + ); + if($id) + { + DB::Realm()->Query('UPDATE account_ip_signup SET tries = tries + 5 WHERE ip = ?', $_SERVER['REMOTE_ADDR']); + DB::Realm()->Query('INSERT INTO account_aowow_extend (id,name) VALUES (?d,?)', $id, 'user-'.wn_create($id, WN_)); + + $us = new User($id); + if($us->Auth($hash) == AUTH_OK) + $us->SetAuthCookies($remember); + else + { + $this->acct_error = ACCT_INTERNAL_ERROR; + $this->type = 'signin'; + return; + } + } + else + { + $this->acct_error = ACCT_INTERNAL_ERROR; + $this->type = 'signup'; + return; + } +*/ + // Account creation + if ($_REQUEST['account'] == 'signup' && isset($_POST['username']) && isset($_POST['password']) && isset($_POST['c_password']) && $AoWoWconf['register'] == true) + { + // password mismatch + if ($_POST['password'] != $_POST['c_password']) + $smarty->assign('signup_error', Lang::$account['passMismatch']); + else + { + // AccName already in use + if ($rDB->selectCell('SELECT Count(id) FROM aowow_account WHERE username=? LIMIT 1', $_POST['username']) >= 1) + $smarty->assign('signup_error', Lang::$account['nameInUse']); + else + { + $success = $rDB->Query('INSERT INTO aowow_account (username, sha_pass_hash, email, joindate, last_ip, locale, online) VALUES (?, ?, ?, NOW(), ?, ?, 1)', + $_POST['username'], + User::$createUserSendPass($_POST['username'], $_POST['password']), + (isset($_POST['email']))? $_POST['email'] : '', + (isset($_SERVER["REMOTE_ADDR"]))? $_SERVER["REMOTE_ADDR"] : '', + $_SESSION['locale'] + ); + if ($success > 0) + // all fine, send to login + $_REQUEST['account']='signin'; + else + // something went wrong + $smarty->assign('signup_error', Lang::$account['unkError']); + } + } + } +} + +function dashboard() +{ + // cpmsg change pass messaeg class:failure|success, msg:blabla +} + +function recoverPass() +{ +} + +function recoverUser() +{ +} + +$page = array( + 'reqCSS' => array( + array('path' => 'template/css/Profiler.css', 'condition' => false), + ), + 'reqJS' => array( + array('path' => 'template/js/user.js'), + array('path' => 'template/js/profile.js'), + ), +); +$smarty->updatePageVars($page); + +$smarty->assign('lang', array_merge(Lang::$main, Lang::$account)); + +if (User::$id) +{ + if ($pageParam == 'signout') + { + User::destroy(); + $next = explode('?', $_SERVER['HTTP_REFERER']); + $next = !empty($next[1]) ? '?'.$next[1] : '.'; + header('Location: '.$next); + } + else + { + dashboard(); + $smarty->display('dashboard.tpl'); + } +} +else +{ + switch ($pageParam) + { + case 'signin_do': + $error = signin(); + if ($error) + $smarty->assign('signinError', $error); + else + header('Location: '.$_GET['next']); + case 'signin': + if (!isset($_GET['next'])) + { + $next = isset($_SERVER['HTTP_REFERER']) ? explode('?', $_SERVER['HTTP_REFERER']) : '.'; + $smarty->assign('next', isset($next[1]) ? '?'.$next[1] : '.'); + } + else + $smarty->assign('next', $_GET['next']); + + $smarty->assign('register', $AoWoWconf['register']); + $smarty->display('signin.tpl'); + break; + case 'signup_do': + $error = signup(); + if ($error) + $smarty->assign('signupError', $error); + else + header('Location: '.$_GET['next']); + break; + case 'signup': + if (!isset($_GET['next'])) + { + $next = isset($_SERVER['HTTP_REFERER']) ? explode('?', $_SERVER['HTTP_REFERER']) : '.'; + $smarty->assign('next', isset($next[1]) ? '?'.$next[1] : '.'); + } + else + $smarty->assign('next', $_GET['next']); + $smarty->display('signup.tpl'); + break; + case 'forgotpassword': + recoverPass(); + $smarty->display('recoverPass.tpl'); + break; + case 'forgotusername': + recoverUser(); + $smarty->display('recoverUser.tpl'); + break; + default: + header('Location: '.($_GET['next'] ? $_GET['next'] : '.')); + break; + } +} + +?> diff --git a/pages/compare.php b/pages/compare.php index 0e70b8ac..035df95d 100644 --- a/pages/compare.php +++ b/pages/compare.php @@ -3,11 +3,14 @@ if (!defined('AOWOW_REVISION')) die('invalid access'); -require_once('includes/class.item.php'); -require_once('includes/class.spell.php'); -require_once('includes/class.faction.php'); // items may require a faction to use/own +require 'includes/class.item.php'; +require 'includes/class.spell.php'; +require 'includes/class.faction.php'; // items may require a faction to use/own -$pageData['items'] = array(); +$pageData = array( + 'summary' => '[]', + 'items' => [] +); // prefer $_GET over $_COOKIE if (!empty($_GET['compare'])) diff --git a/pages/item.php b/pages/item.php index f383322f..a742c5c4 100644 --- a/pages/item.php +++ b/pages/item.php @@ -4,20 +4,20 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -// require_once('includes/game.php'); -require_once('includes/class.spell.php'); -// require_once('includes/allquests.php'); -require_once('includes/class.item.php'); -// require_once('includes/allnpcs.php'); -// require_once('includes/allobjects.php'); -// require_once('includes/class.community.php'); // wo dont need those .. yet -// require_once('includes/class.achievement.php'); -require_once('includes/class.faction.php'); +// require 'includes/game.php'; +require 'includes/class.spell.php'; +// require 'includes/allquests.php'; +require 'includes/class.item.php'; +// require 'includes/allnpcs.php'; +// require 'includes/allobjects.php'; +// require 'includes/class.community.php'; // wo dont need those .. yet +// require 'includes/class.achievement.php'; +require 'includes/class.faction.php'; $id = intVal($pageParam); $item = new Item($id); -$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPEID_ITEM, $id, -1, User::$localeId]); +$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_ITEM, $id, -1, User::$localeId]); if (isset($_GET['xml'])) { @@ -54,7 +54,7 @@ else if (isset($_GET['power'])) $itemString .= 's'; } - $cacheKeyTooltip = implode(':', [CACHETYPE_TOOLTIP, TYPEID_ITEM, $itemString, -1, User::$localeId]); + $cacheKeyTooltip = implode(':', [CACHETYPE_TOOLTIP, TYPE_ITEM, $itemString, -1, User::$localeId]); // output json for tooltips if (!$smarty->loadCache($cacheKeyTooltip, $x)) diff --git a/pages/spell.php b/pages/spell.php index c92c2bff..f696324f 100644 --- a/pages/spell.php +++ b/pages/spell.php @@ -4,18 +4,18 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -require_once('includes/class.spell.php'); -require_once('includes/class.item.php'); -// require_once('includes/allnpcs.php'); -// require_once('includes/allquests.php'); -// require_once('includes/class.community.php'); // not needed .. yet -// require_once('includes/class.achievement.php'); +require 'includes/class.spell.php'; +require 'includes/class.item.php'; +// require 'includes/allnpcs.php'; +// require 'includes/allquests.php'; +// require 'includes/class.community.php'; // not needed .. yet +// require 'includes/class.achievement.php'; $id = intVal($pageParam); $spell = new Spell($id); -$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPEID_SPELL, $id, -1, User::$localeId]); -$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPEID_SPELL, $id, -1, User::$localeId]); +$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_SPELL, $id, -1, User::$localeId]); +$cacheKeyTooltip = implode('_', [CACHETYPE_TOOLTIP, TYPE_SPELL, $id, -1, User::$localeId]); if (isset($_GET['power'])) { diff --git a/pages/title.php b/pages/title.php index 4939657d..5233e293 100644 --- a/pages/title.php +++ b/pages/title.php @@ -4,24 +4,24 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -require_once('includes/class.title.php'); -require_once('includes/class.spell.php'); -require_once('includes/class.achievement.php'); -require_once('includes/class.item.php'); -require_once('includes/class.quest.php'); -require_once('includes/class.worldevent.php'); -require_once('includes/class.community.php'); +require 'includes/class.title.php'; +require 'includes/class.spell.php'; +require 'includes/class.achievement.php'; +require 'includes/class.item.php'; +require 'includes/class.quest.php'; +require 'includes/class.worldevent.php'; +require 'includes/class.community.php'; $Id = intVal($pageParam); -$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPEID_TITLE, $Id, -1, User::$localeId]); +$cacheKeyPage = implode('_', [CACHETYPE_PAGE, TYPE_TITLE, $Id, -1, User::$localeId]); if (!$smarty->loadCache($cacheKeyPage, $pageData)) { $title = new Title($Id); if ($title->template) { - $title->addSelfToJscript($pageData['gTitles']); + $title->addGlobalsToJScript($pageData['gTitles']); $infobox = []; $colon = User::$localeId == LOCALE_FR ? ' : ' : ': '; // Je suis un prick! <_< @@ -66,7 +66,7 @@ if (!$smarty->loadCache($cacheKeyPage, $pageData)) break; case 12: $acvs = new AchievementList(array(['id', $entries])); - $acvs->addSelfToJscript($pageData['gAchievements']); + $acvs->addGlobalsToJScript($pageData['gAchievements']); $acvs->addRewardsToJscript($pageData['gItems'], $pageData['gTitles']); $pageData['page']['acvReward'] = $acvs->getListviewData(); @@ -102,11 +102,11 @@ $smarty->updatePageVars(array( 'title' => $pageData['title']." - ".ucfirst(Lang::$game['title']), 'path' => "[0, 10, ".$title->template['category']."]", 'tab' => 0, // for g_initHeader($tab) - 'type' => TYPEID_TITLE, // 11:Titles + 'type' => TYPE_TITLE, // 11:Titles 'typeId' => $Id )); -$smarty->assign('community', CommunityContent::getAll(TYPEID_TITLE, $Id)); // comments, screenshots, videos +$smarty->assign('community', CommunityContent::getAll(TYPE_TITLE, $Id)); // comments, screenshots, videos $smarty->assign('lang', array_merge(Lang::$main)); $smarty->assign('data', $pageData); $smarty->assign('mysql', DB::Aowow()->getStatistics()); diff --git a/pages/titles.php b/pages/titles.php index 43054d95..890bc9a1 100644 --- a/pages/titles.php +++ b/pages/titles.php @@ -4,13 +4,13 @@ if (!defined('AOWOW_REVISION')) die('illegal access'); -require_once('includes/class.title.php'); -require_once('includes/class.achievement.php'); -require_once('includes/class.quest.php'); +require 'includes/class.title.php'; +require 'includes/class.achievement.php'; +require 'includes/class.quest.php'; $cat = Util::extractURLParams($pageParam)[0]; $path = [0, 10]; -$cacheKey = implode('_', [CACHETYPE_PAGE, TYPEID_TITLE, -1, isset($cat) ? $cat : -1, User::$localeId]); +$cacheKey = implode('_', [CACHETYPE_PAGE, TYPE_TITLE, -1, isset($cat) ? $cat : -1, User::$localeId]); $title = [ucFirst(Lang::$game['titles'])]; $path[] = $cat; // should be only one parameter anyway @@ -22,7 +22,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) { $titles = new TitleList(isset($cat) ? array(['category', (int)$cat]) : []); $listview = $titles->getListviewData(); - + $sources = array( 4 => [], // Quest 12 => [], // Achievement @@ -35,23 +35,18 @@ if (!$smarty->loadCache($cacheKey, $pageData)) if(!isset($lvTitle['source'])) continue; - if (isset($lvTitle['source'][4])) - $sources[4] = array_merge($sources[4], $lvTitle['source'][4]); - - if (isset($lvTitle['source'][12])) - $sources[12] = array_merge($sources[12], $lvTitle['source'][12]); - - if (isset($lvTitle['source'][13])) - $sources[13] = array_merge($sources[13], $lvTitle['source'][13]); + foreach (array_keys($sources) as $srcKey) + if (isset($lvTitle['source'][$srcKey])) + $sources[$srcKey] = array_merge($sources[$srcKey], $lvTitle['source'][$srcKey]); } // replace with suitable objects if (!empty($sources[4])) $sources[4] = new QuestList(array(['Id', $sources[4]])); - + if (!empty($sources[12])) $sources[12] = new AchievementList(array(['Id', $sources[12]])); - + if (!empty($sources[13])) $sources[13] = DB::Aowow()->SELECT('SELECT *, Id AS ARRAY_KEY FROM ?_sourceStrings WHERE Id IN (?a)', $sources[13]); @@ -59,7 +54,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) { if(!isset($lvTitle['source'])) continue; - + // Quest-source if (isset($lvTitle['source'][4])) { @@ -68,7 +63,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) foreach ($ids as $id) $listview[$k]['source'][4][] = $sources[4]->container[$id]->getSourceData(); } - + // Achievement-source if (isset($lvTitle['source'][12])) { @@ -77,7 +72,7 @@ if (!$smarty->loadCache($cacheKey, $pageData)) foreach ($ids as $id) $listview[$k]['source'][12][] = $sources[12]->container[$id]->getSourceData(); } - + // other source (only one item possible, so no iteration needed) if (isset($lvTitle['source'][13])) $listview[$k]['source'][13] = [$sources[13][$lvTitle['source'][13][0]]]; diff --git a/setup/tools/dataset-assembler/enchants.php b/setup/tools/dataset-assembler/enchants.php index 03b06e27..8e3b39e0 100644 --- a/setup/tools/dataset-assembler/enchants.php +++ b/setup/tools/dataset-assembler/enchants.php @@ -50,8 +50,8 @@ if (!defined('AOWOW_REVISION')) }, */ - include 'includes/class.spell.php'; - include 'includes/class.item.php'; + require 'includes/class.spell.php'; + require 'includes/class.item.php'; set_time_limit(300); diff --git a/setup/tools/dataset-assembler/gems.php b/setup/tools/dataset-assembler/gems.php index 39a7fa2a..48c51d7d 100644 --- a/setup/tools/dataset-assembler/gems.php +++ b/setup/tools/dataset-assembler/gems.php @@ -24,7 +24,7 @@ if (!defined('AOWOW_REVISION')) // sketchy, but should work // Id < 36'000 || ilevel < 70 ? BC : WOTLK - include 'includes/class.spell.php'; + require 'includes/class.spell.php'; $gemQuery = " SELECT diff --git a/setup/tools/dataset-assembler/glyphs.php b/setup/tools/dataset-assembler/glyphs.php index db5ec6f1..93685940 100644 --- a/setup/tools/dataset-assembler/glyphs.php +++ b/setup/tools/dataset-assembler/glyphs.php @@ -115,7 +115,7 @@ if (!defined('AOWOW_REVISION')) 41108 => 'Lay on Hands' ); - include 'includes/class.spell.php'; + require 'includes/class.spell.php'; set_time_limit(300); diff --git a/setup/tools/dataset-assembler/itemsets.php b/setup/tools/dataset-assembler/itemsets.php index 9deb2540..5b4a3b5c 100644 --- a/setup/tools/dataset-assembler/itemsets.php +++ b/setup/tools/dataset-assembler/itemsets.php @@ -55,7 +55,7 @@ if (!defined('AOWOW_REVISION')) ... onwards! */ - include 'includes/class.spell.php'; + require 'includes/class.spell.php'; $setList = DB::Aowow()->Select('SELECT * FROM ?_itemset ORDER BY refSetId DESC'); $locales = [LOCALE_EN, LOCALE_FR, LOCALE_DE, LOCALE_ES, LOCALE_RU]; diff --git a/setup/tools/dataset-assembler/talents.php b/setup/tools/dataset-assembler/talents.php index cd6cb868..171bc6f6 100644 --- a/setup/tools/dataset-assembler/talents.php +++ b/setup/tools/dataset-assembler/talents.php @@ -24,7 +24,7 @@ if (!defined('AOWOW_REVISION')) // t - array of talent-objects // f - array:int [pets only] creatureFamilies in that category - include 'includes/class.spell.php'; + require 'includes/class.spell.php'; function buildTree($class) {