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


PHP Common::sendResponseCode方法代碼示例

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


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

示例1: outputException

 /**
  * Echos an error message & other information, then exits.
  *
  * @param Tracker $tracker
  * @param Exception $e
  * @param int  $statusCode eg 500
  */
 public function outputException(Tracker $tracker, Exception $e, $statusCode)
 {
     Common::sendResponseCode($statusCode);
     $this->logExceptionToErrorLog($e);
     $result = $this->formatException($tracker, $e);
     echo json_encode($result);
 }
開發者ID:CaptainSharf,項目名稱:SSAD_Project,代碼行數:14,代碼來源:Response.php

示例2: dispatch

 public function dispatch()
 {
     $module = Common::getRequestVar('module', '', 'string');
     $action = Common::getRequestVar('action', '', 'string');
     if ($module == 'CoreUpdater' || $module == 'Proxy' || $module == 'Installation' || $module == 'LanguagesManager' && $action == 'saveLanguage') {
         return;
     }
     $updater = new PiwikCoreUpdater();
     $updates = $updater->getComponentsWithNewVersion(array('core' => Version::VERSION));
     if (!empty($updates)) {
         Filesystem::deleteAllCacheOnUpdate();
     }
     if ($updater->getComponentUpdates() !== null) {
         if (FrontController::shouldRethrowException()) {
             throw new Exception("Piwik and/or some plugins have been upgraded to a new version. \n" . "--> Please run the update process first. See documentation: http://piwik.org/docs/update/ \n");
         } elseif ($module === 'API') {
             $outputFormat = strtolower(Common::getRequestVar('format', 'xml', 'string', $_GET + $_POST));
             $response = new ResponseBuilder($outputFormat);
             $e = new Exception('Database Upgrade Required. Your Piwik database is out-of-date, and must be upgraded before you can continue.');
             echo $response->getResponseException($e);
             Common::sendResponseCode(503);
             exit;
         } else {
             Piwik::redirectToModule('CoreUpdater');
         }
     }
 }
開發者ID:piwik,項目名稱:piwik,代碼行數:27,代碼來源:CoreUpdater.php

示例3: errorHandler

 public static function errorHandler($errno, $errstr, $errfile, $errline)
 {
     // if the error has been suppressed by the @ we don't handle the error
     if (error_reporting() == 0) {
         return;
     }
     switch ($errno) {
         case E_ERROR:
         case E_PARSE:
         case E_CORE_ERROR:
         case E_CORE_WARNING:
         case E_COMPILE_ERROR:
         case E_COMPILE_WARNING:
         case E_USER_ERROR:
             Common::sendResponseCode(500);
             // Convert the error to an exception with an HTML message
             $e = new \Exception();
             $message = self::getHtmlMessage($errno, $errstr, $errfile, $errline, $e->getTraceAsString());
             throw new ErrorException($message, 0, $errno, $errfile, $errline);
             break;
         case E_WARNING:
         case E_NOTICE:
         case E_USER_WARNING:
         case E_USER_NOTICE:
         case E_STRICT:
         case E_RECOVERABLE_ERROR:
         case E_DEPRECATED:
         case E_USER_DEPRECATED:
         default:
             Log::warning(self::createLogMessage($errno, $errstr, $errfile, $errline));
             break;
     }
 }
開發者ID:bossrabbit,項目名稱:piwik,代碼行數:33,代碼來源:ErrorHandler.php

示例4: displayDbConnectionMessage

 public function displayDbConnectionMessage($exception = null)
 {
     Common::sendResponseCode(500);
     $errorMessage = $exception->getMessage();
     if (Request::isApiRequest($_GET)) {
         $ex = new DatabaseConnectionFailedException($errorMessage);
         throw $ex;
     }
     $view = new PiwikView("@Installation/cannotConnectToDb");
     $view->exceptionMessage = $errorMessage;
     $ex = new DatabaseConnectionFailedException($view->render());
     $ex->setIsHtmlMessage();
     throw $ex;
 }
