Vergleich inc/class_datacache.php - 1.8.8 - 1.8.27

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 93Zeile 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;
}

if($this->handler instanceof CacheHandlerInterface)

				break;
}

if($this->handler instanceof CacheHandlerInterface)

		{

		{

			if(!$this->handler->connect())

			if(!$this->handler->connect())

			{

			{

				$this->handler = null;

				$this->handler = null;

			}

			}

		}
else
{

		}
else
{

Zeile 110Zeile 120
			while($data = $db->fetch_array($query))
{
$this->cache[$data['title']] = unserialize($data['cache']);

			while($data = $db->fetch_array($query))
{
$this->cache[$data['title']] = unserialize($data['cache']);

			}

			}

		}
}


		}
}


Zeile 129Zeile 139
		if(isset($this->cache[$name]) && $hard == false)
{
return $this->cache[$name];

		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 && !($this->handler instanceof CacheHandlerInterface))

		// 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 && !($this->handler instanceof CacheHandlerInterface))

		{
return false;
}

if($this->handler instanceof CacheHandlerInterface)
{
get_execution_time();

$data = $this->handler->fetch($name);

$call_time = get_execution_time();
$this->call_time += $call_time;
$this->call_count++;

if($mybb->debug_mode)

		{
return false;
}

if($this->handler instanceof CacheHandlerInterface)
{
get_execution_time();

$data = $this->handler->fetch($name);

$call_time = get_execution_time();
$this->call_time += $call_time;
$this->call_count++;

if($mybb->debug_mode)

			{
$hit = true;
if($data === false)

			{
$hit = true;
if($data === false)

Zeile 163Zeile 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);

$call_time = get_execution_time();

				$hit = $this->handler->put($name, $data);

$call_time = get_execution_time();

Zeile 204Zeile 214
			return $data;
}
else

			return $data;
}
else

		{

		{

			return false;
}
}

			return false;
}
}

Zeile 213Zeile 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)
{

Zeile 222Zeile 232
		$this->cache[$name] = $contents;

// We ALWAYS keep a running copy in the db just incase we need it

		$this->cache[$name] = $contents;

// 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),


$replace_array = array(
"title" => $db->escape_string($name),

Zeile 244Zeile 254
			if($mybb->debug_mode)
{
$this->debug_call('update:'.$name, $call_time, $hit);

			if($mybb->debug_mode)
{
$this->debug_call('update:'.$name, $call_time, $hit);

			}
}
}


			}
}
}


	/**
* Delete cache contents.
* Originally from frostschutz's PluginLibrary

	/**
* Delete cache contents.
* Originally from frostschutz's PluginLibrary

Zeile 258Zeile 268
	 */
function delete($name, $greedy = false)
{

	 */
function delete($name, $greedy = false)
{

		 global $db, $mybb, $cache;

		global $db, $mybb, $cache;


// Prepare for database query.
$dbname = $db->escape_string($name);


// Prepare for database query.
$dbname = $db->escape_string($name);

Zeile 550Zeile 560
		}

$this->update("usergroups", $gs);

		}

