Vergleich inc/class_datacache.php - 1.8.19 - 1.8.28

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


				break;
}


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

				$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)
{
$this->debug_call('set:'.$name, $call_time, $hit);

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

Zeile 186Zeile 196
			$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;
}

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),
"cache" => $dbcontents
);
$db->replace_query("datacache", $replace_array, "", false);

		$replace_array = array(
"title" => $db->escape_string($name),
"cache" => $dbcontents
);
$db->replace_query("datacache", $replace_array, "", false);





		// Do we have a cache handler we're using?

		// Do we have a cache handler we're using?

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

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

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

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

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

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


if($mybb->debug_mode)
{


if($mybb->debug_mode)
{

Zeile 287Zeile 297
			$name .= '_';
$names = array();
$keys = array_keys($cache->cache);

			$name .= '_';
$names = array();
$keys = array_keys($cache->cache);





			foreach($keys as $key)
{
if(strpos($key, $name) === 0)

			foreach($keys as $key)
{
if(strpos($key, $name) === 0)

Zeile 303Zeile 313
					'_' => '=_'
)
);

					'_' => '=_'
)
);





			$where .= " OR title LIKE '{$ldbname}=_%' ESCAPE '='";

if($this->handler instanceof CacheHandlerInterface)

			$where .= " OR title LIKE '{$ldbname}=_%' ESCAPE '='";

if($this->handler instanceof CacheHandlerInterface)

Zeile 335Zeile 345
					$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)
{
$this->debug_call('delete:'.$name, $call_time, $hit);

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

Zeile 343Zeile 353
				}
}
}

				}
}
}





		// Delete database cache
$db->delete_query("datacache", $where);
}

/**
* Debug a cache call to a non-database cache handler

		// Delete database cache
$db->delete_query("datacache", $where);
}

/**
* Debug a cache call to a non-database cache handler

	 *

	 *

	 * @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

Zeile 561Zeile 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 605Zeile 615
	 * @access private
* @param array $permissions An optional permissions array.
* @param int $pid An optional permission id.

	 * @access private
* @param array $permissions An optional permissions array.
* @param int $pid An optional permission id.

	 */

	 */

	private function build_forum_permissions($permissions=array(), $pid=0)
{
$usergroups = array_keys($this->read("usergroups", true));

	private function build_forum_permissions($permissions=array(), $pid=0)
{
$usergroups = array_keys($this->read("usergroups", true));

		if($this->forum_permissions_forum_cache[$pid])

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

						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 676Zeile 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 735Zeile 746
		$this->moderators = array();

// Fetch moderators from the database

		$this->moderators = array();

// Fetch moderators from the database

		$query = $db->query("

		$query = $db->query("

			SELECT m.*, u.username, u.usergroup, u.displaygroup
FROM ".TABLE_PREFIX."moderators m
LEFT JOIN ".TABLE_PREFIX."users u ON (m.id=u.uid)

			SELECT m.*, u.username, u.usergroup, u.displaygroup
FROM ".TABLE_PREFIX."moderators m
LEFT JOIN ".TABLE_PREFIX."users u ON (m.id=u.uid)

Zeile 766Zeile 777
		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))

		}

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 785Zeile 796

/**
* Update the users awaiting activation cache.


/**
* Update the users awaiting activation cache.

	 *
*/

	 *
*/

	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 798Zeile 809
			'users'	=> $awaitingusers,
'time' => TIME_NOW
);

			'users'	=> $awaitingusers,
'time' => TIME_NOW
);





		$this->update('awaitingactivation', $data);

		$this->update('awaitingactivation', $data);

	}

/**

	}

/**

	 * Build the moderators array
*
* @access private

	 * Build the moderators array
*
* @access private

Zeile 850Zeile 861
		global $db;

$forums = array();

		global $db;

$forums = array();





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


Zeile 865Zeile 876
				}
}
$forums[$forum['fid']] = $forum;

				}
}
$forums[$forum['fid']] = $forum;

		}


		}


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

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

	}

/**

	}

/**

	 * Update usertitles cache.
*
*/

	 * Update usertitles cache.
*
*/

Zeile 887Zeile 898

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


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





	/**
* Update reported content cache.
*
*/
function update_reportedcontent()
{

	/**
* Update reported content cache.
*
*/
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 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()
{
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 1130

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