Parcourir la source

add protection

andre il y a 4 ans
Parent
commit
ebbe087278
2 fichiers modifiés avec 32 ajouts et 1 suppressions
  1. 13 1
      action.php
  2. 19 0
      admin.php

+ 13 - 1
action.php

@@ -22,6 +22,18 @@ class action {
         return true;
     }
 
+    public function getBlockedClients() {
+        $list = array();
+        $dbAction = $this->db->prepare("SELECT ip FROM blocklist WHERE count > 3 ORDER BY ip ASC");
+        $dbAction->execute();
+        $dbAction->store_result();
+        $dbAction->bind_result($ip);
+        while($dbAction->fetch()) {
+            array_push($list,$ip);
+        };
+        return $list;
+    }
+
     public function getUser() {
         $list = array();
         $dbAction = $this->db->prepare("SELECT token, role, description FROM clients ORDER BY role ASC");
@@ -93,7 +105,7 @@ class action {
         };
         return $list;
     }
-
+    
     private function isListed($ip) {
         $dbAction = $this->db->prepare("SELECT ip FROM list WHERE ip = ?");
         $dbAction->bind_param('i',$ip);

+ 19 - 0
admin.php

@@ -160,6 +160,25 @@ foreach($blacklist as $blip) {
     </form>
     </td></tr>
 </table>
+<h3>Clientblocklist</h3>
+<table>
+<?php
+$blacklist = $act->getBlockedClients();
+foreach($blacklist as $blip) {
+    echo "<tr><td>" . long2ip($blip) . "</td><td><input type='button' id='deblocklist' value='remove' onclick='window.location.href=\"admin.php?token=" . $token . "&action=deblocklist&ip=" . long2ip($blip) . "\"'></td></tr>";
+}
+?>
+<tr>
+    <form action="admin.php">
+    <input type="hidden" id="token" name="token" value="<?php echo $token; ?>">
+    <input type="hidden" id="action" name="action" value="blocklist">
+    <td>
+        <input type='text' id='ip' name='ip'>
+    </td><td>
+        <input type='submit' value='add to blocklist'>
+    </form>
+    </td></tr>
+</table>
 <h3>Whitelist</h3>
 <table border="0">
 <?php