获取手机号码被360标记问题(代码备份)

/***********************************************************************
    * 检查大号是否被360标志
    * 作者:Edward
    * 日期:2016-11-24
    * 参数:
    * 代码逻辑:
    * 备用测试号码:18682421839(诈骗),15738969521(快递送餐);
    ***********************************************************************/
function get_360mark()
{
set_time_limit(0);
ini_set('memory_limit', '1024M');
header('Content-Type:text/html;charset=utf-8;');
//获取需要发送邮件的人,若未配置则直接退出
if($this->did_360mark_report_email)
{
$email_arr = explode(',', $this->did_360mark_report_email);
}else{
die('请在系统参数中配置“did_360mark_report_email”参数!');
}
//设置变量
$id   = 1; //邮件记录编号;
$url   = 'https://www.so.com/s?q=';
$email_tr_str   = '<tr style="height:30px;line-height:30px;background:#eee;color:#999;font-weight: normal;font-size: 12px;">';
$email_style_str   = 'font-weight: normal;font-size: 12px;border-right: 1px solid #ddd;border-bottom: 1px solid #ccc;';
$email_message_str = '';


//获取数据库号码信息
$db  = $this->loadDB();
$res = $db->select('number,area_code')->get('t_number_manager')->result_array();
foreach ($res as $val)
{
if( strlen($val['number'])< 10 )
{
$phone = $val['area_code'].$val['number'];
}else{
$phone = $val['number'];
}


//获取数据
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url.$phone);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($status != 200){
$output = (object)array(
'status' => $status,
'errno'  => curl_errno($ch),
'error'  => curl_error($ch)
);
}
curl_close($ch);


//从获取的数据中扒自己要的内容
$output    = preg_replace('/[\t\r\n]+/', '', $output);
$pattern   = '/<div class=\"cont mohe-wrap\"><table(.*?)>(.*?)<\/table><\/div>/';
$match_arr = array();
preg_match_all($pattern, $output, $match_arr);
//由preg_match_all方法确定,$match_arr肯定会存在下标为1的的值;
if( count($match_arr[2]) != 1 )
{
$pattern   = '/<div class=\"cont mohe-wrap\"><table(.*?)<\/table><div class=\"mohe-tips mh-ws-hy\">(.*?)<\/div>/';
$match_arr = array();
preg_match_all($pattern, $output, $match_arr);
if( count($match_arr[1]) != 1 )
{
echo '号码:"'.$phone.'"未获取到结果<br>'.PHP_EOL;
continue;
}
//获取到了结果,则从$match_arr[1]中获取号码,查看是否匹配,从$match_arr[2]获取标记信息
$phone_content_str  = $match_arr[1][0];
if( count($match_arr[2]) != 1 )
{
echo '号码:"'.$phone.'"无标注信息<br>'.PHP_EOL;
continue;
}
$detail_message_match_str = $match_arr[2][0];
}else{
$phone_content_str = $match_arr[2][0];


//获取标志的粗略内容,判断是否存在
$pattern   = '/<div class=\"mohe-tips\"(.*?)<\/div>/';
$message_match_arr = array();
preg_match_all($pattern, $match_arr[2][0], $message_match_arr);
if( count($message_match_arr[1]) != 1 )
{
echo '号码:"'.$phone.'"无标注信息<br>'.PHP_EOL;
continue;
}
$detail_message_match_str = $message_match_arr[1][0];
}

//获取号码,和搜索的号码对比,确保正确
$pattern = '/\d{7,14}/';
$phone_match_arr = array();
preg_match_all($pattern, $phone_content_str, $phone_match_arr);
if( count($phone_match_arr[0]) != 1  &&   $phone != $phone_match_arr[0][0] )
{
echo '号码:"'.$phone.'"获取结果中号码不匹配<br>'.PHP_EOL;
continue;
}


//获取标志具体内容
$pattern  = '/<span (.*?)>(.*?)<\/span>/';
$detail_message_match_arr = array();
preg_match_all($pattern, $detail_message_match_str, $detail_message_match_arr );

//遍历内容,并把内容中的标签去掉
$pattern  = '/<(.*?)>/';
$mark_arr = array();
foreach ($detail_message_match_arr [2] as $mark_key => $mark_value)
{
$mark_value = preg_replace($pattern, '', $mark_value);
$mark_arr[] = $mark_value;
}
//标记信息处理
$detail_mark_message_str = end($mark_arr);
unset( $mark_arr[count($mark_arr)-1] );
$mark_message_str =  implode(',', $mark_arr);
//下面为邮件的一行记录
$email_message_str .= $email_tr_str;
$email_message_str .= '<th style="width: 100px;'.$email_style_str.'">'.$id.'</th>';
$email_message_str .= '<th style="width: 100px;'.$email_style_str.'">'.$phone.'</th>';
$email_message_str .= '<th style="width: 100px;'.$email_style_str.'">'.$val['area_code'].'</th>';
$email_message_str .= '<th style="width: 200px;'.$email_style_str.'">'.$mark_message_str.'</th>';
$email_message_str .= '<th style="width: 460px;'.$email_style_str.'">'.$detail_mark_message_str.'</th>';
$email_message_str .= '</tr>';
$id++;
}//end_foreach_res


