/**
  * 强制修改密码执行页面
  * @author 陈晓东
  */
 public function pwdcompelUpdateAction()
 {
     /**
      * 记录日志
      */
     $log = "强制修改密码执行页面\n\nServerIp:\n" . $this->request->getServer('SERVER_ADDR') . "\n\nGET:\n" . var_export($_GET, true) . "\n\nPOST:\n" . var_export($_POST, true);
     $this->oLogManager->push('log', $log);
     $id = trim($this->request->id);
     //用户ID
     $newpasswd = trim($this->request->newpasswd);
     //新密码
     $confirm = trim($this->request->confirm);
     //确认密码
     $group_id = $this->request->group_id;
     //用户组
     $password = $this->manager->getOne($id, 'password');
     if ($newpasswd != '') {
         if ($newpasswd != $confirm) {
             $response = array('errno' => 2);
             echo json_encode($response);
             return false;
         }
         if (strlen($newpasswd) < 6 || strlen($newpasswd) > 18) {
             $response = array('errno' => 3);
             echo json_encode($response);
             return false;
         }
         //密码强度检测
         if (strlen($newpasswd) < 7) {
             $response = array('errno' => 5);
             echo json_encode($response);
             return false;
         }
         $bind['password'] = md5($newpasswd);
         $bind['reset_password'] = 0;
     }
     $res = $this->manager->update($id, $bind);
     if ($res) {
         $response = array('errno' => 0);
         $cookieManager = Base_String::encode($this->manager->id . ' ' . $this->manager->group_id . ' ' . $this->manager->name . ' ' . '0');
         Base_Cookie::set('__Base_Manager', $cookieManager, 0);
     } else {
         $response = array('errno' => 9);
     }
     echo json_encode($response);
     return true;
 }
Example #2
0
 /**
  * 登录
  * @param string $name
  * @param string $passwd
  * @param integer $expired
  * @return boolean
  */
 public function login($name, $password, $expired = 0)
 {
     $manager = $this->getRowByName($name, '`id`, `name`, `password`, `menu_group_id`, `data_groups`, `reset_password`');
     $expired = intval($expired);
     if ($manager && md5($password) == $manager['password']) {
         $cookieManager = Base_String::encode($manager['id'] . ' ' . $manager['menu_group_id'] . ' ' . $manager['data_groups'] . ' ' . $manager['name'] . ' ' . $manager['reset_password']);
         Base_Cookie::set($this->cookieName, $cookieManager, $expired);
         $bind = array();
         $bind['last_login'] = Base_Registry::get('timestamp');
         $bind['last_active'] = Base_Registry::get('timestamp');
         $bind['last_ip'] = Base_Controller_Request_Http::getInstance()->getIp();
         $this->update($manager['id'], $bind);
         unset($manager['password']);
         $this->push($manager);
         $this->isLogged = true;
         return true;
     }
     $this->isLogged = false;
     return false;
 }
Example #3
0
 /**
  * 设置提示
  * @param string $message
  * @param string $type notice|warning|error
  */
 public function set($message, $type = 'notice')
 {
     $value = json_encode(array('type' => $type, 'message' => $message));
     Base_Cookie::set($this->key, $value);
     return $this;
 }