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


PHP helper::getRemoteIp方法代码示例

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


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

示例1: saveRegion

 /**
  * Save region data.
  * 
  * @access public
  * @return void
  */
 public function saveRegion()
 {
     $year = date('Y');
     $month = date('Ym');
     $day = date('Ymd');
     $hour = date('YmdH');
     $time = new stdclass();
     $time->year = $year;
     $time->month = $month;
     $time->day = $day;
     $time->hour = $hour;
     foreach ($time as $type => $value) {
         $oldRegion = $this->dao->select('*')->from(TABLE_STATREGION)->where('timeType')->eq($type)->andWhere('timeValue')->eq($value)->fetch();
         if (!empty($oldRegion)) {
             $ipAndUv = $this->dao->select('count(distinct(ip)) as ip, count(distinct(visitor)) as uv')->from(TABLE_STATLOG)->where($type)->eq($value)->fetch();
             $this->dao->update(TABLE_STATREGION)->set('pv = pv + 1')->set('uv')->eq($ipAndUv->uv)->set('ip')->eq($ipAndUv->ip)->where('id')->eq($oldRegion->id)->exec();
         } else {
             $location = $this->app->loadClass('IP')->find(helper::getRemoteIp());
             $region = new stdclass();
             $region->timeType = $type;
             $region->timeValue = $value;
             $region->country = $location[0];
             $region->province = $location[1];
             $region->city = $location[2];
             $region->pv = 1;
             $region->uv = 1;
             $region->ip = 1;
             $this->dao->insert(TABLE_STATREGION)->data($region)->exec();
         }
     }
     return !dao::isError();
 }
开发者ID:dyp8848,项目名称:chanzhieps,代码行数:38,代码来源:model.php

示例2: setSecurity

 /**
  * set site security info.
  *
  * @access public
  * @return void
  */
 public function setSecurity()
 {
     $this->lang->site->menu = $this->lang->security->menu;
     $this->lang->menuGroups->site = 'security';
     $captcha = (isset($this->config->site->captcha) and ($this->config->site->captcha == 'open' and ($this->post->captcha == 'close' or $this->post->captcha == 'auto')) or (!isset($this->config->site->captcha) or $this->config->site->captcha == 'auto') and $this->post->captcha == 'close');
     $checkEmail = (isset($this->config->site->checkEmail) and $this->config->site->checkEmail == 'open' and $this->post->checkEmail == 'close');
     $front = (isset($this->config->site->front) and $this->config->site->front == 'login' and $this->post->front == 'guest');
     $checkLocation = (isset($this->config->site->checkLocation) and $this->config->site->checkLocation == 'open' and $this->post->checkLocation == 'close');
     $checkSessionIP = (isset($this->config->site->checkSessionIP) and $this->config->site->checkSessionIP == 1 and $this->post->checkSessionIP == 0);
     $allowedIP = (isset($this->config->site->allowedIP) and $this->config->site->allowedIP != $this->post->allowedIP);
     $newImportantValidate = $this->post->importantValidate ? $this->post->importantValidate : array();
     $oldImportantValidate = explode(',', $this->config->site->importantValidate);
     $importantChange = false;
     foreach ($oldImportantValidate as $validate) {
         if (!in_array($validate, $newImportantValidate)) {
             $importantChange = true;
             break;
         }
     }
     if ($captcha or $checkEmail or $front or $checkLocation or $checkSessionIP or $allowedIP or $importantChange) {
         $okFile = $this->loadModel('common')->verifyAdmin();
         $pass = $this->loadModel('guarder')->verify('okFile');
         $this->view->pass = $pass;
         $this->view->okFile = $okFile;
         if (!empty($_POST) && !$pass) {
             $this->send(array('result' => 'fail', 'reason' => 'captcha'));
         }
     }
     if (!empty($_POST)) {
         $setting = fixer::input('post')->setDefault('captcha', 'auto')->setDefault('filterSensitive', 'close')->setDefault('checkIP', 'close')->setDefault('checkSessionIP', '0')->setDefault('checkLocation', 'close')->setDefault('checkEmail', 'close')->setDefault('allowedIP', '')->setDefault('importantValidate', '')->join('importantValidate', ',')->setForce('sensitive', seo::unify($this->post->sensitive, ','))->get();
         /* check IP. */
         $ips = !$this->post->allowedIP ? array() : explode(',', $this->post->allowedIP);
         foreach ($ips as $ip) {
             if (!empty($ip) and !helper::checkIP($ip)) {
                 dao::$errors['allowedIP'][] = $this->lang->site->wrongAllowedIP;
                 break;
             }
         }
         $result = $this->loadModel('setting')->setItems('system.common.site', $setting, 'all');
         if ($result) {
             $this->send(array('result' => 'success', 'message' => $this->lang->setSuccess, 'locate' => inlink('setsecurity')));
         }
         $this->send(array('result' => 'fail', 'message' => dao::getError()));
     }
     $location = $this->app->loadClass('IP')->find(helper::getRemoteIp());
     if (is_array($location)) {
         $locations = $location;
         $location = join(' ', $locations);
         if (count($location) > 3) {
             $location = $locations[0] . ' ' . $locations[1] . ' ' . $locations[2];
         }
     }
     $this->view->title = $this->lang->site->setBasic;
     $this->view->location = $location;
     $this->display();
 }
