Vergleich inc/class_datacache.php - 1.6.3 - 1.6.9

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * Website: http://mybb.com
* License: http://mybb.com/about/license
*

 * $Id: class_datacache.php 5380 2011-02-21 12:04:43Z Tomm $

 * $Id$

 */

class datacache

 */

class datacache

Zeile 95Zeile 95
	function read($name, $hard=false)
{
global $db, $mybb;

	function read($name, $hard=false)
{
global $db, $mybb;

		



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

			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 && !is_object($this->handler))
{
return false;
}


		if(is_object($this->handler))
{
$data = $this->handler->fetch($name);

		if(is_object($this->handler))
{
$data = $this->handler->fetch($name);

			



			// No data returned - cache gone bad?
if($data === false)
{

			// No data returned - cache gone bad?
if($data === false)
{

Zeile 113Zeile 119
				$query = $db->simple_select("datacache", "title,cache", "title='".$db->escape_string($name)."'");
$cache_data = $db->fetch_array($query);
$data = @unserialize($cache_data['cache']);

				$query = $db->simple_select("datacache", "title,cache", "title='".$db->escape_string($name)."'");
$cache_data = $db->fetch_array($query);
$data = @unserialize($cache_data['cache']);

				
if($data == null)
{
$data = '';
}









				// Update cache for handler
$this->handler->put($name, $data);
}

				// Update cache for handler
$this->handler->put($name, $data);
}

		}		

		}

		// Else, using internal database cache
else
{
$query = $db->simple_select("datacache", "title,cache", "title='$name'");
$cache_data = $db->fetch_array($query);

		// Else, using internal database cache
else
{
$query = $db->simple_select("datacache", "title,cache", "title='$name'");
$cache_data = $db->fetch_array($query);

 


			if(!$cache_data['title'])
{
$data = false;

			if(!$cache_data['title'])
{
$data = false;

Zeile 277Zeile 279
		}

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

		}

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

	}

/**

	}

/**

	 * Update the posticon cache.
*
*/

	 * Update the posticon cache.
*
*/

Zeile 459Zeile 461
		ksort($fcache);

// Fetch moderators from the database

		ksort($fcache);

// 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 469Zeile 471
		while($moderator = $db->fetch_array($query))
{
$this->moderators[$moderator['fid']]['users'][$moderator['id']] = $moderator;

		while($moderator = $db->fetch_array($query))
{
$this->moderators[$moderator['fid']]['users'][$moderator['id']] = $moderator;

		}

if(!function_exists("sort_moderators_by_usernames"))

		}

if(!function_exists("sort_moderators_by_usernames"))

		{
function sort_moderators_by_usernames($a, $b)
{

		{
function sort_moderators_by_usernames($a, $b)
{

Zeile 493Zeile 495
		}

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

		

		

		$this->build_moderators();

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

		$this->build_moderators();

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

	}


	}


	/**
* Build the moderators array
*

	/**
* Build the moderators array
*

Zeile 549Zeile 551
	 *
*/
function update_forums()

	 *
*/
function update_forums()

	{

	{

		global $db;
$forums = array();


		global $db;
$forums = array();


Zeile 570Zeile 572
		}

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

		}

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

	}

	}

	
/**
* Update usertitles cache.

	
/**
* Update usertitles cache.

Zeile 591Zeile 593

/**
* Update reported posts cache.


/**
* Update reported posts cache.

	 *
*/

	 *
*/

	function update_reportedposts()
{
global $db;

	function update_reportedposts()
{
global $db;

Zeile 613Zeile 615
		);

$this->update("reportedposts", $reports);

		);

$this->update("reportedposts", $reports);

	}


	}



/**
* Update mycode cache.


/**
* Update mycode cache.

Zeile 637Zeile 639
	 *
*/
function update_mailqueue($last_run=0, $lock_time=0)

	 *
