Vergleich inc/class_moderation.php - 1.2.2 - 1.2.5

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

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

 * $Id: class_moderation.php 2385 2006-11-06 23:40:55Z Tikitiki $

 * $Id: class_moderation.php 2734 2007-02-08 22:21:16Z CraKteR $

 */

class Moderation

 */

class Moderation

Zeile 158Zeile 158
		$num_unapproved_posts = 0;
while($post = $db->fetch_array($query))
{

		$num_unapproved_posts = 0;
while($post = $db->fetch_array($query))
{

			// Count the post counts for each user to be subtracted
if($userposts[$post['uid']])
{
$userposts[$post['uid']]--;
}
else
{
$userposts[$post['uid']] = -1;
}

 
			$pids .= $post['pid'].",";
$usepostcounts = $post['usepostcounts'];

			$pids .= $post['pid'].",";
$usepostcounts = $post['usepostcounts'];

 
			

			// Remove attachments
remove_attachments($post['pid']);

			// Remove attachments
remove_attachments($post['pid']);

	

			

			// If the post is unapproved, count it!
if($post['visible'] == 0)
{

			// If the post is unapproved, count it!
if($post['visible'] == 0)
{

				$num_unapproved_posts++;












				$num_unapproved_posts++;
continue;
}

// Count the post counts for each user to be subtracted
if($userposts[$post['uid']])
{
$userposts[$post['uid']]--;
}
else
{
$userposts[$post['uid']] = -1;

			}
}
// Remove post count from users

			}
}
// Remove post count from users

Zeile 199Zeile 202
		// Get thread info
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='$tid'");
$thread = $db->fetch_array($query);

		// Get thread info
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='$tid'");
$thread = $db->fetch_array($query);





		// Delete threads, redirects, favorites, polls, and poll votes
$db->delete_query(TABLE_PREFIX."threads", "tid='$tid'");
$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid'");

		// Delete threads, redirects, favorites, polls, and poll votes
$db->delete_query(TABLE_PREFIX."threads", "tid='$tid'");
$db->delete_query(TABLE_PREFIX."threads", "closed='moved|$tid'");

Zeile 209Zeile 212
		$cache->updatestats();
update_forum_count($thread['fid']);
$plugins->run_hooks("delete_thread", $tid);

		$cache->updatestats();
update_forum_count($thread['fid']);
$plugins->run_hooks("delete_thread", $tid);


return true;


return true;

	}

/**

	}

/**

Zeile 220Zeile 223
	 * @return boolean true
*/
function delete_poll($pid)

	 * @return boolean true
*/
function delete_poll($pid)

	{

	{

		global $db;

$db->delete_query(TABLE_PREFIX."polls", "pid='$pid'");

		global $db;

$db->delete_query(TABLE_PREFIX."polls", "pid='$pid'");

Zeile 241Zeile 244
	 * @return boolean true
*/
function approve_threads($tids, $fid)

	 * @return boolean true
*/
function approve_threads($tids, $fid)

	{
global $db, $cache;

if(!is_array($tids))
{
$tids = array($tids);
}
$tid_list = implode(",", $tids);




















	{
global $db, $cache;

if(!is_array($tids))
{
$tids = array($tids);
}
$tid_list = implode(",", $tids);

foreach($tids as $tid)
{
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid' AND p.visible = '0'
");
while($post = $db->fetch_array($query))
{
// If post counts enabled in this forum and the post hasn't already been approved, remove 1
if($post['usepostcounts'] != "no")
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='".$post['uid']."'");
}
}
update_thread_count($tid);
}


$approve = array(
"visible" => 1,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list)", 1);


$approve = array(
"visible" => 1,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list)", 1);

		
foreach($tids as $tid)
{
update_thread_count($tid);
}

 
		
// Update stats
$cache->updatestats();

		
// Update stats
$cache->updatestats();

Zeile 284Zeile 301
			$tids = array($tids);
}
$tid_list = implode(",", $tids);

			$tids = array($tids);
}
$tid_list = implode(",", $tids);

 
		
foreach($tids as $tid)
{
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid' AND p.visible = '1'
");
while($post = $db->fetch_array($query))
{
// If post counts enabled in this forum and the post hasn't already been unapproved, remove 1
if($post['usepostcounts'] != "no")
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='".$post['uid']."'");
}
}
update_thread_count($tid);
}


