get("api:ip:$ip"); if(!in_array($ip, $apip)){ $redis->set("api:ip:$ip", $ip); $redis->expireAt("api:ip:$ip", $now+5); // Five seconds between requests should be okay }else{ die("Too many requests too fast!"); } $reShort = shorten($redis, $short, 2, $seperator); $reShort = explode($seperator, $reShort); $retCode = $reShort[0]; switch($retCode){ case "0": // Successful link Shorten echo $reShort[1]; break; case "1": // Existing Short Link Found echo $reShort[1]; break; case "2": // Dead Link echo "dead"; break; case "3": // DB Error echo "db"; break; case "4": // Sanitize Failure Error echo "sf"; break; default: echo "Error"; break; } exit; }elseif(isset($_GET['resolve'])){ die("Not ready"); } else{ die("Improper Call."); } ?>