Viewing file: visitation_log.phtml (2.2 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<html> <head> <title>Visitor search by name</title> </head> <body> <?
function listrecords($query) { $result=pg_exec(pg_connect("dbname=ax"),$query); $rows=pg_numrows($result); echo "<table border>\n"; for ($row=0;$row<$rows;$row++) { $obj=pg_fetch_array($result,$row); echo "<tr><td>",$obj[ipaddr],"<td>",$obj[username],"<td>",$obj[date],"\n"; } echo "</table>\n"; }
if ($_SERVER['REQUEST_METHOD']=='GET') { echo "<form method=post action=logcheck>"; echo "<table>"; echo "<tr><td>Exact username to search for in pagehits log:</td><td><input type=text name=name></td></tr>"; echo "<tr><td>(part of) username to search for in pagehits log:</td><td><input type=text name=fuzzyname></td></tr>"; echo "<tr><td>Exact IP address to search for in pagehits log:</td><td><input type=text name=ipaddr></td></tr>"; echo "<tr><td>(part of) IP address to search for in pagehits log (slow and loads server, only use if you really have to, and give as much of the IP address as possible!):</td><td><input type=text name=fuzzyip></td></tr>"; echo '<tr><td>Show only entries not older than</td><td><select name=timelimit><option>1 month</option><option>2 months</option><option>3 months</option><option>6 months</option><option>1 year</option><option>2 years</option><option>3 years</option><option value="">unlimited</option></select></td></tr>'; echo "<tr><td colspan=2 align=center><input type=submit value=\"Search!\"></td></tr>"; echo "</table>"; echo "</form>"; } if ($_SERVER['REQUEST_METHOD']=='POST') { $query[]= 'select ipaddr, username, date from agents'; if ($_POST[name]) $clauses[]="username='".pg_escape_string($_POST['name'])."'"; if ($_POST[fuzzyname]) $clauses[]="username~*'".pg_escape_string($_POST['fuzzyname'])."'"; if ($_POST[ipaddr]) $clauses[]="ipaddr='".pg_escape_string($_POST['ipaddr'])."'"; if ($_POST[fuzzyip]) $clauses[]="ipaddr~*'".pg_escape_string($_POST['fuzzyip'])."'"; if ($_POST[timelimit]) $clauses[]="date >= ('now'::timestamp - '".pg_escape_string($_POST['timelimit'])."'::interval)";
if ($clauses) { $query[]='where'; $query[]=join(' and ',$clauses); }
$query[]="order by date desc;";
//echo(join(" ",$query)); listrecords(join(" ",$query)); } ?> </body> </html>
|