$this->update("usergroups", $gs);

	}


	}


	/**
* Update the forum permissions cache.
*
* @return bool When failed, returns false.
*/
function update_forumpermissions()

	/**
* Update the forum permissions cache.
*
* @return bool When failed, returns false.
*/
function update_forumpermissions()

	{
global $forum_cache, $db;

$this->built_forum_permissions = array(0);

// Get our forum list
cache_forums(true);
if(!is_array($forum_cache))
{
return false;
}

reset($forum_cache);

	{
global $forum_cache, $db;

$this->forum_permissions = $this->built_forum_permissions = array(0);

// Get our forum list
cache_forums(true);
if(!is_array($forum_cache))
{
return false;
}

reset($forum_cache);

		$fcache = array();

// Resort in to the structure we require
foreach($forum_cache as $fid => $forum)

		$fcache = array();

// Resort in to the structure we require
foreach($forum_cache as $fid => $forum)

		{

		{

			$this->forum_permissions_forum_cache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

			$this->forum_permissions_forum_cache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

		}


		}


		// Sort children
foreach($fcache as $pid => $value)
{

		// Sort children
foreach($fcache as $pid => $value)
{

Zeile 589Zeile 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 618Zeile 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 646Zeile 656

/**
* Update the statistics cache


/**
* Update the statistics cache

	 *
*/

	 *
*/

	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);

	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);





		$timesearch = TIME_NOW - 86400;
switch($db->type)
{

		$timesearch = TIME_NOW - 86400;
switch($db->type)
{

Zeile 664Zeile 674
			default:
$group_by = 'p.uid';
break;

			default:
$group_by = 'p.uid';
break;

		}

$query = $db->query('
SELECT u.uid, u.username, COUNT(pid) AS poststoday
FROM '.TABLE_PREFIX.'posts p
LEFT JOIN '.TABLE_PREFIX.'users u ON (p.uid=u.uid)
WHERE p.dateline>'.$timesearch.'
GROUP BY '.$group_by.' ORDER BY poststoday DESC
LIMIT 1
');
$topposter = $db->fetch_array($query);












		}

$query = $db->query("
SELECT u.uid, u.username, COUNT(*) AS poststoday
FROM {$db->table_prefix}posts p
LEFT JOIN {$db->table_prefix}users u ON (p.uid=u.uid)
WHERE p.dateline > {$timesearch} AND p.visible=1
GROUP BY {$group_by}
ORDER BY poststoday DESC
");

$most_posts = 0;
$topposter = array();
while($user = $db->fetch_array($query))
{
if($user['poststoday'] > $most_posts)
{
$most_posts = $user['poststoday'];
$topposter = $user;
}
}


		$query = $db->simple_select('users', 'COUNT(uid) AS posters', 'postnum>0');
$posters = $db->fetch_field($query, 'posters');


		$query = $db->simple_select('users', 'COUNT(uid) AS posters', 'postnum>0');
$posters = $db->fetch_field($query, 'posters');


Zeile 712Zeile 732

// 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;
}


Zeile 764Zeile 784
			foreach(array_keys($this->moderators) as $fid)
{
uasort($this->moderators[$fid], 'sort_moderators_by_usernames');

			foreach(array_keys($this->moderators) as $fid)
{
uasort($this->moderators[$fid], 'sort_moderators_by_usernames');

			}
}

$this->build_moderators();


			}
}

$this->build_moderators();


		$this->update("moderators", $this->built_moderators);

return true;

		$this->update("moderators", $this->built_moderators);

return true;

Zeile 805Zeile 825
		if(isset($this->moderators_forum_cache[$pid]))
{
foreach($this->moderators_forum_cache[$pid] as $main)

		if(isset($this->moderators_forum_cache[$pid]))
{
foreach($this->moderators_forum_cache[$pid] as $main)

			{

			{

				foreach($main as $forum)
{

				foreach($main as $forum)
{

					$forum_mods = '';

					$forum_mods = array();

					if(count($moderators))
{
$forum_mods = $moderators;

					if(count($moderators))
{
$forum_mods = $moderators;

Zeile 844Zeile 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 863Zeile 883

/**
* Update usertitles cache.


/**
* Update usertitles cache.

	 *
*/

	 *
*/

	function update_usertitles()
{
global $db;

	function update_usertitles()
{
global $db;





		$usertitles = array();
$query = $db->simple_select("usertitles", "utid, posts, title, stars, starimage", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
while($usertitle = $db->fetch_array($query))

		$usertitles = array();
$query = $db->simple_select("usertitles", "utid, posts, title, stars, starimage", "", array('order_by' => 'posts', 'order_dir' => 'DESC'));
while($usertitle = $db->fetch_array($query))

Zeile 881Zeile 901

/**
* Update reported content cache.


/**
* Update reported content cache.

	 *

	 *

	 */
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);

$query = $db->simple_select("reportedcontent", "COUNT(rid) AS reportcount");
$total = $db->fetch_array($query);

		$unreadcount = $db->fetch_field($query, 'unreadcount');








		$query = $db->simple_select("reportedcontent", "dateline", "reportstatus='0'", array('order_by' => 'dateline', 'order_dir' => 'DESC'));
$latest = $db->fetch_array($query);




		$query = $db->simple_select("reportedcontent", "COUNT(rid) AS reportcount");
$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 907Zeile 927

/**
* Update mycode cache.


/**
* Update mycode cache.

	 *
*/

	 *
*/

	function update_mycode()
{
global $db;

	function update_mycode()
{
global $db;

Zeile 945Zeile 965
		if($last_run > 0)
{
$mailqueue['last_run'] = $last_run;

		if($last_run > 0)
{
$mailqueue['last_run'] = $last_run;

		}

		}

		$mailqueue['locked'] = $lock_time;

$this->update("mailqueue", $mailqueue);

		$mailqueue['locked'] = $lock_time;

$this->update("mailqueue", $mailqueue);

Zeile 1020Zeile 1040
	 * Updates the banned emails cache
*/
function update_bannedemails()

	 * Updates the banned emails cache
*/
function update_bannedemails()

	{
global $db;


	{
global $db;


		$banned_emails = array();
$query = $db->simple_select("banfilters", "fid, filter", "type = '3'");

while($banned_email = $db->fetch_array($query))

		$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;
}


			$banned_emails[$banned_email['fid']] = $banned_email;
}


Zeile 1051Zeile 1071
	}

function update_most_replied_threads()

	}

function update_most_replied_threads()

	{
global $db, $mybb;

$threads = array();

$query = $db->simple_select("threads", "tid, subject, replies, fid", "visible='1'", array('order_by' => 'replies', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
while($thread = $db->fetch_array($query))
{
$threads[] = $thread;

	{
global $db, $mybb;

$threads = array();

$query = $db->simple_select("threads", "tid, subject, replies, fid, uid", "visible='1'", array('order_by' => 'replies', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
while($thread = $db->fetch_array($query))
{
$threads[] = $thread;

		}

$this->update("most_replied_threads", $threads);

		}

$this->update("most_replied_threads", $threads);

Zeile 1071Zeile 1091

$threads = array();



$threads = array();


		$query = $db->simple_select("threads", "tid, subject, views, fid", "visible='1'", array('order_by' => 'views', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));

		$query = $db->simple_select("threads", "tid, subject, views, fid, uid", "visible='1'", array('order_by' => 'views', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));

		while($thread = $db->fetch_array($query))
{
$threads[] = $thread;

		while($thread = $db->fetch_array($query))
{
$threads[] = $thread;

		}


		}


		$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()

Zeile 1329Zeile 1342

$query = $db->simple_select("datacache", "title,cache", "title='adminnotes'");
$this->update("adminnotes", unserialize($db->fetch_field($query, "cache")));


$query = $db->simple_select("datacache", "title,cache", "title='adminnotes'");
$this->update("adminnotes", unserialize($db->fetch_field($query, "cache")));

	}

function reload_mybb_credits()
{
admin_redirect('index.php?module=home-credits&fetch_new=-2');

 
	}
}

	}
}