*/
function update_mailqueue($last_run=0, $lock_time=0)

	{
global $db;


	{
global $db;


		$query = $db->simple_select("mailqueue", "COUNT(*) AS queue_size");
$queue_size = $db->fetch_field($query, "queue_size");


		$query = $db->simple_select("mailqueue", "COUNT(*) AS queue_size");
$queue_size = $db->fetch_field($query, "queue_size");


Zeile 662Zeile 664
	 * Update update_check cache (dummy function used by upgrade/install scripts)
*/
function update_update_check()

	 * Update update_check cache (dummy function used by upgrade/install scripts)
*/
function update_update_check()

	{

	{

		$update_cache = array(
"dateline" => TIME_NOW
);

		$update_cache = array(
"dateline" => TIME_NOW
);

Zeile 708Zeile 710
			$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
*/
function update_bannedemails()
{
global $db;

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

$this->update("bannedemails", $banned_emails);

	}

/**

	}

/**

Zeile 726Zeile 746
	}

function update_most_replied_threads()

	}

function update_most_replied_threads()

	{
global $db, $mybb;

$threads = array();

	{
global $db, $mybb;

$threads = array();

		
$query = $db->simple_select("threads", "tid, subject, replies, fid", "visible='1'", array('order_by' => 'replies', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
while($thread = $db->fetch_array($query))

		
$query = $db->simple_select("threads", "tid, subject, replies, fid", "visible='1'", array('order_by' => 'replies', 'order_dir' => 'DESC', 'limit_start' => 0, 'limit' => $mybb->settings['statslimit']));
while($thread = $db->fetch_array($query))

Zeile 741Zeile 761
	}

function update_most_viewed_threads()

	}

function update_most_viewed_threads()

	{

	{

		global $db, $mybb;

$threads = array();

		global $db, $mybb;

$threads = array();

Zeile 763Zeile 783
		
$query = $db->simple_select("banned");
while($ban = $db->fetch_array($query))

		
$query = $db->simple_select("banned");
while($ban = $db->fetch_array($query))

		{

		{

			$bans[$ban['uid']] = $ban;
}


			$bans[$ban['uid']] = $ban;
}


Zeile 806Zeile 826
	}

function update_groupleaders()

	}

function update_groupleaders()

	{
global $db;

$groupleaders = array();

	{
global $db;

$groupleaders = array();

		
$query = $db->simple_select("groupleaders");
while($groupleader = $db->fetch_array($query))

		
$query = $db->simple_select("groupleaders");
while($groupleader = $db->fetch_array($query))

		{

		{

			$groupleaders[$groupleader['uid']][] = $groupleader;

			$groupleaders[$groupleader['uid']][] = $groupleader;

		}

		}

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

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

	

































































function update_threadprefixes()
{
global $db;

$prefixes = array();
$query = $db->simple_select("threadprefixes", "*", "", array("order_by" => "pid"));

while($prefix = $db->fetch_array($query))
{
$prefixes[$prefix['pid']] = $prefix;
}

$this->update("threadprefixes", $prefixes);
}

function update_forumsdisplay()
{
global $db;

$fd_statistics = array();

$time = TIME_NOW; // Look for announcements that don't end, or that are ending some time in the future
$query = $db->simple_select("announcements", "fid", "enddate = '0' OR enddate > '{$time}'", array("order_by" => "aid"));

if($db->num_rows($query))
{
while($forum = $db->fetch_array($query))
{
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", "type = 't'", array("order_by" => "tid"));

if($db->num_rows($query))
{
unset($forum);
while($tool = $db->fetch_array($query))
{
$forums = explode(",", $tool['forums']);

foreach($forums as $forum)
{
if(!$forum)
{
$forum = -1;
}

if(!isset($fd_statistics[$forum]['modtools']))
{
$fd_statistics[$forum]['modtools'] = 1;
}
}
}
}

$this->update("forumsdisplay", $fd_statistics);
}


	/* Other, extra functions for reloading caches if we just changed to another cache extension (i.e. from db -> xcache) */
function reload_mostonline()
{

	/* Other, extra functions for reloading caches if we just changed to another cache extension (i.e. from db -> xcache) */
function reload_mostonline()
{