防盗链之来源检测
<?php $ref = parse_url($_SERVER['HTTP_REFERER']); if($ref['host']<>$_SERVER['HTTP_HOST']){ $r['ok']=0; }else{ $url=$_POST['url']; $a=parse_url($url); $path=trim($a['path'],'/'); $etime=time()+600; //10分钟后过期 $key='nihaowoyehao68'; $sign = substr(md5($key.'&'.$etime.'&'.$path), 12, 8).$etime; $r['sign']=$sign; $r['ok']=1; } echo json_encode($r);