$approve = array(
"visible" => 0,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list) AND replyto='0'", 1);


$approve = array(
"visible" => 0,
);
$db->update_query(TABLE_PREFIX."threads", $approve, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $approve, "tid IN ($tid_list) AND replyto='0'", 1);


foreach($tids as $tid)
{
update_thread_count($tid);
}

 
		
// Update stats
$cache->updatestats();

		
// Update stats
$cache->updatestats();

Zeile 321Zeile 352
			WHERE p.pid='$pid'
");
$post = $db->fetch_array($query);

			WHERE p.pid='$pid'
");
$post = $db->fetch_array($query);

		// If post counts enabled in this forum, remove 1
if($post['usepostcounts'] != "no")

		// If post counts enabled in this forum and it hasn't already been unapproved, remove 1
if($post['usepostcounts'] != "no" && $post['visible'] != 0)

		{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='".$post['uid']."'");
}

		{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='".$post['uid']."'");
}

Zeile 387Zeile 418
					$message .= "[hr]{$post['message']}";
}


					$message .= "[hr]{$post['message']}";
}


				if($post['usepostcounts'] != "no")

				if($post['usepostcounts'] != "no" && $post['visible'] == '1')

				{
// Update post count of the user of the merged posts
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='{$post['uid']}'");

				{
// Update post count of the user of the merged posts
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='{$post['uid']}'");

Zeile 396Zeile 427
		}

$fid = $post['fid'];

		}

$fid = $post['fid'];





		// Update the message
$mergepost = array(
"message" => $db->escape_string($message),

		// Update the message
$mergepost = array(
"message" => $db->escape_string($message),

Zeile 411Zeile 442
		$db->update_query(TABLE_PREFIX."attachments", $mergepost2, "pid IN($pidin)");

// Update stats

		$db->update_query(TABLE_PREFIX."attachments", $mergepost2, "pid IN($pidin)");

// Update stats

		update_thread_count($tid);

		update_thread_count($tid);

		update_forum_count($fid);

return true;

		update_forum_count($fid);

return true;

Zeile 448Zeile 479
				$db->update_query(TABLE_PREFIX."posts", $changefid, "tid='$tid'");
$threadarray = array(
"fid" => $thread['fid'],

				$db->update_query(TABLE_PREFIX."posts", $changefid, "tid='$tid'");
$threadarray = array(
"fid" => $thread['fid'],

					"subject" => $db->escape_string($thread['subject']),
"icon" => $thread['icon'],
"uid" => $thread['uid'],
"username" => $db->escape_string($thread['username']),

					"subject" => $db->escape_string($thread['subject']),
"icon" => $thread['icon'],
"uid" => $thread['uid'],
"username" => $db->escape_string($thread['username']),

					"dateline" => $thread['dateline'],
"lastpost" => $thread['lastpost'],
"lastposteruid" => $thread['lastposteruid'],

					"dateline" => $thread['dateline'],
"lastpost" => $thread['lastpost'],
"lastposteruid" => $thread['lastposteruid'],

Zeile 459Zeile 490
					"views" => 0,
"replies" => 0,
"closed" => "moved|$tid",

					"views" => 0,
"replies" => 0,
"closed" => "moved|$tid",

					"sticky" => $thread['sticky'],
"visible" => $thread['visible'],
"notes" => ''

					"sticky" => $thread['sticky'],
"visible" => $thread['visible'],
"notes" => ''

				);
$db->insert_query(TABLE_PREFIX."threads", $threadarray);
if($redirect_expire)

				);
$db->insert_query(TABLE_PREFIX."threads", $threadarray);
if($redirect_expire)

Zeile 471Zeile 502
				}
break;
case "copy":// copy thread

				}
