Advertisement
Guest User

Untitled

a guest
Nov 25th, 2018
365
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. <?php
  2. function readIP($path, $file, $ip) {
  3.     $flag = false;
  4.     if(file_exists($path.$file)) {
  5.         if ($data = fopen($path.$file, "r")) {
  6.             while(!feof($data)) {
  7.                 $line = fgets($data);
  8.                 if($line != '') {
  9.                     $line = explode("-", $line);
  10.                     if(trim($ip) == trim($line[2])) {
  11.                         $flag = true;
  12.                     }
  13.                 }
  14.             }
  15.             fclose($data);
  16.         }
  17.     }
  18.     return $flag;
  19. }
  20. function writeIP($path, $file, $ip) {
  21.     $ip = date("d.m.Y - H:i:s "). " - ".$ip;
  22.     if(file_exists($path.$file)) {
  23.         $fo = fopen($path.$file, "a");
  24.         fwrite($fo, $ip."\n");
  25.         fclose($fo);
  26.     }
  27. }
  28.  
  29. $filePath = "./";
  30. $fileName = "ip.txt";
  31.  
  32. $ip = $_SERVER['REMOTE_ADDR'];
  33.  
  34. if (readIP($filePath, $fileName, $ip) === false) {
  35.     writeIP($filePath, $fileName, $ip);
  36. }
  37. header( 'Location: https://wunschdomain.com') ;
  38. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement