├── Database - shop └── shop database - SQL Dump File - phpMyAdmin Export.sql ├── Project Screenshots └── admin-panel-login.jpg ├── README.md ├── admin ├── categories.php ├── comments.php ├── connect.php ├── dashboard.php ├── includes │ ├── functions │ │ └── functions.php │ ├── languages │ │ ├── arabic.php │ │ └── english.php │ └── templates │ │ ├── footer.php │ │ ├── header.php │ │ └── navbar.php ├── index.php ├── init.php ├── items.php ├── layout │ ├── css │ │ ├── backend.css │ │ ├── bootstrap.css │ │ ├── bootstrap.min.css │ │ ├── font-awesome.min.css │ │ ├── images │ │ │ ├── ui-icons_444444_256x240.png │ │ │ ├── ui-icons_555555_256x240.png │ │ │ ├── ui-icons_777620_256x240.png │ │ │ ├── ui-icons_777777_256x240.png │ │ │ ├── ui-icons_cc0000_256x240.png │ │ │ └── ui-icons_ffffff_256x240.png │ │ ├── jquery-ui.min.css │ │ └── jquery.selectBoxIt.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.svg │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ ├── fontawesome-webfont.woff2 │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ └── js │ │ ├── backend.js │ │ ├── bootstrap.min.js │ │ ├── jquery-3.3.1.min.js │ │ ├── jquery-ui.min.js │ │ └── jquery.selectBoxIt.min.js ├── logout.php ├── members.php ├── temporaryTemplate.php └── uploads │ └── avatars │ ├── 475952_adel.jpg │ ├── 525975_fayez.jpg │ ├── 875944_hind.jpg │ └── 997912_ramy.jpg ├── categories.php ├── function-doc.txt ├── img.jpg ├── includes ├── functions │ └── functions.php ├── languages │ ├── arabic.php │ └── english.php └── templates │ ├── footer.php │ └── header.php ├── index.php ├── init.php ├── items.php ├── layout ├── css │ ├── bootstrap.css │ ├── bootstrap.min.css │ ├── font-awesome.min.css │ ├── front.css │ ├── images │ │ ├── ui-icons_444444_256x240.png │ │ ├── ui-icons_555555_256x240.png │ │ ├── ui-icons_777620_256x240.png │ │ ├── ui-icons_777777_256x240.png │ │ ├── ui-icons_cc0000_256x240.png │ │ └── ui-icons_ffffff_256x240.png │ ├── jquery-ui.min.css │ └── jquery.selectBoxIt.css ├── fonts │ ├── FontAwesome.otf │ ├── fontawesome-webfont.eot │ ├── fontawesome-webfont.svg │ ├── fontawesome-webfont.ttf │ ├── fontawesome-webfont.woff │ ├── fontawesome-webfont.woff2 │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.svg │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ └── glyphicons-halflings-regular.woff2 └── js │ ├── bootstrap.min.js │ ├── front.js │ ├── jquery-3.3.1.min.js │ ├── jquery-ui.min.js │ └── jquery.selectBoxIt.min.js ├── login.php ├── logout.php ├── newad.php ├── profile.php └── tags.php /Database - shop/shop database - SQL Dump File - phpMyAdmin Export.sql: -------------------------------------------------------------------------------- 1 | -- phpMyAdmin SQL Dump 2 | -- version 5.2.1 3 | -- https://www.phpmyadmin.net/ 4 | -- 5 | -- Host: localhost 6 | -- Generation Time: Jun 11, 2023 at 06:49 PM 7 | -- Server version: 8.0.28 8 | -- PHP Version: 8.1.4 9 | 10 | SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; 11 | START TRANSACTION; 12 | SET time_zone = "+00:00"; 13 | 14 | 15 | /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; 16 | /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; 17 | /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; 18 | /*!40101 SET NAMES utf8mb4 */; 19 | 20 | -- 21 | -- Database: `shop` 22 | -- 23 | 24 | -- -------------------------------------------------------- 25 | 26 | -- 27 | -- Table structure for table `categories` 28 | -- 29 | 30 | CREATE TABLE `categories` ( 31 | `ID` int NOT NULL, 32 | `Name` varchar(255) NOT NULL, 33 | `Description` text NOT NULL, 34 | `parent` int NOT NULL, 35 | `Ordering` int DEFAULT NULL, 36 | `Visibility` tinyint NOT NULL DEFAULT '0', 37 | `Allow_Comment` tinyint NOT NULL DEFAULT '0', 38 | `Allow_Ads` tinyint NOT NULL DEFAULT '0' 39 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; 40 | 41 | -- 42 | -- Dumping data for table `categories` 43 | -- 44 | 45 | INSERT INTO `categories` (`ID`, `Name`, `Description`, `parent`, `Ordering`, `Visibility`, `Allow_Comment`, `Allow_Ads`) VALUES 46 | (17, 'Hand Made', 'Hand Made Items', 0, 1, 1, 1, 1), 47 | (18, 'Computers', 'Computer Items', 0, 2, 0, 0, 0), 48 | (19, 'Cell Phones', 'Cell Phones', 0, 3, 0, 0, 0), 49 | (20, 'Clothing', 'Clothes and Fashion', 0, 4, 0, 0, 0), 50 | (21, 'Tools', 'Home Tools', 0, 5, 0, 0, 0), 51 | (23, 'Blackberry', 'Blackberry Phones', 19, 2, 0, 0, 0), 52 | (24, 'Hammers', 'Hammers Description test', 21, 1, 0, 0, 0), 53 | (25, 'Boxes', 'Boxes Hand made', 21, 1, 0, 0, 0), 54 | (26, 'Wool', 'Hand Made wool', 17, 3, 0, 0, 0), 55 | (27, 'Games', '', 0, 1, 0, 0, 0), 56 | (28, 'Cars', 'Luxurious cars', 0, 6, 0, 0, 0); 57 | 58 | -- -------------------------------------------------------- 59 | 60 | -- 61 | -- Table structure for table `comments` 62 | -- 63 | 64 | CREATE TABLE `comments` ( 65 | `c_id` int NOT NULL, 66 | `comment` text NOT NULL, 67 | `status` tinyint NOT NULL, 68 | `comment_date` date NOT NULL, 69 | `item_id` int NOT NULL, 70 | `user_id` int NOT NULL 71 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; 72 | 73 | -- 74 | -- Dumping data for table `comments` 75 | -- 76 | 77 | INSERT INTO `comments` (`c_id`, `comment`, `status`, `comment_date`, `item_id`, `user_id`) VALUES 78 | (10, 'Awesome!\r\n', 0, '2023-05-23', 16, 29), 79 | (11, 'Cool!\r\n', 1, '2023-05-23', 23, 29), 80 | (12, 'Comfortable!\r\n', 0, '2023-05-23', 22, 29), 81 | (13, 'test comment\r\n', 0, '2023-06-09', 17, 29); 82 | 83 | -- -------------------------------------------------------- 84 | 85 | -- 86 | -- Table structure for table `items` 87 | -- 88 | 89 | CREATE TABLE `items` ( 90 | `Item_ID` int NOT NULL, 91 | `Name` varchar(255) NOT NULL, 92 | `Description` text NOT NULL, 93 | `Price` varchar(255) NOT NULL, 94 | `Add_Date` date NOT NULL, 95 | `Country_Made` varchar(255) NOT NULL, 96 | `Image` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, 97 | `Status` varchar(255) NOT NULL, 98 | `Rating` smallint DEFAULT NULL, 99 | `Approve` tinyint NOT NULL DEFAULT '0', 100 | `Cat_ID` int NOT NULL, 101 | `Member_ID` int NOT NULL, 102 | `tags` varchar(255) NOT NULL 103 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; 104 | 105 | -- 106 | -- Dumping data for table `items` 107 | -- 108 | 109 | INSERT INTO `items` (`Item_ID`, `Name`, `Description`, `Price`, `Add_Date`, `Country_Made`, `Image`, `Status`, `Rating`, `Approve`, `Cat_ID`, `Member_ID`, `tags`) VALUES 110 | (12, 'Network Cable', 'Cat 9 Network Cable', '100', '2018-03-10', 'USA', '', '1', 0, 1, 18, 14, ''), 111 | (14, 'Assassin\'s Creed', 'Open-world, action-adventure, and stealth game', '150', '2018-03-26', 'Turkey', '', '4', 0, 1, 27, 21, ''), 112 | (16, 'Chess Wooden Game', 'A good wooden game', '100', '2018-03-29', 'Egypt', '', '1', 0, 0, 17, 21, 'Hand, Discount, Guarantee'), 113 | (17, 'Battlefield 2', 'Good playstation 4 Game', '70', '2018-03-30', 'USA', '', '1', 0, 1, 18, 21, 'RPG, Online, Game'), 114 | (18, 'Red Alert 3', 'A good PS Game', '100', '2018-03-30', 'Japan', '', '1', 0, 0, 27, 21, 'Online, RPG, Gamed'), 115 | (21, 'Lamborghini', 'Lambo cars', '3157145', '2023-04-14', 'Italy', NULL, '1', NULL, 1, 28, 21, 'cars'), 116 | (22, 'Men\'s Sneakers', 'High quality sneakers', '450', '2023-05-20', 'Egypt', NULL, '1', NULL, 0, 20, 29, ''), 117 | (23, 'iPhone 14', 'Luxurious Apple iPhone 14', '41999', '2023-05-20', 'China', NULL, '1', NULL, 1, 18, 29, ''); 118 | 119 | -- -------------------------------------------------------- 120 | 121 | -- 122 | -- Table structure for table `users` 123 | -- 124 | 125 | CREATE TABLE `users` ( 126 | `UserID` int NOT NULL COMMENT 'To identify user', 127 | `Username` varchar(255) NOT NULL COMMENT 'Username to login', 128 | `Password` varchar(255) NOT NULL COMMENT 'Password to login', 129 | `Email` varchar(255) NOT NULL, 130 | `FullName` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL, 131 | `GroupID` int NOT NULL DEFAULT '0' COMMENT 'Identifies Group ID (Admin or Normal User or Moderator)', 132 | `TrustStatus` int NOT NULL DEFAULT '0' COMMENT 'Seller Rank', 133 | `RegStatus` int NOT NULL DEFAULT '0' COMMENT 'User approval status (Ex: pending, approved, ...)', 134 | `Date` date NOT NULL, 135 | `avatar` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT NULL 136 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; 137 | 138 | -- 139 | -- Dumping data for table `users` 140 | -- 141 | 142 | INSERT INTO `users` (`UserID`, `Username`, `Password`, `Email`, `FullName`, `GroupID`, `TrustStatus`, `RegStatus`, `Date`, `avatar`) VALUES 143 | (12, 'Hind', '601f1889667efaebb33b8c12572835da3f027f78', 'hind@gmail.com', 'Hind Ahmed', 0, 0, 1, '2018-02-25', '875944_hind.jpg'), 144 | (14, 'Fathy', '03785d4e638cd09cea620fd0939bf06825be88df', 'fathy@fathy.com', 'Fathy Shady', 0, 0, 0, '2018-02-25', ''), 145 | (16, 'Ramy', '59f7c8818803a2f0d7946e160dc2a63b88c0ee28', 'ramy@ramy.com', 'Ramy Rabie', 0, 0, 1, '2018-02-25', '997912_ramy.jpg'), 146 | (17, 'Adel', 'e5594062f0a0a362abbb022a6fb0c36dcd9a1bd1', 'adel@yahoo.com', 'Adel Sameh', 0, 0, 0, '2018-02-25', '475952_adel.jpg'), 147 | (21, 'Mazen', '601f1889667efaebb33b8c12572835da3f027f78', 'mazen@mazen.com', 'Mazen Naeem', 0, 0, 1, '2018-03-02', ''), 148 | (22, 'Fayez', '601f1889667efaebb33b8c12572835da3f027f78', 'fayez@fayez.com', 'Fayez Fawzy', 0, 0, 0, '2018-03-13', '525975_fayez.jpg'), 149 | (27, 'Abu Gamal', '601f1889667efaebb33b8c12572835da3f027f78', 'abugamal@hotmail.com', 'Abu Gamal Mahmoud Shanawany', 0, 0, 1, '2018-03-31', ''), 150 | (29, 'Ahmed', '7c4a8d09ca3762af61e59520943dc26494f8941b', 'ahmed@gmail.com', 'Ahmed Yahya', 1, 0, 1, '2023-05-20', NULL); 151 | 152 | -- 153 | -- Indexes for dumped tables 154 | -- 155 | 156 | -- 157 | -- Indexes for table `categories` 158 | -- 159 | ALTER TABLE `categories` 160 | ADD PRIMARY KEY (`ID`), 161 | ADD UNIQUE KEY `Name` (`Name`); 162 | 163 | -- 164 | -- Indexes for table `comments` 165 | -- 166 | ALTER TABLE `comments` 167 | ADD PRIMARY KEY (`c_id`), 168 | ADD KEY `My_items_comments` (`item_id`), 169 | ADD KEY `My_users_comment` (`user_id`); 170 | 171 | -- 172 | -- Indexes for table `items` 173 | -- 174 | ALTER TABLE `items` 175 | ADD PRIMARY KEY (`Item_ID`), 176 | ADD KEY `hamada` (`Member_ID`), 177 | ADD KEY `hazem` (`Cat_ID`); 178 | 179 | -- 180 | -- Indexes for table `users` 181 | -- 182 | ALTER TABLE `users` 183 | ADD PRIMARY KEY (`UserID`), 184 | ADD UNIQUE KEY `Username` (`Username`); 185 | 186 | -- 187 | -- AUTO_INCREMENT for dumped tables 188 | -- 189 | 190 | -- 191 | -- AUTO_INCREMENT for table `categories` 192 | -- 193 | ALTER TABLE `categories` 194 | MODIFY `ID` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=32; 195 | 196 | -- 197 | -- AUTO_INCREMENT for table `comments` 198 | -- 199 | ALTER TABLE `comments` 200 | MODIFY `c_id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15; 201 | 202 | -- 203 | -- AUTO_INCREMENT for table `items` 204 | -- 205 | ALTER TABLE `items` 206 | MODIFY `Item_ID` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24; 207 | 208 | -- 209 | -- AUTO_INCREMENT for table `users` 210 | -- 211 | ALTER TABLE `users` 212 | MODIFY `UserID` int NOT NULL AUTO_INCREMENT COMMENT 'To identify user', AUTO_INCREMENT=30; 213 | 214 | -- 215 | -- Constraints for dumped tables 216 | -- 217 | 218 | -- 219 | -- Constraints for table `comments` 220 | -- 221 | ALTER TABLE `comments` 222 | ADD CONSTRAINT `My_items_comments` FOREIGN KEY (`item_id`) REFERENCES `items` (`Item_ID`) ON DELETE CASCADE ON UPDATE CASCADE, 223 | ADD CONSTRAINT `My_users_comment` FOREIGN KEY (`user_id`) REFERENCES `users` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE; 224 | 225 | -- 226 | -- Constraints for table `items` 227 | -- 228 | ALTER TABLE `items` 229 | ADD CONSTRAINT `hamada` FOREIGN KEY (`Member_ID`) REFERENCES `users` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE, 230 | ADD CONSTRAINT `hazem` FOREIGN KEY (`Cat_ID`) REFERENCES `categories` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE; 231 | COMMIT; 232 | 233 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; 234 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; 235 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; 236 | -------------------------------------------------------------------------------- /Project Screenshots/admin-panel-login.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/Project Screenshots/admin-panel-login.jpg -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Plain PHP and MySQL complete E-commerce Application 2 | A plain PHP/MySQL complete E-commerce application with an Admin Panel, Login System, Registration, Validation and Authorization. It provides the functionality needed for running an online store, such as product listing, shopping cart, and order management and approvals through its Admin Panel. This project aims to demonstrate the implementation of an e-commerce system without relying on any external libraries or frameworks. 3 | 4 | Frontend technologies used: jQuery and Bootstrap (Responsive Design/Mobile First Design). 5 | 6 | ## Screenshots: 7 | ***Admin Panel Login*** 8 | ![admin-panel-login](https://github.com/AhmedYahyaE/plain-php-ecommerce/assets/118033266/fd26152d-fd25-4367-9334-7f10c048bea7) 9 | 10 | ## Features: 11 | 1- User Registration, Authentication and Authorization. 12 | 13 | 2- Both Server-side and Client-side Validation. 14 | 15 | 3- Login System (Session Management). 16 | 17 | 4- CRUD Operations. 18 | 19 | 5- Admin Panel for the website owner (interactive Dashboard, user registration approval, member commemt approval, item and category approval, ...). 20 | 21 | 6- User Roles and Permissions. 22 | 23 | 7- File Upload. 24 | 25 | ## Application URLs: 26 | 1- Frontend: The public-facing website can be accessed at https://www.domain-example.com/index.php. This is where customers/users/members can browse products/items, add items to their cart, and comment on existing products, ... 27 | 28 | 2- Admin Panel: The Admin Panel for managing the E-commerce website is available at https://www.domain-example.com/admin/index.php. This is a secure area accessible only to authorized administrators. It provides functionalities for managing products/items, categories, orders, and user accounts and comments. 29 | 30 | ## Installation & Configuration: 31 | 1- Clone the project or download it. 32 | 33 | 2- Create a MySQL database named **\`shop\`** and import the database schema from [shop database - PhpMyAdmin Export.sql]() SQL Dump file. Navigate to '**`Database - shop`**/**`shop database - PhpMyAdmin Export.sql`**' SQL Dump file. 34 | 35 | 3- Navigate to the database connection configuration file in '**`admin/connect.php`**' file and configure/edit the file according to your MySQL credentials. 36 | 37 | 4- Navigate to the project root directory by using the **`cd`** terminal command, and then start your PHP built-in Development Web Server by running the command: **`php -S localhost:8000`**. 38 | 39 | 5- In your browser, go to http://localhost:8000/index.php (**Frontend**) and http://localhost:8000/admin/index.php (**Admin Panel**). 40 | 41 | 6- A ready-to-use registered user account credentials (for both **Frontend** and **Admin Panel**): 42 | 43 | > **Username**: **Ahmed**, **Password**: **123456** 44 | 45 | ## Contribution: 46 | Contributions to my plain PHP/MySQL E-commerce application are most welcome! If you find any issues or have suggestions for improvements or want to add new features, please open an issue or submit a pull request. 47 | -------------------------------------------------------------------------------- /admin/comments.php: -------------------------------------------------------------------------------- 1 | ', print_r($_SESSION), ' (from members.php)'; 23 | 24 | // GET HTTP Request ($_GET) is coming from navbar.php (Edit Profile) 25 | $do = isset($_GET['do']) ? $_GET['do'] : 'Manage';/* This is the same as: if (isset($_GET['do'])) {$do = $_GET['do'];} else {$do = 'Manage';} */ 26 | 27 | 28 | 29 | 30 | 31 | if ($do == 'Manage') { // GET Request: Manage Members Page (coming from clicking on Members in the navbar.php) 32 | $stmt = $con->prepare('SELECT `comments`.*, `items`.`Name` AS My_item_name, `users`.`Username` AS My_user_name FROM `comments` 33 | INNER JOIN `items` ON `items`.`Item_ID` = `comments`.`item_id` 34 | INNER JOIN `users` ON `users`.`UserID` = `comments`.`user_id` 35 | ORDER BY `c_id` DESC 36 | '); 37 | 38 | // Executing the statement 39 | $stmt->execute(); 40 | 41 | // Retrieving/Fetching all the rows and assigning them to a variable 42 | $comments = $stmt->fetchAll(); 43 | // echo '
', var_dump($rows), '
'; 44 | //echo '
', print_r($rows), '
'; 45 | 46 | if (!empty($comments)) { 47 | ?> 48 |

