Zeile 93 | Zeile 93 |
---|
case "apc": require_once MYBB_ROOT."/inc/cachehandlers/apc.php"; $this->handler = new apcCacheHandler();
|
case "apc": require_once MYBB_ROOT."/inc/cachehandlers/apc.php"; $this->handler = new apcCacheHandler();
|
| break; // APCu cache case "apcu": require_once MYBB_ROOT."/inc/cachehandlers/apcu.php"; $this->handler = new apcuCacheHandler(); break; // Redis cache case "redis": require_once MYBB_ROOT."/inc/cachehandlers/redis.php"; $this->handler = new redisCacheHandler();
|
break; }
| break; }
|
Zeile 122 | Zeile 132 |
---|
* @return mixed */ function read($name, $hard=false)
|
* @return mixed */ function read($name, $hard=false)
|
{ global $db, $mybb;
| { global $db, $mybb;
|
// Already have this cache and we're not doing a hard refresh? Return cached copy if(isset($this->cache[$name]) && $hard == false) {
| // Already have this cache and we're not doing a hard refresh? Return cached copy if(isset($this->cache[$name]) && $hard == false) {
|
Zeile 138 | Zeile 148 |
---|
}
if($this->handler instanceof CacheHandlerInterface)
|
}
if($this->handler instanceof CacheHandlerInterface)
|
{ get_execution_time();
| { get_execution_time();
|
$data = $this->handler->fetch($name);
| $data = $this->handler->fetch($name);
|
Zeile 163 | Zeile 173 |
---|
// Fetch from database $query = $db->simple_select("datacache", "title,cache", "title='".$db->escape_string($name)."'"); $cache_data = $db->fetch_array($query);
|
// Fetch from database $query = $db->simple_select("datacache", "title,cache", "title='".$db->escape_string($name)."'"); $cache_data = $db->fetch_array($query);
|
$data = unserialize($cache_data['cache']);
| $data = my_unserialize($cache_data['cache']);
|
// Update cache for handler get_execution_time();
|
// Update cache for handler get_execution_time();
|
|
|
$hit = $this->handler->put($name, $data);
|
$hit = $this->handler->put($name, $data);
|
|
|
$call_time = get_execution_time(); $this->call_time += $call_time; $this->call_count++;
| $call_time = get_execution_time(); $this->call_time += $call_time; $this->call_count++;
|
Zeile 213 | Zeile 223 |
---|
* Update cache contents. * * @param string $name The cache content identifier.
|
* Update cache contents. * * @param string $name The cache content identifier.
|
* @param string $contents The cache content.
| * @param mixed $contents The cache content.
|
*/ function update($name, $contents)
|
*/ function update($name, $contents)
|
{ global $db, $mybb;
| { global $db, $mybb;
|
$this->cache[$name] = $contents;
|
$this->cache[$name] = $contents;
|
|
|
// We ALWAYS keep a running copy in the db just incase we need it
|
// We ALWAYS keep a running copy in the db just incase we need it
|
$dbcontents = $db->escape_string(serialize($contents));
| $dbcontents = $db->escape_string(my_serialize($contents));
|
$replace_array = array( "title" => $db->escape_string($name), "cache" => $dbcontents
| $replace_array = array( "title" => $db->escape_string($name), "cache" => $dbcontents
|
Zeile 231 | Zeile 241 |
---|
$db->replace_query("datacache", $replace_array, "", false);
// Do we have a cache handler we're using?
|
$db->replace_query("datacache", $replace_array, "", false);
// Do we have a cache handler we're using?
|
if($this->handler instanceof CacheHandlerInterface) {
| if($this->handler instanceof CacheHandlerInterface) {
|
get_execution_time();
|
get_execution_time();
|
$hit = $this->handler->put($name, $contents);
| $hit = $this->handler->put($name, $contents);
|
$call_time = get_execution_time(); $this->call_time += $call_time; $this->call_count++;
| $call_time = get_execution_time(); $this->call_time += $call_time; $this->call_count++;
|
Zeile 247 | Zeile 257 |
---|
} } }
|
} } }
|
|
|
/** * Delete cache contents. * Originally from frostschutz's PluginLibrary
| /** * Delete cache contents. * Originally from frostschutz's PluginLibrary
|
Zeile 293 | Zeile 303 |
---|
if(strpos($key, $name) === 0) { $names[$key] = 0;
|
if(strpos($key, $name) === 0) { $names[$key] = 0;
|
}
| }
|
}
$ldbname = strtr($dbname,
| }
$ldbname = strtr($dbname,
|
Zeile 323 | Zeile 333 |
---|
{ $filename = substr($filename, $start, strlen($filename)-4-$start); $names[$filename] = 0;
|
{ $filename = substr($filename, $start, strlen($filename)-4-$start); $names[$filename] = 0;
|
} }
| } }
|
foreach($names as $key => $val) { get_execution_time();
|
foreach($names as $key => $val) { get_execution_time();
|
$hit = $this->handler->delete($key);
| $hit = $this->handler->delete($key);
|
$call_time = get_execution_time(); $this->call_time += $call_time; $this->call_count++;
| $call_time = get_execution_time(); $this->call_time += $call_time; $this->call_count++;
|
Zeile 339 | Zeile 349 |
---|
if($mybb->debug_mode) { $this->debug_call('delete:'.$name, $call_time, $hit);
|
if($mybb->debug_mode) { $this->debug_call('delete:'.$name, $call_time, $hit);
|
} } }
| } } }
|
}
|
}
|
|
|
// Delete database cache $db->delete_query("datacache", $where); }
| // Delete database cache $db->delete_query("datacache", $where); }
|
Zeile 354 | Zeile 364 |
---|
* @param string $string The cache key * @param string $qtime The time it took to perform the call. * @param boolean $hit Hit or miss status
|
* @param string $string The cache key * @param string $qtime The time it took to perform the call. * @param boolean $hit Hit or miss status
|
*/
| */
|
function debug_call($string, $qtime, $hit) { global $mybb, $plugins;
| function debug_call($string, $qtime, $hit) { global $mybb, $plugins;
|
Zeile 368 | Zeile 378 |
---|
if($hit) { $hit_status = 'HIT';
|
if($hit) { $hit_status = 'HIT';
|
} else
| } else
|
{ $hit_status = 'MISS'; }
|
{ $hit_status = 'MISS'; }
|
|
|
$cache_data = explode(':', $string); $cache_method = $cache_data[0]; $cache_key = $cache_data[1];
| $cache_data = explode(':', $string); $cache_method = $cache_data[0]; $cache_key = $cache_data[1];
|
Zeile 384 | Zeile 394 |
---|
</tr> <tr style=\"background-color: #fefefe;\"> <td><span style=\"font-family: Courier; font-size: 14px;\">({$mybb->config['cache_store']}) [{$hit_status}] ".htmlspecialchars_uni($cache_key)."</span></td>
|
</tr> <tr style=\"background-color: #fefefe;\"> <td><span style=\"font-family: Courier; font-size: 14px;\">({$mybb->config['cache_store']}) [{$hit_status}] ".htmlspecialchars_uni($cache_key)."</span></td>
|
</tr>
| </tr>
|
<tr> <td bgcolor=\"#ffffff\">Call Time: ".format_time_duration($qtime)."</td> </tr>
| <tr> <td bgcolor=\"#ffffff\">Call Time: ".format_time_duration($qtime)."</td> </tr>
|
Zeile 445 | Zeile 455 |
---|
* */ function update_version()
|
* */ function update_version()
|
{
| {
|
global $mybb;
|
global $mybb;
|
|
|
$version = array( "version" => $mybb->version, "version_code" => $mybb->version_code
| $version = array( "version" => $mybb->version, "version_code" => $mybb->version_code
|
Zeile 455 | Zeile 465 |
---|
$this->update("version", $version); }
|
$this->update("version", $version); }
|
|
|
/** * Update the attachment type cache. * */ function update_attachtypes()
|
/** * Update the attachment type cache. * */ function update_attachtypes()
|
{ global $db;
$types = array();
| { global $db;
$types = array();
|
$query = $db->simple_select('attachtypes', '*', 'enabled=1'); while($type = $db->fetch_array($query)) {
| $query = $db->simple_select('attachtypes', '*', 'enabled=1'); while($type = $db->fetch_array($query)) {
|
Zeile 481 | Zeile 491 |
---|
* */ function update_smilies()
|
* */ function update_smilies()
|
{
| {
|
global $db;
$smilies = array();
| global $db;
$smilies = array();
|
Zeile 512 | Zeile 522 |
---|
}
$this->update("posticons", $icons);
|
}
$this->update("posticons", $icons);
|
}
| }
|
/** * Update the badwords cache.
| /** * Update the badwords cache.
|
Zeile 540 | Zeile 550 |
---|
function update_usergroups() { global $db;
|
function update_usergroups() { global $db;
|
$query = $db->simple_select("usergroups");
| $query = $db->simple_select("usergroups");
|
$gs = array(); while($g = $db->fetch_array($query)) {
| $gs = array(); while($g = $db->fetch_array($query)) {
|
Zeile 561 | Zeile 571 |
---|
{ global $forum_cache, $db;
|
{ global $forum_cache, $db;
|
$this->built_forum_permissions = array(0);
| $this->forum_permissions = $this->built_forum_permissions = array(0);
|
// Get our forum list cache_forums(true);
| // Get our forum list cache_forums(true);
|
Zeile 589 | Zeile 599 |
---|
// Fetch forum permissions from the database $query = $db->simple_select("forumpermissions"); while($forum_permission = $db->fetch_array($query))
|
// Fetch forum permissions from the database $query = $db->simple_select("forumpermissions"); while($forum_permission = $db->fetch_array($query))
|
{
| {
|
$this->forum_permissions[$forum_permission['fid']][$forum_permission['gid']] = $forum_permission; }
| $this->forum_permissions[$forum_permission['fid']][$forum_permission['gid']] = $forum_permission; }
|
Zeile 618 | Zeile 628 |
---|
$perms = $permissions; foreach($usergroups as $gid) {
|
$perms = $permissions; foreach($usergroups as $gid) {
|
if($this->forum_permissions[$forum['fid']][$gid])
| if(isset($this->forum_permissions[$forum['fid']][$gid]) && $this->forum_permissions[$forum['fid']][$gid])
|
{ $perms[$gid] = $this->forum_permissions[$forum['fid']][$gid]; }
| { $perms[$gid] = $this->forum_permissions[$forum['fid']][$gid]; }
|
Zeile 636 | Zeile 646 |
---|
/** * Update the stats cache (kept for the sake of being able to rebuild this cache via the cache interface)
|
/** * Update the stats cache (kept for the sake of being able to rebuild this cache via the cache interface)
|
*
| *
|
*/ function update_stats() {
| */ function update_stats() {
|
Zeile 651 | Zeile 661 |
---|
function update_statistics() { global $db;
|
function update_statistics() { global $db;
|
|
|
$query = $db->simple_select('users', 'uid, username, referrals', 'referrals>0', array('order_by' => 'referrals', 'order_dir' => 'DESC', 'limit' => 1)); $topreferrer = $db->fetch_array($query);
| $query = $db->simple_select('users', 'uid, username, referrals', 'referrals>0', array('order_by' => 'referrals', 'order_dir' => 'DESC', 'limit' => 1)); $topreferrer = $db->fetch_array($query);
|
Zeile 676 | Zeile 686 |
---|
");
$most_posts = 0;
|
");
$most_posts = 0;
|
| $topposter = array();
|
while($user = $db->fetch_array($query)) { if($user['poststoday'] > $most_posts)
| while($user = $db->fetch_array($query)) { if($user['poststoday'] > $most_posts)
|
Zeile 714 | Zeile 725 |
---|
if(!is_array($forum_cache)) { return false;
|
if(!is_array($forum_cache)) { return false;
|
}
| }
|
reset($forum_cache); $fcache = array();
|
reset($forum_cache); $fcache = array();
|
|
|
// Resort in to the structure we require foreach($forum_cache as $fid => $forum)
|
// Resort in to the structure we require foreach($forum_cache as $fid => $forum)
|
{
| {
|
$this->moderators_forum_cache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
|
$this->moderators_forum_cache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;
|
}
| }
|
// Sort children foreach($fcache as $pid => $value) { ksort($fcache[$pid]);
|
// Sort children foreach($fcache as $pid => $value) { ksort($fcache[$pid]);
|
}
| }
|
ksort($fcache);
$this->moderators = array();
| ksort($fcache);
$this->moderators = array();
|
Zeile 790 | Zeile 801 |
---|
function update_awaitingactivation() { global $db;
|
function update_awaitingactivation() { global $db;
|
|
|
$query = $db->simple_select('users', 'COUNT(uid) AS awaitingusers', 'usergroup=\'5\''); $awaitingusers = (int)$db->fetch_field($query, 'awaitingusers');
| $query = $db->simple_select('users', 'COUNT(uid) AS awaitingusers', 'usergroup=\'5\''); $awaitingusers = (int)$db->fetch_field($query, 'awaitingusers');
|
Zeile 836 | Zeile 847 |
---|
} $this->built_moderators[$forum['fid']] = $forum_mods; $this->build_moderators($forum_mods, $forum['fid']);
|
} $this->built_moderators[$forum['fid']] = $forum_mods; $this->build_moderators($forum_mods, $forum['fid']);
|
} }
| } }
|
} }
| } }
|
Zeile 853 | Zeile 864 |
---|
// Things we don't want to cache $exclude = array("unapprovedthreads", "unapprovedposts", "threads", "posts", "lastpost", "lastposter", "lastposttid", "lastposteruid", "lastpostsubject", "deletedthreads", "deletedposts");
|
// Things we don't want to cache $exclude = array("unapprovedthreads", "unapprovedposts", "threads", "posts", "lastpost", "lastposter", "lastposttid", "lastposteruid", "lastpostsubject", "deletedthreads", "deletedposts");
|
|
|
$query = $db->simple_select("forums", "*", "", array('order_by' => 'pid,disporder')); while($forum = $db->fetch_array($query)) {
| $query = $db->simple_select("forums", "*", "", array('order_by' => 'pid,disporder')); while($forum = $db->fetch_array($query)) {
|
Zeile 868 | Zeile 879 |
---|
}
$this->update("forums", $forums);
|
}
$this->update("forums", $forums);
|
}
| }
|
/** * Update usertitles cache.
| /** * Update usertitles cache.
|
Zeile 894 | Zeile 905 |
---|
*/ function update_reportedcontent() {
|
*/ function update_reportedcontent() {
|
global $db, $mybb;
| global $db;
|
$query = $db->simple_select("reportedcontent", "COUNT(rid) AS unreadcount", "reportstatus='0'");
|
$query = $db->simple_select("reportedcontent", "COUNT(rid) AS unreadcount", "reportstatus='0'");
|
$num = $db->fetch_array($query);
| $unreadcount = $db->fetch_field($query, 'unreadcount');
|
$query = $db->simple_select("reportedcontent", "COUNT(rid) AS reportcount");
|
$query = $db->simple_select("reportedcontent", "COUNT(rid) AS reportcount");
|
$total = $db->fetch_array($query);
$query = $db->simple_select("reportedcontent", "dateline", "reportstatus='0'", array('order_by' => 'dateline', 'order_dir' => 'DESC')); $latest = $db->fetch_array($query);
| $reportcount = $db->fetch_field($query, 'reportcount'); $query = $db->simple_select("reportedcontent", "dateline", "reportstatus='0'", array('order_by' => 'dateline', 'order_dir' => 'DESC', 'limit' => 1)); $dateline = $db->fetch_field($query, 'dateline');
|
$reports = array(
|
$reports = array(
|
"unread" => $num['unreadcount'], "total" => $total['reportcount'], "lastdateline" => $latest['dateline']
| 'unread' => $unreadcount, 'total' => $reportcount, 'lastdateline' => $dateline,
|
);
$this->update("reportedcontent", $reports);
| );
$this->update("reportedcontent", $reports);
|
Zeile 1089 | Zeile 1100 |
---|
$this->update("most_viewed_threads", $threads); }
|
$this->update("most_viewed_threads", $threads); }
|
| /** * @deprecated */
|
function update_banned() {
|
function update_banned() {
|
global $db;
$bans = array();
$query = $db->simple_select("banned"); while($ban = $db->fetch_array($query)) { $bans[$ban['uid']] = $ban; }
$this->update("banned", $bans);
| // "banned" cache removed
|
}
function update_birthdays()
| }
function update_birthdays()
|