Vergleich inc/class_datacache.php - 1.8.15 - 1.8.24

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 94Zeile 94
				require_once MYBB_ROOT."/inc/cachehandlers/apc.php";
$this->handler = new apcCacheHandler();
break;

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


if($this->handler instanceof CacheHandlerInterface)
{

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

			}
}
}

			}
}
}


/**
* Read cache from files or db.


/**
* Read cache from files or db.

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 346Zeile 356

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


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

	}

	}


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


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

Zeile 384Zeile 394
</tr>
<tr style=\"background-color: #fefefe;\">
<td><span style=\"font-family: Courier; font-size: 14px;\">({$mybb->config['cache_store']}) [{$hit_status}] ".htmlspecialchars_uni($cache_key)."</span></td>

</tr>
<tr style=\"background-color: #fefefe;\">
<td><span style=\"font-family: Courier; font-size: 14px;\">({$mybb->config['cache_store']}) [{$hit_status}] ".htmlspecialchars_uni($cache_key)."</span></td>

</tr>

</tr>

<tr>
<td bgcolor=\"#ffffff\">Call Time: ".format_time_duration($qtime)."</td>
</tr>
</table>
<br />\n";

<tr>
<td bgcolor=\"#ffffff\">Call Time: ".format_time_duration($qtime)."</td>
</tr>
</table>
<br />\n";





		$this->calllist[$this->call_count]['key'] = $string;
$this->calllist[$this->call_count]['time'] = $qtime;
}

		$this->calllist[$this->call_count]['key'] = $string;
$this->calllist[$this->call_count]['time'] = $qtime;
}

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;

	{
global $db;


if($this->handler instanceof CacheHandlerInterface)
{


if($this->handler instanceof CacheHandlerInterface)
{

Zeile 672Zeile 682
			LEFT JOIN {$db->table_prefix}users u ON (p.uid=u.uid)
WHERE p.dateline > {$timesearch} AND p.visible=1
GROUP BY {$group_by}

			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 NULL DESC

			ORDER BY poststoday DESC

		");

$most_posts = 0;

		");

$most_posts = 0;

Zeile 712Zeile 722
		// 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->moderators_forum_cache[$forum['pid']][$forum['disporder']][$forum['fid']] = $forum;

			$this->moderators_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);





		$this->moderators = array();

// Fetch moderators from the database

		$this->moderators = array();

// Fetch moderators from the database

Zeile 743Zeile 753
			ORDER BY u.username
");
while($moderator = $db->fetch_array($query))

			ORDER BY u.username
");
while($moderator = $db->fetch_array($query))

		{

		{

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

if(!function_exists("sort_moderators_by_usernames"))
{
function sort_moderators_by_usernames($a, $b)

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

if(!function_exists("sort_moderators_by_usernames"))
{
function sort_moderators_by_usernames($a, $b)

			{

			{

				return strcasecmp($a['username'], $b['username']);
}

				return strcasecmp($a['username'], $b['username']);
}

		}

		}


//Fetch moderating usergroups from the database
$query = $db->query("


//Fetch moderating usergroups from the database
$query = $db->query("

Zeile 769Zeile 779
		}

if(is_array($this->moderators))

		}

if(is_array($this->moderators))

		{

		{

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

Zeile 778Zeile 788

$this->build_moderators();



$this->build_moderators();


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


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


		return true;
}


		return true;
}


Zeile 788Zeile 798
	 *
*/
function update_awaitingactivation()

	 *
*/
function update_awaitingactivation()

	{

	{

		global $db;

$query = $db->simple_select('users', 'COUNT(uid) AS awaitingusers', 'usergroup=\'5\'');

		global $db;

$query = $db->simple_select('users', 'COUNT(uid) AS awaitingusers', 'usergroup=\'5\'');

Zeile 826Zeile 836
					if(isset($this->moderators[$forum['fid']]))
{
if(is_array($forum_mods) && count($forum_mods))

					if(isset($this->moderators[$forum['fid']]))
{
if(is_array($forum_mods) && count($forum_mods))

						{

						{

							$forum_mods = array_merge($forum_mods, $this->moderators[$forum['fid']]);
}
else

							$forum_mods = array_merge($forum_mods, $this->moderators[$forum['fid']]);
}
else

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

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

		}


		}


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


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


Zeile 1089Zeile 1099
		$this->update("most_viewed_threads", $threads);
}


		$this->update("most_viewed_threads", $threads);
}


 
	/**
* @deprecated
*/

	function update_banned()

	function update_banned()

 
	{
// "banned" cache removed
}

function update_birthdays()

	{
global $db;


	{
global $db;


		$bans = array();

$query = $db->simple_select("banned");
while($ban = $db->fetch_array($query))
{
$bans[$ban['uid']] = $ban;
}

$this->update("banned", $bans);
}

function update_birthdays()
{
global $db;

$birthdays = array();

		$birthdays = array();

















// Get today, yesterday, and tomorrow's time (for different timezones)
$bdaytime = TIME_NOW;


// Get today, yesterday, and tomorrow's time (for different timezones)
$bdaytime = TIME_NOW;

Zeile 1140Zeile 1143
	}

function update_groupleaders()

	}

function update_groupleaders()

	{

	{

		global $db;

$groupleaders = array();

		global $db;

$groupleaders = array();

Zeile 1162Zeile 1165
		$query = $db->simple_select("threadprefixes", "*", "", array('order_by' => 'prefix', 'order_dir' => 'ASC'));

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

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

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

		{

		{

			$prefixes[$prefix['pid']] = $prefix;
}


			$prefixes[$prefix['pid']] = $prefix;
}


Zeile 1183Zeile 1186
			while($forum = $db->fetch_array($query))
{
if(!isset($fd_statistics[$forum['fid']]['announcements']))

			while($forum = $db->fetch_array($query))
{
if(!isset($fd_statistics[$forum['fid']]['announcements']))

				{

				{

					$fd_statistics[$forum['fid']]['announcements'] = 1;
}
}

					$fd_statistics[$forum['fid']]['announcements'] = 1;
}
}

Zeile 1222Zeile 1225
	 *
*/
function update_profilefields()

	 *
*/
function update_profilefields()

	{
global $db;


	{
global $db;


		$fields = array();
$query = $db->simple_select("profilefields", "*", "", array('order_by' => 'disporder'));
while($field = $db->fetch_array($query))

		$fields = array();
$query = $db->simple_select("profilefields", "*", "", array('order_by' => 'disporder'));
while($field = $db->fetch_array($query))

Zeile 1240Zeile 1243
	 *
*/
function update_reportreasons($no_plugins = false)

	 *
*/
function update_reportreasons($no_plugins = false)

	{
global $db;


	{
global $db;


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

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

Zeile 1258Zeile 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'],

				{
$reasons[$content][] = array(
'rid' => $reason['rid'],

						'title' => $reason['title'],
'extra' => $reason['extra'],
);

						'title' => $reason['title'],
'extra' => $reason['extra'],
);

Zeile 1298Zeile 1301

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


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

	}


	}


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

	}


	}


	function reload_internal_settings()

	function reload_internal_settings()

	{

	{

		global $db;

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

		global $db;

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

Zeile 1317Zeile 1320
	}

function reload_version_history()

	}

function reload_version_history()

	{
global $db;

	{
global $db;


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

	function reload_modnotes()

	{
global $db;

	{
global $db;


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


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

	}

	}


function reload_adminnotes()


function reload_adminnotes()

	{

	{

		global $db;

		global $db;





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

 
	}
}

	}
}