< >

ipsperre2.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;
}
dialog{
width:500px;
height:300px;
position:fixed;
z-index:600;
top:200px;
left:calc(50% - 250px);
}
#backdrop{
display:none;
z-index:502;
height:100vh;
width:100vw;
position:fixed;
top:0;
left:0;
background:rgba(0,0,0,0.6);
}
</style>
</head>
<body>
<div id="backdrop"></div>
<?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='ipsperre2.php'>Zurück</a>");
}
$timestamp=date('U');
$sperre=22;
$datum_zeit = date("d.m.Y H:i:s");
$ip = $_SERVER["REMOTE_ADDR"];
$speicherort = "beispiel.txt"; 
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);
      ?>
      <dialog id="favDialog">
         <form method="dialog">
            <section>
                  <div id="timer"></div>
                  <span> Auf Seite :<?php echo $pa; ?></span>
            </section>
            <menu>
                 <button id="cancel" type="reset">Cancel</button>
            </menu>
         </form>
      </dialog> 
<script>
(function() {
     var favDialog = document.getElementById("favDialog");
     document.getElementById("backdrop").style.display='block';
     favDialog.showModal();
     g=10;
     timer=setInterval(function(){
         g--;
         document.getElementById("timer").innerHTML="Sie werden weitergeleitet in<br>"+g+" Sekunden <br>";
         if(g<=0){
            clearInterval(timer);
            location.href="ipsperre2.php?seite=<?php echo $pa; ?>";
         } 
     },1000);
     var cancelButton = document.getElementById('cancel');
     cancelButton.addEventListener('click', function() {
         favDialog.close();
              document.getElementById("backdrop").style.display='none';
         location.href='ipsperre2.php';
     });
})();
</script>
<?php
}else{
$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 action="ipsperre2.php" name="formsend" method="POST">
<input type="hidden" name="site" value="leer">
<input type="submit" id="updateDetails" name="letsgo" value="Open Random Page">
</form>
<h2>Code dieses Scriptes</h2>
<div id="code">
<?php echo highlight_file('ipsperre2.php'); ?>
</div>
</body>
</html>

Add Comment

* Required information
1000
Powered by Commentics

Comments (1)

Gravatar
Admin
Sascha65says...

Die Canvas Balken Uhr ist ja mal Fett