Scoop -- the swiss army chainsaw of content management
Front Page Everything News Code Help! Wishlist Project Scoop Sites Dev Notes Latest CVS changes Development Activities
Scoop Box Exchange - Show Box: referer_catch 1.00

Author: janra [Info]

Description:

records the referer for referer_view to display - helps you track who's linking in

Box Code:

## START referer_catch ##
# This box collects referer information but
# doesn't actually output anything visible. Place
# on every page template if you want to find out
# who's linking to any page. If the referer is
# from within the site, it is ignored
# To use this box, you must create a table in the
# database named "referer"
# with the following SQL command:
#
# CREATE TABLE referer (
# url varchar(255),
# hits int(10) DEFAULT 0,
# INDEX (url)
# );
#

my $sitename = $S->{UI}->{VARS}->{site_url};
my $raw_referer = $S->{REFERER};
unless ( $raw_referer ) {
$raw_referer = "-";
}

# keep things clean; we only want referers you
# *don't* know about
return if ( $raw_referer =~ /$sitename/i );

my $referer = $S->{DBH}->quote($raw_referer);

# check if that URL is already in the db
my ($rv, $sth) = $S->db_select({
WHAT => 'count(url) AS num',
FROM => 'referer',
WHERE => "url = $referer"
});
my $dbresponse = $sth->fetchrow_hashref();
my $url_exists = $dbresponse->{num};

# count the URL
if ( $url_exists ) {
($rv, $sth) = $S->db_update({
WHAT => 'referer',
SET => 'hits = hits + 1',
WHERE => "url = $referer"
});
} else {
$S->db_insert({ INTO => 'referer',
COLS => 'url, hits',
VALUES => "$referer, 1"
});
}

return;

## END referer_catch ##
Display: Sort:
Code (none / 0) (#1)
by michaellhog on Tue Nov 13, 2018 at 06:47:15 AM PST

Hi my name is Michaell Hog and I provide Custom Essay Writing service in UK could you please help in coding?



Menu
create account
faq
search
report bugs
Scoop Administrators Guide
Scoop Box Exchange

Scoop Site Scroller: Get one yourself!
Smokedot
It's 4:19... do you know where your bong is?

Login
Make a new account
Username:
Password:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest 1999 The Management

create account | faq | search