File: /www/wwwroot/bs.kntsleep.com/system/admin/statistics/employ.class.php
<?php
/*
* Copyright (c) Huyin Information Technology Co., Ltd. All Rights Reserved.
* BOSSCMS Content Management System (https://www.bosscms.net/)
*/
defined('IS_OK') or exit('Access Forbidden');
into::basic_class('admin');
class employ extends admin
{
public function init()
{
global $G;
$G['cover'] = $this->cover();
echo $this->theme('statistics/employ');
}
public function record()
{
global $G;
$host = urlencode(arrExist(parse_url($G['config']['domain']),'host'));
$file = ROOT_PATH.'cache/employ/'.md5($G['get']['platform'].$host);
switch($G['get']['platform']){
case 'baidu':
$url = 'https://www.baidu.com/s?ie=utf-8&wd=site%3A'.$host;
if(is_file($file) && filemtime($file)<TIME+3600){
$mat[1] = file_get_contents($file);
}else{
$res = $this->curl($url);
preg_match('/找到相关结果数约(.+)个/',$res,$mat);
dir::create($file,$mat[1]);
}
break;
case '360':
$url = 'https://www.so.com/s?ie=utf-8&q=site%3A'.$host;
if(is_file($file) && filemtime($file)<TIME+3600){
$mat[1] = file_get_contents($file);
}else{
$res = $this->curl($url);
preg_match('/该网站约(.+)个网页被360搜索收录/',$res,$mat);
dir::create($file,$mat[1]);
}
break;
case 'sogou':
$url = 'https://www.sogou.com/web?query=site%3A'.$host;
if(is_file($file) && filemtime($file)<TIME+3600){
$mat[1] = file_get_contents($file);
}else{
$res = $this->curl($url);
preg_match('/找到约(.+)条结果/',$res,$mat);
dir::create($file,$mat[1]);
}
break;
case 'bing':
$url = 'https://cn.bing.com/search?q=site%3A'.$host;
if(is_file($file) && filemtime($file)<TIME+3600){
$mat[1] = file_get_contents($file);
}else{
$res = $this->curl($url);
preg_match('/约(.+)个结果/',$res,$mat);
dir::create($file,$mat[1]);
}
break;
}
echo '<b>'.setDefault($mat[1],0).'</b><a href="'.$url.'" target="_blank">手动查询</a>';
}
public function curl($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.114 Safari/537.36 Edg/103.0.1264.49");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);
return $res;
}
}
?>