Changeset 4377 for lang/php

Show
Ignore:
Timestamp:
01/10/08 22:53:17 (5 years ago)
Author:
tasuku
Message:

lang/php/mumu: added MuUtil::absolute_uri

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/php/mumu/trunk/mumu.php

    r4376 r4377  
    9595    } 
    9696    return true; 
     97  } 
     98  public static function absolute_uri($base, $ref) { 
     99    $b = parse_url($base); 
     100    $uri = $b['scheme'].'://'; 
     101    if (isset($b['user'])) { 
     102      $uri .= $b['user']; 
     103      if (isset($b['pass'])) { 
     104        $uri .= ':'. $b['pass']; 
     105      } 
     106      $uri .= '@'; 
     107    } 
     108    $uri .= $b['host']; 
     109    if (isset($b['port'])) { 
     110      $uri .= ':'. $b['port']; 
     111    } 
     112    $paths = explode('/', $b['path']); 
     113    if ($ref[0] == '/') { 
     114      return $uri. $ref; 
     115    } 
     116    $refs = explode('/', $ref); 
     117    foreach ($refs as $r) { 
     118      switch ($r) { 
     119        case '': 
     120        case '.': 
     121          break; 
     122        case '..': 
     123          array_pop($paths); 
     124          break; 
     125        default: 
     126          $paths[] = $r; 
     127      } 
     128    } 
     129    $uri .= implode('/', $paths); 
     130    return $uri; 
    97131  } 
    98132}