1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- <?php
- define("WEB_ROOT",__DIR__);
- define("WEB_ROOT_CONFIG",__DIR__."/config");
- include WEB_ROOT_CONFIG."/config.php";
- $type=trim($_SERVER['PATH_INFO']??"home",'/');
- //退出登录
- if(isset($_POST['a']) && strtolower($_SERVER['REQUEST_METHOD'])=="post" && $_POST['a']=='logout'){
- header("Content-type: text/json; charset=utf-8");
- if(!session_unset())exit(json_encode(array("code"=>0,"msg"=>"退出登录失败")));
- exit(json_encode(array("code"=>1,"msg"=>"退出成功")));
- }
- //回调
- if($type=="notify"){
- header("Content-type: text/json; charset=utf-8");
- file_put_contents(date("Y-m-d").'notify.log',date("H:i:s")."回调:".json_encode($_POST)."\r\n",FILE_APPEND);
- $data=[
- "sh_order"=>$_POST['sh_order']??"",
- "pt_order"=>$_POST['pt_order']??"",
- "money"=>$_POST['money']??"",
- "time"=>$_POST['time']??"",
- "status"=>$_POST['status']??"",
- ];
- if(isset($_POST['old_money']))$data['old_money']=($_POST['money']??"");
- ksort($data);
- $data['key']="37cd2d09c84f6ff7f1d28960ef82c4e533a3c047";
- $new_sign=md5(urldecode(http_build_query($data)));
- if($new_sign!=$_POST['sign'])exit("签名错误");
- $order_simit=$pdo->query("select * from recharge where `order_sn`='{$data['sh_order']}' and `app_order_sn`='{$data['pt_order']}' limit 1");
- $order=$order_simit->fetch(PDO::FETCH_ASSOC);
- if(empty($order))exit("订单不存在");
- $status=1;
- if($data['status']!="success")$status=2;
- $update_simit=$pdo->prepare('update recharge set status=? where `order_sn`=? and `app_order_sn`=?');
- $res=$update_simit->execute([$status,$data['sh_order'],$data['pt_order']]);
- if(!$res)exit("失败");
- exit("success");
- }
- if(!isset($_SESSION['admin_id']) && empty($_SESSION['admin_id']) && $type!="login" && $type!="register"){
- header("location:/login");
- }elseif(($type=="login" || $type=="register") && isset($_SESSION['admin_id'])){
- header("location:/home");
- }
- $file=WEB_ROOT."/{$type}.php";
- if(!is_file($file)){
- exit('<script src="//cdn.dnpw.org/404/v1.min.js" maincolor="#F00" jumptime="-1" jumptarget="/" tips="404" error="" charset="utf-8"></script>');
- }
- include_once WEB_ROOT."/{$type}.php";
|