<?php
/*========================================================================*\
|| ###################################################################### ||
|| # vBulletin 6.2.3 - Licence Number L3138846
|| # ------------------------------------------------------------------ # ||
|| # Copyright 2000-2026 MH Sub I, LLC dba vBulletin. All Rights Reserved.  # ||
|| # This file may not be redistributed in whole or significant part.   # ||
|| # ----------------- VBULLETIN IS NOT FREE SOFTWARE ----------------- # ||
|| # http://www.vbulletin.com | http://www.vbulletin.com/license.html   # ||
|| ###################################################################### ||
\*========================================================================*/

define('VB_REQUEST_START_TIME', microtime(true));

if (!defined('VB_ENTRY'))
{
	define('VB_ENTRY', 1);
}

// We don't want to process Firefox prefetches of the "rel=next" links.  However it appears to run
// afoul of the Content Security Policy (see https://bugzilla.mozilla.org/show_bug.cgi?id=1242902)
// and show blocked/NS_BINDING_ABORTED. So while it's sending the request and triggering all of the
// page processing, it's not actually doing anything with the results.  Unfortunately the rel=next
// links are there to help search engines figure out the pagination and there is no way to tell
// Firefox to not do that.  The Sec-Purpose header does not seem to be widely used in requests but
// chances are we don't want to handle prefetch links anyway.
//
// We'll set the cache control to hopefully prevent anybody from using the blank return on the prefetch.
// This will also block <script type="speculationrules"> tags but we aren't using any and that's
// experimental.
if (str_contains($_SERVER['HTTP_USER_AGENT'], 'Gecko') AND ($_SERVER['HTTP_SEC_PURPOSE'] ?? '') == 'prefetch')
{
	// It feels like we should set a non 200 header here but nothing feels right.  503 comes the closest
	// but kicking out a 50x error here seems extreme.  We want to communicate that this request is invalid
	// in context but that the url itself is fine and should be requeried.
	header('Cache-Control: no-store');
	return;
}

// Check for cached image calls to filedata/fetch?
if (
	isset($_REQUEST['routestring']) AND
	$_REQUEST['routestring'] == 'filedata/fetch' AND
	(!empty($_SERVER['HTTP_IF_MODIFIED_SINCE']) OR !empty($_SERVER['HTTP_IF_NONE_MATCH']))
)
{
	http_response_code(304);
}

require_once('includes/vb5/autoloader.php');
vB5_Autoloader::register(__DIR__);

//For a few set routes we can run a streamlined function.
if (vB5_Frontend_ApplicationLight::isQuickRoute())
{
	$app = vB5_Frontend_ApplicationLight::init(__DIR__);
	vB5_Frontend_ExplainQueries::initialize();
	if ($app->execute())
	{
		vB5_Frontend_ExplainQueries::finish();
		exit();
	}
}

$app = vB5_Frontend_Application::init(__DIR__);
$config = vB5_Config::instance();
if (!$config->report_all_php_errors)
{
	// Note that E_STRICT became part of E_ALL in PHP 5.4, and deprecated as of PHP 8.4
	error_reporting(error_reporting() & ~E_NOTICE);
}

$routing = $app->getRouter();
$method = $routing->getAction();
$class = $routing->getControllerClass();

if (!class_exists($class))
{
	throw new vB5_Exception_404('invalid_page_url');
}

vB5_Frontend_ExplainQueries::initialize();
$c = new $class();

if (!is_callable([$c, $method]))
{
	throw new vB5_Exception_404('invalid_page_url');
}

$c->$method(...array_values($routing->getArguments()));
vB5_Frontend_ExplainQueries::finish();

/*=========================================================================*\
|| #######################################################################
|| # Downloaded: 13:27, Sun Aug 30th 2026
|| # CVS: $RCSfile$ - $Revision: 121582 $
|| #######################################################################
\*=========================================================================*/
