Vergleich inc/functions_rebuild.php - 1.2.7 - 1.2.14

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 6Zeile 6
 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/eula.html
*

 * $Id$

 * $Id: functions_rebuild.php 3514 2007-11-24 09:02:58Z Tikitiki $

 */

/**

 */

/**

Zeile 16Zeile 16
{
global $db;


{
global $db;


	$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS threads", "visible='1' AND closed NOT LIKE 'moved|%'");
$stats['numthreads'] = $db->fetch_field($query, 'threads');














	$query = $db->simple_select(TABLE_PREFIX."forums", "SUM(threads) AS numthreads");
$stats['numthreads'] = $db->fetch_field($query, 'numthreads');

if(!$stats['numthreads'])
{
$stats['numthreads'] = 0;
}

$query = $db->simple_select(TABLE_PREFIX."forums", "SUM(posts) AS numposts");
$stats['numposts'] = $db->fetch_field($query, 'numposts');

if(!$stats['numposts'])
{
$stats['numposts'] = 0;
}

	

	

	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS posts", "visible='1'");
$stats['numposts'] = $db->fetch_field($query, 'posts');


 
	$query = $db->simple_select(TABLE_PREFIX."users", "COUNT(uid) AS users");
$stats['numusers'] = $db->fetch_field($query, 'users');

	$query = $db->simple_select(TABLE_PREFIX."users", "COUNT(uid) AS users");
$stats['numusers'] = $db->fetch_field($query, 'users');

 
	
if(!$stats['numusers'])
{
$stats['numusers'] = 0;
}


update_stats($stats);


update_stats($stats);

}

}


/**
* Completely rebuild the counters for a particular forum (useful if they become out of sync)


/**
* Completely rebuild the counters for a particular forum (useful if they become out of sync)

Zeile 36Zeile 51
	global $db;

// Fetch the number of threads and replies in this forum (Approved only)

	global $db;

// Fetch the number of threads and replies in this forum (Approved only)

	$query = $db->query("
SELECT COUNT(*) AS threads, SUM(replies) AS replies

	$query = $db->query("
SELECT COUNT(tid) AS threads, SUM(replies) AS replies

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'
");

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='1' AND closed NOT LIKE 'moved|%'
");

Zeile 46Zeile 61

// Fetch the number of threads and replies in this forum (Unapproved only)
$query = $db->query("


// Fetch the number of threads and replies in this forum (Unapproved only)
$query = $db->query("

		SELECT COUNT(*) AS threads

		SELECT COUNT(tid) AS threads, SUM(replies) AS impliedunapproved

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%'

		FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND visible='0' AND closed NOT LIKE 'moved|%'

	");
$count['unapprovedthreads'] = $db->fetch_field($query, "threads");



	");
$count2 = $db->fetch_array($query);
$count['unapprovedthreads'] = $count2['threads'];
$count['unapprovedposts'] = $count2['impliedunapproved'];


$query = $db->query("
SELECT SUM(unapprovedposts) AS posts
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND closed NOT LIKE 'moved|%'
");


$query = $db->query("
SELECT SUM(unapprovedposts) AS posts
FROM ".TABLE_PREFIX."threads
WHERE fid='$fid' AND closed NOT LIKE 'moved|%'
");

	$count['unapprovedposts'] = $db->fetch_field($query, "posts");

	$count['unapprovedposts'] += $db->fetch_field($query, "posts");


update_forum_counters($fid, $count);
}


update_forum_counters($fid, $count);
}





/**
* Completely rebuild the counters for a particular thread (useful if they become out of sync)

/**
* Completely rebuild the counters for a particular thread (useful if they become out of sync)

 
 *
* @param int The thread ID
* @param array Optional thread array so we don't have to query it

 */

 */

function rebuild_thread_counters($tid)

function rebuild_thread_counters($tid, $thread=array())

{
global $db;


{
global $db;


	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS replies", "tid='{$tid}' AND visible='1'");
$count['replies'] = $db->fetch_field($query, "replies") -1;






	if(!$thread['tid'])
{
$thread = get_thread($tid);
}

$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS replies", "tid='{$tid}' AND pid!='{$thread['firstpost']}' AND visible='1'");
$count['replies'] = $db->fetch_field($query, "replies");

	if($count['replies'] < 0)
{
$count['replies'] = 0;
}

// Unapproved posts

	if($count['replies'] < 0)
{
$count['replies'] = 0;
}

// Unapproved posts

	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS totunposts", "tid='{$tid}' AND visible='0'");

	$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(*) AS totunposts", "tid='{$tid}' AND pid!='{$thread['firstpost']}' AND visible='0'");

	$count['unapprovedposts'] = $db->fetch_field($query, "totunposts");

// Attachment count

	$count['unapprovedposts'] = $db->fetch_field($query, "totunposts");

// Attachment count