Jump to content

[SOLVED] Passing GET data through require()


iarp

Recommended Posts

Is there anyway possible todo so?

 

<?php
ob_start();
session_start();
session_regenerate_id();

$errors = array();

require_once('iarp-settings.php');
require_once('includes/iarp-core-functions.php');
require_once('includes/iarp-core-classes.php');

$cms = new iarp_main();
$content = new iarp_pages();
$content->setvals($_SERVER['REQUEST_URI']);

$parts = explode('?',$_SERVER['REQUEST_URI']);

$p = 'themes/' . $cms->theme();
if ($_SERVER['REQUEST_URI'] == '/') {
	$p .= '/index.php';
} else {
	$p .= $parts[0];
}

if (file_exists($p)) {
	if (!empty($parts[1]))
		$p .= '?' . $parts[1];

	require_once($p);
} else {
	require_once('themes/default/index.php');
}

mysql_close();
ob_flush();
?>

 

In a nutshell the above code checks the url against files contained in the themes folder, but if someone adds ? and anything after that to any of the file names it's unable to be require()'d

 

All i get is:


Warning: main(themes/default/file.php?uid=1) [function.main]: failed to open stream: No such file or directory in /homepages/31/d204952132/htdocs/iarp/main/iarp-load.php on line 29

Fatal error: main() [function.require]: Failed opening required 'themes/default/file.php?uid=1' (include_path='.:/usr/lib/php') in /homepages/31/d204952132/htdocs/iarp/main/iarp-load.php on line 29

Link to comment
https://forums.phpfreaks.com/topic/141036-solved-passing-get-data-through-require/
Share on other sites

I'm thinking that there's a server var called "QUERY_STRING" that would hold your GET vars after the ?.  Also, taking the basename() of the REQUEST_URI should give you the filename.  Maybe you have to pass the query string on to the requested URI by setting it?

 

If all else fails, you could just use cURL to retrieve the page and dump the response in your handler page.  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.