Dynamic Inlcude Question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JGold1993
    New Member
    • Mar 2010
    • 4

    Dynamic Inlcude Question

    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://killinginthenam e.com

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

    but I want to make it so I can go:
    http://killinginthenam e.com/?x=content/tutorials/photoshoptutori als/tutorial

    or at least one more /filename

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

    Code:
    <?php if (isset($_GET['x'])) {
       if (strpos($_GET['x'], "/")) {
          $dir = substr(str_replace('..', '', $_GET['x']), 0, strpos($_GET['x'], "/")) . "/";
          $file = substr(strrchr($_GET['x'], "/"), 1);
          if (file_exists($dir.$file.".php")) {
             include($dir.$file.".php");
          } else {
             include("default.php");
          }
       } else {
          if (file_exists(basename($_GET['x']).".php")) {
             include(basename($_GET['x']).".php");
          } else {
             include("default.php");
          }
       }
    } else {
       include("default.php");
    } ?>
    Please help????
Working...