開發者ID:cemo,項目名稱:piwik,代碼行數:14,代碼來源:Installation.php

示例5: handleMaintenanceMode

 protected function handleMaintenanceMode()
 {
     if (Config::getInstance()->General['maintenance_mode'] != 1 || Common::isPhpCliMode()) {
         return;
     }
     Common::sendResponseCode(503);
     $logoUrl = null;
     $faviconUrl = null;
     try {
         $logo = new CustomLogo();
         $logoUrl = $logo->getHeaderLogoUrl();
         $faviconUrl = $logo->getPathUserFavicon();
     } catch (Exception $ex) {
     }
     $logoUrl = $logoUrl ?: 'plugins/Morpheus/images/logo-header.png';
     $faviconUrl = $faviconUrl ?: 'plugins/CoreHome/images/favicon.ico';
     $page = file_get_contents(PIWIK_INCLUDE_PATH . '/plugins/Morpheus/templates/maintenance.tpl');
     $page = str_replace('%logoUrl%', $logoUrl, $page);
     $page = str_replace('%faviconUrl%', $faviconUrl, $page);
     $page = str_replace('%piwikTitle%', Piwik::getRandomTitle(), $page);
     echo $page;
     exit;
 }
開發者ID:drabberhorizon,項目名稱:ActiveNative,代碼行數:23,代碼來源:FrontController.php

示例6: outputApiResponse

 private function outputApiResponse(Tracker $tracker)
 {
     if ($tracker->isDebugModeEnabled()) {
         return;
     }
     if ($this->hasAlreadyPrintedOutput()) {
         return;
     }
     $request = $_GET + $_POST;
     if (array_key_exists('send_image', $request) && $request['send_image'] === '0') {
         Common::sendResponseCode(204);
         return;
     }
     $this->outputTransparentGif();
 }
開發者ID:bossrabbit,項目名稱:piwik,代碼行數:15,代碼來源:Response.php

示例7: redirectToUrlNoExit

 private static function redirectToUrlNoExit($url)
 {
     if (UrlHelper::isLookLikeUrl($url) || strpos($url, 'index.php') === 0) {
         Common::sendResponseCode(302);
         Common::sendHeader("Location: {$url}");
     } else {
         echo "Invalid URL to redirect to.";
     }
     if (Common::isPhpCliMode()) {
         throw new Exception("If you were using a browser, Piwik would redirect you to this URL: {$url} \n\n");
     }
 }
開發者ID:mgou-net,項目名稱:piwik,代碼行數:12,代碼來源:Url.php

示例8: handleFatalErrors

 private function handleFatalErrors()
 {
     register_shutdown_function(function () {
         $lastError = error_get_last();
         if (!empty($lastError) && $lastError['type'] == E_ERROR) {
             Common::sendResponseCode(500);
         }
     });
 }
開發者ID:FluentDevelopment,項目名稱:piwik,代碼行數:9,代碼來源:Tracker.php

示例9: download

 public function download()
 {
     Piwik::checkUserHasSuperUserAccess();
     $this->dieIfPluginsAdminIsDisabled();
     $pluginName = new PluginName();
     $pluginName = $pluginName->getPluginName();
     Nonce::checkNonce($pluginName);
     $filename = $pluginName . '.zip';
     try {
         $pathToPlugin = $this->marketplaceApi->download($pluginName);
         ProxyHttp::serverStaticFile($pathToPlugin, 'application/zip', $expire = 0, $start = false, $end = false, $filename);
     } catch (Exception $e) {
         Common::sendResponseCode(500);
         Log::warning('Could not download file . ' . $e->getMessage());
     }
     if (!empty($pathToPlugin)) {
         Filesystem::deleteFileIfExists($pathToPlugin);
     }
 }
開發者ID:piwik,項目名稱:piwik,代碼行數:19,代碼來源:Controller.php


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