Manage Comments

49 |
50 |
51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | '; 63 | echo ''; 64 | echo ''; 65 | echo ''; // from the last SQL query (AS ....) 66 | echo ''; // from the last SQL query (AS ....) 67 | echo ''; 68 | echo ''; 77 | echo ''; 78 | } 79 | ?> 80 | 81 |
IDCommentItem NameUsernameAdded DateControl
' . $comment['c_id'] . '' . $comment['comment'] . '' . $comment['My_item_name'] . '' . $comment['My_user_name'] . '' . $comment['comment_date'] . ' 69 | Edit 70 | Delete'; 71 | if ($comment['status'] == 0) { // means that the user request hasn't been appproved yet, so show the activate button to Admin to make `RegStatus` = 1 72 | echo ' 73 | Approve 74 | '; 75 | } 76 | echo '
82 |
83 |
84 | '; 87 | echo '
There are no comments to show'; 89 | } 90 | ?> 91 | 92 | 93 | 94 | 95 | 96 | '; 99 | 100 | // Checking if userid GET Request is numeric only and getting its integer value 101 | $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0; 102 | 103 | // Selecting all data depending on that $comid 104 | $stmt = $con->prepare('SELECT * FROM `comments` WHERE `c_id` = ?'); // `GroupID` = 1 to make sure the user is an Admin 105 | // echo '
', print_r($stmt), '
'; 106 | 107 | // Executing the query 108 | $stmt->execute(array($comid)); 109 | 110 | // Retrieving/Fetching data resulted from the query 111 | $row = $stmt->fetch(); 112 | 113 | // Get the row count 114 | $count = $stmt->rowCount(); // returns the number of rows affected by the last SQL statement(from execute()) 115 | 116 | // If there's such $userid, show the form 117 | if ($count > 0) { // You can add this for more security to prevent Admin to change id from address bar and edit the user data from address bar: if ($count > 0 && $_SESSION['Username'] == $row['Username']) { 118 | // echo $row['UserID'] . ' ' . $row['Username'] . ' ' . $row['Password'] . ' ' . $row['FullName'] . ' ' . $row['Email'] . '
'; 119 | ?> 120 |

Edit Comment

121 |
122 | 123 |
124 | 125 | 126 | 127 | 128 |
129 | 130 |
131 | 132 |
133 |
134 | 135 | 136 |
137 |
138 | 139 |
140 |
141 | 142 |
143 |
144 | '; 148 | $theMsg = '
ERROR: There\'s no such ID

'; 149 | redirectHome($theMsg); 150 | echo '
'; 151 | } 152 | 153 | 154 | 155 | 156 | } elseif ($do == 'Update') { // Update Page (GET Request coming from the Form in Edit Page) 157 | echo '

Update Comment

'; 158 | echo '
'; // To show errors using Bootstrap (alert-danger class) 159 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { // to make sure the URL is not copy and paste (to make sure that the HTTP Request is not a GET request (copy/paste in the browser address bar), but it's a POST request) // if the HTML Form is submitted with a POST method/verb HTTP Request 160 | // Getting the variables and their values coming from the Form in Edit Page (from name and value attributes in the fields (Ex: ) 161 | // Storing the name attribute values of the fields in New variables 162 | $comid = $_POST['comid']; // from the hidden input field in Edit Page 163 | $comment = $_POST['comment']; 164 | 165 | // Updating the database corresponding to these info 166 | $stmt = $con->prepare('UPDATE `comments` SET `comment` = ? WHERE `c_id` = ?'); 167 | $stmt->execute(array($comment, $comid)); 168 | 169 | //Echoing a Success Message 170 | $theMsg = '
' . $stmt->rowCount() . ' Records Updated Successfully.

