Vergleich inc/class_datacache.php - 1.8.14 - 1.8.24

  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
* github.com/frostschutz

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

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 363Zeile 373
		if($plugins->current_hook)
{
$debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";

		if($plugins->current_hook)
{
$debug_extra = "<div style=\"float_right\">(Plugin Hook: {$plugins->current_hook})</div>";

		}


		}


		if($hit)
{
$hit_status = 'HIT';

		if($hit)
{
$hit_status = 'HIT';

Zeile 402Zeile 412
	 * @return integer the size of the cache
*/
function size_of($name='')

	 * @return integer the size of the cache
*/
function size_of($name='')

	{

	{

		global $db;

if($this->handler instanceof CacheHandlerInterface)

		global $db;

if($this->handler instanceof CacheHandlerInterface)

Zeile 414Zeile 424
				{
$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"));

				}

				}

				else
{
return $db->fetch_size("datacache");
}

				else
{
return $db->fetch_size("datacache");
}

			}
else
{

			}
else
{

				return $size;

				return $size;

			}

			}

		}
// Using MySQL as cache
else

		}
// Using MySQL as cache
else

Zeile 432Zeile 442
			{
$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"));

			}

			}

			else
{
return $db->fetch_size("datacache");
}

			else
{
return $db->fetch_size("datacache");
}

		}
}

/**

		}
}

/**

	 * Update the MyBB version in the cache.
*
*/

	 * Update the MyBB version in the cache.
*
*/

Zeile 452Zeile 462
			"version" => $mybb->version,
"version_code" => $mybb->version_code
);

			"version" => $mybb->version,
"version_code" => $mybb->version_code
);





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

/**
* Update the attachment type cache.

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

/**
* Update the attachment type cache.

	 *
*/

	 *
*/

	function update_attachtypes()
{
global $db;

	function update_attachtypes()
{
global $db;

Zeile 478Zeile 488

/**
* Update the smilies cache.


/**
* Update the smilies cache.

	 *

	 *

	 */
function update_smilies()
{
global $db;

	 */
function update_smilies()
{
global $db;





		$smilies = array();

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

		$smilies = array();

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

Zeile 497Zeile 507

/**
* Update the posticon cache.


/**
* Update the posticon cache.

	 *

	 *

	 */
function update_posticons()
{
global $db;

	 */
function update_posticons()
{
global $db;





		$icons = array();

$query = $db->simple_select("icons", "iid, name, path");

		$icons = array();

$query = $db->simple_select("icons", "iid, name, path");

Zeile 516Zeile 526

/**
* Update the badwords cache.


/**
* Update the badwords cache.

	 *

	 *

	 */
function update_badwords()
{

	 */
function update_badwords()
{

Zeile 554Zeile 564

/**
* Update the forum permissions cache.


/**
* Update the forum permissions cache.

	 *

	 *

	 * @return bool When failed, returns false.
*/
function update_forumpermissions()
{
global $forum_cache, $db;

	 * @return bool When failed, returns false.
*/
function update_forumpermissions()
{
global $forum_cache, $db;





		$this->built_forum_permissions = array(0);

// Get our forum list

		$this->built_forum_permissions = array(0);

// Get our forum list

Zeile 568Zeile 578
		if(!is_array($forum_cache))
{
return false;

		if(!is_array($forum_cache))
{
return false;

		}

		}


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


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

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

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

		{

		{

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

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

Zeile 666Zeile 676
				break;
}


				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.' AND p.visible=1
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;
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 1020Zeile 1039
	 * 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'");


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

		while($banned_email = $db->fetch_array($query))
{
$banned_emails[$banned_email['fid']] = $banned_email;

Zeile 1038Zeile 1057
	 * Updates the search engine spiders cache
*/
function update_spiders()

	 * Updates the search engine spiders cache
*/
function update_spiders()

	{

	{

		global $db;

$spiders = array();

		global $db;

$spiders = array();

Zeile 1075Zeile 1094
		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 1119Zeile 1131
			{
++$birthdays[$bday['bday']]['hiddencount'];
continue;

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

			}


			}


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


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


Zeile 1176Zeile 1188
				if(!isset($fd_statistics[$forum['fid']]['announcements']))
{
$fd_statistics[$forum['fid']]['announcements'] = 1;

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


		// Do we have any mod tools to use in our forums?
$query = $db->simple_select("modtools", "forums, tid", '', array("order_by" => "tid"));


Zeile 1236Zeile 1248

$content_types = array('post', 'profile', 'reputation');
if(!$no_plugins)


$content_types = array('post', 'profile', 'reputation');
if(!$no_plugins)

		{

		{

			global $plugins;
$content_types = $plugins->run_hooks("report_content_types", $content_types);
}

			global $plugins;
$content_types = $plugins->run_hooks("report_content_types", $content_types);
}





		$reasons = array();

$query = $db->simple_select("reportreasons", "*", "", array('order_by' => 'disporder'));

		$reasons = array();

$query = $db->simple_select("reportreasons", "*", "", array('order_by' => 'disporder'));

Zeile 1249Zeile 1261
			if($reason['appliesto'] == 'all')
{
foreach($content_types as $content)

			if($reason['appliesto'] == 'all')
{
foreach($content_types as $content)

				{
$reasons[$content][] = array(
'rid' => $reason['rid'],
'title' => $reason['title'],
'extra' => $reason['extra'],
);
}

				{
$reasons[$content][] = array(
'rid' => $reason['rid'],
'title' => $reason['title'],
'extra' => $reason['extra'],
);
}

			}
elseif($reason['appliesto'] != '')
{

			}
elseif($reason['appliesto'] != '')
{

Zeile 1292Zeile 1304
	}

function reload_last_backup()

	}

function reload_last_backup()

	{
global $db;

	{
global $db;


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


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

Zeile 1329Zeile 1341

$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&amp;fetch_new=-2');

 
	}
}

	}
}