andre 4 лет назад
Родитель
Сommit
cb93789bbf
2 измененных файлов с 36 добавлено и 1 удалено
  1. 12 0
      action.php
  2. 24 1
      admin.php

+ 12 - 0
action.php

@@ -17,6 +17,18 @@ class action {
         return $list;
     }
 
+    public function addUser($userid,$role,$description) {
+        $dbAction = $this->db->prepare("INSERT IGNORE INTO clients VALUES (?,?,?)");
+        $dbAction->bind_param('sss',$userid,$role,$description);
+        return $dbAction->execute();
+    }
+
+    public function delUser($userid) {
+        $dbAction = $this->db->prepare("DELETE FROM clients WHERE token = (?)");
+        $dbAction->bind_param('s',$userid);
+        return $dbAction->execute();
+    }
+
     public function getWhiteList() {
         $list = array();
         $dbAction = $this->db->prepare("SELECT ip FROM whitelist ORDER BY ip ASC");

+ 24 - 1
admin.php

@@ -26,6 +26,15 @@ if(isset($_GET['token'])) {
 if(isset($_GET['action'])) {
     $action = substr(trim($_GET['action']),0,12);
 }
+if(isset($_GET['userid'])) {
+    $userid = substr(trim($_GET['id']),0,25);
+}
+if(isset($_GET['role'])) {
+    $role = substr(trim($_GET['role']),0,8);
+}
+if(isset($_GET['description'])) {
+    $description = substr(trim($_GET['description']),0,25);
+}
 $stats = true;
 
 if (!(new token)->isAdmin($token)) {
@@ -36,6 +45,20 @@ if($stats == true) {
     (new stats)->log($ip,$action,$token);
 }
 switch($action) {
+    case 'deluser':
+        if((new action)->delUser($id)){
+            echo " user removed " . $id ."\n";
+        } else {
+            echo " fehler\n";
+        };
+        break;
+    case 'adduser':
+        if((new action)->addUser($id,$role,$description)){
+            echo " user added " . $id . " role " . "\n";
+        } else {
+            echo " fehler\n";
+        };
+        break;
     case 'blacklist':
         if((new action)->blackList($ip)){
             echo " blacklisted " . long2ip($ip) ."\n";
@@ -95,7 +118,7 @@ foreach($userlist as $user) {
     <input type="hidden" id="token" name="token" value="<?php echo $token; ?>">
     <input type="hidden" id="action" name="action" value="adduser">
     <td>
-        <input type='text' id='id' name='id'>
+        <input type='text' id='userid' name='userid'>
     </td><td>
         <input type='radio' id='reporter' name='role' value='Reporter'>Reporter
         <input type='radio' id='consumer' name='role' value='Consumer'>Consumer