REGISTER or LOGIN to have the annoying ads removed.
Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
M.A.D. Alert Code Edit Please
#1
Hi everyone.

I'm trying to edit the code for the M.A.D. plugin so that it automatically bans those it detects. Also, it's causing a problem where when I subscribe to the forum I don't get the emails to it. Somehow it's registering the thread as created by me so when I subscribe to the forum I don't get new emails about new threads.

Here's the code for the plugin:

PHP Code:
<?php
/*    Multiple Account Detector (M.A.D)
\

\     Copyright 2009 MyBBSource.com
\ */
if(!defined("IN_MYBB"))
{
    die(
"Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("global_end""mad");
function 
mad_info()
{
    return array(
    
"name"            => "Multiple Account Detector (M.A.D)",    
             
"description"    => "",
    
"website"        => "http://www.mybbsource.com",    "author"        => "Nickman",
    
"authorsite"    => "http://mybbsource.com",    "version"        => "1.0",
    
"guid"             => "",
    
"compatibility" => "*"
    
);
}
function 
mad_activate(){
    global 
$db;
    
$mad_group = array(
    
'gid'            => 'NULL',
    
'name'            => 'mad',    'title'            => 'Multiple Account Detector',
    
'description'    => 'Make sure your users are not cheating you!',
    
'disporder'        => "1",
    
'isdefault'        => 'no',    );
    
$db->insert_query('settinggroups'$mad_group);
    
$gid $db->insert_id();
    
$mad_setting_1 = array(
    
'sid'            => 'NULL',
    
'name'            => 'enable_mad',
    
'title'            => 'Enable M.A.D?',    'description'    => 'If disabled, nothing will happen',    'optionscode'    => 'yesno',
    
'value'            => '1',
    
'disporder'        => 0,
    
'gid'            => intval($gid),
    );
    
$mad_setting_2 = array(
    
'sid'            => 'NULL',
    
'name'            => 'mad_forum',
    
'title'            => 'Forum to post a notice in',    'description'    => 'A post will be made in this forum alerting you of users logging into multiple accounts. Put the FID',
    
'optionscode'    => 'text',
    
'value'            => '',
    
'disporder'        => 1,
    
'gid'            => intval($gid),
    );        
$mad_setting_3 = array(
    
'sid'            => 'NULL',
    
'name'            => 'mad_global_check',
    
'title'            => 'Global Check',
    
'description'    => 'Do you want a check on each login that checks to see if the logged in user has the same IP as other users?',
    
'optionscode'    => 'yesno',
    
'value'            => '1',
    
'disporder'        => 2,
    
'gid'            => intval($gid),
    );
    
$mad_setting_4 = array(
    
'sid'            => 'NULL',
    
'name'            => 'mad_cookie_check',
    
'title'            => 'Cookie Check',
    
'description'    => 'Do you want a cookie to be set, then compared on next login to see if multiple users are logging in?',
    
'optionscode'    => 'yesno',
    
'value'            => '1',
    
'disporder'        => 3,
    
'gid'            => intval($gid),
    );    
$mad_setting_5 = array(
    
'sid'            => 'NULL',
    
'name'            => 'mad_excluded',
    
'title'            => 'Excluded Groups',
    
'description'    => 'Enter any GIDs of groups that should not be checked.  Separate with a comma',
    
'optionscode'    => 'text',
    
'value'            => '',
    
'disporder'        => 4,
    
'gid'            => intval($gid),
    );
    
    
$db->insert_query('settings'$mad_setting_1);
    
$db->insert_query('settings'$mad_setting_2);
    
$db->insert_query('settings'$mad_setting_3);
    
$db->insert_query('settings'$mad_setting_4);
    
$db->insert_query('settings'$mad_setting_5);
    
$db->query("CREATE TABLE `".TABLE_PREFIX."mad` (
`id` INT NOT NULL AUTO_INCREMENT ,
`uid1` INT NOT NULL ,
`uid2` INT NOT NULL ,
PRIMARY KEY ( `id` )
)"
);
    
rebuild_settings();
}
function 
mad_deactivate(){
    global 
$db;
    
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('enable_mad','mad_forum','mad_global_check','mad_cookie_check','mad_excluded')");
    
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='mad'");
    
rebuild_settings();
    
$db->query("DROP TABLE ".TABLE_PREFIX."mad");
}
function 
mad()
{
    global 
$mybb,$db;
    
//First, let's see if the mod is on
    
if ($mybb->settings['enable_mad'] != 1)
    {
        return;
    }    
//now we check if they are excused
    
if (in_array($mybb->user['usergroup'],explode(",",$mybb->settings['mad_excluded'])))    
{
        return;
    }
    
//Now we see if our cookie is set
    
if ($_COOKIE['users'] == '')
    {
        
//Do we want to set cookies?
        
if ($mybb->settings['mad_cookie_check'] == AND $mybb->user['uid'] != '')
        {
            
setcookie("users",$mybb->user['uid'],time()+23444040);
        }
    }
    
//Otherwise, we check the cookie, and see if they match up!    else
    
{
        
//OH NO, we have an imposter!
        
if ($_COOKIE['users'] != $mybb->user['uid'] AND $mybb->user['uid'] != '')
        {
        
$uid1=$mybb->user['uid'];
        
$uid2=$_COOKIE['users'];
            
//check to see if these two have been reported already
            
if ($db->num_rows($db->query("SELECT * FROM ".TABLE_PREFIX."mad WHERE (`uid1`='$uid1' AND `uid2`='$uid2') OR (`uid1`='$uid2' AND `uid2`='$uid1')")) < 1)
            {
                
mad_do_post($mybb->user['uid'],$_COOKIE['users'],2);
            }
        }
    }
    
//now, do we want to do an IP check?
    
if ($mybb->settings['mad_global_check'] == 1)    {
        
$ip=mad_getRealIP();
        
$check=$db->simple_select("users","*","lastip='$ip' OR regip='$ip'");
        
//this should be one, if it's greater, we have an issue!        if ($db->num_rows($check) > 1)
        
{
            while (
$user $db->fetch_array($check))            {
                
$users[]=$user['uid'];
            }
        }
        
$uid1=$users[0];
        
$uid2=$users[1];
        
$do=$db->query("SELECT * FROM ".TABLE_PREFIX."mad WHERE (`uid1`='$uid1' AND `uid2`='$uid2') OR (`uid1`='$uid2' AND `uid2`='$uid1')");
        if (
$db->num_rows($do) < 1)
        {
            
mad_do_post($users[0],$users[1],1);        }
    }
}
function 
mad_do_post($uid1,$uid2,$type)
{
    global 
$mybb,$db,$cache;
    if (
$type == 1)
    {
        
$type="They have been reported because they have logged in with the same IP address to two different accounts";
    }
    else
    {
        
$type="They have been reported because they have logged in on a computer with a different UID set on their cookie";
    }
    
$fid=$mybb->settings['mad_forum'];
    
$user1=$db->fetch_array($db->simple_select("users","username","uid='$uid1'"));
    
$user2=$db->fetch_array($db->simple_select("users","username","uid='$uid2'"));
    
$message="M.A.D has found that [url={$mybb->settings['bburl']}/member.php?action=profile&uid=$uid1]$user1[username][/url] and [url={$mybb->settings['bburl']}/member.php?action=profile&uid=$uid2]$user2[username][/url] have been logged in on the same computer[hr]
    
$type";
    
$insert_array = array(
    
"fid" => $fid,
    
"subject" => "M.A.D. Alert!!!",
    
"icon" => 0,
    
"uid" => intval($uid1),
    
"username" =>  $user1['username'],
    
"dateline" => time(),
    
"lastpost" => time(),
    
"closed" => "",
    
"visible" => 1,
    );
    
$db->insert_query("threads"$insert_array);
    
$newtid $db->insert_id();
    
$insert_post = array(
    
"tid" => intval($newtid),
    
"subject" => "M.A.D. Alert!",
    
"fid" => intval($fid),
    
"uid" => intval($uid1),
    
"username" =>  $user1['username'],
    
"dateline" => time(),
    
"message" => $message,
    
"visible" => 1,
    );
    
$db->insert_query("posts"$insert_post);
    
//UPDATE POSTCOUNT
    
$update_posts = array(
    
"postnum" => $mybb->user['postnum']+1,
    );
    
$db->update_query("users"$update_posts"uid='$uid'");    //UPDATE STATS
    
update_thread_counters($newtid, array("replies" => "+1"));    update_forum_counters($fid, array("threads" => "+1""posts" => "+1"));
    
update_forum_lastpost($fid);
    
$cache->update_stats();
    
$db->insert_query("mad",array("uid1"=>$uid1,"uid2"=>$uid2));
}
function 
mad_getRealIP()
{
    if (!empty(
$_SERVER['HTTP_CLIENT_IP']))
       {
        
$ip=$_SERVER['HTTP_CLIENT_IP'];
    }
    elseif (!empty(
$_SERVER['HTTP_X_FORWARDED_FOR']))       {
        
$ip=$_SERVER['HTTP_X_FORWARDED_FOR'];
    }
    else
    {
        
$ip=$_SERVER['REMOTE_ADDR'];
    }
    return 
$ip;
}
?>
Reply
#2
It would have felt so good if that code wasn't compressed in to 5 lines Sad
Smile
Reply
#3
Yeah I know I saw that too but I didn't have time to fix it.
Reply
#4
Oh cool hey when and if you get this sorted out can I get a copy of the code I have membership on mybbsource.com - http://mybbsource.com/user-2405.html
[Image: userbar.png]
Reply
#5
Axvis, the only reason I'm posting this question here is because this question has been posed multiple times on mybbsource and for MONTHS there's been absolutely no answer from the coder. It should be a very simple code edit really, but my experience in php and mybb is too little to grasp it, plus it's going to include some sql coding as well to update the group membership.

If you want this plugin I highly suggest you go to mybbsource and get it from there. If I get an answer here I'm posting it there as well so that the information required is provided in the correct location referencing the original file.
Alright, I tried updating the code as best as possible so it looks cleaner. I added a bunch of returns, I guess it just didn't copy over correctly. I'm not ENTIRELY sure if the returns are in the correct spot or not some of these, so you coders who know you should be able to spot it a lot easier than I would. anyways thanks for the help folks, I really appreciate it!!!! Smile
Reply
#6
Is anyone able to help please?
Reply
#7
Oh MasterZuFu, I also having the same problem with me. As I also have tried to make that code but I am not able to solve this problem. I am also searching the person who can solve this.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  [For 1.8] Last Edit Lock uav 3 3,198 Oct 27, 2017, 03:45 AM
Last Post: kajj88

Forum Jump:


Users browsing this thread: 1 Guest(s)