function app_request($str_method = "get", $with_sign = false)
{
if ($str_method == "post") {
$_num_appId = fn_post("app_id");
$_str_appKey = fn_post("app_key");
$_tm_time = fn_post("time");
if ($with_sign) {
$_str_sign = fn_post("signature");
}
} else {
$_num_appId = fn_get("app_id");
$_str_appKey = fn_get("app_key");
$_tm_time = fn_get("time");
if ($with_sign) {
$_str_sign = fn_get("signature");
}
}
$_arr_appId = validateStr($_num_appId, 1, 0, "str", "int");
switch ($_arr_appId["status"]) {
case "too_short":
return array("alert" => "x050203");
break;
case "format_err":
return array("alert" => "x050204");
break;
case "ok":
$_arr_appRequest["app_id"] = $_arr_appId["str"];
break;
}
$_arr_appKey = validateStr($_str_appKey, 1, 64, "str", "alphabetDigit");
switch ($_arr_appKey["status"]) {
case "too_short":
return array("alert" => "x050214");
break;
case "too_long":
return array("alert" => "x050215");
break;
case "format_err":
return array("alert" => "x050216");
break;
case "ok":
$_arr_appRequest["app_key"] = $_arr_appKey["str"];
break;
}
$_arr_time = validateStr($_tm_time, 1, 0, "str", "int");
switch ($_arr_time["status"]) {
case "too_short":
return array("alert" => "x050224");
break;
case "format_err":
return array("alert" => "x050225");
break;
case "ok":
$_arr_appRequest["time"] = $_arr_time["str"];
break;
}
$_tm_diff = $_arr_appRequest["time"] - time();
if ($_tm_diff > 1800 || $_tm_diff < -1800) {
return array("alert" => "x050227");
}
if ($with_sign) {
$_arr_sign = validateStr($_str_sign, 1, 0);
switch ($_arr_appId["status"]) {
case "too_short":
return array("alert" => "x050226");
break;
case "ok":
$_arr_appRequest["signature"] = $_arr_sign["str"];
break;
}
}
$_arr_appRequest["alert"] = "ok";
return $_arr_appRequest;
}