diff --git a/firebase-jwt-test/api.php b/firebase-jwt-test/api.php index 9f38c3a..fc49c93 100644 --- a/firebase-jwt-test/api.php +++ b/firebase-jwt-test/api.php @@ -13,27 +13,42 @@ require DT_ROOT . '/include/post.func.php'; $gets = array( - 'login' + 'sell' ); $posts = array( 'login' ); -if ($_SERVER['REQUEST_METHOD'] == 'GET') { - if (in_array($action, $gets)) { - echo 'get'; - a_login('15612341234', '123456'); - } else { - die('40001'); - } -} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') { - echo 'post'; -} else { - 'ajax'; +init($gets, $posts); + +function init($gets, $posts) +{ + //无方法名拒绝请求 + if (!isset($_GET['action'])) { + die('无效的请求'); + } + //为防止方法冲突,所有方法追加前缀: k_ + $k_action = 'k_' . $_GET['action']; + // get 请求 + if ($_SERVER['REQUEST_METHOD'] == 'GET') { + if (in_array($_GET['action'], $gets)) { + $k_action(); + } else { + die("没有该方法"); + } + } + // post 请求 + if ($_SERVER['REQUEST_METHOD'] == 'POST') { + if (in_array($_GET['action'], $posts)) { + $k_action(); + } else { + die("没有该方法"); + } + } } -function a_login($username, $password) +function k_login($username, $password) { $username = trim($username); $password = trim($password); @@ -60,4 +75,19 @@ function a_login($username, $password) } $GLOBALS['db']->query("UPDATE {$GLOBALS['DT_PRE']}_memeber SET loginip='{$GLOBALS['DT_IP']}',logintime={$GLOBALS['DT_TIME']},logintimes=logintimes+1 WHERE userid={$user['userid']}"); return $user; +} + +function k_sell() +{ + $categories = $GLOBALS['db']->query("SELECT * FROM {$GLOBALS['DT_PRE']}category where moduleid=5 "); + if (!$categories) { + var_dump(mysql_error()); + } + $data = []; + if (mysql_num_rows($categories) > 0) { + while ($category = mysql_fetch_assoc($categories)) { + $data[] = $category; + } + } + var_dump($data); } \ No newline at end of file diff --git a/firebase-jwt-test/dostoon数据库表结构分析.md b/firebase-jwt-test/dostoon数据库表结构分析.md new file mode 100644 index 0000000..69bb8db --- /dev/null +++ b/firebase-jwt-test/dostoon数据库表结构分析.md @@ -0,0 +1,5 @@ +## destoon 产品分类 +功能 | 相关表 | 参数 | 说明 +--- | --- | --- | --- +在售分类| sell destoon_category | (modules=5) | 只有modules=5,即在售分类才展示给用户 +产品 | destoon_sell_5 | catid,status=3 | 包含产品信息与其公司信息 \ No newline at end of file