<source_code>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>show IP numbers</TITLE>
</HEAD>
<body
background=""
bgcolor="#000000"
text="#33FF33"
link="#33FF33"
alink="#33FF33"
vlink="#33FF33">
<?php
$this_url="http://www.yourdomainname.org";
$database="put-your-database-name-here";
$user="put-your-database-user-name-here";
$password="put-your-database-user-password-here";
$host="localhost";
$dbh=mysql_connect (${host},${user},${password}) or die ('I cannot connect to the database because: ' .
mysql_error());
mysql_select_db ($database);
echo "<h3>Database of Visitors</h3>";
echo "MySQL is currently: ";
echo date("l dS of F Y h:i:s A");
echo "<br>";
$sql = 'SELECT * ';
$sql .= " FROM `ip_visit` ORDER by `time` DESC LIMIT 40 ";
$results = mysql_query( ${sql});
$error=mysql_error();
echo "{$error}";
while($row = mysql_fetch_row($results)) {
echo "<hr>";
if ($REMOTE_ADDR==$row[0]) {echo "this ip is yours:<br>";}
whonumber($row[0]);
echo " time of access: ".$row[1]."<br>webpage: ";
linker($row[2],$row[2]);
echo "<hr><br>";
}
function insert_showaccess($this_url, $REMOTE_ADDR , $PHP_SELF) {
$sql = "INSERT INTO `ip_visit` ( `ip_number` , `time` , `webpage` ) ";
$sql.= " VALUES ( '".$REMOTE_ADDR."', now() , '".$this_url.$PHP_SELF."' );";
mysql_query($sql);
}
function whonumber($ip_num) {
echo "<form name=\"thisform\" method=\"POST\" action=\"http://ws.arin.net/cgi-bin/whois.pl\">
<input type=\"text\" Name=\"queryinput\"";
echo " value=\"".$ip_num."\"";
echo " size=\"20\"><input type=\"submit\" value=go></form>";
}
function makevisitortable($database) {
mysql_select_db ($database);
$sql = 'CREATE TABLE `ip_visit` ( `ip_number` varchar( 16 ) NOT NULL default \'\','
. ' `time` datetime NOT NULL default \'0000-00-00 00:00:00\','
. ' `webpage` varchar( 128 ) NOT NULL default \'\','
. ' `nmap` tinytext NOT NULL ) TYPE = MYISAM ';
mysql_query($sql);
}
function linker($url,$link) {
echo "<a href=\"$url\">$link</a>";
}
if ($HTTP_GET_VARS['create_db_table']==yes) {
makevisitortable($database);
}
insert_showaccess($this_url, $REMOTE_ADDR , $PHP_SELF);
?>
</body>
</html>
<?php
die();
?>
</source_code>
Showing posts with label WEBSITE ACCESS. Show all posts
Showing posts with label WEBSITE ACCESS. Show all posts
Monday, December 24, 2007
PHP Database that shows web page access
Subscribe to:
Posts (Atom)