public function check_admin() { if (!Session::is_set('lfy_name') or !Session::is_set('lfy') or $_SESSION['lfy'] != md5('lfy000')) { $this->redirect('index/index'); exit; } }
/** +---------------------------------------------------------- * 返回后台资讯列表 +---------------------------------------------------------- */ public function listInformationColumn() { if (!Session::is_set("systemId")) { header("Content-type: text/html; charset=utf-8"); echo '<script>alert("您还没有登录!");location.href="Admin/loginInit";</script>'; } else { $informationColumn = M("information_column"); $title = $_REQUEST["title"]; if (!empty($title)) { $condition["title"] = array("like", "%" . $title . "%"); } $source = $_REQUEST["source"]; if (!empty($source)) { $condition["source"] = $source; } $column = $_REQUEST["column"]; if (!empty($column)) { $condition["column"] = $column; } $status = $_REQUEST["status"]; if (!empty($status)) { $condition["status"] = $status; } $count = $informationColumn->where($condition)->count(); import("ORG.Util.Page"); $Page = new Page($count, 10); $foot = $Page->show(); $list = $informationColumn->where($condition)->order('seq desc,update_time desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); // 查询数据 $this->assign('list', $list); $this->assign('foot', $foot); $this->display(); } }
function SignIn($row) { Module::Module($row); if (User::is_login()) { if ($data = Session::get('user_data') and $data['home_page']) { Url::redirect_url($data['home_page']); } else { Url::redirect('home'); } } else { // xoa toan bo du lieu dang co truoc khi dang nhap if (Session::is_set('user_id')) { $id = Session::get('user_id'); DB::update('account', array('last_online_time' => time()), 'id=\'' . $id . '\''); setcookie('user_id', "", time() - 3600); Session::destroy('user_id'); } //if(URL::get("m")== "mobile"){ // require_once 'forms/mlogin.php'; // $this->add_form(new SignInmForm); //}else{ require_once 'forms/sign_in.php'; $this->add_form(new SignInForm()); //} } }
static function getCurrent() { if (!Session::is_set(self::SESSION_LANGUAGE_PATH)) { self::initDefault(); } return Session::get(self::SESSION_LANGUAGE_PATH); }
/** +---------------------------------------------------------- * 返回用户列表 +---------------------------------------------------------- */ public function listActivityComment() { if (!Session::is_set("systemId")) { header("Content-type: text/html; charset=utf-8"); echo '<script>alert("您还没有登录!");location.href="/Admin/loginInit";try{window.event.returnValue=false; }catch(e){}</script>'; } else { $vactivity_comment = M("vactivity_comment"); $user_name = $_REQUEST["user_name"]; if (!empty($user_name)) { $condition["user_name"] = array("like", "%" . $user_name . "%"); } $activity_title = $_REQUEST["activity_title"]; if (!empty($activity_title)) { $condition["activity_title"] = array("like", "%" . $activity_title . "%"); } $content = $_REQUEST["content"]; if (!empty($content)) { $condition["content"] = array("like", "%" . $content . "%"); } $count = $vactivity_comment->where($condition)->count(); import("ORG.Util.Page"); $Page = new Page($count, 10); $foot = $Page->show(); $list = $vactivity_comment->where($condition)->order('insert_time desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); // 查询数据 $this->assign('list', $list); $this->assign('foot', $foot); $this->display(); } }
function testClear() { Session::clear(); $this->assertFalse(Session::is_set("/prova"), "La variabile prova e' gia' impostata!!"); Session::set("/prova", "ok"); $this->assertTrue(Session::is_set("/prova"), "la chiave prova non e' stata trovata."); $this->assertTrue(Session::get("/prova"), "ok", "Il valore della chiave non corrisponde!!"); Session::clear(); $this->assertFalse(Session::is_set("/prova"), "la chiave prova e' stata trovata."); }
function getNodeName($id) { if (Session::is_set('nodeNameList')) { $name = Session::get('nodeNameList'); return $name[$id]; } $Group = D("Node"); $list = $Group->getField('id,name'); $name = $list[$id]; Session::set('nodeNameList', $list); return $name; }
/** * 通过条码字典获取条码信息 * * @param $code */ private function getInfoByCodeFromCodeDict($code) { if (!Session::is_set('codeparm') || !Session::is_set('codedict')) { return false; } $codeparm = Session::get('codeparm'); $codedict = Session::get('codedict'); $codeinfo = array(); foreach ($codeparm as $key => $value) { $s = (int) $value["start"] - 1; $l = $value["length"]; $data = $codedict[$key][substr($code, $s, $l)]; if ($data == '' || $data == null) { continue; } switch ($key) { case '品名': $codeinfo['goodsName'] = $data; break; case '型号': $codeinfo['spec'] = $data; break; case '电流': $codeinfo['current1'] = $data; break; case '电压': $codeinfo['voltage1'] = $data; break; case '方向': $codeinfo['direct'] = $data; break; case '常数': $codeinfo['constant'] = $data; break; case '等级': $codeinfo['grade'] = $data; break; case '生产厂商': $codeinfo['madeIn'] = $data; break; case '生产日期': $codeinfo['madeDate'] = $data; break; } } system_out(print_r($codeinfo, true)); if (sizeof($codeinfo)) { $codeinfo['code'] = $code; return $codeinfo; } else { return false; } }
public function logout() { if (Session::is_set(C('USER_AUTH_KEY'))) { Session::clear(); $this->assign('jumpUrl', __URL__ . '/login'); $this->success("注销成功!"); } else { $this->assign('jumpUrl', __URL__ . '/login'); $this->error('已经注销!'); } $this->forward(); }
public function add() { $dao = D("Node"); if (Session::is_set('currentNodeId')) { $vo = $dao->getById(Session::get('currentNodeId')); $this->assign('parentNode', $vo['name']); $this->assign('level', $vo['level'] + 1); $this->assign('pid', $vo['id']); } else { $this->assign('level', 1); } $this->display(); }
public function checkAdminUser() { if (!Session::is_set("systemId")) { $json["success"] = false; $json["msg"] = "请您先登录"; } else { $condition["id"] = Session::get("systemId"); $admin_user = M("admin_user"); $result = $admin_user->where($condition)->find(); $json["success"] = true; $json["user_name"] = $result["user_name"]; } $this->ajaxReturn($json); }
function getGroupName($id) { if ($id == 0) { return '无上级组'; } if (Session::is_set('groupName')) { $name = Session::get('groupName'); return $name[$id]; } $Group = D("Group"); $list = $Group->getFields('id,name'); $name = $list[$id]; Session::set('groupName', $list); return $name; }
/** +---------------------------------------------------------- * 返回用户列表 +---------------------------------------------------------- */ public function listUser() { if (!Session::is_set("systemId")) { header("Content-type: text/html; charset=utf-8"); echo '<script>alert("您还没有登录!");location.href="Admin/loginInit";try{window.event.returnValue=false; }catch(e){}</script>'; } else { $User = M("User"); $user_name = $_REQUEST["user_name"]; if (!empty($user_name)) { $condition["user_name"] = array("like", "%" . $user_name . "%"); } $user_type1 = $_REQUEST["user_type1"]; if (!empty($user_type1)) { $condition["user_type1"] = $user_type1; } $user_type2 = $_REQUEST["user_type2"]; if (!empty($user_type2)) { $condition["user_type2"] = $user_type2; } $status = $_REQUEST["status"]; if (!empty($status)) { $condition["status"] = $status; } $activite_flag = $_REQUEST["activite_flag"]; if (!empty($activite_flag)) { $condition["activite_flag"] = $activite_flag; } $freeze_flag = $_REQUEST["freeze_flag"]; if (!empty($freeze_flag)) { if ($freeze_flag == "已冻结") { $condition["freeze_flag"] = $freeze_flag; } else { $condition["freeze_flag"] = array('neq', "已冻结"); } } $count = $User->where($condition)->count(); import("ORG.Util.Page"); $Page = new Page($count, 10); $foot = $Page->show(); $list = $User->where($condition)->order('update_time desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); // 查询数据 $this->assign('list', $list); $this->assign('foot', $foot); $this->display(); } }
public function update() { if (!isset($_POST['author']) or !isset($_POST['content'])) { alert('非法操作!', 3); } //读取数据库和缓存 $pl = M('guestbook'); $config = F('basic', '', './Web/Conf/'); //相关判断 if (Session::is_set('posttime')) { $temp = Session::get('posttime') + $config['postovertime']; if (time() < $temp) { // echo "请不要连续发布!"; alert('请不要连续发布!', U('Guestbook/index')); exit; } } //准备工作 if ($config['bookoff'] == 0) { $data['status'] = 0; } $data['author'] = htmlspecialchars($_POST['author']); $data['content'] = htmlspecialchars(trim($_POST['content'])); $data['email'] = htmlspecialchars(trim($_POST['email'])); $data['tel'] = htmlspecialchars(trim($_POST['tel'])); $data['addtime'] = date('Y-m-d H:i:s'); //处理数据 // dump($data) if ($pl->add($data)) { Session::set('posttime', time()); if ($config['bookoff'] == 0) { // echo '发布成功,留言需要管理员审核!'; alert('操作成功!', U('Guestbook/index')); exit; } else { // echo '发布成功!'; alert('发布成功!', U('Guestbook/index')); exit; } } else { // echo '发布失败!'; alert('发布失败!', U('Guestbook/index')); exit; } }
public function update() { //输出gb2312码,ajax默认转的是utf-8 header("Content-type: text/html; charset=utf-8"); if (!isset($_POST['author']) or !isset($_POST['content'])) { alert('非法操作!', 3); } //读取数据库和缓存 $pl = M('guestbook'); $config = F('basic', '', './Web/Conf/'); //相关判断 if (Session::is_set('posttime')) { $temp = Session::get('posttime') + $config['postovertime']; if (time() < $temp) { echo "请不要连续发布!"; exit; } } //准备工作 if ($config['bookoff'] == 0) { $data['status'] = 0; } //先解密js的escape $data['author'] = htmlspecialchars(unescape($_POST['author'])); $data['content'] = htmlspecialchars(trim(unescape($_POST['content']))); $data['title'] = htmlspecialchars(trim(unescape($_POST['title']))); $data['tel'] = htmlspecialchars(trim(unescape($_POST['tel']))); $data['ip'] = remove_xss(htmlentities(get_client_ip())); $data['addtime'] = date('Y-m-d H:i:s'); //处理数据 if ($pl->add($data)) { Session::set('posttime', time()); if ($config['bookoff'] == 0) { echo '发布成功,留言需要管理员审核!'; exit; } else { echo '发布成功!'; exit; } } else { echo '发布失败!'; exit; } }
public function updateComment() { if (!Session::is_set("id")) { $json["success"] = false; $json["msg"] = "还没有登录"; } else { $ActivityComment = M("activity_comment"); $ActivityComment->title = $_REQUEST["title"]; $ActivityComment->content = $_REQUEST["content"]; $ActivityComment->activity_id = $_REQUEST["activity_id"]; $ActivityComment->insert_time = date("Y-m-d H:i:s"); $ActivityComment->user_id = Session::get("id"); $ActivityComment->ip = $_SERVER['REMOTE_ADDR']; $ActivityComment->add(); $json["success"] = true; $json["msg"] = "评论成功"; } $this->ajaxReturn($json); }
public function connect($type = '', $options = array()) { if (empty($type)) { $type = C('DATA_CACHE_TYPE'); } if (Session::is_set('CACHE_' . strtoupper($type))) { $cacheClass = Session::get('CACHE_' . strtoupper($type)); } else { $cachePath = dirname(__FILE__) . '/Cache/'; $cacheClass = 'Cache' . ucwords(strtolower(trim($type))); require_cache($cachePath . $cacheClass . '.class.php'); } if (class_exists($cacheClass)) { $cache = new $cacheClass($options); } else { throw_exception(L('_CACHE_TYPE_INVALID_') . ':' . $type); } return $cache; }
public function update() { //输出utf-8码,ajax默认转的是utf-8 header("Content-type: text/html; charset=utf-8"); if (!isset($_POST['aid']) or !isset($_POST['author']) or !isset($_POST['content'])) { $this->error('非法操作!'); } //读取数据库和缓存 $pl = M('pl'); $config = F('basic', '', './Web/Conf/'); $data['ip'] = htmlentities(get_client_ip()); //先解密js的escape $data['author'] = htmlspecialchars(unescape($_POST['author'])); //使用stripslashes 反转义,防止服务器开启自动转义 $data['content'] = htmlspecialchars(trim(stripslashes(unescape($_POST['content'])))); $data['ptime'] = date('Y-m-d H:i:s'); $data['aid'] = intval($_POST['aid']); if (Session::is_set('pltime')) { $temp = Session::get('pltime') + $config['postovertime']; if (time() < $temp) { echo "请不要连续发布!"; exit; } } if ($config['pingoff'] == 0) { $data['status'] = 0; } if ($pl->add($data)) { Session::set('pltime', time()); if ($config['pingoff'] == 0) { echo "发布成功,评论需要管理员审核!"; exit; } else { echo "发布成功!"; exit; } } else { echo "发布失败!"; exit; } }
public function deleteUserLog() { if (!Session::is_set("systemId")) { header("Content-type: text/html; charset=utf-8"); echo '<script>location.href="Admin/loginInit";try{window.event.returnValue=false; }catch(e){}</script>'; } else { $id = $_REQUEST["id"]; $Userlog = M("Userlog"); $Userlog->where("id=" . $id)->delete(); //记录日志 $Userlog->user_id = Session::get("systemId"); $Userlog->table_name = "kp_userlog"; $Userlog->table_id = $id; $Userlog->act_describ = "删除操作"; $Userlog->insert_time = date("Y-m-d H:i:s"); $Userlog->ip = $_SERVER['REMOTE_ADDR']; $Userlog->add(); header("Content-type: text/html; charset=utf-8"); echo '<script>alert("删除成功!");location.href="listUserLog";try{window.event.returnValue=false; }catch(e){}</script>'; } }
public function update() { if (!isset($_POST['aid']) or !isset($_POST['author']) or !isset($_POST['content'])) { alert('非法操作!', 3); } //读取数据库和缓存 $pl = M('pl'); $config = F('basic', '', './Web/Conf/'); //载入函数库 Load('extend'); $data['ip'] = get_client_ip(); $data['author'] = htmlspecialchars($_POST['author']); $data['content'] = htmlspecialchars(trim($_POST['content'])); $data['ptime'] = date('Y-m-d H:i:s'); $data['aid'] = htmlspecialchars($_POST['aid']); if (Session::is_set('pltime')) { $temp = Session::get('pltime') + $config['postovertime']; if (time() < $temp) { echo "请不要连续发布!"; exit; } } if ($config['pingoff'] == 0) { $data['status'] = 0; } if ($pl->add($data)) { Session::set('pltime', time()); if ($config['pingoff'] == 0) { echo "发布成功,评论需要管理员审核!"; exit; } else { echo "发布成功!"; exit; } } else { echo "发布失败!"; exit; } }
public function join() { if (!Session::is_set("id")) { $json["success"] = false; $json["msg"] = "没有登录"; } else { //记录日志 $user_id = Session::get("id"); $id = $_REQUEST["id"]; $Activity = M("Activity"); $Activityresult = $Activity->where("id=" . $id)->find(); $Userlog = M("Userlog"); $Userlog->user_id = $user_id; $Userlog->table_name = "kp_activity"; $Userlog->table_id = $id; $Userlog->act_describ = "参加" . $Activityresult["type"] . "一次"; $Userlog->insert_time = date("Y-m-d H:i:s"); $Userlog->ip = $_SERVER['REMOTE_ADDR']; $Userlog->add(); $User = M("User"); $condition["id"] = $user_id; $result = $User->where($condition)->field("user_name, true_name")->find(); if (empty($result["true_name"])) { $true_name = "用户"; } else { $true_name = $result["true_name"]; } $user_name = $result["user_name"]; if ($Activityresult["type"] == "免费试用") { $sendSms = "sendSms"; $this->{$sendSms}($user_name, "尊敬的" . $true_name . ",感谢您参加本次立配网活动!我们将在您获得试用资格后,发送试用通知,敬请留意。【立配网】"); //发送短消息 $saveMessage = "saveMessage"; $this->{$saveMessage}($user_id, "参加" . $Activityresult["title"], "尊敬的" . $true_name . ",感谢您参加本次立配网活动!我们将在您获得试用资格后,发送试用通知,敬请留意。【立配网】"); $json["success"] = true; $json["msg"] = "参加成功!感谢您参加本次活动,我们将在您获得试用资格后,发送短信通知到您的手机上,敬请留意查收。"; } else { //发送短消息 $saveMessage = "saveMessage"; $this->{$saveMessage}($user_id, "参加" . $Activityresult["title"], "尊敬的" . $true_name . ",您成功参加" . $Activityresult["title"] . "!。【立配网】"); $json["success"] = true; $json["msg"] = $Activityresult["type"]; } } $this->ajaxReturn($json); }
function is_logged() { return Session::is_set("/session/type") && Session::get("/session/type") === "admin"; }
/** * 打开灯操作 * * @param String $struct 表架参数 Example:struct = array("No" = "GN01","xNum"=>10,"yNum"=>5) * @param String array $places 表位 Example:places = array("A"=>array("GN01A0101","GN01A0102") * "B"=>array("GN01B0101","GN01B0102")) * @param String $stype 类型 get(取表),put(挂表) * @return Array */ public function trunOn($struct, $places, $stype) { //system_out("places:".print_r($places,true)); //DEBUG if (true == STRUCT_DEBUG) { $confirm = new ConfirmStationAction(); try { $confirm->saveUnconfirmStation($places, $struct["No"], $stype == 'put' ? "U" : "D"); } catch (Executive $e) { //system_out("StructControlAction.trunOn:" . print_r($e,true)); throw new Exception($e); } $rtn["stype"] = $stype; $rtn["places"] = $places; return $rtn; } //如果表架没有xNum或者yNum,则获取 if (!$struct["xNum"] || !$struct["yNum"]) { $structparm = $this->getStructparmBySingle($struct["No"]); if ($structparm) { $struct["xNum"] = $structparm["xNum"]; $struct["yNum"] = $structparm["yNum"]; $struct["comport"] = $structparm["comport"]; $struct["hardadd"] = $structparm["hardadd"]; $struct["ipaddress"] = $structparm["ipaddress"]; $struct["delay"] = Session::get('structdelay'); } } $this->setLogs("structparms of turnon light:" . print_r($struct, true)); $this->address = $struct["ipaddress"] ? $struct["ipaddress"] : $this->address; $this->com = $struct["comport"] ? $struct["comport"] : 'COM1'; $add = $struct["hardadd"] ? $struct["hardadd"] : (int) substr($struct["No"], 2, 2); $ycbk = new YCBK($this->address, $this->port, $this->com, $this->comToNetType); //system_out("places:".print_r($places,true)); $placesNo = AddressCover::NameToNumber($places, $struct["xNum"], $struct["yNum"]); $ycbk->close(); //system_out(Session::id()); if (!Session::is_set($struct["No"])) { system_out("StructControlAccino.trunOn:is not set"); //硬件操作 for ($i = 0; $i < $this->looptimes; $i++) { $ycbk->open(); //获取表架使用情况 $station = $ycbk->querySwitchStatus($add); $ycbk->close(); if ($station) { break; } usleep($this->waittime); } if (!$station) { throw new Exception("查询表架[" . $add . "]使用情况出错:" . $ycbk->getError(), 101); } } else { $station = Session::get($struct["No"]); //system_out("test:".print_r($station,true)); } //设置A面放表的表位的标记 for ($i = 0; $i < sizeof($placesNo["A"]); $i++) { $index = $placesNo["A"][$i]; $stype == 'put' ? $station[$index]["A"] = "U" : ($station[$index]["A"] = "D"); } //设置B面放表的表位的标记 for ($i = 0; $i < sizeof($placesNo["B"]); $i++) { $index = $placesNo["B"][$i]; $stype == 'put' ? $station[$index]["B"] = "U" : ($station[$index]["B"] = "D"); } //执行硬件操作 for ($i = 0; $i < $this->looptimes; $i++) { $ycbk->open(); //挂表 if ($stype == 'put') { //转换码 $station = AddressCover::changeCodeForPut($station); //system_out("after addresscover station:".print_r($station,true)); $result = $ycbk->uploadMeterStateLight($add, $station); } else { //转换码 $station = AddressCover::changeCodeForGet($station); //system_out("after addresscover station,get:".print_r($station,true) ); $result = $ycbk->downloadMeterStateLight($add, $station); } $ycbk->close(); if ($result) { break; } usleep($this->waittime); } if (!$result) { throw new Exception("开启表架[" . $add . "]灯出错:" . $ycbk->getError(), 102); } //保存开了的灯进数据库 $confirm = new ConfirmStationAction(); try { $confirm->saveUnconfirmStation($places, $struct["No"], $stype == 'put' ? "U" : "D"); } catch (Executive $e) { $this->close($struct, $stype); throw new Exception($e); } $rtn["stype"] = $stype; $rtn["places"] = $places; $this->setLogs($ycbk->getLogs()); return $rtn; }
/** * 显示报考成功信息 */ function ok() { if (!Session::is_set('lfy_stuno') or $_SESSION['lfy_kkk'] != md5($_SESSION['lfy_stuno'] . 'lfy19881214')) { $this->redirect('index/index'); } else { //判断是否缓存了科目名称 if (!S('kemu_name')) { $Config = M('Config'); S('kemu_name', $Config->getField('kemu_name'), -1); } $this->assign('kemu_name', S('kemu_name')); $stu_no = addslashes($_SESSION['lfy_stuno']); if (!S('stu' . $stu_no)) { $Stu_info = M('Stu_info'); S('stu' . $stu_no, $Stu_info->where("stu_no='{$stu_no}'")->find(), -1); } $this->assign(S('stu' . $stu_no)); $stu_list = S('stu' . $stu_no); if (!S('bk' . $stu_list['stu_join'])) { $Bk = M('Bk_num'); //永久缓存年级每人的报考次数 S('bk' . $stu_list['stu_join'], $Bk->where("stu_join='{$stu_list['stu_join']}'")->getfield('bk_num'), -1); } $Stubk_temp = M('Stubk_temp'); $ready_num = $Stubk_temp->where("stu_no='{$stu_no}'")->count(); $this->assign('sy_num', S('bk' . $stu_list['stu_join']) - $ready_num); $this->assign('bk_num', S('bk' . $stu_list['stu_join'])); //检测批次信息是否被缓存 if (!S('pc' . $stu_list['stu_join'])) { $Pici = M('Pici'); S('pc' . $stu_list['stu_join'], $Pici->where("pc_join='{$stu_list['stu_join']}' and pc_off='t'")->find(), 3600); } $this->assign(S('pc' . $stu_list['stu_join'])); $this->display(); } }
function get_current_folder() { if (!Session::is_set(self::SESSION_GALLERY_CURRENT_FOLDER)) { Session::set(self::SESSION_GALLERY_CURRENT_FOLDER, $this->get_user_root()); } return Session::get(self::SESSION_GALLERY_CURRENT_FOLDER); }
/** +---------------------------------------------------------- * 检查乐观锁 +---------------------------------------------------------- * @access protected +---------------------------------------------------------- * @param array $data 当前数据 * @param mixed $where 查询条件 +---------------------------------------------------------- * @return mixed +---------------------------------------------------------- * @throws ThinkExecption +---------------------------------------------------------- */ protected function checkLockVersion(&$data, &$where = '') { $pk = $this->getPk(); $id = $data[$pk]; if (empty($where) && isset($id)) { $where = $pk . "=" . $id; } // 检查乐观锁 $identify = $this->name . '_' . $id . '_lock_version'; if ($this->optimLock && Session::is_set($identify)) { $lock_version = Session::get($identify); if (!empty($where)) { $vo = $this->find($where, $this->optimLock); } else { $vo = $this->find($data, $this->optimLock); } Session::set($identify, $lock_version); $curr_version = is_array($vo) ? $vo[$this->optimLock] : $vo->{$this->optimLock}; if (isset($curr_version)) { if ($curr_version > 0 && $lock_version != $curr_version) { // 记录已经更新 return false; } else { // 更新乐观锁 $save_version = $data[$this->optimLock]; if ($save_version != $lock_version + 1) { $data[$this->optimLock] = $lock_version + 1; } Session::set($identify, $lock_version + 1); } } } //unset($data[$pk]); return true; }
/** * 获取查看目录的成员 * * @param int $parentid * @return Array * @return Boolean */ public function getViewObjects($parentid) { if (!Session::is_set(USER_AUTH_KEY)) { return false; } $listDao = null; $userid = Session::get(USER_AUTH_KEY); $whereStr = ""; if (Session::is_setLocal('administrator')) { $listDao = new View_objectsDao(); $whereStr = "parentid = {$parentid}"; } else { $groups = Session::get('_USER_GROUPS'); if ($groups) { $groupStr = implode(',', $groups); } else { $groupStr = 0; } $roles = Session::get('_USER_ROLES'); if ($roles) { $roleStr = implode(',', $roles); } else { $roleStr = 0; } $listDao = new View_objects_permDao(); $whereStr = "( (object_owner={$userid} or other_bitset >=1 or (owner_group in({$groupStr}) and group_bitset >= 1)) or "; $whereStr .= " ((userid = {$userid} or roleid in({$roleStr}) or groupid in({$groupStr})) and bitset >=1) ) and parentid = {$parentid}"; } $vol = $listDao->findAll($whereStr, '', '*', 'object_type,status_date'); if (!$vol->isEmpty()) { $result = $vol->toResultSet(); return $result; } else { return false; } }
static function AccessDecision() { //检查是否需要认证 if (RBAC::checkAccess()) { //检查认证识别号 if (!Session::is_set(C('USER_AUTH_KEY'))) { //跳转到认证网关 redirect(PHP_FILE . C('USER_AUTH_GATEWAY')); } //存在认证识别号,则进行进一步的访问决策 $accessGuid = md5(APP_NAME . MODULE_NAME . ACTION_NAME); if (!Session::is_setLocal('administrator')) { //管理员无需认证 if (C('USER_AUTH_TYPE') == 2) { //加强验证和即时验证模式 更加安全 后台权限修改可以即时生效 //通过数据库进行访问检查 $accessList = RBAC::getAccessList(); } else { // 如果是管理员或者当前操作已经认证过,无需再次认证 if (Session::is_set($accessGuid)) { return; } //登录验证模式,比较登录后保存的权限访问列表 $accessList = Session::get('_ACCESS_LIST'); } if (!isset($accessList[strtoupper(APP_NAME)][strtoupper(MODULE_NAME)][strtoupper(ACTION_NAME)])) { throw_exception(L('_VALID_ACCESS_')); } else { Session::set($accessGuid, true); } } } return true; }
/** +---------------------------------------------------------- * 导出订阅情况 +---------------------------------------------------------- */ public function subscribeExcel() { if (!Session::is_set("systemId")) { header("Content-type: text/html; charset=utf-8"); echo '<script>alert("您还没有登录!");location.href="Admin/loginInit";try{window.event.returnValue=false; }catch(e){}</script>'; } else { //输出头信息 $filename = "export" . date("YmdHis"); header("Content-Type: text/plain"); header("Content-Disposition: attachment; filename={$filename}.csv;"); header('Pragma: cache'); header('Cache-Control: public, must-revalidate, max-age=0'); //由于 Excel 无法直接识别 utf-8 的数据,所以需要转换一下 $iconvstr = "iconvstr"; echo auto_charset("Email,订阅时间\n", 'utf-8', 'gbk'); $subscribe = M('subscribe'); $result = $subscribe->field("email, insert_time")->findAll(); foreach ($result as $row) { $contents = $row['email']; $contents .= ','; $contents .= $row['insert_time']; $contents .= "\n"; echo auto_charset($contents, 'utf-8', 'gbk'); } } }
function getUser($id) { if (Session::is_set('user')) { $user = Session::get('user'); return $user[$id]; } import('@.Dao.UserDao'); $dao = new UserDao(); $userList = $dao->field('id,name,nickname')->findAll(); $user = $userList->getCol('id,name'); $name = $user[$id]; Session::set('user', $user); return $name; }