'; 171 | 172 | redirectHome($theMsg, 'back'); 173 | } else { 174 | 175 | $theMsg = '
Sorry, You can\'t browse this page directly by copy paste in the address bar, you must come through a POST or GET HTTP Request.

'; 176 | redirectHome($theMsg); 177 | } 178 | echo '
'; // The continer div 179 | 180 | 181 | 182 | 183 | 184 | } elseif ($do == 'Delete') { // Delete Comment Page (from Delete button in Comments Page) 185 | echo '

Delete Comment

'; 186 | echo '
'; 187 | // Checking if userid GET Request is numeric only and getting its integer value 188 | $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0; 189 | 190 | //Checking if the comment exists in the database 191 | $check = checkItem('`c_id`', '`comments`', $comid); 192 | 193 | // If there's such $userid, show the form 194 | if ($check > 0) { // You can add this for more security to prevent Admin to change id from address bar and edit the user data from address bar: if ($count > 0 && $_SESSION['Username'] == $row['Username']) { 195 | // echo $row['UserID'] . ' ' . $row['Username'] . ' ' . $row['Password'] . ' ' . $row['FullName'] . ' ' . $row['Email'] . '
'; 196 | // echo 'Good this is the form'; 197 | $stmt = $con->prepare('DELETE FROM `comments` WHERE `c_id` = :zid'); 198 | $stmt->bindParam(':zid', $comid); 199 | $stmt->execute(); 200 | 201 | $theMsg = '
' . $stmt->rowCount() . ' Record Deleted Successfully.

'; 202 | redirectHome($theMsg, 'back'); 203 | } else { 204 | $theMsg ='
This ID does Not exist (from Delete Page)

'; 205 | redirectHome($theMsg); 206 | } 207 | echo '
'; 208 | 209 | 210 | 211 | 212 | 213 | } elseif ($do == 'Approve') { // coming from the GET Request of the Approve Button in Manage Comments Page 214 | echo '

Approve Comment

'; 215 | echo '
'; 216 | // Checking if userid GET Request is numeric only and getting its integer value 217 | $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0; 218 | 219 | // Checking if the comment exists in the database 220 | $check = checkItem('`c_id`', '`comments`', $comid); 221 | 222 | // If there's such $comid, show the form 223 | if ($check > 0) { // You can add this for more security to prevent Admin to change id from address bar and edit the user data from address bar: if ($count > 0 && $_SESSION['Username'] == $row['Username']) { 224 | // echo $row['UserID'] . ' ' . $row['Username'] . ' ' . $row['Password'] . ' ' . $row['FullName'] . ' ' . $row['Email'] . '
'; 225 | $stmt = $con->prepare('UPDATE `comments` SET `Status` = 1 WHERE `c_id` = ?'); 226 | $stmt->execute(array($comid)); 227 | 228 | $theMsg = '
' . $stmt->rowCount() . ' Comment Approved Successfully.

'; 229 | redirectHome($theMsg, 'back'); 230 | } else { 231 | $theMsg ='
This ID does Not exist (from Delete Page)

'; 232 | redirectHome($theMsg); 233 | } 234 | echo '
'; 235 | } 236 | 237 | 238 | 239 | 240 | 241 | // Include footer.php 242 | include $tpl . 'footer.php'; 243 | 244 | 245 | } else { // Protected Routes (Protecting Routes): if there's no user stored in the Session, redirect the website guest/visitor to the eCommerce\admin\index.php page // This is for security to prevent anyone from copy paste the page URL directly in the browser address bar (i.e. the HTTP Request is GET method, not POST method), and to make sure the user is coming through a POST HTTP request 246 | // echo 'You Are Not Authorized to View This Page (from dashboard.php)
'; 247 | header('Location: index.php'); 248 | exit(); 249 | } 250 | 251 | 252 | 253 | ob_end_flush(); // For fixing the "headers already sent" error -------------------------------------------------------------------------------- /admin/connect.php: -------------------------------------------------------------------------------- 1 | 'SET NAMES utf8' 11 | ); 12 | 13 | try { 14 | $con = new PDO($dsn, $user, $pass, $options); 15 | $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); // to activate the Exception error handling mode 16 | // echo 'You Are Connected To the Database!
'; 17 | } catch (PDOException $e) { // $e is a PDOException class object which contains the error 18 | echo 'Failed To Connect To Database: ' . $e->getMessage() . '
'; 19 | } -------------------------------------------------------------------------------- /admin/dashboard.php: -------------------------------------------------------------------------------- 1 | */ 17 | //echo 'Welcome ' . $_SESSION['Username'] . ' (from dashboard.php)
'; 18 | // echo "
MY SESSION ARRAY ELEMENTS ARE: \n", print_r($_SESSION), ' (from dashboard.php)
'; 19 | 20 | $numUsers = 6; // The number of latest users (in latest users div) 21 | $latestUsers = getLatest('*', 'users', 'UserID', $numUsers); // Latest Users Array 22 | 23 | $numItems = 5; // The number of latest items (in latest items div) 24 | $latestItems = getLatest('*', 'items', 'Item_ID', $numItems); // Latest Items Array 25 | 26 | $numComments = 5; // The number of latest comments 27 | $latestComments = getLatest('*', 'items', 'Item_ID', $numItems); // Latest Items Array 28 | 29 | ?> 30 |
31 |
32 |

Dashboard

33 |
34 |
35 |
36 | 37 |
38 | Total Members 39 |
40 |
41 |
42 |
43 |
44 | 45 |
46 | Pending Members 47 |
48 |
49 |
50 |
51 |
52 | 53 |
54 | Total Items 55 |
56 |
57 |
58 |
59 |
60 | 61 |
62 | Total Comments 63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | Latest Registered Users 76 |
77 |
78 |
    79 | '; 83 | echo $user['Username']; 84 | echo ''; 85 | echo ''; 86 | echo ' Edit'; 87 | if ($user['RegStatus'] == 0) { // means that the user request hasn't been appproved yet, so show the activate button to Admin to make RegStatus = 1 88 | echo ' Activate'; 89 | } 90 | echo ''; 91 | echo ''; 92 | echo ''; 93 | } 94 | } else { 95 | echo 'There are no members to show'; 96 | } 97 | ?> 98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | Latest Items 106 |
107 |
108 |
    109 | '; 113 | echo $item['Name']; 114 | echo ''; 115 | echo ''; 116 | echo ' Edit'; 117 | if ($item['Approve'] == 0) { // means that the user request hasn't been appproved yet, so show the approve button to Admin to make Approve = 1 118 | echo ' Approve'; 119 | } 120 | echo ''; 121 | echo ''; 122 | echo ''; 123 | } 124 | } else { 125 | echo 'There are no items to show'; 126 | } 127 | ?> 128 |
