diff --git a/Application/Api/Common/index.html b/Application/Api/Common/index.html new file mode 100644 index 0000000000000000000000000000000000000000..0519ecba6ea913e21689ec692e81e9e4973fbf73 --- /dev/null +++ b/Application/Api/Common/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/Api/Conf/config.php b/Application/Api/Conf/config.php new file mode 100644 index 0000000000000000000000000000000000000000..cc42ec62ce868b8fa5c646a353acf38f8684b5d7 --- /dev/null +++ b/Application/Api/Conf/config.php @@ -0,0 +1,4 @@ +'配置值' +); \ No newline at end of file diff --git a/Application/Api/Conf/index.html b/Application/Api/Conf/index.html new file mode 100644 index 0000000000000000000000000000000000000000..0519ecba6ea913e21689ec692e81e9e4973fbf73 --- /dev/null +++ b/Application/Api/Conf/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/Api/Controller/UserController.class.php b/Application/Api/Controller/UserController.class.php new file mode 100644 index 0000000000000000000000000000000000000000..ff72387e8eb0ee8f509b0b719788ca8240cf4ae9 --- /dev/null +++ b/Application/Api/Controller/UserController.class.php @@ -0,0 +1,91 @@ +ajaxReturn ( array ( + 'state' => 601, + 'msg' => '参数不全', + 'data' => NULL + ) ); + exit (); + } + $type = 1; + if (preg_match ( '/^\d+$/', $username )) { + // 全数字 + if (preg_match ( '/^(0|86|17951)?(13[0-9]|15[012356789]|17[0678]|18[0-9]|14[57])[0-9]{8}$/', $username )) { + // 手机号 + $type = 3; + } else { + // uid + $type = 4; + } + } else { + if (preg_match ( '/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/', $username )) { + // 邮箱 + $type = 2; + } else { + // 用户名 + $type = 1; + } + } + $api = new UserApi (); + $result = $api->login ( $username, $password, $type ); + if ($result > 0) { + $this->ajaxReturn ( array ( + 'state' => 200, + 'msg' => '登录成功', + 'data' => array ( + 'uid' => $result + ) + ) ); + } else { + if ($result == - 1) { + $this->ajaxReturn ( array ( + 'state' => 404, + 'msg' => '用户不存在', + 'data' => NULL + ) ); + } + if ($result == - 2) { + $this->ajaxReturn ( array ( + 'state' => 401, + 'msg' => '密码错误', + 'data' => NULL + ) ); + } + } + } + + public function register(){ + $username = I ( 'username', '', 'text' ); + $nickname = I ( 'nickname', '', 'text' ); + $password = I ( 'password', '', 'text' ); + $email = I ( 'email', '', 'text' ); + $mobile = I ( 'mobile', '', 'text' ); + $nickname = ''; + $api = new UserApi (); + $result = $api->register($username, $nickname, $password, $email, $mobile); + if ($result > 0){ + $this->ajaxReturn ( array ( + 'state' => 200, + 'msg' => '注册成功', + 'data' => array ( + 'uid' => $result + ) + )); + }else{ + $this->ajaxReturn(array( + 'state' => 500, + 'msg' => '注册失败', + 'data' => NULL + )); + } + } +} \ No newline at end of file diff --git a/Application/Api/Controller/index.html b/Application/Api/Controller/index.html new file mode 100644 index 0000000000000000000000000000000000000000..0519ecba6ea913e21689ec692e81e9e4973fbf73 --- /dev/null +++ b/Application/Api/Controller/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/Api/Model/index.html b/Application/Api/Model/index.html new file mode 100644 index 0000000000000000000000000000000000000000..0519ecba6ea913e21689ec692e81e9e4973fbf73 --- /dev/null +++ b/Application/Api/Model/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/Api/View/index.html b/Application/Api/View/index.html new file mode 100644 index 0000000000000000000000000000000000000000..0519ecba6ea913e21689ec692e81e9e4973fbf73 --- /dev/null +++ b/Application/Api/View/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Application/Api/index.html b/Application/Api/index.html new file mode 100644 index 0000000000000000000000000000000000000000..0519ecba6ea913e21689ec692e81e9e4973fbf73 --- /dev/null +++ b/Application/Api/index.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/api.php b/api.php index c994238c4fdd05e9682e9df976a06d8e7e0abe7d..6310646872b1da5b944350822c366a0cd8949fe4 100644 --- a/api.php +++ b/api.php @@ -1,35 +1,7 @@ - */ -define ('OS_THEME_PATH', './Theme/'); define ( 'RUNTIME_PATH', './Runtime/' ); require './ThinkPHP/ThinkPHP.php'; \ No newline at end of file