-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuy.php
211 lines (161 loc) · 5.18 KB
/
buy.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
<?php
session_start();
$id="";
if (isset($_COOKIE["user"])) {
$cookie = $_COOKIE["user"];
$value = explode("-",$cookie);
$user_id = $value[2];
if (stripos($_COOKIE["user"], "admin") !== false) {
$user = "admin";
}
else {
$user = "user";
}
}
else {
$user = "oauth";
$user_id = "";
}
?>
<html lang="en" data-bs-theme="light"><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
<meta name="generator" content="Hugo 0.122.0">
<title>YRprey - Buy</title>
<link href="css/styles.css" rel="stylesheet" />
</head>
<body class="d-flex align-items-center py-4 bg-body-tertiary">
<?php
include("nav.php");
?>
<main class="form-signin w-100 m-auto">
<?php
include("database.php");
if (isset($_GET["product"])) {
$product = $_GET["product"];
$msg = '';
$query = "SELECT * FROM users where id='" . $user_id . "'";
$result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
$exist = 0;
$exist = mysqli_num_rows($result);
if ($exist > 0) {
$rw = mysqli_fetch_assoc($result);
$username = $rw["username"];
}
$query = "SELECT * FROM tool where id='" . $product . "'";
$result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
$row = mysqli_num_rows($result);
if ($row > 0 and $user !== "admin" and $user === "user") {
$rw = mysqli_fetch_assoc($result);
$id = $rw["id"];
$name = $rw["name"];
$category = $rw["category"];
$img = $rw["img"];
$price = $rw["price"];
$description = $rw["description"];
$q = "INSERT INTO orders (id, name, product, img, price) VALUES (NULL, '$username', '$name', '$img', '$price')";
$inserted = mysqli_query($mysqli, $q);
}
if ($row > 0 and $user !== "admin" and $user === "user") {
$query = "SELECT * FROM warrior where id='" . $product . "'";
$result = mysqli_query($mysqli, $query) or die(mysqli_error($mysqli));
$row = mysqli_num_rows($result);
if ($row > 0 and $user !== "admin") {
$rw = mysqli_fetch_assoc($result);
$id = $rw["id"];
$name = $rw["name"];
$category = $rw["category"];
$img = $rw["img"];
$price = $rw["price"];
$description = $rw["description"];
$q = "INSERT INTO orders (id, name, product, img, price) VALUES (NULL, '$username', '$name', '$img', '$price')";
$inserted = mysqli_query($mysqli, $q);
}
}
if (empty($name)) {
$msg ='<div class="alert alert-danger" role="alert">
Product not found!
</div>';
}
if ($user === "oauth") {
$msg ='<div class="alert alert-danger" role="alert">
Not authenticated!
</div>';
}
if ($user === "admin") {
$msg ='<div class="alert alert-danger" role="alert">
You are admin, not have permission!
</div>';
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Framework Vulnerable">
<meta name="author" content="Fernando Mengali">
<link rel="icon" href="img/favicon.svg">
<title>Checkout for Product</title>
<link rel="canonical" href="https://getbootstrap.com/docs/4.0/examples/checkout/">
<!-- Bootstrap core CSS -->
<link href="../../dist/css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="form-validation.css" rel="stylesheet">
</head>
<body class="bg-light">
<br><br>
<div class="container">
<div class="py-5 text-center">
<?php
if (empty($msg)) {
?>
<h2 style="color: rgb(25,135,84,1);">✅ Purchase made successfully!!</h2>
<p class="lead">Thank you very much for your purchase.</p>
<?php
}
else {
print $msg."";
}
?>
</div>
<?php
if (empty($msg)) {
?>
<div class="row">
<div class="col-md-4 order-md-2 mb-4">
<h4 class="d-flex justify-content-between align-items-center mb-3">
<span class="text-muted">Your Purchase</span>
<span class="badge badge-secondary badge-pill">3</span>
</h4>
<ul class="list-group mb-3">
<li class="list-group-item d-flex justify-content-between lh-condensed">
<div>
<h6 class="my-0"><?php echo $name; ?></h6>
<small class="text-muted"><?php echo $description; ?></small>
</div>
<span class="text-muted"><?php echo $price; ?> BTC</span>
</li>
<li class="list-group-item d-flex justify-content-between">
<span>Total (BTC)</span>
<strong><?php echo $price; ?></strong>
</li>
</ul>
</div>
<div class="col-md-8 order-md-1">
<div class="mb-3">
<img class="card-img-top mb-5 mb-md-0" src="img/<?php echo $img; ?>" alt="...">
</div>
</form>
</div>
</div>
<?php
}
?>
</div>
<?php include("footer.php"); ?>
</body>
</html>