Vergleich inc/class_datacache.php - 1.8.21 - 1.8.39

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 51Zeile 51
	 * @var string
*/
public $cache_debug;

	 * @var string
*/
public $cache_debug;

 

/**
* @var array
*/
public $moderators;

/**
* @var array
*/
public $built_moderators;

/**
* @var array
*/
public $moderators_forum_cache;


/**
* Build cache data.


/**
* Build cache data.

Zeile 93Zeile 108
			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 101Zeile 126
			if(!$this->handler->connect())
{
$this->handler = null;

			if(!$this->handler->connect())
{
$this->handler = null;

			}

			}

		}
else
{

		}
else
{

Zeile 109Zeile 134
			$query = $db->simple_select("datacache", "title,cache");
while($data = $db->fetch_array($query))
{

			$query = $db->simple_select("datacache", "title,cache");
while($data = $db->fetch_array($query))
{

				$this->cache[$data['title']] = unserialize($data['cache']);


				// use native_unserialize() over my_unserialize() for performance reasons
$this->cache[$data['title']] = native_unserialize($data['cache']);

			}
}
}

			}
}
}

Zeile 135Zeile 161
		else if($hard == false && !($this->handler instanceof CacheHandlerInterface))
{
return false;

		else if($hard == false && !($this->handler instanceof CacheHandlerInterface))
{
return false;

		}

		}


if($this->handler instanceof CacheHandlerInterface)
{


if($this->handler instanceof CacheHandlerInterface)
{

Zeile 151Zeile 177
			{
$hit = true;
if($data === false)

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

				{

				{

					$hit = false;

					$hit = false;

				}

				}

				$this->debug_call('read:'.$name, $call_time, $hit);
}


				$this->debug_call('read:'.$name, $call_time, $hit);
}


Zeile 163Zeile 189
				// 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 = my_unserialize($cache_data['cache']);

// Update cache for handler
get_execution_time();

 




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













				if($cache_data)
{
// use native_unserialize() over my_unserialize() for performance reasons
$data = native_unserialize($cache_data['cache']);

// Update cache for handler
get_execution_time();

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

if($mybb->debug_mode)


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

				{

				{

					$this->debug_call('set:'.$name, $call_time, $hit);

					$data = false;

				}
}
}

				}
}
}

Zeile 186Zeile 221
			$query = $db->simple_select("datacache", "title,cache", "title='$name'");
$cache_data = $db->fetch_array($query);


			$query = $db->simple_select("datacache", "title,cache", "title='$name'");
$cache_data = $db->fetch_array($query);


			if(!$cache_data['title'])

			if(empty($cache_data['title']))

			{
$data = false;

			{
$data = false;

			}
else
{
$data = unserialize($cache_data['cache']);
}
}


			}
else
{
// use native_unserialize() over my_unserialize() for performance reasons
$data = native_unserialize($cache_data['cache']);
}
}


// Cache locally
$this->cache[$name] = $data;


// Cache locally
$this->cache[$name] = $data;

Zeile 211Zeile 247

/**
* Update cache contents.


/**
* Update cache contents.

	 *

	 *

	 * @param string $name The cache content identifier.
* @param mixed $contents The cache content.
*/

	 * @param string $name The cache content identifier.
* @param mixed $contents The cache content.
*/

Zeile 259Zeile 295
	 function delete($name, $greedy = false)
{
global $db, $mybb, $cache;

	 function delete($name, $greedy = false)
{
global $db, $mybb, $cache;





		// Prepare for database query.
$dbname = $db->escape_string($name);
$where = "title = '{$dbname}'";

		// Prepare for database query.
$dbname = $db->escape_string($name);
$where = "title = '{$dbname}'";

Zeile 269Zeile 305
		{
get_execution_time();


		{
get_execution_time();


			$hit = $this->handler->delete($name);


			$hit = $this->handler->delete($name);


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

if($mybb->debug_mode)

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

if($mybb->debug_mode)

			{

			{

				$this->debug_call('delete:'.$name, $call_time, $hit);
}
}

				$this->debug_call('delete:'.$name, $call_time, $hit);
}
}

Zeile 323Zeile 359
					{
$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 340Zeile 376
					{
$this->debug_call('delete:'.$name, $call_time, $hit);
}

					{
$this->debug_call('delete:'.$name, $call_time, $hit);
}

				}
}

				}
}

		}

