Jump to content

[SOLVED] Passing GET data through require()


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.  :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.