Files
aowow/includes/kernel.php
Sarjuuk 4919e1ef57 removing smarty - part VII
- rewrote Item/Items
- BaseType: fixed querey generation wizh null-values in extraOpts
- ItemList:
  * reworked extendJsonStats() to use ?_itemstats istead of parsing on the fly
  * moved onUse-components used by xml from extendJsonStats() to separate function
  * the enhance-string passed with tooltips is now checked first
- Loot: class is no longer static
- Util::parseItemEnchantment() will now accept and return arrays and does only one single lookup
- cuFlags are explained in the infobox, when available
- JS:
  * do NOT strip iconStrings. It rightly can contain whitespaces >.<
  * removed a redundant $WH.ct in Conditions
2014-06-28 14:29:39 +02:00

130 lines
4.4 KiB
PHP

<?php
if (!defined('AOWOW_REVISION'))
die('illegal access');
ini_set('serialize_precision', 4);
require 'includes/defines.php';
require 'config/config.php';
require 'includes/genericPage.class.php';
require 'includes/libs/DbSimple/Generic.php'; // Libraray: http://en.dklab.ru/lib/DbSimple (using mysqli variant: https://bitbucket.org/brainreaver/dbsimple/src)
require 'includes/utilities.php'; // misc™ data 'n func
require 'includes/ajaxHandler.class.php'; // handles ajax and jsonp requests
require 'includes/user.class.php';
require 'includes/database.class.php'; // wrap DBSimple
require 'includes/community.class.php'; // handle comments, screenshots and videos
require 'includes/loot.class.php'; // build lv-tabs containing loot-information
require 'localization/lang.class.php';
// autoload List-classes, associated filters and pages
spl_autoload_register(function ($class) {
$class = str_replace('Filter', '', $class);
if (class_exists($class)) // already registered
return;
if (preg_match('/[^\w]/i', $class)) // name should contain only letters
return;
if (strpos($class, 'List'))
{
if (!class_exists('BaseType'))
require 'includes/types/basetype.class.php';
if (file_exists(CWD.'includes/types/'.strtr($class, ['List' => '']).'.class.php'))
require 'includes/types/'.strtr($class, ['List' => '']).'.class.php';
return;
}
if (file_exists('pages/'.strtr($class, ['Page' => '']).'.php'))
require 'pages/'.strtr($class, ['Page' => '']).'.php';
});
// Setup DB-Wrapper
if (!empty($AoWoWconf['aowow']['db']))
DB::load(DB_AOWOW, $AoWoWconf['aowow']);
else
die('no database credentials given for: aowow');
if (!empty($AoWoWconf['world']['db']))
DB::load(DB_WORLD, $AoWoWconf['world']);
if (!empty($AoWoWconf['auth']['db']))
DB::load(DB_AUTH, $AoWoWconf['auth']);
foreach ($AoWoWconf['characters'] as $realm => $charDBInfo)
if (!empty($charDBInfo))
DB::load(DB_CHARACTERS + $realm, $charDBInfo);
unset($AoWoWconf); // link set up: delete passwords
// load config to constants
$sets = DB::Aowow()->select('SELECT `key` AS ARRAY_KEY, intValue as i, strValue as s FROM ?_config');
foreach ($sets as $k => $v)
define('CFG_'.strtoupper($k), $v['s'] ? $v['s'] : intVal($v['i']));
define('STATIC_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1).'/static'); // points js to images & scripts (change here if you want to use a separate subdomain)
define('HOST_URL', substr('http://'.$_SERVER['SERVER_NAME'].strtr($_SERVER['SCRIPT_NAME'], ['index.php' => '']), 0, -1)); // points js to executable files
define('CWD', strtr(getcwd(), ['\\' => '/']).'/');
$e = CFG_DEBUG ? (E_ALL & ~(E_DEPRECATED | E_USER_DEPRECATED | E_STRICT)) : 0;
error_reporting($e);
// php session (used for profiler: g_dataKey) (todo (high): merge to user-class at some point)
session_start();
if (empty($_SESSION['timeout']) || $_SESSION['timeout'] < time())
{
$seed = "abcdefghijklmnopqrstuvwxyz0123456789";
$_SESSION['dataKey'] = ''; // just some random numbers for identifictaion purpose
for ($i = 0; $i < 40; $i++)
$_SESSION['dataKey'] .= substr($seed, mt_rand(0, 35), 1);
}
$_SESSION['timeout'] = time() + CFG_SESSION_TIMEOUT_DELAY;
// debug: measure execution times
Util::execTime(CFG_DEBUG);
// Setup Session
if (isset($_COOKIE[COOKIE_AUTH]))
{
$offset = intval($_COOKIE[COOKIE_AUTH][1]);
if ($id = hexdec(substr($_COOKIE[COOKIE_AUTH], 2, $offset)))
{
User::init($id);
switch (User::Auth())
{
case AUTH_OK:
case AUTH_BANNED:
User::writeCookie();
break;
default:
User::destroy();
}
}
else
User::init(0);
}
else
User::init(0);
User::setLocale();
// parse page-parameters .. sanitize before use!
@list($str, $trash) = explode('&', $_SERVER['QUERY_STRING'], 2);
@list($pageCall, $pageParam) = explode('=', $str, 2);
Util::$wowheadLink = 'http://'.Util::$subDomains[User::$localeId].'.wowhead.com/'.$str;
$ajax = new AjaxHandler($pageParam);
?>