sanitize.inc 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. $san=0;
  3. //Forbid anything starting with / and anything with .. in it; also remote links
  4. $badguy = strpos($pwd, '/');
  5. $badguys = strstr($pwd,'..');
  6. $http = stristr($pwd,'http://');
  7. $https = stristr($pwd,'https://');
  8. $ftp = stristr($pwd, 'ftp://');
  9. $gop = stristr($pwd, 'gopher://');
  10. if ($badguy === 0) {
  11. include 'sys/fileshare/include/forbidden.inc';
  12. $san=1;
  13. return(0);
  14. }
  15. if ($badguys !== FALSE) {
  16. include 'sys/fileshare/include/forbidden.inc';
  17. $san=1;
  18. return(0);
  19. }
  20. if ($http !== FALSE || $https !== FALSE || $ftp !== FALSE || $gop !== FALSE) {
  21. include 'sys/fileshare/include/external.inc';
  22. $san=1;
  23. return(0);
  24. }
  25. //Check the list of other forbidden directories
  26. $blist = "sys/fileshare/include/blacklist";
  27. $channel = fopen($blist, "r");
  28. $contents = fread($channel, filesize($blist));
  29. $readable = preg_split('[/]', $contents);
  30. $countchocula = count($readable)-1;
  31. for ($a = 0; $a < $countchocula; $a++) {
  32. $patterns = '^'.$readable[$a];
  33. $foos = ereg($patterns, $pwd);
  34. if ($foos == 1) {
  35. include 'sys/fileshare/include/forbidden.inc';
  36. $san=1;
  37. return(0);
  38. }
  39. }
  40. ?>