本文整理汇总了PHP中Piwik_Common::substr方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_Common::substr方法的具体用法?PHP Piwik_Common::substr怎么用?PHP Piwik_Common::substr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_Common
的用法示例。
在下文中一共展示了Piwik_Common::substr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputBinaryImage
/**
* Output binary image from base-64 encoded data.
*
* @deprecated 1.5.1
*
* @param string $imageData Base-64 encoded image data (via $_POST)
*/
public static function outputBinaryImage()
{
Piwik::checkUserHasSomeViewAccess();
$rawData = Piwik_Common::getRequestVar('imageData', '', 'string', $_POST);
// returns false if any illegal characters in input
$data = base64_decode($rawData);
if ($data !== false) {
// check for PNG header
if (Piwik_Common::substr($data, 0, 8) === "‰PNG\r\n\n") {
header('Content-Type: image/png');
// more robust validation (if available)
if (function_exists('imagecreatefromstring')) {
// validate image data
$imgResource = @imagecreatefromstring($data);
if ($imgResource !== false) {
// output image and clean-up
imagepng($imgResource);
imagedestroy($imgResource);
exit;
}
} else {
echo $data;
exit;
}
}
}
Piwik::setHttpStatus('400 Bad Request');
exit;
}
示例2: long2ip
/**
* Convert IP address (in network address format) to presentation format.
* This is a backward compatibility function for code that only expects
* IPv4 addresses (i.e., doesn't support IPv6).
*
* This function does not support the long (or its string representation)
* returned by the built-in ip2long() function, from Piwik 1.3 and earlier.
*
* @param string $ip IPv4 address in network address format
* @return string IP address in presentation format
*/
public static function long2ip($ip)
{
// IPv4
if (Piwik_Common::strlen($ip) == 4) {
return self::N2P($ip);
}
// IPv6 - transitional address?
if (Piwik_Common::strlen($ip) == 16) {
if (substr_compare($ip, "ÿÿ", 0, 12) === 0 || substr_compare($ip, "", 0, 12) === 0) {
// remap 128-bit IPv4-mapped and IPv4-compat addresses
return self::N2P(Piwik_Common::substr($ip, 12));
}
}
return '0.0.0.0';
}
示例3: getConfigHash
/**
* Returns a 64-bit hash of all the configuration settings
* @param $os
* @param $browserName
* @param $browserVersion
* @param $resolution
* @param $plugin_Flash
* @param $plugin_Java
* @param $plugin_Director
* @param $plugin_Quicktime
* @param $plugin_RealPlayer
* @param $plugin_PDF
* @param $plugin_WindowsMedia
* @param $plugin_Gears
* @param $plugin_Silverlight
* @param $plugin_Cookie
* @param $ip
* @param $browserLang
* @return string
*/
protected function getConfigHash($os, $browserName, $browserVersion, $resolution, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ip, $browserLang)
{
$hash = md5($os . $browserName . $browserVersion . $plugin_Flash . $plugin_Java . $plugin_Director . $plugin_Quicktime . $plugin_RealPlayer . $plugin_PDF . $plugin_WindowsMedia . $plugin_Gears . $plugin_Silverlight . $plugin_Cookie . $ip . $browserLang, $raw_output = true);
return Piwik_Common::substr($hash, 0, Piwik_Tracker::LENGTH_BINARY_ID);
}