exec("delete from {$db['table']} where (expires != 0 AND expires < unix_timestamp(now()))"); $sth=$dbh->prepare("select url from {$db['table']} where name = ?"); // batten down the hatches, User Input Ahead! $targ = preg_replace("/([%_])/","\\$1",$targ); $targ = preg_replace("/[<>]/","",$targ); $targ = substr($targ,0,50); if (!$sth->execute(Array($targ)) || $sth->rowcount() == 0) include('notfound.php'); else { $data = $sth->fetch($result); header('Location: '.$data[0],true,302); error_log("302: [$targ] referer:".getenv('REFERER')); } @include("./piwik.inc"); ?>