Vergleich inc/plugins/akismet.php - 1.4.4 - 1.4.8

  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 4279 2008-11-26 00:01:25Z 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.1",
"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 165Zeile 165
		'name' => 'akismetapikey',
'title' => 'API Key to use for Akismet',
'description' => $db->escape_string('The API Key used to connect to Akismet. Please check here for more details: <a href="http://wordpress.com/api-keys/" target="_blank">http://wordpress.com/api-keys/</a>'),

		'name' => 'akismetapikey',
'title' => 'API Key to use for Akismet',
'description' => $db->escape_string('The API Key used to connect to Akismet. Please check here for more details: <a href="http://wordpress.com/api-keys/" target="_blank">http://wordpress.com/api-keys/</a>'),

		'optionscode' => 'text',
'value' => '',

		'optionscode' => 'text',
'value' => '',

		'disporder' => 1,

		'disporder' => 1,

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

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

	
$insertarray = array(
'name' => 'akismetnumtillban',

	
$insertarray = array(
'name' => 'akismetnumtillban',

Zeile 179Zeile 179
		'optionscode' => 'text',
'value' => '3',
'disporder' => 2,

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

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

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

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

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

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()
{

function akismet_show_confirm_page()
{

	global $mybb, $lang, $theme, $pid, $fid;

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

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

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

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

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

	
if(!$post)
{

	
if(!$post)
{

Zeile 352Zeile 352
{$footer}
</body>
</html>");

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


	}

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


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

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

	{

	{

		error("No Post ID specified.");

		error("No Post ID specified.");

	}


	}


	$pid = intval($mybb->input['pid']);

if(!$mybb->input['fid'])
{
error("No Forum ID specified.");

	$pid = intval($mybb->input['pid']);

if(!$mybb->input['fid'])
{
error("No Forum ID specified.");

	}

$fid = intval($mybb->input['fid']);

	}

$fid = intval($mybb->input['fid']);

	
if(!is_moderator($fid))
{
error("No Permissions to do this action.");
}

	
if(!is_moderator($fid))
{
error("No Permissions to do this action.");
}

	

	

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

if(!$post)

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

if(!$post)

	{

	{

		error("Invalid Post ID.");
}


		error("Invalid Post ID.");
}


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

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

	}


	}


	if(!$akismet)
{
$akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'], $akismet_array);
}

$akismet->submit_spam();

	if(!$akismet)
{
$akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'], $akismet_array);
}

$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 477Zeile 491
				
$cache->update_moderators();
}

				
$cache->update_moderators();
}

			
++$unapprovedakismetthread;
++$unapprovedakismetpost;

 
		}

		}

 
		
++$numakismetthread;

	}
else
{

	}
else
{

Zeile 488Zeile 501
		$query = $db->simple_select("users", "akismetstopped, usergroup", "uid = '{$post['uid']}'");
$akismetstopped = $db->fetch_field($query, 'akismetstopped');
$usergroup = $db->fetch_field($query, 'usergroup');

		$query = $db->simple_select("users", "akismetstopped, usergroup", "uid = '{$post['uid']}'");
$akismetstopped = $db->fetch_field($query, 'akismetstopped');
$usergroup = $db->fetch_field($query, 'usergroup');

		

		

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

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

		{

		{

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

			$akismet_uids_ignore = explode(',', $mybb->settings['akismetuidsignore']);
if(in_array($usergroup, $akismet_uids_ignore))
{
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->insert_query("banned", $banned_user);


Zeile 518Zeile 537
			$cache->update_moderators();
}


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

	
if($snippit == "thread")

	{

	{

		redirect("./forumdisplay.php?fid={$post['fid']}", $lang->thread_spam_success);
}
else
{
redirect("./showthread.php?tid={$post['tid']}", $lang->post_spam_success);

		redirect("./forumdisplay.php?fid={$post['fid']}", $lang->thread_spam_success);
}
else
{
redirect("./showthread.php?tid={$post['tid']}", $lang->post_spam_success);

	}
}

	}
}


function akismet_postbit(&$post)
{
global $templates, $mybb, $theme, $lang;


function akismet_postbit(&$post)
{
global $templates, $mybb, $theme, $lang;

	

	

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

	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 550Zeile 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(isset($post->thread_insert_data))

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

Zeile 570Zeile 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 590Zeile 627
		if(in_array($mybb->user['usergroup'], $akismet_uids_ignore))
{
return;

		if(in_array($mybb->user['usergroup'], $akismet_uids_ignore))
{
return;

		}
}

		}
}

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

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

Zeile 601Zeile 638
		'message' => $post->data['message'],
'user_ip' => $mybb->user['ipaddress']
);

		'message' => $post->data['message'],
'user_ip' => $mybb->user['ipaddress']
);

	

	

	if(!$akismet)

	if(!$akismet)

	{

	{

		$akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'],  $akismet_array);
}

if($akismet->check())
{
global $db;

		$akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'],  $akismet_array);
}

if($akismet->check())
{
global $db;

		

		

		$isspam = true;

// Update our spam count attempts

		$isspam = true;

// Update our spam count attempts

Zeile 622Zeile 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 647Zeile 685
			{
$mybbgroups .= ','.$mybb->user['additionalgroups'];
}

			{
$mybbgroups .= ','.$mybb->user['additionalgroups'];
}

		}


		}


		// 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 667Zeile 705
		$lang->load("akismet", false, true);

$url = get_thread_link($thread['tid']);

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

$url = get_thread_link($thread['tid']);

		$url2 = get_forum_link($thread['fid']);

		$url2 = get_forum_link($thread['fid']);

		
