Description:
An update of janra's useful referer_view box. Just a minor Perl hack, this one snips the referring URL down to just the domain name part of the referer. It still links to the full referring URL, but can help clean up your referrer box when you're getting those 80 character long URL's.
I also took out the UL and LI tags, preferring to put just my |dot| macro in at box entry time. But that's up to you. :)
Box Code:
## START referer_view ##
# This box displays the referer information
# collected by referer_catch. It requires a
# table called 'referer' in your database;
# please see the comments in referer_catch.
my $title = "External links in";
my $content = "";
my ($rv, $sth) = $S->db_select({
WHAT => '*',
FROM => 'referer',
ORDER_BY => 'hits DESC'
});
while ( my $referers = $sth->fetchrow_hashref ) {;
# now to format and print them
#foreach my $ref ( %$referers ) {
# my $url = $ref->{url};
# my $hits = $ref->{hits};
my $url = $referers->{url};
my $hits = $referers->{hits};
my $chopped_url = substr( $url, 7);
my $end_of_url = index ($chopped_url, "/" );
$chopped_url = substr ($chopped_url,0, $end_of_url);
if ( $url =~ /^-$/ ) {
$content .= qq{no referer ($hits)<br>};
} else {
$content .= qq{<A href="$url">$chopped_url</A> ($hits hits)<br>};
}
}
$content .= "<br>";
return $title, $content;
## END referer_view ##
|