Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- IP Logger, with no Cloudflare/Incapsula:
- <?php
- function logIP()
- {
- $ipLog="logfile.txt"; // Your log files here; (.html, .txt extensions work fine.)
- $register_globals = (bool) ini_get('register_gobals');
- if ($register_globals) $ip = getenv(REMOTE_ADDR);
- else $ip = $_SERVER['REMOTE_ADDR'];
- $date=date ("l dS of F Y h:i:s A");
- $log=fopen("$ipLog", "a+");
- if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
- {
- fputs($log, "Logged IP address: $ip - Date logged: $date<br>"); // How you want it to show up
- }
- else fputs($log, "Logged IP address: $ip - Date logged: $date\n"); // How you want it to show up
- fclose($log);
- }
- // Place the below function call wherever you want the script to fire.
- logIp();
- ?>
- IP Logger, with Cloudflare:
- <?php
- function logIP()
- {
- $ipLog="logfile.txt"; // Your log files here; (.html, .txt extensions work fine.)
- $register_globals = (bool) ini_get('register_gobals');
- if ($register_globals) $ip = getenv(HTTP_CF_CONNECTING_IP);
- else $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
- $date=date ("l dS of F Y h:i:s A");
- $log=fopen("$ipLog", "a+");
- if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
- {
- fputs($log, "Logged IP address: $ip - Date logged: $date<br>"); // How you want it to show up
- }
- else fputs($log, "Logged IP address: $ip - Date logged: $date\n"); // How you want it to show up
- fclose($log);
- }
- // Place the below function call wherever you want the script to fire.
- logIp();
- ?>
- IP Logger, with Incapsula:
- <?php
- function logIP()
- {
- $ipLog="logfile.txt"; // Your log files here; (.html, .txt extensions work fine.)
- $register_globals = (bool) ini_get('register_gobals');
- if ($register_globals) $ip = getenv(HTTP_INCAP_CLIENT_IP);
- else $ip = $_SERVER['HTTP_INCAP_CLIENT_IP'];
- $date=date ("l dS of F Y h:i:s A");
- $log=fopen("$ipLog", "a+");
- if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
- {
- fputs($log, "Logged IP address: $ip - Date logged: $date<br>"); // How you want it to show up
- }
- else fputs($log, "Logged IP address: $ip - Date logged: $date\n"); // How you want it to show up
- fclose($log);
- }
- // Place the below function call wherever you want the script to fire.
- logIp();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement