Vergleich inc/class_datacache.php - 1.8.27 - 1.8.35

  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 118Zeile 133
			// Database cache
$query = $db->simple_select("datacache", "title,cache");
while($data = $db->fetch_array($query))

			// Database cache
$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']);
}

		}
}

		}
}





	/**
* Read cache from files or db.
*

	/**
* Read cache from files or db.
*

Zeile 137Zeile 153

// Already have this cache and we're not doing a hard refresh? Return cached copy
if(isset($this->cache[$name]) && $hard == false)


// Already have this cache and we're not doing a hard refresh? Return cached copy
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

			return $this->cache[$name];
}
// If we're not hard refreshing, and this cache doesn't exist, return false

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




// use native_unserialize() over my_unserialize() for performance reasons
$data = native_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 187Zeile 205
				if($mybb->debug_mode)
{
$this->debug_call('set:'.$name, $call_time, $hit);

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

				}
}

				}
}

		}
// Else, using internal database cache
else

		}
// Else, using internal database cache
else

Zeile 196Zeile 214
			$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;
}
else
{

			{
$data = false;
}
else
{

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


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

			}
}


			}
}


Zeile 224Zeile 243
	 *
* @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.

	 */

	 */

	function update($name, $contents)
{
global $db, $mybb;

	function update($name, $contents)
{
global $db, $mybb;

Zeile 257Zeile 276
			}
}
}

			}
}
}





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

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

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

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





		// Greedy?
if($greedy)
{

		// Greedy?
if($greedy)
{

Zeile 323Zeile 342
				while($row = $db->fetch_array($query))
{
$names[$row['title']] = 0;

				while($row = $db->fetch_array($query))
{
$names[$row['title']] = 0;

				}

				}


// ...from the filesystem...
$start = strlen(MYBB_ROOT."cache/");


// ...from the filesystem...
$start = strlen(MYBB_ROOT."cache/");

Zeile 356Zeile 375

// 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 373Zeile 392
		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 407Zeile 426

/**
* Select the size of the cache


/**
* Select the size of the cache

	 *

	 *

	 * @param string $name The name of the cache
* @return integer the size of the cache
*/

	 * @param string $name The name of the cache
* @return integer the size of the cache
*/

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

Zeile 457Zeile 476
	function update_version()
{
global $mybb;

	function update_version()
{
global $mybb;





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

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





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


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


Zeile 471Zeile 490
	 *
*/
function update_attachtypes()

	 *
*/
function update_attachtypes()

	{
global $db;

$types = array();

	{
global $db;

$types = array();


$query = $db->simple_select('attachtypes', '*', 'enabled=1');
while($type = $db->fetch_array($query))


$query = $db->simple_select('attachtypes', '*', 'enabled=1');
while($type = $db->fetch_array($query))

Zeile 488Zeile 507

/**
* Update the smilies cache.


/**
* Update the smilies cache.

	 *
*/

	 *
*/

	function update_smilies()
{
global $db;


	function update_smilies()
{
global $db;


		$smilies = array();


		$smilies = array();


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

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





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

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

	}

/**

	}

/**

	 * Update the posticon cache.
*
*/

	 * Update the posticon cache.
*
*/

Zeile 538Zeile 557
		while($badword = $db->fetch_array($query))
{
$badwords[$badword['bid']] = $badword;

		while($badword = $db->fetch_array($query))
{
$badwords[$badword['bid']] = $badword;

		}

		}


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


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

Zeile 570Zeile 589
	function update_forumpermissions()
{
global $forum_cache, $db;

	function update_forumpermissions()
{
global $forum_cache, $db;





		$this->forum_permissions = $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();


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;

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

		}

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

		}

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

		{
ksort($fcache[$pid]);
}

		{
ksort($fcache[$pid]);
}

Zeile 619Zeile 638
	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 632Zeile 651
						{
$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 666Zeile 685
		$topreferrer = $db->fetch_array($query);

$timesearch = TIME_NOW - 86400;

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


			ORDER BY poststoday DESC
");


Zeile 779Zeile 789
			$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 999Zeile 1009
	 * Updates the tasks cache saving the next run time
*/
function update_tasks()

	 * Updates the tasks cache saving the next run time
*/
function update_tasks()

	{
global $db;


	{
global $db;


		$query = $db->simple_select("tasks", "nextrun", "enabled=1", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1));
$next_task = $db->fetch_array($query);

		$query = $db->simple_select("tasks", "nextrun", "enabled=1", array("order_by" => "nextrun", "order_dir" => "asc", "limit" => 1));
$next_task = $db->fetch_array($query);





		$task_cache = $this->read("tasks");
if(!is_array($task_cache))
{

		$task_cache = $this->read("tasks");
if(!is_array($task_cache))
{

Zeile 1018Zeile 1028
		}

$this->update("tasks", $task_cache);

		}

$this->update("tasks", $task_cache);

	}


	}


	/**
* Updates the banned IPs cache
*/

	/**
* Updates the banned IPs cache
*/

Zeile 1034Zeile 1044
			$banned_ips[$banned_ip['fid']] = $banned_ip;
}
$this->update("bannedips", $banned_ips);

			$banned_ips[$banned_ip['fid']] = $banned_ip;
}
$this->update("bannedips", $banned_ips);

	}


	}


	/**
* Updates the banned emails cache
*/

	/**
* Updates the banned emails cache
*/

Zeile 1068Zeile 1078
			$spiders[$spider['sid']] = $spider;
}
$this->update("spiders", $spiders);

			$spiders[$spider['sid']] = $spider;
}
$this->update("spiders", $spiders);

	}

	}


function update_most_replied_threads()
{


function update_most_replied_threads()
{

Zeile 1130Zeile 1140

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;

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

 

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


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


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

Zeile 1293Zeile 1315
		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 1301Zeile 1323
		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 1309Zeile 1331
		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 1317Zeile 1339
		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 1325Zeile 1347
		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 1333Zeile 1355
		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 1341Zeile 1363
		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")));

	}
}

	}
}