$val){ $sb .= $key . '=' . $val . '&'; } $sb .= $xpp_key; $server_sign = md5($sb); //将sign与客户端传过来的sign进行比对,如不一样则可能是中途被篡改参数,服务器拒绝此次请求 if($server_sign !== $client_sign){ echo json_encode(array('code'=>'invalid request')); exit; } //将sign与session中的sign对比,如果一样,则为重复提交,服务器拒绝此次请求 if($server_sign == $_SESSION['last_sign']){ echo json_encode(array('code'=>'Repeated requests')); exit(); } //此次的sign存入session $_SESSION['last_sign'] = $server_sign; //执行路由cmd(base64解析后),将参数带到该方法中 $cmd = base64_decode($param['cmd']); list($__controller,$__action) = explode('-' , $cmd); // 设置请求参数 unset($param['cmd']); unset($param['timestamp']); foreach($param as $key => $val){ $_REQUEST[$key] = $val; }