本文整理汇总了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);
}
}
}
}
示例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);
}
示例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);
}
}
}