diff --git a/admin/categories.php b/admin/categories.php
new file mode 100644
index 0000000..7c3bfe8
--- /dev/null
+++ b/admin/categories.php
@@ -0,0 +1,472 @@
+prepare("SELECT * FROM categories ORDER BY Ordering $sort");
+
+ $stmt2->execute();
+
+ $cats = $stmt2->fetchAll();
+
+ if (! empty($cats)) {
+
+ ?>
+
+
Manage Categories
+
+
+
+
Manage Categories
+
+
Ordering: [
+
Asc |
+
Desc ]
+
View: [
+
Full |
+
Classic ]
+
+
+
+ ";
+ echo "
";
+ echo "
" . $cat['Name'] . '
';
+ echo "
";
+ echo "
"; if($cat['Description'] == '') { echo 'This category has no description'; } else { echo $cat['Description']; } echo "
";
+ if($cat['Visibility'] == 1) { echo '
Hidden'; }
+ if($cat['Allow_Comment'] == 1) { echo ''; }
+ if($cat['Allow_Ads'] == 1) { echo '
Ads Disabled'; }
+ echo "
";
+ echo "
";
+ echo "
";
+ }
+ ?>
+
+
+ Add New Category
+
+
+ ';
+ echo 'There\'s No Categories To Show
';
+ echo '
+ New Category
+ ';
+ echo '';
+
+ } ?>
+
+
+
+ Add New Category
+
+
+ Insert Category";
+ echo "";
+
+ // Get Variables From The Form
+
+ $name = $_POST['name'];
+ $desc = $_POST['description'];
+ $order = $_POST['ordering'];
+ $visible = $_POST['visibility'];
+ $comment = $_POST['commenting'];
+ $ads = $_POST['ads'];
+
+ // Check If Category Exist in Database
+
+ $check = checkItem("Name", "categories", $name);
+
+ if ($check == 1) {
+
+ $theMsg = '
Sorry This Category Is Exist
';
+
+ redirectHome($theMsg, 'back');
+
+ } else {
+
+ // Insert Category Info In Database
+
+ $stmt = $con->prepare("INSERT INTO
+
+ categories(Name, Description, Ordering, Visibility, Allow_Comment, Allow_Ads)
+
+ VALUES(:zname, :zdesc, :zorder, :zvisible, :zcomment, :zads)");
+
+ $stmt->execute(array(
+ 'zname' => $name,
+ 'zdesc' => $desc,
+ 'zorder' => $order,
+ 'zvisible' => $visible,
+ 'zcomment' => $comment,
+ 'zads' => $ads
+ ));
+
+ // Echo Success Message
+
+ $theMsg = "
" . $stmt->rowCount() . ' Record Inserted
';
+
+ redirectHome($theMsg, 'back');
+
+ }
+
+ } else {
+
+ echo "
";
+
+ $theMsg = '
Sorry You Cant Browse This Page Directly
';
+
+ redirectHome($theMsg, 'back');
+
+ echo "
";
+
+ }
+
+ echo "
";
+
+ } elseif ($do == 'Edit') {
+
+ // Check If Get Request catid Is Numeric & Get Its Integer Value
+
+ $catid = isset($_GET['catid']) && is_numeric($_GET['catid']) ? intval($_GET['catid']) : 0;
+
+ // Select All Data Depend On This ID
+
+ $stmt = $con->prepare("SELECT * FROM categories WHERE ID = ?");
+
+ // Execute Query
+
+ $stmt->execute(array($catid));
+
+ // Fetch The Data
+
+ $cat = $stmt->fetch();
+
+ // The Row Count
+
+ $count = $stmt->rowCount();
+
+ // If There's Such ID Show The Form
+
+ if ($count > 0) { ?>
+
+ Edit Category
+
+
+ ";
+
+ $theMsg = 'Theres No Such ID
';
+
+ redirectHome($theMsg);
+
+ echo "";
+
+ }
+
+ } elseif ($do == 'Update') {
+
+ echo "Update Category
";
+ echo "";
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+
+ // Get Variables From The Form
+
+ $id = $_POST['catid'];
+ $name = $_POST['name'];
+ $desc = $_POST['description'];
+ $order = $_POST['ordering'];
+
+ $visible = $_POST['visibility'];
+ $comment = $_POST['commenting'];
+ $ads = $_POST['ads'];
+
+ // Update The Database With This Info
+
+ $stmt = $con->prepare("UPDATE
+ categories
+ SET
+ Name = ?,
+ Description = ?,
+ Ordering = ?,
+ Visibility = ?,
+ Allow_Comment = ?,
+ Allow_Ads = ?
+ WHERE
+ ID = ?");
+
+ $stmt->execute(array($name, $desc, $order, $visible, $comment, $ads, $id));
+
+ // Echo Success Message
+
+ $theMsg = "
" . $stmt->rowCount() . ' Record Updated
';
+
+ redirectHome($theMsg, 'back');
+
+ } else {
+
+ $theMsg = '
Sorry You Cant Browse This Page Directly
';
+
+ redirectHome($theMsg);
+
+ }
+
+ echo "
";
+
+ } elseif ($do == 'Delete') {
+
+ echo "Delete Category
";
+ echo "";
+
+ // Check If Get Request Catid Is Numeric & Get The Integer Value Of It
+
+ $catid = isset($_GET['catid']) && is_numeric($_GET['catid']) ? intval($_GET['catid']) : 0;
+
+ // Select All Data Depend On This ID
+
+ $check = checkItem('ID', 'categories', $catid);
+
+ // If There's Such ID Show The Form
+
+ if ($check > 0) {
+
+ $stmt = $con->prepare("DELETE FROM categories WHERE ID = :zid");
+
+ $stmt->bindParam(":zid", $catid);
+
+ $stmt->execute();
+
+ $theMsg = "
" . $stmt->rowCount() . ' Record Deleted
';
+
+ redirectHome($theMsg, 'back');
+
+ } else {
+
+ $theMsg = '
This ID is Not Exist
';
+
+ redirectHome($theMsg);
+
+ }
+
+ echo '
';
+
+ }
+
+ include $tpl . 'footer.php';
+
+ } else {
+
+ header('Location: index.php');
+
+ exit();
+ }
+
+ ob_end_flush(); // Release The Output
+
+?>
\ No newline at end of file
diff --git a/admin/comments.php b/admin/comments.php
new file mode 100644
index 0000000..2f352c4
--- /dev/null
+++ b/admin/comments.php
@@ -0,0 +1,287 @@
+prepare("SELECT
+ comments.*, items.Name AS Item_Name, users.Username AS Member
+ FROM
+ comments
+ INNER JOIN
+ items
+ ON
+ items.Item_ID = comments.item_id
+ INNER JOIN
+ users
+ ON
+ users.UserID = comments.user_id
+ ORDER BY
+ c_id DESC");
+
+ // Execute The Statement
+
+ $stmt->execute();
+
+ // Assign To Variable
+
+ $comments = $stmt->fetchAll();
+
+ if (! empty($comments)) {
+
+ ?>
+
+ Manage Comments
+
+
+
+
+ ID |
+ Comment |
+ Item Name |
+ User Name |
+ Added Date |
+ Control |
+
+ ";
+ echo "" . $comment['c_id'] . " | ";
+ echo "" . $comment['comment'] . " | ";
+ echo "" . $comment['Item_Name'] . " | ";
+ echo "" . $comment['Member'] . " | ";
+ echo "" . $comment['comment_date'] ." | ";
+ echo "
+ Edit
+ Delete ";
+ if ($comment['status'] == 0) {
+ echo "
+ Approve";
+ }
+ echo " | ";
+ echo "";
+ }
+ ?>
+
+
+
+
+
+ ';
+ echo 'There\'s No Comments To Show
';
+ echo '';
+
+ } ?>
+
+ prepare("SELECT * FROM comments WHERE c_id = ?");
+
+ // Execute Query
+
+ $stmt->execute(array($comid));
+
+ // Fetch The Data
+
+ $row = $stmt->fetch();
+
+ // The Row Count
+
+ $count = $stmt->rowCount();
+
+ // If There's Such ID Show The Form
+
+ if ($count > 0) { ?>
+
+ Edit Comment
+
+
+ ";
+
+ $theMsg = 'Theres No Such ID
';
+
+ redirectHome($theMsg);
+
+ echo "";
+
+ }
+
+ } elseif ($do == 'Update') { // Update Page
+
+ echo "Update Comment
";
+ echo "";
+
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+
+ // Get Variables From The Form
+
+ $comid = $_POST['comid'];
+ $comment = $_POST['comment'];
+
+ // Update The Database With This Info
+
+ $stmt = $con->prepare("UPDATE comments SET comment = ? WHERE c_id = ?");
+
+ $stmt->execute(array($comment, $comid));
+
+ // Echo Success Message
+
+ $theMsg = "
" . $stmt->rowCount() . ' Record Updated
';
+
+ redirectHome($theMsg, 'back');
+
+ } else {
+
+ $theMsg = '
Sorry You Cant Browse This Page Directly
';
+
+ redirectHome($theMsg);
+
+ }
+
+ echo "
";
+
+ } elseif ($do == 'Delete') { // Delete Page
+
+ echo "Delete Comment
";
+
+ echo "";
+
+ // Check If Get Request comid Is Numeric & Get The Integer Value Of It
+
+ $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0;
+
+ // Select All Data Depend On This ID
+
+ $check = checkItem('c_id', 'comments', $comid);
+
+ // If There's Such ID Show The Form
+
+ if ($check > 0) {
+
+ $stmt = $con->prepare("DELETE FROM comments WHERE c_id = :zid");
+
+ $stmt->bindParam(":zid", $comid);
+
+ $stmt->execute();
+
+ $theMsg = "
" . $stmt->rowCount() . ' Record Deleted
';
+
+ redirectHome($theMsg, 'back');
+
+ } else {
+
+ $theMsg = '
This ID is Not Exist
';
+
+ redirectHome($theMsg);
+
+ }
+
+ echo '
';
+
+ } elseif ($do == 'Approve') {
+
+ echo "Approve Comment
";
+ echo "";
+
+ // Check If Get Request comid Is Numeric & Get The Integer Value Of It
+
+ $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0;
+
+ // Select All Data Depend On This ID
+
+ $check = checkItem('c_id', 'comments', $comid);
+
+ // If There's Such ID Show The Form
+
+ if ($check > 0) {
+
+ $stmt = $con->prepare("UPDATE comments SET status = 1 WHERE c_id = ?");
+
+ $stmt->execute(array($comid));
+
+ $theMsg = "
" . $stmt->rowCount() . ' Record Approved
';
+
+ redirectHome($theMsg, 'back');
+
+ } else {
+
+ $theMsg = '
This ID is Not Exist
';
+
+ redirectHome($theMsg);
+
+ }
+
+ echo '
';
+
+ }
+
+ include $tpl . 'footer.php';
+
+ } else {
+
+ header('Location: index.php');
+
+ exit();
+ }
+
+ ob_end_flush(); // Release The Output
+
+?>
\ No newline at end of file
diff --git a/admin/connect.php b/admin/connect.php
new file mode 100644
index 0000000..9c642a7
--- /dev/null
+++ b/admin/connect.php
@@ -0,0 +1,17 @@
+ 'SET NAMES utf8',
+ );
+
+ try {
+ $con = new PDO($dsn, $user, $pass, $option);
+ $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ }
+
+ catch(PDOException $e) {
+ echo 'Failed To Connect' . $e->getMessage();
+ }
\ No newline at end of file
diff --git a/admin/copy_template.php b/admin/copy_template.php
new file mode 100644
index 0000000..3a4f404
--- /dev/null
+++ b/admin/copy_template.php
@@ -0,0 +1,55 @@
+
\ No newline at end of file
diff --git a/admin/dashboard.php b/admin/dashboard.php
new file mode 100644
index 0000000..043176c
--- /dev/null
+++ b/admin/dashboard.php
@@ -0,0 +1,222 @@
+
+
+
+
+
Dashboard
+
+
+
+
+
+
+ Pending Members
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Latest Registerd Users
+
+
+
+
+
+
+
+
+
+
+ Latest Items
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Latest Comments
+
+
+
+
+
+ prepare("SELECT
+ comments.*, users.Username AS Member
+ FROM
+ comments
+ INNER JOIN
+ users
+ ON
+ users.UserID = comments.user_id
+ ORDER BY
+ c_id DESC
+ LIMIT $numComments");
+
+ $stmt->execute();
+ $comments = $stmt->fetchAll();
+
+ if (! empty($comments)) {
+ foreach ($comments as $comment) {
+ echo '';
+ }
+ } else {
+ echo 'There\'s No Comments To Show';
+ }
+ ?>
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/admin/includes/functions/functions.php b/admin/includes/functions/functions.php
new file mode 100644
index 0000000..8aa9f39
--- /dev/null
+++ b/admin/includes/functions/functions.php
@@ -0,0 +1,130 @@
+You Will Be Redirected to $link After $seconds Seconds.";
+
+ header("refresh:$seconds;url=$url");
+
+ exit();
+
+ }
+
+ /*
+ ** Check Items Function v1.0
+ ** Function to Check Item In Database [ Function Accept Parameters ]
+ ** $select = The Item To Select [ Example: user, item, category ]
+ ** $from = The Table To Select From [ Example: users, items, categories ]
+ ** $value = The Value Of Select [ Example: Osama, Box, Electronics ]
+ */
+
+ function checkItem($select, $from, $value) {
+
+ global $con;
+
+ $statement = $con->prepare("SELECT $select FROM $from WHERE $select = ?");
+
+ $statement->execute(array($value));
+
+ $count = $statement->rowCount();
+
+ return $count;
+
+ }
+
+ /*
+ ** Count Number Of Items Function v1.0
+ ** Function To Count Number Of Items Rows
+ ** $item = The Item To Count
+ ** $table = The Table To Choose From
+ */
+
+ function countItems($item, $table) {
+
+ global $con;
+
+ $stmt2 = $con->prepare("SELECT COUNT($item) FROM $table");
+
+ $stmt2->execute();
+
+ return $stmt2->fetchColumn();
+
+ }
+
+ /*
+ ** Get Latest Records Function v1.0
+ ** Function To Get Latest Items From Database [ Users, Items, Comments ]
+ ** $select = Field To Select
+ ** $table = The Table To Choose From
+ ** $order = The Desc Ordering
+ ** $limit = Number Of Records To Get
+ */
+
+ function getLatest($select, $table, $order, $limit = 5) {
+
+ global $con;
+
+ $getStmt = $con->prepare("SELECT $select FROM $table ORDER BY $order DESC LIMIT $limit");
+
+ $getStmt->execute();
+
+ $rows = $getStmt->fetchAll();
+
+ return $rows;
+
+ }
\ No newline at end of file
diff --git a/admin/includes/languages/arabic.php b/admin/includes/languages/arabic.php
new file mode 100644
index 0000000..e69de29
diff --git a/admin/includes/languages/english.php b/admin/includes/languages/english.php
new file mode 100644
index 0000000..281d3c4
--- /dev/null
+++ b/admin/includes/languages/english.php
@@ -0,0 +1,25 @@
+ 'Home',
+ 'CATEGORIES' => 'Categories',
+ 'ITEMS' => 'Items',
+ 'MEMBERS' => 'Members',
+ 'COMMENTS' => 'Comments',
+ 'STATISTICS' => 'Statistics',
+ 'LOGS' => 'Logs',
+ '' => '',
+ '' => '',
+ '' => '',
+ '' => '',
+ '' => ''
+ );
+
+ return $lang[$phrase];
+
+ }
diff --git a/admin/includes/templates/footer.php b/admin/includes/templates/footer.php
new file mode 100644
index 0000000..c566d05
--- /dev/null
+++ b/admin/includes/templates/footer.php
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
' . $comment['comment'] . '
'; + echo '