__construct() public method

架构函数
public __construct ( think\Request $request = null )
$request think\Request Request对象
Exemplo n.º 1
0
 public function __construct()
 {
     parent::__construct();
     if (!session('?username')) {
         $this->error('请先登录', U('login/login'), 3);
     }
 }
Exemplo n.º 2
0
 public function __construct()
 {
     parent::__construct();
     if (!$_SESSION['user']) {
         header('location:' . U('admin/Index/login'));
     }
 }
Exemplo n.º 3
0
Arquivo: Klsf.php Projeto: klsf/kldns
 function __construct()
 {
     $this->pdo = new PdoHelper();
     parent::__construct();
     $this->loadWebConfig();
     $this->getLoginuUser();
 }
 /**
  * CourseController constructor.
  */
 public function __construct()
 {
     // 调用父类控制器
     parent::__construct();
     // 初始化curl管理器
     $this->_curl_init();
 }
Exemplo n.º 5
0
 function __construct()
 {
     parent::__construct();
     //if(empty($_SESSION['USER_ID']))exit(C('SITE_LANG.LOGIN_ALERT'));//check login
     $this->visible_tag_model = D('VisibleTag');
     $this->follow_model = D('Follow');
 }
 public function __construct()
 {
     $this->jsonUtils = new \Org\Util\JsonUtils();
     $this->session_handle = new \Org\Util\SessionHandle();
     $this->dao = M('service');
     parent::__construct();
 }
Exemplo n.º 7
0
 public function __construct()
 {
     parent::__construct();
     //读取配置信息
     $web_stting = F('setting');
     if ($web_stting === false) {
         $params = array();
         $list = M('Setting')->getField('name,value');
         foreach ($list as $key => $val) {
             $params[$key] = unserialize($val) ? unserialize($val) : $val;
         }
         F('setting', $params);
         $web_stting = F('setting');
     }
     $this->assign('web_stting', $web_stting);
     //站点状态判断
     if ($web_stting['site_status'] != 1) {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
         echo $web_stting['closed_reason'];
         exit;
     } else {
         $this->check_login();
         $link = M('Link')->where(array('status' => 1))->order('sort DESC')->select();
         $this->assign('link', $link);
         $this->assign('seo', seo());
     }
 }
Exemplo n.º 8
0
 function __construct()
 {
     parent::__construct();
     if (empty($_COOKIE['USERNAME'])) {
         //$this->success('', '?c=user&a=login');
     }
 }
 function __construct()
 {
     parent::__construct();
     $this->room = D("Room");
     $this->room_type = D("Room_type");
     $this->lunbo = D("Lunbo");
 }
Exemplo n.º 10
0
 public function __construct()
 {
     parent::__construct();
     if (ACTION_NAME != "login" && ACTION_NAME != "code" && ACTION_NAME != "check_verify") {
         $this->check();
     }
 }
Exemplo n.º 11
0
 public function __construct()
 {
     parent::__construct();
     $this->mkCateData();
     $this->getNav();
     $this->getCategoryTree();
 }
 public function __construct()
 {
     parent::__construct();
     if (!empty($this->controll_keywords)) {
         $this->model = D($this->controll_keywords);
     }
     $this->system_name = "兔芭露<span style='vertical-align:super; font-size:9px'>TM</span>产销存管理系统";
     $this->page_title = "RMS";
     $this->brand = C('brand');
     $this->brand_lang = C('brand_lang');
     $this->retailer_products_status = C('retailer_products_status');
     $this->plans_status = C('plans_status');
     $this->retailers = D('Retailer')->getRetailers();
     $this->retailer_id_selected = (int) I('get.retailer_id');
     $this->retailer_payment_status = C('retailer_payment_status');
     $this->retailer_payment_status_selected = (int) I('get.retailer_payment_status');
     $this->retailer_apply_status = C('retailer_apply_status');
     $this->retailer_apply_status_selected = (int) I('get.retailer_apply_status');
     $this->bill_status = C('retailer_bill_status');
     $this->bill_status_selected = (int) I('get.bill_status');
     $this->initSubMenus();
     $this->CONTROLLER_NAME = CONTROLLER_NAME;
     $this->ACTION_NAME = ACTION_NAME;
     $notices = D('articles')->getArticles(array(), 5);
     $this->notices = $notices['data'];
 }
