lRange("tracking:ip:$link", 0, -1); if(!in_array($_SERVER['REMOTE_ADDR'], $ipTrack)){ // Check to see if visiter hit this link before (This would make it a lot easier to skew statistics if anyone would register multiples times) $redis->rPush("tracking:ip:$link", $_SERVER['REMOTE_ADDR']); $trTtl = $redis->ttl("links:$link"); if($trTtl != -2){ $tracking = $redis->zIncrBy("tracking:clicks", 1, $link); }else{ if($trTtl == -2){ // The link has been deleted, no need to track it anymore $redis->zRem("tracking:clicks", $link); } } } $short = $redis->lRange("links:$link", 0, 0); if($short){ header('location:'.$short[0]); exit(5); } } // exit codes: /* exit 0 - Good script exit 5 - Link redirection 10x exit codes exit 11 - Shortener Stats redirection exit 12 - Shortener Resolver redirection exit 13 - Shortener About redirection */ if(!empty($_GET)){ $key = key($_GET); if($key == "l") $key = $_GET['l']; if($key == "stats"){ header("location:http://s.lob.li"); exit(11); } if($key == "resolv"){ header("location:http://r.lob.li"); exit(12); } if($key == "about"){ header("location:http://a.lob.li"); exit(13); } followLink($redis, $key); } ?>