Advertisement
CorteX-

IP Logger, works with Cloudflare, Incapsula, no protection.

Sep 1st, 2014
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.47 KB | None | 0 0
  1. IP Logger, with no Cloudflare/Incapsula:
  2.  
  3. <?php
  4.  
  5. function logIP()
  6. {
  7. $ipLog="logfile.txt"; // Your log files here; (.html, .txt extensions work fine.)
  8.  
  9. $register_globals = (bool) ini_get('register_gobals');
  10. if ($register_globals) $ip = getenv(REMOTE_ADDR);
  11. else $ip = $_SERVER['REMOTE_ADDR'];
  12.  
  13. $date=date ("l dS of F Y h:i:s A");
  14. $log=fopen("$ipLog", "a+");
  15.  
  16. if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
  17. {
  18. fputs($log, "Logged IP address: $ip - Date logged: $date<br>"); // How you want it to show up
  19. }
  20. else fputs($log, "Logged IP address: $ip - Date logged: $date\n"); // How you want it to show up
  21.  
  22. fclose($log);
  23. }
  24. // Place the below function call wherever you want the script to fire.
  25. logIp();
  26.  
  27.  
  28. ?>
  29.  
  30. IP Logger, with Cloudflare:
  31.  
  32. <?php
  33.  
  34. function logIP()
  35. {
  36. $ipLog="logfile.txt"; // Your log files here; (.html, .txt extensions work fine.)
  37.  
  38. $register_globals = (bool) ini_get('register_gobals');
  39. if ($register_globals) $ip = getenv(HTTP_CF_CONNECTING_IP);
  40. else $ip = $_SERVER['HTTP_CF_CONNECTING_IP'];
  41.  
  42. $date=date ("l dS of F Y h:i:s A");
  43. $log=fopen("$ipLog", "a+");
  44.  
  45. if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
  46. {
  47. fputs($log, "Logged IP address: $ip - Date logged: $date<br>"); // How you want it to show up
  48. }
  49. else fputs($log, "Logged IP address: $ip - Date logged: $date\n"); // How you want it to show up
  50.  
  51. fclose($log);
  52. }
  53. // Place the below function call wherever you want the script to fire.
  54. logIp();
  55.  
  56.  
  57. ?>
  58.  
  59. IP Logger, with Incapsula:
  60.  
  61. <?php
  62.  
  63. function logIP()
  64. {
  65. $ipLog="logfile.txt"; // Your log files here; (.html, .txt extensions work fine.)
  66.  
  67. $register_globals = (bool) ini_get('register_gobals');
  68. if ($register_globals) $ip = getenv(HTTP_INCAP_CLIENT_IP);
  69. else $ip = $_SERVER['HTTP_INCAP_CLIENT_IP'];
  70.  
  71. $date=date ("l dS of F Y h:i:s A");
  72. $log=fopen("$ipLog", "a+");
  73.  
  74. if (preg_match("/\bhtm\b/i", $ipLog) || preg_match("/\bhtml\b/i", $ipLog))
  75. {
  76. fputs($log, "Logged IP address: $ip - Date logged: $date<br>"); // How you want it to show up
  77. }
  78. else fputs($log, "Logged IP address: $ip - Date logged: $date\n"); // How you want it to show up
  79.  
  80. fclose($log);
  81. }
  82. // Place the below function call wherever you want the script to fire.
  83. logIp();
  84.  
  85.  
  86. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement