mirror of
https://github.com/Sarjuuk/aowow.git
synced 2025-11-29 15:58:16 +08:00
Cache:
- implemented Memcached (untested though (tough luck trying to get it to run using win)) - added config value to select caching method (default: filecache; setting debug to 1 will still disable caching) - implemented url-param 'refresh' to clear cache for this page
This commit is contained in:
@@ -26,11 +26,14 @@ define('TYPE_SKILL', 15);
|
||||
define('TYPE_CURRENCY', 17);
|
||||
define('TYPE_USER', 100); // internal use only
|
||||
|
||||
define('CACHETYPE_NONE', 0); // page will not be cached
|
||||
define('CACHETYPE_PAGE', 1);
|
||||
define('CACHETYPE_TOOLTIP', 2);
|
||||
define('CACHETYPE_SEARCH', 3);
|
||||
define('CACHETYPE_XML', 4); // only used by items
|
||||
define('CACHE_TYPE_NONE', 0); // page will not be cached
|
||||
define('CACHE_TYPE_PAGE', 1);
|
||||
define('CACHE_TYPE_TOOLTIP', 2);
|
||||
define('CACHE_TYPE_SEARCH', 3);
|
||||
define('CACHE_TYPE_XML', 4); // only used by items
|
||||
|
||||
define('CACHE_MODE_FILECACHE', 0x1);
|
||||
define('CACHE_MODE_MEMCACHED', 0x2);
|
||||
|
||||
define('SEARCH_TYPE_REGULAR', 0x10000000);
|
||||
define('SEARCH_TYPE_OPEN', 0x20000000);
|
||||
|
||||
@@ -10,7 +10,7 @@ class AccountPage extends GenericPage
|
||||
protected $tpl = 'acc-dashboard';
|
||||
protected $js = ['user.js', 'profile.js'];
|
||||
protected $css = [['path' => 'Profiler.css']];
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
protected $category = null;
|
||||
protected $validCats = array(
|
||||
'signin' => [false],
|
||||
|
||||
@@ -30,14 +30,14 @@ class AchievementPage extends GenericPage
|
||||
protected $tpl = 'achievement';
|
||||
protected $path = [0, 9];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
{
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && isset($_GET['domain']))
|
||||
Util::powerUseLocale($_GET['domain']);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
@@ -422,7 +422,7 @@ class AchievementPage extends GenericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::display($override);
|
||||
|
||||
if (!$this->loadCache($tt))
|
||||
@@ -437,7 +437,7 @@ class AchievementPage extends GenericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::notFound($typeStr);
|
||||
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
|
||||
@@ -14,7 +14,7 @@ class AchievementsPage extends GenericPage
|
||||
protected $tpl = 'achievements';
|
||||
protected $path = [0, 9];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['filters.js'];
|
||||
protected $validCats = array(
|
||||
92 => true,
|
||||
|
||||
@@ -15,7 +15,7 @@ class ClassPage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 12];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['swfobject.js'];
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
|
||||
@@ -14,7 +14,7 @@ class ClassesPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 12];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ class ComparePage extends GenericPage
|
||||
protected $tpl = 'compare';
|
||||
protected $tabId = 1;
|
||||
protected $path = [1, 3];
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
protected $js = array(
|
||||
'profile.js',
|
||||
'Draggable.js',
|
||||
|
||||
@@ -14,7 +14,7 @@ class CurrenciesPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 15];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [1, 2, 3, 22];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
|
||||
@@ -15,7 +15,7 @@ class CurrencyPage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 15];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
{
|
||||
|
||||
@@ -15,7 +15,7 @@ class EventPage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 11];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
private $hId = 0;
|
||||
private $eId = 0;
|
||||
|
||||
@@ -14,7 +14,7 @@ class EventsPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 11];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [0, 1, 2, 3];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
|
||||
@@ -15,7 +15,7 @@ class FactionPage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 7];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
{
|
||||
|
||||
@@ -14,7 +14,7 @@ class FactionsPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 7];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = array(
|
||||
1118 => [469, 891, 67, 892, 169],
|
||||
980 => [936],
|
||||
|
||||
@@ -12,10 +12,12 @@ trait DetailPage
|
||||
|
||||
private $subject = null; // so it will not get cached
|
||||
|
||||
protected function generateCacheKey()
|
||||
protected function generateCacheKey($withStaff = true)
|
||||
{
|
||||
// mode, type, typeId, employee-flag, localeId, category, filter
|
||||
$key = [$this->mode, $this->type, $this->typeId, intVal(User::isInGroup(U_GROUP_EMPLOYEE)), User::$localeId, '-1', '-1'];
|
||||
$staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE));
|
||||
|
||||
// mode, type, typeId, employee-flag, localeId, category, filter
|
||||
$key = [$this->mode, $this->type, $this->typeId, $staff, User::$localeId, '-1', '-1'];
|
||||
|
||||
// item special: can modify tooltips
|
||||
if (isset($this->enhancedTT))
|
||||
@@ -35,10 +37,12 @@ trait ListPage
|
||||
|
||||
private $filterObj = null;
|
||||
|
||||
protected function generateCacheKey()
|
||||
protected function generateCacheKey($withStaff = true)
|
||||
{
|
||||
// mode, type, typeId, employee-flag, localeId,
|
||||
$key = [$this->mode, $this->type, '-1', intVal(User::isInGroup(U_GROUP_EMPLOYEE)), User::$localeId];
|
||||
$staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE));
|
||||
|
||||
// mode, type, typeId, employee-flag, localeId,
|
||||
$key = [$this->mode, $this->type, '-1', $staff, User::$localeId];
|
||||
|
||||
//category
|
||||
$key[] = $this->category ? implode('.', $this->category) : '-1';
|
||||
@@ -55,7 +59,7 @@ class GenericPage
|
||||
{
|
||||
protected $tpl = '';
|
||||
protected $restrictedGroups = U_GROUP_NONE;
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
|
||||
protected $jsGlobals = [];
|
||||
protected $lvData = [];
|
||||
@@ -68,7 +72,6 @@ class GenericPage
|
||||
|
||||
// private vars don't get cached
|
||||
private $time = 0;
|
||||
private $isCached = false;
|
||||
private $cacheDir = 'cache/template/';
|
||||
private $jsgBuffer = [];
|
||||
private $gPageInfo = [];
|
||||
@@ -76,19 +79,34 @@ class GenericPage
|
||||
private $pageTemplate = [];
|
||||
private $community = ['co' => [], 'sc' => [], 'vi' => []];
|
||||
|
||||
private $cacheLoaded = [];
|
||||
private $skipCache = 0x0;
|
||||
private $memcached = null;
|
||||
|
||||
public function __construct($pageCall/*, $pageParam */)
|
||||
{
|
||||
$this->time = microtime(true);
|
||||
|
||||
// force page refresh
|
||||
if (isset($_GET['refresh']) && User::isInGroup(U_GROUP_ADMIN | U_GROUP_BUREAU | U_GROUP_DEV))
|
||||
{
|
||||
if ($_GET['refresh'] == 'filecache')
|
||||
$this->skipCache = CACHE_MODE_FILECACHE;
|
||||
else if ($_GET['refresh'] == 'memcached')
|
||||
$this->skipCache = CACHE_MODE_MEMCACHED;
|
||||
else if ($_GET['refresh'] == '')
|
||||
$this->skipCache = CACHE_MODE_FILECACHE | CACHE_MODE_MEMCACHED;
|
||||
}
|
||||
|
||||
// restricted access
|
||||
if ($this->restrictedGroups && !User::isInGroup($this->restrictedGroups))
|
||||
$this->error();
|
||||
|
||||
// display modes
|
||||
if (isset($_GET['power']) && method_exists($this, 'generateTooltip'))
|
||||
$this->mode = CACHETYPE_TOOLTIP;
|
||||
$this->mode = CACHE_TYPE_TOOLTIP;
|
||||
else if (isset($_GET['xml']) && method_exists($this, 'generateXML'))
|
||||
$this->mode = CACHETYPE_XML;
|
||||
$this->mode = CACHE_TYPE_XML;
|
||||
else
|
||||
{
|
||||
$this->gUser = User::getUserGlobals();
|
||||
@@ -167,8 +185,6 @@ class GenericPage
|
||||
|
||||
$this->saveCache();
|
||||
}
|
||||
else
|
||||
$this->isCached = true;
|
||||
|
||||
if (isset($this->type) && isset($this->typeId))
|
||||
$this->gPageInfo = array( // varies slightly for special pages like maps, user-dashboard or profiler
|
||||
@@ -597,17 +613,16 @@ class GenericPage
|
||||
|
||||
public function saveCache($saveString = null) // visible properties or given strings are cached
|
||||
{
|
||||
if ($this->mode == CACHETYPE_NONE)
|
||||
if ($this->mode == CACHE_TYPE_NONE)
|
||||
return false;
|
||||
|
||||
if (CFG_DEBUG)
|
||||
if (!CFG_CACHE_MODE || CFG_DEBUG)
|
||||
return;
|
||||
|
||||
$file = $this->cacheDir.$this->generateCacheKey();
|
||||
$data = time()." ".AOWOW_REVISION." ".($saveString ? '1' : '0')."\n";
|
||||
$cKey = $this->generateCacheKey();
|
||||
$cache = [];
|
||||
if (!$saveString)
|
||||
{
|
||||
$cache = [];
|
||||
foreach ($this as $key => $val)
|
||||
{
|
||||
try
|
||||
@@ -618,40 +633,118 @@ class GenericPage
|
||||
}
|
||||
catch (ReflectionException $e) { } // shut up!
|
||||
}
|
||||
|
||||
$data .= gzcompress(serialize($cache), 9);
|
||||
}
|
||||
else
|
||||
$data .= (string)$saveString;
|
||||
$cache = (string)$saveString;
|
||||
|
||||
file_put_contents($file, $data);
|
||||
if (CFG_CACHE_MODE & CACHE_MODE_MEMCACHED)
|
||||
{
|
||||
// on &refresh also clear related
|
||||
if ($this->skipCache == CACHE_MODE_FILECACHE)
|
||||
{
|
||||
$oldMode = $this->mode;
|
||||
for ($i = 1; $i < 5; $i++) // page (1), tooltips (2), searches (3) and xml (4)
|
||||
{
|
||||
$this->mode = $i;
|
||||
for ($j = 0; $j < 2; $j++) // staff / normal
|
||||
$this->memcached()->delete($this->generateCacheKey($j));
|
||||
}
|
||||
|
||||
$this->mode = $oldMode;
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'timestamp' => time(),
|
||||
'revision' => AOWOW_REVISION,
|
||||
'isString' => $saveString ? 1 : 0,
|
||||
'data' => $cache
|
||||
);
|
||||
|
||||
$this->memcached()->set($cKey, $data);
|
||||
}
|
||||
|
||||
if (CFG_CACHE_MODE & CACHE_MODE_FILECACHE)
|
||||
{
|
||||
$data = time()." ".AOWOW_REVISION." ".($saveString ? '1' : '0')."\n";
|
||||
$data .= gzcompress($saveString ? $cache : serialize($cache), 9);
|
||||
|
||||
// on &refresh also clear related
|
||||
if ($this->skipCache == CACHE_MODE_FILECACHE)
|
||||
{
|
||||
$oldMode = $this->mode;
|
||||
for ($i = 1; $i < 5; $i++) // page (1), tooltips (2), searches (3) and xml (4)
|
||||
{
|
||||
$this->mode = $i;
|
||||
for ($j = 0; $j < 2; $j++) // staff / normal
|
||||
{
|
||||
$key = $this->generateCacheKey($j);
|
||||
if (file_exists($this->cacheDir.$key))
|
||||
unlink($this->cacheDir.$key);
|
||||
}
|
||||
}
|
||||
|
||||
$this->mode = $oldMode;
|
||||
}
|
||||
|
||||
file_put_contents($this->cacheDir.$cKey, $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function loadCache(&$saveString = null)
|
||||
{
|
||||
if ($this->mode == CACHETYPE_NONE)
|
||||
if ($this->mode == CACHE_TYPE_NONE)
|
||||
return false;
|
||||
|
||||
if (CFG_DEBUG)
|
||||
if (!CFG_CACHE_MODE || CFG_DEBUG)
|
||||
return false;
|
||||
|
||||
$file = $this->cacheDir.$this->generateCacheKey();
|
||||
if (!file_exists($file))
|
||||
return false;
|
||||
$cKey = $this->generateCacheKey();
|
||||
$rev = $type = $cache = $data = null;
|
||||
|
||||
if ((CFG_CACHE_MODE & CACHE_MODE_MEMCACHED) && !($this->skipCache & CACHE_MODE_MEMCACHED))
|
||||
{
|
||||
if ($cache = $this->memcached()->get($cKey))
|
||||
{
|
||||
$type = $cache['isString'];
|
||||
$data = $cache['data'];
|
||||
|
||||
if ($cache['timestamp'] + CFG_CACHE_DECAY <= time() || $cache['revision'] < AOWOW_REVISION)
|
||||
$cache = null;
|
||||
else
|
||||
$this->cacheLoaded = [CACHE_MODE_MEMCACHED, $cache['timestamp']];
|
||||
}
|
||||
}
|
||||
|
||||
if (!$cache && (CFG_CACHE_MODE & CACHE_MODE_FILECACHE) && !($this->skipCache & CACHE_MODE_FILECACHE))
|
||||
{
|
||||
if (!file_exists($this->cacheDir.$cKey))
|
||||
return false;
|
||||
|
||||
$cache = file_get_contents($this->cacheDir.$cKey);
|
||||
if (!$cache)
|
||||
return false;
|
||||
|
||||
$cache = explode("\n", $cache, 2);
|
||||
$data = $cache[1];
|
||||
@list($time, $rev, $type) = explode(' ', $cache[0]);
|
||||
|
||||
if ($time + CFG_CACHE_DECAY <= time() || $rev < AOWOW_REVISION)
|
||||
$cache = null;
|
||||
else
|
||||
{
|
||||
$this->cacheLoaded = [CACHE_MODE_FILECACHE, $time];
|
||||
$data = gzuncompress($data);
|
||||
}
|
||||
}
|
||||
|
||||
$cache = file_get_contents($file);
|
||||
if (!$cache)
|
||||
return false;
|
||||
|
||||
$cache = explode("\n", $cache, 2);
|
||||
|
||||
@list($time, $rev, $type) = explode(' ', $cache[0]);
|
||||
if ($time + CFG_CACHE_DECAY <= time() || $rev < AOWOW_REVISION)
|
||||
return false;
|
||||
|
||||
if ($type == '0')
|
||||
{
|
||||
$data = unserialize(gzuncompress($cache[1]));
|
||||
if (is_string($data))
|
||||
$data = unserialize($data);
|
||||
|
||||
foreach ($data as $k => $v)
|
||||
$this->$k = $v;
|
||||
|
||||
@@ -659,12 +752,23 @@ class GenericPage
|
||||
}
|
||||
else if ($type == '1')
|
||||
{
|
||||
$saveString = $cache[1];
|
||||
$saveString = $data;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;;
|
||||
}
|
||||
|
||||
private function memcached()
|
||||
{
|
||||
if (!$this->memcached && (CFG_CACHE_MODE & CACHE_MODE_MEMCACHED))
|
||||
{
|
||||
$this->memcached = new Memcached();
|
||||
$this->memcached->addServer('localhost', 11211);
|
||||
}
|
||||
|
||||
return $this->memcached;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -15,7 +15,7 @@ class ItemPage extends genericPage
|
||||
protected $tpl = 'item';
|
||||
protected $path = [0, 0];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $enhancedTT = [];
|
||||
protected $js = array(
|
||||
'swfobject.js', // view in 3d, ok
|
||||
@@ -31,7 +31,7 @@ class ItemPage extends genericPage
|
||||
|
||||
$this->typeId = intVal($param);
|
||||
|
||||
if ($this->mode == CACHETYPE_TOOLTIP)
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP)
|
||||
{
|
||||
// temp locale
|
||||
if (isset($_GET['domain']))
|
||||
@@ -46,7 +46,7 @@ class ItemPage extends genericPage
|
||||
if (isset($_GET['sock']))
|
||||
$this->enhancedTT['s'] = '';
|
||||
}
|
||||
else if ($this->mode == CACHETYPE_XML)
|
||||
else if ($this->mode == CACHE_TYPE_XML)
|
||||
{
|
||||
// temp locale
|
||||
if (isset($_GET['domain']))
|
||||
@@ -66,7 +66,7 @@ class ItemPage extends genericPage
|
||||
|
||||
$this->name = $this->subject->getField('name', true);
|
||||
|
||||
if ($this->mode == CACHETYPE_PAGE)
|
||||
if ($this->mode == CACHE_TYPE_PAGE)
|
||||
{
|
||||
$jsg = $this->subject->getJSGlobals(GLOBALINFO_EXTRA | GLOBALINFO_SELF, $extra);
|
||||
$this->extendGlobalData($jsg, $extra);
|
||||
@@ -1075,7 +1075,7 @@ class ItemPage extends genericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode == CACHETYPE_TOOLTIP)
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP)
|
||||
{
|
||||
if (!$this->loadCache($tt))
|
||||
{
|
||||
@@ -1086,7 +1086,7 @@ class ItemPage extends genericPage
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
die($tt);
|
||||
}
|
||||
else if ($this->mode == CACHETYPE_XML)
|
||||
else if ($this->mode == CACHE_TYPE_XML)
|
||||
{
|
||||
if (!$this->loadCache($xml))
|
||||
{
|
||||
@@ -1103,13 +1103,13 @@ class ItemPage extends genericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode == CACHETYPE_TOOLTIP)
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP)
|
||||
{
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
echo $this->generateTooltip(true);
|
||||
exit();
|
||||
}
|
||||
else if ($this->mode == CACHETYPE_XML)
|
||||
else if ($this->mode == CACHE_TYPE_XML)
|
||||
{
|
||||
header('Content-type: text/xml; charset=utf-8');
|
||||
echo $this->generateXML(true);
|
||||
|
||||
@@ -14,7 +14,7 @@ class ItemsPage extends GenericPage
|
||||
protected $tpl = 'items';
|
||||
protected $path = [0, 0];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['filters.js', 'swfobject.js'];
|
||||
protected $validCats = array( // if > 0 class => subclass
|
||||
2 => [15, 13, 0, 4, 7, 6, 10, 1, 5, 8, 2, 18, 3, 16, 19, 20, 14],
|
||||
|
||||
@@ -15,7 +15,7 @@ class ItemsetPage extends GenericPage
|
||||
protected $tpl = 'itemset';
|
||||
protected $path = [0, 2];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = array(
|
||||
'swfobject.js',
|
||||
'Summary.js'
|
||||
|
||||
@@ -14,7 +14,7 @@ class ItemsetsPage extends GenericPage
|
||||
protected $tpl = 'itemsets';
|
||||
protected $path = [0, 2];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['filters.js'];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
|
||||
@@ -10,7 +10,7 @@ class MapsPage extends GenericPage
|
||||
protected $tpl = 'maps';
|
||||
protected $tabId = 1;
|
||||
protected $path = [1, 1];
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
protected $js = array(
|
||||
'maps.js',
|
||||
'Mapper.js'
|
||||
|
||||
@@ -13,7 +13,7 @@ class MorePage extends GenericPage
|
||||
protected $tpl = 'text-page-generic';
|
||||
protected $path = [2];
|
||||
protected $tabId = 2;
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
protected $js = ['swfobject.js'];
|
||||
|
||||
private $subPages = [ -13 => ['commenting-and-you', 'modelviewer', 'screenshots-tips-tricks', 'stat-weighting', 'talent-calculator', 'item-comparison', 'profiler', 'markup-guide']];
|
||||
|
||||
@@ -15,7 +15,7 @@ class NpcPage extends GenericPage
|
||||
protected $tpl = 'npc';
|
||||
protected $path = [0, 4];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = array(
|
||||
'swfobject.js',
|
||||
// 'Mapper.js'
|
||||
@@ -29,7 +29,7 @@ class NpcPage extends GenericPage
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && isset($_GET['domain']))
|
||||
Util::powerUseLocale($_GET['domain']);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
@@ -639,7 +639,7 @@ class NpcPage extends GenericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::display($override);
|
||||
|
||||
if (!$this->loadCache($tt))
|
||||
@@ -654,7 +654,7 @@ class NpcPage extends GenericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::notFound($typeStr);
|
||||
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
|
||||
@@ -14,7 +14,7 @@ class NpcsPage extends GenericPage
|
||||
protected $tpl = 'npcs';
|
||||
protected $path = [0, 4];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
|
||||
protected $js = ['filters.js'];
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class ObjectPage extends GenericPage
|
||||
protected $tpl = 'object';
|
||||
protected $path = [0, 5];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = array(
|
||||
'swfobject.js',
|
||||
// 'Mapper.js'
|
||||
@@ -36,7 +36,7 @@ class ObjectPage extends GenericPage
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && isset($_GET['domain']))
|
||||
Util::powerUseLocale($_GET['domain']);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
@@ -486,7 +486,7 @@ class ObjectPage extends GenericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::display($override);
|
||||
|
||||
if (!$this->loadCache($tt))
|
||||
@@ -501,7 +501,7 @@ class ObjectPage extends GenericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::notFound($typeStr);
|
||||
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
|
||||
@@ -14,7 +14,7 @@ class ObjectsPage extends GenericPage
|
||||
protected $tpl = 'objects';
|
||||
protected $path = [0, 5];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [-2, -3, -4, -5, -6, 0, 3, 9, 25];
|
||||
protected $js = ['filters.js'];
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class PetPage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 8];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['swfobject.js'];
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
|
||||
@@ -14,7 +14,7 @@ class PetsPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 8];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [1, 2, 3];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
|
||||
@@ -32,7 +32,7 @@ class ProfilePage extends GenericPage
|
||||
parent::__construct($pageCall, $pageParam);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && isset($_GET['domain']))
|
||||
Util::powerUseLocale($_GET['domain']);
|
||||
|
||||
if (count($_) == 1 && intVal($_[0]))
|
||||
@@ -114,7 +114,7 @@ class ProfilePage extends GenericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::display($override);
|
||||
|
||||
// do not cache profile tooltips
|
||||
@@ -124,7 +124,7 @@ class ProfilePage extends GenericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::notFound($typeStr);
|
||||
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
|
||||
@@ -15,7 +15,7 @@ class QuestPage extends GenericPage
|
||||
protected $tpl = 'quest';
|
||||
protected $path = [0, 3];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['Mapper.js'];
|
||||
protected $css = array(
|
||||
['path' => 'Book.css'],
|
||||
@@ -27,7 +27,7 @@ class QuestPage extends GenericPage
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && isset($_GET['domain']))
|
||||
Util::powerUseLocale($_GET['domain']);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
@@ -616,7 +616,7 @@ class QuestPage extends GenericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::display($override);
|
||||
|
||||
if (!$this->loadCache($tt))
|
||||
@@ -631,7 +631,7 @@ class QuestPage extends GenericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::notFound($typeStr);
|
||||
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
|
||||
@@ -13,7 +13,7 @@ class QuestsPage extends GenericPage
|
||||
protected $tpl = 'quests';
|
||||
protected $path = [0, 3];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [];
|
||||
protected $js = ['filters.js'];
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class RacePage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 13];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['swfobject.js'];
|
||||
|
||||
public function __construct($pageCall, $id)
|
||||
|
||||
@@ -14,7 +14,7 @@ class RacesPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 13];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ class SearchPage extends GenericPage
|
||||
{
|
||||
protected $tpl = 'search';
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_SEARCH;
|
||||
protected $mode = CACHE_TYPE_SEARCH;
|
||||
protected $js = ['swfobject.js'];
|
||||
protected $lvTabs = [];
|
||||
protected $search = ''; // output
|
||||
@@ -105,7 +105,7 @@ class SearchPage extends GenericPage
|
||||
// invalid conditions: not enough characters to search OR no types to search
|
||||
if ((!$this->included || !($this->searchMask & SEARCH_MASK_ALL)) && !CFG_MAINTENANCE && !(($this->searchMask & SEARCH_TYPE_JSON) && intVal($this->search)))
|
||||
{
|
||||
$this->mode = CACHETYPE_NONE;
|
||||
$this->mode = CACHE_TYPE_NONE;
|
||||
$this->notFound();
|
||||
}
|
||||
|
||||
@@ -137,9 +137,11 @@ class SearchPage extends GenericPage
|
||||
}
|
||||
}
|
||||
|
||||
protected function generateCacheKey()
|
||||
protected function generateCacheKey($withStaff = true)
|
||||
{
|
||||
$key = [$this->mode, $this->searchMask, md5($this->query), intVal(User::isInGroup(U_GROUP_EMPLOYEE)), User::$localeId];
|
||||
$staff = intVal($withStaff && User::isInGroup(U_GROUP_EMPLOYEE));
|
||||
|
||||
$key = [$this->mode, $this->searchMask, md5($this->query), $staff, User::$localeId];
|
||||
|
||||
return implode('_', $key);
|
||||
}
|
||||
@@ -186,7 +188,7 @@ class SearchPage extends GenericPage
|
||||
|
||||
protected function generateContent() // just wrap it, so GenericPage can call and cache it
|
||||
{
|
||||
if ($this->mode == CACHETYPE_NONE) // search is invalid
|
||||
if ($this->mode == CACHE_TYPE_NONE) // search is invalid
|
||||
return;
|
||||
|
||||
$this->performSearch();
|
||||
|
||||
@@ -15,7 +15,7 @@ class SkillPage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 14];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
private $cat = 0;
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class SkillsPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 14];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [-6, -5, -4, 6, 7, 8, 9, 10, 11];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
|
||||
@@ -15,7 +15,7 @@ class SpellPage extends GenericPage
|
||||
protected $tpl = 'spell';
|
||||
protected $path = [0, 1];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['swfobject.js'];
|
||||
|
||||
private $difficulties = [];
|
||||
@@ -26,7 +26,7 @@ class SpellPage extends GenericPage
|
||||
parent::__construct($pageCall, $id);
|
||||
|
||||
// temp locale
|
||||
if ($this->mode == CACHETYPE_TOOLTIP && isset($_GET['domain']))
|
||||
if ($this->mode == CACHE_TYPE_TOOLTIP && isset($_GET['domain']))
|
||||
Util::powerUseLocale($_GET['domain']);
|
||||
|
||||
$this->typeId = intVal($id);
|
||||
@@ -1093,7 +1093,7 @@ class SpellPage extends GenericPage
|
||||
|
||||
public function display($override = '')
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::display($override);
|
||||
|
||||
if (!$this->loadCache($tt))
|
||||
@@ -1108,7 +1108,7 @@ class SpellPage extends GenericPage
|
||||
|
||||
public function notFound($typeStr)
|
||||
{
|
||||
if ($this->mode != CACHETYPE_TOOLTIP)
|
||||
if ($this->mode != CACHE_TYPE_TOOLTIP)
|
||||
return parent::notFound($typeStr);
|
||||
|
||||
header('Content-type: application/x-javascript; charset=utf-8');
|
||||
|
||||
@@ -14,7 +14,7 @@ class SpellsPage extends GenericPage
|
||||
protected $tpl = 'spells';
|
||||
protected $path = [0, 1];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $js = ['filters.js'];
|
||||
protected $validCats = array(
|
||||
-2 => array( // Talents: Class => Skill
|
||||
|
||||
@@ -10,7 +10,7 @@ class TalentPage extends GenericPage
|
||||
protected $tpl = 'talent';
|
||||
protected $tabId = 1;
|
||||
protected $path = [1];
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
protected $gDataKey = true;
|
||||
protected $js = ['TalentCalc.js'];
|
||||
protected $css = array(
|
||||
|
||||
@@ -20,7 +20,7 @@ class TitlePage extends GenericPage
|
||||
protected $tpl = 'detail-page-generic';
|
||||
protected $path = [0, 10];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
|
||||
private $nameFixed = '';
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ class TitlesPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 10];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [0, 1, 2, 3, 4, 5, 6];
|
||||
|
||||
public function __construct($pageCall, $pageParam)
|
||||
|
||||
@@ -11,7 +11,7 @@ class UtilityPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [1, 8];
|
||||
protected $tabId = 1;
|
||||
protected $mode = CACHETYPE_NONE;
|
||||
protected $mode = CACHE_TYPE_NONE;
|
||||
protected $validPages = array(
|
||||
'latest-additions', 'latest-articles', 'latest-comments', 'latest-screenshots', 'random',
|
||||
'unrated-comments', 11 => 'latest-videos', 12 => 'most-comments', 13 => 'missing-screenshots'
|
||||
|
||||
@@ -14,7 +14,7 @@ class ZonesPage extends GenericPage
|
||||
protected $tpl = 'list-page-generic';
|
||||
protected $path = [0, 6];
|
||||
protected $tabId = 0;
|
||||
protected $mode = CACHETYPE_PAGE;
|
||||
protected $mode = CACHE_TYPE_PAGE;
|
||||
protected $validCats = [true, true, [0, 1, 2], [0, 1, 2], true, true, true, true, true];
|
||||
protected $css = array(
|
||||
['path' => 'Mapper.css']
|
||||
|
||||
2
setup/updates/07_config.sql
Normal file
2
setup/updates/07_config.sql
Normal file
@@ -0,0 +1,2 @@
|
||||
INSERT IGNORE INTO aowow_config (`key`, `intValue`, `comment`) VALUES ('cache_mode', 1, 'default: 1 - set cache method (0: none; 1:filecache; 2:memcached; 3:both)');
|
||||
|
||||
@@ -19785,7 +19785,7 @@ function g_modifyUrl(url, params, opt) {
|
||||
// Polish
|
||||
url = url.replace('?&', '?');
|
||||
url = url.replace(/&&/g, '&');
|
||||
url = url.replace(/\/\?/g, '/');
|
||||
url = url.replace(/\/\?/g, '?');
|
||||
url = url.replace(/(&|\?)+$/, ''); // Remove trailing & and ? characters
|
||||
|
||||
return url + hash;
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -12,8 +12,10 @@ if (User::isInGroup(U_GROUP_EMPLOYEE) && ($this->time || isset($this->mysql) ||
|
||||
echo ' <tr><td style="text-align:left;">Page generated in</td><td>'.Util::formatTime($this->time * 1000, true)."</td></tr>\n";
|
||||
endif;
|
||||
|
||||
if ($this->isCached):
|
||||
echo " <tr><td style=\"text-align:left;\">(rebuild from cache)</td><td></td></tr>\n";
|
||||
if ($this->cacheLoaded && $this->cacheLoaded[0] == CACHE_MODE_FILECACHE):
|
||||
echo " <tr><td style=\"text-align:left;\">reloaded from filecache</td><td>created".Lang::$main['colon'].date(Lang::$main['dateFmtLong'], $this->cacheLoaded[1])."</td></tr>\n";
|
||||
elseif ($this->cacheLoaded && $this->cacheLoaded[0] == CACHE_MODE_MEMCACHED):
|
||||
echo " <tr><td style=\"text-align:left;\">reloaded from memcached</td><td>created".Lang::$main['colon'].date(Lang::$main['dateFmtLong'], $this->cacheLoaded[1])."</td></tr>\n";
|
||||
endif;
|
||||
|
||||
echo " </table>\n";
|
||||
|
||||
Reference in New Issue
Block a user