// Delete database cache

		}

// Delete database cache

Zeile 372Zeile 408
		else
{
$hit_status = 'MISS';

		else
{
$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 406Zeile 442
		global $db;

if($this->handler instanceof CacheHandlerInterface)

		global $db;

if($this->handler instanceof CacheHandlerInterface)

		{

		{

			$size = $this->handler->size_of($name);
if(!$size)
{

			$size = $this->handler->size_of($name);
if(!$size)
{

Zeile 454Zeile 490
		);

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

		);

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

	}

	}


/**
* Update the attachment type cache.


/**
* Update the attachment type cache.

Zeile 481Zeile 517
	 *
*/
function update_smilies()

	 *
*/
function update_smilies()

	{
global $db;

$smilies = array();

	{
global $db;

$smilies = array();


$query = $db->simple_select("smilies", "*", "", array('order_by' => 'disporder', 'order_dir' => 'ASC'));
while($smilie = $db->fetch_array($query))


$query = $db->simple_select("smilies", "*", "", array('order_by' => 'disporder', 'order_dir' => 'ASC'));
while($smilie = $db->fetch_array($query))

Zeile 512Zeile 548
		}

$this->update("posticons", $icons);

		}

$this->update("posticons", $icons);

	}

/**

	}

/**

	 * Update the badwords cache.
*
*/

	 * Update the badwords cache.
*
*/

Zeile 545Zeile 581

$gs = array();
while($g = $db->fetch_array($query))


$gs = array();
while($g = $db->fetch_array($query))

		{

		{

			$gs[$g['gid']] = $g;
}

			$gs[$g['gid']] = $g;
}





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


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


Zeile 560Zeile 596
	function update_forumpermissions()
{
global $forum_cache, $db;

	function update_forumpermissions()
{
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);
if(!is_array($forum_cache))


// Get our forum list
cache_forums(true);
if(!is_array($forum_cache))

		{

		{

			return false;

			return false;

		}


		}


		reset($forum_cache);
$fcache = array();

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

		reset($forum_cache);
$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)
{
ksort($fcache[$pid]);
}
ksort($fcache);


		}

// Sort children
foreach($fcache as $pid => $value)
{
ksort($fcache[$pid]);
}
ksort($fcache);


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

Zeile 608Zeile 644
	 */
private function build_forum_permissions($permissions=array(), $pid=0)
{

	 */
private function build_forum_permissions($permissions=array(), $pid=0)
{

		$usergroups = array_keys($this->read("usergroups", true));
if($this->forum_permissions_forum_cache[$pid])








		$usergroups = $this->read("usergroups", true);

if($usergroups === false)
{
$usergroups = array();
}

$usergroups = array_keys($usergroups);
if(!empty($this->forum_permissions_forum_cache[$pid]))

		{
foreach($this->forum_permissions_forum_cache[$pid] as $main)
{

		{
foreach($this->forum_permissions_forum_cache[$pid] as $main)
{

Zeile 618Zeile 661
					$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];
}

						if($perms[$gid])

						if(!empty($perms[$gid]))

						{
$perms[$gid]['fid'] = $forum['fid'];
$this->built_forum_permissions[$forum['fid']][$gid] = $perms[$gid];

						{
$perms[$gid]['fid'] = $forum['fid'];
$this->built_forum_permissions[$forum['fid']][$gid] = $perms[$gid];

Zeile 632Zeile 675
				}
}
}

				}
}
}

	}


	}


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

Zeile 651Zeile 694
	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);

$timesearch = TIME_NOW - 86400;

		$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)
{
case 'pgsql':
$group_by = $db->build_fields_string('users', 'u.');
break;
default:
$group_by = 'p.uid';
break;
}

 

$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


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

			GROUP BY u.uid, u.username

			ORDER BY poststoday DESC
");

$most_posts = 0;

			ORDER BY poststoday DESC
");

$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 768Zeile 803
			$this->moderators[$moderator['fid']]['usergroups'][$moderator['id']] = $moderator;
}


			$this->moderators[$moderator['fid']]['usergroups'][$moderator['id']] = $moderator;
}


		if(is_array($this->moderators))

		foreach(array_keys($this->moderators) as $fid)

		{

		{

			foreach(array_keys($this->moderators) as $fid)

			if(isset($this->moderators[$fid]['users']))

			{

			{

				uasort($this->moderators[$fid], 'sort_moderators_by_usernames');

				uasort($this->moderators[$fid]['users'], 'sort_moderators_by_usernames');

			}
}


			}
}


