tobast

secure_include

May 17th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2.     // You can modify the second value to change the fallback page (eg., you could make it redirect to an error page).
  3.     define("FALLBACK_PAGE", "news_en.php");
  4.  
  5.     /// secure_include
  6.     /// string $file : file to include
  7.     /// If the given $file is not in the working directory, includes FALLBACK_PAGE. Else, includes $file.
  8.     function secure_include($file)
  9.     {
  10.         addslashes($file);
  11.  
  12.         if($file == 'div_en.php' || $file == 'div.php' || !in_array($file, scandir(getcwd())))
  13.             include(FALLBACK_PAGE);
  14.         else
  15.             include($file);
  16.     }
  17. ?>
Advertisement
Add Comment
Please, Sign In to add comment