/** * 强制修改密码执行页面 * @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; }
/** * Enable SSL support (not enabled by default) * pro: protect against replay attack * con: cookie's lifetime is limited to SSL session's lifetime * * @param bool $enable TRUE to enable, FALSE to disable */ public static function set_ssl($enable) { self::$_ssl = $enable; }
/** * 判断用户是否登录 * @return boolean */ public function isLogin() { if (null !== $this->isLogged) { return $this->isLogged; } else { $cookieManager = Base_Cookie::get($this->cookieName); @(list($id, $menu_group_id, $data_groups, $name, $reset_password) = explode(' ', Base_String::decode($cookieManager))); if ('' != $name && $id > 0) { $manager = array('name' => $name, 'id' => $id, 'reset_password' => $reset_password); $this->push($manager); $managerArr = $this->get($id); $this->menu_group_id = $managerArr['menu_group_id']; $this->data_groups = $managerArr['data_groups']; return $this->isLogged = true; } else { $this->logout(); } return $this->isLogged = false; } }
/** * 设置提示 * @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; }