示例#1
0
/**
 * Handle a thumbnail request via thumbnail file URL
 *
 * @return void
 */
function wfThumbHandle404()
{
    # lighttpd puts the original request in REQUEST_URI, while sjs sets
    # that to the 404 handler, and puts the original request in REDIRECT_URL.
    if (isset($_SERVER['REDIRECT_URL'])) {
        # The URL is un-encoded, so put it back how it was
        $uriPath = str_replace("%2F", "/", urlencode($_SERVER['REDIRECT_URL']));
    } else {
        $uriPath = $_SERVER['REQUEST_URI'];
    }
    # Just get the URI path (REDIRECT_URL/REQUEST_URI is either a full URL or a path)
    if (substr($uriPath, 0, 1) !== '/') {
        $bits = wfParseUrl($uriPath);
        if ($bits && isset($bits['path'])) {
            $uriPath = $bits['path'];
        } else {
            wfThumbError(404, 'The source file for the specified thumbnail does not exist.');
            return;
        }
    }
    $params = wfExtractThumbParams($uriPath);
    // basic wiki URL param extracting
    if ($params == null) {
        wfThumbError(404, 'The source file for the specified thumbnail does not exist.');
        return;
    }
    wfStreamThumb($params);
    // stream the thumbnail
}
示例#2
0
/**
 * Handle a thumbnail request via thumbnail file URL
 *
 * @return void
 */
function wfThumbHandle404() {
	global $wgArticlePath;

	# Set action base paths so that WebRequest::getPathInfo()
	# recognizes the "X" as the 'title' in ../thumb_handler.php/X urls.
	# Note: If Custom per-extension repo paths are set, this may break.
	$repo = RepoGroup::singleton()->getLocalRepo();
	$oldArticlePath = $wgArticlePath;
	$wgArticlePath = $repo->getZoneUrl( 'thumb' ) . '/$1';

	$matches = WebRequest::getPathInfo();

	$wgArticlePath = $oldArticlePath;

	if ( !isset( $matches['title'] ) ) {
		wfThumbError( 404, 'Could not determine the name of the requested thumbnail.' );
		return;
	}

	$params = wfExtractThumbRequestInfo( $matches['title'] ); // basic wiki URL param extracting
	if ( $params == null ) {
		wfThumbError( 400, 'The specified thumbnail parameters are not recognized.' );
		return;
	}

	wfStreamThumb( $params ); // stream the thumbnail
}
示例#3
0
/**
 * Handle a thumbnail request via thumbnail file URL
 *
 * @return void
 */
function wfThumbHandle404()
{
    global $wgArticlePath;
    # Set action base paths so that WebRequest::getPathInfo()
    # recognizes the "X" as the 'title' in ../thumb_handler.php/X urls.
    $wgArticlePath = false;
    # Don't let a "/*" article path clober our action path
    $matches = WebRequest::getPathInfo();
    if (!isset($matches['title'])) {
        wfThumbError(404, 'Could not determine the name of the requested thumbnail.');
        return;
    }
    $params = wfExtractThumbParams($matches['title']);
    // basic wiki URL param extracting
    if ($params == null) {
        wfThumbError(400, 'The specified thumbnail parameters are not recognized.');
        return;
    }
    wfStreamThumb($params);
    // stream the thumbnail
}