当前位置: 首页>>代码示例>>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;未经允许,请勿转载。