//遍历后,被标记号码数不为空,则发邮件格式信息,若为空,则直接提示;
$date = date('Y-m-d', time());
$subject = "大号被360标记情况报告(from 云之讯VBOSS)";
if($email_message_str)
{
$message_header_str = '<div class="cont" style="width: 1202px;mini-height: 370px;margin:0 auto;">
<div class="header" style="width: 1000px;height: 60px;font-size: 18px;color: #fff;border: 1px solid #48C690;-webkit-border-radius: 4px 4px 0 0;-moz-border-radius: 4px 4px 0 0;border-radius: 4px 4px 0 0;background: #48C690;margin: 0;padding: 0;">
<div style="width:50px;height:60px;float:left;margin-top:5px;margin-left:15px;">
<img src="http://www.uciaas.com/vboss/public/images/email_logo.png"/>
</div>
 <div style="width:370px;height:60px;margin-right:255px;float:right;line-height:60px;text-align:center;font-weight:bold;">VBOSS  &nbsp;&nbsp;&nbsp;深圳市云之讯网络技术有限公司</div>
</div>
<div class="main" style="width: 1000px;min-height: 310px;border:1px solid #ccc;border-top:none;-webkit-border-radius:0 0 4px 4px;-moz-border-radius:0 0 4px 4px;border-radius:0 0 4px 4px;">
<h1 style="font-size: 16px;color: #000;margin: 0;padding: 20px 0 10px 20px;letter-spacing: 2px;">您好:</h1>
<h2 style="padding-left: 30px;font-size: 14px;font-weight:normal;margin: 0;">
截至'.$date.',大号被360标记的情况如下:
</h2>
<table cellspacing="0" cellpadding="5" border="0" style="width:960px;border:1px solid #ccc;min-height: 60px;margin:25px 0 25px 30px;font-size: 12px;font-weight: normal;">
<tr style="height:30px;line-height:30px;background:#eee;color:#999;font-weight: normal;font-size: 12px;">
<th style="width: 100px;'.$email_style_str.'">编号</th>
<th style="width: 100px;'.$email_style_str.'">号码</th>
<th style="width: 100px;'.$email_style_str.'">区号</th>
<th style="width: 200px;'.$email_style_str.'">标记</th>
<th style="width: 460px;'.$email_style_str.'">详细信息</th>
</tr>';
$message_footer_str = '</table>
<p style="width:540px;height:50px;line-height: 25px;color:#999;font-size: 12px;margin:0 0 10px 30px;">
温馨提示:本邮件为系统自动发送,如果任何疑问请联系相关的客户经理或者发送邮件到以下邮箱
   bcs@ucpaas.com,感谢您的支持!
</p>
<p style="width:540px;height:40px;line-height: 20px;color:#999;font-size: 12px;margin:20px 0 10px 30px;">
深圳市云之讯网络技术有限公司<br/>'.$date.'
</p>
</div>
</div>';
//整合最终邮件内容
$email_message_str = $message_header_str.$email_message_str.$message_footer_str;
}else{
$email_message_str = $date.'没有号码被标记!';
}
//发送邮件,若不成功则输出失败原因
echo $email_message_str;
foreach ($email_arr as $value) {
echo $value;
$res = $this->send_email($subject, $email_message_str, $value, '', '', 1);
if(!$res['flag']){
echo '发送失败<br>';
echo $res['log'].'<br>';
}
}
}




