Guest User

script.php

a guest
Jan 5th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.61 KB | None | 0 0
  1. <?php
  2. function rmNonAlpha($input) {
  3.   return preg_replace("@[^0-9a-zA-Z\s]@", "", $input);
  4. }
  5.  
  6. if(isset($_GET['filepath'])){
  7.     $base_filepath = ""; // Enter here your base filepath (The directory where you want people to be able to read/write files). You should end it with an "/"
  8.     $sanitized_filepath = rmNonAlpha($_GET['filepath']); // Removes non Alpha chars, so stuff like "/" will be ignored, so people won't leave directory
  9.     $full_path = $base_filepath . $sanitized_filepath;
  10.     if(file_exists($full_path)) {
  11.         echo file_get_contents($path);
  12.     } else echo "File doesn't exist";
  13. } else echo "Filepath Missing";
  14.  
  15. ?>
Advertisement
Add Comment
Please, Sign In to add comment