示例#1
0
 public function indexAction()
 {
     $this->forceInstall();
     $session = new USession($this);
     $uid = $session->getUid();
     $urlHandler = $this->getApp()->getUrlHandler();
     if ($uid == 0) {
         $signInUrl = $urlHandler->createUrl('web/SignIn', 'index', array());
         header('Location: ' . $signInUrl);
         return;
     }
     $user = new UserModel($this);
     $uid = $session->getUid();
     $rand = $session->createNewSid();
     $session->getSessionData()->set('rand', $rand);
     $userInfo = $user->getUidInfo($uid, array('username', 'nickname', 'user_img', 'regtime'));
     $isAdmin = $user->isSuperAdmin($uid);
     $session = null;
     $siteInfoM = new SiteModel($this);
     $siteInfo = $siteInfoM->getSiteInfo(array('sitename'));
     $title = $siteInfo['sitename'] . ' › ' . $userInfo['nickname'];
     Templatel::tplStart();
     include Templatel::view('/userindex.html');
     Templatel::tplEnd();
 }
示例#2
0
 /**
  * 处理提交的安装表单
  *
  * @return void
  */
 public function doAction()
 {
     $installModel = new InstallModel($this);
     $errArr = array();
     $installStep = 0;
     if ($installModel->hasInstalled()) {
         $installStep = 3;
         $this->showInstallForm($installStep, $errArr);
         return;
     }
     if (!$installModel->statReady()) {
         $errArr[] = $installModel->getErrMsg();
     }
     // 检测post提交的数据
     $user = new UserModel($this);
     $postData = new DataMap($_POST);
     $username = $postData->get('username', '');
     $nickname = $postData->get('nickname', '');
     $email = $postData->get('email', '');
     if (!$user->isUsername($username)) {
         $errArr[] = $user->getErrMsg();
     }
     if (!$user->isNickname($nickname)) {
         $errArr[] = $user->getErrMsg();
     }
     if (!$user->isEmail($email)) {
         $errArr[] = $user->getErrMsg();
     }
     $pass1 = $postData->get('pass1', '');
     $pass2 = $postData->get('pass2', '');
     if ($pass1 != $pass2) {
         $errArr[] = '两次输入的密码不一致';
     }
     if (!$user->isPass($pass1)) {
         $errArr[] = $user->getErrMsg();
     }
     if (!empty($errArr)) {
         $installStep = 1;
         $this->showInstallForm($installStep, $errArr);
         return;
     }
     // 执行安装操作
     $installModel->initDb();
     // 添加管理员账号
     $uid = $user->addAccount($username, $nickname, $pass1, $email);
     if ($uid == -1) {
         $installStep = 1;
         $this->showInstallForm($installStep, array('添加用户账号失败'));
         return;
     }
     // 添加管理员权限
     $user->addSuperAdmin($uid);
     $installStep = 2;
     $this->showInstallForm($installStep, array());
 }
示例#3
0
 public function doAction()
 {
     $this->forceInstall();
     $session = new USession($this);
     $sessionData = $session->getSessionData();
     //判断用户是否已登录
     if ($session->getUid() != 0) {
         header('Location: /');
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->showLoginForm();
         return;
     }
     $postData = new DataMap($_POST);
     $user = new UserModel($this);
     $errArr = array();
     $username = $postData->get('username', '');
     $pass = $postData->get('pass', '');
     $rcodePost = $postData->get('rcode', '');
     $rcode = $sessionData->get('rcode', '');
     $sessionData->set('rcode', '');
     $urlPost = $postData->get('url', '');
     $loginType = 1;
     if ($user->isUsername($username)) {
         $loginType = 1;
     } elseif ($user->isEmail($username)) {
         $loginType = 2;
     } else {
         $errArr[] = '请输入正确的用户名或者邮箱地址';
     }
     if (!$user->isPass($pass)) {
         $errArr[] = $user->getErrMsg();
     }
     if ($rcode == '') {
         $errArr[] = '请打开验证码图片显示';
     }
     if (strcasecmp($rcodePost, $rcode) != 0) {
         $errArr[] = '验证码输入有误';
     }
     if (!empty($errArr)) {
         $this->showLoginForm('', $errArr);
         return;
     }
     // 判断用户名是否存在
     if ($loginType == 1 && !$user->isUsernameExists($username)) {
         $errArr[] = '用户名' . $username . '不存在';
     }
     if ($loginType == 2 && !$user->isEmailExists($username)) {
         $errArr[] = '邮箱' . $username . '不存在';
     }
     if (!empty($errArr)) {
         $this->showLoginForm('', $errArr);
         return;
     }
     $uid = $user->authPass($username, $pass, $loginType);
     if ($uid == -1) {
         if ($loginType == 1) {
             $errArr[] = '用户名或密码错误';
         } elseif ($loginType == 2) {
             $errArr[] = '邮箱或密码错误';
         }
         $this->showLoginForm('', $errArr);
     } else {
         $session->setUid($uid);
         $session->updateLifetime(30 * 24 * 3600);
         $url = $postData->get('url', '');
         if (empty($url)) {
             $urlHandler = $this->getApp()->getUrlHandler();
             $url = $urlHandler->createUrl('web/Index', 'index', array(), false);
         }
         header('Location: ' . $url);
     }
 }
