$time || $time-$cktime > $public_r['keytime']*60){ return -1; } if( empty($val) || md5($val) !== $code ){ return 0; } $checkpass = md5(md5(md5($val).'EmpireCMS'.$cktime).$public_r['keyrnd']); if( $checkpass !== $pass ){ return 0; } return 1; } //时间验证 function api_check_timeclosedo($ecms){ global $public_r; if(stristr($public_r['timeclosedo'],','.$ecms.',') && strstr($public_r['timeclose'],','.date('G').',')){ return false; } return true; } //IP验证 function api_check_ip($doing){ global $public_r,$empire,$dbtbpre; $pr=$empire->fetch1("select opendoip,closedoip,doiptype from {$dbtbpre}enewspublic limit 1"); if(!strstr($pr['doiptype'],','.$doing.',')){ return true; } $userip=egetip(); //允许IP if($pr['opendoip']){ $close=1; foreach(explode("\n",$pr['opendoip']) as $ctrlip){ if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip)){ $close=0; break; } } if($close==1){ return false; } } //禁止IP if($pr['closedoip']){ foreach(explode("\n",$pr['closedoip']) as $ctrlip){ if(preg_match("/^(".preg_quote(($ctrlip=trim($ctrlip)),'/').")/",$userip)){ return false; } } } return true; } //来源验证 function api_check_posturl(){ global $public_r; if($public_r['canposturl']){ $r=explode("\r\n",$public_r['canposturl']); $count=count($r); $b=0; for($i=0;$i<$count;$i++){ if(strstr($_SERVER['HTTP_REFERER'],$r[$i])){ $b=1; break; } } if($b==0){ return false; } } return true; }