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


PHP request::ip方法代码示例

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


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

示例1: action_index

 public function action_index()
 {
     // clear buffer
     helper_ob::clean_all();
     // validating
     do {
         $options = application::get('flag.numbers.backend.cron.base');
         // token
         if (!empty($options['token']) && request::input('token') != $options['token']) {
             break;
         }
         // ip
         if (!empty($options['ip']) && !in_array(request::ip(), $options['ip'])) {
             break;
         }
         // get date parts
         $date_parts = format::now('parts');
         print_r($date_parts);
         echo "GOOD\n";
     } while (0);
     // we need to validate token
     //$token = request::input('token');
     echo "OK\n";
     // exit
     exit;
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:26,代码来源:execute.php

示例2: start

 /**
  * Starting session
  *
  * @param array $options
  */
 public static function start($options)
 {
     // setting default options
     foreach (self::$default_options as $k => $v) {
         if (isset($options[$k]) || array_key_exists($k, $options)) {
             ini_set("session.{$k}", $options[$k]);
             self::$default_options[$k] = $options[$k];
         } else {
             if (isset(self::$default_options[$k])) {
                 ini_set("session.{$k}", $v);
             }
         }
     }
     // starting session submodule if we have one
     $class = application::get('flag.global.session.submodule', ['class' => 1]);
     if (!empty($class)) {
         $object = new $class();
         $object->init();
         self::$object = $object;
     }
     // starting session
     session_start();
     // session fixation prevention
     if (empty($_SESSION['numbers']['flag_generated_by_system'])) {
         session_regenerate_id(true);
         $_SESSION = [];
         $_SESSION['numbers']['flag_generated_by_system'] = true;
     }
     // processing IP address
     $ip = request::ip();
     // we need to reset ip address details if we have different ip
     if (!empty($_SESSION['numbers']['ip']['ip']) && $_SESSION['numbers']['ip']['ip'] != $ip) {
         $_SESSION['numbers']['ip'] = [];
     }
     // we need to try to decode ip address
     if (!isset($_SESSION['numbers']['ip']['ip'])) {
         $ip_submodule = application::get('flag.global.ip.submodule', ['class' => 1]);
         if (!empty($ip_submodule)) {
             $ip_object = new $ip_submodule();
             $ip_data = $ip_object->get($ip);
             if ($ip_data['success']) {
                 $_SESSION['numbers']['ip'] = $ip_data['data'];
             }
         }
         // we only store ip address if its not set
         if (!isset($_SESSION['numbers']['ip']['ip'])) {
             $_SESSION['numbers']['ip'] = ['ip' => $ip];
         }
     }
 }
开发者ID:volodymyr-volynets,项目名称:framework,代码行数:55,代码来源:session.php

示例3: token_validate

 /**
  * see crypt::token_validate();
  */
 public function token_validate($token, $options = [])
 {
     $result = ['id' => null, 'data' => null, 'time' => null, 'ip' => request::ip()];
     if ($this->base64) {
         $token2 = base64_decode($token);
     } else {
         $token2 = $token;
     }
     $digest = substr($token2, 0, 32);
     $result['time'] = hexdec(substr($token2, 32, 8));
     $temp = explode('!', substr($token2, 40, strlen($token2)));
     $result['id'] = $temp[0];
     $result['data'] = unserialize(base64_decode($temp[2]));
     $rebuilt = self::token_create($result['id'], $result['data'], ['time' => $result['time'], 'ip' => $result['ip']]);
     if (urldecode($rebuilt) != $token) {
         return false;
     } else {
         // todo: validate valid_hours
         return $result;
     }
 }
开发者ID:volodymyr-volynets,项目名称:backend,代码行数:24,代码来源:base.php

示例4: write

 public function write($id, $data)
 {
     // Don't run without a database connection
     if (!$this->db->link()) {
         return FALSE;
     }
     // Only write once...
     if ($this->written) {
         return true;
     }
     $data = array('session_id' => $id, 'session_ip' => request::ip(), 'session_user_agent' => $_SERVER['HTTP_USER_AGENT'], 'session_last_activity' => time(), 'session_data' => $this->encrypt === NULL ? base64_encode($data) : $this->encrypt->encode($data));
     if ($this->session_id === NULL) {
         // Insert a new session
         $this->db->use_master(YES);
         $query = $this->db->insert($this->table, $data);
     } elseif ($id === $this->session_id) {
         // Do not update the session_id
         unset($data['session_id']);
         // Update the existing session
         $this->db->use_master(YES);
         $query = $this->db->update($this->table, $data, array('session_id' => $id));
     } else {
         // Update the session and id
         $this->db->use_master(YES);
         $query = $this->db->update($this->table, $data, array('session_id' => $this->session_id));
         // Set the new session id
         $this->session_id = $id;
     }
     // Written!
     $this->written = true;
     return (bool) $query->count();
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:32,代码来源:database.php

示例5: text

 /**
  * Get a single line of text representing the exception:
  *
  * Error [ Code ]: Message ~ File [ Line ]
  *
  * @param   object  Exception
  * @return  string
  */
 public static function text($e, $full_args = FALSE)
 {
     // Should we use the full argument length or truncate?
     $arg_char_limit = $full_args ? 2500 : 50;
     // Clean up the message a bit
     $message = str_replace(array("<br>", "<br/>", "<br />", "\r\n", "\n", "\r"), '; ', strip_tags($e->getMessage()));
     // How was the request made
     $called = 'Request:' . "\n";
     $method = strtoupper(request::method());
     if ($method == 'CLI') {
         $called .= 'CLI - ' . cli::launch_cmd();
     } else {
         $called .= '[' . $method . '] ' . request::ip() . ' - ' . request::protocol() . '://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
         if (is_array($_POST) && count($_POST) > 0) {
             $called .= "\n\nBody:\n";
             $called .= var_export($_POST, TRUE);
         }
     }
     return sprintf('%s [ %s ]: %s ~ %s [ %d ]' . "\n\n" . '%s' . "\n\n" . '%s' . "\n", get_class($e), $e->getCode(), $message, Eight_Exception::debug_path($e->getFile()), $e->getLine(), $called, Eight_Exception::trace_string($e->getTrace(), $arg_char_limit));
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:28,代码来源:exception.php


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