random-ipsperre.php


Quell Code


<?php
error_reporting(E_ALL); 
ini_set('display_errors', true);
?>
<!DOCTYPE html>
<html lang="de">
<head>
    <title>Ip sperren für pages</title>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
<style>
*{
margin:0;
padding:0;
}

body{
  color: #2c3e50;
  background: #ecf0f1;
  text-align:center;
  font-size:30px;
}
input{
font-size:30px;
padding:5px;
}
h1 {
  text-align: center;
}
#code{
margin-top:100vh;
text-align:left;
font-size:10px;
}
</style>
</head>
<body>
<?php
if(isset($_GET['seite'])){
     die("<style>body{font-size:100px;text-align:center;}</style>Dank für den Besuch auf Seite ".$_GET['seite']."<br><a href='random-ipsperre.php'>Zurück</a>");
}

$timestamp=date('U');
$sperre=60;
$datum_zeit = date("d.m.Y H:i:s");
$ip = $_SERVER["REMOTE_ADDR"];
$speicherort = "beispiel.txt"; //Speicherort der .csv Datei
$daten = array(); 
      if (file_exists($speicherort)){      
          $daten = file($speicherort, FILE_IGNORE_NEW_LINES);
          foreach ($daten as $value){
              $datensave = explode(";", $value);
              $iptxt=$datensave[0];
              $timestamptxt=$datensave[2];
              if($iptxt==$ip){
                  $timmerest=$timestamptxt+$sperre;
                  $rest=$timmerest-$timestamp;
                  if($rest>=1){
                       die("Wilkommen zurück .Sie haben in <span id='back'>$rest</span> Sekunden wieder zugang
                       <script>
                            runter($rest);
                              function runter(s){
                                   if(s<=0){
                                        location.reload();
                                  }else{
                                    setTimeout(function(){
                                          s--;
                                          runter(s);
                                          document.getElementById('back').innerHTML=s;
                                    },1000);
                                 }
                            }
                       </script> ");
                  }
             }
        }
    }else{
        file_put_contents("beispiel.txt", "");
    }
?>
<form name="formsend" method="POST">
<input type="hidden" name="site" value="leer">
<input type="submit" name="letsgo" value="Open Random Page">
</form>
<div id="timer"></div>
<?php 
if(isset($_POST['letsgo'])){
      $pages=['1','2','3','4','5','6','7','8','9','10'];
      $pa=$pages[rand(1,10)];
      $inhalt = "$ip;$pa;$timestamp;$datum_zeit\r\n";
      file_put_contents("beispiel.txt", $inhalt, FILE_APPEND);
      echo "nach ".$pa."";
      echo ' <script>
               runter(10);
               function runter(g){
                    if(g<=0){
                           location.href="random-ipsperre.php?seite='.$pa.'";
                    }else{
                           setTimeout(function(){
                                 g--;
                                 runter(g);
                                document.getElementById("timer").innerHTML="Sie werden weitergeleitet in<br>"+g+" Sekunden <br>";
                          },1000);
                    }
               }
            </script>';
}
?>
<h2>Code dieses Scriptes</h2>
<div id="code">
<?php echo highlight_file('random-ipsperre.php'); ?>
</div>
</body>
</html>


Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0