Vergleich inc/class_moderation.php - 1.2.1 - 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 2228 2006-09-17 19:49:10Z 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
if($usepostcounts != "no")
{

		// Remove post count from users
if($usepostcounts != "no")
{

Zeile 215Zeile 218
	
/**
* Delete a poll

	
/**
* Delete a poll

	 *

	 *

	 * @param int Poll id
* @return boolean true
*/

	 * @param int Poll id
* @return boolean true
*/

Zeile 235Zeile 238

/**
* Approve one or more threads


/**
* Approve one or more threads

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

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

	function approve_threads($tids, $fid)

	function approve_threads($tids, $fid)

	{
global $db, $cache;

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

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

	{
global $db, $cache;

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







		
foreach($tids as $tid)
{

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

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


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

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





		return true;
}

/**
* Unapprove one or more threads

		return true;
}

/**
* Unapprove one or more threads

	 *

	 *

	 * @param array Thread IDs
* @param int Forum ID
* @return boolean true

	 * @param array Thread IDs
* @param int Forum ID
* @return boolean true

Zeile 280Zeile 297
		global $db, $cache;

if(!is_array($tids))

		global $db, $cache;

if(!is_array($tids))

		{

		{

			$tids = array($tids);

			$tids = array($tids);

		}

		}

		$tid_list = implode(",", $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']."'");
}
// Delete the post

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

Zeile 344Zeile 375

return true;
}


return true;
}





	/**
* Merge posts within thread
*

	/**
* Merge posts within thread
*

Zeile 359Zeile 390
		$pidin = implode(",", $pids);
$first = 1;
// Get the messages to be merged

		$pidin = implode(",", $pids);
$first = 1;
// Get the messages to be merged

		$query = $db->simple_select(TABLE_PREFIX."posts", "*", "tid='$tid' AND pid IN($pidin)", array('order_by' => 'dateline'));







		$query = $db->query("
SELECT p.pid, p.uid, p.fid, p.tid, p.visible, p.message, f.usepostcounts
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)
WHERE p.tid='$tid' AND p.pid IN($pidin)
ORDER BY dateline ASC
");

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

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

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

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

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






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

			}
}


			}
}


Zeile 450Zeile 492
					"closed" => "moved|$tid",
"sticky" => $thread['sticky'],
"visible" => $thread['visible'],

					"closed" => "moved|$tid",
"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 459Zeile 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 476Zeile 519
					"sticky" => $thread['sticky'],
"visible" => $thread['visible'],
"unapprovedposts" => $thread['unapprovedposts'],

					"sticky" => $thread['sticky'],
"visible" => $thread['visible'],
"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);

$the_thread = $newtid;

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

$the_thread = $newtid;

				break;

				break;

			default:
case "move": // plain move thread
$plugins->run_hooks("moderation_do_move_simple");

			default:
case "move": // plain move thread
$plugins->run_hooks("moderation_do_move_simple");

Zeile 553Zeile 662
		else
{
return $tid;

		else
{
return $tid;

		}

		}

	}

/**

	}

/**

Zeile 573Zeile 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)
{
$tid = intval($tid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);
}

		}
if(!isset($thread['tid']) || $thread['tid'] != $tid)
{
$tid = intval($tid);
$query = $db->simple_select(TABLE_PREFIX."threads", "*", "tid='".intval($tid)."'");
$thread = $db->fetch_array($query);
}

		$pollsql = '';
if($mergethread['poll'])
{

		$pollsql = '';
if($mergethread['poll'])
{

Zeile 665Zeile 774
			"lastposter" => $thread['lastposter'],
"replies" => count($pids)-1,
"visible" => "1",

			"lastposter" => $thread['lastposter'],
"replies" => count($pids)-1,
"visible" => "1",

 
			"notes" => ''

		);
$db->insert_query(TABLE_PREFIX."threads", $query);
$newtid = $db->insert_id();

		);
$db->insert_query(TABLE_PREFIX."threads", $query);
$newtid = $db->insert_id();

Zeile 684Zeile 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
");
while($posters = $db->fetch_array($query))

			GROUP BY u.uid 
ORDER BY posts DESC
");
while($posters = $db->fetch_array($query))

		{

		{

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

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

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

			{
$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']}'");


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


Zeile 735Zeile 845
			update_forum_count($moveto);
}
update_forum_count($thread['fid']);

			update_forum_count($moveto);
}
update_forum_count($thread['fid']);





		// Merge new thread with destination thread if specified
if($destination_tid)
{
$this->merge_threads($newtid, $destination_tid, $subject);
}

		// Merge new thread with destination thread if specified
if($destination_tid)
{
$this->merge_threads($newtid, $destination_tid, $subject);
}





		return $newtid;

		return $newtid;

	}

/**

	}

/**

	 * Move multiple threads to new forum
*
* @param array Thread IDs

	 * Move multiple threads to new forum
*
* @param array Thread IDs

Zeile 766Zeile 876

$sqlarray = array(
"fid" => $moveto,


$sqlarray = array(
"fid" => $moveto,

		);

		);

		$db->update_query(TABLE_PREFIX."threads", $sqlarray, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid IN ($tid_list)");


		$db->update_query(TABLE_PREFIX."threads", $sqlarray, "tid IN ($tid_list)");
$db->update_query(TABLE_PREFIX."posts", $sqlarray, "tid IN ($tid_list)");


Zeile 774Zeile 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

Zeile 791Zeile 901
		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 = '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 806Zeile 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 827Zeile 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).")";