diff --git a/website/index.php b/website/index.php index 84110f8..d4576bb 100644 --- a/website/index.php +++ b/website/index.php @@ -39,12 +39,12 @@ function add_identity($name, $mac) $url = strtok($_SERVER['REQUEST_URI'], '?'); foreach ($identities as $identity) { - if ($identity['name'] == $name) { - $_SESSION['form_success'] = false; - $_SESSION['form_success_message'] = 'Name already in use, please choose a different one.'; - header("Location: " . $url, true, 303); - exit(); - } + //if ($identity['name'] == $name) { + // $_SESSION['form_success'] = false; + // $_SESSION['form_success_message'] = 'Name already in use, please choose a different one.'; + // header("Location: " . $url, true, 303); + // exit(); + //} if ($identity['mac_hash'] == $hashed_mac) { $_SESSION['form_success'] = false; $_SESSION['form_success_message'] = 'MAC already set up, please remove it first to change name.'; @@ -62,15 +62,13 @@ function add_identity($name, $mac) exit(); } -function remove_identity($mac) +function remove_identity($name) { - if (preg_match('/' . MAC_PATTERN . '/', $mac) != 1) { + if (preg_match('/' . NAME_PATTERN . '/', $name) != 1) { http_response_code(400); die("Bad data"); } - $hashed_mac = hash_mac($mac); - $url = strtok($_SERVER['REQUEST_URI'], '?'); $identities = json_decode(file_get_contents(IDENTITIES_FILE), true); @@ -78,7 +76,7 @@ function remove_identity($mac) $new_identities = array(); foreach ($identities as $identity) { - if ($identity['mac_hash'] != $hashed_mac) { + if ($identity['name'] != $name) { array_push($new_identities, $identity); } } @@ -101,8 +99,8 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { isset($_POST['mac']) ) { add_identity($_POST['name'], $_POST['mac']); - } else if (isset($_POST['remove-mac'])) { - remove_identity($_POST['remove-mac']); + } else if (isset($_POST['remove-name'])) { + remove_identity($_POST['remove-name']); } } ?> @@ -176,7 +174,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") {
Gerät entfernen
-
+