PX : code

ShortUrl by Philip Hofstetter
Download this code


<?php
function short_url($url){
 if (
$url == '-'){ return "-"; }
 
$longpath=false;
 
$comps parse_url($url);
 
$res $comps['scheme']."://".$comps['host'];
 if (
$comps['port'] != ''){$res $res.":".$comps['port'];}
 
 
$t1=strpossubstr($comps['path'], 1), "/" );
 if (
$t1 0){$t1++;}
 if (
$t1 != strrpos($comps['path'], "/")){
  
$longpath=true;
 }
 if (
$longpath){
  
$res $res."/.../".basename($comps['path']);
 }else{
  
$res $res.$comps['path'];
 }
 if (
$comps['query'] != ''){$res $res."?".$comps['query']; }
 if (
substr($urlstrlen($url), 1) == "/"){
  
$res $res.'/';
 }
 return 
$res;
}
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.