當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Piwik_Common::substr方法代碼示例

本文整理匯總了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;
 }
開發者ID:neolf,項目名稱:PIWIK4MOBILE,代碼行數:36,代碼來源:Controller.php

示例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';
 }
開發者ID:neolf,項目名稱:PIWIK4MOBILE,代碼行數:26,代碼來源:IP.php

示例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);
 }
開發者ID:nnnnathann,項目名稱:piwik,代碼行數:25,代碼來源:Visit.php


注:本文中的Piwik_Common::substr方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。