|
@@ -17,20 +17,22 @@ class Base
|
|
|
{
|
|
|
|
|
|
protected $checkTokenOpen = false;//是否校验token
|
|
|
+ protected $checkApiSignOpen = false;//是否校验签名
|
|
|
public $user;//用户
|
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
{
|
|
|
- Log::record("---------------------------", "info");
|
|
|
+ Log::record("-------------start--------------", "info");
|
|
|
Log::record($_SERVER['REQUEST_METHOD'] . ' ' . getUrl(), 'info');
|
|
|
Log::record('REFERER ' . (array_key_exists('HTTP_REFERER', $_SERVER) ? $_SERVER['HTTP_REFERER'] : ""), 'info');
|
|
|
Log::record('GET ' . json_encode($_GET, JSON_UNESCAPED_UNICODE), 'info');
|
|
|
Log::record('POST ' . json_encode($_POST, JSON_UNESCAPED_UNICODE), 'info');
|
|
|
Log::record('cookie ' . json_encode($_COOKIE, JSON_UNESCAPED_UNICODE), 'info');
|
|
|
Log::record('input ' . json_encode(input('param.'), JSON_UNESCAPED_UNICODE), 'info');
|
|
|
- $this->checkApiSign();
|
|
|
-
|
|
|
+ if($this->checkApiSignOpen){
|
|
|
+ $this->checkApiSign();
|
|
|
+ }
|
|
|
if ($this->checkTokenOpen) {
|
|
|
$this->checkToken();
|
|
|
}
|
|
@@ -79,11 +81,11 @@ class Base
|
|
|
//以下部分根据自己的业务实现
|
|
|
|
|
|
//$field = "id,login_name,valid,last_login_time,login_count,token";
|
|
|
- $user = \app\common\model\User::where("token", "=", $token)->find();//找到token
|
|
|
+ /*$user = \app\common\model\User::where("token", "=", $token)->find();//找到token
|
|
|
if (!$user) {
|
|
|
$this->error(ErrorCode::getError(ErrorCode::CODE_TOKEN_ERR), ErrorCode::CODE_TOKEN_ERR);
|
|
|
}
|
|
|
- $this->user = $user;
|
|
|
+ $this->user = $user;*/
|
|
|
|
|
|
}
|
|
|
|
|
@@ -98,6 +100,7 @@ class Base
|
|
|
$res = returnFormat(0, $msg, $data);
|
|
|
|
|
|
Log::record("response:" . mb_substr(json_encode($res, JSON_UNESCAPED_UNICODE), 0, 1000) . ",code:0", "debug");
|
|
|
+ Log::record("-------------start--------------", "info");
|
|
|
throw new HttpResponseException(Response::create($res, "json"));
|
|
|
}
|
|
|
|
|
@@ -120,6 +123,7 @@ class Base
|
|
|
{
|
|
|
$res = returnFormat($code, $msg, $data);
|
|
|
Log::record("response:" . mb_substr(json_encode($res, JSON_UNESCAPED_UNICODE), 0, 1000) . ",code:" . $code, "debug");
|
|
|
+ Log::record("-------------start--------------", "info");
|
|
|
throw new HttpResponseException(Response::create($res, "json"));
|
|
|
}
|
|
|
|
|
@@ -166,8 +170,8 @@ class Base
|
|
|
|
|
|
if ($sign !== $sign2) {
|
|
|
Log::record("签名错误:sign: $sign sign2: $sign2", "debug");
|
|
|
- Log::record("sign2 签名key:".$secret,"debug");
|
|
|
- Log::record("sign2 签名字符串:".$signStr,"debug");
|
|
|
+ Log::record("sign2 签名key:" . $secret, "debug");
|
|
|
+ Log::record("sign2 签名字符串:" . $signStr, "debug");
|
|
|
$this->error("签名错误。" . $signStr);
|
|
|
}
|
|
|
}
|