Vergleich inc/plugins/akismet.php - 1.4.3 - 1.4.10

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

 * Website: http://www.mybboard.net
* License: http://www.mybboard.net/about/license
*

 * $Id: akismet.php 4178 2008-09-06 16:39:10Z Tikitiki $

 * $Id: akismet.php 4343 2009-04-09 05:36:29Z Tikitiki $

 */

// Disallow direct access to this file for security reasons

 */

// Disallow direct access to this file for security reasons

Zeile 52Zeile 52
	$lang->load("forum_akismet", false, true);

return array(

	$lang->load("forum_akismet", false, true);

return array(

		"name"			=> $lang->akismet,
"description" => $lang->akismet_desc,
"website" => "http://mybboard.net",
"author" => "MyBB Group",
"authorsite" => "http://mybboard.net",
"version" => "1.2",
"guid" => "e57a80dbe7ff85083596a1a3b7da3ce7",

		"name"          => $lang->akismet,
"description" => $lang->akismet_desc,
"website" => "http://mybboard.net",
"author" => "MyBB Group",
"authorsite" => "http://mybboard.net",
"version" => "1.2.1",
"guid" => "e57a80dbe7ff85083596a1a3b7da3ce7",

		"compatibility" => "14*",
);
}

		"compatibility" => "14*",
);
}

Zeile 82Zeile 82
 *
* function hello_is_installed()
* {

 *
* function hello_is_installed()
* {

 *		global $db;
* if($db->table_exists("hello_world"))
* {
* return true;
* }
* return false;

 *      global $db;
* if($db->table_exists("hello_world"))
* {
* return true;
* }
* return false;

 * }
*
* _uninstall():

 * }
*
* _uninstall():

Zeile 116Zeile 116
 * {
* }
*/

 * {
* }
*/

 

	

function akismet_install()
{
global $db, $mybb, $lang;

if($db->field_exists('akismetstopped', "users"))
{

function akismet_install()
{
global $db, $mybb, $lang;

if($db->field_exists('akismetstopped', "users"))
{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP akismetstopped"); 

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP akismetstopped");

	}

// DELETE ALL SETTINGS TO AVOID DUPLICATES

	}

// DELETE ALL SETTINGS TO AVOID DUPLICATES

Zeile 141Zeile 141
	$rows = $db->fetch_field($query, "rows");

$insertarray = array(

	$rows = $db->fetch_field($query, "rows");

$insertarray = array(

		'name' => 'akismet', 
'title' => 'Akismet',
'description' => 'Options on how to configure and personalize Akismet',
'disporder' => $rows+1,

		'name' => 'akismet',
'title' => 'Akismet',
'description' => 'Options on how to configure and personalize Akismet',
'disporder' => $rows+1,

		'isdefault' => 0
);
$group['gid'] = $db->insert_query("settinggroups", $insertarray);

		'isdefault' => 0
);
$group['gid'] = $db->insert_query("settinggroups", $insertarray);

Zeile 182Zeile 182
		'gid' => $group['gid']
);
$db->insert_query("settings", $insertarray);

		'gid' => $group['gid']
);
$db->insert_query("settings", $insertarray);

		

	

	$insertarray = array(
'name' => 'akismetfidsignore',
'title' => 'Forums to Ignore',

	$insertarray = array(
'name' => 'akismetfidsignore',
'title' => 'Forums to Ignore',

Zeile 190Zeile 190
		'optionscode' => 'text',
'value' => '',
'disporder' => 3,

		'optionscode' => 'text',
'value' => '',
'disporder' => 3,

		'gid' => $group['gid']

		'gid' => $group['gid']

	);
$db->insert_query("settings", $insertarray);


	);
$db->insert_query("settings", $insertarray);


Zeile 220Zeile 220

rebuild_settings();
}


rebuild_settings();
}

 



function akismet_is_installed()
{
global $db;

function akismet_is_installed()
{
global $db;

Zeile 241Zeile 241
	
find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);

	
find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);

		

	

	$db->delete_query("templates", "title = 'akismet_postbit_spam'");

	$db->delete_query("templates", "title = 'akismet_postbit_spam'");

	

	

	find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_edit\']}')."#i", '{$post[\'button_spam\']}{$post[\'button_edit\']}');
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_edit\']}')."#i", '{$post[\'button_spam\']}{$post[\'button_edit\']}');

	find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_edit\']}')."#i", '{$post[\'button_spam\']}{$post[\'button_edit\']}');
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_edit\']}')."#i", '{$post[\'button_spam\']}{$post[\'button_edit\']}');

	

	

	$insert_array = array(
'title' => 'akismet_postbit_spam',
'template' => $db->escape_string('<a href="{$mybb->settings[\'bburl\']}/moderation.php?action=mark_as_spam&amp;pid={$post[\'pid\']}&amp;fid={$post[\'fid\']}"><img src="{$theme[\'imglangdir\']}/postbit_spam.gif" alt="{$lang->spam}" /></a>'),

	$insert_array = array(
'title' => 'akismet_postbit_spam',
'template' => $db->escape_string('<a href="{$mybb->settings[\'bburl\']}/moderation.php?action=mark_as_spam&amp;pid={$post[\'pid\']}&amp;fid={$post[\'fid\']}"><img src="{$theme[\'imglangdir\']}/postbit_spam.gif" alt="{$lang->spam}" /></a>'),

Zeile 254Zeile 254
		'version' => '',
'dateline' => TIME_NOW
);

		'version' => '',
'dateline' => TIME_NOW
);

	

	

	$db->insert_query("templates", $insert_array);

	$db->insert_query("templates", $insert_array);

	

	

	change_admin_permission('forum', 'akismet');
}

