简介:
子比主题7.4绕授权接口源码,仅包含api文件仅供学习参考!正版子比主题7.4请到官方下载这里不提供。
使用方法:
1.搭建一个站点,绑定apizibl.com域名,并开启SSL (随便找个域名的证书就行)
2.上传以上源码,并配置好伪静态最后在/etc/hosts里面加一行127.0.0.1 apiZibll.com
3.Nginx伪静态
location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php/$1 last; break; } } 代码:
<?php $url = $_SERVER['REQUEST_URI']; function getRandom($length) { $characters = 'abcdefghijklmnopqrstuvwxyz1234567890'; $randomString = ''; for ($i = 0; $i < $length; $i++) { $index = rand(0, strlen($characters) - 1); $randomString .= $characters[$index]; } return $randomString; } function generate_randstr($url) { $key = strrev(md5($url)); $num1 = rand(70,99); $num1r = strrev(strval($num1)); $num2 = rand(70,99); $num2r = strrev(strval($num2)); $key = substr($key,22).substr($key,0,22); $keystr = substr_replace($key,getRandom(3),$num1-69,0); $randstr = getRandom(3).$num1r.getRandom(rand(5,10)).$keystr.getRandom(100-$num2).$num2r; return $randstr; } header('Content-Type: application/json; charset=UTF-8'); if(strpos($url, '/api/auth') !== false){ $time = time(); $token = md5(uniqid(mt_rand(), true) . microtime()); $randstr = generate_randstr($_POST['url']); $sign = md5($randstr.$time.$token.'ok'); $data = ['error'=>true, 'error_code'=>0, 'msg'=>'', 'time'=>$time, 'token'=>$token, 'randstr'=>$randstr, 'code'=>base64_encode('恭喜您,授权验证成功'), 'sign'=>$sign]; echo json_encode($data); } elseif(strpos($url, '/api/update') !== false){ $version = $_POST['version']; $data = ['result'=>false, 'aut_error'=>false, 'msg'=>'暂无更新,您当前的版本已是最新版', 'version'=>$version]; echo serialize($data); }