By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,694 Members | 1,622 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,694 IT Pros & Developers. It's quick & easy.

Dynamic Inlcude Question

P: 4
Hi, I am new to this forum.

I have a question involving PHP dynamic includes, (I think). I am not the best at PHP, and I am surprised I have been able to run my website with PHP. But this is where I am..

http://killinginthename.com

My links go as follows:
http://killinginthename.com/?x=content/tutorials

but I want to make it so I can go:
http://killinginthename.com/?x=content/tutorials/photoshoptutorials/tutorial

or at least one more /filename

It doesn't seem to be working. Below is my PHP code:

Expand|Select|Wrap|Line Numbers
  1. <?php if (isset($_GET['x'])) {
  2.    if (strpos($_GET['x'], "/")) {
  3.       $dir = substr(str_replace('..', '', $_GET['x']), 0, strpos($_GET['x'], "/")) . "/";
  4.       $file = substr(strrchr($_GET['x'], "/"), 1);
  5.       if (file_exists($dir.$file.".php")) {
  6.          include($dir.$file.".php");
  7.       } else {
  8.          include("default.php");
  9.       }
  10.    } else {
  11.       if (file_exists(basename($_GET['x']).".php")) {
  12.          include(basename($_GET['x']).".php");
  13.       } else {
  14.          include("default.php");
  15.       }
  16.    }
  17. } else {
  18.    include("default.php");
  19. } ?>
Please help????
Mar 26 '10 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.