function akismet_deactivate()

	change_admin_permission('forum', 'akismet');
}

function akismet_deactivate()

{
global $db, $mybb;

include MYBB_ROOT."/inc/adminfunctions_templates.php";


{
global $db, $mybb;

include MYBB_ROOT."/inc/adminfunctions_templates.php";


	find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);


	find_replace_templatesets("postbit", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);
find_replace_templatesets("postbit_classic", "#".preg_quote('{$post[\'button_spam\']}')."#i", '', 0);


Zeile 280Zeile 280
	
if($db->field_exists('akismetstopped', "users"))
{

	
if($db->field_exists('akismetstopped', "users"))
{

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP akismetstopped"); 

		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP akismetstopped");

	}

// DELETE ALL SETTINGS TO AVOID DUPLICATES

	}

// DELETE ALL SETTINGS TO AVOID DUPLICATES

Zeile 303Zeile 303
	if($installed == false && $mybb->input['plugin'] == "akismet")
{
global $message;

	if($installed == false && $mybb->input['plugin'] == "akismet")
{
global $message;

		

	

		flash_message($message, 'success');
admin_redirect("index.php?module=config/settings&action=change&gid=".intval($mybb->akismet_insert_gid)."#row_setting_akismetapikey");
}

		flash_message($message, 'success');
admin_redirect("index.php?module=config/settings&action=change&gid=".intval($mybb->akismet_insert_gid)."#row_setting_akismetapikey");
}

 
}


function akismet_show_confirm_page()
{
global $mybb, $lang, $theme, $pid, $fid, $db, $headerinclude, $header, $footer;

$pid = intval($pid);
$fid = intval($fid);

$query = $db->simple_select("posts", "subject", "pid='{$pid}'", 1);
$post = $db->fetch_array($query);

if(!$post)
{
error("Invalid Post ID.");
}

output_page("<html>
<head>
<title>{$mybb->settings['bbname']} - {$lang->mark_as_spam}</title>
{$headerinclude}
</head>
<body>
{$header}
<form action=\"moderation.php\" method=\"post\">
<input type=\"hidden\" name=\"my_post_key\" value=\"{$mybb->post_code}\" />
<table border=\"0\" cellspacing=\"{$theme['borderwidth']}\" cellpadding=\"{$theme['tablespace']}\" class=\"tborder\">
<tr>
<td class=\"thead\" colspan=\"2\"><strong>{$post['subject']} - {$lang->mark_as_spam}</strong></td>
</tr>
<tr>
<td class=\"trow1\" colspan=\"2\" align=\"center\">{$lang->confirm_mark_as_spam}</td>
</tr>
{$loginbox}
</table>
<br />
<div align=\"center\"><input type=\"submit\" class=\"button\" name=\"submit\" value=\"{$lang->mark_as_spam}\" /></div>
<input type=\"hidden\" name=\"action\" value=\"mark_as_spam\" />
<input type=\"hidden\" name=\"pid\" value=\"{$pid}\" />
<input type=\"hidden\" name=\"fid\" value=\"{$fid}\" />
</form>
{$footer}
</body>
</html>");
exit;

}

function akismet_moderation_start()
{

}

function akismet_moderation_start()
{

	global $mybb, $db, $akismet, $lang, $cache;

	global $mybb, $db, $akismet, $lang, $cache, $fid, $pid;

	
if(!$mybb->settings['akismetswitch'] || $mybb->input['action'] != 'mark_as_spam')
{
return;

	
if(!$mybb->settings['akismetswitch'] || $mybb->input['action'] != 'mark_as_spam')
{
return;

	}


	}


	$lang->load("akismet", false, true);

if(!$mybb->input['pid'])

	$lang->load("akismet", false, true);

if(!$mybb->input['pid'])

Zeile 340Zeile 386
	}

$query = $db->query("

	}

$query = $db->query("

		SELECT p.username, u.email, u.website, u.akismetstopped, p.message, p.ipaddress, p.tid, p.replyto, p.fid

		SELECT p.uid, p.username, u.email, u.website, u.akismetstopped, p.message, p.ipaddress, p.tid, p.replyto, p.fid, f.usepostcounts

		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)

 
		LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)

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

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

