This is an easy way to record the incoming IP addresses who visiting your page in a simple text file. Additionally, record the type of browser and operating system.
You can put the code in two ways inside the page you want to record the incoming IP's. Depending on the type of file, select the first option if your page is PHP or the second option if your page is HTML.
In the first case of PHP copy the file IpLogger.php
to the same folder as the file you pasted the code.
Otherwise in the second case of HTML copy the file IpLogger.php
and the file IpLoggerApi.php
in the same folder
as the file where you pasted the JavaScript code.
- Copy the
IpLogger.php
andIpLoggerApi.php
files to the same folder as the page where you want to record incoming traffic IP addresses. - Copy the code to the page where you want to record the incoming traffic IP addresses at the bottom of the page before
the
</body>
tag.- If your page is PHP paste the php code. (The
IpLoggerApi.php
file is not required) - If your page is HTML paste the Javascript code.
- If your page is PHP paste the php code. (The
- Open the text file that will be created to see the IP logs that have been created.
<?php
require_once "./IpLogger.php";
$logger = new IpLogger();
$logger->write('ipsLog.txt', 'Europe/Athens');
?>
<script>
CallIpLogger();
function CallIpLogger() {
let xhttp = new XMLHttpRequest();
let url = "IpLoggerApi.php";
xhttp.open("GET", url, true);
xhttp.send();
}
<script>
By changing the settings in the call of method write you can have
- In the first member the name of the file where the network addresses will be stored.
- Ιn the second member the time zone you belong to so that you can record the correct time. Find here a list of all timezones
$logger->write('ipsLog.txt', 'Europe/Athens');
You can also change the method you called to record more data. This way you will be able to see the country, the city and other details. But be careful because this causes a delay due to the fact that it requires closures in external service and is still in a trial version.
$logger->writeExtra('ipsLog.txt', 'Europe/Athens');
The Trusted Source for IP Address Data https://ipinfo.io/