Example #1
0
 function loginout()
 {
     foreach ($_COOKIE as $key => $value) {
         Cookie::delete($key);
         Cookie::clear();
     }
     $this->redirect('Index');
 }
Example #2
0
 public function checkLogin()
 {
     //Cookie::delete("userinfo");
     //  		session_unset();
     // 		session_destroy();
     // 		exit;
     $userinfo = Cookie::get("userinfo");
     $userinfo["user"] ? $_POST["account"] = $userinfo["user"] : ($_POST["account"] = $_REQUEST["account"]);
     $userinfo['pwd'] ? $_POST["password"] = $userinfo['pwd'] : ($_POST["password"] = $_REQUEST["password"]);
     //$_POST["password"]="******";
     if ($_POST["account"] && $_POST["password"]) {
         //先判读cookie里存的userinfo,再判断通过REQUEST传递过来的数据
         if ($_SESSION[C('USER_AUTH_KEY')]) {
             //不管安全问题只管性能,如果存在,直接判断有就绕开判断,以后可以用握手协议来记录安全
             // 				$map=array();
             // 				$map['account']	= $userinfo['user'];
             // 				$map['password']= $userinfo['pwd'];
             // 				$map["status"]	=array('gt',0);
             // 				$authInfo =RBAC::authenticate($map);
             // 				if($authInfo){
             // 					return true;
             // 				}
             //延长cookie超时时间
             Cookie::set("userinfo", Cookie::get("userinfo"), C('COOKIE_EXPIRE'));
             //验证完成后清理
             unset($_POST["account"]);
             unset($_POST["password"]);
             return true;
         } else {
             $authInfo = $this->getAuthInfo();
             if ($authInfo) {
                 //--------------此部分为验证密码-------------------//
                 $this->loginType = "checkLogin";
                 //核验类型为:检验登录
                 $this->checkPwd($authInfo);
                 $this->setSession($authInfo);
                 //重新设置session
                 $this->setUserInfoCookie($authInfo);
                 //设置UserInfo的cookie
                 //验证完成后清理
                 unset($_POST["account"]);
                 unset($_POST["password"]);
                 return true;
             } else {
                 //更新online信息,类型为删除
                 $this->setUserOnline($authInfo = "logout", $type = "delete");
                 // 		session_unset();
                 // 		session_destroy();
                 //销毁cookie
                 Cookie::delete("userinfo");
                 Cookie::clear();
                 return false;
             }
         }
     } else {
         //更新online信息,类型为删除
         $this->setUserOnline($authInfo = "logout", $type = "delete");
         // 		session_unset();
         // 		session_destroy();
         //销毁cookie
         Cookie::delete("userinfo");
         Cookie::clear();
         return false;
     }
 }
 public function logout()
 {
     Session::clear();
     Cookie::delete("email");
     Cookie::delete("password");
     Cookie::clear();
     $this->redirect("index", "Index");
 }
 /**
  * @Title: todoDBInit
  * @Description: todo(清除数据表数据)
  * @author jiangx
  * @throws
  */
 public function todoDBInit()
 {
     //获取当前数据库的所有表名
     $database = C('DB_NAME');
     $model = M("INFORMATION_SCHEMA.TABLES", '', '', 1);
     $map['_string'] = " TABLE_SCHEMA = '" . $database . "'";
     $tableslist = $model->where($map)->field($field)->getfield('TABLE_NAME,TABLE_COMMENT');
     //不会被清空的数据表
     $tables = $this->tablelist;
     foreach ($_REQUEST['tables'] as $val) {
         $tables[$val] = $val;
     }
     foreach ($tableslist as $key => $val) {
         if ($tables[$key]) {
             continue;
         }
         $tablemodel = M($key);
         $sql = "DELETE FROM `" . $key . "`";
         $result = $tablemodel->execute($sql);
         if ($result === false) {
             $this->error(L('_ERROR_'));
         }
     }
     //初始化一个admin账号 姓名admin 密码 admin
     if (!isset($tableslist['user'])) {
         $this->error(L('数据库没有user数据表,不能初始化admin用户'));
     }
     $usermodel = M("user");
     $map = array();
     $map['account'] = 'admin';
     $adminuser = $usermodel->where($map)->find();
     if (!$adminuser) {
         $_POST['account'] = 'admin';
         $_POST['name'] = 'admin';
         $_POST['password'] = md5('admin');
         unset($_POST['tables']);
         if (false === $usermodel->create()) {
             $this->error($usermodel->getError());
         }
         $list = $usermodel->add();
         if ($list === false) {
             $this->error(L('初始化user用户失败'));
         }
     }
     $this->transaction_model->commit();
     //事务提交
     if ($adminuser) {
         //注销登录
         $data = array();
         //$data['last_login_time'] ="";
         $data['isonline'] = 0;
         $data['sessionid'] = "";
         $data['leavetime'] = time();
         $data['id'] = $_SESSION[C('USER_AUTH_KEY')];
         $usermodel->save($data);
         $usermodel->commit();
     }
     unset($_SESSION);
     Cookie::delete("userinfo");
     Cookie::clear();
     session_destroy();
     $this->success('清空数据表成功!');
     $this->redirect('/Public/login/');
 }
