Zeile 1 | Zeile 1 |
---|
<?php /** * MyBB 1.4
|
<?php /** * MyBB 1.4
|
* Copyright � 2008 MyBB Group, All Rights Reserved
| * Copyright © 2008 MyBB Group, All Rights Reserved
|
* * 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 3995 2008-07-07 09:32:32Z Tikitiki $
| * $Id: akismet.php 4754 2010-01-30 09:20:31Z RyanGordon $
|
*/
// Disallow direct access to this file for security reasons
| */
// Disallow direct access to this file for security reasons
|
Zeile 52 | Zeile 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 82 | Zeile 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 116 | Zeile 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 141 | Zeile 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 182 | Zeile 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 190 | Zeile 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 220 | Zeile 220 |
---|
rebuild_settings(); }
|
rebuild_settings(); }
|
|
|
function akismet_is_installed() { global $db;
| function akismet_is_installed() { global $db;
|
Zeile 241 | Zeile 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&pid={$post[\'pid\']}&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&pid={$post[\'pid\']}&fid={$post[\'fid\']}"><img src="{$theme[\'imglangdir\']}/postbit_spam.gif" alt="{$lang->spam}" /></a>'),
|
Zeile 254 | Zeile 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 279 | Zeile 279 |
---|
global $db; if($db->field_exists('akismetstopped', "users"))
|
global $db; 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 $db->write_query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN( 'akismetswitch',
| // DELETE ALL SETTINGS TO AVOID DUPLICATES $db->write_query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN( 'akismetswitch',
|
Zeile 299 | Zeile 299 |
---|
function akismet_key() { global $installed, $mybb;
|
function akismet_key() { global $installed, $mybb;
|
|
|
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);
| } $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']);
| } $pid = intval($mybb->input['pid']);
|
if(!$mybb->input['fid']) { error("No Forum ID specified.");
|
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);
| WHERE p.pid = '{$pid}' "); $post = $db->fetch_array($query);
|
Zeile 350 | Zeile 397 |
---|
if(!$post) { error("Invalid Post ID.");
|
if(!$post) { 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 368 | Zeile 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 379 | Zeile 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 425 | Zeile 491 |
---|
$cache->update_moderators(); }
|
$cache->update_moderators(); }
|
++$unapprovedakismetthread; ++$unapprovedakismetpost;
| |
}
|
}
|
| ++$numakismetthread;
|
} else {
| } else {
|
Zeile 444 | Zeile 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->insert_query("banned", $banned_user);
|
Zeile 466 | Zeile 537 |
---|
$cache->update_moderators(); }
|
$cache->update_moderators(); }
|
++$unapprovedakismetthread; ++$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('unapprovedposts' => '-'.$unapprovedakismetpost)); update_forum_counters($post['fid'], array('unapprovedthreads' => $unapprovedakismetthread, 'unapprovedposts' => '-'.$unapprovedakismetpost));
| update_thread_counters($post['tid'], array('replies' => '-'.$numakismetpost)); update_forum_counters($post['fid'], array('threads' => '-'.$numakismetthread, 'posts' => '-'.$numakismetpost));
|
if($snippit == "thread") {
| if($snippit == "thread") {
|
Zeile 488 | Zeile 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 498 | Zeile 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 518 | Zeile 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 539 | Zeile 628 |
---|
{ return; }
|
{ return; }
|
}
| }
|
$akismet_array = array( 'type' => 'post',
| $akismet_array = array( 'type' => 'post',
|
Zeile 551 | Zeile 640 |
---|
); if(!$akismet)
|
); if(!$akismet)
|
{
| {
|
$akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'], $akismet_array); }
| $akismet = new Akismet($mybb->settings['bburl'], $mybb->settings['akismetapikey'], $akismet_array); }
|
Zeile 567 | Zeile 656 |
---|
// Check if the person should be banned if($mybb->settings['akismetnumtillban'] > 0 && $mybb->user['akismetstopped'] >= $mybb->settings['akismetnumtillban'])
|
// Check if the person should be banned if($mybb->settings['akismetnumtillban'] > 0 && $mybb->user['akismetstopped'] >= $mybb->settings['akismetnumtillban'])
|
{
| {
|
$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->update_query("users", array('usergroup' => 7), "uid = '{$mybb->user['uid']}'");
|
); $db->insert_query("banned", $banned_user); $db->update_query("users", array('usergroup' => 7), "uid = '{$mybb->user['uid']}'");
|
|
|
$cache->update_moderators(); // We better do this..otherwise they have dodgy permissions $mybb->user['banoldgroup'] = $mybb->user['usergroup']; $mybb->user['usergroup'] = 7;
|
$cache->update_moderators(); // We better do this..otherwise they have dodgy permissions $mybb->user['banoldgroup'] = $mybb->user['usergroup']; $mybb->user['usergroup'] = 7;
|
|
|
global $mybbgroups; $mybbgroups = $mybb->user['usergroup'];
| global $mybbgroups; $mybbgroups = $mybb->user['usergroup'];
|
Zeile 599 | Zeile 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 641 | Zeile 731 |
---|
}
function akismet_admin_nav(&$sub_menu)
|
}
function akismet_admin_nav(&$sub_menu)
|
{
| {
|
global $mybb, $lang; if($mybb->settings['akismetswitch'] == 1) { $lang->load("forum_akismet", false, true);
|
global $mybb, $lang; if($mybb->settings['akismetswitch'] == 1) { $lang->load("forum_akismet", false, true);
|
|
|
end($sub_menu); $key = (key($sub_menu))+10;
| end($sub_menu); $key = (key($sub_menu))+10;
|
Zeile 657 | Zeile 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 685 | Zeile 775 |
---|
$page->add_breadcrumb_item($lang->akismet);
|
$page->add_breadcrumb_item($lang->akismet);
|
if($mybb->input['delete_all']) {
| 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');
|
flash_message($lang->success_deleted_spam, 'success');
|
admin_redirect("index.php?module=forum/akismet"); }
| admin_redirect("index.php?module=forum/akismet"); }
|
else
|
else
|
{
| {
|
$page->output_confirm_action("index.php?module=forum/akismet&delete_all=1", $lang->confirm_spam_deletion);
|
$page->output_confirm_action("index.php?module=forum/akismet&delete_all=1", $lang->confirm_spam_deletion);
|
}
| }
|
}
|
}
|
if($mybb->input['unmark'])
| if($mybb->input['unmark'] && $mybb->request_method == "post")
|
{ $unmark = $mybb->input['akismet'];
|
{ $unmark = $mybb->input['akismet'];
|
|
|
if(empty($unmark)) { flash_message($lang->error_unmark, 'error');
|
if(empty($unmark)) { flash_message($lang->error_unmark, 'error');
|
admin_redirect("index.php?module=forum/akismet"); }
| admin_redirect("index.php?module=forum/akismet"); }
|
$posts_in = '';
|
$posts_in = '';
|
| $comma = '';
|
foreach($unmark as $key => $val)
|
foreach($unmark as $key => $val)
|
{ $posts_in .= $comma.$key;
| { $posts_in .= $comma.intval($key);
|
$comma = ',';
|
$comma = ',';
|
} $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 737 | Zeile 827 |
---|
if(!is_array($threadp)) { $threadp = array();
|
if(!is_array($threadp)) { $threadp = array();
|
}
| }
|
$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 750 | Zeile 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 774 | Zeile 857 |
---|
$lastpost['lastposteruid'] = $post['lastposteruid']; $lastpost['subject'] = $post['subject']; $lastpost['tid'] = $post['tid'];
|
$lastpost['lastposteruid'] = $post['lastposteruid']; $lastpost['subject'] = $post['subject']; $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']) {
|
Zeile 839 | Zeile 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']);
|
--$mybb->user['akismetstopped']; if($mybb->user['akismetstopped'] < 0)
| $query2 = $db->simple_select("users", "akismetstopped", "uid='{$post['uid']}'"); $akismetstopped = $db->fetch_field($query2, "akismetstopped")-1; if($akismetstopped < 0)
|
{
|
{
|
$mybb->user['akismetstopped'] = 0;
| $akismetstopped = 0;
|
}
|
}
|
$db->update_query("users", array('akismetstopped' => $mybb->user['akismetstopped']), "uid='{$mybb->user['uid']}'");
| $db->update_query("users", array('akismetstopped' => $akismetstopped), "uid='{$post['uid']}'");
|
$update_array = array( 'username' => $firstpost['username'],
| $update_array = array( 'username' => $firstpost['username'],
|
Zeile 857 | Zeile 923 |
---|
'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( "visible" => 1, );
| $approve = array( "visible" => 1, );
|
Zeile 869 | Zeile 953 |
---|
if($thread_list) { $db->update_query("threads", $approve, "tid IN ({$thread_list})");
|
if($thread_list) { $db->update_query("threads", $approve, "tid IN ({$thread_list})");
|
} $db->update_query("posts", $approve, "pid IN ({$posts_in})");
| } $db->update_query("posts", $approve, "pid IN ({$posts_in})");
|
// Log admin action log_admin_action();
|
// Log admin action log_admin_action();
|
|
|
flash_message($lang->success_unmarked, 'success'); admin_redirect("index.php?module=forum/akismet"); }
|
flash_message($lang->success_unmarked, 'success'); admin_redirect("index.php?module=forum/akismet"); }
|
if($mybb->input['delete'])
| if($mybb->input['delete'] && $mybb->request_method == "post")
|
{ $deletepost = $mybb->input['akismet'];
|
{ $deletepost = $mybb->input['akismet'];
|
|
|
if(empty($deletepost)) { flash_message($lang->error_deletepost, 'error');
| if(empty($deletepost)) { flash_message($lang->error_deletepost, 'error');
|
Zeile 891 | Zeile 975 |
---|
} $posts_in = '';
|
} $posts_in = '';
|
| $comma = '';
|
foreach($deletepost as $key => $val) {
|
foreach($deletepost as $key => $val) {
|
$posts_in .= $comma.$key;
| $posts_in .= $comma.intval($key);
|
$comma = ','; }
|
$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 944 | Zeile 1029 |
---|
} 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 968 | Zeile 1053 |
---|
} $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)
|
if($start > $total_rows)
|
{
| {
|
$start = $total_rows - 20;
|
$start = $total_rows - 20;
|
}
| }
|
if($start < 0) {
| if($start < 0) {
|
Zeile 984 | Zeile 1069 |
---|
while($post = $db->fetch_array($query)) { if($post['uid'] != 0)
|
while($post = $db->fetch_array($query)) { if($post['uid'] != 0)
|
{ $username = "<a href=\"".str_replace("{uid}", $post['uid'], PROFILE_URL)."\" target=\"_blank\">".format_name($post['username'], $post['usergroup'], $post['displaygroup'])."</a>"; }
| { $username = "<a href=\"../".str_replace("{uid}", $post['uid'], PROFILE_URL)."\" target=\"_blank\">".format_name($post['username'], $post['usergroup'], $post['displaygroup'])."</a>"; }
|
else { $username = $post['username'];
| else { $username = $post['username'];
|
Zeile 1016 | Zeile 1101 |
---|
{ $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);
| } $table->output($lang->detected_spam_messages);
|
echo "<br />".draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum/akismet&page={page}"); $buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark')); $buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));
|
echo "<br />".draw_admin_pagination($mybb->input['page'], 20, $total_rows, "index.php?module=forum/akismet&page={page}"); $buttons[] = $form->generate_submit_button($lang->unmark_selected, array('name' => 'unmark')); $buttons[] = $form->generate_submit_button($lang->deleted_selected, array('name' => 'delete'));
|
|
|
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}');"));
|
Zeile 1033 | Zeile 1118 |
---|
$form->output_submit_wrapper($buttons); $form->end();
|
$form->output_submit_wrapper($buttons); $form->end();
|
|
|
$page->output_footer(); }
| $page->output_footer(); }
|
Zeile 1041 | Zeile 1126 |
---|
}
/**
|
}
/**
|
* 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 1184 | Zeile 1269 |
---|
} // 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() {
|
Zeile 1203 | Zeile 1288 |
---|
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 1222 | Zeile 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 1235 | Zeile 1320 |
---|
); // 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 1252 | Zeile 1337 |
---|
*/ 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 1281 | Zeile 1366 |
---|
* Connects to the Akismet server * * @return boolean True on success.
|
* Connects to the Akismet server * * @return boolean True on success.
|
*/
| */
|
function connect() { $this->connection = @fsockopen($this->host, 80); if(!$this->connection) {
|
function connect() { $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 1335 | Zeile 1420 |
---|
$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 1349 | Zeile 1434 |
---|
* Disconnects from the Akismet server * */
|
* Disconnects from the Akismet server * */
|
function disconnect()
| function disconnect()
|
{ @fclose($this->connection); }
| { @fclose($this->connection); }
|