Skip to content

Instantly share code, notes, and snippets.

@n0wheremany
Created February 20, 2013 17:45
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save n0wheremany/4997434 to your computer and use it in GitHub Desktop.
Save n0wheremany/4997434 to your computer and use it in GitHub Desktop.
DLE Выявление спамеров по базе пользователей
<?php
/*
=====================================================
n0wheremany
-----------------------------------------------------
http://nowheredev.ru/
-----------------------------------------------------
Copyright (c) 2013 n0wheremany
=====================================================
Данный код защищен авторскими правами
=====================================================
Файл: stopforumspam.php
-----------------------------------------------------
Назначение: Определение спамеров
=====================================================
*/
@session_start ();
define ( 'DATALIFEENGINE', true );
define ( 'ROOT_DIR', '..' );
define ( 'ENGINE_DIR', ROOT_DIR . '/engine' );
@error_reporting ( E_ALL ^ E_NOTICE );
@ini_set ( 'display_errors', true );
@ini_set ( 'html_errors', false );
@ini_set ( 'error_reporting', E_ALL ^ E_NOTICE );
@set_time_limit(0);
@ini_set("max_execution_time", 90000000);
require ENGINE_DIR . '/data/config.php';
if ($config['http_home_url'] == "") {
$config['http_home_url'] = explode ( "engine/stopforumspam.php", $_SERVER['PHP_SELF'] );
$config['http_home_url'] = reset ( $config['http_home_url'] );
$config['http_home_url'] = "http://" . $_SERVER['HTTP_HOST'] . $config['http_home_url'];
}
require_once ENGINE_DIR . '/classes/mysql.php';
require_once ENGINE_DIR . '/data/dbconfig.php';
require_once ENGINE_DIR . '/modules/functions.php';
require_once ENGINE_DIR . '/modules/sitelogin.php';
function reset_url($url) {
$value = str_replace ( "http://", "", $url );
$value = str_replace ( "www.", "", $value );
$value = explode ( "/", $value );
$value = reset ( $value );
return $value;
}
if (! $is_logged) $member_id['user_group'] = 5;
//if ($member_id['user_group']!=1) die ( "Access denied" );
$type = intval($_REQUEST['step']);
function StopForumSpam( $args ){
return json_decode(file_get_contents( 'http://www.stopforumspam.com/api?f=json&'.http_build_query($args, '', '&') ), true);
}
echo "обработка спамеров<br />";
$sfs_i = 0;
$sfs_c = 0;
$sfs_a = array();
$sfs_z = 0;
$db->query( "SELECT user_id, name, email FROM " . USERPREFIX . "_users WHERE banned!='yes'" );
while ( $row = $db->get_row() ) {
$sfs_a[$sfs_z][$row['email']] = $row['user_id'];
if(count($sfs_a[$sfs_z])>50)
$sfs_z++;
}
$db->free();
foreach($sfs_a as $ii => $dd){
$rr = StopForumSpam( array('email' => array_keys($dd)) );
foreach($rr['email'] as $iii => $ddd){
$rrr = $dd[$ddd['value']];
if(intval($ddd['frequency'])>3 and intval($rrr)>0){
if($type>1) {
$db->query("UPDATE " . USERPREFIX . "_users set banned='yes',icq='',land='',info='', signature='', fullname='', xfields='',restricted='3', restricted_days='',restricted_date='' WHERE user_id = '{$rrr}'");
$row_banned = $db->super_query( "SELECT users_id FROM " . USERPREFIX . "_banned WHERE users_id = '{$rrr}'" );
if( ! $row_banned['users_id'] )
$db->query( "INSERT INTO " . USERPREFIX . "_banned (users_id, descr, date, days) values ('{$rrr}', 'Таки спамер ж', '0', '0')" );
else
$db->query( "UPDATE " . USERPREFIX . "_banned set days='0',date='0',descr='' WHERE users_id = '{$rrr}'" );
}
echo "Определён спамер: {$rrr} ({$ddd['value']}) - {$ddd['frequency']}<br />";
$sfs_i++;
}
$sfs_c++;
}
}
die("<br />Обработка завершена: забанено {$sfs_i} из {$sfs_c}");
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment