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


PHP wfHttpError函数代码示例

本文整理汇总了PHP中wfHttpError函数的典型用法代码示例。如果您正苦于以下问题:PHP wfHttpError函数的具体用法?PHP wfHttpError怎么用?PHP wfHttpError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: performAction

 function performAction()
 {
     global $wgAjaxExportList, $wgOut;
     if (empty($this->mode)) {
         return;
     }
     wfProfileIn(__METHOD__);
     if (!in_array($this->func_name, $wgAjaxExportList)) {
         wfHttpError(400, 'Bad Request', "unknown function " . (string) $this->func_name);
     } else {
         try {
             $result = call_user_func_array($this->func_name, $this->args);
             if ($result === false || $result === NULL) {
                 wfHttpError(500, 'Internal Error', "{$this->func_name} returned no data");
             } else {
                 if (is_string($result)) {
                     $result = new AjaxResponse($result);
                 }
                 $result->sendHeaders();
                 $result->printText();
             }
         } catch (Exception $e) {
             if (!headers_sent()) {
                 wfHttpError(500, 'Internal Error', $e->getMessage());
             } else {
                 print $e->getMessage();
             }
         }
     }
     wfProfileOut(__METHOD__);
     $wgOut = null;
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:32,代码来源:AjaxDispatcher.php

示例2: hRawPageViewBeforeOutput

 public function hRawPageViewBeforeOutput(&$rawpage, &$text)
 {
     global $wgUser;
     if (!$wgUser->isAllowed("raw")) {
         $text = '';
         wfHttpError(403, 'Forbidden', 'Unsufficient access rights.');
         return false;
     }
     return true;
     // continue hook-chain.
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:11,代码来源:RawRight.body.php

示例3: checkFeedOutput

 /**
  * Check whether feeds can be used and that $type is a valid feed type
  *
  * @param $type String: feed type, as requested by the user
  * @return Boolean
  */
 public static function checkFeedOutput($type)
 {
     global $wgFeed, $wgFeedClasses;
     if (!$wgFeed) {
         global $wgOut;
         $wgOut->addWikiMsg('feed-unavailable');
         return false;
     }
     if (!isset($wgFeedClasses[$type])) {
         wfHttpError(500, "Internal Server Error", "Unsupported feed type.");
         return false;
     }
     return true;
 }
开发者ID:rocLv,项目名称:conference,代码行数:20,代码来源:FeedUtils.php

示例4: rdfSetup

/**
 * @private
 */
function rdfSetup()
{
    global $wgOut, $_SERVER;
    $rdftype = wfNegotiateType(wfAcceptToPrefs(@$_SERVER['HTTP_ACCEPT']), wfAcceptToPrefs(RDF_TYPE_PREFS));
    if (!$rdftype) {
        wfHttpError(406, "Not Acceptable", wfMsg("notacceptable"));
        return false;
    } else {
        $wgOut->disable();
        header("Content-type: {$rdftype}");
        $wgOut->sendCacheControl();
        return true;
    }
}
开发者ID:k-hasan-19,项目名称:wiki,代码行数:17,代码来源:Metadata.php

示例5: setup

 /**
  *
  */
 protected function setup()
 {
     global $wgOut, $wgRequest;
     $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null;
     $rdftype = wfNegotiateType(wfAcceptToPrefs($httpaccept), wfAcceptToPrefs(self::RDF_TYPE_PREFS));
     if (!$rdftype) {
         wfHttpError(406, 'Not Acceptable', wfMsg('notacceptable'));
         return false;
     } else {
         $wgOut->disable();
         $wgRequest->response()->header("Content-type: {$rdftype}; charset=utf-8");
         $wgOut->sendCacheControl();
         return true;
     }
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:18,代码来源:Metadata.php

示例6: execute

 function execute($par)
 {
     global $wgOut, $wgOpenIDClientOnly;
     wfLoadExtensionMessages('OpenID');
     # No server functionality if this site is only a client
     # Note: special page is un-registered if this flag is set,
     # so it'd be unusual to get here.
     if ($wgOpenIDClientOnly) {
         wfHttpError(404, "Not Found", wfMsg('openidclientonlytext'));
         return;
     }
     // XRDS preamble XML.
     $xml_template = array('<?xml version="1.0" encoding="UTF-8"?' . '>', '<xrds:XRDS', '  xmlns:xrds="xri://\\$xrds"', '  xmlns:openid="http://openid.net/xmlns/1.0"', '  xmlns="xri://$xrd*($v*2.0)">', '<XRD>');
     # Check to see if the parameter is really a user name
     if (!$par) {
         wfHttpError(404, "Not Found", wfMsg('openidnousername'));
         return;
     }
     $user = User::newFromName($par);
     if (!$user || $user->getID() == 0) {
         wfHttpError(404, "Not Found", wfMsg('openidbadusername'));
         return;
     }
     // Generate the user page URL.
     $user_title = $user->getUserPage();
     $user_url = $user_title->getFullURL();
     // Generate the OpenID server endpoint URL.
     $server_title = SpecialPage::getTitleFor('OpenIDServer');
     $server_url = $server_title->getFullURL();
     // Define array of Yadis services to be included in
     // the XRDS output.
     $services = array(array('uri' => $server_url, 'priority' => '0', 'types' => array('http://openid.net/signon/1.0', 'http://openid.net/sreg/1.0', 'http://specs.openid.net/auth/2.0/signon'), 'delegate' => $user_url));
     // Generate <Service> elements into $service_text.
     $service_text = "\n";
     foreach ($services as $service) {
         $types = array();
         foreach ($service['types'] as $type_uri) {
             $types[] = '    <Type>' . $type_uri . '</Type>';
         }
         $service_text .= implode("\n", array('  <Service priority="' . $service['priority'] . '">', '    <URI>' . $server_url . '</URI>', implode("\n", $types), '  </Service>'));
     }
     $wgOut->disable();
     // Print content-type and XRDS XML.
     header("Content-Type: application/xrds+xml");
     print implode("\n", $xml_template);
     print $service_text;
     print implode("\n", array("</XRD>", "</xrds:XRDS>"));
 }
开发者ID:ErdemA,项目名称:wikihow,代码行数:48,代码来源:SpecialOpenIDXRDS.body.php

示例7: execute

 /**
  * main()
  */
 public function execute($par)
 {
     global $wgContLang, $wgFeedClasses, $wgLanguageCode, $wgMemc, $wgOut, $wgGNSMsmaxage;
     list($params, $categories, $notCategories) = $this->getParams();
     // if there's an error parsing the params, bail out and return
     if (isset($params['error'])) {
         wfHttpError(500, 'Internal Server Error', $params['error']);
         return;
     }
     // Check to make sure that feed type is supported.
     if (FeedUtils::checkFeedOutput($params['feed'])) {
         $msg = wfMessage('feed-' . $params['feed'])->inContentLanguage();
         if ($msg->exists()) {
             // This seems a little icky since
             // its re-using another message in a
             // different context.
             // uses feed-rss and feed-atom messages.
             $feedType = $msg->text();
         } else {
             $feedType = $wgContLang->uc($params['feed']);
         }
         $feed = new $wgFeedClasses[$params['feed']](wfMsgExt('googlenewssitemap_feedtitle', array('parsemag', 'content'), $wgContLang->getLanguageName($wgLanguageCode), $feedType, $wgLanguageCode), wfMsgExt('tagline', array('parsemag', 'content')), Title::newMainPage()->getFullURL());
     } else {
         // FeedUtils outputs an error if wrong feed type.
         // So nothing else to do at this point
         return;
     }
     $wgOut->setSquidMaxage($wgGNSMsmaxage);
     $cacheInvalidationInfo = $this->getCacheInvalidationInfo($params, $categories, $notCategories);
     $cacheKey = $this->getCacheKey($params, $categories, $notCategories);
     // The way this does caching is based on ChangesFeed::execute.
     $cached = $this->getCachedVersion($cacheKey, $cacheInvalidationInfo);
     if ($cached !== false) {
         $feed->httpHeaders();
         echo $cached;
         echo "<!-- From cache: {$cacheKey} -->";
     } else {
         wfProfileIn(__METHOD__ . '-not-cached');
         $res = $this->getCategories($params, $categories, $notCategories);
         ob_start();
         $this->makeFeed($feed, $res);
         $output = ob_get_contents();
         ob_end_flush();
         echo "<!-- Not cached. Saved as: {$cacheKey} -->";
         $wgMemc->set($cacheKey, array($cacheInvalidationInfo, $output), $this->maxCacheTime);
         wfProfileOut(__METHOD__ . '-not-cached');
     }
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:51,代码来源:GoogleNewsSitemap_body.php

示例8: wfSpecialUserlogoutUCSC

/**
 * constructor
 */
function wfSpecialUserlogoutUCSC()
{
    global $wgUser, $wgOut, $wgRequest;
    /**
     * Some satellite ISPs use broken precaching schemes that log people out straight after
     * they're logged in (bug 17790). Luckily, there's a way to detect such requests.
     */
    if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&amp;') !== false) {
        wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n");
        wfHttpError(400, wfMsg('loginerror'), wfMsg('suspicious-userlogout'));
        return;
    }
    $oldName = $wgUser->getName();
    $wgUser->logout();
    $wgOut->setRobotPolicy('noindex,nofollow');
    // Hook.
    $injected_html = '';
    wfRunHooks('UserLogoutComplete', array(&$wgUser, &$injected_html, $oldName));
    $wgOut->addHTML(wfMsgExt('logouttext', array('parse')) . $injected_html);
    returnToExternal(true, $wgRequest->getVal('returnto'));
}
开发者ID:ucsc-mus-strain-cactus,项目名称:kent,代码行数:24,代码来源:includes.specials.SpecialUserlogoutUCSC.php

示例9: output

 /**
  * @param Exception|Throwable $e Original exception
  * @param integer $mode MWExceptionExposer::AS_* constant
  * @param Exception|Throwable|null $eNew New exception from attempting to show the first
  */
 public static function output($e, $mode, $eNew = null)
 {
     global $wgMimeType;
     if (defined('MW_API')) {
         // Unhandled API exception, we can't be sure that format printer is alive
         self::header('MediaWiki-API-Error: internal_api_error_' . get_class($e));
         wfHttpError(500, 'Internal Server Error', self::getText($e));
     } elseif (self::isCommandLine()) {
         self::printError(self::getText($e));
     } elseif ($mode === self::AS_PRETTY) {
         if ($e instanceof DBConnectionError) {
             self::reportOutageHTML($e);
         } else {
             self::statusHeader(500);
             self::header("Content-Type: {$wgMimeType}; charset=utf-8");
             self::reportHTML($e);
         }
     } else {
         if ($eNew) {
             $message = "MediaWiki internal error.\n\n";
             if (self::showBackTrace($e)) {
                 $message .= 'Original exception: ' . MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($e) . "\n\nException caught inside exception handler: " . MWExceptionHandler::getLogMessage($eNew) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($eNew);
             } else {
                 $message .= "Exception caught inside exception handler.\n\n" . "Set \$wgShowExceptionDetails = true; at the bottom of LocalSettings.php " . "to show detailed debugging information.";
             }
             $message .= "\n";
         } else {
             if (self::showBackTrace($e)) {
                 $message = MWExceptionHandler::getLogMessage($e) . "\nBacktrace:\n" . MWExceptionHandler::getRedactedTraceAsString($e) . "\n";
             } else {
                 $message = MWExceptionHandler::getPublicLogMessage($e);
             }
         }
         if (self::isCommandLine()) {
             self::printError($message);
         } else {
             echo nl2br(htmlspecialchars($message)) . "\n";
         }
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:45,代码来源:MWExceptionRenderer.php

示例10: execute

 function execute($par)
 {
     global $wgUser, $wgOut;
     /**
      * Some satellite ISPs use broken precaching schemes that log people out straight after
      * they're logged in (bug 17790). Luckily, there's a way to detect such requests.
      */
     if (isset($_SERVER['REQUEST_URI']) && strpos($_SERVER['REQUEST_URI'], '&amp;') !== false) {
         wfDebug("Special:Userlogout request {$_SERVER['REQUEST_URI']} looks suspicious, denying.\n");
         wfHttpError(400, wfMsg('loginerror'), wfMsg('suspicious-userlogout'));
         return;
     }
     $this->setHeaders();
     $this->outputHeader();
     $oldName = $wgUser->getName();
     $wgUser->logout();
     $wgOut->addWikiMsg('logouttext');
     // Hook.
     $injected_html = '';
     wfRunHooks('UserLogoutComplete', array(&$wgUser, &$injected_html, $oldName));
     $wgOut->addHTML($injected_html);
     $wgOut->returnToMain();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:23,代码来源:SpecialUserlogout.php

示例11: wfHttpError

// Content-Type if it sees a recognized extension on the URL, such as
// might be appended via PATH_INFO after 'api.php'.
//
// Some data formats can end up containing unfiltered user-provided data
// which will end up triggering HTML detection and execution, hence
// XSS injection and all that entails.
//
// Ensure that all access is through the canonical entry point...
//
if (isset($_SERVER['SCRIPT_URL'])) {
    $url = $_SERVER['SCRIPT_URL'];
} else {
    $url = $_SERVER['PHP_SELF'];
}
if (strcmp("{$wgScriptPath}/api{$wgScriptExtension}", $url)) {
    wfHttpError(403, 'Forbidden', 'API must be accessed through the primary script entry point.');
    return;
}
// Verify that the API has not been disabled
if (!$wgEnableAPI) {
    echo 'MediaWiki API is not enabled for this site. Add the following line to your LocalSettings.php';
    echo '<pre><b>$wgEnableAPI=true;</b></pre>';
    die(1);
}
// So extensions can check whether they're running in API mode
define('MW_API', true);
// Set a dummy $wgTitle, because $wgTitle == null breaks various things
// In a perfect world this wouldn't be necessary
$wgTitle = Title::newFromText('API');
/* Construct an ApiMain with the arguments passed via the URL. What we get back
 * is some form of an ApiMain, possibly even one that produces an error message,
开发者ID:ui-libraries,项目名称:TIRW,代码行数:31,代码来源:api.php

示例12: showPageNotFound

 /**
  * Show an error page, if page not found
  */
 protected function showPageNotFound()
 {
     wfHttpError(404, $this->msg('mobile-frontend-history-404-title')->text(), $this->msg('mobile-frontend-history-404-desc')->text());
 }
开发者ID:micha6554,项目名称:mediawiki-extensions-MobileFrontend,代码行数:7,代码来源:SpecialMobileHistory.php

示例13: ini_set

ini_set("display_errors", 1);
// So extensions (and other code) can check whether they're running in API mode
define('MW_API', true);
$apiDir = dirname(__FILE__);
$globAPIModules = array();
$globAutoloadClasses = array();
require $apiDir . (file_exists($apiDir . '/api.config.php') ? '/api.config.php' : '/api.config.default.php');
// Initialise common code
require $apiDir . '/phpapi/WebStart.php';
// URL safety checks
//
// See RawPage.php for details; summary is that MSIE can override the
// Content-Type if it sees a recognized extension on the URL, such as
// might be appended via PATH_INFO after 'api.php'.
//
// Some data formats can end up containing unfiltered user-provided data
// which will end up triggering HTML detection and execution, hence
// XSS injection and all that entails.
//
if ($wgRequest->isPathInfoBad()) {
    // TODO
    wfHttpError(403, 'Forbidden', 'Invalid file extension found in PATH_INFO. ' . 'The API must be accessed through the primary script entry point.');
    return;
}
/* Construct an ApiMain with the arguments passed via the URL. What we get back
 * is some form of an ApiMain, possibly even one that produces an error message,
 * but we don't care here, as that is handled by the ctor.
 */
$processor = new ApiMain($wgRequest);
// Process data & print results
$processor->execute();
开发者ID:JeroenDeDauw,项目名称:iRail,代码行数:31,代码来源:api.php

示例14: performAction

 /**
  * Perform one of the "standard" actions
  *
  * @param $output OutputPage
  * @param $article Article
  * @param $title Title
  * @param $user User
  * @param $request WebRequest
  */
 function performAction(&$output, &$article, &$title, &$user, &$request)
 {
     wfProfileIn(__METHOD__);
     if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request, $this))) {
         wfProfileOut(__METHOD__);
         return;
     }
     $action = $this->getVal('Action');
     if (in_array($action, $this->getVal('DisabledActions', array()))) {
         /* No such action; this will switch to the default case */
         $action = 'nosuchaction';
     }
     // Workaround for bug #20966: inability of IE to provide an action dependent
     // on which submit button is clicked.
     if ($action === 'historysubmit') {
         if ($request->getBool('revisiondelete')) {
             $action = 'revisiondelete';
         } else {
             $action = 'view';
         }
     }
     switch ($action) {
         case 'view':
             $output->setSquidMaxage($this->getVal('SquidMaxage'));
             $article->view();
             break;
         case 'raw':
             // includes JS/CSS
             wfProfileIn(__METHOD__ . '-raw');
             $raw = new RawPage($article);
             $raw->view();
             wfProfileOut(__METHOD__ . '-raw');
             break;
         case 'watch':
         case 'unwatch':
         case 'delete':
         case 'revert':
         case 'rollback':
         case 'protect':
         case 'unprotect':
         case 'info':
         case 'markpatrolled':
         case 'render':
         case 'deletetrackback':
         case 'purge':
             $article->{$action}();
             break;
         case 'print':
             $article->view();
             break;
         case 'dublincore':
             if (!$this->getVal('EnableDublinCoreRdf')) {
                 wfHttpError(403, 'Forbidden', wfMsg('nodublincore'));
             } else {
                 $rdf = new DublinCoreRdf($article);
                 $rdf->show();
             }
             break;
         case 'creativecommons':
             if (!$this->getVal('EnableCreativeCommonsRdf')) {
                 wfHttpError(403, 'Forbidden', wfMsg('nocreativecommons'));
             } else {
                 $rdf = new CreativeCommonsRdf($article);
                 $rdf->show();
             }
             break;
         case 'credits':
             Credits::showPage($article);
             break;
         case 'submit':
             if (session_id() == '') {
                 /* Send a cookie so anons get talk message notifications */
                 wfSetupSession();
             }
             /* Continue... */
         /* Continue... */
         case 'edit':
         case 'editredlink':
             if (wfRunHooks('CustomEditor', array($article, $user))) {
                 $internal = $request->getVal('internaledit');
                 $external = $request->getVal('externaledit');
                 $section = $request->getVal('section');
                 $oldid = $request->getVal('oldid');
                 if (!$this->getVal('UseExternalEditor') || $action == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) {
                     $editor = new EditPage($article);
                     $editor->submit();
                 } elseif ($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) {
                     $mode = $request->getVal('mode');
                     $extedit = new ExternalEdit($article, $mode);
                     $extedit->edit();
                 }
//.........这里部分代码省略.........
开发者ID:GodelDesign,项目名称:Godel,代码行数:101,代码来源:Wiki.php

示例15: stream

 /**
  * Stream a contained file directly to HTTP output.
  * Will throw a 404 if file is missing; 400 if invalid key.
  * @return true on success, false on failure
  */
 function stream($key)
 {
     $path = $this->filePath($key);
     if ($path === false) {
         wfHttpError(400, "Bad request", "Invalid or badly-formed filename.");
         return false;
     }
     if (file_exists($path)) {
         // Set the filename for more convenient save behavior from browsers
         // FIXME: Is this safe?
         header('Content-Disposition: inline; filename="' . $key . '"');
         require_once 'StreamFile.php';
         wfStreamFile($path);
     } else {
         return wfHttpError(404, "Not found", "The requested resource does not exist.");
     }
 }
开发者ID:negabaro,项目名称:alfresco,代码行数:22,代码来源:FileStore.php


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