forked from hammadshahir/PHP-MySQL-ecommerce-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
header.php
411 lines (377 loc) · 14.6 KB
/
header.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<!-- This is main configuration File -->
<?php
ob_start();
session_start();
include("admin/inc/config.php");
include("admin/inc/functions.php");
include("admin/inc/CSRF_Protect.php");
$csrf = new CSRF_Protect();
$error_message = '';
$success_message = '';
$error_message1 = '';
$success_message1 = '';
// Getting all language variables into array as global variable
$i=1;
$statement = $pdo->prepare("SELECT * FROM tbl_language");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
define('LANG_VALUE_'.$i,$row['lang_value']);
$i++;
}
$statement = $pdo->prepare("SELECT * FROM tbl_settings WHERE id=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row)
{
$logo = $row['logo'];
$favicon = $row['favicon'];
$contact_email = $row['contact_email'];
$contact_phone = $row['contact_phone'];
$meta_title_home = $row['meta_title_home'];
$meta_keyword_home = $row['meta_keyword_home'];
$meta_description_home = $row['meta_description_home'];
$before_head = $row['before_head'];
$after_body = $row['after_body'];
}
// Checking the order table and removing the pending transaction that are 24 hours+ old. Very important
$current_date_time = date('Y-m-d H:i:s');
$statement = $pdo->prepare("SELECT * FROM tbl_payment WHERE payment_status=?");
$statement->execute(array('Pending'));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$ts1 = strtotime($row['payment_date']);
$ts2 = strtotime($current_date_time);
$diff = $ts2 - $ts1;
$time = $diff/(3600);
if($time>24) {
// Return back the stock amount
$statement1 = $pdo->prepare("SELECT * FROM tbl_order WHERE payment_id=?");
$statement1->execute(array($row['payment_id']));
$result1 = $statement1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $row1) {
$statement2 = $pdo->prepare("SELECT * FROM tbl_product WHERE p_id=?");
$statement2->execute(array($row1['product_id']));
$result2 = $statement2->fetchAll(PDO::FETCH_ASSOC);
foreach ($result2 as $row2) {
$p_qty = $row2['p_qty'];
}
$final = $p_qty+$row1['quantity'];
$statement = $pdo->prepare("UPDATE tbl_product SET p_qty=? WHERE p_id=?");
$statement->execute(array($final,$row1['product_id']));
}
// Deleting data from table
$statement1 = $pdo->prepare("DELETE FROM tbl_order WHERE payment_id=?");
$statement1->execute(array($row['payment_id']));
$statement1 = $pdo->prepare("DELETE FROM tbl_payment WHERE id=?");
$statement1->execute(array($row['id']));
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta Tags -->
<meta name="viewport" content="width=device-width,initial-scale=1.0"/>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<!-- Favicon -->
<link rel="icon" type="image/png" href="assets/uploads/<?php echo $favicon; ?>">
<!-- Stylesheets -->
<link rel="stylesheet" href="assets/css/bootstrap.min.css">
<link rel="stylesheet" href="assets/css/font-awesome.min.css">
<link rel="stylesheet" href="assets/css/owl.carousel.min.css">
<link rel="stylesheet" href="assets/css/owl.theme.default.min.css">
<link rel="stylesheet" href="assets/css/jquery.bxslider.min.css">
<link rel="stylesheet" href="assets/css/magnific-popup.css">
<link rel="stylesheet" href="assets/css/rating.css">
<link rel="stylesheet" href="assets/css/spacing.css">
<link rel="stylesheet" href="assets/css/bootstrap-touch-slider.css">
<link rel="stylesheet" href="assets/css/animate.min.css">
<link rel="stylesheet" href="assets/css/tree-menu.css">
<link rel="stylesheet" href="assets/css/select2.min.css">
<link rel="stylesheet" href="assets/css/main.css">
<link rel="stylesheet" href="assets/css/responsive.css">
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_page WHERE id=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$about_meta_title = $row['about_meta_title'];
$about_meta_keyword = $row['about_meta_keyword'];
$about_meta_description = $row['about_meta_description'];
$faq_meta_title = $row['faq_meta_title'];
$faq_meta_keyword = $row['faq_meta_keyword'];
$faq_meta_description = $row['faq_meta_description'];
$blog_meta_title = $row['blog_meta_title'];
$blog_meta_keyword = $row['blog_meta_keyword'];
$blog_meta_description = $row['blog_meta_description'];
$contact_meta_title = $row['contact_meta_title'];
$contact_meta_keyword = $row['contact_meta_keyword'];
$contact_meta_description = $row['contact_meta_description'];
$pgallery_meta_title = $row['pgallery_meta_title'];
$pgallery_meta_keyword = $row['pgallery_meta_keyword'];
$pgallery_meta_description = $row['pgallery_meta_description'];
$vgallery_meta_title = $row['vgallery_meta_title'];
$vgallery_meta_keyword = $row['vgallery_meta_keyword'];
$vgallery_meta_description = $row['vgallery_meta_description'];
}
$cur_page = substr($_SERVER["SCRIPT_NAME"],strrpos($_SERVER["SCRIPT_NAME"],"/")+1);
if($cur_page == 'index.php' || $cur_page == 'login.php' || $cur_page == 'registration.php' || $cur_page == 'cart.php' || $cur_page == 'checkout.php' || $cur_page == 'forget-password.php' || $cur_page == 'reset-password.php' || $cur_page == 'product-category.php' || $cur_page == 'product.php') {
?>
<title><?php echo $meta_title_home; ?></title>
<meta name="keywords" content="<?php echo $meta_keyword_home; ?>">
<meta name="description" content="<?php echo $meta_description_home; ?>">
<?php
}
if($cur_page == 'about.php') {
?>
<title><?php echo $about_meta_title; ?></title>
<meta name="keywords" content="<?php echo $about_meta_keyword; ?>">
<meta name="description" content="<?php echo $about_meta_description; ?>">
<?php
}
if($cur_page == 'faq.php') {
?>
<title><?php echo $faq_meta_title; ?></title>
<meta name="keywords" content="<?php echo $faq_meta_keyword; ?>">
<meta name="description" content="<?php echo $faq_meta_description; ?>">
<?php
}
if($cur_page == 'contact.php') {
?>
<title><?php echo $contact_meta_title; ?></title>
<meta name="keywords" content="<?php echo $contact_meta_keyword; ?>">
<meta name="description" content="<?php echo $contact_meta_description; ?>">
<?php
}
if($cur_page == 'product.php')
{
$statement = $pdo->prepare("SELECT * FROM tbl_product WHERE p_id=?");
$statement->execute(array($_REQUEST['id']));
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row)
{
$og_photo = $row['p_featured_photo'];
$og_title = $row['p_name'];
$og_slug = 'product.php?id='.$_REQUEST['id'];
$og_description = substr(strip_tags($row['p_description']),0,200).'...';
}
}
if($cur_page == 'dashboard.php') {
?>
<title>Dashboard - <?php echo $meta_title_home; ?></title>
<meta name="keywords" content="<?php echo $meta_keyword_home; ?>">
<meta name="description" content="<?php echo $meta_description_home; ?>">
<?php
}
if($cur_page == 'customer-profile-update.php') {
?>
<title>Update Profile - <?php echo $meta_title_home; ?></title>
<meta name="keywords" content="<?php echo $meta_keyword_home; ?>">
<meta name="description" content="<?php echo $meta_description_home; ?>">
<?php
}
if($cur_page == 'customer-billing-shipping-update.php') {
?>
<title>Update Billing and Shipping Info - <?php echo $meta_title_home; ?></title>
<meta name="keywords" content="<?php echo $meta_keyword_home; ?>">
<meta name="description" content="<?php echo $meta_description_home; ?>">
<?php
}
if($cur_page == 'customer-password-update.php') {
?>
<title>Update Password - <?php echo $meta_title_home; ?></title>
<meta name="keywords" content="<?php echo $meta_keyword_home; ?>">
<meta name="description" content="<?php echo $meta_description_home; ?>">
<?php
}
if($cur_page == 'customer-order.php') {
?>
<title>Orders - <?php echo $meta_title_home; ?></title>
<meta name="keywords" content="<?php echo $meta_keyword_home; ?>">
<meta name="description" content="<?php echo $meta_description_home; ?>">
<?php
}
?>
<?php if($cur_page == 'blog-single.php'): ?>
<meta property="og:title" content="<?php echo $og_title; ?>">
<meta property="og:type" content="website">
<meta property="og:url" content="<?php echo BASE_URL.$og_slug; ?>">
<meta property="og:description" content="<?php echo $og_description; ?>">
<meta property="og:image" content="assets/uploads/<?php echo $og_photo; ?>">
<?php endif; ?>
<?php if($cur_page == 'product.php'): ?>
<meta property="og:title" content="<?php echo $og_title; ?>">
<meta property="og:type" content="website">
<meta property="og:url" content="<?php echo BASE_URL.$og_slug; ?>">
<meta property="og:description" content="<?php echo $og_description; ?>">
<meta property="og:image" content="assets/uploads/<?php echo $og_photo; ?>">
<?php endif; ?>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
<script type="text/javascript" src="//platform-api.sharethis.com/js/sharethis.js#property=5993ef01e2587a001253a261&product=inline-share-buttons"></script>
<?php echo $before_head; ?>
</head>
<body>
<?php echo $after_body; ?>
<!--
<div id="preloader">
<div id="status"></div>
</div>-->
<!-- top bar -->
<div class="top">
<div class="container">
<div class="row">
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="left">
<ul>
<li><i class="fa fa-phone"></i> <?php echo $contact_phone; ?></li>
<li><i class="fa fa-envelope-o"></i> <?php echo $contact_email; ?></li>
</ul>
</div>
</div>
<div class="col-md-6 col-sm-6 col-xs-12">
<div class="right">
<ul>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_social");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<?php if($row['social_url'] != ''): ?>
<li><a href="<?php echo $row['social_url']; ?>"><i class="<?php echo $row['social_icon']; ?>"></i></a></li>
<?php endif; ?>
<?php
}
?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="header">
<div class="container">
<div class="row inner">
<div class="col-md-4 logo">
<a href="index.php"><img src="assets/uploads/<?php echo $logo; ?>" alt="logo image"></a>
</div>
<div class="col-md-5 right">
<ul>
<?php
if(isset($_SESSION['customer'])) {
?>
<li><i class="fa fa-user"></i> <?php echo LANG_VALUE_13; ?> <?php echo $_SESSION['customer']['cust_name']; ?></li>
<li><a href="dashboard.php"><i class="fa fa-home"></i> <?php echo LANG_VALUE_89; ?></a></li>
<?php
} else {
?>
<li><a href="login.php"><i class="fa fa-sign-in"></i> <?php echo LANG_VALUE_9; ?></a></li>
<li><a href="registration.php"><i class="fa fa-user-plus"></i> <?php echo LANG_VALUE_15; ?></a></li>
<?php
}
?>
<li><a href="cart.php"><i class="fa fa-shopping-cart"></i> <?php echo LANG_VALUE_19; ?> (<?php echo LANG_VALUE_1; ?><?php
if(isset($_SESSION['cart_p_id'])) {
$table_total_price = 0;
$i=0;
foreach($_SESSION['cart_p_qty'] as $key => $value)
{
$i++;
$arr_cart_p_qty[$i] = $value;
} $i=0;
foreach($_SESSION['cart_p_current_price'] as $key => $value)
{
$i++;
$arr_cart_p_current_price[$i] = $value;
}
for($i=1;$i<=count($arr_cart_p_qty);$i++) {
$row_total_price = $arr_cart_p_current_price[$i]*$arr_cart_p_qty[$i];
$table_total_price = $table_total_price + $row_total_price;
}
echo $table_total_price;
} else {
echo '0.00';
}
?>)</a></li>
</ul>
</div>
<div class="col-md-3 search-area">
<form class="navbar-form navbar-left" role="search" action="search-result.php" method="get">
<?php $csrf->echoInputField(); ?>
<div class="form-group">
<input type="text" class="form-control search-top" placeholder="<?php echo LANG_VALUE_2; ?>" name="search_text">
</div>
<button type="submit" class="btn btn-default"><?php echo LANG_VALUE_3; ?></button>
</form>
</div>
</div>
</div>
</div>
<div class="nav">
<div class="container">
<div class="row">
<div class="col-md-12 pl_0 pr_0">
<div class="menu-container">
<div class="menu">
<ul>
<li><a href="index.php">Home</a></li>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_top_category WHERE show_on_menu=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
?>
<li><a href="product-category.php?id=<?php echo $row['tcat_id']; ?>&type=top-category"><?php echo $row['tcat_name']; ?></a>
<ul>
<?php
$statement1 = $pdo->prepare("SELECT * FROM tbl_mid_category WHERE tcat_id=?");
$statement1->execute(array($row['tcat_id']));
$result1 = $statement1->fetchAll(PDO::FETCH_ASSOC);
foreach ($result1 as $row1) {
?>
<li><a href="product-category.php?id=<?php echo $row1['mcat_id']; ?>&type=mid-category"><?php echo $row1['mcat_name']; ?></a>
<ul>
<?php
$statement2 = $pdo->prepare("SELECT * FROM tbl_end_category WHERE mcat_id=?");
$statement2->execute(array($row1['mcat_id']));
$result2 = $statement2->fetchAll(PDO::FETCH_ASSOC);
foreach ($result2 as $row2) {
?>
<li><a href="product-category.php?id=<?php echo $row2['ecat_id']; ?>&type=end-category"><?php echo $row2['ecat_name']; ?></a></li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
</ul>
</li>
<?php
}
?>
<?php
$statement = $pdo->prepare("SELECT * FROM tbl_page WHERE id=1");
$statement->execute();
$result = $statement->fetchAll(PDO::FETCH_ASSOC);
foreach ($result as $row) {
$about_title = $row['about_title'];
$faq_title = $row['faq_title'];
$blog_title = $row['blog_title'];
$contact_title = $row['contact_title'];
$pgallery_title = $row['pgallery_title'];
$vgallery_title = $row['vgallery_title'];
}
?>
<li><a href="about.php"><?php echo $about_title; ?></a></li>
<li><a href="faq.php"><?php echo $faq_title; ?></a></li>
<li><a href="contact.php"><?php echo $contact_title; ?></a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>