From 00fda2f0dfdaa1129949f0fa116cfaeff23ab486 Mon Sep 17 00:00:00 2001 From: Mateja Date: Mon, 28 Sep 2020 19:14:53 +0200 Subject: first commit --- admin.php | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 admin.php (limited to 'admin.php') diff --git a/admin.php b/admin.php new file mode 100644 index 0000000..2bfdfde --- /dev/null +++ b/admin.php @@ -0,0 +1,105 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +} catch (PDOException $e) { + echo "

Error!: " . $e->getMessage() . "

"; + die(); +} + +# SHOLUD SOMETHING BE APPROVED? +if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['id']) ) { + $stmt = $conn->prepare("UPDATE activities SET approved = true WHERE id=:id"); +echo "lol:" . $_POST['id']; + $stmt->bindParam(':id', $_POST['id']); + $stmt->execute(); +} + +# IS LOGIN LEGITIMATE? +if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST['email']) && isset($_POST['password'])) { + try { + $stmt = $conn->prepare("SELECT * FROM admins WHERE email=:email"); + $stmt->bindParam(':email', $_POST['email']); + $stmt->execute(); + $row = $stmt->fetch(); + if (password_verify($_POST['password'], $row['password'])){ + $_SESSION['admin'] = true; + } else { + $_SESSION['admin'] = false; + } + } catch (PDOException $e) { + echo "

Error!: " . $e->getMessage() . "

"; + } +} +?> + + + + + + + Yota Callplan + + +
YOTA
+ +
+'; + echo "\n"; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo "\n"; + foreach($conn->query("SELECT * FROM activities WHERE approved = false") as $row) { + echo ""; + echo ""; + echo ""; + echo ""; + echo ''; + echo "\n"; + } + echo "
ImePrezimeGodineActions
" . $row['name'] . "" . $row['surname'] . "" . $row['age'] . "
'; + echo ''; + echo ''; + echo '
\n\n"; + } catch (PDOException $e) { + echo "

Error!: " . $e->getMessage() . "

"; + } +} else { + # Bad pass check... + if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_SESSION['admin']) && $_SESSION['admin'] == false) echo "Bad credentials!"; + # Login form + echo '
'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + echo '
'; +} +?> +
+ + -- cgit v1.2.3