Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function makeFileURL($filePath){
- $filePath = str_replace('\','/',$filePath);
- $ssl = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? true : false;
- $sp = strtolower($_SERVER['SERVER_PROTOCOL']);
- $protocol = substr($sp, 0, strpos($sp, '/')) . (($ssl) ? 's' : '');
- $port = $_SERVER['SERVER_PORT'];
- $stringPort = ((!$ssl && ($port == '80' || $port=='8080')) || ($ssl && $port == '443')) ? '' : ':' . $port;
- $host = isset($_SERVER['HTTP_X_FORWARDED_HOST']) ? $_SERVER['HTTP_X_FORWARDED_HOST'] : isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME'];
- $filePath = preg_replace('/(/+)/','/',$filePath);
- $fileUrl = str_replace($_SERVER['DOCUMENT_ROOT'] ,$protocol . '://' . $host . $stringPort, $filePath);
- return $fileUrl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement