'; $code = $_GET['code']; $query = 'SELECT * FROM `redirects` WHERE code="' . $code . '";'; $r = mysql_query($query); if(mysql_num_rows($r) > 0){ $host = addslashes(gethostbyaddr($_SERVER['REMOTE_ADDR'])); $ip = addslashes($_SERVER['REMOTE_ADDR']); $ref = addslashes($_SERVER['HTTP_REFERER']); $agent = addslashes($_SERVER['HTTP_USER_AGENT']); $query = "INSERT INTO `redirects_hits` (`code`, `date`, `ip`, `host`, `referral`, `agent`) VALUES ('$code', UNIX_TIMESTAMP(), '$ip', '$host', '$ref', '$agent');"; mysql_query($query); $url = mysql_result($r, 0, 1); header("HTTP/1.0 301 Moved Permanently"); header("Location: $url"); /* require_once "geoip/GeoIP.php"; $geoip = Net_GeoIP::getInstance("/path/to/geoipdb.dat"); try { echo $geoip->lookupCountryName($_SERVER['REMOTE_ADDR']); } catch (Exception $e) { // Handle exception echo 'error'; } */ } else { header('Location: http://lev.me?error'); //echo 'omg. gtfo'; //echo $query; //echo mysql_error($r); } ?>