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) { $dest = makeSearch($targ); } else { $data = $sth->fetch($result); $dest = $data[0]; } } header('Location: '.$dest); $logName = "./log/404.log"; $logstr = strftime("%Y-%m-%d %H:%M:%S") . ' <' . getenv('REMOTE_ADDR') . '>' . "\t[" . getenv('HTTP_REFERER') . '] ' . getenv('SCRIPT_URI') . ' => ' . $dest . "\n"; if ($log = fopen($logName, "a+")){ flock($log, LOCK_EX); fwrite($log, $logstr); flock($log, LOCK_UN); fclose($log); } ?> Boot to the Head

Righto... here you go