129 |
130 |
131 |
132 |
133 | 134 |
135 |
136 |
137 |
138 | Latest Comments 139 |
140 |
141 | prepare("SELECT `comments`.*, `users`.`Username` AS My_user_name FROM `comments` 143 | INNER JOIN `users` ON `users`.`UserID` = `comments`.`user_id` 144 | ORDER BY `c_id` DESC 145 | LIMIT $numComments 146 | "); 147 | $stmt->execute(); 148 | $comments = $stmt->fetchAll(); 149 | if (!empty($comments)) { 150 | foreach ($comments as $comment) { 151 | echo '
'; 152 | echo '' . $comment['My_user_name'] . ''; 153 | echo '

' . $comment['comment'] . '

'; 154 | echo '
'; 155 | } 156 | } else { 157 | echo 'There are no comments to show'; 158 | } 159 | ?> 160 |
161 |
162 |
163 |
164 | 165 |
166 |
167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | '; 181 | header('Location: index.php'); 182 | exit(); 183 | } -------------------------------------------------------------------------------- /admin/includes/functions/functions.php: -------------------------------------------------------------------------------- 1 | prepare("SELECT $field FROM $table $where $and ORDER BY $orderField $ordering"); 17 | $getAll->execute(); 18 | $all = $getAll->fetchAll(); 19 | return $all; 20 | } 21 | 22 | /* Title Function v1.0: 23 | ** echoes the page's title (in case the page has the variable $pageTitle OR echoes the default title for other pages) 24 | */ 25 | function getTitle() { 26 | global $pageTitle; // Every page in this project has its own $pageTitle variable at the top of the page which holds its name 27 | 28 | if (isset($pageTitle)) { 29 | return $pageTitle; 30 | } else { 31 | return 'Default Title'; 32 | } 33 | } 34 | 35 | 36 | /* Redirection to HomePage function v1.0 37 | ** when any error in the website happens: It accepts the parameters: $errorMsg (to echo the error message) and $seconds (seconds before redirecting) 38 | */ 39 | /* function redirectHome($errorMsg, $seconds = 3) { // 3 seconds as a default value for $seconds if not specified 40 | echo "
$errorMsg
"; 41 | echo "
You will be redirected to HomePage after $seconds seconds...
"; 42 | header("refresh:$seconds;url=index.php"); // Redirection after a certain time u want 43 | exit(); 44 | } */ 45 | 46 | 47 | /* Redirection to HomePage function v2.0 48 | ** when any error in the website happens: It accepts the parameters: $theMsg (to echo the message: error, success, warning,... messages) and $seconds (seconds before redirecting) and $url (the link you want to redirect to) 49 | */ 50 | function redirectHome($theMsg, $url = NULL, $seconds = 3) { // 3 seconds as a default value for $seconds if not specified 51 | if ($url === Null) { // If it is left without anything 52 | $url = 'index.php'; 53 | $link = 'HomePage'; 54 | } else { // if it's redirect 'back' 55 | if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== '') { // This is to avoid the PHP error message that will appear if the user starting from that specific page and there wasn't any page originally coming from 56 | $url = $_SERVER['HTTP_REFERER']; // the page you are coming from 57 | $link = 'the Previous Page'; 58 | } else { // Here there is no page $_SERVER['HTTP_REFERER'] can refer to because user is starting from that specific page already 59 | $url = 'index.php'; 60 | $link = 'HomePage'; 61 | } 62 | /* $url = isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== '' ? $_SERVER['HTTP_REFERER'] : 'index.php'; */ // The same previous if condition code using the Ternary Operator 63 | } 64 | 65 | echo $theMsg; 66 | echo "
You will be redirected to $link after $seconds seconds...
"; 67 | 68 | header("refresh:$seconds;url=$url"); // Redirection after a certain time duration you want 69 | exit(); 70 | } 71 | 72 | 73 | /* Function to check item in database v1.0 (to check if the new user to be added already exists in the database) 74 | **Parameters are: $select (items to be selected. Ex: user, item, category), $from (the table to select from. Ex: users, items, categories), $value (the value of $select. Ex: Ahmed, box, electronics) 75 | */ 76 | function checkItem($select, $from, $value) { 77 | global $con; 78 | 79 | $statement = $con->prepare("SELECT $select FROM $from WHERE $select = ?"); 80 | $statement->execute(array($value)); 81 | $count = $statement->rowCount(); 82 | 83 | 84 | return $count; 85 | } 86 | 87 | 88 | /* Count number of items in a table function v1.0 89 | ** A function to count number of items (rows) (Function that calculates number of rows in any table(Ex: to get the total number of users in the table)) 90 | *** Parameters are: $item is items to be counted, $table is the table where you select from 91 | */ 92 | function countItems($item, $table) { 93 | global $con; 94 | 95 | $stmt2 = $con->prepare("SELECT COUNT(`$item`) FROM `$table`"); 96 | $stmt2->execute(); 97 | return $stmt2->fetchColumn(); 98 | } 99 | 100 | 101 | /* Getting the latest records function v1.0 102 | ** A function to get the latest items from the database (Ex: users, shop items, comments,...) 103 | ** Parameters are: $select: the field to select from database, $table: the table to select from and $limit: the number of records to get from the query, $order: ASC or DESC order 104 | */ 105 | function getLatest($select, $table, $order, $limit = 5) { 106 | global $con; 107 | 108 | $getStmt = $con->prepare("SELECT $select FROM `$table` ORDER BY `$order` DESC LIMIT $limit"); 109 | $getStmt->execute(); 110 | $rows = $getStmt->fetchAll(); 111 | return $rows; 112 | } 113 | 114 | 115 | 116 | 117 | // Get the admin's name based on the Session (to be displayed in the Admin Panel in the navbar on the right in eCommerce\admin\includes\templates\navbar.php ) 118 | function getAdminNameThroughSession($session_username, $session_id) { 119 | global $con; 120 | 121 | $statement = $con->prepare("SELECT `FullName` FROM `users` WHERE `Username` = :session_username AND `UserID` = :session_id AND `GroupID` = 1 LIMIT 1;"); // `GroupID` = 1 to make sure the user is an Admin // LIMIT 1 because it must be a unique one user 122 | // return $statement; 123 | /* echo '
', var_dump($statement),'
'; 124 | exit; */ 125 | 126 | $statement->bindValue(':session_username', $session_username, PDO::PARAM_STR); 127 | $statement->bindValue(':session_id' , $session_id , PDO::PARAM_INT); 128 | 129 | /* echo '
', var_dump($statement->execute()),'
'; 130 | exit; */ 131 | // return $statement->execute(); 132 | $statement->execute(); 133 | 134 | 135 | /* echo '
', var_dump($statement->fetch()),'
'; 136 | // echo '
', var_dump($statement->fetch(PDO::FETCH_ASSOC)),'
'; 137 | // echo '
', var_dump($statement->fetchColumn()),'
'; 138 | exit; */ 139 | // return $statement->fetch(); 140 | // return $statement->fetch(PDO::FETCH_ASSOC); 141 | return $statement->fetchColumn(); 142 | } -------------------------------------------------------------------------------- /admin/includes/languages/arabic.php: -------------------------------------------------------------------------------- 1 | 'أهلا', 9 | 'ADMIN' => 'الأدمن', 10 | 'Comments' => 'التعليقات' 11 | ); 12 | 13 | 14 | return $lang[$phrase]; 15 | } -------------------------------------------------------------------------------- /admin/includes/languages/english.php: -------------------------------------------------------------------------------- 1 | 'Home', 9 | 'CATEGORIES' => 'Categories', 10 | 'ITEMS' => 'Items', 11 | 'MEMBERS' => 'Members', 12 | 'Comments' => 'Comments', 13 | 'STATISTICS' => 'Statistics', 14 | 'LOGS' => 'Logs' 15 | ); 16 | 17 | 18 | return $lang[$phrase]; 19 | } -------------------------------------------------------------------------------- /admin/includes/templates/footer.php: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /admin/includes/templates/header.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | <?php echo getTitle() ?> 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /admin/includes/templates/navbar.php: -------------------------------------------------------------------------------- 1 | 44 | MY SESSION ARRAY ELEMENTS ARE: \n", print_r($_SESSION), ' (from the Admin Panel in admin/includes/templates/navbar.php)'; 46 | ?> -------------------------------------------------------------------------------- /admin/index.php: -------------------------------------------------------------------------------- 1 | MY SESSION ARRAY ELEMENTS ARE: \n", print_r($_SESSION), '(from dashboard.php)'; 20 | 21 | 22 | 23 | // If the HTML Form is submitted (the 54 | HomePage 55 | Admin Panel 56 | 57 | 58 | 59 | 75 | 76 | 77 | 78 | MY SESSION ARRAY ELEMENTS ARE: \n", print_r($_SESSION), '(from the Frontend in includes/templates/header.php)'; 80 | ?> -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 10 | 11 | 12 | 13 |
14 |
15 | '; 21 | echo '
'; 22 | echo '$' . $item['Price'] . ''; 23 | echo 'random image'; 24 | echo '
'; 25 | echo '

' . $item['Name'] . '

'; 26 | echo '

' . $item['Description'] . '

'; 27 | echo '
' . $item['Add_Date'] . '
'; 28 | echo '
'; 29 | echo '
'; 30 | echo '
'; 31 | } 32 | ?> 33 |
34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /init.php: -------------------------------------------------------------------------------- 1 | prepare('SELECT `items`.*, `categories`.Name AS My_Category, `users`.Username AS My_Username FROM `items` 15 | INNER JOIN `categories` ON `categories`.ID = `items`.Cat_ID 16 | INNER JOIN `users` ON `users`.UserID = `items`.Member_ID 17 | WHERE `Item_ID` = ? AND `Approve` = 1 18 | '); 19 | // echo '
', print_r($stmt), '
'; 20 | 21 | // Executing the query 22 | $stmt->execute(array($itemid)); 23 | 24 | $count = $stmt->rowCount(); 25 | 26 | if ($count > 0) { 27 | // Retrieving/Fetching data resulted from the query 28 | $item = $stmt->fetch(); 29 | 30 | ?> 31 | 32 |

33 |
34 |
35 |
random image
36 |
37 |

38 |

39 |
    40 |
  • Adding Date:
  • 41 |
  • Price:
  • 42 |
  • Made In:
  • 43 |
  • Category:
  • 44 |
  • Added By:
  • 45 |
  • Tags: 46 | ', var_dump($allTags), ''; 49 | // exit; 50 | 51 | foreach ($allTags as $tag) { 52 | $tag = str_replace(' ', '', $tag); // to be properly printed in href 53 | // echo '
    ', var_dump($tag), '
    '; 54 | // exit; 55 | 56 | $lowertag = strtolower($tag); // to be properly printed in href 57 | 58 | if (!empty($tag)) { 59 | echo "" . $tag . ''; // check eCommerce/tags.php file 60 | } 61 | } 62 | ?> 63 |
  • 64 |
65 |
66 |
67 |
68 | 71 | 72 |
73 |
74 |
75 |

Add Your Comment

76 |
77 | 78 | 79 |
80 | prepare('INSERT INTO `comments` (`comment`, `status`, `comment_date`, `item_id`, `user_id`) VALUES (:zcomment, 0, NOW(), :zitemid, :zuserid)'); 90 | $stmt->execute(array( 91 | 'zcomment' => $comment, 92 | 'zitemid' => $itemid, 93 | 'zuserid' => $userid 94 | )); 95 | 96 | if ($stmt) { 97 | echo '
Comment Added!
'; 98 | } 99 | } 100 | } 101 | ?> 102 |
103 |
104 |
105 | 106 | Login or Register to add comment'; 109 | } 110 | ?> 111 |
112 | prepare('SELECT `comments`.*, `users`.`Username` AS My_user_name FROM `comments` 114 | INNER JOIN `users` ON `users`.`UserID` = `comments`.`user_id` 115 | WHERE `item_id` = ? AND `status` = 1 116 | ORDER BY `c_id` DESC 117 | '); 118 | 119 | // Executing the statement 120 | $stmt->execute(array($item['Item_ID'])); 121 | 122 | // Retrieving/Fetching all the rows and assigning them to a variable 123 | $comments = $stmt->fetchAll(); 124 | // echo '
', var_dump($comments), '
'; 125 | 126 | ?> 127 | 128 | 131 |
132 |
133 |
134 | random image 135 | 136 |
137 |
138 |

139 |
140 |
141 |
142 |
143 | 146 |
147 | 148 | 149 | 150 | 151 | There\'s no such item ID or this item is waiting for approval by admin'; 155 | } 156 | 157 | 158 | // Footer 159 | include $tpl . 'footer.php'; 160 | 161 | ?> -------------------------------------------------------------------------------- /layout/css/front.css: -------------------------------------------------------------------------------- 1 | /*Start: Main Rulez*/ 2 | body {background-color: #f4f4f4; font-size: 16px} 3 | .asterisk {font-size: 20px; color: #d20707; position: absolute; right: 10px; top: 7px}/*class asterisk was created using jQuery. The first positioned-parent is .form-control*/ 4 | .main-form .asterisk {font-size: 30px; color: #d20707; position: absolute; right: 30px; top: 8px} 5 | .nice-message {padding: 10px; background-color: #fff; margin: 10px 0; border-left: 5px solid #080} 6 | h1 {font-size: 55px; margin: 40px 0; font-weight: bold; color: #666} 7 | .input-container {position: relative} 8 | .custom-hr {border-top: 1px solid #c9c9c9} 9 | /*End: Main Rulez*/ 10 | 11 | /*Start: Bootstrap edits*/ 12 | .navbar {border-radius: 0; margin-bottom: 0} 13 | .nav>li>a, .navbar-brand {padding: 15px 12px} 14 | .navbar-brand {font-size: 1em}/*from body font-size*/ 15 | .navbar-inverse .navbar-nav>.open>a, .navbar-inverse .navbar-nav>.open>a:focus, .navbar-inverse .navbar-nav>.open>a:hover, .dropdown-menu {background-color: #3498db} 16 | .dropdown-menu {min-width: 180px; padding: 0; font-size: 1em; border: none; border-radius: 0} 17 | .dropdown-menu>li>a {color: #fff; padding: 10px 15px} 18 | .dropdown-menu>li>a:focus, .dropdown-menu>li>a:hover {color: #fff; background-color: #8e44ad} 19 | .form-control {position: relative}/*to enable me to position the asterisk I made using jQuery in the Form Validation section*/ 20 | /*End: Bootstrap edits*/ 21 | 22 | /*Start: Header Page*/ 23 | .upper-bar {padding: 10px; background-color: #fff} 24 | .my-image {width: 32px; height: 32px} 25 | /*End: Header Page*/ 26 | 27 | /*Start: Login Page*/ 28 | .login-page form, .the-errors {max-width: 380px; margin: auto} 29 | .login-page h1 {color: #c0c0c0} 30 | .login-page h1 span {cursor: pointer} 31 | .login-page form {margin: auto; max-width: 380px} 32 | .login-page form input {margin-bottom: 10px} 33 | .login-page [data-class='login'].selected {color: #337ab7} /*THIS IS HOW TO SELECT A CUSTOM DATA ATTRIBUTE*/ /* Check front.js */ 34 | .login-page [data-class='signup'].selected {color: #5cb85c} /*THIS IS HOW TO SELECT A CUSTOM DATA ATTRIBUTE*/ /* Check front.js */ 35 | .login-page .signup {display: none} 36 | .the-errors .msg {padding: 10px; text-align: left; border-left: 5px solid #cd6858; background-color: #fff; margin-bottom: 8px; border-right: 1px solid #e0e0e0; border-top: 1px solid #e0e0e0; border-bottom: 1px solid #e0e0e0; color: #919191} 37 | .the-errors .error {border-left: 5px solid #cd6858} 38 | /*End: Login Page*/ 39 | 40 | /*Start: Categories Page*/ 41 | .item-box {position: relative} 42 | .item-box .price-tag {background-color: #b4b4b4; padding: 2px 10px; position: absolute; left: 0; top: 10px; font-weight: bold; color: #fff} 43 | .item-box .approve-status {position: absolute; top: 40px; left: 0; background-color: #b85a5a; color: #fff; padding: 3px 5px} 44 | .item-box .caption p {height: 44px; max-height: 44px} 45 | /*End: Categories Page*/ 46 | 47 | /*Start: Profile Page*/ 48 | .information {margin-top: 20px} 49 | .information ul {padding: 0; margin: 0} 50 | .information ul li {padding: 10px} 51 | .information ul li:nth-child(odd) {background-color: #eee} 52 | .information ul li span {display: inline-block; width: 128px} 53 | .thumbnail .date {text-align: right; font-size: 13px; color: #aaa; font-weight: bold} 54 | .information .btn {margin-top: 10px} 55 | /*End: Profile Page*/ 56 | 57 | /*Start: Show Items Page*/ 58 | .item-info h2 {padding: 10px; margin: 0} 59 | .item-info p {padding: 10px} 60 | .item-info ul li {padding: 10px} 61 | .item-info li:nth-child(odd) {background-color: #e8e8e8} 62 | .item-info ul li span {display: inline-block; width: 120px} 63 | .tags-items a {display: inline-block; background-color: #e2e2e2; padding: 2px 10px; border-radius: 5px; color: #666; margin-right: 5px} 64 | .add-comment h3 {margin: 0 0 10px} 65 | .add-comment textarea {display: block; margin-bottom: 10px; width: 500px; height: 120px} 66 | .comment-box {margin-bottom: 20px} 67 | .comment-box img {max-width: 100px; margin-bottom: 10px} 68 | .comment-box .lead {background-color: #e0e0e0; padding: 10px; margin-top: 25px; position: relative} 69 | .comment-box .lead::before {content: ""; width: 0; height: 0; border-width: 15px; border-style: solid; border-color: transparent #e0e0e0 transparent transparent; position: absolute; left: -28px; top: 10px} 70 | /*End: Show Items Page*/ -------------------------------------------------------------------------------- /layout/css/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/css/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /layout/css/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/css/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /layout/css/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/css/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /layout/css/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/css/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /layout/css/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/css/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /layout/css/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/css/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /layout/css/jquery.selectBoxIt.css: -------------------------------------------------------------------------------- 1 | /* 2 | * jquery.selectBoxIt.css 3.8.1 3 | * Author: @gregfranko 4 | */ 5 | 6 | /* 7 | Common CSS Properties 8 | --------------------- 9 | These properties will be applied to any themes that you use 10 | */ 11 | 12 | /* SelectBoxIt container */ 13 | .selectboxit-container { 14 | width: 100%; 15 | position: relative; 16 | display: inline-block; 17 | vertical-align: top; 18 | } 19 | 20 | /* Styles that apply to all SelectBoxIt elements */ 21 | .selectboxit-container * { 22 | font: 14px Helvetica, Arial; 23 | /* Prevents text selection */ 24 | -webkit-touch-callout: none; 25 | -webkit-user-select: none; 26 | -khtml-user-select: none; 27 | -moz-user-select: -moz-none; 28 | -ms-user-select: none; 29 | -o-user-select: none; 30 | user-select: none; 31 | outline: none; 32 | white-space: nowrap; 33 | } 34 | 35 | /* Button */ 36 | .selectboxit-container .selectboxit { 37 | width: 100%; /* Width of the dropdown button */ 38 | cursor: pointer; 39 | margin: 0; 40 | padding: 0; 41 | border-radius: 6px; 42 | overflow: hidden; 43 | display: block; 44 | position: relative; 45 | } 46 | 47 | /* Height and Vertical Alignment of Text */ 48 | .selectboxit-container span, .selectboxit-container .selectboxit-options a { 49 | height: 30px; /* Height of the drop down */ 50 | line-height: 30px; /* Vertically positions the drop down text */ 51 | display: block; 52 | } 53 | 54 | /* Focus pseudo selector */ 55 | .selectboxit-container .selectboxit:focus { 56 | outline: 0; 57 | } 58 | 59 | /* Disabled Mouse Interaction */ 60 | .selectboxit.selectboxit-disabled, .selectboxit-options .selectboxit-disabled { 61 | opacity: 0.65; 62 | filter: alpha(opacity=65); 63 | -webkit-box-shadow: none; 64 | -moz-box-shadow: none; 65 | box-shadow: none; 66 | cursor: default; 67 | } 68 | 69 | /* Button Text */ 70 | .selectboxit-text { 71 | text-indent: 5px; 72 | overflow: hidden; 73 | text-overflow: ellipsis; 74 | float: left; 75 | } 76 | 77 | .selectboxit .selectboxit-option-icon-container { 78 | margin-left: 5px; 79 | } 80 | 81 | /* Options List */ 82 | .selectboxit-container .selectboxit-options { 83 | -moz-box-sizing: border-box; 84 | box-sizing: border-box; 85 | box-sizing: content-box\9; 86 | min-width: 100%; /* Minimum Width of the dropdown list box options */ 87 | margin: 0; 88 | padding: 0; 89 | list-style: none; 90 | position: absolute; 91 | overflow-x: hidden; 92 | overflow-y: auto; 93 | cursor: pointer; 94 | display: none; 95 | z-index: 9999999999999; 96 | border-radius: 6px; 97 | text-align: left; 98 | -webkit-box-shadow: none; 99 | -moz-box-shadow: none; 100 | box-shadow: none; 101 | } 102 | 103 | /* Individual options */ 104 | .selectboxit-option .selectboxit-option-anchor{ 105 | padding: 0 2px; 106 | } 107 | 108 | /* Individual Option Hover Action */ 109 | .selectboxit-option .selectboxit-option-anchor:hover { 110 | text-decoration: none; 111 | } 112 | 113 | /* Individual Option Optgroup Header */ 114 | .selectboxit-option, .selectboxit-optgroup-header { 115 | text-indent: 5px; /* Horizontal Positioning of the select box option text */ 116 | margin: 0; 117 | list-style-type: none; 118 | } 119 | 120 | /* The first Drop Down option */ 121 | .selectboxit-option-first { 122 | border-top-right-radius: 6px; 123 | border-top-left-radius: 6px; 124 | } 125 | 126 | /* The first Drop Down option optgroup */ 127 | .selectboxit-optgroup-header + .selectboxit-option-first { 128 | border-top-right-radius: 0px; 129 | border-top-left-radius: 0px; 130 | } 131 | 132 | /* The last Drop Down option */ 133 | .selectboxit-option-last { 134 | border-bottom-right-radius: 6px; 135 | border-bottom-left-radius: 6px; 136 | } 137 | 138 | /* Drop Down optgroup headers */ 139 | .selectboxit-optgroup-header { 140 | font-weight: bold; 141 | } 142 | 143 | /* Drop Down optgroup header hover psuedo class */ 144 | .selectboxit-optgroup-header:hover { 145 | cursor: default; 146 | } 147 | 148 | /* Drop Down down arrow container */ 149 | .selectboxit-arrow-container { 150 | /* Positions the down arrow */ 151 | width: 30px; 152 | position: absolute; 153 | right: 0; 154 | } 155 | 156 | /* Drop Down down arrow */ 157 | .selectboxit .selectboxit-arrow-container .selectboxit-arrow { 158 | /* Horizontally centers the down arrow */ 159 | margin: 0 auto; 160 | position: absolute; 161 | top: 50%; 162 | right: 0; 163 | left: 0; 164 | } 165 | 166 | /* Drop Down down arrow for jQueryUI and jQuery Mobile */ 167 | .selectboxit .selectboxit-arrow-container .selectboxit-arrow.ui-icon { 168 | top: 30%; 169 | } 170 | 171 | /* Drop Down individual option icon positioning */ 172 | .selectboxit-option-icon-container { 173 | float: left; 174 | } 175 | 176 | .selectboxit-container .selectboxit-option-icon { 177 | margin: 0; 178 | padding: 0; 179 | vertical-align: middle; 180 | } 181 | 182 | /* Drop Down individual option icon positioning */ 183 | .selectboxit-option-icon-url { 184 | width: 18px; 185 | background-size: 18px 18px; 186 | background-repeat: no-repeat; 187 | height: 100%; 188 | background-position: center; 189 | float: left; 190 | } 191 | 192 | .selectboxit-rendering { 193 | display: inline-block !important; 194 | *display: inline !important; 195 | zoom: 1 !important; 196 | visibility: visible !important; 197 | position: absolute !important; 198 | top: -9999px !important; 199 | left: -9999px !important; 200 | } 201 | 202 | /* jQueryUI and jQuery Mobile compatability fix - Feel free to remove this style if you are not using jQuery Mobile */ 203 | .jqueryui .ui-icon { 204 | background-color: inherit; 205 | } 206 | 207 | /* Another jQueryUI and jQuery Mobile compatability fix - Feel free to remove this style if you are not using jQuery Mobile */ 208 | .jqueryui .ui-icon-triangle-1-s { 209 | background-position: -64px -16px; 210 | } 211 | 212 | /* 213 | Default Theme 214 | ------------- 215 | Note: Feel free to remove all of the CSS underneath this line if you are not using the default theme 216 | */ 217 | .selectboxit-btn { 218 | background-color: #f5f5f5; 219 | background-image: -moz-linear-gradient(top, #ffffff, #e6e6e6); 220 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#ffffff), to(#e6e6e6)); 221 | background-image: -webkit-linear-gradient(top, #ffffff, #e6e6e6); 222 | background-image: -o-linear-gradient(top, #ffffff, #e6e6e6); 223 | background-image: linear-gradient(to bottom, #ffffff, #e6e6e6); 224 | background-repeat: repeat-x; 225 | border: 1px solid #cccccc; 226 | border-color: #e6e6e6 #e6e6e6 #bfbfbf; 227 | border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); 228 | border-bottom-color: #b3b3b3; 229 | } 230 | 231 | .selectboxit-btn.selectboxit-enabled:hover, 232 | .selectboxit-btn.selectboxit-enabled:focus, 233 | .selectboxit-btn.selectboxit-enabled:active { 234 | color: #333333; 235 | background-color: #e6e6e6; 236 | } 237 | 238 | .selectboxit-btn.selectboxit-enabled:hover, 239 | .selectboxit-btn.selectboxit-enabled:focus { 240 | color: #333333; 241 | text-decoration: none; 242 | background-position: 0 -15px; 243 | } 244 | 245 | .selectboxit-default-arrow { 246 | width: 0; 247 | height: 0; 248 | border-top: 4px solid #000000; 249 | border-right: 4px solid transparent; 250 | border-left: 4px solid transparent; 251 | } 252 | 253 | .selectboxit-list { 254 | background-color: #ffffff; 255 | border: 1px solid #ccc; 256 | border: 1px solid rgba(0, 0, 0, 0.2); 257 | -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); 258 | -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); 259 | box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); 260 | } 261 | 262 | .selectboxit-list .selectboxit-option-anchor { 263 | color: #333333; 264 | } 265 | 266 | .selectboxit-list > .selectboxit-focus > .selectboxit-option-anchor { 267 | color: #ffffff; 268 | background-color: #0081c2; 269 | background-image: -moz-linear-gradient(top, #0088cc, #0077b3); 270 | background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); 271 | background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); 272 | background-image: -o-linear-gradient(top, #0088cc, #0077b3); 273 | background-image: linear-gradient(to bottom, #0088cc, #0077b3); 274 | background-repeat: repeat-x; 275 | } 276 | 277 | .selectboxit-list > .selectboxit-disabled > .selectboxit-option-anchor { 278 | color: #999999; 279 | } 280 | -------------------------------------------------------------------------------- /layout/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /layout/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /layout/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /layout/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /layout/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /layout/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /layout/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /layout/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /layout/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AhmedYahyaE/plain-php-ecommerce/fd702ac49e2145fa918e32237b13271a78764485/layout/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /layout/js/front.js: -------------------------------------------------------------------------------- 1 | // The jQuery of the "Frontend Section" of the website 2 | 3 | 4 | 5 | /* global $, confirm */ 6 | $(function () { 7 | 'use strict'; 8 | 9 | 10 | 11 | // Switching between Login or Signup forms. Check eCommerce\login.php 12 | $('.login-page h1 span').click(function () { 13 | // console.log($(this)); 14 | 15 | 16 | $(this).addClass('selected').siblings().removeClass('selected'); // Add the .selected CSS class to the clicked , and remove it from the other siblings (the other -s) at the same time (switch adding the .selected CSS class to the Login and Signup ) // This is used for coloring the .selected CSS class . Check front.css file 17 | 18 | $('.login-page form').hide(); // Hide BOTH Login and Signup HTML Forms 19 | 20 | // Show the clicked HTML Form whether the Login or Signup Form 21 | // console.log($(this)); // Using Custom HTML data-* Attributes // '.login' or '.signup' 22 | // console.log($(this).data('class')); // Using Custom HTML data-* Attributes // '.login' or '.signup' 23 | 24 | // console.log('.' + $(this).data('class')); // Using Custom HTML data-* Attributes // '.login' or '.signup' 25 | // console.log($('.' + $(this).data('class'))); // Using Custom HTML data-* Attributes // '.login' or '.signup' 26 | 27 | $('.' + $(this).data('class')).fadeIn(100); // Using Custom HTML data-* Attributes // '.login' or '.signup' 28 | }); 29 | 30 | 31 | 32 | // Triggering (firing) the SelectBoxIt Plugin (for all Select Boxes in my application) 33 | $("select").selectBoxIt({ 34 | autoWidth: false 35 | }); 36 | 37 | 38 | 39 | // Hiding placeholder upon form focus 40 | $('[placeholder]').focus(function () { 41 | 42 | $(this).attr('data-text', $(this).attr('placeholder')); // storing the placeholder attribute value in a Custom HTML data-* Attribute data-text 43 | $(this).attr('placeholder', ''); // hiding the placeholder upon focus 44 | 45 | }).blur(function () { 46 | $(this).attr('placeholder', $(this).attr('data-text')); // Or $(this).attr('placeholder', $(this).data('text')); 47 | }); 48 | 49 | 50 | 51 | 52 | // Form Validation 53 | // Adding an Asterisk * on the required fields 54 | $('input').each(function () { 55 | if ($(this).attr('required') === 'required') { // Or the same code: if ($(this).prop('required') === true) { 56 | $(this).after('*'); 57 | } 58 | }); 59 | 60 | 61 | 62 | // Confirmation message when Delete button in members.php is clicked 63 | $('.confirm').click(function () { 64 | return confirm('Are You Sure?'); 65 | }); 66 | 67 | 68 | 69 | // Newad.php Page (Beautiful Live Show) 70 | /****** 71 | $('.live-name').keyup(function () { 72 | // console.log($(this).val()); 73 | $('.live-preview h3').text($(this).val()); 74 | }); 75 | $('.live-desc').keyup(function () { 76 | // console.log($(this).val()); 77 | $('.live-preview p').text($(this).val()); 78 | }); 79 | $('.live-price').keyup(function () { 80 | // console.log($(this).val()); 81 | $('.live-preview .price-tag').text('$' + $(this).val()); 82 | }); 83 | ******/ 84 | // TO REDUCE THE LAST CODE INTO ONE FUNCTION 85 | $('.live').keyup(function () { 86 | // console.log($(this).data('class')); // Here we are printing the classes themselves // Outputs are .live-name, .live-desc, .live-price 87 | // console.log($($(this).data('class'))); // Here we are selecting elements not printing the classes themselves as in the previous code line 88 | $($(this).data('class')).text($(this).val()); 89 | }); 90 | 91 | }); -------------------------------------------------------------------------------- /layout/js/jquery.selectBoxIt.min.js: -------------------------------------------------------------------------------- 1 | /*! jquery.selectBoxIt - v3.8.2 - 2017-12-06 2 | * http://www.selectboxit.com 3 | * Copyright (c) 2017 Greg Franko; Licensed MIT*/ 4 | !function(a){"use strict";a(window.jQuery,window,document)}(function(a,b,c,d){"use strict";a.widget("selectBox.selectBoxIt",{VERSION:"3.8.2",options:{showEffect:"none",showEffectOptions:{},showEffectSpeed:"medium",hideEffect:"none",hideEffectOptions:{},hideEffectSpeed:"medium",showFirstOption:!0,defaultText:"",defaultIcon:"",downArrowIcon:"",theme:"default",keydownOpen:!0,isMobile:function(){var a=navigator.userAgent||navigator.vendor||b.opera;return/iPhone|iPod|iPad|Silk|Android|BlackBerry|Opera Mini|IEMobile/.test(a)},"native":!1,aggressiveChange:!1,selectWhenHidden:!0,viewport:a(b),similarSearch:!1,copyAttributes:["title","rel"],dontCopyAttributes:["data-reactid"],copyClasses:"button",nativeMousedown:!1,customShowHideEvent:!1,autoWidth:!0,html:!0,populate:"",dynamicPositioning:!0,hideCurrent:!1,numSearchCharacters:"auto"},getThemes:function(){var b=this,c=a(b.element).attr("data-theme")||"c";return{bootstrap:{focus:"active",hover:"",enabled:"enabled",disabled:"disabled",arrow:"caret",button:"btn",list:"dropdown-menu",container:"bootstrap",open:"open"},jqueryui:{focus:"ui-state-focus",hover:"ui-state-hover",enabled:"ui-state-enabled",disabled:"ui-state-disabled",arrow:"ui-icon ui-icon-triangle-1-s",button:"ui-widget ui-state-default",list:"ui-widget ui-widget-content",container:"jqueryui",open:"selectboxit-open"},jquerymobile:{focus:"ui-btn-down-"+c,hover:"ui-btn-hover-"+c,enabled:"ui-enabled",disabled:"ui-disabled",arrow:"ui-icon ui-icon-arrow-d ui-icon-shadow",button:"ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-"+c,list:"ui-btn ui-btn-icon-right ui-btn-corner-all ui-shadow ui-btn-up-"+c,container:"jquerymobile",open:"selectboxit-open"},"default":{focus:"selectboxit-focus",hover:"selectboxit-hover",enabled:"selectboxit-enabled",disabled:"selectboxit-disabled",arrow:"selectboxit-default-arrow",button:"selectboxit-btn",list:"selectboxit-list",container:"selectboxit-container",open:"selectboxit-open"}}},isDeferred:function(b){return a.isPlainObject(b)&&b.promise&&b.done},_create:function(b){var d=this,e=d.options.populate,f=d.options.theme;if(d.element.is("select"))return d.widgetProto=a.Widget.prototype,d.originalElem=d.element[0],d.selectBox=d.element,d.options.populate&&d.add&&!b&&d.add(e),d.selectItems=d.element.find("option"),d.firstSelectItem=d.selectItems.slice(0,1),d.documentHeight=a(c).height(),d.theme=a.isPlainObject(f)?a.extend({},d.getThemes()["default"],f):d.getThemes()[f]?d.getThemes()[f]:d.getThemes()["default"],d.currentFocus=0,d.blur=!0,d.textArray=[],d.currentIndex=0,d.currentText="",d.flipped=!1,b||(d.selectBoxStyles=d.selectBox.attr("style")),d._createDropdownButton()._createUnorderedList()._copyAttributes()._replaceSelectBox()._addClasses(d.theme)._eventHandlers(),d.originalElem.disabled&&d.disable&&d.disable(),d._ariaAccessibility&&d._ariaAccessibility(),d.isMobile=d.options.isMobile(),d._mobile&&d._mobile(),d.options["native"]&&this._applyNativeSelect(),d.triggerEvent("create"),d},_createDropdownButton:function(){var b=this,c=b.originalElemId=b.originalElem.id||"",d=b.originalElemValue=b.originalElem.value||"",e=b.originalElemName=b.originalElem.name||"",f=b.options.copyClasses,g=b.selectBox.attr("class")||"";return b.dropdownText=a("",{id:c&&c+"SelectBoxItText","class":"selectboxit-text",unselectable:"on",text:b.firstSelectItem.text()}).attr("data-val",d),b.dropdownImageContainer=a("",{"class":"selectboxit-option-icon-container"}),b.dropdownImage=a("",{id:c&&c+"SelectBoxItDefaultIcon","class":"selectboxit-default-icon",unselectable:"on"}),b.dropdown=a("",{id:c&&c+"SelectBoxIt","class":"selectboxit "+("button"===f?g:"")+" "+(b.selectBox.prop("disabled")?b.theme.disabled:b.theme.enabled),name:e,tabindex:b.selectBox.attr("tabindex")||"0",unselectable:"on"}).append(b.dropdownImageContainer.append(b.dropdownImage)).append(b.dropdownText),b.dropdownContainer=a("",{id:c&&c+"SelectBoxItContainer","class":"selectboxit-container "+b.theme.container+" "+("container"===f?g:"")}).append(b.dropdown),b},_createUnorderedList:function(){var b,c,d,e,f,g,h,i,j,k,l,m,n,o=this,p="",q=o.originalElemId||"",r=a("
    ",{id:q&&q+"SelectBoxItOptions","class":"selectboxit-options",tabindex:-1});if(o.options.showFirstOption||(o.selectItems.first().attr("disabled","disabled"),o.selectItems=o.selectBox.find("option").slice(1)),o.selectItems.each(function(q){m=a(this),c="",d="",b=m.prop("disabled"),e=m.attr("data-icon")||"",f=m.attr("data-iconurl")||"",g=f?"selectboxit-option-icon-url":"",h=f?"style=\"background-image:url('"+f+"');\"":"",i=m.attr("data-selectedtext"),j=m.attr("data-text"),l=j?j:m.text(),n=m.parent(),n.is("optgroup")&&(c="selectboxit-optgroup-option",0===m.index()&&(d=''+n.first().attr("label")+"")),m.attr("value",this.value),p+=d+'
  • "+(o.options.html?l:o.htmlEscape(l))+"
  • ",k=m.attr("data-search"),o.textArray[q]=b?"":k?k:l,this.selected&&(o._setText(o.dropdownText,i||l),o.currentFocus=q)}),o.options.defaultText||o.selectBox.attr("data-text")){var s=o.options.defaultText||o.selectBox.attr("data-text");o._setText(o.dropdownText,s),o.options.defaultText=s}return r.append(p),o.list=r,o.dropdownContainer.append(o.list),o.listItems=o.list.children("li"),o.listAnchors=o.list.find("a"),o.listItems.first().addClass("selectboxit-option-first"),o.listItems.last().addClass("selectboxit-option-last"),o.list.find("li[data-disabled='true']").not(".optgroupHeader").addClass(o.theme.disabled),o.dropdownImage.addClass(o.selectBox.attr("data-icon")||o.options.defaultIcon||o.listItems.eq(o.currentFocus).find("i").attr("class")),o.dropdownImage.attr("style",o.listItems.eq(o.currentFocus).find("i").attr("style")),o},_replaceSelectBox:function(){var b,c,e,f=this,g=f.originalElem.id||"",h=f.selectBox.attr("data-size"),i=f.listSize=h===d?"auto":"0"===h?"auto":+h;return f.selectBox.css("display","none").after(f.dropdownContainer),f.dropdownContainer.appendTo("body").addClass("selectboxit-rendering"),b=f.dropdown.height(),f.downArrow=a("",{id:g&&g+"SelectBoxItArrow","class":"selectboxit-arrow",unselectable:"on"}),f.downArrowContainer=a("",{id:g&&g+"SelectBoxItArrowContainer","class":"selectboxit-arrow-container",unselectable:"on"}).append(f.downArrow),f.dropdown.append(f.downArrowContainer),f.listItems.removeClass("selectboxit-selected").eq(f.currentFocus).addClass("selectboxit-selected"),c=f.downArrowContainer.outerWidth(!0),e=f.dropdownImage.outerWidth(!0),f.options.autoWidth&&(f.dropdown.css({width:"auto"}).css({width:f.list.outerWidth(!0)+c+e}),f.list.css({"min-width":f.dropdown.width()})),f.selectBox.after(f.dropdownContainer),f.dropdownContainer.removeClass("selectboxit-rendering"),f.dropdownText.css({"max-width":f.dropdownContainer.outerWidth(!0)-(c+e)}),"number"===a.type(i)&&(f.maxHeight=f.listAnchors.outerHeight(!0)*i),f},_scrollToView:function(a){var b=this,c=b.listItems.eq(b.currentFocus),d=b.list.scrollTop(),e=c.height(),f=c.position().top,g=Math.abs(f),h=b.list.height();return"search"===a?e>h-f?b.list.scrollTop(d+(f-(h-e))):-1>f&&b.list.scrollTop(f-e):"up"===a?-1>f&&b.list.scrollTop(d-g):"down"===a&&e>h-f&&b.list.scrollTop(d+(g-h+e)),b},_callbackSupport:function(b){var c=this;return a.isFunction(b)&&b.call(c,c.dropdown),c},_setText:function(a,b){var c=this;return c.options.html?a.html(b):a.text(b),c},open:function(a){var b=this,c=b.options.showEffect,d=b.options.showEffectSpeed,e=b.options.showEffectOptions,f=b.options["native"],g=b.isMobile;return!b.listItems.length||b.dropdown.hasClass(b.theme.disabled)?b:(f||g||this.list.is(":visible")||(b.triggerEvent("open"),b._dynamicPositioning&&b.options.dynamicPositioning&&b._dynamicPositioning(),"none"===c?b.list.show():"show"===c||"slideDown"===c||"fadeIn"===c?b.list[c](d):b.list.show(c,e,d),b.list.promise().done(function(){b._scrollToView("search"),b.triggerEvent("opened")})),b._callbackSupport(a),b)},close:function(a){var b=this,c=b.options.hideEffect,d=b.options.hideEffectSpeed,e=b.options.hideEffectOptions,f=b.options["native"],g=b.isMobile;return f||g||!b.list.is(":visible")||(b.triggerEvent("close"),"none"===c?b.list.hide():"hide"===c||"slideUp"===c||"fadeOut"===c?b.list[c](d):b.list.hide(c,e,d),b.list.promise().done(function(){b.triggerEvent("closed")})),b._callbackSupport(a),b},toggle:function(){var a=this,b=a.list.is(":visible");b?a.close():b||a.open()},_keyMappings:{38:"up",40:"down",13:"enter",8:"backspace",9:"tab",32:"space",27:"esc"},_keydownMethods:function(){var a=this,b=a.list.is(":visible")||!a.options.keydownOpen;return{down:function(){a.moveDown&&b&&a.moveDown()},up:function(){a.moveUp&&b&&a.moveUp()},enter:function(){var b=a.listItems.eq(a.currentFocus);a._update(b),"true"!==b.attr("data-preventclose")&&a.close(),a.triggerEvent("enter")},tab:function(){a.triggerEvent("tab-blur"),a.close()},backspace:function(){a.triggerEvent("backspace")},esc:function(){a.close()}}},_eventHandlers:function(){var b,c,d=this,e=d.options.nativeMousedown,f=d.options.customShowHideEvent,g=d.focusClass,h=d.hoverClass,i=d.openClass;return this.dropdown.on({"click.selectBoxIt":function(){d.dropdown.trigger("focus",!0),d.originalElem.disabled||(d.triggerEvent("click"),e||f||d.toggle())},"mousedown.selectBoxIt":function(){a(this).data("mdown",!0),d.triggerEvent("mousedown"),e&&!f&&d.toggle()},"mouseup.selectBoxIt":function(){d.triggerEvent("mouseup")},"blur.selectBoxIt":function(){d.blur&&(d.triggerEvent("blur"),d.close(),a(this).removeClass(g))},"focus.selectBoxIt":function(b,c){var e=a(this).data("mdown");a(this).removeData("mdown"),e||c||setTimeout(function(){d.triggerEvent("tab-focus")},0),c||(a(this).hasClass(d.theme.disabled)||a(this).addClass(g),d.triggerEvent("focus"))},"keydown.selectBoxIt":function(a){var b=d._keyMappings[a.keyCode],c=d._keydownMethods()[b];c&&(c(),!d.options.keydownOpen||"up"!==b&&"down"!==b||d.open()),c&&"tab"!==b&&a.preventDefault()},"keypress.selectBoxIt":function(a){if(!d.originalElem.disabled){var b=a.charCode||a.keyCode,c=d._keyMappings[a.charCode||a.keyCode],e=String.fromCharCode(b);d.search&&(!c||c&&"space"===c)&&d.search(e,!0,!0),"space"===c&&a.preventDefault()}},"mouseenter.selectBoxIt":function(){d.triggerEvent("mouseenter")},"mouseleave.selectBoxIt":function(){d.triggerEvent("mouseleave")}}),d.list.on({"mouseover.selectBoxIt":function(){d.blur=!1},"mouseout.selectBoxIt":function(){d.blur=!0},"focusin.selectBoxIt":function(){d.dropdown.trigger("focus",!0)}}),d.list.on({"mousedown.selectBoxIt":function(){d._update(a(this)),d.triggerEvent("option-click"),"false"===a(this).attr("data-disabled")&&"true"!==a(this).attr("data-preventclose")&&d.close(),setTimeout(function(){d.dropdown.trigger("focus",!0)},0)},"focusin.selectBoxIt":function(){d.listItems.not(a(this)).removeAttr("data-active"),a(this).attr("data-active","");var b=d.list.is(":hidden");(d.options.searchWhenHidden&&b||d.options.aggressiveChange||b&&d.options.selectWhenHidden)&&d._update(a(this)),a(this).addClass(g)},"mouseup.selectBoxIt":function(){e&&!f&&(d._update(a(this)),d.triggerEvent("option-mouseup"),"false"===a(this).attr("data-disabled")&&"true"!==a(this).attr("data-preventclose")&&d.close())},"mouseenter.selectBoxIt":function(){"false"===a(this).attr("data-disabled")&&(d.listItems.removeAttr("data-active"),a(this).addClass(g).attr("data-active",""),d.listItems.not(a(this)).removeClass(g),a(this).addClass(g),d.currentFocus=+a(this).attr("data-id"))},"mouseleave.selectBoxIt":function(){"false"===a(this).attr("data-disabled")&&(d.listItems.not(a(this)).removeClass(g).removeAttr("data-active"),a(this).addClass(g),d.currentFocus=+a(this).attr("data-id"))},"blur.selectBoxIt":function(){a(this).removeClass(g)}},".selectboxit-option"),d.list.on({"click.selectBoxIt":function(a){a.preventDefault()}},"a"),d.selectBox.on({"change.selectBoxIt, internal-change.selectBoxIt":function(a,e){var f,g;e||(f=d.list.find('li[data-val="'+d.originalElem.value+'"]'),f.length&&(d.listItems.eq(d.currentFocus).removeClass(d.focusClass),d.currentFocus=+f.attr("data-id"))),f=d.listItems.eq(d.currentFocus),g=f.attr("data-selectedtext"),b=f.attr("data-text"),c=b?b:f.find("a").text(),d._setText(d.dropdownText,g||c),d.dropdownText.attr("data-val",d.originalElem.value),f.find("i").attr("class")&&(d.dropdownImage.attr("class",f.find("i").attr("class")).addClass("selectboxit-default-icon"),d.dropdownImage.attr("style",f.find("i").attr("style"))),d.triggerEvent("changed")},"disable.selectBoxIt":function(){d.dropdown.addClass(d.theme.disabled)},"enable.selectBoxIt":function(){d.dropdown.removeClass(d.theme.disabled)},"open.selectBoxIt":function(){var a,b=d.list.find("li[data-val='"+d.dropdownText.attr("data-val")+"']");b.length||(b=d.listItems.not("[data-disabled=true]").first()),d.currentFocus=+b.attr("data-id"),a=d.listItems.eq(d.currentFocus),d.dropdown.addClass(i).removeClass(h).addClass(g),d.listItems.removeClass(d.selectedClass).removeAttr("data-active").not(a).removeClass(g),a.addClass(d.selectedClass).addClass(g),d.options.hideCurrent&&a.hide().promise().done(function(){d.listItems.show()})},"close.selectBoxIt":function(){d.dropdown.removeClass(i)},"blur.selectBoxIt":function(){d.dropdown.removeClass(g)},"mouseenter.selectBoxIt":function(){a(this).hasClass(d.theme.disabled)||d.dropdown.addClass(h)},"mouseleave.selectBoxIt":function(){d.dropdown.removeClass(h)},destroy:function(a){a.preventDefault(),a.stopPropagation()}}),d},_update:function(a){var b,c,d,e=this,f=e.options.defaultText||e.selectBox.attr("data-text"),g=e.listItems.eq(e.currentFocus);"false"===a.attr("data-disabled")&&(b=e.listItems.eq(e.currentFocus).attr("data-selectedtext"),c=g.attr("data-text"),d=c?c:g.text(),(f&&e.options.html?e.dropdownText.html()===f:e.dropdownText.text()===f)&&e.selectBox.val()===a.attr("data-val")?e.triggerEvent("change"):(e.selectBox.val(a.attr("data-val")),e.currentFocus=+a.attr("data-id"),e.originalElem.value!==e.dropdownText.attr("data-val")&&e.triggerEvent("change")))},_addClasses:function(a){{var b=this,c=(b.focusClass=a.focus,b.hoverClass=a.hover,a.button),d=a.list,e=a.arrow,f=a.container;b.openClass=a.open}return b.selectedClass="selectboxit-selected",b.downArrow.addClass(b.selectBox.attr("data-downarrow")||b.options.downArrowIcon||e),b.dropdownContainer.addClass(f),b.dropdown.addClass(c),b.list.addClass(d),b},refresh:function(a,b){var c=this;return c._destroySelectBoxIt()._create(!0),b||c.triggerEvent("refresh"),c._callbackSupport(a),c},htmlEscape:function(a){return String(a).replace(/&/g,"&").replace(/"/g,""").replace(/'/g,"'").replace(//g,">")},triggerEvent:function(a){var b=this,c=b.options.showFirstOption?b.currentFocus:b.currentFocus-1>=0?b.currentFocus:0;return b.selectBox.trigger(a,{selectbox:b.selectBox,selectboxOption:b.selectItems.eq(c),dropdown:b.dropdown,dropdownOption:b.listItems.eq(b.currentFocus)}),b},_copyAttributes:function(){var a=this;return a._addSelectBoxAttributes&&a._addSelectBoxAttributes(),a},_realOuterWidth:function(a){if(a.is(":visible"))return a.outerWidth(!0);var b,c=a.clone();return c.css({visibility:"hidden",display:"block",position:"absolute"}).appendTo("body"),b=c.outerWidth(!0),c.remove(),b}});var e=a.selectBox.selectBoxIt.prototype;e.add=function(b,c){this._populate(b,function(b){var d,e,f=this,g=a.type(b),h=0,i=[],j=f._isJSON(b),k=j&&f._parseJSON(b);if(b&&("array"===g||j&&k.data&&"array"===a.type(k.data))||"object"===g&&b.data&&"array"===a.type(b.data)){for(f._isJSON(b)&&(b=k),b.data&&(b=b.data),e=b.length;e-1>=h;h+=1)d=b[h],a.isPlainObject(d)?i.push(a("