Exemplo n.º 13
0
 public function __construct()
 {
     parent::__construct();
     //初始化系统信息
     $m = D('Home/System');
     $GLOBALS['CONFIG'] = $m->loadConfigs();
     $this->assign("baseUser", $_SESSION['USER']);
     $areas = D('Home/Areas');
     $areaList = $areas->getCitys();
     $areaId2 = $this->getDefaultCity();
     $currArea = $areas->getArea($areaId2);
     $this->assign('template_path', $template_path);
     //获取分类
     $gcm = D('Home/GoodsCats');
     $catList = $gcm->getGoodsCats($areaId2);
     $spm = D('Home/Shops');
     $selfShop = $spm->getSelfShop($areaId2);
     $this->assign('selfShop', $selfShop);
     $m = D('Home/Cart');
     $cartInfo = $m->getCartInfo();
     $this->assign('cartcnt', count($cartInfo["cartgoods"]));
     $this->assign('searchType', I("searchType", 1));
     $this->assign('catList', $catList);
     $this->assign('currCity', $areaList[$areaId2]);
     $this->assign('cityList', $areaList);
     $this->assign('areaId2', $areaId2);
     $this->assign('currArea', $currArea);
     $this->assign('CONF', $GLOBALS['CONFIG']);
     $this->header();
     //加入头部
     $this->footer();
     //加入底部
 }
Exemplo n.º 14
0
 function __construct()
 {
     parent::__construct();
     //if(empty($_SESSION['USER_ID']))exit(C('SITE_LANG.LOGIN_ALERT'));//check login
     $this->user_model = D('User');
     $this->user_config_model = D('UserConfig');
 }
 public function __construct()
 {
     parent::__construct();
     if (!session('id')) {
         $this->error('必须先登录', U('Login/index'));
     }
 }
Exemplo n.º 16
0
 public function __construct()
 {
     parent::__construct();
     R('Tool/Too/chechLogin');
     R('Home/Public/showHeader');
     R('Home/Public/showFooter');
 }
Exemplo n.º 17
0
 public function __construct()
 {
     if ($_GET['source'] && !cookie('source')) {
         cookie('source', trim($_GET['source']));
     }
     if (isset($_GET['spm']) && $_GET['spm']) {
         cookie('_spm', $_GET['spm'], array('expire' => 172800, 'domain' => '.wdwd.com', 'path' => '/'));
     }
     if (!session('?shop')) {
         $this->redirect('admin/passport/logout');
     }
     /*
     var_dump(session('shop'));
     exit;
     if (!session('?shop') || ('' == session('shop.mobile'))) {
         if (session('?user')) {
             $this->redirect('admin/passport/bind');
         }
         else {
             $this->redirect('admin/passport/logout');
         }
     }
     */
     $shop = session('shop');
     $shop['decode_shop_id'] = \Common\Lib\Idhandler::decode($shop['shop_id']);
     $this->passport = session('passport');
     $this->shop = $shop;
     $this->shop['mobile'] = $this->passport['loginname'];
     //print_r($this->shop);
     //print_r(session('passport'));
     parent::__construct();
 }
