DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Textpattern - Display Log By Hostname

04.11.2006
| 1925 views |
  • submit to reddit
        
<html>
<head>
<link href="/textpattern/textpattern.css" rel="Stylesheet" type="text/css" />
</head>
<body>
<?php
require_once("textpattern/config.php");
mysql_connect($txpcfg['host'], $txpcfg['user'], $txpcfg['pass']) or die(mysql_error());
mysql_select_db($txpcfg['db']) or die(mysql_error());

// Quote variable to make safe
function quote_smart($value)
{
   // Stripslashes
   if (get_magic_quotes_gpc()) {
       $value = stripslashes($value);
   }
   // Quote if not a number or a numeric string
   if (!is_numeric($value)) {
       $value = mysql_real_escape_string($value);
   }
   return $value;
}
$sql = "SELECT * FROM " .$txpcfg['table_prefix'] ."txp_log WHERE host LIKE '%" .quote_smart($_GET['host']) ."%' ORDER BY 'time' DESC LIMIT 0, 30 ";
$result = mysql_query($sql) or die(mysql_error());
echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" id=\"list\" align=\"center\">";
echo "<tr><td><b>Time</b></td><td><b>host</b></td><td><b>page</b></td></tr>";
while($row = mysql_fetch_array($result))
{
 echo "<tr><td>".$row['time']."</td><td>".$row['host']."</td><td>".$row['page']."</td></tr>";
}
echo "</table>";
?>
</body></html>