public function main() { header('Content-type: text/plain'); WoW_Template::SetTemplateTheme('wow'); if (isset($_GET['locale']) && WoW_Locale::IsLocale($_GET['locale'], WoW_Locale::GetLocaleIDForLocale($_GET['locale']))) { WoW_Locale::SetLocale($_GET['locale'], WoW_Locale::GetLocaleIDForLocale($_GET['locale'])); } $searchQuery = isset($_GET['term']) ? $_GET['term'] : null; if ($searchQuery != null && mb_strlen($searchQuery) < 3 || $searchQuery == null) { die('{"reason":"A term parameter is required.","status":"nok"}'); } WoW_Search::SetSearchQuery($searchQuery); WoW_Search::PerformItemsSearch(10); WoW_Template::LoadTemplate('page_ta_lookup'); }
public static function CatchOperations(&$loaded) { // Perform log in (if required) if (isset($_GET['login']) || preg_match('/\\?login/', $_SERVER['REQUEST_URI'])) { // $_SERVER['REQUEST_URI'] check is required for mod_rewrited URL cases. header('Location: ' . WoW::GetWoWPath() . '/login/'); exit; } // Perform logout (if required) if (isset($_GET['logout']) || preg_match('/\\?logout/', $_SERVER['REQUEST_URI'])) { // $_SERVER['REQUEST_URI'] check is required for mod_rewrited URL cases. WoW_Account::PerformLogout(); header('Location: ' . WoW::GetWoWPath() . '/'); exit; } // Locale if (isset($_GET['locale']) && !preg_match('/lookup/', $_SERVER['REQUEST_URI'])) { if (WoW_Locale::IsLocale($_GET['locale'], WoW_Locale::GetLocaleIDForLocale($_GET['locale']))) { WoW_Locale::SetLocale($_GET['locale'], WoW_Locale::GetLocaleIDForLocale($_GET['locale'])); $loaded = true; setcookie('wow_locale', WoW_Locale::GetLocale(), strtotime('NEXT YEAR'), '/'); if (isset($_SERVER['HTTP_REFERER'])) { header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } else { header('Location: ' . WoW::GetWoWPath() . '/'); exit; } } } }
WoW::SelfTests(); // Try to catch some operations (login, logout, etc.) $locale_loaded = false; WoW::CatchOperations($locale_loaded); // locale from page controller $wow_locale_cms = isset($_COOKIE['wow_locale']) ? $_COOKIE['wow_locale'] : WoWConfig::$DefaultLocale; if (!isset($_COOKIE['wow_locale'])) { setcookie('wow_locale', $wow_locale_cms, strtotime('NEXT YEAR'), '/'); $_COOKIE['wow_locale'] = $wow_locale_cms; } $pController = new PageController(); if ($pController->GetLocale() != null && $pController->GetLocale() != $_COOKIE['wow_locale']) { //$_SESSION['wow_locale'] = $pController->GetLocale(); WoW_Locale::SetLocale($pController->GetLocale(), WoW_Locale::GetLocaleIDForLocale($pController->GetLocale()), true); } else { WoW_Locale::SetLocale($_COOKIE['wow_locale'], WoW_Locale::GetLocaleIDForLocale($_COOKIE['wow_locale'])); } // Initialize account (if user already logged in we need to re-build his info from session data) WoW_Account::Initialize(); if (isset($_COOKIE['wow_session']) && !WoW_Account::IsLoggedIn()) { WoW_Account::loadFromCookieSession(); } // Initialize auction handler WoW_Auction::InitAuction(); // TODO: this initialization should be moved in some other place. // Display wow revision (if required; do not remove). if (isset($_GET['_DISPLAYVERSION_'])) { die('WOW_REVISION: ' . WOW_REVISION); } // RunOnce define('__RUNONCE__', true);
protected static function SetPowerLocale() { if (strpos(WoW::GetRawPageAction(), '&pl')) { $data = explode('&', WoW::GetRawPageAction()); foreach ($data as $it) { $tmp = explode('=', $it); if ($tmp[0] == 'pl') { if (!$tmp[1] || !WoW_Locale::IsLocale($tmp[1], WoW_Locale::GetLocaleIDForLocale($tmp[1]))) { $tmp[1] = 'enus'; } WoW_Locale::SetLocale($tmp[1], WoW_Locale::GetLocaleIDForLocale($tmp[1]), true); } } } }
//prevent error when mailer classes are loaded $className = strtolower(str_replace('WoW_', null, $className)); if (!file_exists(CLASSES_DIR . 'class.' . $className . '.php')) { die('<strong>Autoload Fatal Error:</strong> unable to autoload class ' . $className . '!'); } include CLASSES_DIR . 'class.' . $className . '.php'; } // Locale if (isset($_GET['locale'])) { if (WoW_Locale::IsLocale($_GET['locale'], WoW_Locale::GetLocaleIDForLocale($_GET['locale']))) { WoW_Locale::SetLocale($_GET['locale'], WoW_Locale::GetLocaleIDForLocale($_GET['locale'])); if (isset($_SERVER['HTTP_REFERER'])) { header('Location: ' . $_SERVER['HTTP_REFERER']); exit; } else { WoW::RedirectTo(); exit; } } } // Load locale if (isset($_COOKIE['wow_locale'], $_COOKIE['wow_locale_id']) && WoW_Locale::IsLocale($_COOKIE['wow_locale'], $_COOKIE['wow_locale_id'])) { WoW_Locale::SetLocale($_COOKIE['wow_locale'], $_COOKIE['wow_locale_id']); } else { WoW_Locale::SetLocale(WoWConfig::$DefaultLocale, WoWConfig::$DefaultLocaleID); } // Initialize debug log WoW_Log::Initialize(WoWConfig::$UseLog, WoWConfig::$LogLevel); if (isset($_GET['_DISPLAYVERSION_'])) { die(WOW_REVISION); }