2016-10-20, 09:00 PM
Can someone make a plugin to delete account and their threads/posts (or better yet...execute purge spammer on them) based on a users first post, and their content... keywords/phrases with options to add to it in ACP?
Quote:I tested it a bit and it is working.Thank You!!!!
Quote:Known issues: The subject is even checked at thread replays. Too lazy to check if it's new post or new thread.
if (stristr($message, $phrase) || stristr($subject, $phrase)){
ban_user($mybb->user['uid']);
error_no_permission();
}
EDIT:(2016-10-24, 12:09 AM)metulburr Wrote: [ -> ]How can i test it without banning myself? I am not sure if it bans IP/account/etc.Create a test account . It bans the account only. Not sure if there is any internal function to ban by IP.
(2016-10-24, 12:09 AM)metulburr Wrote: [ -> ]You mean it just rechecks the thread title on a new post? That seems no biggie.Exactly that. Not a big deal...
(2016-10-24, 12:09 AM)metulburr Wrote: [ -> ]Is there anyway to switch to just block a post VS block a ppost and ban user? I am assuming from looking at the code that to deny banning a user, and just block a user, to comment out the first line in this block?If you comment "ban_user" call, it will only block the post/thread.
EDIT:if (stristr($message, $phrase) || stristr($subject, $phrase)){ ban_user($mybb->user['uid']); error_no_permission(); }
If i add this original file to my plugins directory, i do not see it listed in my plugins available. Is it suppose to be elsewhere?
Quote:If you comment "ban_user" call, it will only block the post/thread.Nice. Thanks.
You must name the plugin "auto_ban.php". I should had attached it. I updated my last answer with the file attached.
$plugins->add_hook("datahandler_post_validate_thread", "atuo_ban_trigger");
$plugins->add_hook("datahandler_post_validate_post", "auto_ban_trigger");
function auto_ban_trigger(){
global $mybb;
if ($mybb->settings['autoban_enabled'] == 0){
return false;
}
if ($mybb->user['postcount'] < $mybb->settings['autoban_minposts']){
$message = $mybb->get_input('message');
$subject = $mybb->get_input('subject');
$phrases = explode(',',$mybb->settings['autoban_words']);
foreach ($phrases as $phrase){
$phrase = trim($phrase);
if ($phrase == ''){
continue;
}
if (stristr($message, $phrase) || stristr($subject, $phrase)){
//ban_user($mybb->user['uid']);
// error_no_permission();
$post->is_validated = false;
$post->set_error(sprintf("Your post has been marked as spam, and notified admins and mods. ", "Auto-Block"));
}
}
}
}
But it takes you to a white page. <?php
/*********************************************************************************************
+ No Links Allowed v0.1 : A Plugin for MyBB 1.4 and 1.6
+ Free to Use
+ Free to Edit
+ But Not Allowed to distribute
**********************************************************************************************
*/
if(!defined("IN_MYBB")){
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
function no_links_info(){
return array(
"name" => "No Links Allowed", "description" => "This plugin used to deny posting links before reaching min. amount of posts.", "website" => "http://yaldaram.com", "author" => "Yaldaram", "authorsite" => "http://yaldaram.com", "version" => "0.1", "compatibility" => "14*,16*,18*", "guid" => "7cfbe49416c7ffc03af0801cde9c59fc"
);
}
function no_links_activate(){
global $db, $mybb;
$no_links_group = array(
"gid" => "NULL", "name" => "no_links", "title" => "No Links Allowed", "description" => "Settings for the plugin.", "disporder" => "1", "isdefault" => "no",
);
$db->insert_query("settinggroups", $no_links_group);
$gid = $db->insert_id();
$no_links_setting_1 = array(
"sid" => "NULL", "name" => "no_links_power", "title" => "Power", "description" => "Select Yes if you really wants this plugin to run.", "optionscode" => "yesno", "value" => "no", "disporder" => "1", "gid" => intval($gid),
);
$db->insert_query("settings", $no_links_setting_1);
$no_links_setting_2 = array(
"sid" => "NULL", "name" => "no_links_groups", "title" => "Restricted_Groups", "description" => "Specify who is not allowed to post link. Separate each with ,", "optionscode" => "text", "value" => "1,2,5", "disporder" => "2", "gid" => intval($gid),
);
$db->insert_query("settings", $no_links_setting_2);
$no_links_setting_3 = array(
"sid" => "NULL", "name" => "no_links_forums", "title" => "Restricted_Forums", "description" => "Specify where this plugin is functional. Separate each with ,", "optionscode" => "text", "value" => "2,3", "disporder" => "3", "gid" => intval($gid),
);
$db->insert_query("settings", $no_links_setting_3);
$no_links_setting_4 = array(
"sid" => "NULL", "name" => "no_links_posts", "title" => "Minimum_Posts", "description" => "Specify minimum amount of posts.", "optionscode" => "text", "value" => "25", "disporder" => "4", "gid" => intval($gid),
);
$db->insert_query("settings", $no_links_setting_4);
rebuild_settings();
}
function no_links_deactivate(){
global $db, $mybb;
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='no_links'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_power'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_groups'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_forums'");
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='no_links_posts'");
rebuild_settings();
}
$plugins->add_hook("datahandler_post_validate_thread", "no_links_do");
$plugins->add_hook("datahandler_post_validate_post", "no_links_do");
function no_links_do($post){
global $mybb, $fid;
$power = $mybb->settings['no_links_power'];
$group = $mybb->user['usergroup'];
$groups = explode(",",$mybb->settings['no_links_groups']);
$forums = explode(",",$mybb->settings['no_links_forums']);
$postcount = $mybb->user['postnum'];
$posts = $mybb->settings['no_links_posts'];
if ($power != "0"){
if (in_array($fid,$forums) && in_array($group,$groups) && $posts > $postcount){
if (preg_match('@((http|https|ftp|irc)://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $post->data['message'])){
$post->is_validated = false;
$post->set_error(sprintf("You cannot post clickable links on this board until you proved you are not a spammer.", "No Links Allowed"));
}
}
}
}
?>