Hi all,
Something disturbing is happening... I make an AJAX call to a page and it returns unprocessed PHP, not HTML. However, when I navigate to the page manually, the PHP is processing as expected. This must be a huge security vulnerability?
My AJAX call is:
$('#forgot').click(function(e){
e.preventDefault();
lFormContainer.load("ajax/?page=authenticate/username");
});
The PHP code itself is too huge to paste here, so it's difficult to see what is relevant. However, the AJAX call returns only the content for index.php, and none of the code referenced in the classes index.php makes calls to.
I have pasted index.php below, it may reveal something:
<?php
session_start();
unset($_SESSION);
define("FRAMEWORK_PATH", dirname(__FILE__) . "/");
require __DIR__ . '/vendor/autoload.php';
require('registry/registry.php');
$registry = new Registry();
//Setup our core registry objects
$registry->createAndStoreObject('template', 'template');
$registry->createAndStoreObject('mysql', 'db');
$registry->createAndStoreObject('authenticate', 'authenticate');
$registry->createAndStoreObject('urlprocessor', 'url');
$registry->createAndStoreObject('mailout', 'mail');
//Database settings
include (FRAMEWORK_PATH . 'config.php');
//Create database connection
$registry->getObject('db')->newConnection($config['mysql_host'], $config['mysql_user'], $config['mysql_pass'], $config['mysql_name']);
//Process URL
$registry->getObject('url')->getURLData();
//Process Authentication
$registry->getObject('authenticate')->checkForAuthentication();
//Store settings in our registry
$settingsSQL = "SELECT * FROM settings";
$registry->getObject('db')->executeQuery($settingsSQL);
while($setting = $registry->getObject('db')->getRows())
{
$registry->storeSetting($setting['value'], $setting['key']);
}
$registry->getObject('template')->getPage()->addTag( 'siteurl', $registry->getSetting('siteurl') );
$registry->getObject('template')->buildFromTemplates('header.php', 'main.php', 'footer.php');
//Is the user authenticated?
if($registry->getObject('authenticate')->isLoggedIn())
{
}
else
{
// Grab Templates for no-login
$registry->getObject('template')->buildFromTemplates('header-no_log.php', 'main-no_log.php', 'footer.php');
//Set default greeting
$registry->getObject('template')->getPage()->addTag( 'greeting', '<h1 class="text-center" id="greeting">hello</h1>' );
}
$controllers = array();
$controllersSQL = "SELECT * FROM controllers WHERE active=1";
$registry->getObject('db')->executeQuery( $controllersSQL );
while( $controller = $registry->getObject('db')->getRows() )
{
$controllers[] = $controller['controller'];
}
//Which controller should we delegate to?
//?page=$controller
$controller = $registry->getObject('url')->getURLBit(0);
if( in_array( $controller, $controllers ) )
{
require_once( FRAMEWORK_PATH . 'controllers/' . $controller . '/controller.php');
$controllerInc = $controller.'controller';
$controller = new $controllerInc( $registry, true );
}
else
{
// default controller, or pass control to CMS type system?
}
if(!isset($_POST['process_registration']))
{
$registry->getObject('template')->parseOutput();
print $registry->getObject('template')->getPage()->getContentToPrint();
}
?>