123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- <?php
- class UserController
- {
-
- private $returnJson = array('type' => 'user');
-
- public function __construct()
- {
-
- $server = new GuestModule;
- if (!$server->checkLogin()) {
- $this->returnJson['statusCode'] = '120005';
- exitOutput($this->returnJson);
- }
- }
-
- public function logout()
- {
- @session_start();
- @session_destroy();
- $this->returnJson['statusCode'] = '000000';
- exitOutput(json_encode($this->returnJson));
- }
-
- public function changePassword()
- {
- $oldPassword = securelyInput('oldPassword');
- $newPassword = securelyInput('newPassword');
- if (!preg_match('/^[0-9a-zA-Z]{32}$/', $newPassword) || !preg_match('/^[0-9a-zA-Z]{32}$/', $oldPassword)) {
-
- $this->returnJson['statusCode'] = '130002';
- } elseif ($oldPassword == $newPassword) {
-
- $this->returnJson['statusCode'] = '000000';
- } else {
- $server = new UserModule;
- $result = $server->changePassword($oldPassword, $newPassword);
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- } else {
- $this->returnJson['statusCode'] = '130006';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function changeNickName()
- {
- $nickNameLength = mb_strlen(quickInput('nickName'), 'utf8');
- $nickName = securelyInput('nickName');
- if ($nickNameLength > 20) {
-
- $this->returnJson['statusCode'] = '130008';
- } else {
- $server = new UserModule;
- $result = $server->changeNickName($nickName);
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- } else {
- $this->returnJson['statusCode'] = '130009';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function confirmUserName()
- {
- $userName = securelyInput('userName');
-
- if (!preg_match('/^[a-zA-Z][0-9a-zA-Z_]{3,59}$/', $userName)) {
-
- $this->returnJson['statusCode'] = '130001';
- } else {
- $server = new UserModule;
- $result = $server->confirmUserName($userName);
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- } else {
- $this->returnJson['statusCode'] = '130010';
- }
- }
- exitOutput($this->returnJson);
- }
-
- public function getUserInfo()
- {
- $server = new UserModule;
- $result = $server->getUserInfo();
- if ($result) {
- $this->returnJson['statusCode'] = '000000';
- $this->returnJson['userInfo'] = $result;
- } else {
- $this->returnJson['statusCode'] = '130013';
- }
- exitOutput($this->returnJson);
- }
- }
- ?>
|