├── Chatbot-PHP
├── PHP-chatbot
│ ├── administrator
│ │ └── components
│ │ │ └── com_chatter
│ │ │ ├── chatter.php
│ │ │ ├── controller.php
│ │ │ ├── index.html
│ │ │ ├── install.sql
│ │ │ ├── uninstall.sql
│ │ │ └── update.sql
│ ├── chatter.xml
│ ├── components
│ │ └── com_chatter
│ │ │ ├── chatter.php
│ │ │ ├── controller.php
│ │ │ ├── index.html
│ │ │ ├── models
│ │ │ └── chatter.php
│ │ │ ├── simple_html_dom.php
│ │ │ └── views
│ │ │ └── chatter
│ │ │ ├── tmpl
│ │ │ ├── default.php
│ │ │ └── default_guest_view.php
│ │ │ └── view.html.php
│ └── media
│ │ ├── css
│ │ ├── chatter.css
│ │ └── index.html
│ │ ├── images
│ │ └── index.html
│ │ ├── index.html
│ │ └── js
│ │ ├── frontend.js
│ │ ├── index.html
│ │ └── jquery-3.4.0.min.js
└── README.md
├── Ecommerce-website-PHP
├── DataBase
│ └── shop.sql
├── README.md
└── Website
│ └── admin
│ ├── categories.php
│ ├── comments.php
│ ├── connect.php
│ ├── copy_template.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.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
├── Email-System-Php
├── License.md
├── MYSQL FILES
│ ├── furkan.sql
│ ├── jack.sql
│ ├── oliver.sql
│ └── users_july.sql
├── README.md
├── add.php
├── connect.php
├── createTable.php
├── homepage
│ └── homepage.php
├── index.php
├── loginPage
│ └── login.php
├── navbar.php
├── pages
│ ├── Inbox.php
│ └── newMessage.php
├── register
│ └── register.php
└── styleFile
│ ├── inbox.css
│ ├── navbar.css
│ ├── newMessage.css
│ └── style.css
├── Star-Rating-System-PHP
├── README.md
├── action.php
├── class
│ └── Rating.php
├── css
│ └── style.css
├── db
│ ├── product.sql
│ ├── product_rating.sql
│ └── product_users.sql
├── image
│ ├── chicken.png
│ ├── frog.png
│ ├── home.png
│ ├── product-detail.png
│ └── product-rating.png
├── inc
│ ├── header.php
│ ├── index_content.php
│ ├── navbar.php
│ └── product_detail_content.php
├── index.php
├── js
│ └── rating.js
├── layout
│ └── app.php
└── product_detail.php
└── Student-management-system
├── Admin
├── addstudent.php
├── admindash.php
├── deleteform.php
├── deletestudent.php
├── header.php
├── titleheader.php
├── updatedata.php
├── updateform.php
└── updatestudent.php
├── README.md
├── css
└── style.css
├── dataimg
├── abc.bmp
└── image (2).png
├── dbcon.php
├── function.php
├── index.php
├── login.php
└── logout.php
/Chatbot-PHP/PHP-chatbot/administrator/components/com_chatter/chatter.php:
--------------------------------------------------------------------------------
1 | execute(JRequest::getCMd('task'));
10 |
11 | $controller->redirect();
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/administrator/components/com_chatter/controller.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/administrator/components/com_chatter/install.sql:
--------------------------------------------------------------------------------
1 | -- Tables to be created - 1. Messeges, 2. Blocked Users --
2 |
3 | CREATE TABLE IF NOT EXISTS `#__chatter_msgs`(
4 | id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
5 | userid INT(10) NOT NULL,
6 | msgs TEXT,
7 | datime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
8 | );
9 |
10 | CREATE TABLE IF NOT EXISTS `#__chatter_block_usr`(
11 | id INT(10) NOT NULL AUTO_INCREMENT PRIMARY KEY,
12 | userid INT(10) NOT NULL,
13 | datime TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
14 | );
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/administrator/components/com_chatter/uninstall.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS `#__chatter_msgs`;
2 |
3 | DROP TABLE IF EXISTS `#__chatter_block_usr`;
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/administrator/components/com_chatter/update.sql:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/engineers-planet/PHP_Free_Downloads/ba8be31590052331a602e970dd2a14ad528c6420/Chatbot-PHP/PHP-chatbot/administrator/components/com_chatter/update.sql
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/chatter.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com_chatter
4 | Harshawardhan Natu
5 | 1.0.0
6 | This is chat component
7 |
8 |
9 | images
10 | css
11 | js
12 | index.html
13 |
14 |
15 |
16 | chatter.php
17 | index.html
18 | controller.php
19 | simple_html_dom.php
20 | views
21 | models
22 |
23 |
24 |
25 |
26 | install.sql
27 |
28 |
29 |
30 |
31 |
32 | uninstall.sql
33 |
34 |
35 |
36 |
37 |
38 | update.sql
39 |
40 |
41 |
42 |
43 |
44 |
45 | chatter.php
46 | index.html
47 | controller.php
48 | install.sql
49 | uninstall.sql
50 | update.sql
51 |
52 |
53 | Chat Options
54 |
55 |
56 | Chat History
57 | Block User
58 |
59 |
60 |
61 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/chatter.php:
--------------------------------------------------------------------------------
1 | execute(JRequest::getCmd('task'));
10 |
11 | $controller->redirect();
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/controller.php:
--------------------------------------------------------------------------------
1 | addStyleSheet(JURI::root().'media/com_chatter/css/chatter.css'); # Link custom CSS file
21 | $doc->addScript(JURI::root().'media/com_chatter/js/jquery-3.4.0.min.js'); # Link the jQuery file
22 | $doc->addScript(JURI::root().'media/com_chatter/js/frontend.js'); # Link custom JS file
23 |
24 | if(!JRequest::getVar('view'))
25 | {
26 | JRequest::setVar('view','chatter');
27 | }
28 |
29 | parent::display();
30 | }
31 |
32 |
33 | /**
34 | * Function to send the input message as ajax request in form of JSON object.
35 | */
36 | function getMsgRequest() # Function to get input from user and send ajax request as JSON
37 | {
38 | $app = JFactory::getApplication();
39 | $msg = JRequest::getString('msg');
40 | $user = JFactory::getUser()->id;
41 |
42 |
43 | $res = array();
44 |
45 | if($user == 0) # Check if the user is logged in or not
46 | {
47 | $res['status'] = false;
48 | $res['msg'] = 'Please login first!';
49 | echo json_encode($res);
50 | exit();
51 | }
52 |
53 | if($msg == "") # Check if the input is blank/null
54 | {
55 | $res['status'] = false;
56 | $res['msg'] = 'Please enter message!';
57 | echo json_encode($res);
58 | exit();
59 | }
60 |
61 | if($chatID = $this->chatToDb($msg,$user)) # 1. Call to insert input msg from user and get last
62 | { # inserted ID.
63 | $msgDtl = $this->showLastMsg($chatID); # 2. Call to fetch the msg using last inserted ID.
64 | $res['chatDetails'] = $msgDtl;
65 | $res['status'] = true;
66 | }
67 | else
68 | {
69 | $res['status'] = false;
70 | }
71 | echo json_encode($res); # Sending JSON encoded data with status check
72 | $app->close();
73 | }
74 |
75 |
76 | /**
77 | * Function to insert and store the last msg input by user.
78 | *
79 | * @param string $msg
80 | * The string input from user.
81 | *
82 | * @param int $user
83 | * The user id from which the message was inserted.
84 | *
85 | * @return int $inserted_id
86 | * The id of last successfully inserted row.
87 | */
88 | function chatToDb($msg, $user)
89 | {
90 | $model = $this->getModel('Chatter'); # Getting model instance of 'Chatter' model
91 | $inserted_id = $model->insert($msg, $user); # get last insert id
92 |
93 | return $inserted_id;
94 | }
95 |
96 |
97 | /**
98 | * Function to select last inserted chat msg w.r.t last inserted ID.
99 | *
100 | * @param int $id
101 | * The last inserted row ID returned from the above function 'chatToDb'.
102 | *
103 | * @return array $lastIns
104 | * Array containing the message, user id w.r.t last inserted id.
105 | */
106 | private function showLastMsg($id)
107 | {
108 | $model = $this->getModel('Chatter'); # Getting model instance of 'Chatter' model
109 | $lastIns = $model->selectLastInserted($id); # get msg of last inserted id
110 |
111 | return $lastIns;
112 | }
113 |
114 |
115 | /**
116 | * Function to scrap html from any URL.
117 | *
118 | * @param string $url
119 | * The URL from which the data is to be scraped.
120 | *
121 | * @return object $html_output
122 | * The html parsed from the URL passed using cURL.
123 | */
124 | //
125 | function scrapHTML($url)
126 | {
127 | if(!function_exists('curl_init'))
128 | {
129 | die('cURL is not installed. Please install!');
130 | }
131 |
132 | $options = Array(
133 | CURLOPT_RETURNTRANSFER => TRUE, // Setting cURL's option to return the webpage data
134 | CURLOPT_FOLLOWLOCATION => TRUE, // Setting cURL to follow 'location' HTTP headers
135 | CURLOPT_AUTOREFERER => TRUE, // Automatically set the referer where following 'location' HTTP headers
136 | CURLOPT_CONNECTTIMEOUT => 120, // Setting the amount of time (in seconds) before the request times out
137 | CURLOPT_TIMEOUT => 120, // Setting the maximum amount of time for cURL to execute queries
138 | CURLOPT_MAXREDIRS => 10, // Setting the maximum number of redirections to follow
139 | CURLOPT_USERAGENT => "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8", // Setting the useragent
140 | CURLOPT_URL => $url, // Setting cURL's URL option with the $url variable passed into the function
141 | );
142 |
143 | $curl = curl_init();
144 | curl_setopt_array($curl, $options);
145 | $html_output = curl_exec($curl);
146 |
147 | if(curl_errno($curl))
148 | {
149 | $curl_err = "Scraping error : ".curl_error($curl);
150 |
151 | var_dump($curl_err);
152 | exit();
153 | }
154 |
155 | curl_close($curl);
156 |
157 | return $html_output;
158 | }
159 |
160 |
161 | /**
162 | * Function for checking for a response of msg entered.
163 | */
164 | function checkForResponse()
165 | {
166 | $app = JFactory::getApplication();
167 | $msg=JRequest::getVar('msg'); # Getting request from JS with msg-content
168 |
169 |
170 | $res = array();
171 |
172 | #-------------------------- Predefined commands ---------------------------------------------#
173 |
174 | $greets = array('hi','hey','hello','hola','hey there', 'hi there', 'hello there','namaste','bonjour');
175 |
176 | $abouts = array('how are you','hi how are you','hey how are you', 'hello how are you','how are you today','how are you feeling',' how are you feeling today','how are you doing','how you doin');
177 |
178 | $whos = array('who are you', 'whats your name', 'who am I talking to', 'what are you', 'what is your name','what are you called','what do people call you');
179 |
180 | $byes = array('bye','until next time','bye bye','good bye','see you soon','chao','goodbye','catch you later','see you next time','see you later');
181 |
182 | $locate = array('location','my current location','my location','current location','where am i', 'what is my location', 'what is my current location', 'whats my location','whats my current location', 'get my location', 'what is this place');
183 |
184 | $weather = array('weather','how is the weather today','how is the weather right now','weather right now','current weather','current weather conditions','how is the weather','weather conditions','weather forecast');
185 |
186 | $times = array('current time', 'what is the time right now', 'time right now', 'tell me the time', 'what is the time', 'whats the time', 'whats the time right now');
187 |
188 | $dates = array('what is the date today','todays date','what is the date','whats the date','whats the date today','current date','date today');
189 |
190 | $day_ask = array('todays day','what is the day today','current day','the day today','current day','day today');
191 |
192 | $helper_cmd = array('commands','chatbot help','help for chatbot','help us','all commands');
193 |
194 | #--------------------------------------------------------------------------------------------#
195 |
196 | #--------------------------- Bot Responses --------------------------------------------------#
197 |
198 | $about_resp = array('i am fine.', 'i am doing great.', 'i\'m fine, thank you.', 'i am doing good and am glad you asked, thank you.','everything is good, thank you.', 'everything is great.', 'everything Seems good.');
199 |
200 | $whos_resp = array('My name is bot.','I am the bot, your helping hand.','The name is bot... Chat Bot!','I am the bot.','People call me bot.');
201 |
202 | #---------------------------------------------------------------------------------------------#
203 |
204 | $msg_ext = strtolower($msg);
205 | $msg_arr = explode(' ', $msg_ext);
206 |
207 | $msg = strtolower(trim(str_replace(array('/','?','!',';',',','.','@','$','#','*','^','%','~','%','(',')','{','}','[',']',':','&','"','\'','<','>','\\'), '', $msg)));
208 |
209 | $Bot = 'BOT';
210 | $resp = '';
211 |
212 | $respDtl = array();
213 |
214 |
215 | if(in_array($msg, $greets)) # Check for greetings
216 | {
217 | $resp = array_rand($greets);
218 | $resp=$greets[$resp].' !';
219 | }
220 | else if(in_array($msg,$abouts)) # Check for abouts
221 | {
222 | $resp = array_rand($about_resp);
223 | $resp=$about_resp[$resp];
224 | }
225 | else if(in_array($msg, $whos)) # Check for whos
226 | {
227 | $resp = array_rand($whos_resp);
228 | $resp=$whos_resp[$resp];
229 | }
230 | else if(in_array($msg, $byes)) # Check for Byes
231 | {
232 | $resp = array_rand($byes);
233 | $resp=$byes[$resp];
234 | }
235 | else if(in_array($msg, $times)) # Check for current time
236 | {
237 | $curr_time = date('h:i:s A');
238 | $resp = "current time is : ".$curr_time;
239 | }
240 | else if(in_array($msg, $dates)) # Check for current date
241 | {
242 | $curr_date = date('F d, Y');
243 | $resp = "Date today is : ".$curr_date;
244 | }
245 | else if(in_array($msg, $day_ask)) # Check for current day
246 | {
247 | $curr_day = date('l');
248 | $resp = "Day today is : ".$curr_day;
249 | }
250 | else if(in_array($msg, $locate)) # Check for current location : Based on IP
251 | {
252 | $locate_url = 'http://ip-api.com/json/';
253 | $curr_loc = json_decode(file_get_contents($locate_url));
254 | $locate_data = array($curr_loc->city, $curr_loc->regionName, $curr_loc->country);
255 |
256 | $resp = implode(', ', $locate_data);
257 | }
258 | else if(in_array($msg, $weather)) # Check for weather w.r.t current location
259 | {
260 | $app = JFactory::getApplication();
261 | $locate_url = 'http://ip-api.com/json/';
262 | $curr_loc = json_decode(file_get_contents($locate_url));
263 | $curr_city = $curr_loc->city;
264 | $curr_state = $curr_loc->regionName;
265 | $curr_country = $curr_loc->country;
266 |
267 |
268 | $weather_url = 'http://api.apixu.com/v1/current.json?key=6a796cd5ec244b74be4112646192204&q='.$curr_city;
269 | $weather_data = json_decode(file_get_contents($weather_url));
270 |
271 | $temp_c = ($weather_data->current)->temp_c;
272 | $temp_f = ($weather_data->current)->temp_f;
273 |
274 | $resp = 'Current temperature in '.$curr_city.' : '.$temp_c.' °C | '.$temp_f.' °F';
275 | }
276 | else if(in_array($msg, $helper_cmd)) # Check for help commands
277 | {
278 | $resp = "List of commands available :-
279 | Greetings (Eg. - Hi)
280 | Abouts (Eg. - How are you?).
281 | Who's (Eg. Who are you?)
282 | Date, time or Day (Eg. date today, current time or day today)
283 | Current Geo-location (Eg. Where am I?)
284 | Current temperature (Eg. Current weather)
285 | Basic arithmetic caclulation (Eg. calc 3 + 2)
286 | Search for anything (Eg. Search Potato)
287 | Byes (Eg. Goodbye) ";
288 | }
289 | else if((strpos($msg, 'calculate') === 0) || (strpos($msg, 'calc') === 0)) # Check for calculator
290 | {
291 | if(($msg_arr[0] == 'calculate') || ($msg_arr[0] == 'calc'))
292 | {
293 | if($msg_arr[2] == '+')
294 | {
295 | $calc = ((double)$msg_arr[1]) + ((double)$msg_arr[3]);
296 | $calc = "Sum would be : ".$calc;
297 | }
298 | else if($msg_arr[2] == '-')
299 | {
300 | $calc = ((double)$msg_arr[1]) - ((double)$msg_arr[3]);
301 | $calc = "Difference would be : ".$calc;
302 | }
303 | else if($msg_arr[2] == '*')
304 | {
305 | $calc = ((double)$msg_arr[1]) * ((double)$msg_arr[3]);
306 | $calc = "Product would be : ".$calc;
307 | }
308 | else if($msg_arr[2] == '/')
309 | {
310 | if($msg_arr[3] == 0)
311 | {
312 | $calc = "Any number cannot be divided by zero!";
313 | }
314 | else
315 | {
316 | $calc = ((double)$msg_arr[1]) / ((double)$msg_arr[3]);
317 | $calc = "Division would be : ".$calc;
318 | }
319 | }
320 | else
321 | {
322 | $calc = "Only four basic arithmetic operation (+, -, *, /) are supported right now!";
323 | }
324 |
325 | $resp = $calc;
326 | }
327 | }
328 | else if((strpos($msg, 'search') === 0)) # Check for search
329 | {
330 | array_shift($msg_arr);
331 | $search_str = implode(' ',$msg_arr);
332 | $search_url = "https://en.wikipedia.org/wiki/".$search_str;
333 |
334 | $html = file_get_html($search_url);
335 |
336 | $def_flag = 0;
337 |
338 | foreach($html->find('p') as $para)
339 | {
340 | if($def_flag < 1)
341 | {
342 | $def = $para->plaintext;
343 | if((($def != null) || ($def != "")) && (!preg_match('/:$/i', $def)))
344 | {
345 | $def_flag++;
346 | }
347 | }
348 | else
349 | {
350 | break;
351 | }
352 | }
353 |
354 | if((preg_match('/to:$/i',$def)) || (preg_match('/'.$search_str.':$/i',$def)))
355 | {
356 | $resp = $def."Read here. ";
357 | }
358 | else
359 | {
360 | $def = preg_replace('/\[[0-9]+\]/','',html_entity_decode($def));
361 | $resp = $def;
362 | }
363 |
364 | }
365 | else # If no commands is applicable, show default text
366 | {
367 | $resp = 'No response available for - "'.$msg.'". Check for wrong spellings or commands, for all available commands, type "chatbot help" or "all commands".';
368 | }
369 |
370 | $resp = ucfirst($resp);
371 |
372 | $respDtl['name'] = $Bot;
373 | $respDtl['resp'] = $resp;
374 |
375 | $res['status'] = true;
376 | $res['respDetails'] = $respDtl;
377 |
378 | echo json_encode($res); # send bot response as ajax request, JSON encoded
379 | exit();
380 | }
381 |
382 | // End of class
383 | }
384 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/models/chatter.php:
--------------------------------------------------------------------------------
1 | setQuery($query);
27 | if($db->query())
28 | {
29 | return $db->insertid();
30 | }
31 | else
32 | {
33 | return false;
34 | }
35 | }
36 |
37 |
38 | /**
39 | * Function to select last inserted chat msg w.r.t last inserted ID.
40 | *
41 | * @param int $id
42 | * The last inserted row ID returned from the above function 'insert'.
43 | *
44 | * @return array $lastInsData
45 | * Array containing the message, user id w.r.t last inserted id.
46 | */
47 | function selectLastInserted($id)
48 | {
49 | $id = (INT)$id;
50 |
51 | $db = JFactory::getDBO();
52 | $query = "SELECT M.msgs, U.name FROM `#__chatter_msgs` AS M LEFT JOIN `#__users` as U ON M.userId=U.id WHERE M.id=$id LIMIT 1;";
53 | $lastInsData=$db->setQuery($query)->loadObject();
54 |
55 | return $lastInsData;
56 | }
57 | }
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/views/chatter/tmpl/default.php:
--------------------------------------------------------------------------------
1 |
6 |
7 |
ChatBot!
8 |
name;?> is Typing.....
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 | Send
19 |
20 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/views/chatter/tmpl/default_guest_view.php:
--------------------------------------------------------------------------------
1 |
5 |
6 |
7 |
Please login first!
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/components/com_chatter/views/chatter/view.html.php:
--------------------------------------------------------------------------------
1 | id > 0)
14 | {
15 | $tpl = null;
16 | }
17 | else
18 | {
19 | $tpl = 'guest_view';
20 | }
21 |
22 | parent::display($tpl);
23 | }
24 | }
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/media/css/chatter.css:
--------------------------------------------------------------------------------
1 | .chat-div
2 | {
3 | padding: 20px;
4 | background: #e6e6e6;
5 | border-radius: 10px;
6 | }
7 |
8 | .chat-app-title
9 | {
10 | color: #0caf50;
11 | }
12 |
13 | .msg-input
14 | {
15 | height: 60px;
16 | width: inherit;
17 | padding: 10px;
18 | border-radius: 10px;
19 | }
20 |
21 | .send-btn
22 | {
23 | background: #000000;
24 | color: #ffffff;
25 | padding: 6px;
26 | border-radius: 5px;
27 | border-color: #000000;
28 | }
29 |
30 | .msg-disp
31 | {
32 | padding: 10px;
33 | background: #ffffff;
34 | color: #1a1a1a;
35 | border: 1px solid skyblue;
36 | border-radius: 10px;
37 | min-height: 300px;
38 | max-height: 300px;
39 | width: inherit;
40 | overflow: scroll;
41 | }
42 |
43 | .msg-sender
44 | {
45 | font-weight: bold;
46 | color: skyblue;
47 | }
48 |
49 | .bot-resp
50 | {
51 | font-weight: bold;
52 | color: lime;
53 | }
54 |
55 | .the-msg-text
56 | {
57 | text-align: right;
58 | background-color: #ccffff;
59 | padding: 10px;
60 | margin-left: 50%;
61 | margin-bottom: 4px;
62 | border-radius: 10px;
63 | }
64 | .the-resp
65 | {
66 | background-color: #b3ffb3;
67 | padding: 10px;
68 | margin-right: 50%;
69 | margin-bottom: 4px;
70 | border-radius: 10px;
71 | }
72 |
73 | .msg-sender, .msg-content, .bot-resp
74 | {
75 | text-align: left;
76 | }
77 |
78 | .msg-sender
79 | {
80 | border-bottom: 1px solid skyblue;
81 | }
82 |
83 | .bot-resp
84 | {
85 | border-bottom: 1px solid lime;
86 | }
87 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/media/css/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/media/images/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/media/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/media/js/frontend.js:
--------------------------------------------------------------------------------
1 | var jq = jQuery.noConflict();
2 |
3 | jq(document).ready(function(){
4 |
5 | /**
6 | * Function to "auto-scroll" the chat box to latest response
7 | */
8 | function scrolltoLatest()
9 | {
10 | jq('div.msg-disp').scrollTop(jq('div.msg-disp')[0].scrollHeight);
11 | }
12 |
13 |
14 | /**
15 | * Function for checking Responses from bot PHP function in controller - checkForResp
16 | *
17 | * @param string msg
18 | * The input msg for which the response is to be matched.
19 | *
20 | * @return html respTags
21 | * appends the html code with the appropriate response found in PHP controller
22 | */
23 | function giveResp(msg)
24 | {
25 | var param = {};
26 | param.option = 'com_chatter';
27 | param.task = 'checkForResponse';
28 | param.msg = msg;
29 |
30 | jq.ajax({
31 | url:'index.php',
32 | method:'POST',
33 | data:param,
34 | success:function(response)
35 | {
36 | console.log(response);
37 |
38 | response=JSON.parse(response);
39 | respDtls=response.respDetails;
40 | var respTags = "";
41 |
42 | respTags+='' + respDtls.name + '
' + respDtls.resp + '
';
43 | jq('div.msg-disp').append(respTags);
44 |
45 | scrolltoLatest();
46 | }
47 | });
48 | }
49 |
50 | jq(".msg-input").keypress(function(e){
51 | if(e.which == 13){
52 | jq('#send-btn').click();//Trigger search button click event
53 | }
54 | });
55 |
56 | jq(document).on('keydown','.msg-input', function(e){
57 | jq('.typing').show();
58 | });
59 |
60 | jq(document).on('keyup','.msg-input', function(e){
61 | jq('.typing').hide();
62 | });
63 |
64 | /**
65 | * Onclick chat button
66 | */
67 | jq(document).on('click','#send-btn',function(){
68 | var msg = jq('.msg-input').val().trim();
69 |
70 |
71 | if(msg == "")
72 | {
73 | alert('Please enter message!');
74 | return false;
75 | }
76 |
77 |
78 | // Passing initial parameters - Msg, sender id, task
79 | var param = {};
80 | param.option = 'com_chatter';
81 | param.task = 'getMsgRequest';
82 | param.msg = msg;
83 |
84 | jq.ajax({ // First Ajax call to PHP function - getMsgReq
85 | url:'index.php',
86 | method:'POST',
87 | data:param,
88 | success:function(response)
89 | {
90 | jq(".msg-input").val('');
91 | response=JSON.parse(response);
92 | actualresponse=response.chatDetails;
93 | var chatMsgHTML = "";
94 |
95 | chatMsgHTML+='' + actualresponse.name + '
' + actualresponse.msgs + '
';
96 | jq('div.msg-disp').append(chatMsgHTML);
97 |
98 | // Call to JS function giveResp to check response from bot
99 | giveResp(msg);
100 | }
101 | });
102 | });
103 | });
--------------------------------------------------------------------------------
/Chatbot-PHP/PHP-chatbot/media/js/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/Chatbot-PHP/README.md:
--------------------------------------------------------------------------------
1 | # PHP-chatbot
2 | Chatbot created using php-ajax in Joomla Framework.
3 |
4 | Current features added to chatbot are -
5 |
6 | 1. Greetings (Eg. - Hi)
7 | 2. Abouts (Eg. - How are you?).
8 | 3. Who's (Eg. Who are you?)
9 | 4. Date, time or day (Eg. Day today, current time or day today)
10 | 5. Current Geo-location (Eg. Where am I?)
11 | 6. Current temperature (Eg. Current weather)
12 | 7. Basic arithmetic caclulation (Eg. calc 3 + 2)
13 | 8. Search for anything (Eg. Search Potato)
14 | 9. Byes (Eg. Goodbye)
15 |
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/DataBase/shop.sql:
--------------------------------------------------------------------------------
1 | -- phpMyAdmin SQL Dump
2 | -- version 5.0.2
3 | -- https://www.phpmyadmin.net/
4 | --
5 | -- Hôte : 127.0.0.1
6 | -- Généré le : ven. 28 août 2020 à 21:08
7 | -- Version du serveur : 10.4.14-MariaDB
8 | -- Version de PHP : 7.4.9
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 | -- Base de données : `shop`
22 | --
23 |
24 | -- --------------------------------------------------------
25 |
26 | --
27 | -- Structure de la table `categories`
28 | --
29 |
30 | CREATE TABLE `categories` (
31 | `ID` int(11) NOT NULL,
32 | `Name` varchar(255) NOT NULL,
33 | `Description` text NOT NULL,
34 | `parent` int(11) NOT NULL,
35 | `Ordering` int(11) DEFAULT NULL,
36 | `Visibility` tinyint(4) NOT NULL DEFAULT 0,
37 | `Allow_Comment` tinyint(4) NOT NULL DEFAULT 0,
38 | `Allow_Ads` tinyint(4) NOT NULL DEFAULT 0
39 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
40 |
41 | --
42 | -- Déchargement des données de la table `categories`
43 | --
44 |
45 | INSERT INTO `categories` (`ID`, `Name`, `Description`, `parent`, `Ordering`, `Visibility`, `Allow_Comment`, `Allow_Ads`) VALUES
46 | (1, 'Accessoires', 'Mobile and PC Accessoires', 0, 1, 0, 0, 0),
47 | (2, 'PC Desktop', '', 0, 1, 0, 0, 0),
48 | (3, 'PC Portable', '', 0, 1, 0, 0, 0),
49 | (4, 'Smartphones', '', 0, 1, 0, 0, 0),
50 | (5, 'Others', '', 0, 1, 0, 0, 0);
51 |
52 | -- --------------------------------------------------------
53 |
54 | --
55 | -- Structure de la table `comments`
56 | --
57 |
58 | CREATE TABLE `comments` (
59 | `c_id` int(11) NOT NULL,
60 | `comment` text NOT NULL,
61 | `status` tinyint(4) NOT NULL,
62 | `comment_date` date NOT NULL,
63 | `item_id` int(11) NOT NULL,
64 | `user_id` int(11) NOT NULL
65 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
66 |
67 | --
68 | -- Déchargement des données de la table `comments`
69 | --
70 |
71 | INSERT INTO `comments` (`c_id`, `comment`, `status`, `comment_date`, `item_id`, `user_id`) VALUES
72 | (1, 'I love this keyboard', 1, '2020-08-28', 2, 2),
73 | (9, 'This is a good book, thank you', 1, '2020-08-28', 15, 2);
74 |
75 | -- --------------------------------------------------------
76 |
77 | --
78 | -- Structure de la table `items`
79 | --
80 |
81 | CREATE TABLE `items` (
82 | `Item_ID` int(11) NOT NULL,
83 | `Name` varchar(255) NOT NULL,
84 | `Description` text NOT NULL,
85 | `Price` varchar(255) NOT NULL,
86 | `Add_Date` date NOT NULL,
87 | `Country_Made` varchar(255) NOT NULL,
88 | `Status` varchar(255) NOT NULL,
89 | `Rating` smallint(6) NOT NULL,
90 | `Approve` tinyint(4) NOT NULL DEFAULT 0,
91 | `Cat_ID` int(11) NOT NULL,
92 | `Member_ID` int(11) NOT NULL,
93 | `picture` varchar(255) NOT NULL,
94 | `contact` varchar(255) NOT NULL
95 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
96 |
97 | --
98 | -- Déchargement des données de la table `items`
99 | --
100 |
101 | INSERT INTO `items` (`Item_ID`, `Name`, `Description`, `Price`, `Add_Date`, `Country_Made`, `Status`, `Rating`, `Approve`, `Cat_ID`, `Member_ID`, `picture`, `contact`) VALUES
102 | (1, 'Gaming Chair DXRacer', 'A new gaming chair from dxracer company high quality', '350', '2020-08-28', 'Maroc', '1', 0, 1, 1, 2, '9043072703_619sWFsXJ+L._AC_SY879_.jpg', ''),
103 | (2, 'Keyboard', 'keyboard blue switch RGB', '30', '2020-08-28', 'Maroc', '1', 0, 1, 1, 2, '9132677317_pro-x-keyboard-gallery-1.png', ''),
104 | (3, 'PC Portable', 'i7 9th gen 12Gb Ram double carte graphique Predator ecran 17\"', '1900', '2020-08-28', 'Maroc', '2', 0, 1, 3, 2, '1183001430_raw.jpg', '0612564852'),
105 | (4, 'PC desktop', 'Pc desktop for gamers', '800', '2020-08-28', 'Maroc', '2', 0, 1, 2, 2, '2118289353_tgf-PC.jpg', '0613357700'),
106 | (5, 'Houssam Mrabet', 'ssssssssssssssssssss', '15', '2020-08-28', 'Maroc', '4', 0, 1, 1, 2, '1515871950_l20m01.jpg', '0613357700'),
107 | (15, 'Midnight Sun', 'this not a phgysical book it\'s an e version', '5', '2020-08-28', 'France', '2', 0, 1, 5, 2, '8719133711_midnight_sun.jpg', '0613774702');
108 |
109 | -- --------------------------------------------------------
110 |
111 | --
112 | -- Structure de la table `users`
113 | --
114 |
115 | CREATE TABLE `users` (
116 | `UserID` int(11) NOT NULL COMMENT 'To Identify User',
117 | `Username` varchar(255) NOT NULL COMMENT 'Username To Login',
118 | `Password` varchar(255) NOT NULL COMMENT 'Password To Login',
119 | `Email` varchar(255) NOT NULL,
120 | `FullName` varchar(255) NOT NULL,
121 | `GroupID` int(11) NOT NULL DEFAULT 0 COMMENT 'Identify User Group',
122 | `TrustStatus` int(11) NOT NULL DEFAULT 0 COMMENT 'Seller Rank',
123 | `RegStatus` int(11) NOT NULL DEFAULT 0 COMMENT 'User Approval',
124 | `Date` date NOT NULL,
125 | `avatar` varchar(255) NOT NULL
126 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
127 |
128 | --
129 | -- Déchargement des données de la table `users`
130 | --
131 |
132 | INSERT INTO `users` (`UserID`, `Username`, `Password`, `Email`, `FullName`, `GroupID`, `TrustStatus`, `RegStatus`, `Date`, `avatar`) VALUES
133 | (1, 'Admin', '7af2d10b73ab7cd8f603937f7697cb5fe432c7ff', 'Admin@gmail.com', 'Admin Admin', 1, 1, 1, '2020-08-27', 'default.png'),
134 | (2, 'LMask', 'e9d155e1e377fed9a68863896a49308449f5b5f9', 'aymandebzi723@gmail.com', 'Aymane Debzi', 0, 0, 1, '2020-08-27', '7809775163_unnamed.jpg');
135 |
136 | --
137 | -- Index pour les tables déchargées
138 | --
139 |
140 | --
141 | -- Index pour la table `categories`
142 | --
143 | ALTER TABLE `categories`
144 | ADD PRIMARY KEY (`ID`),
145 | ADD UNIQUE KEY `Name` (`Name`);
146 |
147 | --
148 | -- Index pour la table `comments`
149 | --
150 | ALTER TABLE `comments`
151 | ADD PRIMARY KEY (`c_id`),
152 | ADD KEY `items_comment` (`item_id`),
153 | ADD KEY `comment_user` (`user_id`);
154 |
155 | --
156 | -- Index pour la table `items`
157 | --
158 | ALTER TABLE `items`
159 | ADD PRIMARY KEY (`Item_ID`),
160 | ADD KEY `member_1` (`Member_ID`),
161 | ADD KEY `cat_1` (`Cat_ID`);
162 |
163 | --
164 | -- Index pour la table `users`
165 | --
166 | ALTER TABLE `users`
167 | ADD PRIMARY KEY (`UserID`),
168 | ADD UNIQUE KEY `Username` (`Username`);
169 |
170 | --
171 | -- AUTO_INCREMENT pour les tables déchargées
172 | --
173 |
174 | --
175 | -- AUTO_INCREMENT pour la table `categories`
176 | --
177 | ALTER TABLE `categories`
178 | MODIFY `ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
179 |
180 | --
181 | -- AUTO_INCREMENT pour la table `comments`
182 | --
183 | ALTER TABLE `comments`
184 | MODIFY `c_id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3;
185 |
186 | --
187 | -- AUTO_INCREMENT pour la table `items`
188 | --
189 | ALTER TABLE `items`
190 | MODIFY `Item_ID` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
191 |
192 | --
193 | -- AUTO_INCREMENT pour la table `users`
194 | --
195 | ALTER TABLE `users`
196 | MODIFY `UserID` int(11) NOT NULL AUTO_INCREMENT COMMENT 'To Identify User', AUTO_INCREMENT=3;
197 |
198 | --
199 | -- Contraintes pour les tables déchargées
200 | --
201 |
202 | --
203 | -- Contraintes pour la table `comments`
204 | --
205 | ALTER TABLE `comments`
206 | ADD CONSTRAINT `comment_user` FOREIGN KEY (`user_id`) REFERENCES `users` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE,
207 | ADD CONSTRAINT `items_comment` FOREIGN KEY (`item_id`) REFERENCES `items` (`Item_ID`) ON DELETE CASCADE ON UPDATE CASCADE;
208 |
209 | --
210 | -- Contraintes pour la table `items`
211 | --
212 | ALTER TABLE `items`
213 | ADD CONSTRAINT `cat_1` FOREIGN KEY (`Cat_ID`) REFERENCES `categories` (`ID`) ON DELETE CASCADE ON UPDATE CASCADE,
214 | ADD CONSTRAINT `member_1` FOREIGN KEY (`Member_ID`) REFERENCES `users` (`UserID`) ON DELETE CASCADE ON UPDATE CASCADE;
215 | COMMIT;
216 |
217 | /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
218 | /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
219 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
220 |
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/README.md:
--------------------------------------------------------------------------------
1 | # Ecommerce Web App
2 |
3 | This is an ecommerce web application developed using PHP and MySQL, with Bootstrap for the user interface. The application allows visitors to browse products, view individual product descriptions, leave feedback in the comment section, and view seller information. Sellers need to register and await admin confirmation before they can start posting their products for sale. Each product requires admin approval before it is displayed to buyers. The admin has their own interface to manage seller accounts, products, comments, and other aspects of the application.
4 |
5 | ## Getting Started
6 |
7 | To get started with this ecommerce web app, follow the steps below:
8 |
9 | ### Prerequisites
10 |
11 | - PHP (version >= 7.0)
12 | - MySQL (version >= 5.7)
13 | - Web server (e.g., Apache)
14 |
15 | ### Installation
16 |
17 | 1. Clone the repository or download the source code.
18 |
19 | 2. Import the database into your local MySQL server:
20 | - Locate the database file (`database.sql`) in the project folder.
21 | - Import the database file into your MySQL server using a tool like phpMyAdmin or the MySQL command line.
22 |
23 | 3. Configure the database connection:
24 | - Open the `config.php` file in the project folder.
25 | - Update the database credentials (hostname, username, password, and database name) to match your local setup.
26 |
27 | 4. Start the web server:
28 | - Configure your web server to serve the project folder (e.g., set up a virtual host).
29 | - Ensure that PHP is properly configured with your web server.
30 |
31 | 5. Access the application:
32 | - Open a web browser and navigate to the configured URL for the application.
33 | - You should now be able to access the ecommerce web app.
34 |
35 | ## Features
36 |
37 | - User Registration:
38 | - Visitors can register as sellers to post products for sale.
39 | - Sellers must wait for admin confirmation before they can start posting products.
40 |
41 | - Product Listing:
42 | - Visitors can browse and view a list of available products.
43 | - Each product has a description page with detailed information.
44 |
45 | - Comment Section:
46 | - Users can leave feedback and comments on product description pages.
47 |
48 | - Seller Information:
49 | - Product descriptions display seller information.
50 |
51 | - Admin Interface:
52 | - The admin has a dedicated interface to manage seller accounts, products, and comments.
53 | - Admin approval is required for new seller registrations and product postings.
54 |
55 | ## Contributing
56 |
57 | Contributions are welcome! If you'd like to contribute to this ecommerce web app, please follow these steps:
58 |
59 | 1. Fork the repository.
60 |
61 | 2. Create a new branch for your feature or bug fix.
62 |
63 | 3. Make your changes and commit them to your branch.
64 |
65 | 4. Push your changes to your forked repository.
66 |
67 | 5. Submit a pull request describing your changes.
68 |
69 | ## License
70 |
71 | This project is licensed under the [MIT License](LICENSE).
72 |
73 | ## Contact
74 |
75 | For any inquiries or feedback, please contact [houssammrabet5@gmail.com](mailto:houssammrabet5@gmail.com).
76 |
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/categories.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT * FROM categories WHERE parent = 0 ORDER BY Ordering $sort");
34 |
35 | $stmt2->execute();
36 |
37 | $cats = $stmt2->fetchAll();
38 |
39 | if (! empty($cats)) {
40 |
41 | ?>
42 |
43 | Manage Categories
44 |
45 |
46 |
47 |
Manage Categories
48 |
49 |
Ordering: [
50 |
Asc |
51 |
Desc ]
52 |
View: [
53 |
Full |
54 |
Classic ]
55 |
56 |
57 |
58 | ";
61 | echo "
";
65 | echo "
" . $cat['Name'] . ' ';
66 | echo "
";
67 | echo "
"; if($cat['Description'] == '') { echo 'This category has no description'; } else { echo $cat['Description']; } echo "
";
68 | if($cat['Visibility'] == 1) { echo '
Hidden'; }
69 | if($cat['Allow_Comment'] == 1) { echo ''; }
70 | if($cat['Allow_Ads'] == 1) { echo '
Ads Disabled'; }
71 | echo "
";
72 |
73 | // Get Child Categories
74 | $childCats = getAllFrom("*", "categories", "where parent = {$cat['ID']}", "", "ID", "ASC");
75 | if (! empty($childCats)) {
76 | echo "
Child Categories ";
77 | echo "
";
85 | }
86 |
87 | echo "
";
88 | echo "
";
89 | }
90 | ?>
91 |
92 |
93 | Add New Category
94 |
95 |
96 | ';
99 | echo 'There\'s No Categories To Show
';
100 | echo '
101 | New Category
102 | ';
103 | echo '';
104 |
105 | } ?>
106 |
107 |
110 |
111 | Add New Category
112 |
208 |
209 | Insert Category";
216 | echo "";
217 |
218 | // Get Variables From The Form
219 |
220 | $name = $_POST['name'];
221 | $desc = $_POST['description'];
222 | $parent = $_POST['parent'];
223 | $order = $_POST['ordering'];
224 | $visible = $_POST['visibility'];
225 | $comment = $_POST['commenting'];
226 | $ads = $_POST['ads'];
227 |
228 | // Check If Category Exist in Database
229 |
230 | $check = checkItem("Name", "categories", $name);
231 |
232 | if ($check == 1) {
233 |
234 | $theMsg = '
Sorry This Category Is Exist
';
235 |
236 | redirectHome($theMsg, 'back');
237 |
238 | } else {
239 |
240 | // Insert Category Info In Database
241 |
242 | $stmt = $con->prepare("INSERT INTO
243 |
244 | categories(Name, Description, parent, Ordering, Visibility, Allow_Comment, Allow_Ads)
245 |
246 | VALUES(:zname, :zdesc, :zparent, :zorder, :zvisible, :zcomment, :zads)");
247 |
248 | $stmt->execute(array(
249 | 'zname' => $name,
250 | 'zdesc' => $desc,
251 | 'zparent' => $parent,
252 | 'zorder' => $order,
253 | 'zvisible' => $visible,
254 | 'zcomment' => $comment,
255 | 'zads' => $ads
256 | ));
257 |
258 | // Echo Success Message
259 |
260 | $theMsg = "
" . $stmt->rowCount() . ' Record Inserted
';
261 |
262 | $seconds = 3;
263 |
264 | echo "
You Will Be Redirected to your profil After $seconds Seconds.
";
265 |
266 | header("refresh:$seconds;url='categories.php'");
267 |
268 | }
269 |
270 | } else {
271 |
272 | echo "
";
273 |
274 | $theMsg = '
Sorry You Cant Browse This Page Directly
';
275 |
276 | redirectHome($theMsg, 'back');
277 |
278 | echo "
";
279 |
280 | }
281 |
282 | echo "
";
283 |
284 | } elseif ($do == 'Edit') {
285 |
286 | // Check If Get Request catid Is Numeric & Get Its Integer Value
287 |
288 | $catid = isset($_GET['catid']) && is_numeric($_GET['catid']) ? intval($_GET['catid']) : 0;
289 |
290 | // Select All Data Depend On This ID
291 |
292 | $stmt = $con->prepare("SELECT * FROM categories WHERE ID = ?");
293 |
294 | // Execute Query
295 |
296 | $stmt->execute(array($catid));
297 |
298 | // Fetch The Data
299 |
300 | $cat = $stmt->fetch();
301 |
302 | // The Row Count
303 |
304 | $count = $stmt->rowCount();
305 |
306 | // If There's Such ID Show The Form
307 |
308 | if ($count > 0) { ?>
309 |
310 | Edit Category
311 |
410 |
411 | ";
418 |
419 | $theMsg = 'Theres No Such ID
';
420 |
421 | redirectHome($theMsg);
422 |
423 | echo "";
424 |
425 | }
426 |
427 | } elseif ($do == 'Update') {
428 |
429 | echo "Update Category ";
430 | echo "";
431 |
432 | if ($_SERVER['REQUEST_METHOD'] == 'POST') {
433 |
434 | // Get Variables From The Form
435 |
436 | $id = $_POST['catid'];
437 | $name = $_POST['name'];
438 | $desc = $_POST['description'];
439 | $order = $_POST['ordering'];
440 | $parent = $_POST['parent'];
441 |
442 | $visible = $_POST['visibility'];
443 | $comment = $_POST['commenting'];
444 | $ads = $_POST['ads'];
445 |
446 | // Update The Database With This Info
447 |
448 | $stmt = $con->prepare("UPDATE
449 | categories
450 | SET
451 | Name = ?,
452 | Description = ?,
453 | Ordering = ?,
454 | parent = ?,
455 | Visibility = ?,
456 | Allow_Comment = ?,
457 | Allow_Ads = ?
458 | WHERE
459 | ID = ?");
460 |
461 | $stmt->execute(array($name, $desc, $order, $parent, $visible, $comment, $ads, $id));
462 |
463 | // Echo Success Message
464 |
465 | $theMsg = "
" . $stmt->rowCount() . ' Record Updated
';
466 |
467 | $seconds = 3;
468 |
469 | echo $theMsg;
470 |
471 | echo "
You Will Be Redirected to your profil After $seconds Seconds.
";
472 |
473 | header("refresh:$seconds;url='categories.php'");
474 |
475 | } else {
476 |
477 | $theMsg = '
Sorry You Cant Browse This Page Directly
';
478 |
479 | redirectHome($theMsg);
480 |
481 | }
482 |
483 | echo "
";
484 |
485 | } elseif ($do == 'Delete') {
486 |
487 | echo "Delete Category ";
488 | echo "";
489 |
490 | // Check If Get Request Catid Is Numeric & Get The Integer Value Of It
491 |
492 | $catid = isset($_GET['catid']) && is_numeric($_GET['catid']) ? intval($_GET['catid']) : 0;
493 |
494 | // Select All Data Depend On This ID
495 |
496 | $check = checkItem('ID', 'categories', $catid);
497 |
498 | // If There's Such ID Show The Form
499 |
500 | if ($check > 0) {
501 |
502 | $stmt = $con->prepare("DELETE FROM categories WHERE ID = :zid");
503 |
504 | $stmt->bindParam(":zid", $catid);
505 |
506 | $stmt->execute();
507 |
508 | $theMsg = "
" . $stmt->rowCount() . ' Record Deleted
';
509 |
510 | redirectHome($theMsg, 'back');
511 |
512 | } else {
513 |
514 | $theMsg = '
This ID is Not Exist
';
515 |
516 | redirectHome($theMsg);
517 |
518 | }
519 |
520 | echo '
';
521 |
522 | }
523 |
524 | include $tpl . 'footer.php';
525 |
526 | } else {
527 |
528 | header('Location: index.php');
529 |
530 | exit();
531 | }
532 |
533 | ob_end_flush(); // Release The Output
534 |
535 | ?>
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/comments.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT
29 | comments.*, items.Name AS Item_Name, users.Username AS Member
30 | FROM
31 | comments
32 | INNER JOIN
33 | items
34 | ON
35 | items.Item_ID = comments.item_id
36 | INNER JOIN
37 | users
38 | ON
39 | users.UserID = comments.user_id
40 | ORDER BY
41 | c_id DESC");
42 |
43 | // Execute The Statement
44 |
45 | $stmt->execute();
46 |
47 | // Assign To Variable
48 |
49 | $comments = $stmt->fetchAll();
50 |
51 | if (! empty($comments)) {
52 |
53 | ?>
54 |
55 | Manage Feedbacks
56 |
57 |
58 |
59 |
60 | Feedback
61 | Item Name
62 | User Name
63 | Added Date
64 | Control
65 |
66 | ";
69 | echo "" . $comment['comment'] . " ";
70 | echo "" . $comment['Item_Name'] . " ";
71 | echo "" . $comment['Member'] . " ";
72 | echo "" . $comment['comment_date'] ." ";
73 | echo "
74 | Delete ";
75 | if ($comment['status'] == 0) {
76 | echo "
79 | Approve ";
80 | }
81 | echo " ";
82 | echo "";
83 | }
84 | ?>
85 |
86 |
87 |
88 |
89 |
90 | ';
93 | echo 'There\'s No Comments To Show
';
94 | echo '';
95 |
96 | } ?>
97 |
98 | Delete Comment";
103 |
104 | echo "";
105 |
106 | // Check If Get Request comid Is Numeric & Get The Integer Value Of It
107 |
108 | $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0;
109 |
110 | // Select All Data Depend On This ID
111 |
112 | $check = checkItem('c_id', 'comments', $comid);
113 |
114 | // If There's Such ID Show The Form
115 |
116 | if ($check > 0) {
117 |
118 | $stmt = $con->prepare("DELETE FROM comments WHERE c_id = :zid");
119 |
120 | $stmt->bindParam(":zid", $comid);
121 |
122 | $stmt->execute();
123 |
124 | $theMsg = "
" . $stmt->rowCount() . ' Record Deleted
';
125 |
126 | redirectHome($theMsg, 'back');
127 |
128 | } else {
129 |
130 | $theMsg = '
This ID is Not Exist
';
131 |
132 | redirectHome($theMsg);
133 |
134 | }
135 |
136 | echo '
';
137 |
138 | } elseif ($do == 'Approve') {
139 |
140 | echo "Approve Comment ";
141 | echo "";
142 |
143 | // Check If Get Request comid Is Numeric & Get The Integer Value Of It
144 |
145 | $comid = isset($_GET['comid']) && is_numeric($_GET['comid']) ? intval($_GET['comid']) : 0;
146 |
147 | // Select All Data Depend On This ID
148 |
149 | $check = checkItem('c_id', 'comments', $comid);
150 |
151 | // If There's Such ID Show The Form
152 |
153 | if ($check > 0) {
154 |
155 | $stmt = $con->prepare("UPDATE comments SET status = 1 WHERE c_id = ?");
156 |
157 | $stmt->execute(array($comid));
158 |
159 | $theMsg = "
" . $stmt->rowCount() . ' Record Approved
';
160 |
161 | redirectHome($theMsg, 'back');
162 |
163 | } else {
164 |
165 | $theMsg = '
This ID is Not Exist
';
166 |
167 | redirectHome($theMsg);
168 |
169 | }
170 |
171 | echo '
';
172 |
173 | }
174 |
175 | include $tpl . 'footer.php';
176 |
177 | } else {
178 |
179 | header('Location: index.php');
180 |
181 | exit();
182 | }
183 |
184 | ob_end_flush(); // Release The Output
185 |
186 | ?>
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/connect.php:
--------------------------------------------------------------------------------
1 | 'SET NAMES utf8',
8 | );
9 |
10 | try {
11 | $con = new PDO($dsn, $user, $pass, $option);
12 | $con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
13 | }
14 |
15 | catch(PDOException $e) {
16 | echo 'Failed To Connect' . $e->getMessage();
17 | }
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/copy_template.php:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/dashboard.php:
--------------------------------------------------------------------------------
1 |
26 |
27 |
28 |
29 |
Dashboard
30 |
31 |
32 |
33 |
34 |
35 | Total Members
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | Total Items
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 | Latest Registerd Users
76 |
77 |
78 |
79 |
80 |
106 |
107 |
108 |
109 |
110 |
111 | Latest Items
112 |
113 |
114 |
115 |
116 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | Latest Feedbacks
152 |
153 |
154 |
155 |
156 |
157 | prepare("SELECT
159 | comments.*, users.Username AS Member
160 | FROM
161 | comments
162 | INNER JOIN
163 | users
164 | ON
165 | users.UserID = comments.user_id
166 | ORDER BY
167 | c_id DESC
168 | LIMIT $numComments");
169 |
170 | $stmt->execute();
171 | $comments = $stmt->fetchAll();
172 |
173 | if (! empty($comments)) {
174 | foreach ($comments as $comment) {
175 | echo '';
181 | }
182 | } else {
183 | echo 'There\'s No Comments To Show';
184 | }
185 | ?>
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/includes/functions/functions.php:
--------------------------------------------------------------------------------
1 | prepare("SELECT $field FROM $table $where $and ORDER BY $orderfield $ordering");
13 |
14 | $getAll->execute();
15 |
16 | $all = $getAll->fetchAll();
17 |
18 | return $all;
19 |
20 | }
21 |
22 |
23 | /*
24 | ** Title Function v1.0
25 | ** Title Function That Echo The Page Title In Case The Page
26 | ** Has The Variable $pageTitle And Echo Defult Title For Other Pages
27 | */
28 |
29 | function getTitle() {
30 |
31 | global $pageTitle;
32 |
33 | if (isset($pageTitle)) {
34 |
35 | echo $pageTitle;
36 |
37 | } else {
38 |
39 | echo 'Default';
40 |
41 | }
42 | }
43 |
44 | /*
45 | ** Home Redirect Function v2.0
46 | ** This Function Accept Parameters
47 | ** $theMsg = Echo The Message [ Error | Success | Warning ]
48 | ** $url = The Link You Want To Redirect To
49 | ** $seconds = Seconds Before Redirecting
50 | */
51 |
52 | function redirectHome($theMsg, $url = null, $seconds = 3) {
53 |
54 | if ($url === null) {
55 |
56 | $url = 'index.php';
57 |
58 | $link = 'Homepage';
59 |
60 | } else {
61 |
62 | if (isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] !== '') {
63 |
64 | $url = $_SERVER['HTTP_REFERER'];
65 |
66 | $link = 'Previous Page';
67 |
68 | } else {
69 |
70 | $url = 'index.php';
71 |
72 | $link = 'Homepage';
73 |
74 | }
75 |
76 | }
77 |
78 | echo $theMsg;
79 |
80 | echo "You Will Be Redirected to $link After $seconds Seconds.
";
81 |
82 | header("refresh:$seconds;url=$url");
83 |
84 | exit();
85 |
86 | }
87 |
88 | /*
89 | ** Check Items Function v1.0
90 | ** Function to Check Item In Database [ Function Accept Parameters ]
91 | ** $select = The Item To Select [ Example: user, item, category ]
92 | ** $from = The Table To Select From [ Example: users, items, categories ]
93 | ** $value = The Value Of Select [ Example: Osama, Box, Electronics ]
94 | */
95 |
96 | function checkItem($select, $from, $value) {
97 |
98 | global $con;
99 |
100 | $statement = $con->prepare("SELECT $select FROM $from WHERE $select = ?");
101 |
102 | $statement->execute(array($value));
103 |
104 | $count = $statement->rowCount();
105 |
106 | return $count;
107 |
108 | }
109 |
110 | /*
111 | ** Count Number Of Items Function v1.0
112 | ** Function To Count Number Of Items Rows
113 | ** $item = The Item To Count
114 | ** $table = The Table To Choose From
115 | */
116 |
117 | function countItems($item, $table) {
118 |
119 | global $con;
120 |
121 | $stmt2 = $con->prepare("SELECT COUNT($item) FROM $table");
122 |
123 | $stmt2->execute();
124 |
125 | return $stmt2->fetchColumn();
126 |
127 | }
128 |
129 | /*
130 | ** Get Latest Records Function v1.0
131 | ** Function To Get Latest Items From Database [ Users, Items, Comments ]
132 | ** $select = Field To Select
133 | ** $table = The Table To Choose From
134 | ** $order = The Desc Ordering
135 | ** $limit = Number Of Records To Get
136 | */
137 |
138 | function getLatest($select, $table, $order, $limit = 5) {
139 |
140 | global $con;
141 |
142 | $getStmt = $con->prepare("SELECT $select FROM $table ORDER BY $order DESC LIMIT $limit");
143 |
144 | $getStmt->execute();
145 |
146 | $rows = $getStmt->fetchAll();
147 |
148 | return $rows;
149 |
150 | }
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/includes/languages/arabic.php:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/engineers-planet/PHP_Free_Downloads/ba8be31590052331a602e970dd2a14ad528c6420/Ecommerce-website-PHP/Website/admin/includes/languages/arabic.php
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/includes/languages/english.php:
--------------------------------------------------------------------------------
1 | 'Home',
10 | 'CATEGORIES' => 'Categories',
11 | 'ITEMS' => 'Items',
12 | 'MEMBERS' => 'Members',
13 | 'FEEDBACKS' => 'Feedbacks',
14 | 'STATISTICS' => 'Statistics',
15 | 'LOGS' => 'Logs',
16 | '' => '',
17 | '' => '',
18 | '' => '',
19 | '' => '',
20 | '' => ''
21 | );
22 |
23 | return $lang[$phrase];
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/Ecommerce-website-PHP/Website/admin/includes/templates/footer.php:
--------------------------------------------------------------------------------
1 |
13 |
14 |
15 |
16 |
17 |
18 |
' . $comment['comment'] . '
'; 180 | echo '