break;
case "copy":// copy thread

				// we need to add code to copy attachments(?), polls, etc etc here

				

				$threadarray = array(
"fid" => $new_fid,
"subject" => $db->escape_string($thread['subject']),

				$threadarray = array(
"fid" => $new_fid,
"subject" => $db->escape_string($thread['subject']),

Zeile 490Zeile 521
					"unapprovedposts" => $thread['unapprovedposts'],
"notes" => ''
);

					"unapprovedposts" => $thread['unapprovedposts'],
"notes" => ''
);

 
				

				$plugins->run_hooks("moderation_do_move_copy");
$db->insert_query(TABLE_PREFIX."threads", $threadarray);
$newtid = $db->insert_id();

				$plugins->run_hooks("moderation_do_move_copy");
$db->insert_query(TABLE_PREFIX."threads", $threadarray);
$newtid = $db->insert_id();

				$query = $db->simple_select(TABLE_PREFIX."posts", "*", "tid='$tid'");
$postsql = '';



































				
if($thread['poll'] != 0)
{
$query = $db->simple_select(TABLE_PREFIX."polls", "*", "tid = '{$thread['tid']}'");
$poll = $db->fetch_array($query);

$poll_array = array(
'tid' => $newtid,
'question' => $db->escape_string($poll['question']),
'dateline' => $poll['dateline'],
'options' => $db->escape_string($poll['options']),
'votes' => $poll['votes'],
'numoptions' => $poll['numoptions'],
'numvotes' => $poll['numvotes'],
'timeout' => $poll['timeout'],
'closed' => $poll['closed'],
'multiple' => $poll['multiple'],
'public' => $poll['public']
);
$db->insert_query(TABLE_PREFIX."polls", $poll_array);
$new_pid = $db->insert_id();
}

$query = $db->simple_select(TABLE_PREFIX."pollvotes", "*", "tid = '{$thread['tid']}'");
while($pollvote = $db->fetch_array($query))
{
$pollvote_array = array(
'pid' => $new_pid,
'uid' => $pollvote['uid'],
'voteoption' => $pollvote['voteoption'],
'dateline' => $pollvote['dateline'],
);
$db->insert_query(TABLE_PREFIX."pollvotes", $pollvote_array);
}

$query = $db->simple_select(TABLE_PREFIX."posts", "*", "tid = '{$thread['tid']}'");

				while($post = $db->fetch_array($query))
{

				while($post = $db->fetch_array($query))
{

					if($postssql != '')






















					$post_array = array(
'tid' => $newtid,
'fid' => $new_fid,
'subject' => $db->escape_string($post['subject']),
'icon' => $post['icon'],
'uid' => $post['uid'],
'username' => $db->escape_string($post['username']),
'dateline' => $post['dateline'],
'message' => $db->escape_string($post['message']),
'ipaddress' => $post['ipaddress'],
'includesig' => $post['includesig'],
'smilieoff' => $post['smilieoff'],
'edituid' => $post['edituid'],
'edittime' => $post['edittime'],
'visible' => $post['visible']
);
$db->insert_query(TABLE_PREFIX."posts", $post_array);
$pid = $db->insert_id();

// Insert attachments for this post
$query2 = $db->simple_select(TABLE_PREFIX."attachments", "*", "pid = '{$post['pid']}'");
while($attachment = $db->fetch_array($query2))

					{

					{

						$postssql .= ", ";













						$attachment_array = array(
'pid' => $pid,
'posthash' => $db->escape_string($attachment['posthash']),
'uid' => $attachment['uid'],
'filename' => $db->escape_string($attachment['filename']),
'filetype' => $attachment['filetype'],
'filesize' => $attachment['filesize'],
'attachname' => $attachment['attachname'],
'downloads' => $attachment['downloads'],
'visible' => $attachment['visible'],
'thumbnail' => $attachment['thumbnail']
);
$db->insert_query(TABLE_PREFIX."attachments", $attachment_array);

					}

					}

					$post['message'] = $db->escape_string($post['message']);
$postssql .= "('$newtid','$new_fid','{$post['subject']}','{$post['icon']}','{$post['uid']}','{$post['username']}','{$post['dateline']}','{$post['message']}','{$post['ipaddress']}','{$post['includesig']}','{$post['smilieoff']}','{$post['edituid']}','{$post['edittime']}','{$post['visible']}')";

 
				}

				}

				$db->query("INSERT INTO ".TABLE_PREFIX."posts (tid,fid,subject,icon,uid,username,dateline,message,ipaddress,includesig,smilieoff,edituid,edittime,visible) VALUES $postssql");


				


				update_first_post($newtid);
