Posted By

cdohost on 09/28/11


Tagged

php path


Versions (?)

PHP - Bug Fix Required Path


 / Published in: PHP
 

Bug Fix Required Path (Corrige o bug no caminho do arquivo)

  1. if (!function_exists('bugFixRequirePath'))
  2. {
  3. function bugFixRequirePath($newPath)
  4. {
  5. $stringPath = dirname(__FILE__);
  6. if (strstr($stringPath,":")) $stringExplode = "\\"; else $stringExplode = "/";
  7. $paths = explode($stringExplode,$stringPath);
  8. $newPaths = explode("/",$newPath);
  9. if (count($newPaths) > 0)
  10. {
  11. for($i=0;$i<count($newPaths);$i++) { if ($newPaths[$i] == "..") array_pop($paths); }
  12. for($i=0;$i<count($newPaths);$i++) { if ($newPaths[$i] == "..") unset($newPaths[$i]); }
  13. reset($newPaths);
  14. $stringNewPath = implode($stringExplode,$paths).$stringExplode.implode($stringExplode,$newPaths);
  15. return $stringNewPath;
  16. }
  17. }
  18. }

Report this snippet  

You need to login to post a comment.