-
Notifications
You must be signed in to change notification settings - Fork 0
/
store.php
141 lines (134 loc) · 4.52 KB
/
store.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
<?php
require_once("includes/setup.php");
if ($isLogedIn) {
$user = $_SESSION['user'];
}
$page = setPage($_GET['page']);
$num_per_page = 12;
if(isset($_GET["addid"])) {
if(!$isLogedIn) {
header("Location: store.php");
}
if($_GET['token'] == $_SESSION['token']){
$productId = sanitize($_GET["addid"]);
if(validateInt((int)$productId)){
$db->addProductToCart($user->getUserName(), $productId);
header("Location: store.php?page=$page");
}
}
}
$token = md5(uniqid(rand(), TRUE));
$_SESSION['token'] = $token;
require_once("includes/header.php");
?>
<div id="menu_wrapper">
<div id="menu_container">
<!--<div id="menu_object_container">-->
<a href="index.php" class="menu_object">
HOME
</a>
<a href="store.php?browseall" class="menu_object_active">
STORE
</a>
<a href="about.php" class="menu_object">
ABOUT
</a>
<a href="help.php" class="menu_object">
HELP
</a>
<?php if($isLogedIn) { ?>
<a href="includes/logout_parse.php" class="menu_object" style="float: right;">
SIGN OUT
</a>
<?php } ?>
<!--</div>-->
</div>
</div>
<div id="content_wrapper">
<div id="content">
<div id="store_menu">
<?php if(isset($_GET['browseall']) || !isset($_GET['browsecategory'])) { ?>
<a href="store.php?browseall" class="store_menu_object active">
BROWSING ALL
<?php } else { ?>
<a href="store.php?browseall" class="store_menu_object">
BROWSE ALL
<?php } ?>
</a>
<?php if(isset($_GET['browsecategory'])) { ?>
<a href="store.php?browsecategory" class="store_menu_object active">
BROWSING BY CATEGORY
<?php } else { ?>
<a href="store.php?browsecategory" class="store_menu_object" id="cat">
BROWSE BY CATEGORY
<?php } ?>
</a>
</div>
<?php if(isset($_GET['browseall']) || !isset($_GET['browsecategory'])) { ?>
<div class="store_header_box">
PROMOTED
</div>
<?php $promoted = $db->listPromotedProducts(); ?>
<?php foreach($promoted as $promotedproduct) { ?>
<div class="promoted_store_object">
<div class="promoted_category">
<?php echo strtoupper($promotedproduct['categoryName']); ?>
</div>
<div class="promoted_picture" style="background-image:url('images/products/<?php echo $promotedproduct['productName']; ?>.png')">
<img src="" class="image_promoted" />
</div>
<div class="promoted_name">
<?php echo strtoupper($promotedproduct['productName']); ?>
</div>
<div class="promoted_info">
Anno 1961 <br/>
<?php echo $promotedproduct['price']; ?> SEK
</div>
<div class="buy_now">
<?php if($isLogedIn) { ?>
<a href="store.php?page=<?php echo $page; ?>&addid=<?php echo $promotedproduct['productId']; ?>&token=<?php echo $token; ?>" class="lgreen_to_dgreen">BUY NOW</a>
<?php } else { echo "Log in to buy"; } ?>
</div>
</div>
<?php } ?>
<div class="store_header_box">
PRODUCTS
<div id="paginate">
<?php
$total_pages = $db->getPages($num_per_page);
echo "<a href='store.php?browseall&page=1' class='lgreen_to_dgreen'>".'|<'."</a> ";
for ($i=1; $i<=$total_pages; $i++) {
echo "<a href='store.php?browseall&page=".$i."' class='lgreen_to_dgreen'>".$i."</a> ";
};
echo "<a href='store.php?browseall&page=$total_pages' class='lgreen_to_dgreen'>".'>|'."</a> ";
?>
</div>
</div>
<?php $products = $db->getProductsPaginate($page, $num_per_page); ?>
<?php foreach($products as $product) { ?>
<div class="store_object">
<div class="product_category">
<?php echo strtoupper($product['categoryName']); ?>
</div>
<div class="product_picture" style="background-image:url('images/products/<?php echo $product['productName']; ?>.png')">
<img src="" class="image_promoted" />
</div>
<div class="product_name">
<?php echo strtoupper($product['productName']); ?>
</div>
<div class="product_info">
<?php echo $product['price']; ?> SEK
</div>
<div class="buy_now small">
<?php if($isLogedIn) { ?>
<a href="store.php?page=<?php echo $page ?>&addid=<?php echo $product['productId']; ?>&token=<?php echo $token; ?>" class="lgreen_to_dgreen">BUY NOW</a>
<?php } else { echo "Log in to buy"; } ?>
</div>
</div>
<?php } ?>
<?php } ?>
</div>
</div>
<?php
require_once("includes/footer.php");
?>