Zeile 6 | Zeile 6 |
---|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* Website: http://mybb.com * License: http://mybb.com/about/license *
|
* $Id: class_datacache.php 5057 2010-06-23 08:07:55Z RyanGordon $
| * $Id$
|
*/
class datacache
| */
class datacache
|
Zeile 95 | Zeile 95 |
---|
function read($name, $hard=false) { global $db, $mybb;
|
function read($name, $hard=false) { 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) { return $this->cache[$name]; }
|
// Already have this cache and we're not doing a hard refresh? Return cached copy if(isset($this->cache[$name]) && $hard == false) { return $this->cache[$name]; }
|
| // If we're not hard refreshing, and this cache doesn't exist, return false // It would have been loaded pre-global if it did exist anyway... else if($hard == false && !is_object($this->handler)) { return false; }
|
if(is_object($this->handler)) { $data = $this->handler->fetch($name);
|
if(is_object($this->handler)) { $data = $this->handler->fetch($name);
|
|
|
// No data returned - cache gone bad? if($data === false) {
| // No data returned - cache gone bad? if($data === false) {
|
Zeile 113 | Zeile 119 |
---|
$query = $db->simple_select("datacache", "title,cache", "title='".$db->escape_string($name)."'"); $cache_data = $db->fetch_array($query); $data = @unserialize($cache_data['cache']);
|
$query = $db->simple_select("datacache", "title,cache", "title='".$db->escape_string($name)."'"); $cache_data = $db->fetch_array($query); $data = @unserialize($cache_data['cache']);
|
if($data == null) { $data = ''; }
|
|
// Update cache for handler $this->handler->put($name, $data); }
|
// Update cache for handler $this->handler->put($name, $data); }
|
}
| }
|
// Else, using internal database cache else { $query = $db->simple_select("datacache", "title,cache", "title='$name'"); $cache_data = $db->fetch_array($query);
|
// Else, using internal database cache else { $query = $db->simple_select("datacache", "title,cache", "title='$name'"); $cache_data = $db->fetch_array($query);
|
|
|
if(!$cache_data['title']) { $data = false;
| if(!$cache_data['title']) { $data = false;
|
Zeile 170 | Zeile 172 |
---|
"title" => $db->escape_string($name), "cache" => $dbcontents );
|
"title" => $db->escape_string($name), "cache" => $dbcontents );
|
$db->replace_query("datacache", $replace_array, "title", false);
| $db->replace_query("datacache", $replace_array, "", false);
|
// Do we have a cache handler we're using? if(is_object($this->handler))
| // Do we have a cache handler we're using? if(is_object($this->handler))
|
Zeile 195 | Zeile 197 |
---|
if(!$size) { if($name)
|
if(!$size) { if($name)
|
{
| {
|
$query = $db->simple_select("datacache", "cache", "title='{$name}'"); return strlen($db->fetch_field($query, "cache")); }
| $query = $db->simple_select("datacache", "cache", "title='{$name}'"); return strlen($db->fetch_field($query, "cache")); }
|
Zeile 476 | Zeile 478 |
---|
function sort_moderators_by_usernames($a, $b) { return strcasecmp($a['username'], $b['username']);
|
function sort_moderators_by_usernames($a, $b) { return strcasecmp($a['username'], $b['username']);
|
} }
| } }
|
//Fetch moderating usergroups from the database $query = $db->query(" SELECT m.*, u.title
| //Fetch moderating usergroups from the database $query = $db->query(" SELECT m.*, u.title
|
Zeile 490 | Zeile 492 |
---|
while($moderator = $db->fetch_array($query)) { $this->moderators[$moderator['fid']]['usergroups'][$moderator['id']] = $moderator;
|
while($moderator = $db->fetch_array($query)) { $this->moderators[$moderator['fid']]['usergroups'][$moderator['id']] = $moderator;
|
}
| }
|
if(is_array($this->moderators)) {
| if(is_array($this->moderators)) {
|
Zeile 521 | Zeile 523 |
---|
foreach($main as $forum) { $forum_mods = '';
|
foreach($main as $forum) { $forum_mods = '';
|
if($moderators)
| if(count($moderators))
|
{ $forum_mods = $moderators; } // Append - local settings override that of a parent - array_merge works here if($this->moderators[$forum['fid']]) {
|
{ $forum_mods = $moderators; } // Append - local settings override that of a parent - array_merge works here if($this->moderators[$forum['fid']]) {
|
if(is_array($forum_mods))
| if(is_array($forum_mods) && count($forum_mods))
|
{
|
{
|
$forum_mods = $forum_mods + $this->moderators[$forum['fid']];
| $forum_mods = array_merge($forum_mods, $this->moderators[$forum['fid']]);
|
} else {
| } else {
|
Zeile 539 | Zeile 541 |
---|
} $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 552 | Zeile 554 |
---|
{ global $db; $forums = array();
|
{ global $db; $forums = array();
|
|
|
// Things we don't want to cache $exclude = array("unapprovedthreads","unapprovedposts", "threads", "posts", "lastpost", "lastposter", "lastposttid");
| // Things we don't want to cache $exclude = array("unapprovedthreads","unapprovedposts", "threads", "posts", "lastpost", "lastposter", "lastposttid");
|
Zeile 574 | Zeile 576 |
---|
/** * Update usertitles cache.
|
/** * Update usertitles cache.
|
* */
| * */
|
function update_usertitles() { global $db;
| function update_usertitles() { global $db;
|
Zeile 584 | Zeile 586 |
---|
while($usertitle = $db->fetch_array($query)) { $usertitles[] = $usertitle;
|
while($usertitle = $db->fetch_array($query)) { $usertitles[] = $usertitle;
|
}
| }
|
$this->update("usertitles", $usertitles); }
| $this->update("usertitles", $usertitles); }
|
Zeile 631 | Zeile 633 |
---|
} $this->update("mycode", $mycodes);
|
} $this->update("mycode", $mycodes);
|
} /**
| } /**
|
* Update the mailqueue cache * */
| * Update the mailqueue cache * */
|
Zeile 656 | Zeile 658 |
---|
$mailqueue['locked'] = $lock_time; $this->update("mailqueue", $mailqueue);
|
$mailqueue['locked'] = $lock_time; $this->update("mailqueue", $mailqueue);
|
}
| }
|
|
|
/**
| /**
|
* Update update_check cache (dummy function used by upgrade/install scripts) */ function update_update_check()
| * Update update_check cache (dummy function used by upgrade/install scripts) */ function update_update_check()
|
Zeile 668 | Zeile 670 |
---|
); $this->update("update_check", $update_cache);
|
); $this->update("update_check", $update_cache);
|
}
/**
| }
/**
|
* Updates the tasks cache saving the next run time */ function update_tasks()
|
* Updates the tasks cache saving the next run time */ function update_tasks()
|
{ global $db;
| { global $db;
|
$query = $db->simple_select("tasks", "nextrun", "enabled=1", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1)); $next_task = $db->fetch_array($query);
| $query = $db->simple_select("tasks", "nextrun", "enabled=1", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1)); $next_task = $db->fetch_array($query);
|
Zeile 689 | Zeile 691 |
---|
if(!$task_cache['nextrun']) { $task_cache['nextrun'] = TIME_NOW+3600;
|
if(!$task_cache['nextrun']) { $task_cache['nextrun'] = TIME_NOW+3600;
|
}
| }
|
$this->update("tasks", $task_cache);
|
$this->update("tasks", $task_cache);
|
}
| }
|
/** * Updates the banned IPs cache */
| /** * Updates the banned IPs cache */
|
Zeile 708 | Zeile 710 |
---|
$banned_ips[$banned_ip['fid']] = $banned_ip; } $this->update("bannedips", $banned_ips);
|
$banned_ips[$banned_ip['fid']] = $banned_ip; } $this->update("bannedips", $banned_ips);
|
| }
/** * Updates the banned emails cache */ function update_bannedemails() { global $db;
$banned_emails = array(); $query = $db->simple_select("banfilters", "fid, filter", "type = '3'");
while($banned_email = $db->fetch_array($query)) { $banned_emails[$banned_email['fid']] = $banned_email; }
$this->update("bannedemails", $banned_emails);
|
}
/**
| }
/**
|
Zeile 819 | Zeile 839 |
---|
$this->update("groupleaders", $groupleaders); }
|
$this->update("groupleaders", $groupleaders); }
|
/* Other, extra functions for reloading caches if we just changed to another cache extension (i.e. from db -> xcache) */ function reload_mostonline()
| function update_threadprefixes() { global $db;
$prefixes = array(); $query = $db->simple_select("threadprefixes", "*", "", array("order_by" => "pid"));
while($prefix = $db->fetch_array($query)) { $prefixes[$prefix['pid']] = $prefix; }
$this->update("threadprefixes", $prefixes); }
function update_forumsdisplay() { global $db;
$fd_statistics = array();
$time = TIME_NOW; // Look for announcements that don't end, or that are ending some time in the future $query = $db->simple_select("announcements", "fid", "enddate = '0' OR enddate > '{$time}'", array("order_by" => "aid"));
if($db->num_rows($query)) { while($forum = $db->fetch_array($query)) { if(!isset($fd_statistics[$forum['fid']]['announcements'])) { $fd_statistics[$forum['fid']]['announcements'] = 1; } } }
// Do we have any mod tools to use in our forums? $query = $db->simple_select("modtools", "forums, tid", '', array("order_by" => "tid"));
if($db->num_rows($query)) { unset($forum); while($tool = $db->fetch_array($query)) { $forums = explode(",", $tool['forums']);
foreach($forums as $forum) { if(!$forum) { $forum = -1; }
if(!isset($fd_statistics[$forum]['modtools'])) { $fd_statistics[$forum]['modtools'] = 1; } } } }
$this->update("forumsdisplay", $fd_statistics); }
/* Other, extra functions for reloading caches if we just changed to another cache extension (i.e. from db -> xcache) */ function reload_mostonline()
|
{ global $db;
$query = $db->simple_select("datacache", "title,cache", "title='mostonline'"); $this->update("mostonline", @unserialize($db->fetch_field($query, "cache")));
|
{ global $db;
$query = $db->simple_select("datacache", "title,cache", "title='mostonline'"); $this->update("mostonline", @unserialize($db->fetch_field($query, "cache")));
|
}
| }
|
function reload_plugins() { global $db;
| function reload_plugins() { global $db;
|
Zeile 838 | Zeile 921 |
---|
} function reload_last_backup()
|
} function reload_last_backup()
|
{
| {
|
global $db;
$query = $db->simple_select("datacache", "title,cache", "title='last_backup'"); $this->update("last_backup", @unserialize($db->fetch_field($query, "cache")));
|
global $db;
$query = $db->simple_select("datacache", "title,cache", "title='last_backup'"); $this->update("last_backup", @unserialize($db->fetch_field($query, "cache")));
|
}
| }
|
function reload_internal_settings()
|
function reload_internal_settings()
|
{ global $db;
| { global $db;
|
$query = $db->simple_select("datacache", "title,cache", "title='internal_settings'"); $this->update("internal_settings", @unserialize($db->fetch_field($query, "cache"))); }
| $query = $db->simple_select("datacache", "title,cache", "title='internal_settings'"); $this->update("internal_settings", @unserialize($db->fetch_field($query, "cache"))); }
|
Zeile 859 | Zeile 942 |
---|
$query = $db->simple_select("datacache", "title,cache", "title='version_history'"); $this->update("version_history", @unserialize($db->fetch_field($query, "cache")));
|
$query = $db->simple_select("datacache", "title,cache", "title='version_history'"); $this->update("version_history", @unserialize($db->fetch_field($query, "cache")));
|
| }
function reload_modnotes() { global $db;
$query = $db->simple_select("datacache", "title,cache", "title='modnotes'"); $this->update("modnotes", @unserialize($db->fetch_field($query, "cache"))); }
function reload_adminnotes() { global $db;
$query = $db->simple_select("datacache", "title,cache", "title='adminnotes'"); $this->update("adminnotes", @unserialize($db->fetch_field($query, "cache")));
|
} } ?>
| } } ?>
|