connect('127.0.0.1', 6379); function followLink($shortdb, $redis, $link){ $link = $shortdb->real_escape_string(strtolower(stripslashes(strip_tags($link)))); $link = str_replace('/', '', $link); $sql = "SELECT * FROM `tracking` WHERE `id` = '$link' LIMIT 1;"; // Testing to see if the link has been visited before if($result = $shortdb->query($sql)){ if($row = $result->fetch_assoc()){ $sql = "UPDATE `tracking` SET `clicks` = `clicks` + 1 WHERE `id` = '$link'"; // Yes it has, increment clicks by 1 if($result = $shortdb->query($sql)){ if($result->num_rows == 0){ die ($shortdb->error); } } } }else{ $sql = "INSERT INTO `tracking` (id, clicks) VALUES ('$link', 1)"; // No it hasn't, add 1 click to the table if($result = $shortdb->query($sql)){ if($result->num_rows == 0){ die ($shortdb->error); } } } // Try to find it in the redis db first, if not there, add it $short = $redis->get($link); if (!$short || $short == null) { $sql = "SELECT * FROM `links` WHERE `shortlink` = '$link' LIMIT 1;"; if($result = $shortdb->query($sql)){ if($row = $result->fetch_assoc()){ $llink = $row['link']; $redis->set($link, $llink); echo $llink; //header("location:$link"); exit(5); // Stop script execution to save on resources } } }else{ echo $short; 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 */ // This has been depreciated. Still here for backwards compatibility with existing links if(!empty($_GET['l'])){ followLink($shortdb, $redis, $_GET['l']); } // New way to check for valid short links, two characters shorter than the if statement above if(!empty($_GET)){ $key = key($_GET); 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($shortdb, $redis, $key); } ?> lob.li - Objective Links

Please give me a link to shorten...

loading.... Please Wait