update_thread_count($newtid);


				update_first_post($newtid);
update_thread_count($newtid);


Zeile 535Zeile 631
		while($posters = $db->fetch_array($query))
{
if($method == "copy" && $newforum['usepostcounts'] != "no")

		while($posters = $db->fetch_array($query))
{
if($method == "copy" && $newforum['usepostcounts'] != "no")

			{
$pcount = "+{$posters['posts']}";
}

			{
$pcount = "+{$posters['posts']}";
}

			elseif($method != "copy" && ($newforum['usepostcounts'] != "no" && $forum['usepostcounts'] == "no"))

			elseif($method != "copy" && ($newforum['usepostcounts'] != "no" && $forum['usepostcounts'] == "no"))

			{

			{

				$pcount = "+{$posters['posts']}";

				$pcount = "+{$posters['posts']}";

			}

			}

			elseif($method != "copy" && ($newforum['usepostcounts'] == "no" && $forum['usepostcounts'] != "no"))
{
$pcount = "-{$posters['posts']}";

			elseif($method != "copy" && ($newforum['usepostcounts'] == "no" && $forum['usepostcounts'] != "no"))
{
$pcount = "-{$posters['posts']}";

			}

			}

			if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");

			if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");

Zeile 586Zeile 682
			$mergetid = intval($mergetid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($mergetid)."'");
$mergethread = $db->fetch_array($query);

			$mergetid = intval($mergetid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($mergetid)."'");
$mergethread = $db->fetch_array($query);

		}
if(!isset($thread['tid']) || $thread['tid'] != $tid)

		}
if(!isset($thread['tid']) || $thread['tid'] != $tid)

		{
$tid = intval($tid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($tid)."'");

		{
$tid = intval($tid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($tid)."'");

Zeile 698Zeile 794
		$query = $db->simple_select(TABLE_PREFIX."forums", "usepostcounts", "fid='$moveto'");
$newusepcounts = $db->fetch_field($query, "usepostcounts");
$query = $db->query("

		$query = $db->simple_select(TABLE_PREFIX."forums", "usepostcounts", "fid='$moveto'");
$newusepcounts = $db->fetch_field($query, "usepostcounts");
$query = $db->query("

			SELECT COUNT(p.pid) AS posts, u.uid 

			SELECT COUNT(p.pid) AS posts, u.uid

			FROM ".TABLE_PREFIX."posts p 
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

			FROM ".TABLE_PREFIX."posts p 
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

			WHERE p.tid='$newtid' 

			WHERE p.tid='$newtid' AND p.visible = '1'

			GROUP BY u.uid 
ORDER BY posts DESC
");

			GROUP BY u.uid 
ORDER BY posts DESC
");

Zeile 714Zeile 810
			elseif($oldusepcounts == "no" && $newusepcounts == "yes")
{
$pcount = "+{$posters['posts']}";

			elseif($oldusepcounts == "no" && $newusepcounts == "yes")
{
$pcount = "+{$posters['posts']}";

			}


			}


			if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");
}

			if(!empty($pcount))
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum$pcount WHERE uid='{$posters['uid']}'");
}

		}


		}


		// Update the subject of the first post in the new thread
