setDB(); //print_R($options); require_once 'FlexyWiki/MenuParser.php'; $this->menu = new FlexyWiki_MenuParser; $this->menu->baseURL = "{$this->rootURL}/wiki.php"; $this->menu->currentPage = '/spam.php'; $this->menu->parseMenu(); if (!preg_match('/^(192\.168\.0\.|202\.134\.88\.6)/',$_SERVER["REMOTE_ADDR"])) { $this->errors['readonly'] = true; $this->REMOTE_ADDR = $_SERVER["REMOTE_ADDR"]; } if ($what) { list($type,$value) = explode('/',$what); switch($type) { case 'IP': //DB_DataObject::debugLevel(1); $this->iplog = DB_DataObject::factory('email_iplog'); $this->iplog->get('ip',$value); if (!($this->iplog->whitelist && isset($this->errors['readonly']))) { $trylog = DB_DataObject::factory('email_trylog'); $trylog->orderBy('try desc'); $trylog->limit(50); $trylog->ip = $value; $trylog->find(); $this->ipdetails = array(); while ($trylog->fetch()) { $this->ipdetails[] = clone($trylog); } } //echo '
';print_r($this->ipdetails);
$this->ip = $value;
$this->template = 'spamip.html';
// DB_DataObject::debugLevel(1);
$badlog = DB_DataObject::factory('email_badlog');
$badlog->ip = $value;
$badlog->limit(100);
$badlog->orderBy('try desc');
$badlog->find();
$this->attacks = array();
while($badlog->fetch()) {
$this->attacks[] = clone($badlog);
}
return;
default:
echo "EH whats going on?";
exit;
}
//$this->errors['readonly']
}
//DB_DataObject::Debuglevel(1);
// list the messages..
$iplog = DB_DataObject::factory('email_iplog');
$iplog->whereAdd('efforts > 2');
$iplog->blacklist = 0;
$iplog->whitelist = 0;
$iplog->greylist = 0;
$iplog->find();
$ips = array();
while ($iplog->fetch()) {
// check the trylog to make sure they have had a decent whack..
$trylog = DB_DataObject::factory('email_trylog');
$trylog->ip = $iplog->ip;
$trylog->selectAdd();
$trylog->selectAdd('count(id) as efforts');
$trylog->groupBy('title,sender,host');
$trylog->whereAdd("sender != ''");
$trylog->whereAdd("host != 'akbkhome.com'");
$trylog->having('count(id) > 2');
if (!$trylog->find(true)) {
continue;
}
$ips[] = clone($iplog);
}
$this->ips = $ips;
//echo '';print_r($ips);
// to do .. list greylisted ones..
// DB_DataObject::Debuglevel(1);
// list the messages..
$iplog = DB_DataObject::factory('email_iplog');
//$iplog->whereAdd('efforts > 1');
$iplog->blacklist = 0;
$iplog->whitelist = 0;
$iplog->greylist = 1;
$iplog->find();
$ips = array();
while ($iplog->fetch()) {
$ips[] = clone($iplog);
}
$this->greyips = $ips;
// DB_DataObject::debugLevel(1);
// attacks..
$badlog = DB_DataObject::factory('email_badlog');
$badlog->selectAdd();
$badlog->selectAdd('distinct(ip) as ip, count(id) as num, max(try) as try');
$badlog->selectAdd('max(host) as host, max(rcpt) as rcpt');
$badlog->groupBy('ip');
$badlog->having('count(ip) > 2 and count(id) > 5');
$badlog->orderBy('num desc');
$badlog->limit(20);
$badlog->find();
$this->attacks = array();
while($badlog->fetch()) {
$this->attacks[] = clone($badlog);
}
//echo '';print_r($this->attacks);
//DB_DataaObject::debuglevel(1);
// failed records..
$iplog = DB_DataObject::factory('email_iplog');
//$iplog->whereAdd('efforts > 1');
$iplog->whereAdd('try is not null');
$iplog->whitelist = 0;
$iplog->greylist = 0;
$iplog->orderBy('try desc');
$iplog->selectAdd('FLOOR((UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(updated)) / (24 * 60 * 60)) as age');
$iplog->limit(50);
$iplog->find();
$ips = array();
while ($iplog->fetch()) {
$ips[] = clone($iplog);
}
$this->failips = $ips;
}
function post() {
// testauth();
if (!preg_match('/^(192\.168\.0\.|202\.134\.88\.6)/',$_SERVER["REMOTE_ADDR"])) {
return $this->get();
}
$this->setDB();
//print_r($_POST);
foreach($_POST['list'] as $ip => $action) {
// we can only modify greylisted rows..
//DB_DataObject::debugLevel(1);
$iplog = DB_DataObject::factory('email_iplog');
$iplog->ip = $ip;
//$iplog->blacklist = 0;
$iplog->whitelist = 0;
if (!$iplog->find(true)) {
continue;
}
switch($action) {
case 'greylist':
$iplog->greylist = 1;
$iplog->blacklist = 0;
break;
case 'whitelist':
$iplog->greylist = 0;
$iplog->whitelist = 1;
$iplog->blacklist = 0;
break;
case 'blacklist':
$iplog->greylist = 0;
$iplog->whitelist = 0;
$iplog->blacklist = 1;
break;
}
$iplog->updated = date('Y-m-d');
$iplog->update();
}
$this->get();
}
function chopstr($s) {
$bits = explode(' ', $s);
if (strlen($bits[0]) > 30) {
return substr($s,0,30);
}
return $s;
}
function outputBlogBody() {
return $this->outputBody();
}
function summary()
{
/*
echo "
Success Rate Yesterday:
";
echo "Message OK'ed: ". `grep '=>' /var/log/exim4/mainlog.1 | wc -l`;
echo "Message Rejected: ". `grep 'rejected' /var/log/exim4/mainlog.1 | wc -l`;
echo "Message Rejected (HTML only): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep HTML | wc -l`;
echo "Message Rejected (Virus): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep -i Virus | wc -l`;
echo "Message Rejected (blacklist): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep black | wc -l`;
echo "Message Rejected (PHP rich): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep 'PHP.NET' | wc -l`;
echo "Message Rejected (no relay): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep 'relay not' | wc -l`;
echo "Message Rejected (unroutable):". `grep 'rejected' /var/log/exim4/mainlog.1 | grep 'Unrouteable' | wc -l`;
echo "Message Rejected (HELO bad): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep 'EHLO or HELO' | wc -l`;
echo "Message Rejected (protocol): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep 'protocol violation' | wc -l`;
echo "Message Rejected (defer): ". `grep 'rejected' /var/log/exim4/mainlog.1 | grep 'Defer' | wc -l`;
echo "
Success Rate Today:
";
echo "Message OK'ed: ". `grep '=>' /var/log/exim4/mainlog | wc -l`;
echo "Message Rejected: ". `grep 'rejected' /var/log/exim4/mainlog | wc -l`;
echo "Message Rejected (HTML only): ". `grep 'rejected' /var/log/exim4/mainlog | grep HTML | wc -l`;
echo "Message Rejected (Virus): ". `grep 'rejected' /var/log/exim4/mainlog | grep -i Virus | wc -l`;
echo "Message Rejected (blacklist): ". `grep 'rejected' /var/log/exim4/mainlog | grep black | wc -l`;
echo "Message Rejected (PHP rich): ". `grep 'rejected' /var/log/exim4/mainlog | grep 'PHP.NET' | wc -l`;
echo "Message Rejected (no relay): ". `grep 'rejected' /var/log/exim4/mainlog | grep 'relay not' | wc -l`;
echo "Message Rejected (unroutable):". `grep 'rejected' /var/log/exim4/mainlog | grep 'Unrouteable' | wc -l`;
echo "Message Rejected (HELO bad): ". `grep 'rejected' /var/log/exim4/mainlog | grep 'EHLO or HELO' | wc -l`;
echo "Message Rejected (protocol): ". `grep 'rejected' /var/log/exim4/mainlog | grep 'protocol violation' | wc -l`;
echo "Message Rejected (defer): ". `grep 'rejected' /var/log/exim4/mainlog | grep 'Defer' | wc -l`;
echo "";
*/
}
function host($ip) {
return gethostbyaddr($ip);
}
}