Eric @ EricBess WebHome

Rather than just thinking, knowing it would be meaningless

Chinese (Simplified) flagItalian flagKorean flagPortuguese flagEnglish flagGerman flagFrench flagSpanish flagJapanese flagArabic flagRussian flagGreek flagDutch flagBulgarian flagCzech flagCroat flagDanish flagFinnish flagHindi flagPolish flagRumanian flagSwedish flagNorwegian flagCatalan flagFilipino flagHebrew flagIndonesian flagLatvian flagLithuanian flagSerbian flagSlovak flagSlovenian flagUkrainian flagVietnamese flag
By N2H

PHP FixPath Function [path finishing function]

FixPath Function: fix the dirty paths. PHP path sorting function.
Example:

? View Code PHP
 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
 10 
 11 
 12 
 13 
 14 
 15 
 16 
 17 
 18 
  <? Php 
  ; echo "nnn Dirty paths: n"; 
  = 'C://////////Windows//////System' ; //  C:/System $ paths [] = 'C :////////// Windows ////// System'; / / C: / System 
  = 'C:HTMLjavascript..examplescolors.html' ; //  C:/HTML/examples/colors.html $ paths [] = 'C: HTMLjavascript .. examplescolors.html'; / / C: / HTML / examples / colors.html 
  = '/root/./wwwroot/scripts/../././webpage' ; //  /root/wwwroot/webpage $ paths [] = '/ root /. / wwwroot / scripts / .. /. /. / webpage'; / / / root / wwwroot / webpage 
  = 'wwwroot/webpage/../index.php?querystring' ; //  wwwroot/index.php?querystring $ paths [] = 'wwwroot / webpage / .. / index.php? querystring'; / / wwwroot / index.php? querystring 
  = 'http://www.php.net/manual/en/../../downloads' ; //  http://www.php.net/downloads $ paths [] = 'http://www.php.net/manual/en/../../downloads'; / / http://www.php.net/downloads 
  = 'http://www.php.net/downloads/test/test1/test2//./docs.php' ; //  http://www.php.net/docs.php $ paths [] = 'http://www.php.net/downloads/test/test1/test2//./docs.php'; / / http://www.php.net/docs.php 
  = '../downloads/../docs.php' ; //  ../docs.php $ paths [] = '.. / downloads / .. / docs.php'; / / .. / docs.php 
  = 'localhost//projetos/../_arquivos/../' ; //   "" $ paths [] = 'localhost / / projetos / .. / _arquivos /../'; / / "" 
  = 'C:/downloads/../../../' ; //  C:/ $ paths [] = 'C: / downloads /../../../'; / / C: / 
  = 'downloads/../../../' ; //  ../../ $ paths [] = 'downloads /../../../'; / / ../../ 

  $paths as $path ) foreach ($ paths as $ path) 
  ( 
      . $path . "&quot;  =  &quot;" .  fixpath ( $path ) . "&quot;" ; echo "n" ". $ path." "=" ". fixpath ($ path)." ""; 
  ) 
  ?> 
Note: "/ /" one more slashes will roll back the root.

Click to continue reading

July 17th, 2008 Posted by eric | Coding | no comments

FindRelativePath Function [path to find out the relationship between the relative]

PHP FUNCTION: Found the relative between the path.
PHP function: to find the path between the relative relationship.

Example:

? View Code PHP
 1 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
  <? Php 
  'http://www.php.net/manual/en/install.php' ; $ path_a = 'http://www.php.net/manual/en/install.php'; 
  'http://www.php.net/downloads' ; $ path_b = 'http://www.php.net/downloads'; 

  Path A:  " . $path_a ; echo "\ n Path A:". $ path_a; 
  Path B:  " . $path_b ; echo "\ n Path B:". $ path_b; 
  A to B:  " .  findRelativePath ( $path_a , $path_b ) ; //  ../../downloads/ echo "\ n A to B:". findRelativePath ($ path_a, $ path_b); / / .. / .. / downloads / 
  B to A:  " .  findRelativePath ( $path_b , $path_a ) ; //  ../manual/en/install.php echo "\ n B to A:". findRelativePath ($ path_b, $ path_a); / / .. / manual / en / install.php 
  ?> 

Function:

Click to continue reading

July 17th, 2008 Posted by eric | Coding | 2 comments