From 6720423e164e5419b59cfb068ebce7a68158fc0e Mon Sep 17 00:00:00 2001 From: Jonathan Flueren Date: Sun, 13 Aug 2023 19:51:44 +0200 Subject: [PATCH] Separate scanner and website, begin with front-end for identity input --- public/index.php | 48 ---------- public/present.json | 1 - identities.yaml => scanner/identities.yaml | 0 scan.sh => scanner/scan.sh | 0 upload.py => scanner/upload.py | 0 wifi_map.yaml => scanner/wifi_map.yaml | 0 .../bootstrap/css/bootstrap.min.css | 0 .../bootstrap/css/bootstrap.min.css.map | 0 .../bootstrap/js/bootstrap.bundle.min.js | 0 .../bootstrap/js/bootstrap.bundle.min.js.map | 0 website/config.php | 0 website/identities.json | 1 + website/index.php | 89 +++++++++++++++++++ website/present.json | 1 + {public => website}/update.php | 0 15 files changed, 91 insertions(+), 49 deletions(-) delete mode 100644 public/index.php delete mode 100644 public/present.json rename identities.yaml => scanner/identities.yaml (100%) rename scan.sh => scanner/scan.sh (100%) rename upload.py => scanner/upload.py (100%) rename wifi_map.yaml => scanner/wifi_map.yaml (100%) rename {public => website}/bootstrap/css/bootstrap.min.css (100%) rename {public => website}/bootstrap/css/bootstrap.min.css.map (100%) rename {public => website}/bootstrap/js/bootstrap.bundle.min.js (100%) rename {public => website}/bootstrap/js/bootstrap.bundle.min.js.map (100%) create mode 100644 website/config.php create mode 100644 website/identities.json create mode 100644 website/index.php create mode 100644 website/present.json rename {public => website}/update.php (100%) diff --git a/public/index.php b/public/index.php deleted file mode 100644 index f82c181..0000000 --- a/public/index.php +++ /dev/null @@ -1,48 +0,0 @@ -setTimestamp($present["timestamp"]); - -?> - - - - - <?php echo $page_title; ?> - - - - - - - -
-

Jetzt gerade im CZI (letztes Update von format('H:i:s d.m.Y'); ?>)


- - - - - - - - - - - - -
NameMAC
-
- - \ No newline at end of file diff --git a/public/present.json b/public/present.json deleted file mode 100644 index 1825229..0000000 --- a/public/present.json +++ /dev/null @@ -1 +0,0 @@ -{"timestamp":1691853251,"identities":[{"mac":"ff:ff:ff:ff:ff:ff","name":"BROADCAST"}]} \ No newline at end of file diff --git a/identities.yaml b/scanner/identities.yaml similarity index 100% rename from identities.yaml rename to scanner/identities.yaml diff --git a/scan.sh b/scanner/scan.sh similarity index 100% rename from scan.sh rename to scanner/scan.sh diff --git a/upload.py b/scanner/upload.py similarity index 100% rename from upload.py rename to scanner/upload.py diff --git a/wifi_map.yaml b/scanner/wifi_map.yaml similarity index 100% rename from wifi_map.yaml rename to scanner/wifi_map.yaml diff --git a/public/bootstrap/css/bootstrap.min.css b/website/bootstrap/css/bootstrap.min.css similarity index 100% rename from public/bootstrap/css/bootstrap.min.css rename to website/bootstrap/css/bootstrap.min.css diff --git a/public/bootstrap/css/bootstrap.min.css.map b/website/bootstrap/css/bootstrap.min.css.map similarity index 100% rename from public/bootstrap/css/bootstrap.min.css.map rename to website/bootstrap/css/bootstrap.min.css.map diff --git a/public/bootstrap/js/bootstrap.bundle.min.js b/website/bootstrap/js/bootstrap.bundle.min.js similarity index 100% rename from public/bootstrap/js/bootstrap.bundle.min.js rename to website/bootstrap/js/bootstrap.bundle.min.js diff --git a/public/bootstrap/js/bootstrap.bundle.min.js.map b/website/bootstrap/js/bootstrap.bundle.min.js.map similarity index 100% rename from public/bootstrap/js/bootstrap.bundle.min.js.map rename to website/bootstrap/js/bootstrap.bundle.min.js.map diff --git a/website/config.php b/website/config.php new file mode 100644 index 0000000..e69de29 diff --git a/website/identities.json b/website/identities.json new file mode 100644 index 0000000..0637a08 --- /dev/null +++ b/website/identities.json @@ -0,0 +1 @@ +[] \ No newline at end of file diff --git a/website/index.php b/website/index.php new file mode 100644 index 0000000..4fccccc --- /dev/null +++ b/website/index.php @@ -0,0 +1,89 @@ +setTimestamp($present["timestamp"]); + +if ($_SERVER['REQUEST_METHOD'] == "POST") { + if ( + preg_match($name_pattern, $_POST['name']) != 1 || + preg_match($mac_pattern, $_POST['mac'] != 1) + ) { + http_response_code(400); + die("Bad data"); + } + + $name = $_POST['name']; + $normalized_mac = str_replace('-', ':', strtolower($_POST['mac'])); + $hashed_mac = hash('sha256', $normalized_mac); + + $identities = json_decode(file_get_contents($identities_file), true); + + foreach ($identities as $identity) { + if ( + $identity['name'] == $name || + $identity['mac_hash'] == $hashed_mac + ) { + // TODO show error to user + die("Duplicate data"); + } + } + + // TODO store new identity + + header("Location: /", true, 303); + exit(); +} +?> + + + + <?php echo $page_title; ?> + + + + + + + +
+

Jetzt gerade im CZI (letztes Update von format('H:i:s d.m.Y'); ?>)


+ + + + + + + + + + + +
Name
+


+
+
+
Neues Gerät tracken
+
+
+
+ +
+
+ + \ No newline at end of file diff --git a/website/present.json b/website/present.json new file mode 100644 index 0000000..a2e023a --- /dev/null +++ b/website/present.json @@ -0,0 +1 @@ +{"timestamp":1691853251,"names":["BROADCAST"]} \ No newline at end of file diff --git a/public/update.php b/website/update.php similarity index 100% rename from public/update.php rename to website/update.php