From 15b264ded2e417f8b14b55796c2062cce0fcafd0 Mon Sep 17 00:00:00 2001 From: Kilian Hofmann Date: Fri, 21 Jun 2024 13:51:15 +0200 Subject: [PATCH] Start on HW --- homework/2/counterDB/counter.php | 21 +++++++++++++++++++++ homework/2/counterDB/impl/.htaccess | 3 +++ homework/2/counterDB/impl/functions.php | 20 ++++++++++++++++++++ homework/2/counterDB/impl/queries.php | 16 ++++++++++++++++ homework/2/counterDB/index.php | 21 +++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 homework/2/counterDB/counter.php create mode 100644 homework/2/counterDB/impl/.htaccess create mode 100644 homework/2/counterDB/impl/functions.php create mode 100644 homework/2/counterDB/impl/queries.php create mode 100644 homework/2/counterDB/index.php diff --git a/homework/2/counterDB/counter.php b/homework/2/counterDB/counter.php new file mode 100644 index 0000000..bf690ec --- /dev/null +++ b/homework/2/counterDB/counter.php @@ -0,0 +1,21 @@ + +
+ Visitor count: +
\ No newline at end of file diff --git a/homework/2/counterDB/impl/.htaccess b/homework/2/counterDB/impl/.htaccess new file mode 100644 index 0000000..872a3ce --- /dev/null +++ b/homework/2/counterDB/impl/.htaccess @@ -0,0 +1,3 @@ +Order deny,allow +Deny from all +Allow from 127.0.0.1 \ No newline at end of file diff --git a/homework/2/counterDB/impl/functions.php b/homework/2/counterDB/impl/functions.php new file mode 100644 index 0000000..00c0f57 --- /dev/null +++ b/homework/2/counterDB/impl/functions.php @@ -0,0 +1,20 @@ +prepare($getHitsQuery); + $stmt->bindValue(":SID", $id); + $stmt->execute(); + $hits = $stmt->fetch(PDO::FETCH_COLUMN); + return $hits !== false ? $hits : 0; +} + +function addHit($id, $db) +{ + global $setHitsQuery; + $stmt = $db->prepare($setHitsQuery); + $stmt->bindValue(":SID", $id); + $stmt->execute(); +} diff --git a/homework/2/counterDB/impl/queries.php b/homework/2/counterDB/impl/queries.php new file mode 100644 index 0000000..a0b609e --- /dev/null +++ b/homework/2/counterDB/impl/queries.php @@ -0,0 +1,16 @@ + + + + + + + Counter DB Tester + + + + + This is a dummy test for the database Counter + + + + + \ No newline at end of file