Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Shared :: "Linedancer 2/Unix Compliance.php"
- function UnixAdjust($path){
- $path = str_replace("\\","/",$path);
- $adjusted = "";
- for($offset = 0; $offset < strlen($path); $offset++){
- $c = substr($path,$offset,1);
- $upper = strtoupper($c);
- $lower = strtolower($c);
- if($upper !== $lower){
- $adjusted .= "[{$upper}{$lower}]";
- }else{
- $adjusted .= "{$c}";
- }
- }
- return $adjusted;
- }
- function UnixNormalized($path){
- $path = UnixAdjust($path);
- if(substr($path,0,strlen("{$_SERVER['DOCUMENT_ROOT']}")) === "{$_SERVER['DOCUMENT_ROOT']}"){
- $path = substr($path,strlen("{$_SERVER['DOCUMENT_ROOT']}")) === "{$_SERVER['DOCUMENT_ROOT']}";
- }
- while(substr($path,0,1) == "/"){
- $path = substr($path,1);
- }
- $parts = explode("/",$path);
- $parts = explode("/",$path);
- $adjusted = "";
- $normalized = "{$_SERVER['DOCUMENT_ROOT']}";
- foreach($parts as $part){
- if(glob("{$normalized}/{$part}",GLOB_ONLYDIR)){
- $normalized.="/{$part}";
- }elseif(glob("{$normalized}/{$part}")){
- $normalized.="/{$part}";
- break;
- }
- }
- return $normalized;
- }
- function UnixPath($path){
- $normalized = UnixNormalized($path);
- return glob($normalized)[0];
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement