Posted By

Guitaraholic on 03/18/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Guitaraholic


PHP flat site html index.php : easy content switch


 / Published in: PHP
 

  1. <?php include('header.php'); ?>
  2.  
  3. <?php include('navigation.php'); ?>
  4.  
  5. <div id="contentwrap">
  6.  
  7. <?php
  8.  
  9. $default = "home.php";
  10.  
  11. $allowed = array (
  12. );
  13.  
  14. chdir("pages/");
  15.  
  16. if( isset( $_POST["page"] ) || isset( $_GET["page"] ))
  17. {
  18. $page = isset($_GET["page"]) ? $_GET["page"] : $_POST["page"];
  19.  
  20. if( in_array( trim ( $page ), $allowed ))
  21. {
  22. $file = $page . ".php";
  23. if( (file_exists( $file )))
  24. {
  25. include( $file );
  26. }
  27. else
  28. {
  29. include( $default);
  30. }
  31. }
  32. else
  33. {
  34. include( $default);
  35. }
  36. }
  37. else
  38. {
  39. include( $default );
  40. }
  41. ?>
  42.  
  43. </div><!-- end contentwrap -->
  44.  
  45.  
  46.  
  47. <?php include('footer.php'); ?>

Report this snippet  

You need to login to post a comment.