1 Star 1 Fork 0

涛之雨/php_url_sign

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
s.php 2.38 KB
一键复制 编辑 原始数据 按行查看 历史
涛之雨 提交于 2020-05-26 22:48 . Update s.php
<?php
header("Content-type: text/html; charset=utf-8");
$user_id= $_GET['i'];//QQ号,5~15位,非0开头数字
$user_number=$_GET['n'];//10位数字,过期时间
$user_exp= $_GET['e'];//过期时间,时间戳,十位数字,永久为十个9
$user_key= $_GET['k'];//这里是固定值,防止被后台地址泄露
$user_isShorten= $_GET['u'];//是否生成短连接
$url="links.php";//订阅的主php
$shortenUrl="这里是短网址的api,我采用的是yourls";
$My_key='这里是个人混淆参数(可以这样理解吧,需要把获取签名和订阅的两个地方的设置成相同参数)';
if(!preg_match("/^[1-9]\\d{4,14}$/",$user_id)||
!preg_match("/^\\d{9,10}$/",$user_exp)||
!preg_match("/^\\d+$/",$user_number)||
$user_key!="233333333"){
//最后这个k防止被后台地址泄露
echo "参数错误!";
return;
}
if($user_isShorten=="1"){
$apistr=file_get_contents($shortenUrl.$url . "?i=".urlencode( $user_id . "&n=" . $user_number . "&e=". $user_exp . "&s=" . getSign($user_id,$user_number,$user_exp,$user_sign,$My_key)));
//echo $apistr.PHP_EOL."---------------------".PHP_EOL;
$apiobj=simplexml_load_string($apistr);//解析xml代码
//var_dump($apiobj);
$surl=(string)$apiobj->shorturl;//yourls的api范湖的xml数据解析出
echo $surl;
}else{
echo $url . "?i=". $user_id . "&n=" . $user_number . "&e=". $user_exp . "&s=" . getSign($user_id,$user_number,$user_exp,$user_sign,$My_key);
}
function getSign($user_id,$user_number,$user_exp,$user_sign,$My_key){
return substr (md5(substr(md5 (md5($user_id.$user_number).$user_exp),0,5).$My_key),0,30);//算法随便改,只要获取签名和订阅的两个地方的设置成相同方法就成
}
function getShortenUrl($url, $args=null, $method="post", $withCookie = false, $timeout = CURL_TIMEOUT, $headers=array())
{
$ch = curl_init();
$data = convert($args);
if($data){
if(stripos($url, "?") > 0){
$url .= "&$data";
}else{
$url .= "?$data";
}
}
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if(!empty($headers))
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
if($withCookie)
{
curl_setopt($ch, CURLOPT_COOKIEJAR, $_COOKIE);
}
$r = curl_exec($ch);
curl_close($ch);
return $r;
}
?>
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/taozhiyu/php_url_sign.git
git@gitee.com:taozhiyu/php_url_sign.git
taozhiyu
php_url_sign
php_url_sign
master

搜索帮助