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


PHP Piwik\ProxyHttp類代碼示例

本文整理匯總了PHP中Piwik\ProxyHttp的典型用法代碼示例。如果您正苦於以下問題:PHP ProxyHttp類的具體用法?PHP ProxyHttp怎麽用?PHP ProxyHttp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ProxyHttp類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: sendHeader

 public function sendHeader()
 {
     if ($this->isJsonp()) {
         Common::sendHeader('Content-Type: application/javascript; charset=utf-8');
     } else {
         Renderer\Json::sendHeaderJSON();
     }
     ProxyHttp::overrideCacheControlHeaders();
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:9,代碼來源:Json.php

示例2: addJsGlobalVariables

 public function addJsGlobalVariables(&$out)
 {
     if (ProxyHttp::isHttps()) {
         $isHttps = 'true';
     } else {
         $isHttps = 'false';
     }
     $out .= "piwik.hasServerDetectedHttps = {$isHttps};\n";
 }
開發者ID:piwik,項目名稱:piwik,代碼行數:9,代碼來源:CoreAdminHome.php

示例3: notifyIfURLIsNotSecure

 private static function notifyIfURLIsNotSecure()
 {
     $isURLSecure = ProxyHttp::isHttps();
     if ($isURLSecure) {
         return;
     }
     if (!Piwik::hasUserSuperUserAccess()) {
         return;
     }
     $message = Piwik::translate('General_CurrentlyUsingUnsecureHttp');
     $message .= " ";
     $message .= Piwik::translate('General_ReadThisToLearnMore', array('<a rel="noreferrer" target="_blank" href="https://piwik.org/faq/how-to/faq_91/">', '</a>'));
     $notification = new Notification($message);
     $notification->context = Notification::CONTEXT_WARNING;
     $notification->raw = true;
     Notification\Manager::notify('ControllerAdmin_HttpIsUsed', $notification);
 }
開發者ID:Gabriel-Bowater,項目名稱:piwik,代碼行數:17,代碼來源:ControllerAdmin.php

示例4: processSuccessfulSession

 /**
  * Executed when the session was successfully authenticated.
  *
  * @param AuthResult $authResult The successful authentication result.
  * @param bool $rememberMe Whether the authenticated session should be remembered after
  *                         the browser is closed or not.
  */
 protected function processSuccessfulSession(AuthResult $authResult, $rememberMe)
 {
     $storage = new Storage($authResult->getIdentity());
     /**
      * @deprecated Create a custom SessionInitializer instead.
      */
     Piwik::postEvent('Login.authenticate.successful', array($authResult->getIdentity(), $authResult->getTokenAuth()));
     $cookie = $this->getAuthCookie($rememberMe);
     $cookie->set('login', $authResult->getIdentity());
     $cookie->set('token_auth', $this->getHashTokenAuth($authResult->getIdentity(), $authResult->getTokenAuth()));
     if ($storage->isActive()) {
         $cookie->set('auth_code', $this->getHashTokenAuth($authResult->getIdentity(), $storage->getSecret()));
     }
     $cookie->setSecure(ProxyHttp::isHttps());
     $cookie->setHttpOnly(true);
     $cookie->save();
 }
開發者ID:sgiehl,項目名稱:piwik-plugin-GoogleAuthenticator,代碼行數:24,代碼來源:SessionInitializer.php

示例5: render

 /**
  * Renders the current view. Also sends the stored 'Content-Type' HTML header.
  * See {@link setContentType()}.
  *
  * @return string Generated template.
  */
 public function render()
 {
     try {
         $this->currentModule = Piwik::getModule();
         $this->currentAction = Piwik::getAction();
         $this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
         $this->token_auth = Piwik::getCurrentUserTokenAuth();
         $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
         $this->userIsSuperUser = Piwik::hasUserSuperUserAccess();
         $this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
         $this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
         $this->isWidget = Common::getRequestVar('widget', 0, 'int');
         $this->cacheBuster = UIAssetCacheBuster::getInstance()->piwikVersionBasedCacheBuster();
         $this->loginModule = Piwik::getLoginPluginName();
         $user = APIUsersManager::getInstance()->getUser($this->userLogin);
         $this->userAlias = $user['alias'];
     } catch (Exception $e) {
         // can fail, for example at installation (no plugin loaded yet)
     }
     try {
         $this->totalTimeGeneration = Registry::get('timer')->getTime();
         $this->totalNumberOfQueries = Profiler::getQueryCount();
     } catch (Exception $e) {
         $this->totalNumberOfQueries = 0;
     }
     ProxyHttp::overrideCacheControlHeaders('no-store');
     @header('Content-Type: ' . $this->contentType);
     // always sending this header, sometimes empty, to ensure that Dashboard embed loads (which could call this header() multiple times, the last one will prevail)
     @header('X-Frame-Options: ' . (string) $this->xFrameOptions);
     return $this->renderTwigTemplate();
 }
開發者ID:brienomatty,項目名稱:elmsln,代碼行數:37,代碼來源:View.php

示例6: renderHeader

 /**
  * Sends the http headers for csv file
  */
 protected function renderHeader()
 {
     $fileName = 'Piwik ' . Piwik::translate('General_Export');
     $period = Common::getRequestVar('period', false);
     $date = Common::getRequestVar('date', false);
     if ($period || $date) {
         if ($period == 'range') {
             $period = new Range($period, $date);
         } else {
             if (strpos($date, ',') !== false) {
                 $period = new Range('range', $date);
             } else {
                 $period = Period\Factory::build($period, Date::factory($date));
             }
         }
         $prettyDate = $period->getLocalizedLongString();
         $meta = $this->getApiMetaData();
         $fileName .= ' _ ' . $meta['name'] . ' _ ' . $prettyDate . '.csv';
     }
     // silent fail otherwise unit tests fail
     Common::sendHeader('Content-Disposition: attachment; filename="' . $fileName . '"', true);
     ProxyHttp::overrideCacheControlHeaders();
 }
開發者ID:josl,項目名稱:CGE-File-Sharing,代碼行數:26,代碼來源:Csv.php

示例7: sendHeader

 public function sendHeader()
 {
     Common::sendHeader("Content-Type: application/vnd.ms-excel", true);
     ProxyHttp::overrideCacheControlHeaders();
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:5,代碼來源:Csv.php

示例8: initSession

 /**
  * Authenticates the user and initializes the session.
  */
 public function initSession($login, $md5Password, $rememberMe)
 {
     $tokenAuth = API::getInstance()->getTokenAuth($login, $md5Password);
     $this->setLogin($login);
     $this->setTokenAuth($tokenAuth);
     $authResult = $this->authenticate();
     $authCookieName = Config::getInstance()->General['login_cookie_name'];
     $authCookieExpiry = $rememberMe ? time() + Config::getInstance()->General['login_cookie_expire'] : 0;
     $authCookiePath = Config::getInstance()->General['login_cookie_path'];
     $cookie = new Cookie($authCookieName, $authCookieExpiry, $authCookiePath);
     if (!$authResult->wasAuthenticationSuccessful()) {
         $cookie->delete();
         throw new Exception(Piwik::translate('Login_LoginPasswordNotCorrect'));
     }
     $cookie->set('login', $login);
     $cookie->set('token_auth', $this->getHashTokenAuth($login, $authResult->getTokenAuth()));
     $cookie->setSecure(ProxyHttp::isHttps());
     $cookie->setHttpOnly(true);
     $cookie->save();
     @Session::regenerateId();
     // remove password reset entry if it exists
     Login::removePasswordResetInfo($login);
 }
開發者ID:KiwiJuicer,項目名稱:handball-dachau,代碼行數:26,代碼來源:Auth.php

示例9: processSuccessfulSession

 /**
  * Executed when the session was successfully authenticated.
  *
  * @param AuthResult $authResult The successful authentication result.
  * @param bool $rememberMe Whether the authenticated session should be remembered after
  *                         the browser is closed or not.
  */
 protected function processSuccessfulSession(AuthResult $authResult, $rememberMe)
 {
     $cookie = $this->getAuthCookie($rememberMe);
     $cookie->set('login', $authResult->getIdentity());
     $cookie->set('token_auth', $this->getHashTokenAuth($authResult->getIdentity(), $authResult->getTokenAuth()));
     $cookie->setSecure(ProxyHttp::isHttps());
     $cookie->setHttpOnly(true);
     $cookie->save();
 }
開發者ID:piwik,項目名稱:piwik,代碼行數:16,代碼來源:SessionInitializer.php

示例10: getImageTrackingCode

 /**
  * Returns image link tracking code for a given site with specified options.
  *
  * @param int $idSite The ID to generate tracking code for.
  * @param string $piwikUrl The domain and URL path to the Piwik installation.
  * @param int $idGoal An ID for a goal to trigger a conversion for.
  * @param int $revenue The revenue of the goal conversion. Only used if $idGoal is supplied.
  * @return string The HTML tracking code.
  */
 public function getImageTrackingCode($idSite, $piwikUrl = '', $actionName = false, $idGoal = false, $revenue = false)
 {
     $urlParams = array('idsite' => $idSite, 'rec' => 1);
     if ($actionName !== false) {
         $urlParams['action_name'] = urlencode(Common::unsanitizeInputValue($actionName));
     }
     if ($idGoal !== false) {
         $urlParams['idGoal'] = $idGoal;
         if ($revenue !== false) {
             $urlParams['revenue'] = $revenue;
         }
     }
     /**
      * Triggered when generating image link tracking code server side. Plugins can use
      * this event to customise the image tracking code that is displayed to the
      * user.
      *
      * @param string &$piwikHost The domain and URL path to the Piwik installation, eg,
      *                           `'examplepiwik.com/path/to/piwik'`.
      * @param array &$urlParams The query parameters used in the <img> element's src
      *                          URL. See Piwik's image tracking docs for more info.
      */
     Piwik::postEvent('SitesManager.getImageTrackingCode', array(&$piwikUrl, &$urlParams));
     $piwikUrl = (ProxyHttp::isHttps() ? "https://" : "http://") . $piwikUrl . '/piwik.php';
     return "<!-- Piwik Image Tracker-->\n<img src=\"{$piwikUrl}?" . Url::getQueryStringFromParameters($urlParams) . "\" style=\"border:0\" alt=\"\" />\n<!-- End Piwik -->";
 }
開發者ID:a4tunado,項目名稱:piwik,代碼行數:35,代碼來源:API.php

示例11: createConfigFile

 /**
  * Write configuration file from session-store
  */
 private function createConfigFile($dbInfos)
 {
     $config = Config::getInstance();
     // make sure DB sessions are used if the filesystem is NFS
     if (Filesystem::checkIfFileSystemIsNFS()) {
         $config->General['session_save_handler'] = 'dbtable';
     }
     if (count($headers = ProxyHeaders::getProxyClientHeaders()) > 0) {
         $config->General['proxy_client_headers'] = $headers;
     }
     if (count($headers = ProxyHeaders::getProxyHostHeaders()) > 0) {
         $config->General['proxy_host_headers'] = $headers;
     }
     if (Common::getRequestVar('clientProtocol', 'http', 'string') == 'https') {
         $protocol = 'https';
     } else {
         $protocol = ProxyHeaders::getProtocolInformation();
     }
     if (!empty($protocol) && !\Piwik\ProxyHttp::isHttps()) {
         $config->General['assume_secure_protocol'] = '1';
     }
     $config->General['salt'] = Common::generateUniqId();
     $config->General['installation_in_progress'] = 1;
     $config->database = $dbInfos;
     if (!DbHelper::isDatabaseConnectionUTF8()) {
         $config->database['charset'] = 'utf8';
     }
     $config->forceSave();
 }
開發者ID:brienomatty,項目名稱:elmsln,代碼行數:32,代碼來源:Controller.php

示例12: redirectToHttps

 /**
  * If the page is using HTTP, redirect to the same page over HTTPS
  */
 public static function redirectToHttps()
 {
     if (ProxyHttp::isHttps()) {
         return;
     }
     $url = self::getCurrentUrl();
     $url = str_replace("http://", "https://", $url);
     self::redirectToUrl($url);
 }
開發者ID:carriercomm,項目名稱:piwik,代碼行數:12,代碼來源:Url.php

示例13: serveJsFile

 /**
  * @param UIAsset $uiAsset
  */
 private function serveJsFile($uiAsset)
 {
     ProxyHttp::serverStaticFile($uiAsset->getAbsoluteLocation(), self::JS_MIME_TYPE);
 }
開發者ID:brienomatty,項目名稱:elmsln,代碼行數:7,代碼來源:Controller.php

示例14: processSuccessfullSession

 /**
  * Executed when the session was successfully authenticated
  * @param $login
  * @param $tokenAuth
  * @param $rememberMe
  */
 protected function processSuccessfullSession($login, $tokenAuth, $rememberMe)
 {
     $cookie = $this->getAuthCookie($rememberMe);
     $cookie->set('login', $login);
     $cookie->set('token_auth', $this->getHashTokenAuth($login, $tokenAuth));
     $cookie->setSecure(ProxyHttp::isHttps());
     $cookie->setHttpOnly(true);
     $cookie->save();
     // remove password reset entry if it exists
     Login::removePasswordResetInfo($login);
 }
開發者ID:carriercomm,項目名稱:piwik,代碼行數:17,代碼來源:Auth.php

示例15: render

 /**
  * Renders the current view. Also sends the stored 'Content-Type' HTML header.
  * See {@link setContentType()}.
  *
  * @return string Generated template.
  */
 public function render()
 {
     try {
         $this->currentModule = Piwik::getModule();
         $this->currentAction = Piwik::getAction();
         $this->url = Common::sanitizeInputValue(Url::getCurrentUrl());
         $this->token_auth = Piwik::getCurrentUserTokenAuth();
         $this->userHasSomeAdminAccess = Piwik::isUserHasSomeAdminAccess();
         $this->userIsAnonymous = Piwik::isUserIsAnonymous();
         $this->userIsSuperUser = Piwik::hasUserSuperUserAccess();
         $this->latest_version_available = UpdateCheck::isNewestVersionAvailable();
         $this->disableLink = Common::getRequestVar('disableLink', 0, 'int');
         $this->isWidget = Common::getRequestVar('widget', 0, 'int');
         $piwikAds = StaticContainer::get('Piwik\\ProfessionalServices\\Advertising');
         $this->areAdsForProfessionalServicesEnabled = $piwikAds->areAdsForProfessionalServicesEnabled();
         if (Development::isEnabled()) {
             $cacheBuster = rand(0, 10000);
         } else {
             $cacheBuster = UIAssetCacheBuster::getInstance()->piwikVersionBasedCacheBuster();
         }
         $this->cacheBuster = $cacheBuster;
         $this->loginModule = Piwik::getLoginPluginName();
         $user = APIUsersManager::getInstance()->getUser($this->userLogin);
         $this->userAlias = $user['alias'];
     } catch (Exception $e) {
         Log::debug($e);
         // can fail, for example at installation (no plugin loaded yet)
     }
     ProxyHttp::overrideCacheControlHeaders('no-store');
     Common::sendHeader('Content-Type: ' . $this->contentType);
     // always sending this header, sometimes empty, to ensure that Dashboard embed loads
     // - when calling sendHeader() multiple times, the last one prevails
     Common::sendHeader('X-Frame-Options: ' . (string) $this->xFrameOptions);
     return $this->renderTwigTemplate();
 }
開發者ID:diosmosis,項目名稱:piwik,代碼行數:41,代碼來源:View.php


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