Good IP Logger [v1.1]
Notice
This logger is compatible with 000webhost, but I have no idea on how to use it with the Site Builder. So don't ask me.
Instructions
1. Paste the code into a blank PHP file. For this example, the filename is "iplogger.php";
2. Create a blank .txt file called ip_log.txt
3. CHMOD ip_log.txt to 777.
4. Add this code to the top of your scripts:
PHP Code:
require_once("iplogger.php");
5. To view your IP log, go to yoursite.com/iplogger.php?az=view
Code
PHP Code:
<?php
// IP Logger by phpHelper.
function runlog() {
$str = $_SERVER["REMOTE_ADDR"];
$str .= "\t";
$str .= mktime();
$str .= "\t";
$str .= $_SERVER["HTTP_USER_AGENT"];
$str .= "\t";
$browser = get_browser(null, true);
$str .= $browser["browser"];
$str .= "\n";
@$fp = fopen("ip_log.txt", "ab");
if(!$fp) {
return false;
}
fwrite($fp, $str);
fclose($fp);
return true;
}
function writeLog() {
echo "<table border=\"0\">";
echo "<tr>";
echo "<td><strong>IP Address</strong></td>";
echo "<td><strong>Visitor Time</strong></td>";
echo "<td><strong>HTTP User-Agent</strong></td>";
echo "<td><strong>Browser Name</strong></td>";
echo "</tr>";
$n = file_get_contents("ip_log.txt");
$log = explode("\n", $n);
foreach($entryraw as $log) {
$entry = explode("\t", $entryraw);
echo "<tr>";
echo "<td>".$entry[0]."</td>";
echo "<td>".date("H:i, d M Y", $entry[1])."</td>";
echo "<td>".$entry[2]."</td>";
echo "<td>".$entry[3]."</td>";
echo "</tr>";
echo "</table>";
}
@$action = $_REQUEST["az"];
if($action == "view") {
echo "Server time is <strong>".date("O")."</strong><br />";
writeLog();
exit;
}
if(empty($action)) {
runlog();
}
?>
Hope you enjoy this wonderful tool!