Exemplo n.º 18
0
    /**
     * 登录验证 (_initialize)
     */
    public function __construct()
    {
        //先调用父类的构造函数
        parent::__construct();
        //获取当前管理员的ID
        $adminId = session('id');
        if (!$adminId) {
            redirect(U('Admin/Login/login'));
        }
        //1.先获取当前管理员将要访问的这个页面 --- 使用TP 三个常量
        $url = MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME;
        //查询数据库是否存在当前管理员没有访问这个页面的权限
        $where = 'module_name ="' . MODULE_NAME . '" AND controller_name ="' . CONTROLLER_NAME . '" AND action_name ="' . ACTION_NAME . '"';
        //任何人只要登陆就可以进入后台
        if (CONTROLLER_NAME == 'Index') {
            return TRUE;
        }
        if ($adminId == 1) {
            $sql = 'SELECT COUNT(*) has FROM shop_privilege';
        } else {
            $sql = 'SELECT COUNT(a.role_id) has 
					FROM shop_role_privilege a 
						LEFT JOIN shop_privilege b ON a.pri_id = b.id 
						LEFT JOIN shop_admin_role c ON a.role_id = c.role_id
							WHERE c.admin_id = ' . $adminId . ' AND ' . $where;
        }
        $db = M();
        $pri = $db->query($sql);
        if ($pri[0]['has'] < 1) {
            $this->error('你无权访问!');
        }
        //验证登陆
    }
Exemplo n.º 19
0
 public function __construct()
 {
     parent::__construct();
     if (session('?admin')) {
         $database = M('order');
         $admin = M('admin')->where('username=:username')->bind(':username', session('admin'))->find();
         $admin = json_decode($admin['location'], true);
         if (!empty($admin['area']) && !empty($admin['building'])) {
             $where['area'] = array('in', $admin['area']);
             $where['building'] = array('in', $admin['building']);
             $where['_logic'] = 'or';
             $map['_complex'] = $where;
         } elseif (!empty($admin['area'])) {
             $map['area'] = array('in', $admin['area']);
         } elseif (!empty($admin['building'])) {
             $map['building'] = array('in', $admin['building']);
         }
         $map['status'] = 0;
         $count = $database->cache(true, 60)->where($map)->count();
         $this->assign('countTodo', $count);
         $map['status'] = 1;
         $count = $database->cache(true, 60)->where($map)->count();
         $this->assign('countDoing', $count);
         $map['status'] = 2;
         $count = $database->cache(true, 60)->where($map)->count();
         $this->assign('countDone', $count);
         $map['time'] = array('gt', strtotime(date('Y-m-d')));
         $map['status'] = array('neq', -1);
         //隐藏已取消报修的
         $count = $database->cache(true, 60)->where($map)->count();
         $this->assign('countToday', $count);
     }
 }
Exemplo n.º 20
0
 public function __construct()
 {
     parent::__construct();
     if (!session("?uname")) {
         redirect(U("Home/Login/index"));
     }
 }
Exemplo n.º 21
0
 public function __construct()
 {
     /**
      * 如果子类中定义了构造函数则不会隐式调用其父类的构造函数。
      * 如果子类没有定义构造函数则会如同一个普通的类方法一样从父类继承(假如没有被定义为 private 的话)。
      * 因为这子类定义了construct, Controller里面的construct就不会被调用,所以这边要自己继承下父类的construct, 才能用assign
      */
     parent::__construct();
     // 导航栏
     $this->navBar();
     // 作者页不需要
     if (CONTROLLER_NAME != 'Author') {
         // 最新文章
         $this->assign('latestArticles', $this->getArticles('', 10));
         // 最受欢迎 推5
         $this->assign('popularArticles', $this->getArticles('', 10, 0, 5));
         // 关键词列表
         $this->assign('tagsList', $this->tagsList(25));
         $this->assign('randomNum', $this->randomNum(25));
         /**
          * 如果不继承父类的construct(parent::__construct())的话,就不能直接使用assign方法, 但是可以通过__set()间接调用assign, 所以以下写法和用assign效果一样
          * Think\Controller里面有个__set()魔术方法,__set()里面调用assign方法, 因此可通过$object->name = value 的方式来调用__set方法
          * 在给不可访问属性赋值时(类属性为private或者不存在这个属性),__set() 会被调用
          */
         // 随便看看
         $this->randArticles = $this->getArticles('', 10, 0, 0, 0, 1);
         // 浏览历史
         if (CONTROLLER_NAME != 'Index') {
             !empty($_GET['id']) ? $this->recentView(10) : '';
             !empty($_COOKIE['history']) ? $this->history = unserialize($_COOKIE['history']) : '';
             // 当前已浏览过文章的二维数组
         }
     }
 }