/***********************************************************************
    * 检查大号是否被360标志
    * 作者:Edward
    * 日期:2016-11-24
    * 参数:
    * 代码逻辑:
    * 备用测试号码:18682421839(诈骗),15738969521(快递送餐);
    ***********************************************************************/
function get_mark_form360()
{
header('Content-Type:application/json;charset=utf-8;');
$url   = 'https://www.so.com/s?q=';
$phone = '075566610088';
$phone = '18682421839';


//获取数据
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url.$phone);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if($status != 200){
$output = (object)array(
'status' => $status,
'errno'  => curl_errno($ch),
'error'  => curl_error($ch)
);
}
curl_close($ch);


//从获取的数据中扒自己要的内容
$output    = preg_replace('/[\t\r\n]+/', '', $output);
$pattern   = '/<div class=\"cont mohe-wrap\"><table(.*?)>(.*?)<\/table><\/div>/';
$match_arr = array();
preg_match_all($pattern, $output, $match_arr);
//由preg_match_all方法确定,$match_arr肯定会存在下标为1的的值;
if( count($match_arr[2]) != 1 )
{
$pattern   = '/<div class=\"cont mohe-wrap\"><table(.*?)<\/table><div class=\"mohe-tips mh-ws-hy\">(.*?)<\/div>/';
$match_arr = array();
preg_match_all($pattern, $output, $match_arr);
if( count($match_arr[1]) != 1 )
{
echo '号码:"'.$phone.'"未获取到结果<br>'.PHP_EOL;
continue;
}
//获取到了结果,则从$match_arr[1]中获取号码,查看是否匹配,从$match_arr[2]获取标记信息
$phone_content_str  = $match_arr[1][0];
if( count($match_arr[2]) != 1 )
{
echo '号码:"'.$phone.'"无标注信息<br>'.PHP_EOL;
continue;
}
$detail_message_match_str = $match_arr[2][0];
}else{
$phone_content_str = $match_arr[2][0];


//获取标志的粗略内容,判断是否存在
$pattern   = '/<div class=\"mohe-tips\"(.*?)<\/div>/';
$message_match_arr = array();
preg_match_all($pattern, $match_arr[2][0], $message_match_arr);
if( count($message_match_arr[1]) != 1 )
{
echo '号码:"'.$phone.'"无标注信息<br>'.PHP_EOL;
continue;
}
$detail_message_match_str = $message_match_arr[1][0];
}


//获取号码,和搜索的号码对比,确保正确
$pattern = '/\d{7,14}/';
$phone_match_arr = array();
preg_match_all($pattern, $phone_content_str, $phone_match_arr);
if( count($phone_match_arr[0]) != 1  &&   $phone != $phone_match_arr[0][0] )
{
echo '号码:"'.$phone.'"获取结果中号码不匹配<br>'.PHP_EOL;
continue;
}


//获取标志具体内容
$pattern  = '/<span (.*?)>(.*?)<\/span>/';
$detail_message_match_arr = array();
preg_match_all($pattern, $detail_message_match_str, $detail_message_match_arr );

//遍历内容,并把内容中的标签去掉
$pattern  = '/<(.*?)>/';
$mark_arr = array();
foreach ($detail_message_match_arr [2] as $mark_key => $mark_value)
{
$mark_value = preg_replace($pattern, '', $mark_value);
$mark_arr[] = $mark_value;
}
print_r( $mark_arr );
}
阅读更多
换一批

没有更多推荐了,返回首页