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


PHP PMF_String::strstr方法代码示例

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


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

示例1: userTracking

 /**
  * Tracks the user and log what he did
  *
  * @param  string  $action Action string
  * @param  integer $id     Current ID
  *
  * @return void
  */
 public function userTracking($action, $id = 0)
 {
     global $sid, $user, $botBlacklist;
     if ($this->_config->get('main.enableUserTracking')) {
         $bots = 0;
         $banned = false;
         $agent = $_SERVER['HTTP_USER_AGENT'];
         $sid = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
         $sidc = PMF_Filter::filterInput(INPUT_COOKIE, self::PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);
         if (!is_null($sidc)) {
             $sid = $sidc;
         }
         if ($action == 'old_session') {
             $sid = null;
         }
         foreach ($botBlacklist as $bot) {
             if ((bool) PMF_String::strstr($agent, $bot)) {
                 $bots++;
             }
         }
         $network = new PMF_Network($this->_config);
         // if we're running behind a reverse proxy like nginx/varnish, fix the client IP
         $remoteAddr = $_SERVER['REMOTE_ADDR'];
         $localAddresses = array('127.0.0.1', '::1');
         if (in_array($remoteAddr, $localAddresses) && isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
             $remoteAddr = $_SERVER['HTTP_X_FORWARDED_FOR'];
         }
         // clean up as well
         $remoteAddr = preg_replace('([^0-9a-z:\\.]+)i', '', $remoteAddr);
         if (!$network->checkIp($remoteAddr)) {
             $banned = true;
         }
         if (0 == $bots && false == $banned) {
             if (!isset($sid)) {
                 $sid = $this->_config->getDb()->nextId(PMF_Db::getTablePrefix() . 'faqsessions', 'sid');
                 // Sanity check: force the session cookie to contains the current $sid
                 if (!is_null($sidc) && !$sidc != $sid) {
                     self::setCookie(self::PMF_COOKIE_NAME_SESSIONID, $sid);
                 }
                 $query = sprintf("\n                        INSERT INTO \n                            %sfaqsessions\n                        (sid, user_id, ip, time)\n                            VALUES\n                        (%d, %d, '%s', %d)", PMF_Db::getTablePrefix(), $sid, $user ? $user->getUserId() : -1, $remoteAddr, $_SERVER['REQUEST_TIME']);
                 $this->_config->getDb()->query($query);
             }
             $data = $sid . ';' . str_replace(';', ',', $action) . ';' . $id . ';' . $remoteAddr . ';' . str_replace(';', ',', isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '') . ';' . str_replace(';', ',', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . ';' . str_replace(';', ',', urldecode($_SERVER['HTTP_USER_AGENT'])) . ';' . $_SERVER['REQUEST_TIME'] . ";\n";
             $file = './data/tracking' . date('dmY');
             if (is_writeable($file)) {
                 file_put_contents($file, $data, FILE_APPEND);
             } else {
                 throw new PMF_Exception('Cannot write to ' . $file);
             }
         }
     }
 }
开发者ID:maggiofrancesco,项目名称:phpMyFAQ,代码行数:60,代码来源:Session.php

示例2: strstr

 /**
  * Get occurence of a string within another
  * 
  * @param string  $haystack Haystack
  * @param string  $needle   Needle
  * @param boolean $part     Part
  * 
  * @return string|false
  */
 public static function strstr($haystack, $needle, $part = false)
 {
     return self::$instance->strstr($haystack, $needle, $part);
 }
开发者ID:noon,项目名称:phpMyFAQ,代码行数:13,代码来源:String.php

示例3: userTracking

 /**
  * Tracks the user and log what he did
  * 
  * @param  string  $action Action string
  * @param  integer $id     Current ID
  * 
  * @return void
  */
 public function userTracking($action, $id = 0)
 {
     global $sid, $user, $botBlacklist;
     if (PMF_Configuration::getInstance()->get('main.enableUserTracking')) {
         $bots = 0;
         $banned = false;
         $agent = $_SERVER['HTTP_USER_AGENT'];
         $sid = PMF_Filter::filterInput(INPUT_GET, PMF_GET_KEY_NAME_SESSIONID, FILTER_VALIDATE_INT);
         $sidc = PMF_Filter::filterInput(INPUT_COOKIE, PMF_COOKIE_NAME_SESSIONID, FILTER_VALIDATE_INT);
         if (!is_null($sidc)) {
             $sid = $sidc;
         }
         if ($action == 'old_session') {
             $sid = null;
         }
         foreach ($botBlacklist as $bot) {
             if ((bool) PMF_String::strstr($agent, $bot)) {
                 $bots++;
             }
         }
         $network = new PMF_Network();
         if (!$network->checkIp($_SERVER['REMOTE_ADDR'])) {
             $banned = true;
         }
         if (0 == $bots && false == $banned) {
             if (!isset($sid)) {
                 $sid = $this->db->nextID(SQLPREFIX . 'faqsessions', 'sid');
                 // Sanity check: force the session cookie to contains the current $sid
                 if (!is_null($sidc) && !$sidc != $sid) {
                     self::setCookie($sid);
                 }
                 $query = sprintf("\n                        INSERT INTO \n                            %sfaqsessions\n                        (sid, user_id, ip, time)\n                            VALUES\n                        (%d, %d, '%s', %d)", SQLPREFIX, $sid, $user ? $user->getUserId() : -1, $_SERVER['REMOTE_ADDR'], $_SERVER['REQUEST_TIME']);
                 $this->db->query($query);
             }
             $data = $sid . ';' . str_replace(';', ',', $action) . ';' . $id . ';' . $_SERVER['REMOTE_ADDR'] . ';' . str_replace(';', ',', $_SERVER['QUERY_STRING']) . ';' . str_replace(';', ',', isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . ';' . str_replace(';', ',', urldecode($_SERVER['HTTP_USER_AGENT'])) . ';' . $_SERVER['REQUEST_TIME'] . ";\n";
             $file = './data/tracking' . date('dmY');
             file_put_contents($file, $data, FILE_APPEND);
         }
     }
 }
开发者ID:atlcurling,项目名称:tkt,代码行数:48,代码来源:Session.php


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