Exemplo n.º 22
0
 public function __construct()
 {
     if (!session('?auth')) {
         $this->redirect('Login/login', 0);
     }
     parent::__construct();
 }
Exemplo n.º 23
0
 public function __construct()
 {
     parent::__construct();
     $this->_checkAccess();
     $this->serviceConfigList = $this->_getServiceConfigList();
     header("Content-type: text/html; charset=utf-8");
     echo "<style>\n";
     echo "table {margin:0px; padding:0px;}\n";
     echo "table.tbfix {width:100%; table-layout:fixed; background:#bbb}\n";
     echo "table.tbcom {width:100%; background:#bbb}\n";
     echo "td {padding:3px; background:#fff}\n";
     echo "td.title {background:#eee}\n";
     echo "td.left {width:200px}\n";
     echo "input.button {width:100px}\n";
     echo "textarea#result {width:100%; height:300px; background:#ffffe0}";
     echo "</style>";
     echo "<script type='text/javascript' src='/js/jquery.js'></script>\n";
     echo "<script type='text/javascript' src='/js/jquery.form.js'></script>\n";
     echo "<script type='text/javascript' src='/js/app.util.js'></script>\n";
     echo "<script type='text/javascript' src='/js/debug/apiTest.js'></script>\n";
     echo '<h2><a href="/debug/" title="返回首页">API Debug Server</a></h2>';
     echo "<hr/>";
     $user = get_user();
     if ($user) {
         echo '当前登录用户编号:' . $user['uid'], ',用户名:' . $user['uname'];
         echo " | <a href='/debug/apiTest?serviceName=UserController&actionName=login'>切换账号</a>| <a href='/debug/apiTest?serviceName=UserController&actionName=logout'>退出</a>";
     } else {
         echo "<a href='/debug/apiTest?serviceName=UserController&actionName=login'>登录</a>";
     }
     echo "<hr/>";
 }
Exemplo n.º 24
0
 public function __construct()
 {
     parent::__construct();
     if (APP_STATUS == 'product' && $_SERVER['REMOTE_ADDR'] != '121.40.129.216') {
         die('非法来源IP:' . $_SERVER['REMOTE_ADDR']);
     }
 }
Exemplo n.º 25
0
 public function __construct()
 {
     parent::__construct();
     $map['status'] = 1;
     $map['name'] = 'Ronglian';
     $config = M('addons')->where($map)->getField('config');
     if (!$config) {
         $data['status'] = false;
         $data['message'] = '不可用';
         $this->ajaxReturn($data);
     }
     $arr = json_decode($config, true);
     if (!$arr['accountSid'] || !$arr['accountToken'] || !$arr['appId'] || !$arr['Rest_URL2'] || !$arr['Rest_URL1']) {
         $data['status'] = false;
         $data['message'] = '不可用';
         $this->ajaxReturn($data);
     }
     $this->accountSid = $arr['accountSid'];
     $this->accountToken = $arr['accountToken'];
     $this->appId = $arr['appId'];
     if ($arr['type'] == 1) {
         $this->serverIP = $arr['Rest_URL1'];
     } elseif ($arr['type'] == 2) {
         $this->serverIP = $arr['Rest_URL2'];
     }
 }
Exemplo n.º 26
0
 public function __construct(Request $request = null)
 {
     if ($this->theme) {
         $this->set_theme($this->theme);
     }
     return parent::__construct($request);
 }
