';
- }
- }
- }
-}
-
-include 'footer.php';
-?>
diff --git a/php forum/connect.php b/php forum/connect.php
deleted file mode 100644
index cabe808..0000000
--- a/php forum/connect.php
+++ /dev/null
@@ -1,15 +0,0 @@
-connect_error) {
- die("Connection failed: " . $conn->connect_error);
-}
-?>
diff --git a/php forum/create_cat.php b/php forum/create_cat.php
deleted file mode 100644
index 6c2634e..0000000
--- a/php forum/create_cat.php
+++ /dev/null
@@ -1,48 +0,0 @@
-Create a category';
-if($_SESSION['signedIn'] == false | $_SESSION['userLevel'] != 1 )
-{
- //the user is not an admin
- echo 'Sorry, you do not have sufficient rights to access this page.';
-}
-else
-{
- //the user has admin rights
- if($_SERVER['REQUEST_METHOD'] != 'POST')
- {
- //the form hasn't been posted yet, display it
- echo '';
- }
- else
- {
- //the form has been posted, so save it
- $sql = "INSERT INTO categories(catName, catDescr)
- VALUES(?, ?)";
-
- $stmt = $conn->prepare($sql);
- $stmt->bind_param('ss', $_POST['catName'], $_POST['catDescr']);
-
- if(!$stmt->execute())
- {
- //something went wrong, display the error
- echo 'Error' . $conn->error;
- }
- else
- {
- echo 'New category succesfully added. Go Home.';
- }
- }
-}
-
-include 'footer.php';
-?>
diff --git a/php forum/create_topic.php b/php forum/create_topic.php
deleted file mode 100644
index 6d67992..0000000
--- a/php forum/create_topic.php
+++ /dev/null
@@ -1,127 +0,0 @@
-Create a topic';
-if($_SESSION['signedIn'] == false)
-{
- //the user is not signed in
- echo 'Sorry, you have to be signed in to create a topic.';
-}
-else
-{
- //the user is signed in
- if($_SERVER['REQUEST_METHOD'] != 'POST')
- {
- //the form hasn't been posted yet, display it
- //retrieve the categories from the database for use in the dropdown
- $sql = "SELECT catNo, catName, catDescr
- FROM categories";
-
- $result = $conn->query($sql);
-
- if(!$result)
- {
- //the query failed, uh-oh :-(
- echo 'Error while selecting from database. Please try again later.';
- }
- else
- {
- if($result->num_rows == 0)
- {
- //there are no categories, so a topic can't be posted
- if($_SESSION['userLevel'] == 1)
- {
- echo 'You have not created categories yet.';
- }
- else
- {
- echo 'Before you can post a topic, you must wait for an admin to create some categories.';
- }
- }
- else
- {
-
- echo '';
- }
- }
- }
- else
- {
- //start the transaction
- $query = "BEGIN WORK;";
-
- if(!$conn->query($query))
- {
- //Damn! the query failed, quit
- echo 'An error occured while creating your topic. Please try again later.';
- }
- else
- {
-
- //the form has been posted, so save it
- //insert the topic into the topics table first, then we'll save the post into the posts table
- $sql = "INSERT INTO topics(topicSubject, topicDate, topicCat, topicBy)
- VALUES(?, NOW(), ?, ?)";
-
- $stmt = $conn->prepare($sql);
- $stmt->bind_param('sii', $_POST['topicSubject'], $_POST['topicCat'], $_SESSION['userNo']);
-
- if(!$stmt->execute())
- {
- //something went wrong, display the error
- echo 'An error occured while inserting your data. Please try again later.
' . $conn->error;
- $sql = "ROLLBACK;";
- $conn->query($sql);
- }
- else
- {
-
- //the first query worked, now start the second, posts query
- //retrieve the id of the freshly created topic for usage in the posts query
- $topicid = $conn->insert_id;
-
- $sql = "INSERT INTO posts(postContent, postDate, postTopic, postBy)
- VALUES (?, NOW(), ?, ?)";
-
- $stmt = $conn->prepare($sql);
- $stmt->bind_param('sii', $_POST['postContent'], $topicid, $_SESSION['userNo']);
-
- if(!$stmt->execute())
- {
- //something went wrong, display the error
- echo 'An error occured while inserting your post. Please try again later.
' . $conn->error;
- $sql = "ROLLBACK;";
- $conn->query($sql);
- }
- else
- {
- $sql = "COMMIT;";
- $conn->query($sql);
-
- //after a lot of work, the query succeeded!
- echo 'You have succesfully created your new topic.';
- }
- }
- }
- }
-}
-
-include 'footer.php';
-?>
diff --git a/php forum/delete_post.php b/php forum/delete_post.php
deleted file mode 100644
index 0cab905..0000000
--- a/php forum/delete_post.php
+++ /dev/null
@@ -1,92 +0,0 @@
-prepare($post_sql);
-$stmt->bind_param('i', $_GET['post']);
-$stmt->execute();
-$post_result = $stmt->get_result();
-
-if(!$post_result)
-{
- echo 'The post could not be retrieved, please try again later.';
-}
-else
-{
- if($_SERVER['REQUEST_METHOD'] != 'POST')
- {
- if(!$_SESSION['signedIn'])
- {
- echo 'You must be signed in to delete a post. You can also sign up for an account.';
- }
- else if ($_SESSION['userNo'] != $post_result->fetch_assoc()['postBy'])
- {
- echo 'You cannot edit this post. You are not OP!';
- }
- else
- {
-
- echo '
Are you sure you want to remove this post?
';
-
- //show edit form
- echo '
-
- ';
- }
- }
- else
- {
- //the form has been posted, now it's time to process.
- //start the transaction
- $query = "BEGIN WORK;";
-
- if(!$conn->query($query))
- {
- //Damn! the query failed, quit
- echo 'An error occured while editing your post. Please try again later.';
- }
- else
- {
- //the form has been posted, so save it
- //update the post in the posts table then save it
- $update_sql = " UPDATE posts
- SET postContent = ?
- WHERE postNo = ?";
-
- $update_stmt = $conn->prepare($update_sql);
- $update_stmt->bind_param('si', $content, $_GET['post']);
-
- if(!$update_stmt->execute())
- {
- //something went wrong, display the error
- echo 'An error occured while inserting your data. Please try again later.
' . $conn->error;
- $sql = "ROLLBACK;";
- $conn->query($sql);
- }
- else
- {
- $sql = "COMMIT;";
- $conn->query($sql);
-
- //after a lot of work, the query succeeded!
- echo 'You have succesfully removed your post.';
- }
- }
- }
-}
-
-include 'footer.php';
-?>
diff --git a/php forum/edit_post.php b/php forum/edit_post.php
deleted file mode 100644
index 28ebb49..0000000
--- a/php forum/edit_post.php
+++ /dev/null
@@ -1,89 +0,0 @@
-prepare($post_sql);
-$stmt->bind_param('i', $_GET['post']);
-$stmt->execute();
-$post_result = $stmt->get_result();
-
-if(!$post_result)
-{
- echo 'The post could not be retrieved, please try again later.';
-}
-else
-{
- if($_SERVER['REQUEST_METHOD'] != 'POST')
- {
- $post_result = $post_result->fetch_assoc();
-
- if(!$_SESSION['signedIn'])
- {
- echo 'You must be signed in to edit a post. You can also sign up for an account.';
- }
- else if ($_SESSION['userNo'] != $post_result['postBy'])
- {
- echo 'You cannot edit this post. You are not OP!';
- }
- else
- {
- $content = htmlentities(stripslashes($post_result['postContent']));
-
- //show edit form
- echo '
- ';
- }
- }
- else
- {
- //the form has been posted, now it's time to process.
- //start the transaction
- $query = "BEGIN WORK;";
-
- if(!$conn->query($query))
- {
- //Damn! the query failed, quit
- echo 'An error occured while editing your post. Please try again later.';
- }
- else
- {
- //the form has been posted, so save it
- //update the post in the posts table then save it
- $update_sql = " UPDATE posts
- SET postContent = ?
- WHERE postNo = ?";
-
- $update_stmt = $conn->prepare($update_sql);
- $update_stmt->bind_param('si', $_POST['postContent'], $_GET['post']);
-
- if(!$update_stmt->execute())
- {
- //something went wrong, display the error
- echo 'An error occured while inserting your data. Please try again later.