error("<div align=\"center\">".$lang->redirect_newreply."<br /><br />".$lang->sprintf($lang->redirect_return_forum, $url, $url2)."</div>", $lang->akismet_error);

		
error("<div align=\"center\">".$lang->redirect_newreply."<br /><br />".$lang->sprintf($lang->redirect_return_forum, $url, $url2)."</div>", $lang->akismet_error);

	}
}

	}
}


function akismet_redirect_forum()
{


function akismet_redirect_forum()
{

Zeile 684Zeile 722
		$url = get_forum_link($fid);

error("<div align=\"center\">".$lang->redirect_newthread."<br /><br />".$lang->sprintf($lang->redirect_return_forum, $url)."</div>", $lang->akismet_error);

		$url = get_forum_link($fid);

error("<div align=\"center\">".$lang->redirect_newthread."<br /><br />".$lang->sprintf($lang->redirect_return_forum, $url)."</div>", $lang->akismet_error);

	}
}

	}
}


function akismet_action_handler(&$action)
{


function akismet_action_handler(&$action)
{

Zeile 709Zeile 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;


Zeile 738Zeile 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");

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

		}

		}

		else

		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 765Zeile 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))

		if(empty($unmark))

		{

		{

			flash_message($lang->error_unmark, 'error');
admin_redirect("index.php?module=forum/akismet");

			flash_message($lang->error_unmark, 'error');
admin_redirect("index.php?module=forum/akismet");

		}

		}

		
$posts_in = '';
$comma = '';

		
$posts_in = '';
$comma = '';

Zeile 779Zeile 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))
{
$threadp[] = $post['tid'];

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

		}

		}

		
if(!is_array($threadp))

		
if(!is_array($threadp))

		{

		{

			$threadp = array();
}

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

$query = $db->query("

			$threadp = array();
}

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

			);



			

			

			$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("

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

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

Zeile 891Zeile 903
				$lastpost['username'] = $firstpost['username'];
$lastpost['uid'] = $firstpost['uid'];
$lastpost['dateline'] = $firstpost['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 909Zeile 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 935Zeile 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');
admin_redirect("index.php?module=forum/akismet");

		if(empty($deletepost))
{
flash_message($lang->error_deletepost, 'error');
admin_redirect("index.php?module=forum/akismet");

		}

		}

		
$posts_in = '';
$comma = '';

		
$posts_in = '';
$comma = '';

Zeile 949Zeile 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'");

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

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

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

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

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

		}


		}


		if(!is_array($threadp))

		if(!is_array($threadp))

		{

		{

			$threadp = array();
}

require_once MYBB_ROOT."inc/functions_upload.php";


			$threadp = array();
}

require_once MYBB_ROOT."inc/functions_upload.php";


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

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

		{

		{

			if(array_key_exists($key, $threadp))

			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 997Zeile 1027
	}

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

	}

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

	{		

	{

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

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

$form = new Form("index.php?module=forum/akismet", "post");

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

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

$form = new Form("index.php?module=forum/akismet", "post");

		

		

		$table = new Table;
$table->construct_header($form->generate_check_box("checkall", 1, '', array('class' => 'checkall')), array('width' => '5%'));
$table->construct_header("Title / Username / Post", array('class' => 'align_center'));

		$table = new Table;
$table->construct_header($form->generate_check_box("checkall", 1, '', array('class' => 'checkall')), array('width' => '5%'));
$table->construct_header("Title / Username / Post", array('class' => 'align_center'));

		

		

		$mybb->input['page'] = intval($mybb->input['page']);

if($mybb->input['page'] > 0)

		$mybb->input['page'] = intval($mybb->input['page']);

if($mybb->input['page'] > 0)

		{

		{

			$start = $mybb->input['page'] * 20;

			$start = $mybb->input['page'] * 20;

		}

		}

		else

		else

		{

		{

			$start = 0;

			$start = 0;

		}

		}

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

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

		

		

		if($start > $total_rows)

		if($start > $total_rows)

		{

		{

			$start = $total_rows - 20;
}

if($start < 0)

			$start = $total_rows - 20;
}

if($start < 0)

		{

		{

			$start = 0;
}


			$start = 0;
}


Zeile 1060Zeile 1090
			$post['message'] = $parser->parse_message($post['message'], $parser_options);

$table->construct_cell($post['message'], array("colspan" => 2));

			$post['message'] = $parser->parse_message($post['message'], $parser_options);

$table->construct_cell($post['message'], array("colspan" => 2));

			$table->construct_row();
}

$num_rows = $table->num_rows();

			$table->construct_row();
}

$num_rows = $table->num_rows();

		
if($num_rows == 0)

		
if($num_rows == 0)

		{

		{

			$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 1081Zeile 1111
		if($num_rows > 0)
{
$buttons[] = $form->generate_submit_button($lang->delete_all, array('name' => 'delete_all', 'onclick' => "return confirm('{$lang->confirm_spam_deletion}');"));

		if($num_rows > 0)
{
$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 1094Zeile 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 1277Zeile 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 1288Zeile 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 1305Zeile 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;
}
}
}


		

		

		$query_string = '';
foreach($this->post as $key => $data)

		$query_string = '';
foreach($this->post as $key => $data)

		{

		{

			$query_string .= $key.'='.urlencode(stripslashes($data)).'&';
}


			$query_string .= $key.'='.urlencode(stripslashes($data)).'&';
}


Zeile 1332Zeile 1362
	
/**
* Connects to the Akismet server

	
/**
* Connects to the Akismet server

	 *

	 *

	 * @return boolean True on success.
*/
function connect()

	 * @return boolean True on success.
*/
function connect()

Zeile 1340Zeile 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;

		}

		}

		
return true;
}

		
return true;
}

Zeile 1388Zeile 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 1402Zeile 1432
	 * Disconnects from the Akismet server
*
*/

	 * Disconnects from the Akismet server
*
*/

	function disconnect() 

	function disconnect()

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

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