50 lines
1.3 KiB
PHP
50 lines
1.3 KiB
PHP
<?
|
|
// Insert passed information into database to log ad delivery failure
|
|
//
|
|
// Mike Apted (mike@devsol.ca) - 2008.12.14
|
|
|
|
// Configuration
|
|
//
|
|
|
|
$db_host = '192.168.1.10';
|
|
$db_user = 'slowtwitch';
|
|
$db_pass = 'k9volqlAcpq';
|
|
$db_name = 'slowtwitch';
|
|
|
|
// Accept and validate parameters
|
|
//
|
|
|
|
if (isset($_GET["ipaddr"]))
|
|
if (preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $_GET["ipaddr"]))
|
|
$ipaddr = $_GET["ipaddr"];
|
|
else
|
|
$ipaddr = "";
|
|
else
|
|
$ipaddr = "";
|
|
|
|
if (isset($_GET["userID"]))
|
|
if (preg_match("/^[a-z\d_]{0,30}$/i", $_GET["userID"]))
|
|
$userID = $_GET["userID"];
|
|
else
|
|
$userID = "";
|
|
else
|
|
$userID = "";
|
|
|
|
if (isset($_GET["adzone"]))
|
|
if (preg_match("/\d{1,3}/", $_GET["adzone"]))
|
|
$adzone = $_GET["adzone"];
|
|
else
|
|
$adzone = "";
|
|
else
|
|
$adzone = "";
|
|
|
|
// Log entry into database
|
|
//
|
|
|
|
$db = mysql_connect($db_host, $db_user,$db_pass) or die("Error: Could not connect to server.");
|
|
mysql_select_db($db_name) or die("Error: Could not select database.");
|
|
$query = "INSERT into adblock_iplog (ipaddr, user, adzone) values('" . mysql_real_escape_string($ipaddr) . "', '" . mysql_real_escape_string($userID) . "', '" . mysql_real_escape_string($adzone) . "')";
|
|
$result = mysql_query($query) or die("Error: Query failed - " . mysql_error());
|
|
|
|
?>
|