checkCodePathValid.php 563 B

1234567891011121314151617181920
  1. <?php
  2. include_once '../auth.php';
  3. function checkIfFilepathAllowed($filepath){
  4. $allowedEditingDirectory = [realpath(__DIR__ . DIRECTORY_SEPARATOR . "../"),"/media/storage"]; //Default: AOR + /media/storage
  5. if (isset($filepath) != false && $filepath != ""){
  6. $realFilepath = realpath($filepath);
  7. $allowed = false;
  8. foreach ($allowedEditingDirectory as $dir){
  9. if (strpos($realFilepath,$dir) === 0){
  10. $allowed = true;
  11. }
  12. }
  13. return $allowed;
  14. }else{
  15. return false;
  16. }
  17. }
  18. //echo checkIfFilepathAllowed("/media/storage1/text.php")? "true" : "false";
  19. ?>