首页 > 后端开发 > php教程 > webluker刷新缓存-php版

webluker刷新缓存-php版

WBOY
发布: 2016-06-20 12:26:24
原创
808 人浏览过

<br /><?php<br />function fixEncoding($in_str)<br />
登录后复制

{

$cur_encoding = mb_detect_encoding($in_str) ;

if($cur_encoding == "UTF-8" && mb_check_encoding($in_str,"UTF-8"))

return $in_str;

else

return utf8_encode($in_str);

}

function getSign($data,$key)

{

$dataList = array_keys($data);

sort($dataList);

$a = array();

foreach ($dataList as $value)

{

$b="$value=$data[$value]";

a

<br />
登录后复制

rray_push($a,$b);

}

$s = join("&",$a);

$s1 = $s.$key;

$s2 = fixEncoding($s1);

$sign = md5($s2);

return $sign;

}

function doPost($url,$postData){

$ch = curl_init ();

curl_setopt ( $ch, CURLOPT_URL, $url );

curl_setopt ( $ch, CURLOPT_CUSTOMREQUEST,"POST");

curl_setopt ( $ch, CURLOPT_HEADER, 0 );

curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 );

curl_setopt ( $ch, CURLOPT_POSTFIELDS, $postData);

$arr=curl_exec($ch);

curl_close($ch);

return $arr;

}

$username=******

$key=***********************

$cache_url ='http://agent.webluker.com/api/cacherefresh/';

if ($_SERVER['REQUEST_METHOD']=='POST'){

$get_url=trim($_POST['url']);

$a= str_replace("\n"," ,",$get_url);

$c = array(

"username" => "$username",

"refresh_url" => "['$a']",

"refresh_type" => "0",

);

$sign=getSign($c,$key);

$reurl=$c['refresh_url'];

$postData="username=$username&refresh_type=0&refresh_url=".$reurl."&sign=".$sign;

$result=doPost($cache_url,$postData);

}

?>


相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板