示例#4
0
 /**
  * 表单处理
  *
  * @return void
  */
 public function doAction()
 {
     $this->forceInstall();
     $session = new USession($this);
     $sessionData = $session->getSessionData();
     //判断用户是否已登录
     if ($session->getUid() != 0) {
         header('Location: /');
         return;
     }
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->showRegForm();
         return;
     }
     $postData = new DataMap($_POST);
     $user = new UserModel($this);
     $errArr = array();
     $username = $postData->get('username', '');
     $nickname = $postData->get('nickname', '');
     $email = $postData->get('email', '');
     $pass1 = $postData->get('pass1', '');
     $pass2 = $postData->get('pass2', '');
     $rcodePost = $postData->get('rcode', '');
     $rcode = $sessionData->get('rcode', '');
     $sessionData->set('rcode', '');
     if (!$user->isUsername($username)) {
         $errArr[] = $user->getErrMsg();
     }
     if (!$user->isNickname($nickname)) {
         $errArr[] = $user->getErrMsg();
     }
     if (!$user->isEmail($email)) {
         $errArr[] = $user->getErrMsg();
     }
     if ($pass1 != $pass2) {
         $errArr[] = '两次输入的密码不一致';
     }
     if (!$user->isPass($pass1)) {
         $errArr[] = $user->getErrMsg();
     }
     if ($rcode == '') {
         $errArr[] = '请打开验证码图片显示';
     }
     if (strcasecmp($rcodePost, $rcode) != 0) {
         $errArr[] = '验证码输入有误';
     }
     if (!empty($errArr)) {
         $this->showRegForm('', $errArr);
         return;
     }
     // 判断用户名、邮箱是否已经被使用
     if ($user->isUsernameExists($username)) {
         $errArr[] = '用户名' . $username . '已经被注册了';
     }
     if ($user->isEmailExists($email)) {
         $errArr[] = '邮箱' . $email . '已经被使用了';
     }
     if (!empty($errArr)) {
         $this->showRegForm('', $errArr);
         return;
     }
     // 添加账号
     $uid = $user->addAccount($username, $nickname, $pass1, $email);
     if ($uid == -1) {
         $errArr[] = '注册账号失败,请稍后再试';
         $this->showRegForm('', $errArr);
     } else {
         $this->showRegOk($uid);
     }
 }
示例#5
0
 /**
  * 处理异步提交过来的站点配置的修改
  * 
  * @return void
  */
 public function saveConfAction()
 {
     $this->forceInstall();
     $session = new USession($this);
     $uid = $session->getUid();
     $urlHandler = $this->getApp()->getUrlHandler();
     if ($uid == 0) {
         $signInUrl = $urlHandler->createUrl('web/SignIn', 'index', array());
         header('Location: ' . $signInUrl);
         return;
     }
     $user = new UserModel($this);
     $isAdmin = $user->isSuperAdmin($uid);
     if (!$isAdmin) {
         $this->needAdmin();
         return;
     }
     $postData = new DataMap($_POST);
     $sitename = $postData->get('sitename', '');
     $noticeOn = $postData->get('notice_on', 0);
     $noticeText = $postData->get('notice_text', '');
     $openCompress = $postData->get('open_compress', 0);
     $siteM = new SiteModel($this);
     $newSets = array();
     $newSets['sitename'] = $sitename;
     $newSets['notice_on'] = $noticeOn == 0 ? '0' : '1';
     $newSets['notice_text'] = $noticeText;
     $newSets['open_compress'] = $openCompress == 0 ? '0' : '1';
     $siteM->updateSiteInfo($newSets);
     $ajaxReturn = array('success' => true);
     $this->jsonReturn($ajaxReturn);
 }
示例#6
0
 /**
  * 添加板块的ajax异步请求
  * 
  * @return void
  */
 public function addbkAction()
 {
     $this->forceInstall();
     $session = new USession($this);
     $uid = $session->getUid();
     $urlHandler = $this->getApp()->getUrlHandler();
     if ($uid == 0) {
         $signInUrl = $urlHandler->createUrl('web/SignIn', 'index', array());
         header('Location: ' . $signInUrl);
         return;
     }
     $user = new UserModel($this);
     $isAdmin = $user->isSuperAdmin($uid);
     if (!$isAdmin) {
         $this->needAdmin();
         return;
     }
     $bkM = new BkModel($this);
     $postData = new DataMap($_POST);
     $pid = intval($postData->get('pid', 0));
     $bkname = $postData->get('bkname', '新节点');
     //判断父节点pid是否存在
     if (!$bkM->bkIdExists($pid)) {
         $arr = array('success' => false);
     } else {
         $bkid = $bkM->createBk($pid, $bkname);
         $arr = array('success' => true);
         $arr['nodeInfo'] = array('id' => $bkid, 'pId' => $pid, 'isParent' => false, 'name' => $bkname);
     }
     $this->jsonReturn($arr);
 }