*********************************************************************************
* MOD NAME: Automatic Long URL Truncater 6.7 *
*********************************************************************************
* DESCRIPTION: Will automatically shorten urls over 50 characters in length, *
* preventing a long url from messing up page layout *
* DEMO: http://www.alforadmin.com *
* *
*********************************************************************************
* CREATED BY: Al, with help from LK and using code by Charles Capps *
* DATE: 2/1/04 *
* VERSION: version 1.0 *
* *
*********************************************************************************
*********************************************************************************
* REQUIREMENTS: Full License *
* COMPATABILITY: works with v6.7x *
*********************************************************************************
* FILES MODIFIED: ubb_lib.cgi Yep, that's all *
*********************************************************************************
* DISCLAIMER: By using this modification, the user implicitly agrees *
* that they are willingly modifying any and all files at *
* their own risk. Should any errors occur either as a *
* direct or indirect result of said modifications the user *
* agrees not to hold Infopop Corporation or any of the *
* individuals listed accountable. *
* *
* *
* IN OTHER WORDS: PLEASE MAKE BACKUP COPIES OF EVERY FILE YOU PLAN TO *
* MODIFY PRIOR TO MODIFICATION!! *
* *
* *
* FOR MORE TIPS AND TRICKS FOR USE WITH THE ULTIMATE BULLETIN BOARD *
* PLEASE VISIT US AT: *
* *
* http://www.ubbdev.com/ *
* *
*********************************************************************************
*********************************************************************************
###############################################################################
# IMPORTANT: ONLY DO THE NEXT STEP IF YOU ARE RUNNING A BETA VERSION OF 6.7 #
###############################################################################
#########
# FIND: #
#########
sub elipsurl {
my $string = shift;
my $domain;
if($string =~ s!^(\w+://[^\/]+)\/!!) {
$domain = $1;
} # end if
if(length $string < 60) {
# too short to shorten
return "$domain/$string";
} # end if
my $left = substr($string, 0, 25);
my $l = length($string);
my $right = substr($string, $l - 25, $l);
return "$domain/$left...$right";
} # end elipsurl
##################
# REPLACE WITH: #
##################
sub elipsurl {
my $string = shift;
my $domain = "";
if($string =~ s!^(\w+://[^\/]+)\/!!) {
$domain = $1;
$domain = $domain . qq~/~;
} # end if
if(length $string < 60) {
# too short to shorten
return "$domain$string";
} # end if
my $left = substr($string, 0, 25);
my $l = length($string);
my $right = substr($string, $l - 25, $l);
return "$domain$left...$right";
} # end elipsurl
###############################################################################
# IMPORTANT: The Rest of the steps should be done for all versions of 6.7 #
###############################################################################
#########
# FIND: #
#########
$check =~ s/(^|\s)(http:\/\/\S+)(\.|\,|\))?/$1$2<\/a>$3/isg;
$check =~ s/(^|\s)(https:\/\/\S+)(\.|\,|\))?/$1$2<\/a>$3/isg;
$check =~ s/(^|\s)(ftp:\/\/\S+)(\.|\,|\))?/$1$2<\/a>$3/isg;
$check =~ s/(^|\s)(www\.\S+)(\.|\,|\))?/$1$2<\/a>$3/isg;
##################
# REPLACE WITH: #
##################
$check =~ s/(^|\s)(http:\/\/\S+)(\.|\,|\))?/qq~$1~ . &elipsurl($2) . qq~<\/a>$3~/eisg;
$check =~ s/(^|\s)(https:\/\/\S+)(\.|\,|\))?/qq~$1~ . &elipsurl($2) . qq~<\/a>$3~/eisg;
$check =~ s/(^|\s)(www\.\S+)(\.|\,|\))?/qq~$1~ . &elipsurl("http:\/\/$2") . qq~<\/a>$3~/eisg;
$check =~ s/(^|\s)(ftp:\/\/\S+)(\.|\,|\))?/qq~$1~ . &elipsurl($2) . qq~<\/a>$3~/eisg;
#########
# FIND: #
#########
$returner = qq~$wording~;
##################
# REPLACE WITH: #
##################
$returner = qq~~ . &elipsurl($wording) . qq~~;
#############
# End Hack #
#############