public function login() { if (isLogin()) { $this->success('你已经登陆了!如果想切换账户请先退出!'); exit; } if (!$this->isPost()) { $this->display('', '登陆'); exit; } //登陆 $username = $this->_post('username', 'mysql_escape_string'); $password = $this->_post('password', 'mysql_escape_string'); if (!($burl = $this->_get('burl'))) { $burl = __APP__ . '/'; } $model = M("User"); $data = $model->where("username='******' or email='{$username}'")->find(); //验证 if ($data) { $password_hash = pwdHash($password . $data['salt']); if ($password_hash == $data['password']) { //登陆成功 session("user_info", $data); redirect($burl); } else { $this->error("用户或密码不对"); } } else { $this->error("用户或密码不对"); } }
/** * 登陆 * @param string $callback 登陆成功后的回调地址 */ public function index($callback = '') { if (IS_POST) { $validate = Loader::validate('Login'); $data = $this->request->post(); if (config('verify_code')) { $validateResult = $validate->check($data); } else { $validateResult = $validate->scene('not_verify')->check($data); } if (!$validateResult) { return $this->error($validate->getError(), ''); } $user = Db::name('Member')->where('account', $data['account'])->find(); if (!$user) { return $this->error('用户不存在', ''); } elseif ($user['status'] != 1) { return $this->error('用户被禁用', ''); } elseif ($user['password'] != umd5($data['password'])) { logs('登陆失败:密码错误', '', $user['id']); return $this->error('密码错误', ''); } else { self::autoLogin($user); return $this->success('登陆成功', $callback ? $callback : url('system/index/index')); } } else { if (isLogin()) { $this->redirect(url('system/index/index')); } return view(); } }
function __construct() { parent::__construct(); if (!isLogin()) { redirect(__APP__ . '/User/login/'); } }
public function _initialize() { if (!isLogin()) { cookie('__login_return_url__', $_SERVER['REQUEST_URI']); $this->error('请先登录', U('Member/login')); } }
public function login() { if (isLogin()) { redirect(U('index/index')); } $this->display(); }
function v_toolIcon($item) { if (isLogin() === true) { $icon = new toolIcon(); echo $icon->{$item}; } }
public function Logout() { parent::__construct(); if (!isLogin()) { redirect('user/login'); } }
public function run(&$params) { if (isLogin()) { $userinfo = login(); defined('UID') or define('UID', $userinfo['id']); } }
/** * getCategories function * this funciton is to get the list of all those categories which accessable to the current logged in user,. exculded arvind IT users, * it will also give the list of categories under a particluar brand if brand if is provided in parameters. * @todo get the details of a particular id id category id is provided * @param id - category id, to get the details of a particular category * @param brand_id - get the list of categories under this brand_id * @return stdObject * @author Ankit Balyan - sf.ankit@gmail.com **/ function getCategories($id = NULL, $brand_id = NULL) { global $wpdb; $user_id = isLogin(); if ($id) { return array(); } else { if (!isArvindUser()) { $sql = "SELECT \n\t\t\t\t\t category.*\n\t\t\t\t\tFROM\n\t\t\t\t\t rw_category AS category\n\t\t\t\t\t LEFT OUTER JOIN\n\t\t\t\t\t rw_brand_user_map AS user_brand ON user_brand.user_id = {$user_id}\n\t\t\t\t\t LEFT OUTER JOIN\n\t\t\t\t\t rw_brands AS brand ON brand.brand_id = user_brand.brand_id\n\t\t\t\t\t OR brand.brand_parent_id = user_brand.brand_id\n\t\t\t\t\t LEFT OUTER JOIN\n\t\t\t\t\t rw_brand_category_map AS brand_category \n\t\t\t\t\t\t\tON brand_category.brand_id = brand.brand_id\n\t\t\t\t\tWHERE\n\t\t\t\t\t category.category_id = brand_category.category_id"; if (count($brand_id)) { if (is_array($brand_id)) { $i = 0; foreach ($brand_id as $key => $id) { if ($i == 0) { $sql .= " and ( brand_category.brand_id = {$id} "; } else { $sql .= " or brand_category.brand_id = {$id} "; } $i++; } $sql .= " ) "; } else { $sql .= isset($brand_id) ? " and brand_category.brand_id = {$brand_id}" : ""; } } $sql .= " group by category.category_id"; } else { $sql = "SELECT * FROM rw_category"; } } return $wpdb->get_results($sql); }
/** * 该类创建对象时,会执行的方法 */ public function _initialize() { if (!isLogin()) { cookie('__LOGIN_RETURN_URL__', $_SERVER['REQUEST_URI']); $this->error('请登录!', U('Member/login')); } }
public function run(&$params) { //Behavior的行为是在加载控制器之前,也包含了登录页面的控制器和验证码,所以要先排除掉; //>>1.定义不验证的控制器和方法 $notInclude = array('Login/checkLogin', 'Verify/index'); //定义当前访问的控制器和方法 $ongoing = CONTROLLER_NAME . '/' . ACTION_NAME; if (in_array($ongoing, $notInclude)) { return false; } //判断用户是否登录 if (!isLogin()) { $LoginService = D('Login', 'Service'); //判断用户是否自动登录 if (!$LoginService->autoLogin()) { redirect(U('Login/checkLogin'), 1, '请登录'); } } if (superUser()) { return false; } //得到当前用户的权限 $userUrl = savePermissionURL(); if (!in_array($ongoing, $userUrl)) { echo "权限不足"; exit; } }
protected function _initialize() { $this->_name = CONTROLLER_NAME; if (isLogin()) { define('AID', isLogin()); $this->uid = decrypt(cookie('admin_id')); $this->admin_name = decrypt(cookie('admin_name')); $this->assign('admin_name', $this->admin_name); } else { $this->redirect('Public/login'); exit; } import('ORG.Util.Auth'); //加载类库 $auth = new Auth(); if (in_array(isLogin(), C("ADMINISTRATOR"))) { return true; } else { if ($auth->check(CONTROLLER_NAME . '-*', isLogin())) { true; } elseif (!$auth->check(CONTROLLER_NAME . '-' . ACTION_NAME, isLogin())) { echo CONTROLLER_NAME . '-' . ACTION_NAME; die; $this->error('你没有权限'); } } }
function ctreateAccount($link, $userLogin, $userPassword, $userType) { if (!isLogin($userLogin)) { return 'login_encorretcted'; } elseif (!isPassword($userPassword)) { return 'password_encorretcted'; } elseif ($userType == 0 || $userType > 3) { return 'user_type_encorretcted'; } else { $res = mysqli_query($link, "SELECT `user_id` FROM `users` WHERE `user_login`='{$userLogin}'"); $userId = mysqli_fetch_assoc($res); if (isset($userId['user_id'])) { return 'login_found'; } else { $addUserPass = md5(PASSWORD_SALT . $userPassword); $firstIp = $_SERVER['REMOTE_ADDR']; if (mysqli_query($link, "INSERT INTO `users`(`user_login`, `user_password`,`user_type`, `exp`, `money`, `gold`, `user_access`, `user_location_type`, `user_location`,`user_galaxy`, `first_ip`) VALUES ('{$userLogin}','{$addUserPass}','{$userType}',0, 15000, 0, 5,'p',1,1,'{$firstIp}')")) { $insertId = mysqli_insert_id($link); mysqli_query($link, "INSERT INTO `user_galaxy`(`user_id`, `user_galaxy_id`) VALUES ('{$insertId}',1)"); return 'complete'; } else { return 'no_wrtite_to_db'; } } } }
protected function _initialize() { $url = urlencode('http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING']); if (!isLogin()) { $this->error('非法进入', U('Index/login')); } }
public function run(&$params) { //>>1.定义不需要登陆验证的地址 $noCheck = array('Login/index', 'Verify/index'); //>>2.获取用户正在访问的url地址 $requestURL = CONTROLLER_NAME . '/' . ACTION_NAME; if (in_array($requestURL, $noCheck)) { return; } header('Content-Type: text/html;charset=utf-8'); //>>1.判定用户是否登陆 if (!isLogin()) { $loginService = D('Login', 'Service'); if (!$loginService->autoLogin()) { //进行自动登录, 如果没有自动登录,就转向登录页面 redirect(U('Login/index'), 1, '请登陆!'); } } //>>3.如果是超级管理员不用在判定权限 if (isSuperUser()) { return; } //>>2.判定登陆用户访问的url是否在他的权限范围之内 $urls = savePermissionURL(); if (!in_array($requestURL, $urls)) { exit('权限不足!请求联系管理员!'); } }
/** * 获取购物车列表页所需的数据 * 1. 用户没有登录的情况下,从cookie中获取 * 2. 用户登录了的情况下,从数据库中获取 */ public function getList() { if (!isLogin()) { $shoppingCar = cookie('shopping_car'); if (!empty($shoppingCar)) { $shoppingCar = unserialize($shoppingCar); $goodsModel = D('Goods'); foreach ($shoppingCar as &$item) { $row = $goodsModel->field('id,name,logo,shop_price')->find($item['id']); $item['logo'] = $row['logo']; $item['name'] = $row['name']; $item['price'] = $row['shop_price']; } unset($item); return $shoppingCar; } return false; } else { $this->alias('obj'); $this->field('g.id,g.name,g.logo,g.shop_price as price,obj.num'); $this->join('__GOODS__ as g on obj.goods_id=g.id'); $this->where(array('member_id' => UID)); $rows = $this->select(); return $rows; } }
public function Login() { parent::__construct(); $this->load->library(array('form_validation')); if (isLogin('user_id')) { redirect('user/dashboard'); } }
public function _initialize() { //判断是否,否则拒绝显示 if (!isLogin()) { $this->error("请先登录哦<^_^>!", U("Home/Index/index")); exit; } }
function cometchat() { if (isLogin()) { $site = site_url(); return "\r\n\t\t\t<link type=\"text/css\" href=\"{$site}/cometchat/cometchatcss.php\" rel=\"stylesheet\" charset=\"utf-8\">\r\n\t\t\t<script type=\"text/javascript\" src=\"{$site}/cometchat/cometchatjs.php\" charset=\"utf-8\"></script>"; } return ''; }
function toggleLogin() { if (isLogin()) { echo '<li><a href="logout.php"><span class="glyphicon glyphicon-user" aria-hidden="true"></span> ' . $_SESSION["nombre"] . '<span> | Cerrar Sesión</span></a></li>'; } else { echo '<li><a href="login.php">Iniciar Sesión</span></a></li>'; } }
function getVehicleModelByID($id, $session) { if (isLogin($session)) { $jsonObj = new stdClass(); $jsonObj->ID = 1001; $data['encoded_data'] = jsonEncode($jsonObj); $this->load->view('json', $data); } }
function v_loginForm() { $form = new loginForm(); if (isLogin() !== true) { echo '<form class="form" action="' . $form->page . '" method="POST">' . $form->closeIcon . $form->loginTitle . '<div class="formMargin">' . $form->usernameArea . $form->passwordArea . $form->loginSubmit . '</div></form>'; } else { echo '<form class="form" action"' . $form->page . '" method="POST">' . $form->closeIcon . $form->logoutTitle . '<div class="formMargin">' . $form->logoutMessage . $form->logoutSubmit . '</div></form>'; } }
public function _initialize() { if (!isLogin()) { //>>1.得到用户正在请求的地址 $request_url = $_SERVER['REQUEST_URI']; session('login_forward', $request_url); $this->success('请登录!', U('Member/login')); exit; } }
function p_iconFolder() { if (isLogin() === true) { $albums = p_dbms_albums(true); return $albums; } else { $albums = p_dbms_albums(false); return $albums; } }
protected function _initialize() { if (!isLogin()) { $this->redirect('Home/User/login'); } else { if (session('user_level') != 2 && session('user_level') == 1) { $this->error('无权访问,请先注销管理员账户再登陆'); } } }
function isAdmin() { global $_SESSION, $config; if (isLogin()) { if ($_SESSION[$config['name_short']]['level'] == 0) { return true; } } return false; }
function getTopMenu() { $temp = '<div class="menu"><a href="index.php">HOME</a></div>'; if (isLogin()) { $temp .= '<div class="menu"><a href="index.php">Your Wall</a></div> <div class="menu"><a href="logout.php">Logout</a></div>'; } else { $temp .= '<div class="menu"><a href="signup.php">Registration</a></div> <div class="menu"><a href="login.php">Login</a></div>'; } return $temp; }
public function User() { parent::__construct(); if (isLogin('user_id')) { } else { $this->session->unset_userdata('user_id'); redirect('user/login'); } $this->load->model('user_model'); $this->_data['title'] = "User"; $this->_data['type'] = $this->session->userdata('type'); $this->_data['menu'] = "users"; }
public function Sim_Card() { parent::__construct(); if (isLogin('user_id')) { } else { $this->session->unset_userdata('user_id'); redirect('user/login'); } $this->load->model('sim_model'); $this->_data['title'] = "Sim Card"; $this->_data['page_title'] = "Sim Card"; $this->_data['menu'] = "sim_card"; }
public function Device() { parent::__construct(); if (isLogin('user_id')) { } else { $this->session->unset_userdata('user_id'); redirect('user/login'); } $this->load->model('device_model'); $this->_data['title'] = "Device"; $this->_data['page_title'] = "Device"; $this->_data['menu'] = "devices"; }