log spammer post content
#1
coming from
https://community.mybb.com/thread-205983...pid1253002

I am looking for a plugin to log spam content. I would like the username, IP, email, thread titles they created and post content they created...before purge spammer abolishes it.
I was looking in moderation.php, but i am not sure how to create a log in php to log the needed info before removing it. There is a plugin here that does similar, but it doesnt log the post content or thread title content. 

./moderation.php (purge spammer portion)

    case "purgespammer":
        require_once MYBB_ROOT."inc/functions_user.php";
 
        $groups = explode(",", $mybb->settings['purgespammergroups']);
        if(!in_array($mybb->user['usergroup'], $groups))
        {
            error_no_permission();
        }
 
        $uid = $mybb->input['uid'];
        $user = get_user($uid);
        if(!$user['uid'] || !purgespammer_show($user['postnum'], $user['usergroup'], $user['uid']))
        {
            error($lang->purgespammer_invalid_user);
        }
 
        if($mybb->input['action'] == "do_purgespammer")
        {
            verify_post_check($mybb->get_input('my_post_key'));
 
            $user_deleted = false;
 
            // Run the hooks first to avoid any issues when we delete the user
            $plugins->run_hooks("moderation_purgespammer_purge");
 
            require_once MYBB_ROOT.'inc/datahandlers/user.php';
            $userhandler = new UserDataHandler('delete');
 
            if($mybb->settings['purgespammerbandelete'] == "ban")
            {
                // First delete everything
                $userhandler->delete_content($uid);
                $userhandler->delete_posts($uid);
                 
                // Next ban him (or update the banned reason, shouldn't happen)
                $query = $db->simple_select("banned", "uid", "uid = '{$uid}'");
                if($db->num_rows($query) > 0)
                {
                    $banupdate = array(
                        "reason" => $db->escape_string($mybb->settings['purgespammerbanreason'])
                    );
                    $db->update_query('banned', $banupdate, "uid = '{$uid}'");
                }
                else
                {
                    $insert = array(
                        "uid" => $uid,
                        "gid" => (int)$mybb->settings['purgespammerbangroup'],
                        "oldgroup" => 2,
                        "oldadditionalgroups" => "",
                        "olddisplaygroup" => 0,
                        "admin" => (int)$mybb->user['uid'],
                        "dateline" => TIME_NOW,
                        "bantime" => "---",
                        "lifted" => 0,
                        "reason" => $db->escape_string($mybb->settings['purgespammerbanreason'])
                    );
                    $db->insert_query('banned', $insert);
                }
 
                // Add the IP's to the banfilters
                foreach(array($user['regip'], $user['lastip']) as $ip)
                {
                    $ip = my_inet_ntop($db->unescape_binary($ip));
                    $query = $db->simple_select("banfilters", "type", "type = 1 AND filter = '".$db->escape_string($ip)."'");
                    if($db->num_rows($query) == 0)
                    {
                        $insert = array(
                            "filter" => $db->escape_string($ip),
                            "type" => 1,
                            "dateline" => TIME_NOW
                        );
                        $db->insert_query("banfilters", $insert);
                    }
                }
 
                // Clear the profile
                $userhandler->clear_profile($uid, $mybb->settings['purgespammerbangroup']);
 
                $cache->update_banned();
                $cache->update_bannedips();
                $cache->update_awaitingactivation();
 
                // Update reports cache
                $cache->update_reportedcontent();
            }
            elseif($mybb->settings['purgespammerbandelete'] == "delete")
            {
                $user_deleted = $userhandler->delete_user($uid, 1);
            }
 
            // Submit the user to stop forum spam
            if(!empty($mybb->settings['purgespammerapikey']))
            {
                $sfs = @fetch_remote_file("http://stopforumspam.com/add.php?username=" . urlencode($user['username']) . "&ip_addr=" . urlencode(my_inet_ntop($db->unescape_binary($user['lastip']))) . "&email=" . urlencode($user['email']) . "&api_key=" . urlencode($mybb->settings['purgespammerapikey']));
            }
 
            log_moderator_action(array('uid' => $uid, 'username' => $user['username']), $lang->purgespammer_modlog);
 
            if($user_deleted)
            {
                redirect($mybb->settings['bburl'], $lang->purgespammer_success);
            }
            else
            {
                redirect(get_profile_link($uid), $lang->purgespammer_success);
            }
        }
        else if($mybb->input['action'] == "purgespammer")
        {
            $plugins->run_hooks("moderation_purgespammer_show");
 
            add_breadcrumb($lang->purgespammer);
            $lang->purgespammer_purge = $lang->sprintf($lang->purgespammer_purge, htmlspecialchars_uni($user['username']));
            if($mybb->settings['purgespammerbandelete'] == "ban")
            {
                $lang->purgespammer_purge_desc = $lang->sprintf($lang->purgespammer_purge_desc, $lang->purgespammer_ban);
            }
            else
            {
                $lang->purgespammer_purge_desc = $lang->sprintf($lang->purgespammer_purge_desc, $lang->purgespammer_delete);                
            }
            eval("\$purgespammer = \"".$templates->get('moderation_purgespammer')."\";");
            output_page($purgespammer);
        }
        break;
Reply
#2
First you'd want to hook to moderation_purgespammer_purge. Next you'll want to use SQL to get the info you seek from the mybb_posts table. That will get you a uid, username, title, message, ip ( if you have logging enabled. ). You can do a join to the mybb_users table to get the email address of the user. I suggest joining using the uid column of both tables.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)