Exemplo n.º 27
0
 public function __construct()
 {
     parent::__construct();
     $this->assign('controller', CONTROLLER_NAME);
     //读取配置信息
     $web_stting = F('setting');
     if ($web_stting === false) {
         $params = array();
         $list = M('Setting')->getField('name,value');
         foreach ($list as $key => $val) {
             $params[$key] = unserialize($val) ? unserialize($val) : $val;
         }
         F('setting', $params);
         $web_stting = F('setting');
     }
     $this->web_stting = $web_stting;
     //站点状态判断
     if ($this->web_stting['site_status'] != 1) {
         echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
         echo $this->web_stting['closed_reason'];
         exit;
     } else {
         $this->assign('seo', seo());
     }
     //检查登录
     /* session('member_id',null);
     		if(!session('member_id'))
     		{
     			$this->wx_auto_login(); //自动登录	
     		}
     		$this->mid = session('member_id'); */
     $this->mid = 10;
     $this->m_info = M('Member')->where('member_id=' . $this->mid)->find();
 }
Exemplo n.º 28
0
 function __construct()
 {
     parent::__construct();
     //if(empty($_SESSION['USER_ID']))exit(C('SITE_LANG.LOGIN_ALERT'));//check login
     $this->comment_model = D('Comment');
     $this->piece_comment_model = D('PieceComment');
 }
Exemplo n.º 29
0
 function __construct()
 {
     // 先执行父类的构造方法 否则系统会报错
     // 因为原先的构造方法 默认是被执行的
     parent::__construct();
     // CONTROLLER_NAME ---> Goods
     // ACTION_NAME ---> showlist
     // ........\Goods\showlist 当前请求操作
     $now_ac = CONTROLLER_NAME . '-' . ACTION_NAME;
     // show_bug($now_ac); string 'Goods-showlist' (length=14)
     // 过滤控制器和方法 避免用户非法请求
     // 通过角色获取用户可以访问的控制器和方法信息
     $sql = "select auth_ac from shop_mg a join shop_role b on a.rid=b.id where a.id=" . $_SESSION['mg_id'];
     //echo $sql;
     $auth_ac = D()->query($sql);
     // show_bug($auth_ac); auth_ac' => string 'Power-list,Power-add,Power-loglist,Power-addlog' (length=47)
     // 判断 $now_ac 是否在$auth_ac 字符串里边有出现过
     // strpos 函数如果返回false 是没有出现返回 0 1 2 3 表示有出现过
     // 管理员不限制
     // 默认页面 没有权限限制
     // Index/left Index/right Index/head Index/index Manager/login
     // Manager-verify 不放行无法生成
     $allow_ac = array('Index-left', 'Index-right', 'Index-head', 'Index-index', 'Manager-login', 'Manager-verify', 'Manager-checklogin');
     if (!in_array($now_ac, $allow_ac) && $_SESSION['mg_id'] != 1 && strpos($auth_ac, $now_ac) === false) {
         $this->error('你没有权限访问', U('Manager/login'));
     }
 }
Exemplo n.º 30
0
 function __construct()
 {
     parent::__construct();
     //检查 session 是否已经登录
     $users = session('admin_info');
     if ($users) {
         if (md5($users['admin_id'] . C('secret_key')) != $users['secret_key']) {
             session_destroy();
             redirect(U('Public/login'));
             exit;
         }
         $this->admin_id = $users['admin_id'];
         $this->admin_name = $users['admin_name'];
     } else {
         redirect(U('Public/login'));
         exit;
     }
     $this->assign('loginUser', $users);
     /***----------权限控制-----------***/
     $AuthLogic = new \Admin\Logic\AuthLogic($this->admin_id);
     if (true === $AuthLogic->check_auth()) {
     } else {
         if (IS_AJAX) {
             $this->error('没有操作权限');
             exit;
         } else {
             showmessage('没有该页面权限');
             exit;
         }
     }
 }