$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid='$newtid'", array('order_by' => 'dateline', 'limit' => 1));
$newthread = $db->fetch_array($query);
$sqlarray = array(
"subject" => $newsubject,

		// Update the subject of the first post in the new thread
$query = $db->simple_select(TABLE_PREFIX."posts", "pid", "tid='$newtid'", array('order_by' => 'dateline', 'limit' => 1));
$newthread = $db->fetch_array($query);
$sqlarray = array(
"subject" => $newsubject,

			"replyto" => 0
);

			"replyto" => 0
);

		$db->update_query(TABLE_PREFIX."posts", $sqlarray, "pid='{$newthread['pid']}'");

// Update the subject of the first post in the old thread

		$db->update_query(TABLE_PREFIX."posts", $sqlarray, "pid='{$newthread['pid']}'");

// Update the subject of the first post in the old thread

Zeile 757Zeile 853
		}

return $newtid;

		}

return $newtid;

	}

	}


/**
* Move multiple threads to new forum


/**
* Move multiple threads to new forum

Zeile 788Zeile 884
		foreach($update_forums as $fid)
{
update_forum_count($fid);

		foreach($update_forums as $fid)
{
update_forum_count($fid);

		}
return true;

		}
return true;

	}

/**
* Approve multiple posts

	}

/**
* Approve multiple posts

	 *
* @param array PIDs
* @param int Thread ID
* @param int Forum ID
* @return boolean true
*/

	 *
* @param array PIDs
* @param int Thread ID
* @param int Forum ID
* @return boolean true
*/

	function approve_posts($pids, $tid, $fid)
{
global $db, $cache;

$thread = get_thread($tid);

	function approve_posts($pids, $tid, $fid)
{
global $db, $cache;

$thread = get_thread($tid);

 
		
foreach($pids as $pid)
{
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='{$pid}' AND p.visible = '0'
");
while($post = $db->fetch_array($query))
{
// If post counts enabled in this forum and the post hasn't already been approved, add 1
if($post['usepostcounts'] != "no")
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid='".$post['uid']."'");
}
}
}

		
$where = "pid IN (".implode(",", $pids).")";

// Make visible
$approve = array(
"visible" => 1,

		
$where = "pid IN (".implode(",", $pids).")";

// Make visible
$approve = array(
"visible" => 1,

			);

		);

		$db->update_query(TABLE_PREFIX."posts", $approve, $where);

// If this is the first post of the thread, also approve the thread

		$db->update_query(TABLE_PREFIX."posts", $approve, $where);

// If this is the first post of the thread, also approve the thread

Zeile 820Zeile 934
		if($first_post['tid'])
{
$db->update_query(TABLE_PREFIX."threads", $approve, "tid='{$first_post['tid']}'");

		if($first_post['tid'])
{
$db->update_query(TABLE_PREFIX."threads", $approve, "tid='{$first_post['tid']}'");

		}

		}

		update_thread_count($tid);
update_forum_count($fid);
$cache->updatestats();

		update_thread_count($tid);
update_forum_count($fid);
$cache->updatestats();

Zeile 841Zeile 955
		global $db, $cache;

$thread = get_thread($tid);

		global $db, $cache;

$thread = get_thread($tid);

 
		
foreach($pids as $pid)
{
$query = $db->query("
SELECT p.tid, f.usepostcounts, p.uid
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.pid='{$pid}' AND p.visible = '1'
");
while($post = $db->fetch_array($query))
{
// If post counts enabled in this forum and the post hasn't already been unapproved, remove 1
if($post['usepostcounts'] != "no")
{
$db->query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid='".$post['uid']."'");
}
}
}


$where = "pid IN (".implode(",", $pids).")";



$where = "pid IN (".implode(",", $pids).")";