<?php //require('./data/cache/settings.php'); //$mail_setting = $_CACHE['settings']; $mail_setting = array ( 'accessemail' => '', 'censoremail' => '', 'censorusername' => '', 'dateformat' => 'y-n-j', 'doublee' => '0', 'timeoffset' => '28800', 'maildefault' => 'xxx@yeah.net', 'mailsend' => '2', 'mailserver' => 'smtp.yeah.net', 'mailport' => '25', 'mailauth' => '1', 'mailfrom' => '捎点宝 <xxx@yeah.net>', 'mailauth_username' => 'xxx@yeah.net', 'mailauth_password' => '123123',//邮箱授权码 'maildelimiter' => '0', 'mailusername' => '1', 'mailsilent' => '1', 'pmfloodctrl' => '15', 'pmcenter' => '1', 'sendpmseccode' => '1', 'pmsendregdays' => '0', 'privatepmthreadlimit' => '0', 'chatpmthreadlimit' => '1000', 'chatpmmemberlimit' => '35', 'timeformat' => 'h:i A', ); date_default_timezone_set('PRC'); if(empty($_GET['mod']) || empty($_GET['IP'])) exit; $mail = array( 'email_to'=>'xxxx@qq.com',//收件人列表,多个用逗号隔开 'charset'=>'utf-8', ); if($_GET['mod'] == 1){ $mail['message'] = '故障描述:此服务器apache服务于' . date('Y-m-d H:i:s') . '发生apache服务崩溃并尝试重新启动'; $mail['subject'] = $_GET['IP'] . 'apache服务出现异常'; }elseif($_GET['mod'] == 2){ $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '出现硬盘空间低于警戒线值'; $mail['subject'] = $_GET['IP'] . '硬盘空间不足'; }elseif($_GET['mod'] == 3){ $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '出现服务器负载高于警戒线值'; $mail['subject'] = $_GET['IP'] . '负载异常'; }elseif($_GET['mod'] == 4){ $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '出现服务器内存低于警戒线值'; $mail['subject'] = $_GET['IP'] . '内存不足'; }elseif($_GET['mod'] == 5){ $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '出现服务器IO高于警戒线值'; $mail['subject'] = $_GET['IP'] . 'IO异常'; }elseif($_GET['mod'] == 6) { $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '检测出有人在进行getshell的高危操作,具体请查询scanning.log'; $mail['subject'] = $_GET['IP'] . '可能有人进行getshell的攻击的操作!'; }elseif($_GET['mod'] == 7) { $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '检测出有人可能已经上传成功webshell并进行非法操作,具体请查询scanning.log'; $mail['subject'] = $_GET['IP'] . '可能已经被人上传webshell了'; }elseif($_GET['mod'] == 8) { $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '检测出有人疑似在进行拖库的高危操作,具体请查询scanning.log'; $mail['subject'] = $_GET['IP'] . '有人在进行拖库行为'; }elseif($_GET['mod'] == 9) { $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '检测出鱼邻同步论坛功能可能出现故障。'; $mail['subject'] = $_GET['IP'] . '鱼邻同步论坛功能可能出现故障'; }elseif($_GET['mod'] == 10) { $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '出现连续' . $_GET['time'] . '分钟无法访问'; $mail['subject'] = $_GET['IP'] . '无法访问'; }elseif($_GET['mod'] == 11) { $mail['message'] = '故障描述:此服务器于' . date('Y-m-d H:i:s') . '出现连续' . $_GET['time'] . '分钟访问速度超出了警戒线'; $mail['subject'] = $_GET['IP'] . '访问速度超出警戒线'; }else{ exit; } $appname = ''; $mail['subject'] = '=?'.$mail['charset'].'?B?'.base64_encode(str_replace(" ", '', str_replace(" ", '', $mail['subject']))).'?='; $mail['message'] = chunk_split(base64_encode(str_replace(" .", " ..", str_replace(" ", " ", str_replace(" ", " ", str_replace(" ", " ", str_replace(" ", " ", $mail['message']))))))); $email_from = $mail['frommail'] == '' ? '=?'.$mail['charset'].'?B?'.base64_encode($appname)."?= <$mail_setting[maildefault]>" : (preg_match('/^(.+?) <(.+?)>$/',$email_from, $from) ? '=?'.$mail['charset'].'?B?'.base64_encode($from[1])."?= <$from[2]>" : $mail['frommail']); $maildelimiter = $mail_setting['maildelimiter'] == 1 ? " " : ($mail_setting['maildelimiter'] == 2 ? " " : " "); $headers = "From: $email_from{$maildelimiter}X-Priority: 3{$maildelimiter}X-Mailer: Discuz! $version{$maildelimiter}MIME-Version: 1.0{$maildelimiter}Content-type: text/".($mail['htmlon'] ? 'html' : 'plain')."; charset=$mail[charset]{$maildelimiter}Content-Transfer-Encoding: base64{$maildelimiter}"; if(!$fp = fsockopen($mail_setting['mailserver'], $mail_setting['mailport'], $errno, $errstr, 30)) { return false; } stream_set_blocking($fp, true); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != '220') { echo $lastmessage; return false; } fputs($fp, ($mail_setting['mailauth'] ? 'EHLO' : 'HELO')." discuz "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 220 && substr($lastmessage, 0, 3) != 250) { echo $lastmessage; return false; } while(1) { if(substr($lastmessage, 3, 1) != '-' || empty($lastmessage)) { break; } $lastmessage = fgets($fp, 512); } if($mail_setting['mailauth']) { fputs($fp, "AUTH LOGIN "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 334) { echo $lastmessage; return false; } fputs($fp, base64_encode($mail_setting['mailauth_username'])." "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 334) { echo $lastmessage; return false; } fputs($fp, base64_encode($mail_setting['mailauth_password'])." "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 235) { echo $lastmessage; return false; } $email_from = $mail_setting['mailfrom']; } fputs($fp, "MAIL FROM: <".preg_replace("/.*<(.+?)>.*/", "\1", $email_from)."> "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { fputs($fp, "MAIL FROM: <".preg_replace("/.*<(.+?)>.*/", "\1", $email_from)."> "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { echo $lastmessage; return false; } } $email_tos = array(); foreach(explode(',', $mail['email_to']) as $touser) { $touser = trim($touser); if($touser) { fputs($fp, "RCPT TO: <".preg_replace("/.*<(.+?)>.*/", "\1", $touser)."> "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { fputs($fp, "RCPT TO: <".preg_replace("/.*<(.+?)>.*/", "\1", $touser)."> "); $lastmessage = fgets($fp, 512); echo $lastmessage; return false; } } } fputs($fp, "DATA "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 354) { echo $lastmessage; return false; } $headers .= 'Message-ID: <'.gmdate('YmdHs').'.'.substr(md5($mail['message'].microtime()), 0, 6).rand(100000, 999999).'@'.$_SERVER['HTTP_HOST'].">{$maildelimiter}"; fputs($fp, "Date: ".gmdate('r')." "); fputs($fp, "To: ".$mail['email_to']." "); fputs($fp, "Subject: ".$mail['subject']." "); fputs($fp, $headers." "); fputs($fp, " "); fputs($fp, "$mail[message] . "); $lastmessage = fgets($fp, 512); if(substr($lastmessage, 0, 3) != 250) { echo $lastmessage; return false; } echo 'OK'; fputs($fp, "QUIT ");