Example #5
0
<?php

Page::ignore_view();
if ('renew' == Request::get(1)) {
    die('11');
    Session::clear();
    Cookie::clear();
}
$m = new SampleModel();
if ($m->try_post()) {
    if ($m->pwd == Conf::$management_center_password) {
        Auth::im_admin('YYUC_sys');
        Redirect::to('index');
    } else {
        Session::once('logerr', '登录失败!');
    }
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>YYUC开发管理中心</title>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
		<script type="text/javascript">var yyuc_jspath = "/@system/";</script>
		<script type="text/javascript" src="/@system/js/jquery.js"></script>
		<script type="text/javascript" src="/@system/js/yyucadapter.js"></script>
		<!-- stylesheets -->
		<link rel="stylesheet" type="text/css" href="/@system/mg/reset.css" />
		<link rel="stylesheet" type="text/css" href="/@system/mg/style.css" media="screen" />
		<link id="color" rel="stylesheet" type="text/css" href="/@system/mg/colors/blue.css" />
		<style>
 public function checkLogin()
 {
     $account = $_REQUEST["account"];
     $pwd = $_REQUEST["password"];
     $userinfo = Cookie::get("userinfo");
     if ($account && $pwd || $userinfo["user"] && $userinfo['pwd']) {
         if ($account && $pwd) {
             $map = array();
             $map['account'] = $account;
             $map['password'] = $pwd;
         } else {
             $map = array();
             $map['account'] = $userinfo['user'];
             $map['password'] = $userinfo['pwd'];
         }
         $map["status"] = array('gt', 0);
         $authInfo = RBAC::authenticate($map);
         if ($authInfo) {
             //cookie验证重新赋值
             if (ACTION_NAME != "getAllScheduleList") {
                 $this->setBBSCookie($authInfo);
                 $this->setUserInfoCookie($authInfo);
             }
             if (!isset($_SESSION[C('USER_AUTH_KEY')])) {
                 $this->setSession($authInfo);
                 //更新user_online表
                 $online_model = M("user_online");
                 $onlinedata = array();
                 $onlinedata["modify_time"] = time();
                 $onlinedata["session_id"] = session_id();
                 $online_model->where("userid=" . $authInfo['id'])->save($onlinedata);
             }
             // 缓存访问权限
             RBAC::saveAccessList();
             $same_time_login = intval(getCommonSettingSkey("SAME_TIME_LOGIN"));
             if (ACTION_NAME != "getAllScheduleList") {
                 $modeluseronline = D("UserOnline");
                 $aMap = array();
                 $aMap['userid'] = $authInfo["id"];
                 $info = $modeluseronline->where($aMap)->find();
                 $time = time();
                 $session_id = session_id();
                 if ($info) {
                     //存在,则检查session_id
                     if ($same_time_login == 0) {
                         if ($info['session_id'] == $session_id) {
                             //修改时间
                             $modeluseronline->where($aMap)->setField('modify_time', $time);
                         } else {
                             $this->assign("jumpUrl", __APP__ . '/Public/login/');
                             unset($_SESSION);
                             Cookie::delete("userinfo");
                             Cookie::delete("bbsuserinfo");
                             Cookie::clear();
                             session_destroy();
                             $this->error("已在其他地方登陆,被迫下线", '', '', '301');
                             exit;
                         }
                     } else {
                         $modeluseronline->where($aMap)->setField('modify_time', $time);
                     }
                 } else {
                     //如果不存在userid,插入
                     $data = array();
                     $data = array('userid' => $authInfo["id"], 'session_id' => $session_id, 'modify_time' => $time, 'createid' => $authInfo["id"], 'createtime' => $time);
                     $modeluseronline->add($data);
                 }
             }
             return true;
         }
     } else {
         //提示请求时返回json数据
         if (ACTION_NAME == "getAllScheduleList") {
             $rehtml["html"] = 0;
             $rehtml['date'] = "";
             $rehtml['datalist'] = 0;
             echo json_encode($rehtml);
             exit;
         }
     }
     unset($_SESSION);
     Cookie::delete("userinfo");
     Cookie::delete("bbsuserinfo");
     Cookie::clear();
     session_destroy();
     return false;
 }