Vergleich inc/class_moderation.php - 1.2.0 - 1.2.4

  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 2063 2006-08-12 08:12:26Z chris $

 * $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))
{

	{
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 = '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,


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

		$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_forum_count($fid);

return true;

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

return true;

	}

	}


/**
* Unapprove one or more threads


/**
* Unapprove one or more threads

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

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

Zeile 334Zeile 365
		// Update unapproved post count
if($post['visible'] == 0)
{

		// Update unapproved post count
if($post['visible'] == 0)
{

			$db->query("UPDATE ".TABLE_PREFIX."forums SET unapprovedposts=unapprovedposts-1 WHERE fid='$post[fid]'");
$db->query("UPDATE ".TABLE_PREFIX."threads SET unapprovedposts=unapprovedposts-1 WHERE tid='$post[tid]'");

			$db->query("UPDATE ".TABLE_PREFIX."forums SET unapprovedposts=unapprovedposts-1 WHERE fid='{$post['fid']}'");
$db->query("UPDATE ".TABLE_PREFIX."threads SET unapprovedposts=unapprovedposts-1 WHERE tid='{$post['tid']}'");

		}
$plugins->run_hooks("delete_post", $post['tid']);
$cache->updatestats();

		}
$plugins->run_hooks("delete_post", $post['tid']);
$cache->updatestats();

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 374Zeile 411
			{ // these are the selected posts
if($sep == "new_line")
{

			{ // these are the selected posts
if($sep == "new_line")
{

					$message .= "\n\n $post[message]";





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

				}

				}

				else


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

				{

				{

					$message .= "[hr]$post[message]";


					// 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 449Zeile 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 458Zeile 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 475Zeile 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);

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

	

	

				$the_thread = $newtid;
break;
default:

				$the_thread = $newtid;
break;
default:

Zeile 522Zeile 632
		{
if($method == "copy" && $newforum['usepostcounts'] != "no")
{

		{
if($method == "copy" && $newforum['usepostcounts'] != "no")
{

				$pcount = "+$posters[posts]";
}
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"))

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

			{
$pcount = "-$posters[posts]";

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

			}
if(!empty($pcount))
{

			}
if(!empty($pcount))
{

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

			}
}


			}
}


Zeile 572Zeile 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'])
{

			$pollsql = ", poll='$mergethread[poll]'";

			$pollsql = ", poll='{$mergethread['poll']}'";

			$sqlarray = array(
"tid" => $tid,
);

			$sqlarray = array(
"tid" => $tid,
);

Zeile 664Zeile 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 683Zeile 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='$tid' 

			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 694Zeile 805
		{
if($oldusepcounts == "yes" && $newusepcounts == "no")
{

		{
if($oldusepcounts == "yes" && $newusepcounts == "no")
{

				$pcount = "-$posters[posts]";

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

			}
elseif($oldusepcounts == "no" && $newusepcounts == "yes")
{

			}
elseif($oldusepcounts == "no" && $newusepcounts == "yes")
{

				$pcount = "+$posters[posts]";

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

			}

if(!empty($pcount))

			}

if(!empty($pcount))

Zeile 714Zeile 825
			"subject" => $newsubject,
"replyto" => 0
);

			"subject" => $newsubject,
"replyto" => 0
);

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

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


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


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

Zeile 790Zeile 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 826Zeile 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).")";