示例#1
0
 private function getRedisPool()
 {
     $redisConfigFile = $this->container->getParameter('kernel.root_dir') . '/data/redis.php';
     if (file_exists($redisConfigFile)) {
         $redisConfig = (include $redisConfigFile);
         $this->redisPool = RedisPool::init($redisConfig);
         return $this->redisPool;
     }
     return false;
 }
 /**
  * 后台控制器初始化
  */
 protected function _initialize()
 {
     // 获取当前用户ID
     define('UID', is_login());
     if (!UID) {
         // 还没登录 跳转到登录页面
         $this->redirect('Public/login');
     }
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = api('Config/lists');
         S('DB_CONFIG_DATA', $config);
     }
     C($config);
     //添加配置
     // 是否是超级管理员
     define('IS_ROOT', is_administrator());
     if (!IS_ROOT && C('ADMIN_ALLOW_IP')) {
         // 检查IP地址访问
         if (!in_array(get_client_ip(), explode(',', C('ADMIN_ALLOW_IP')))) {
             $this->error('403:禁止访问');
         }
     }
     import("Common.Util.RedisPool");
     $this->redis = \RedisPool::getconnect();
     // 检测访问权限
     /*$access =   $this->accessControl();
       if ( $access === false ) {
           $this->error('403:禁止访问');
       }elseif( $access === null ){
           $dynamic        =   $this->checkDynamic();//检测分类栏目有关的各项动态权限
           if( $dynamic === null ){
               //检测非动态权限
               $rule  = strtolower(MODULE_NAME.'/'.CONTROLLER_NAME.'/'.ACTION_NAME);
               if ( !$this->checkRule($rule,array('in','1,2')) ){
                   $this->error('未授权访问!');
               }
           }elseif( $dynamic === false ){
               $this->error('未授权访问!');
           }
       }
       */
     $this->assign('__MENU__', $this->getMenus());
 }
示例#3
0
 public function _initialize()
 {
     import("Common.Util.RedisPool");
     $this->redis = \RedisPool::getconnect();
     //TODO: 用户登录检测
     $not_login = array('Index' => array('index' => 1, 'test' => 1), 'Public' => array('getbaselanguage' => 1, 'gettags' => 1), 'Passport' => array('login' => 1, 'changepwd' => 1, 'ologin' => 1), 'User' => array('index' => 1, 'comment' => 1), 'Reg' => array('getmobilecode' => 1, 'register' => 1), 'Square' => array('topic' => 1, 'nearby' => 1, 'topicuser' => 1, 'charts' => 1), 'Ad' => array('getad' => 1));
     if (!$not_login[CONTROLLER_NAME][ACTION_NAME]) {
         $this->mid = I('post.userId');
         $token = I('post.token');
         $server_token = $this->redis->GET('Token:uid' . $this->mid);
         if (!$server_token) {
             $this->return['code'] = 401;
             $this->return['message'] = L('token_lose');
             $this->goJson($this->return);
         } elseif ($server_token != $token) {
             $this->return['code'] = 401;
             $this->return['message'] = L('token_error');
             $this->goJson($this->return);
         }
     }
 }
示例#4
0
文件: PHPMQ.php 项目: rainsj/note
   public function init()
   {
        RedisPool::addServer(array("F1"=>array('127.0.0.1',6379)));
	$redis=RedisPool::getRedis("F1");
   }   
示例#5
0
 public function _initialize()
 {
     import("Common.Util.RedisPool");
     $this->redis = \RedisPool::getconnect();
 }
示例#6
0
文件: reg.php 项目: rainsj/note
require 'RedisPool.php';
if(isset($_POST["username"])){
/*
    try{
        $pdo=new PDO(DSN,USER,PASS);    
    }catch(PDOException $e){
        die($e->getMessage);
    }
*/
    $conf=array(
    'FA'=>array('127.0.0.1',6379)
    );

    RedisPool::addServer($conf);
    $redis= RedisPool::getRedis('FA');
    $username=$_POST["username"];
    $password=$_POST["password"];
    $data=array();
    $data["username"]=$username;
    $data["password"]=$password;
    require '../../lib/UserMQ.php';
    UserMQ:MQ()->push($data);
  //  $sql = "insert into tb_user values(null,?,?)";
  //  $stmt = $pdo->prepare($sql);
  //  $stmt->execute(array($username,$password));

    $redis->set("string:user:"******"list:users",$username);
}