Browse Source

fix bug

pull/119/head
xiaoz 2 years ago
parent
commit
e5f1a3709a
  1. 10
      class/Api.php

10
class/Api.php

@ -176,7 +176,9 @@ class Api {
$token_yes = md5(USER.$SecretKey); $token_yes = md5(USER.$SecretKey);
//获取header中的X-token //获取header中的X-token
$xtoken = $_SERVER['HTTP_X_TOKEN']; $xtoken = $_SERVER['HTTP_X_TOKEN'];
if( $xtoken === $token_yes ) {
//如果通过header传递token,且验证通过
if( !empty($xtoken) && ($xtoken === $token_yes) ) {
return TRUE; return TRUE;
} }
//如果token为空,则验证cookie //如果token为空,则验证cookie
@ -824,9 +826,9 @@ class Api {
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}"; $sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
} }
//通过header获取token成功 //通过header获取token成功
else if( $this->auth("") ) { // else if( $this->auth("") ) {
$sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}"; // $sql = "SELECT *,(SELECT name FROM on_categorys WHERE id = on_links.fid) AS category_name FROM on_links WHERE fid = $fid ORDER BY weight DESC,id DESC LIMIT {$limit} OFFSET {$offset}";
} // }
//如果token验证通过 //如果token验证通过
elseif( (!empty($token)) && ($this->auth($token)) ) { elseif( (!empty($token)) && ($this->auth($token)) ) {

Loading…
Cancel
Save