Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function readIP($path, $file, $ip) {
- $flag = false;
- if(file_exists($path.$file)) {
- if ($data = fopen($path.$file, "r")) {
- while(!feof($data)) {
- $line = fgets($data);
- if($line != '') {
- $line = explode("-", $line);
- if(trim($ip) == trim($line[2])) {
- $flag = true;
- }
- }
- }
- fclose($data);
- }
- }
- return $flag;
- }
- function writeIP($path, $file, $ip) {
- $ip = date("d.m.Y - H:i:s "). " - ".$ip;
- if(file_exists($path.$file)) {
- $fo = fopen($path.$file, "a");
- fwrite($fo, $ip."\n");
- fclose($fo);
- }
- }
- $filePath = "./";
- $fileName = "ip.txt";
- $ip = $_SERVER['REMOTE_ADDR'];
- if (readIP($filePath, $fileName, $ip) === false) {
- writeIP($filePath, $fileName, $ip);
- }
- header( 'Location: https://wunschdomain.com') ;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement