您好,登錄后才能下訂單哦!
<?php function fixEncoding($in_str) { $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]"; array_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); } ?>
寫這個腳本純粹是為了減少工作量。公司目前在使用webluker這塊CDN加速軟件。當頁面更新時,需要到webluker中刷新下頁面。如果把刷新頁面的工作給非技術部門同事去做的話必須提供webluker的賬號密碼才行。于是就出現了上面這段代碼,提供個頁面給他們使用且不提供密碼。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。