Exemplo n.º 1
0
 /**
  * 验证码输出
  */
 public function indexAction()
 {
     $namespace = $this->_request->getQuery('ns', 'default');
     $size = $this->_request->getQuery('sz');
     $bootstrap = $this->getInvokeArg('bootstrap');
     // Don't auto render this action
     $this->_helper->viewRenderer->setNoRender();
     $options = $bootstrap->getOption('seccode');
     // 设置大小
     if (false !== strpos($size, 'x')) {
         list($w, $h) = explode('x', $size, 2);
         if (abs((int) $w) && abs((int) $h)) {
             $options['image']['width'] = abs((int) $w);
             $options['image']['height'] = abs((int) $h);
         }
     }
     Oray_Seccode::getInstance()->setConfig($options)->display(Oray_Seccode::TYPE_IMAGE, Oray_Seccode::LENGTH_DEFAULT, $namespace);
 }
Exemplo n.º 2
0
 /**
  * 管理员登录流程
  *
  * /login/login-admin
  */
 public function loginAdminAction()
 {
     // 未登录前台
     if (!$this->_user->isLogined()) {
         $referer = $this->options['sites']['www'];
         if (!empty($this->session->auth['referer'])) {
             $referer = $this->session->auth['referer'];
         }
         return $this->referer($referer);
     }
     // 非管理员身份
     if (!$this->_user->isAdmin() && !$this->_user->isOwner()) {
         PROTOCOL . '//' . $this->getServer($this->_user->orgId) . '/admin/login/?err=timeout';
     }
     $email = $this->_request->getPost('email');
     $password = $this->_request->getPost('password');
     $seccode = $this->_request->getPost('seccode');
     $error = null;
     do {
         if (empty($email)) {
             $error = 'invalid email';
             break;
         }
         if (empty($password)) {
             $error = 'invalid password';
             break;
         }
         if (empty($seccode)) {
             $error = 'unvalid seccode';
             break;
         }
         if (!Oray_Seccode::isValid($seccode, 'adlogin')) {
             $error = 'invalid seccode';
             break;
         }
         Oray_Seccode::clear('adlogin');
         $adapter = new Tudu_Auth_Adapter_Admin(array('db' => Tudu_Dao_Manager::getDb(Tudu_Dao_Manager::DB_MD)));
         $adapter->setUsername($email)->setPassword($password);
         $result = $adapter->authenticate();
         if (!$result->isValid()) {
             $message = $result->getMessages();
             $error = isset($message[0]) ? $message[0] : 'failure';
             break;
         }
     } while (false);
     if (null !== $error) {
         return $this->referer(PROTOCOL . '//' . $this->getServer($this->_user->orgId) . '/admin/login/?err=' . $error);
     }
     $this->session->admin = array_merge($result->getIdentity(), array('logintime' => time()));
     //$this->_user->initAdmin($this->session->admin);
     // 添加登入日志
     $daoLog = Tudu_Dao_Manager::getDao('Dao_Md_Log_Oplog', Tudu_Dao_Manager::DB_MD);
     $clientIp = isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $this->_request->getClientIp();
     $ret = $daoLog->createAdminLog(array('orgid' => $this->_user->orgId, 'userid' => $this->_user->userId, 'ip' => $clientIp, 'module' => Dao_Md_Log_Oplog::MODULE_LOGIN, 'action' => Dao_Md_Log_Oplog::OPERATION_LOGIN, 'subaction' => null, 'target' => implode(':', array($this->_user->orgId, $this->_user->address, $this->_user->uniqueId)), 'local' => !empty($this->session->auth['local']) ? $this->session->auth['local'] : null, 'detail' => serialize(array('account' => $this->_user->userName))));
     return $this->referer(PROTOCOL . '//' . $this->getServer($this->_user->orgId) . '/admin/');
 }
Exemplo n.º 3
0
 /**
  * Enter description here...
  *
  * @return Oray_Seccode
  */
 public function setConfig($config)
 {
     if (isset($config['fontPath'])) {
         self::$fontPath = $config['fontPath'];
     }
     if (isset($config['dataPath'])) {
         self::$dataPath = $config['dataPath'];
     }
     if (isset($config['units'])) {
         $this->_units = $config['units'];
     }
     if (isset($config['image'])) {
         unset($config['image']['fontPath']);
         unset($config['image']['dataPath']);
         $this->getImage()->setConfig($config['image']);
     }
     return $this;
 }