当前位置: 首页>>代码示例>>PHP>>正文


PHP CMS::getip方法代码示例

本文整理汇总了PHP中CMS::getip方法的典型用法代码示例。如果您正苦于以下问题:PHP CMS::getip方法的具体用法?PHP CMS::getip怎么用?PHP CMS::getip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMS的用法示例。


在下文中一共展示了CMS::getip方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: authenticate

 public function authenticate()
 {
     $record = User::model()->with('group')->findByAttributes(array('login' => $this->username));
     if ($record === null) {
         $this->errorCode = self::ERROR_USERNAME_INVALID;
     } else {
         if ($record->banned === '1') {
             $this->errorCode = self::ERROR_PASSWORD_INVALID;
         } else {
             if ($record->password !== User::encodePassword($this->password)) {
                 $this->errorCode = self::ERROR_PASSWORD_INVALID;
             } else {
                 $this->_id = $record->id;
                 $this->_login = $record->login;
                 $record->last_login = date('Y-m-d H:i:s');
                 $record->login_ip = CMS::getip();
                 $record->save(false, false, false);
                 $this->setState('id', $record->id);
                 $this->setState('username', $record->login);
                 $this->setState('roles', $record->group->alias);
                 $this->errorCode = self::ERROR_NONE;
             }
         }
     }
     return !$this->errorCode;
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:26,代码来源:EngineUserIdentity.php

示例2: init

 public function init()
 {
     $this->userIP = CMS::getip();
     if ($this->verify_ip_ban()) {
         header("HTTP/1.0 403 Forbidden");
         header("HTTP/1.1 403 Forbidden");
         header("Status: 403 Forbidden");
         Yii::app()->controllerMap['bannedip'] = 'application.components.bannedIP.bannedIPController';
         Yii::app()->catchAllRequest = array('bannedip/index');
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:11,代码来源:BannedIP.php

示例3: set

 public function set($message, $params = array())
 {
     $browser = new Browser();
     $model = new Timeline();
     $model->user_id = Yii::app()->user->id;
     $model->message = Yii::t('timeline', $message, $params);
     $model->user_agent = $browser->getUserAgent();
     $model->ip = CMS::getip();
     $model->user_platform = $browser->getPlatform();
     $model->save(false, false, false);
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:11,代码来源:CTimeline.php

示例4: init

 public function init()
 {
     $config = Yii::app()->settings->get('core');
     if ($config['site_close']) {
         $users = explode(',', $config['site_close_allowed_users']);
         $ips = explode(',', $config['site_close_allowed_ip']);
         $disable = in_array(Yii::app()->user->name, $users);
         foreach ($this->roles as $role) {
             $disable = $disable || Yii::app()->user->checkAccess($role);
         }
         $disable = $disable || in_array(Yii::app()->request->getPathInfo(), $this->urls);
         $disable = $disable || in_array(CMS::getip(), $ips);
         //check "allowed IP"
         if (!$disable) {
             if ($this->capUrl === 'maintenance/index') {
                 Yii::app()->controllerMap['maintenance'] = 'application.components.MaintenanceMode.MaintenanceController';
             }
             Yii::app()->catchAllRequest = array($this->capUrl);
         }
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:21,代码来源:MaintenanceMode.php

示例5: actionRating

 public function actionRating()
 {
     $request = Yii::app()->request;
     if ($request->isAjaxRequest) {
         $mod = $_REQUEST['module'];
         $rating = (int) $_REQUEST['rating'];
         $id = (int) $_REQUEST['pid'];
         $baseModel = $_REQUEST['model'];
         $model = $baseModel::model()->findByPk($id);
         if ($model && in_array($rating, array(1, 2, 3, 4, 5))) {
             $model->score += 1;
             $model->rating += $rating;
             $model->save();
             $new = time();
             $ratingModel = new EngineRating();
             $ratingModel->mid = $id;
             $ratingModel->modul = $mod;
             $ratingModel->time = $new;
             $ratingModel->user_id = Yii::app()->user->getId();
             $ratingModel->host = CMS::getip();
             $ratingModel->save();
             $cookie = new CHttpCookie($mod . "-" . $id, $id);
             $cookie->expire = time() + 60 * 60 * 24 * 60;
             Yii::app()->request->cookies[$mod . "-" . $id] = $cookie;
             $this->widget('ext.rating.Rating', array('pid' => $id, 'rating' => $model->rating, 'votes' => $model->score, 'active' => false));
         }
     } else {
         die('error');
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:30,代码来源:AjaxController.php

示例6: __construct

 /**
  * Initialize stats component
  */
 public function __construct()
 {
     if (!Yii::app()->request->isAjaxRequest && $this->checkIgnoreRoute()) {
         $offset = 0;
         $t = time() + 3600 * $offset;
         $day = date("D", $t);
         $dt = date("Ymd", $t);
         $tm = date("H:i", $t);
         $refer = $_SERVER['HTTP_REFERER'];
         $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
         $user = $_SERVER['HTTP_USER_AGENT'];
         $req = $_SERVER['REQUEST_URI'];
         if ($ip = $_SERVER['HTTP_X_FORWARDED_FOR']) {
             if (!stristr($_SERVER['HTTP_X_FORWARDED_FOR'], CMS::getip()) and !empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
                 $ip .= ", " . CMS::getip();
             } else {
                 $ip = CMS::getip();
             }
             $proxy = CMS::getip();
         } else {
             $ip = CMS::getip();
             $proxy = "";
         }
         if ($proxy == $ip) {
             $proxy = "";
         }
         $a = explode(", ", $ip);
         $real_ip = $a[count($a) - 1];
         if (!empty($proxy)) {
             $host = gethostbyaddr($proxy);
         } else {
             if ($host = gethostbyaddr($ip)) {
             } else {
                 if ($host = gethostbyaddr($real_ip)) {
                 } else {
                     $host = $ip;
                 }
             }
         }
         $model = new StatsSurf();
         $model->day = $day;
         $model->dt = $dt;
         $model->tm = $tm;
         $model->refer = $refer;
         $model->ip = $ip;
         $model->proxy = $proxy;
         $model->host = $host;
         $model->lang = $lang;
         $model->user = $user;
         $model->req = $req;
         if (!$model->save(false, false, false)) {
             Yii::log('Error save stats', 'info', 'stats');
         }
     }
 }
开发者ID:buildshop,项目名称:bs-common,代码行数:58,代码来源:Stats.php


注:本文中的CMS::getip方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。