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


PHP Piwik_Common::getIpString方法代码示例

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


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

示例1: sendFeedback

 /**
  * send email to Piwik team and display nice thanks
  */
 function sendFeedback()
 {
     $email = Piwik_Common::getRequestVar('email', '', 'string');
     $body = Piwik_Common::getRequestVar('body', '', 'string');
     $category = Piwik_Common::getRequestVar('category', '', 'string');
     $nonce = Piwik_Common::getRequestVar('nonce', '', 'string');
     $view = Piwik_View::factory('sent');
     $view->feedbackEmailAddress = Zend_Registry::get('config')->General->feedback_email_address;
     try {
         $minimumBodyLength = 35;
         if (strlen($body) < $minimumBodyLength) {
             throw new Exception(Piwik_TranslateException('Feedback_ExceptionBodyLength', array($minimumBodyLength)));
         }
         if (!Piwik::isValidEmailString($email)) {
             throw new Exception(Piwik_TranslateException('UsersManager_ExceptionInvalidEmail'));
         }
         if (preg_match('/https?:/i', $body)) {
             throw new Exception(Piwik_TranslateException('Feedback_ExceptionNoUrls'));
         }
         if (!Piwik_Nonce::verifyNonce('Piwik_Feedback.sendFeedback', $nonce)) {
             throw new Exception(Piwik_TranslateException('General_ExceptionNonceMismatch'));
         }
         Piwik_Nonce::discardNonce('Piwik_Feedback.sendFeedback');
         $mail = new Piwik_Mail();
         $mail->setFrom(Piwik_Common::unsanitizeInputValue($email));
         $mail->addTo($view->feedbackEmailAddress, 'Piwik Team');
         $mail->setSubject('[ Feedback form - Piwik ] ' . $category);
         $mail->setBodyText(Piwik_Common::unsanitizeInputValue($body) . "\n" . 'Piwik ' . Piwik_Version::VERSION . "\n" . 'IP: ' . Piwik_Common::getIpString() . "\n" . 'URL: ' . Piwik_Url::getReferer() . "\n");
         @$mail->send();
     } catch (Exception $e) {
         $view->ErrorString = $e->getMessage();
         $view->message = $body;
     }
     echo $view->render();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:38,代码来源:Controller.php

示例2: index

 function index()
 {
     $view = Piwik_View::factory('SitesManager');
     $sites = Piwik_SitesManager_API::getInstance()->getSitesWithAdminAccess();
     foreach ($sites as $site) {
         $sitesIndexedById[$site['idsite']] = $site;
     }
     Piwik_Site::setSites($sitesIndexedById);
     foreach ($sites as &$site) {
         $site['alias_urls'] = Piwik_SitesManager_API::getInstance()->getSiteUrlsFromId($site['idsite']);
         $site['excluded_ips'] = str_replace(',', '<br/>', $site['excluded_ips']);
         $site['excluded_parameters'] = str_replace(',', '<br/>', $site['excluded_parameters']);
     }
     $view->adminSites = $sites;
     $view->adminSitesCount = count($sites);
     $timezones = Piwik_SitesManager_API::getInstance()->getTimezonesList();
     $view->timezoneSupported = Piwik::isTimezoneSupportEnabled();
     $view->timezones = json_encode($timezones);
     $view->defaultTimezone = Piwik_SitesManager_API::getInstance()->getDefaultTimezone();
     $view->currencies = json_encode(Piwik_SitesManager_API::getInstance()->getCurrencyList());
     $view->defaultCurrency = Piwik_SitesManager_API::getInstance()->getDefaultCurrency();
     $view->utcTime = Piwik_Date::now()->getDatetime();
     $excludedIpsGlobal = Piwik_SitesManager_API::getInstance()->getExcludedIpsGlobal();
     $view->globalExcludedIps = str_replace(',', "\n", $excludedIpsGlobal);
     $excludedQueryParametersGlobal = Piwik_SitesManager_API::getInstance()->getExcludedQueryParametersGlobal();
     $view->globalExcludedQueryParameters = str_replace(',', "\n", $excludedQueryParametersGlobal);
     $view->currentIpAddress = Piwik_Common::getIpString();
     $this->setBasicVariablesView($view);
     $view->menu = Piwik_GetAdminMenu();
     echo $view->render();
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:31,代码来源:Controller.php

示例3: __construct

 public function __construct($forcedIpString = null, $forcedDateTime = null)
 {
     $this->timestamp = time();
     if (!empty($forcedDateTime)) {
         if (!is_int($forcedDateTime)) {
             $forcedDateTime = strtotime($forcedDateTime);
         }
         $this->timestamp = $forcedDateTime;
     }
     $ipString = $forcedIpString;
     if (empty($ipString)) {
         $ipString = Piwik_Common::getIpString();
     }
     $this->ipString = Piwik_Common::getIp($ipString);
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:15,代码来源:Visit.php

示例4: sendHttpRequest

 /**
  * Sends http request ensuring the request will fail before $timeout seconds
  *
  * If no $destinationPath is specified, the trimmed response (without header) is returned as a string.
  * If a $destinationPath is specified, the response (without header) is saved to a file.
  *
  * @param string $aUrl
  * @param int $timeout
  * @param string $userAgent
  * @param string $destinationPath
  * @param int $followDepth
  * @return true (or string) on success; false on HTTP response error code (1xx or 4xx); throws exception on all other errors
  */
 public static function sendHttpRequest($aUrl, $timeout, $userAgent = null, $destinationPath = null, $followDepth = 0)
 {
     if ($followDepth > 3) {
         throw new Exception('Too many redirects (' . $followDepth . ')');
     }
     $file = null;
     if ($destinationPath) {
         if (($file = @fopen($destinationPath, 'wb')) === false) {
             throw new Exception('Error while creating the file: ' . $destinationPath);
         }
     }
     // initialization
     $url = @parse_url($aUrl);
     if ($url === false || !isset($url['scheme'])) {
         throw new Exception('Malformed URL: ' . $aUrl);
     }
     if ($url['scheme'] != 'http') {
         throw new Exception('Invalid protocol/scheme: ' . $url['scheme']);
     }
     $host = $url['host'];
     $port = isset($url['port)']) ? $url['port'] : 80;
     $path = isset($url['path']) ? $url['path'] : '/';
     if (isset($url['query'])) {
         $path .= '?' . $url['query'];
     }
     $errno = null;
     $errstr = null;
     // connection attempt
     if (($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) === false) {
         if (is_resource($file)) {
             @fclose($file);
         }
         throw new Exception("Error while connecting to: {$host}. Please try again later.");
     }
     // send HTTP request header
     fwrite($fsock, "GET {$path} HTTP/1.0\r\n" . "Host: {$host}" . ($port != 80 ? ':' . $port : '') . "\r\n" . "User-Agent: Piwik/" . Piwik_Version::VERSION . ($userAgent ? " {$userAgent}" : '') . "\r\n" . 'Referer: http://' . Piwik_Common::getIpString() . "/\r\n" . "Connection: close\r\n" . "\r\n");
     $streamMetaData = array('timed_out' => false);
     @stream_set_blocking($fsock, true);
     @stream_set_timeout($fsock, $timeout);
     // process header
     $status = null;
     $expectRedirect = false;
     $contentLength = 0;
     $fileLength = 0;
     while (!feof($fsock)) {
         $line = fgets($fsock, 4096);
         $streamMetaData = @stream_get_meta_data($fsock);
         if ($streamMetaData['timed_out']) {
             if (is_resource($file)) {
                 @fclose($file);
             }
             @fclose($fsock);
             throw new Exception('Timed out waiting for server response');
         }
         // a blank line marks the end of the server response header
         if (rtrim($line, "\r\n") == '') {
             break;
         }
         // parse first line of server response header
         if (!$status) {
             // expect first line to be HTTP response status line, e.g., HTTP/1.1 200 OK
             if (!preg_match('~^HTTP/(\\d\\.\\d)\\s+(\\d+)(\\s*.*)?~', $line, $m)) {
                 if (is_resource($file)) {
                     @fclose($file);
                 }
                 @fclose($fsock);
                 throw new Exception('Expected server response code.  Got ' . rtrim($line, "\r\n"));
             }
             $status = (int) $m[2];
             // Informational 1xx or Client Error 4xx
             if ($status < 200 || $status >= 400) {
                 if (is_resource($file)) {
                     @fclose($file);
                 }
                 @fclose($s);
                 return false;
             }
             continue;
         }
         // handle redirect
         if (preg_match('/^Location:\\s*(.+)/', rtrim($line, "\r\n"), $m)) {
             if (is_resource($file)) {
                 @fclose($file);
             }
             @fclose($s);
             // Successful 2xx vs Redirect 3xx
             if ($status < 300) {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:101,代码来源:Piwik.php

示例5: sendHttpRequestBy

 public static function sendHttpRequestBy($method = 'socket', $aUrl, $timeout, $userAgent = null, $file = null, $followDepth = 0)
 {
     if ($followDepth > 3) {
         throw new Exception('Too many redirects (' . $followDepth . ')');
     }
     $contentLength = 0;
     if ($method == 'socket') {
         // initialization
         $url = @parse_url($aUrl);
         if ($url === false || !isset($url['scheme'])) {
             throw new Exception('Malformed URL: ' . $aUrl);
         }
         if ($url['scheme'] != 'http') {
             throw new Exception('Invalid protocol/scheme: ' . $url['scheme']);
         }
         $host = $url['host'];
         $port = isset($url['port)']) ? $url['port'] : 80;
         $path = isset($url['path']) ? $url['path'] : '/';
         if (isset($url['query'])) {
             $path .= '?' . $url['query'];
         }
         $errno = null;
         $errstr = null;
         // connection attempt
         if (($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout)) === false || !is_resource($fsock)) {
             if (is_resource($file)) {
                 @fclose($file);
             }
             throw new Exception("Error while connecting to: {$host}. Please try again later. {$errstr}");
         }
         // send HTTP request header
         fwrite($fsock, "GET {$path} HTTP/1.0\r\n" . "Host: {$host}" . ($port != 80 ? ':' . $port : '') . "\r\n" . "User-Agent: Piwik/" . Piwik_Version::VERSION . ($userAgent ? " {$userAgent}" : '') . "\r\n" . 'Referer: http://' . Piwik_Common::getIpString() . "/\r\n" . "Connection: close\r\n" . "\r\n");
         $streamMetaData = array('timed_out' => false);
         @stream_set_blocking($fsock, true);
         @stream_set_timeout($fsock, $timeout);
         // process header
         $status = null;
         $expectRedirect = false;
         $fileLength = 0;
         while (!feof($fsock)) {
             $line = fgets($fsock, 4096);
             $streamMetaData = @stream_get_meta_data($fsock);
             if ($streamMetaData['timed_out']) {
                 if (is_resource($file)) {
                     @fclose($file);
                 }
                 @fclose($fsock);
                 throw new Exception('Timed out waiting for server response');
             }
             // a blank line marks the end of the server response header
             if (rtrim($line, "\r\n") == '') {
                 break;
             }
             // parse first line of server response header
             if (!$status) {
                 // expect first line to be HTTP response status line, e.g., HTTP/1.1 200 OK
                 if (!preg_match('~^HTTP/(\\d\\.\\d)\\s+(\\d+)(\\s*.*)?~', $line, $m)) {
                     if (is_resource($file)) {
                         @fclose($file);
                     }
                     @fclose($fsock);
                     throw new Exception('Expected server response code.  Got ' . rtrim($line, "\r\n"));
                 }
                 $status = (int) $m[2];
                 // Informational 1xx or Client Error 4xx
                 if ($status < 200 || $status >= 400) {
                     if (is_resource($file)) {
                         @fclose($file);
                     }
                     @fclose($s);
                     return false;
                 }
                 continue;
             }
             // handle redirect
             if (preg_match('/^Location:\\s*(.+)/', rtrim($line, "\r\n"), $m)) {
                 if (is_resource($file)) {
                     @fclose($file);
                 }
                 @fclose($s);
                 // Successful 2xx vs Redirect 3xx
                 if ($status < 300) {
                     throw new Exception('Unexpected redirect to Location: ' . rtrim($line) . ' for status code ' . $status);
                 }
                 return self::sendHttpRequest(trim($m[1]), $pathDestination, $tries + 1);
             }
             // save expected content length for later verification
             if (preg_match('/^Content-Length:\\s*(\\d+)/', $line, $m)) {
                 $contentLength = (int) $m[1];
             }
         }
         if (feof($fsock)) {
             throw new Exception('Unexpected end of transmission');
         }
         // process content/body
         $response = '';
         while (!feof($fsock)) {
             $line = fread($fsock, 8192);
             $streamMetaData = @stream_get_meta_data($fsock);
             if ($streamMetaData['timed_out']) {
//.........这里部分代码省略.........
开发者ID:ntulip,项目名称:piwik,代码行数:101,代码来源:Piwik.php

示例6: lostPasswordFormValidated

 /**
  * Validate user (by username or email address).
  *
  * @param string $loginMail (user name or email address)
  * @param string $urlToRedirect (URL to redirect to, if successfully validated)
  * @return string (failure message if unable to validate)
  */
 protected function lostPasswordFormValidated($loginMail, $urlToRedirect)
 {
     $user = self::getUserInformation($loginMail);
     if ($user === null) {
         return Piwik_Translate('Login_InvalidUsernameEmail');
     }
     $view = Piwik_View::factory('passwordsent');
     $login = $user['login'];
     $email = $user['email'];
     // construct a password reset token from user information
     $resetToken = self::generatePasswordResetToken($user);
     $ip = Piwik_Common::getIpString();
     $url = Piwik_Url::getCurrentUrlWithoutQueryString() . "?module=Login&action=resetPassword&token={$resetToken}";
     // send email with new password
     try {
         $mail = new Piwik_Mail();
         $mail->addTo($email, $login);
         $mail->setSubject(Piwik_Translate('Login_MailTopicPasswordRecovery'));
         $mail->setBodyText(str_replace('\\n', "\n", sprintf(Piwik_Translate('Login_MailPasswordRecoveryBody'), $login, $ip, $url, $resetToken)) . "\n");
         $piwikHost = $_SERVER['HTTP_HOST'];
         if (strlen($piwikHost) == 0) {
             $piwikHost = 'piwik.org';
         }
         $fromEmailName = Zend_Registry::get('config')->General->login_password_recovery_email_name;
         $fromEmailAddress = Zend_Registry::get('config')->General->login_password_recovery_email_address;
         $fromEmailAddress = str_replace('{DOMAIN}', $piwikHost, $fromEmailAddress);
         $mail->setFrom($fromEmailAddress, $fromEmailName);
         @$mail->send();
     } catch (Exception $e) {
         $view->ErrorString = $e->getMessage();
     }
     $view->linkTitle = Piwik::getRandomTitle();
     $view->urlToRedirect = $urlToRedirect;
     echo $view->render();
     exit;
 }
开发者ID:Doluci,项目名称:tomatocart,代码行数:43,代码来源:Controller.php


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