SeoController.class.php
<?php
namespace Api\Controller;
use Common\Org\Date;
echo 111111;
class SeoController extends ApiController {
public function __construct() {
parent::__construct();
}
public function seoupdate(){
$site_model = M('Site');
$site_refresh_model = M('SiteRefresh');
$map = array(
'state' => 0,
//'add_time' => array('elt' , strtotime(date("Y-m-1")))
);
$refresh = $site_refresh_model->field("id,site_id,site_domain,type")->where($map)->order("update_time asc")->find();
if(!empty($refresh['site_id'])){
$site_id = $refresh['site_id'];
$domain = $refresh['site_domain'];
$type = $refresh['type'];
// 先更新时间
$site_refresh_model->where(array('id'=>$refresh['id']))->setField('update_time' , time());
// 输出域名
echo $domain;
// 判断是否能访问
if(!$type){
$code = curl_http_code($domain);
if(!in_array($code, array(200, 301, 302, 403))){
// 不能访问直接禁用网站并删除刷新数据
//$site_model->where(array('id'=>$site_id))->setField("state", SITE_FORBID);
$site_refresh_model->where(array('site_id'=>$site_id))->delete();
// 系统日志
sys_log('网站被禁用,site_id='.$site_id);
echo 'Forbidden.';exit;
}
}
//-------------------------------
$data = array(
'site_id' => $site_id,
'update_time' => time()
);
try {
if($type == 1){
$data['outlink'] = $outlink = getOutlink($domain);
}elseif($type == 2){
$data['p_num'] = $pnum = getPnum($domain);
}else{
$data['br'] = $br = getBr($domain);
$data['br_tools'] = $br_tools = getBrTools($domain);
$data['b_num'] = $bnum = getBnum($domain);
$data['b_snapshot'] = $bsnapshot = getBsnapshot($domain);
$data['pr'] = $pr = getPr($domain);
$data['rank'] = $rank = getRank($domain);
}
}catch (\Exception $e){
$site_refresh_model->where(array('site_id'=>$site_id,'type'=>$type))->delete();
echo 'Exception:'.$e->getMessage();
exit;
}
$res = M("SiteStat")->save($data);
$site_refresh_model->where(array('id'=>$refresh['id']))->delete();
if(!$res){
// 系统日志
sys_log('更新SEO数据失败,site_id='.$site_id);
}
}
}
}
ApiController.class.php
namespace Api\Controller;
use Common\Controller\FrantendController;
class ApiController extends FrantendController {
const SECRET = "123456";
public function __construct() {
parent::__construct();
$key = I("get.key");
if(empty($key) || $key != self::SECRET){
die("Sorry ! deny !");
}
}
}
用网址去执行http://123.com/index.php?m=api&c=seo
报错:Sorry ! deny !,请问我要怎么才能有效执行这个文件呢