Zeile 858Zeile 893
		while($forum = $db->fetch_array($query))
{
foreach($forum as $key => $val)

		while($forum = $db->fetch_array($query))
{
foreach($forum as $key => $val)

			{

			{

				if(in_array($key, $exclude))
{
unset($forum[$key]);

				if(in_array($key, $exclude))
{
unset($forum[$key]);

Zeile 868Zeile 903
		}

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

		}

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

	}


	}


	/**
* Update usertitles cache.
*

	/**
* Update usertitles cache.
*

Zeile 884Zeile 919
		{
$usertitles[] = $usertitle;
}

		{
$usertitles[] = $usertitle;
}





		$this->update("usertitles", $usertitles);
}


		$this->update("usertitles", $usertitles);
}


Zeile 894Zeile 929
	 */
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 1089Zeile 1124
		$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()
{
global $db;

	function update_birthdays()
{
global $db;





		$birthdays = array();

// Get today, yesterday, and tomorrow's time (for different timezones)

		$birthdays = array();

// Get today, yesterday, and tomorrow's time (for different timezones)

Zeile 1126Zeile 1154

if($bday['birthdayprivacy'] != 'all')
{


if($bday['birthdayprivacy'] != 'all')
{

				++$birthdays[$bday['bday']]['hiddencount'];








				if(isset($birthdays[$bday['bday']]['hiddencount']))
{
++$birthdays[$bday['bday']]['hiddencount'];
}
else
{
$birthdays[$bday['bday']]['hiddencount'] = 1;
}

				continue;
}

// We don't need any excess caleries in the cache
unset($bday['birthdayprivacy']);

				continue;
}

// We don't need any excess caleries in the cache
unset($bday['birthdayprivacy']);

 

if(!isset($birthdays[$bday['bday']]['users']))
{
$birthdays[$bday['bday']]['users'] = array();
}


$birthdays[$bday['bday']]['users'][] = $bday;
}


$birthdays[$bday['bday']]['users'][] = $bday;
}

Zeile 1289Zeile 1329
		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='mostonline'");

		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='mostonline'");

		$this->update("mostonline", unserialize($db->fetch_field($query, "cache")));

		$this->update("mostonline", my_unserialize($db->fetch_field($query, "cache")));

	}

function reload_plugins()

	}

function reload_plugins()

Zeile 1297Zeile 1337
		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='plugins'");

		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='plugins'");

		$this->update("plugins", unserialize($db->fetch_field($query, "cache")));

		$this->update("plugins", my_unserialize($db->fetch_field($query, "cache")));

	}

function reload_last_backup()

	}

function reload_last_backup()

Zeile 1305Zeile 1345
		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='last_backup'");

		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='last_backup'");

		$this->update("last_backup", unserialize($db->fetch_field($query, "cache")));

		$this->update("last_backup", my_unserialize($db->fetch_field($query, "cache")));

	}

function reload_internal_settings()

	}

function reload_internal_settings()

Zeile 1313Zeile 1353
		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='internal_settings'");

		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='internal_settings'");

		$this->update("internal_settings", unserialize($db->fetch_field($query, "cache")));

		$this->update("internal_settings", my_unserialize($db->fetch_field($query, "cache")));

	}

function reload_version_history()

	}

function reload_version_history()

Zeile 1321Zeile 1361
		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='version_history'");

		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='version_history'");

		$this->update("version_history", unserialize($db->fetch_field($query, "cache")));

		$this->update("version_history", my_unserialize($db->fetch_field($query, "cache")));

	}

function reload_modnotes()

	}

function reload_modnotes()

Zeile 1329Zeile 1369
		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='modnotes'");

		global $db;

$query = $db->simple_select("datacache", "title,cache", "title='modnotes'");

		$this->update("modnotes", unserialize($db->fetch_field($query, "cache")));

		$this->update("modnotes", my_unserialize($db->fetch_field($query, "cache")));

	}

function reload_adminnotes()

	}

function reload_adminnotes()

Zeile 1337Zeile 1377
		global $db;

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

		global $db;

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

		$this->update("adminnotes", unserialize($db->fetch_field($query, "cache")));

		$this->update("adminnotes", my_unserialize($db->fetch_field($query, "cache")));

	}
}

	}
}