Stumble and Digg Begging
Haven’t done a Neat Tricks and Hacks in awhile. Here’s one to remind DIGG and Stumbleupon users to up your shit.
PHP
<?
$sites[’stumbleupon’] = ‘Glad you stumbled upon us. Please leave us a nice review if you enjoy the site!’;
$sites[’digg.com’] = ‘Glad you found us on Digg. Please Digg up if you like!’;
if( !empty( $_SERVER[’HTTP_REFERER’] ) ) {
$data = parse_url( $_SERVER[’HTTP_REFERER’ ] );
foreach( $sites as $domain => $text ) {
if( strpos( strtolower( $data[’host’] ), $domain ) !== false ) {
echo ‘<script type=”text/javascript”>alert(”‘.addslashes($text).’”);</script>’;
break;
}
}
}
?>
PERL
$sites{’stumbleupon’} = ‘Glad you stumbled upon us. Please leave us a nice review if you enjoy the site!’;
$sites{’digg.com’} = ‘Glad you found us on Digg. Please Digg up if you like!’;
if ($ENV{’HTTP_REFERER’} ne “”){
foreach $key (keys %sites) {
if($ENV{’HTTP_REFERER’} =~ /$sites{’$key’}/) {
print qq~<script type=”text/javascript”>alert(”$line”);</script>~;
}
}
}
*PERL code is untested, I just translated it off the top of my head. Probably made a mistake or two… I always do. Am I the only CGIer left in this world?
Javascript
Source: Top News Trends
I just started testing this method today, so I couldn’t tell you how well it works yet. I’m going to start with Stumbleupon because I’m willing to wager I’ll have better results with them than the Digg crowd but who knows? Let me know how it works for you in the comments.
Comments (444)
These comments were imported from the original blog. New comments are closed.