cdnflydadao/web/update.php
2022-07-12 17:43:29 +02:00

30 lines
981 B
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// 更新cdnfly最新版本信息
error_reporting(0);
header('Content-Type: text/html; charset=UTF-8');
$url = 'https://update.cdnfly.cn/master/upgrades?version_num=';
$data = send_request($url);
$arr = json_decode($data, true);
if(!$arr)exit('获取cdnfly版本信息失败json解析失败');
if($arr['code']!=0 || !$arr['data'] || count($arr['data'])==0)exit('获取cdnfly版本信息失败'.$data);
$info = $arr['data'][0];
if(file_put_contents('version.json', json_encode($info))){
exit('保存cdnfly版本信息成功');
}else{
exit('保存cdnfly版本信息失败可能无文件写入权限');
}
function send_request($url){
$ch=curl_init($url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$res=curl_exec($ch);
curl_close($ch);
return $res;
}