Zeile 351Zeile 398
	{
error("Invalid Post ID.");
}

	{
error("Invalid Post ID.");
}

		








	
if(!$mybb->input['my_post_key'] || $mybb->request_method != "post")
{
akismet_show_confirm_page();
}

verify_post_check($mybb->input['my_post_key']);


	$akismet_array = array(
'type' => 'post',
'username' => $post['username'],

	$akismet_array = array(
'type' => 'post',
'username' => $post['username'],

Zeile 368Zeile 422
		$snippit = "thread";
}
else

		$snippit = "thread";
}
else

	{

	{

		$db->update_query("posts", array('visible' => '-4'), "pid = '{$pid}'");
$snippit = "post";

		$db->update_query("posts", array('visible' => '-4'), "pid = '{$pid}'");
$snippit = "post";

	}

	}

	
if(!$akismet)
{

	
if(!$akismet)
{

Zeile 379Zeile 433
	}

$akismet->submit_spam();

	}

$akismet->submit_spam();

	
$unapprovedakismetthread = 0;
$unapprovedakismetpost = 0;



$numakismetthread = $numakismetpost = 0;



	if($snippit == "thread")
{
$query = $db->query("
SELECT p.uid, u.usergroup
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

	if($snippit == "thread")
{
$query = $db->query("
SELECT p.uid, u.usergroup
FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)

			WHERE tid = '{$post['tid']}'

			WHERE p.tid = '{$post['tid']}'

		");
while($post2 = $db->fetch_array($query))
{

		");
while($post2 = $db->fetch_array($query))
{

			if($mybb->settings['akismetuidsignore'])








			++$numakismetpost;

if($post['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum-1 WHERE uid = '{$post2['uid']}'");
}

if($mybb->settings['akismetuidsignore'])

			{
$akismet_uids_ignore = explode(',', $mybb->settings['akismetuidsignore']);

			{
$akismet_uids_ignore = explode(',', $mybb->settings['akismetuidsignore']);

				if(in_array($post2['usergroup'], $akismet_uids_ignore))

				if(in_array($post2['usergroup'], $akismet_uids_ignore) || is_super_admin($post2['uid']))

				{
continue;
}

				{
continue;
}

 
			}

if(is_super_admin($post2['uid']))
{
continue;

			}

$db->write_query("UPDATE ".TABLE_PREFIX."users SET akismetstopped=akismetstopped+1 WHERE uid = '{$post2['uid']}'");
$query1 = $db->simple_select("users", "akismetstopped", "uid = '{$post2['uid']}'");
$akismetstopped = $db->fetch_field($query1, 'akismetstopped');

			}

$db->write_query("UPDATE ".TABLE_PREFIX."users SET akismetstopped=akismetstopped+1 WHERE uid = '{$post2['uid']}'");
$query1 = $db->simple_select("users", "akismetstopped", "uid = '{$post2['uid']}'");
$akismetstopped = $db->fetch_field($query1, 'akismetstopped');

		

			

			// Check if the person should be banned
if($mybb->settings['akismetnumtillban'] > 0 && $akismetstopped >= $mybb->settings['akismetnumtillban'])
{
$banned_user = array(
"uid" => $post2['uid'],

			// Check if the person should be banned
if($mybb->settings['akismetnumtillban'] > 0 && $akismetstopped >= $mybb->settings['akismetnumtillban'])
{
$banned_user = array(
"uid" => $post2['uid'],

					"admin" => "Akismet",

					"admin" => 0,

					"gid" => 7,
"oldgroup" => $post2['usergroup'],
"dateline" => TIME_NOW,
"bantime" => 'perm',
"lifted" => 'perm',

					"gid" => 7,
"oldgroup" => $post2['usergroup'],
"dateline" => TIME_NOW,
"bantime" => 'perm',
"lifted" => 'perm',

					"reason" => "Automatically banned by the Akismet system for spamming."


					"reason" => "Automatically banned by the Akismet system for spamming.",
"oldadditionalgroups" => ''

				);
$db->insert_query("banned", $banned_user);


				);
$db->insert_query("banned", $banned_user);


Zeile 425Zeile 491
				
$cache->update_moderators();
}

				
$cache->update_moderators();
}

			
++$unapprovedakismetthread;
++$unapprovedakismetpost;

 
		}

		}

 
		
++$numakismetthread;

	}
else
{

	}
else
{

Zeile 444Zeile 509
			{
continue;
}

			{
continue;
}

 
		}

if(is_super_admin($post['uid']))
{
continue;

		}

// Check if the person should be banned
if($mybb->settings['akismetnumtillban'] > 0 && $akismetstopped >= $mybb->settings['akismetnumtillban'])

		}

// Check if the person should be banned
if($mybb->settings['akismetnumtillban'] > 0 && $akismetstopped >= $mybb->settings['akismetnumtillban'])

		{			

		{

			$banned_user = array(
"uid" => $post['uid'],

			$banned_user = array(
"uid" => $post['uid'],

				"admin" => "Akismet",

				"admin" => 0,

				"gid" => 7,
"oldgroup" => $usergroup,
"dateline" => TIME_NOW,
"bantime" => 'perm',
"lifted" => 'perm',

				"gid" => 7,
"oldgroup" => $usergroup,
"dateline" => TIME_NOW,
"bantime" => 'perm',
"lifted" => 'perm',

				"reason" => "Automatically banned by the Akismet system for spamming."


				"reason" => "Automatically banned by the Akismet system for spamming.",
"oldadditionalgroups" => ''

			);
$db->insert_query("banned", $banned_user);

$db->update_query("users", array('usergroup' => 7), "uid = '{$post['uid']}'");

$cache->update_moderators();

			);
$db->insert_query("banned", $banned_user);

$db->update_query("users", array('usergroup' => 7), "uid = '{$post['uid']}'");

$cache->update_moderators();

		}

++$unapprovedakismetthread;
++$unapprovedakismetpost;
}

update_thread_counters($post['tid'], array('unapprovedposts' => '-'.$unapprovedakismetpost));
update_forum_counters($post['fid'], array('unapprovedthreads' => $unapprovedakismetthread, 'unapprovedposts' => '-'.$unapprovedakismetpost));






		}

++$numakismetpost;

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

update_thread_counters($post['tid'], array('replies' => '-'.$numakismetpost));
update_forum_counters($post['fid'], array('threads' => '-'.$numakismetthread, 'posts' => '-'.$numakismetpost));


	if($snippit == "thread")
{
redirect("./forumdisplay.php?fid={$post['fid']}", $lang->thread_spam_success);

	if($snippit == "thread")
{
redirect("./forumdisplay.php?fid={$post['fid']}", $lang->thread_spam_success);

Zeile 488Zeile 563
	global $templates, $mybb, $theme, $lang;

if(!$mybb->settings['akismetswitch'] || !is_moderator($post['fid']))

	global $templates, $mybb, $theme, $lang;

if(!$mybb->settings['akismetswitch'] || !is_moderator($post['fid']))

 
	{
return;
}

if($mybb->settings['akismetuidsignore'])
{
$akismet_uids_ignore = explode(',', $mybb->settings['akismetuidsignore']);
if(in_array($usergroup, $akismet_uids_ignore))
{
return;
}
}

if(is_super_admin($post['uid']))

	{
return;
}

	{
return;
}

Zeile 498Zeile 587
}

function akismet_verify(&$post)

}

function akismet_verify(&$post)

{
global $mybb, $isspam, $akismet;

{
global $mybb, $isspam, $akismet;

	
if($isspam == true && $mybb->settings['akismetswitch'] == 1)
{

	
if($isspam == true && $mybb->settings['akismetswitch'] == 1)
{

Zeile 518Zeile 607
	
$exclude_array = explode(',', $mybb->settings['akismetuserstoignore']);


	
$exclude_array = explode(',', $mybb->settings['akismetuserstoignore']);


	if(!$mybb->settings['akismetswitch'] || in_array($mybb->user['uid'], $exclude_array))

	if(!$mybb->settings['akismetswitch'] || in_array($mybb->user['uid'], $exclude_array) || is_super_admin($mybb->user['uid']))

	{
return;
}

	{
return;
}

Zeile 539Zeile 628
		{
return;
}

		{
return;
}

	}	

	}

	
$akismet_array = array(
'type' => 'post',

	
$akismet_array = array(
'type' => 'post',

Zeile 570Zeile 659
		{
$banned_user = array(
"uid" => $mybb->user['uid'],

		{
$banned_user = array(
"uid" => $mybb->user['uid'],

				"admin" => "Akismet",

				"admin" => 0,

				"gid" => 7,
"oldgroup" => $mybb->user['usergroup'],
"dateline" => TIME_NOW,
"bantime" => 'perm',
"lifted" => 'perm',

				"gid" => 7,
"oldgroup" => $mybb->user['usergroup'],
"dateline" => TIME_NOW,
"bantime" => 'perm',
"lifted" => 'perm',

				"reason" => "Automatically banned by the Akismet system for spamming."


				"reason" => "Automatically banned by the Akismet system for spamming.",
"oldadditionalgroups" => ''

			);
$db->insert_query("banned", $banned_user);


			);
$db->insert_query("banned", $banned_user);


Zeile 599Zeile 689
		
// Fake visibility
// Essentially because you can't modify the $visible variable we need to trick it

		
// Fake visibility
// Essentially because you can't modify the $visible variable we need to trick it

	 	// into thinking its saving a draft so it won't modify the users lastpost and postcount

		// into thinking its saving a draft so it won't modify the users lastpost and postcount

		// In akismet_verify, its set back to -4 so we can still uniquely verify that this is a spam message
// before it's inserted into the database.
$post->data['savedraft'] = 1;

		// In akismet_verify, its set back to -4 so we can still uniquely verify that this is a spam message
// before it's inserted into the database.
$post->data['savedraft'] = 1;

Zeile 657Zeile 747
		}

$sub_menu[$key] = array('id' => 'akismet', 'title' => $lang->akismet, 'link' => "index.php?module=forum/akismet");

		}

$sub_menu[$key] = array('id' => 'akismet', 'title' => $lang->akismet, 'link' => "index.php?module=forum/akismet");

	}	

	}

}

function akismet_admin_permissions(&$admin_permissions)
{

}

function akismet_admin_permissions(&$admin_permissions)
{

  	global $db, $mybb;

if($mybb->settings['akismetswitch'] == 1)

	global $db, $mybb;

if($mybb->settings['akismetswitch'] == 1)

	{
global $lang;

	{
global $lang;

		

		

		$lang->load("forum_akismet", false, true);

$admin_permissions['akismet'] = $lang->can_manage_akismet;

		$lang->load("forum_akismet", false, true);

$admin_permissions['akismet'] = $lang->can_manage_akismet;

Zeile 686Zeile 776
	$page->add_breadcrumb_item($lang->akismet);

if($mybb->input['delete_all'] && $mybb->request_method == "post")

	$page->add_breadcrumb_item($lang->akismet);

if($mybb->input['delete_all'] && $mybb->request_method == "post")

	{	

	{

		// User clicked no
if($mybb->input['no'])
{
admin_redirect("index.php?module=forum/akismet");
}

		// User clicked no
if($mybb->input['no'])
{
admin_redirect("index.php?module=forum/akismet");
}

	

		

		if($mybb->request_method == "post")
{
// Delete the template
$db->delete_query("posts", "visible = '-4'");

		if($mybb->request_method == "post")
{
// Delete the template
$db->delete_query("posts", "visible = '-4'");

	

			

			// Log admin action
log_admin_action();

			// Log admin action
log_admin_action();

	

			

			flash_message($lang->success_deleted_spam, 'success');
admin_redirect("index.php?module=forum/akismet");
}
else

			flash_message($lang->success_deleted_spam, 'success');
admin_redirect("index.php?module=forum/akismet");
}
else

		{		

		{

			$page->output_confirm_action("index.php?module=forum/akismet&amp;delete_all=1", $lang->confirm_spam_deletion);
}
}

			$page->output_confirm_action("index.php?module=forum/akismet&amp;delete_all=1", $lang->confirm_spam_deletion);
}
}

Zeile 713Zeile 803
	if($mybb->input['unmark'] && $mybb->request_method == "post")
{
$unmark = $mybb->input['akismet'];

	if($mybb->input['unmark'] && $mybb->request_method == "post")
{
$unmark = $mybb->input['akismet'];

	

		

		if(empty($unmark))
{
flash_message($lang->error_unmark, 'error');

		if(empty($unmark))
{
flash_message($lang->error_unmark, 'error');

Zeile 727Zeile 817
			$posts_in .= $comma.intval($key);
$comma = ',';
}

			$posts_in .= $comma.intval($key);
$comma = ',';
}

	

		

		$query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
while($post = $db->fetch_array($query))
{

		$query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
while($post = $db->fetch_array($query))
{

Zeile 742Zeile 832
		$thread_list = implode(',', $threadp);

$query = $db->query("

		$thread_list = implode(',', $threadp);

$query = $db->query("

			SELECT p.tid, f.usepostcounts, p.uid, p.fid, p.dateline, t.lastpost, t.lastposter, t.lastposteruid, t.subject

			SELECT p.tid, f.usepostcounts, p.uid, p.fid, p.dateline, p.replyto, t.lastpost, t.lastposter, t.lastposteruid, t.subject

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)

			FROM ".TABLE_PREFIX."posts p
LEFT JOIN ".TABLE_PREFIX."threads t ON (t.tid=p.tid)
LEFT JOIN ".TABLE_PREFIX."forums f ON (f.fid=p.fid)

Zeile 750Zeile 840
		");
while($post = $db->fetch_array($query))
{

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

			if($post['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid = '{$post['uid']}'");
}

update_thread_counters($post['tid'], array('posts' => '+1'));


 
			// Fetch the last post for this forum

			// Fetch the last post for this forum

			$query = $db->query("

			$query2 = $db->query("

				SELECT tid, lastpost, lastposter, lastposteruid, subject
FROM ".TABLE_PREFIX."threads
WHERE fid='{$post['fid']}' AND visible='1' AND closed NOT LIKE 'moved|%'
ORDER BY lastpost DESC
LIMIT 0, 1
");

				SELECT tid, lastpost, lastposter, lastposteruid, subject
FROM ".TABLE_PREFIX."threads
WHERE fid='{$post['fid']}' AND visible='1' AND closed NOT LIKE 'moved|%'
ORDER BY lastpost DESC
LIMIT 0, 1
");

			$lastpost = $db->fetch_array($query);

			$lastpost = $db->fetch_array($query2);

			
if($post['lastpost'] > $lastpost['lastpost'])
{

			
if($post['lastpost'] > $lastpost['lastpost'])
{

Zeile 776Zeile 859
				$lastpost['tid'] = $post['tid'];
}


				$lastpost['tid'] = $post['tid'];
}


			// Fetch the number of threads and replies in this forum (Approved only)
$query = $db->query("
SELECT COUNT(*) AS threads, SUM(replies) AS replies
FROM ".TABLE_PREFIX."threads
WHERE fid='{$post['fid']}' AND visible='1' AND closed NOT LIKE 'moved|%'
");
$count = $db->fetch_array($query);
$count['posts'] = $count['threads'] + $count['replies'];


 
			$update_count = array(

			$update_count = array(

				"posts" => intval($count['posts'])+1,
"threads" => intval($count['threads'])+1,

 
				"lastpost" => intval($lastpost['lastpost']),
"lastposter" => $db->escape_string($lastpost['lastposter']),
"lastposteruid" => intval($lastpost['lastposteruid']),
"lastposttid" => intval($lastpost['tid']),
"lastpostsubject" => $db->escape_string($lastpost['subject'])
);

				"lastpost" => intval($lastpost['lastpost']),
"lastposter" => $db->escape_string($lastpost['lastposter']),
"lastposteruid" => intval($lastpost['lastposteruid']),
"lastposttid" => intval($lastpost['tid']),
"lastpostsubject" => $db->escape_string($lastpost['subject'])
);

		

			

			$db->update_query("forums", $update_count, "fid='{$post['fid']}'");


			$db->update_query("forums", $update_count, "fid='{$post['fid']}'");


			$query = $db->query("
SELECT COUNT(*) AS replies
FROM ".TABLE_PREFIX."posts
WHERE tid='{$post['tid']}'
AND visible='1' OR pid = '{$post['pid']}'
");
$treplies = $db->fetch_field($query, 'replies');

$query = $db->query("

			$query2 = $db->query("









				SELECT u.uid, u.username, p.username AS postusername, p.dateline

				SELECT u.uid, u.username, p.username AS postusername, p.dateline

				FROM ".TABLE_PREFIX."posts p 

				FROM ".TABLE_PREFIX."posts p

				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='{$post['tid']}' AND p.visible='1' OR p.pid = '{$post['pid']}'
ORDER BY p.dateline DESC
LIMIT 1"
);

				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='{$post['tid']}' AND p.visible='1' OR p.pid = '{$post['pid']}'
ORDER BY p.dateline DESC
LIMIT 1"
);

			$lastpost = $db->fetch_array($query);

$query = $db->query("

			$lastpost = $db->fetch_array($query2);

$query2 = $db->query("

				SELECT u.uid, u.username, p.username AS postusername, p.dateline

				SELECT u.uid, u.username, p.username AS postusername, p.dateline

				FROM ".TABLE_PREFIX."posts p 

				FROM ".TABLE_PREFIX."posts p

				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='{$post['tid']}'
ORDER BY p.dateline ASC
LIMIT 0,1
");

				LEFT JOIN ".TABLE_PREFIX."users u ON (u.uid=p.uid)
WHERE p.tid='{$post['tid']}'
ORDER BY p.dateline ASC
LIMIT 0,1
");

			$firstpost = $db->fetch_array($query);

			$firstpost = $db->fetch_array($query2);

			
if(!$firstpost['username'])

			
if(!$firstpost['username'])

			{

			{

				$firstpost['username'] = $firstpost['postusername'];

				$firstpost['username'] = $firstpost['postusername'];

			}

			}

			if(!$lastpost['username'])
{
$lastpost['username'] = $lastpost['postusername'];

			if(!$lastpost['username'])
{
$lastpost['username'] = $lastpost['postusername'];

			}


			}


			if(!$lastpost['dateline'])
{
$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

			if(!$lastpost['dateline'])
{
$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['dateline'];

			}	


			}


			$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);


			$lastpost['username'] = $db->escape_string($lastpost['username']);
$firstpost['username'] = $db->escape_string($firstpost['username']);


Zeile 857Zeile 921
				'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),

				'lastpost' => intval($lastpost['dateline']),
'lastposter' => $lastpost['username'],
'lastposteruid' => intval($lastpost['uid']),

				'replies' => $treplies

 
			);
$db->update_query("threads", $update_array, "tid='{$post['tid']}'");

			);
$db->update_query("threads", $update_array, "tid='{$post['tid']}'");

 
			
if($post['usepostcounts'] != 0)
{
$db->write_query("UPDATE ".TABLE_PREFIX."users SET postnum=postnum+1 WHERE uid = '{$post['uid']}'");
}

$newthreads = $newreplies = 0;

if($post['replyto'] == 0)
{
++$newthreads;
}
else
{
++$newreplies;
}

update_thread_counters($post['tid'], array('replies' => '+'.$newreplies));
update_forum_counters($post['fid'], array('threads' => '+'.$newthreads, 'posts' => '+1'));

		}

$approve = array(

		}

$approve = array(

Zeile 883Zeile 965
	if($mybb->input['delete'] && $mybb->request_method == "post")
{
$deletepost = $mybb->input['akismet'];

	if($mybb->input['delete'] && $mybb->request_method == "post")
{
$deletepost = $mybb->input['akismet'];

	

		

		if(empty($deletepost))
{
flash_message($lang->error_deletepost, 'error');

		if(empty($deletepost))
{
flash_message($lang->error_deletepost, 'error');

Zeile 897Zeile 979
			$posts_in .= $comma.intval($key);
$comma = ',';
}

			$posts_in .= $comma.intval($key);
$comma = ',';
}

	

		

		$query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
while($post = $db->fetch_array($query))

		$query = $db->simple_select("posts", "pid, tid", "pid IN ({$posts_in}) AND replyto = '0'");
while($post = $db->fetch_array($query))

		{

		{

			$threadp[$post['pid']] = $post['tid'];
}


			$threadp[$post['pid']] = $post['tid'];
}


		if(!is_array($threadp))
{
$threadp = array();
}

require_once MYBB_ROOT."inc/functions_upload.php";

foreach($deletepost as $key => $val)

		if(!is_array($threadp))








		{

		{

			if(array_key_exists($key, $threadp))








			$threadp = array();
}

require_once MYBB_ROOT."inc/functions_upload.php";

foreach($deletepost as $pid => $val)
{
if(array_key_exists($pid, $threadp))

			{
$db->delete_query("posts", "pid IN ({$posts_in})");
$db->delete_query("attachments", "pid IN ({$posts_in})");

			{
$db->delete_query("posts", "pid IN ({$posts_in})");
$db->delete_query("attachments", "pid IN ({$posts_in})");

	

				

				// Get thread info

				// Get thread info

				$query = $db->simple_select("threads", "poll", "tid='{$threadp[".$key."]}'");

				$query = $db->simple_select("threads", "poll", "tid='".$threadp[$pid]."'");

				$poll = $db->fetch_field($query, 'poll');

				$poll = $db->fetch_field($query, 'poll');

		

				

				// Delete threads, redirects, favorites, polls, and poll votes

				// Delete threads, redirects, favorites, polls, and poll votes

				$db->delete_query("threads", "tid='{$threadp[".$key."]}'");
$db->delete_query("threads", "closed='moved|{$threadp[".$key."]}'");
$db->delete_query("favorites", "tid='{$threadp[".$key."]}'");
$db->delete_query("polls", "tid='{$threadp[".$key."]}'");
$db->delete_query("pollvotes", "pid='$poll'");

				$db->delete_query("threads", "tid='".$threadp[$pid]."'");
$db->delete_query("threads", "closed='moved|".$threadp[$pid]."'");
$db->delete_query("threadsubscriptions", "tid='".$threadp[$pid]."'");
$db->delete_query("polls", "tid='".$threadp[$pid]."'");
$db->delete_query("pollvotes", "pid='{$poll}'");

			}

// Remove attachments

			}

// Remove attachments

			remove_attachments($post['pid']);

			remove_attachments($pid);

			
// Delete the post

			
// Delete the post

			$db->delete_query("posts", "pid='{$post['pid']}'");

			$db->delete_query("posts", "pid='{$pid}'");

		}

// Log admin action

		}

// Log admin action

Zeile 945Zeile 1027
	}

if(!$mybb->input['action'])

	}

if(!$mybb->input['action'])

	{		

	{

		require MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;


		require MYBB_ROOT."inc/class_parser.php";
$parser = new postParser;


Zeile 969Zeile 1051
		}

$query = $db->simple_select("posts", "COUNT(pid) as spam", "visible = '-4'");

		}

$query = $db->simple_select("posts", "COUNT(pid) as spam", "visible = '-4'");

		$total_rows = $db->fetch_field($query, 'spam');


		$total_rows = $db->fetch_field($query, 'spam');


		if($start > $total_rows)
{
$start = $total_rows - 20;

		if($start > $total_rows)
{
$start = $total_rows - 20;

Zeile 1017Zeile 1099
		{
$table->construct_cell($lang->no_spam_found, array("class" => "align_center", "colspan" => 2));
$table->construct_row();

		{
$table->construct_cell($lang->no_spam_found, array("class" => "align_center", "colspan" => 2));
$table->construct_row();

		}

$table->output($lang->detected_spam_messages);

		}



		

		

		echo "<br />".draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum/akismet&amp;page={page}");



		$table->output($lang->detected_spam_messages);

echo "<br />".draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum/akismet&amp;page={page}");

		
$buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark'));
$buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));

		
$buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark'));
$buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));

Zeile 1031Zeile 1113
			$buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_spam_deletion}');"));
}


			$buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_spam_deletion}');"));
}


		$form->output_submit_wrapper($buttons);


		$form->output_submit_wrapper($buttons);


		$form->end();

		$form->end();

	

		

		$page->output_footer();
}


		$page->output_footer();
}


Zeile 1042Zeile 1124
}

/**

}

/**

 * This class is Copyright 2007 Ryan Gordon (Tikitiki)

 * This class is Copyright 2009 Ryan Gordon (Tikitiki)

 * Built to communicate with the akismet server
*/


 * Built to communicate with the akismet server
*/


Zeile 1185Zeile 1267
		}

// Good! The check failed; We're all good to go!

		}

// Good! The check failed; We're all good to go!

		return false;
}

		return false;
}

	
/**
* Submits a spam post to the Akismet server

	
/**
* Submits a spam post to the Akismet server

	 *
*/

	 *
*/

	function submit_spam()

	function submit_spam()

	{

	{

		$this->fetch_response($this->build_query_string(), 'submit-spam');
}


		$this->fetch_response($this->build_query_string(), 'submit-spam');
}


Zeile 1204Zeile 1286
	function submit_ham()
{
$this->fetch_response($this->build_query_string(), 'submit-ham');

	function submit_ham()
{
$this->fetch_response($this->build_query_string(), 'submit-ham');

	}

	}

	
/**
* Validate a API Key against the Akismet server

	
/**
* Validate a API Key against the Akismet server

Zeile 1225Zeile 1307
	 * Formats the comment array to the Akismet API Standards
*
*/

	 * Formats the comment array to the Akismet API Standards
*
*/

	function format_post() 

	function format_post()

	{
$format = array(
'type' => 'comment_type',

	{
$format = array(
'type' => 'comment_type',

Zeile 1236Zeile 1318
		);

// Basically we're assigning $long to the comment array if $short in the comment array, is not null

		);

// Basically we're assigning $long to the comment array if $short in the comment array, is not null

		foreach($format as $short => $long) 

		foreach($format as $short => $long)

		{

		{

			if(isset($this->post[$short])) 

			if(isset($this->post[$short]))

			{
$this->post[$long] = $this->post[$short];
unset($this->post[$short]);

			{
$this->post[$long] = $this->post[$short];
unset($this->post[$short]);

			}
}

			}
}

	}

/**

	}

/**

Zeile 1253Zeile 1335
	 */
function build_query_string()
{

	 */
function build_query_string()
{

		foreach($_SERVER as $key => $value) 

		foreach($_SERVER as $key => $value)

		{
if(in_array($key, $this->required))
{
if($key == 'REMOTE_ADDR')
{
$this->post[$key] = $this->post['user_ip'];

		{
if(in_array($key, $this->required))
{
if($key == 'REMOTE_ADDR')
{
$this->post[$key] = $this->post['user_ip'];

				} 
else

				}
else

				{
$this->post[$key] = $value;
}

				{
$this->post[$key] = $value;
}

Zeile 1288Zeile 1370
		$this->connection = @fsockopen($this->host, 80);
if(!$this->connection)
{

		$this->connection = @fsockopen($this->host, 80);
if(!$this->connection)
{

			$this->set_error("server_not_found");			

			$this->set_error("server_not_found");

			return false;
}


			return false;
}


Zeile 1336Zeile 1418
			
$http_response = explode("\r\n\r\n", $http_response, 2);
return $http_response[1];

			
$http_response = explode("\r\n\r\n", $http_response, 2);
return $http_response[1];

		} 
else

		}
else

		{
$this->set_error("response_failed");
return false;

		{
$this->set_error("response_failed");
return false;

Zeile 1350Zeile 1432
	 * Disconnects from the Akismet server
*
*/

	 * Disconnects from the Akismet server
*
*/

	function disconnect() 

	function disconnect()

	{
@fclose($this->connection);
}

	{
@fclose($this->connection);
}