<?php
/**
- * Copyright (C) 2004 Gabriel Wicke <wicke@wikidev.net>
+ * Raw page text accessor
+ *
+ * Copyright © 2004 Gabriel Wicke <wicke@wikidev.net>
* http://wikidev.net/
- * Based on PageHistory and SpecialExport
+ *
+ * Based on HistoryPage and SpecialExport
*
* License: GPL (http://www.gnu.org/copyleft/gpl.html)
*
var $mSmaxage, $mMaxage;
var $mContentType, $mExpandTemplates;
- function __construct( &$article, $request = false ) {
+ function __construct( Article $article, $request = false ) {
global $wgRequest, $wgInputEncoding, $wgSquidMaxage, $wgJsMimeType, $wgGroupPermissions;
$allowedCTypes = array('text/x-wiki', $wgJsMimeType, 'text/css', 'application/x-zope-edit');
- $this->mArticle =& $article;
- $this->mTitle =& $article->mTitle;
+ $this->mArticle = $article;
+ $this->mTitle = $article->mTitle;
if( $request === false ) {
- $this->mRequest =& $wgRequest;
+ $this->mRequest = $wgRequest;
} else {
$this->mRequest = $request;
}
$ctype = $this->mRequest->getVal( 'ctype' );
- $smaxage = $this->mRequest->getIntOrNull( 'smaxage', $wgSquidMaxage );
+ $smaxage = $this->mRequest->getIntOrNull( 'smaxage' );
$maxage = $this->mRequest->getInt( 'maxage', $wgSquidMaxage );
$this->mExpandTemplates = $this->mRequest->getVal( 'templates' ) === 'expand';
}
function view() {
- global $wgOut, $wgScript;
-
- if( isset( $_SERVER['SCRIPT_URL'] ) ) {
- # Normally we use PHP_SELF to get the URL to the script
- # as it was called, minus the query string.
- #
- # Some sites use Apache rewrite rules to handle subdomains,
- # and have PHP set up in a weird way that causes PHP_SELF
- # to contain the rewritten URL instead of the one that the
- # outside world sees.
- #
- # If in this mode, use SCRIPT_URL instead, which mod_rewrite
- # provides containing the "before" URL.
- $url = $_SERVER['SCRIPT_URL'];
- } else {
- $url = $_SERVER['PHP_SELF'];
- }
+ global $wgOut, $wgRequest;
- if( strcmp( $wgScript, $url ) ) {
+ if( $wgRequest->isPathInfoBad() ) {
# Internet Explorer will ignore the Content-Type header if it
# thinks it sees a file extension it recognizes. Make sure that
# all raw requests are done through the script node, which will
#
# Just return a 403 Forbidden and get it over with.
wfHttpError( 403, 'Forbidden',
+ 'Invalid file extension found in PATH_INFO. ' .
'Raw pages must be accessed through the primary script entry point.' );
return;
}
$mode = $this->mPrivateCache ? 'private' : 'public';
header( 'Cache-Control: '.$mode.', s-maxage='.$this->mSmaxage.', max-age='.$this->mMaxage );
- if( HTMLFileCache::useFileCache() ) {
+ global $wgUseFileCache;
+ if( $wgUseFileCache and HTMLFileCache::useFileCache() ) {
$cache = new HTMLFileCache( $this->mTitle, 'raw' );
if( $cache->isFileCacheGood( /* Assume up to date */ ) ) {
$cache->loadFromFileCache();
$text = $this->getRawText();
if( !wfRunHooks( 'RawPageViewBeforeOutput', array( &$this, &$text ) ) ) {
- wfDebug( __METHOD__ . ': RawPageViewBeforeOutput hook broke raw page output.' );
+ wfDebug( __METHOD__ . ": RawPageViewBeforeOutput hook broke raw page output.\n" );
}
echo $text;
}
function getRawText() {
- global $wgUser, $wgOut, $wgRequest;
+ global $wgUser, $wgOut;
if( $this->mGen ) {
$sk = $wgUser->getSkin();
if( !StubObject::isRealObject( $wgOut ) )