$value) { if (substr($name, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; } } return $headers; } } $headers = getallheaders(); function validSign() { // print_r($request->all());exit; $sign = isset($_POST['sign']) ? $_POST['sign'] : null; $time = isset($_POST['time']) ? $_POST['time'] : 0; $time = time() - $time; if (empty($sign) || $time >= 600) { return false; } $makesign = getSignature($_POST, SECRET_KEY); if ($makesign == $sign) { return true; } return false; } function getSignature($params, $secret_key) { // 按数组键名 正序排序 ksort($params); $tem = array(); foreach ($params as $k => $v) { if ($k !== 'sign') { $tem[] = "$k=$v"; } } $sk = implode('&', $tem) . $secret_key; $a['mm'] = $sk; return md5($sk); } function versionCompare($version1, $operator, $version2) { $_fv = intval(trim(str_replace('.', '', $version1))); $_sv = intval(trim(str_replace('.', '', $version2))); if (strlen($_fv) > strlen($_sv)) { $_sv = str_pad($_sv, strlen($_fv), 0); } if (strlen($_fv) < strlen($_sv)) { $_fv = str_pad($_fv, strlen($_sv), 0); } return version_compare((string) $_fv, (string) $_sv, $operator); } $url = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : null; //todo sign验证 //if (!validSign()) { // $data = []; // $data['rst'] = ["data" => "illegal request"]; // $data['errno'] = 1008; // $data['err'] = "非法请求"; // $data['timestamp'] = time(); // exit(json_encode($data)); //}