开发者ID:hansen1416,项目名称:eastsoft,代码行数:62,代码来源:control.php

示例3: signIn

 /**
  * sign in.
  * 
  * @param  string $account 
  * @param  string $date 
  * @access public
  * @return bool
  */
 public function signIn($account = '', $date = '')
 {
     if ($account == '') {
         $account = $this->app->user->account;
     }
     if ($date == '') {
         $date = date('Y-m-d');
     }
     $attend = $this->dao->select('*')->from(TABLE_ATTEND)->where('account')->eq($account)->andWhere('`date`')->eq($date)->fetch();
     if (empty($attend)) {
         $attend = new stdclass();
         $attend->account = $account;
         $attend->date = $date;
         $attend->signIn = helper::time();
         $attend->ip = helper::getRemoteIp();
         $this->dao->insert(TABLE_ATTEND)->data($attend)->autoCheck()->exec();
         return !dao::isError();
     }
     if ($attend->signIn == '' or $attend->signIn == '00:00:00') {
         $this->dao->update(TABLE_ATTEND)->set('signIn')->eq(helper::time())->where('id')->eq($attend->id)->exec();
         return !dao::isError();
     }
     return true;
 }
开发者ID:leowh,项目名称:colla,代码行数:32,代码来源:model.php

示例4: checkLoginLocation

 /**
  * Check last login location.
  *
  * @param  string $account
  * @access public
  * @return void
  */
 public function checkLoginLocation($account)
 {
     if (!isset($this->config->site->checkLocation) or $this->config->site->checkLocation == 'close') {
         return true;
     }
     $location = $this->app->loadClass('IP')->find(helper::getRemoteIp());
     if (is_array($location)) {
         $locations = $location;
         $location = join(' ', $locations);
         if (count($location) > 3) {
             $location = $locations[0] . ' ' . $locations[1] . ' ' . $locations[2];
         }
     }
     $lastLocation = $this->dao->select('location')->from(TABLE_LOG)->where('account')->eq($account)->andWhere('`desc`')->eq('success')->andWhere('type')->eq('adminlogin')->orderBy('date_desc')->limit(1)->fetch('location');
     if ($lastLocation and trim($location) != $lastLocation) {
         return false;
     }
     return true;
 }
开发者ID:qiaqiali,项目名称:chanzhieps,代码行数:26,代码来源:model.php

示例5: checkLocation

 /**
  * checkLocation 
  * 
  * @access public
  * @return bool
  */
 public function checkLocation()
 {
     if (isset($this->config->site->safeMode) and $this->config->site->safeMode == '1') {
         return true;
     }
     if (!isset($this->config->site->checkLocation) or $this->config->site->checkLocation == 'close') {
         return true;
     }
     if (!isset($this->config->site->allowedLocation) or $this->config->site->allowedLocation == '') {
         return true;
     }
     $allowedLocation = $this->config->site->allowedLocation;
     $location = $this->app->loadClass('IP')->find(helper::getRemoteIp());
     if (is_array($location)) {
         $locations = $location;
         $location = join(' ', $locations);
         if (count($location) > 3) {
             $location = $locations[0] . ' ' . $locations[1] . ' ' . $locations[2];
         }
     }
     return $allowedLocation == $location;
 }
开发者ID:AlenWon,项目名称:chanzhieps,代码行数:28,代码来源:model.php


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