From 8192e30810af84d5b9cb756af8834e31842d5bf8 Mon Sep 17 00:00:00 2001 From: Samuel ORTION Date: Tue, 30 Mar 2021 10:52:22 +0200 Subject: [PATCH] Added forum category adding --- public/forum/categories.php | 49 +++++++++++++++++++++++ public/forum/createcategory.php | 62 +++++++++++++++++++++++++++++ public/forum/index.php | 29 ++++++++++++++ public/home/last-uploaded-file.php | 32 +++++++++++++++ public/index.php | 9 +++-- public/styles/style.css | 24 ++++++++++- public/test-file-upload.php | 0 public/upload/submitobservation.php | 2 +- 8 files changed, 202 insertions(+), 5 deletions(-) create mode 100644 public/forum/categories.php create mode 100644 public/forum/createcategory.php create mode 100644 public/forum/index.php create mode 100644 public/home/last-uploaded-file.php delete mode 100644 public/test-file-upload.php diff --git a/public/forum/categories.php b/public/forum/categories.php new file mode 100644 index 0000000..8dc662e --- /dev/null +++ b/public/forum/categories.php @@ -0,0 +1,49 @@ + PDO::ERRMODE_EXCEPTION + )); +}catch (Exception $e){ + die("Error : ".$e->getMessage()); +} +$req = $db->prepare('SELECT * FROM `categories`'); +$req->execute(); +$rows = $req->fetchAll(PDO::FETCH_ASSOC); +?> +

Categories

+ + + + + + + + + + + + + + +
TitleDescription
+

Create a category

+
+ + + + + +
diff --git a/public/forum/createcategory.php b/public/forum/createcategory.php new file mode 100644 index 0000000..8632867 --- /dev/null +++ b/public/forum/createcategory.php @@ -0,0 +1,62 @@ + PDO::ERRMODE_EXCEPTION + )); + }catch (Exception $e){ + die("Error : ".$e->getMessage()); + } + $req = $db->prepare('INSERT INTO `categories` (cat_name, cat_description) VALUES (:cat_name, :cat_description)'); + $req->execute(array( + "cat_name"=>$name, + "cat_description"=>$description + )); +} + +ini_set('display_errors', 1); +ini_set('display_startup_errors', 1); +error_reporting(E_ALL); +session_start(); + +$_SESSION['error_msg'] = ""; +if (isset($_POST['submit'])) +{ + if (isset($_SESSION['username'])) { + if (isset($_POST['title'])) + { + $name = $_POST['title']; + } else + { + $_SESSION['error_msg'] .= "You did not enter a proper category title. \n"; + } + if (isset($_POST['description'])) + { + $description = $_POST['description']; + } else + { + $_SESSION['error_msg'] .= "You did not enter a proper category description. \n"; + } + } else { + $_SESSION['error_msg'] .= "You did not log in.\n"; + header('Location: '."/auth/login/"); + } +} else +{ + $_SESSION['error_msg'] .= "You did not sumit the category creation form.\n"; +} + +if ($_SESSION['error_msg'] == "") +{ + create_category($name, $description); + header('Location: '."/forum"); +} else { + header('Location: '."/auth/login/"); +} +?> \ No newline at end of file diff --git a/public/forum/index.php b/public/forum/index.php new file mode 100644 index 0000000..0912984 --- /dev/null +++ b/public/forum/index.php @@ -0,0 +1,29 @@ + + + + + + + + + Chiro - Canto + + + + + +
+

Forum

+ +
+ + + + \ No newline at end of file diff --git a/public/home/last-uploaded-file.php b/public/home/last-uploaded-file.php new file mode 100644 index 0000000..7e8445f --- /dev/null +++ b/public/home/last-uploaded-file.php @@ -0,0 +1,32 @@ + PDO::ERRMODE_EXCEPTION + )); +} catch (Exception $e) { + die("Error : ".$e->getMessage()); +} + +$req = $db->prepare('SELECT id, recordist_name, file_name, license, species, sound_type, date, time FROM `records` ORDER BY `entry_timestamp` ASC LIMIT 1'); +$req->execute(); +if ($data = $req->fetch()) +{ + ?> +
+

+

+

Recorded on at

+ +

+
+ \ No newline at end of file diff --git a/public/index.php b/public/index.php index ad5c9f3..c5db3f4 100644 --- a/public/index.php +++ b/public/index.php @@ -1,8 +1,10 @@ @@ -19,6 +21,7 @@ session_start();

Last uploaded sound

+
diff --git a/public/styles/style.css b/public/styles/style.css index 22aea58..fc04f87 100644 --- a/public/styles/style.css +++ b/public/styles/style.css @@ -131,7 +131,7 @@ nav { border-bottom: 1px solid black; position: flex; display: block; - width: 100vw; + width: 99vw; background-color: white; z-index: 10; } @@ -208,6 +208,21 @@ p.large { width: auto; } +table { + border-radius: 5px; + width: 100%; + border-collapse: collapse; +} +td, th { + border: 1px solid #dddddd; + text-align: left; + padding: 0.5em; +} + +tr:nth-child(even) { + background-color: #dddddd; +} + #searchbar { display: flex; flex-direction: row; @@ -246,4 +261,11 @@ div.coordinates input[type="text"] { border-radius: 5px; padding: 0.5em; background-color: rgba(255, 0, 0, 0.4) +} + +.sound { + background-color: rgba(0, 255, 0, 0.5); + padding: 1em; + border-radius: 5px; + overflow: auto; } \ No newline at end of file diff --git a/public/test-file-upload.php b/public/test-file-upload.php deleted file mode 100644 index e69de29..0000000 diff --git a/public/upload/submitobservation.php b/public/upload/submitobservation.php index e3cf650..cf10b1f 100644 --- a/public/upload/submitobservation.php +++ b/public/upload/submitobservation.php @@ -14,7 +14,7 @@ try { $password, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION )); -}catch (Exception $e) { +} catch (Exception $e) { die("Error : ".$e->getMessage()); }