-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhub.php
217 lines (204 loc) · 10.1 KB
/
hub.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
<?php require 'inc/_global/config.php'; ?>
<?php require 'inc/backend/config.php'; ?>
<?php require 'inc/_global/views/head_start.php'; ?>
<?php require 'inc/_global/views/head_end.php';
if (!$user->hasMembership($odb)) {
header('location: index.php');
exit;
}
?>
<?php require 'inc/_global/views/page_start.php';
$SQLCount = $odb -> prepare("SELECT * FROM `users` WHERE `username` = ?");
$SQLCount -> execute(array($_SESSION['username']));
$membership = $SQLCount -> fetch(PDO::FETCH_BOTH)['membership'];
$SQLCount = $odb -> prepare("SELECT * FROM `plans` WHERE `ID` = ?");
$SQLCount -> execute(array($membership));
$show = $SQLCount -> fetch(PDO::FETCH_ASSOC);
$SQLCheck = $odb -> prepare("SELECT COUNT(*) FROM `logs` WHERE `username` = ? AND `date` > ?");
$SQLCheck -> execute(array($_SESSION['username'], strtotime(date('d-m-Y 00:00:00'))));
$limit = $SQLCheck->fetch();
$nbGen = $show['limit']-$limit[0];
if ($nbGen <= 0){
$nbGen = 0;
}
$recupLot = $odb->prepare('SELECT * FROM logs_loterie WHERE username = ? AND used = 0 and date > ?');
$recupLot->execute(array($_SESSION['username'],strtotime(date('d-m-Y 00:00:00'))));
$recupLot = $recupLot->fetch();
$nbGen = $nbGen + $recupLot['nb'];
?>
<!-- Hero -->
<div class="bg-body-light">
<div class="content content-full">
<div class="d-flex flex-column flex-sm-row justify-content-sm-between align-items-sm-center">
<h1 class="flex-sm-fill font-size-h2 font-w400 mt-2 mb-0 mb-sm-2">The different dispensers</h1>
<nav class="flex-sm-00-auto ml-sm-3" aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item">Dispenser</li>
<li class="breadcrumb-item active" aria-current="page">My dispensers</li>
</ol>
</nav>
</div>
</div>
</div>
<!-- END Hero -->
<!-- Page Content -->
<div class="content">
<div class="block block-rounded block-bordered">
<div class="block-header block-header-default">
<h3 class="block-title">Dispenser</h3>
<div class="block-options">
<div class="block-options-item">
<?php
if ($nbGen > 1){
echo '<div class="alert alert-info py-2 mb-0"><i class="fa fa-info-circle mr-1"></i> '.$nbGen.' remaining Dispensering</div>';
} elseif ($nbGen == 1){
echo '<div class="alert alert-warning py-2 mb-0"><i class="fas fa-exclamation-triangle"></i> 1 remaining generation</div>';
} elseif ($nbGen < 1){
echo '<div class="alert alert-danger py-2 mb-0"><i class="fas fa-exclamation-circle"></i> No generation left</div>';
}
?>
</div>
</div>
</div>
<div class="content content-narrow">
<div class="row push">
<div class="col-lg-12" id="div"></div>
<div class="col-lg-12">
<form class="form-horizontal push-10-t push-10" method="post" onsubmit="return false;">
<div class="form-group row items-push mb-0">
<?php
$membershipSQL = $odb -> prepare("SELECT * FROM `users` WHERE `username` = ?");
$membershipSQL -> execute(array($_SESSION['username']));
$membership = $membershipSQL -> fetch(PDO::FETCH_ASSOC)['membership'];
$accountsSQL = $odb -> prepare("SELECT * FROM `plans` WHERE `ID` = ?");
$accountsSQL -> execute(array($membership));
$accounts = $accountsSQL -> fetch(PDO::FETCH_ASSOC)['accounts'];
$accountsArray = explode(',', $accounts);
foreach ($accountsArray as $account) {
$recupType = $odb->prepare('SELECT * FROM type WHERE name = ?');
$recupType->execute(array($account));
foreach ($recupType as $recupType) {
echo '
<div class="col-md-2">
<div class="custom-control custom-block custom-control-primary mb-1">
<input type="radio" value="'.$account.'" class="custom-control-input" id="example-rd-custom-block'.$account.'" name="example-rd-custom-block">
<label class="custom-control-label" for="example-rd-custom-block'.$account.'">
<span class="d-block font-w400 text-center my-3">
<img class="img-avatar img-avatar32" src="'.$recupType['img'].'" alt=""></br>
<span class="font-size-h4 font-w600">'.$account.'</span>
</span>
</label>
</div>
</div>
';
}
}
?>
<div class="row" style="padding-top: 200px;">
<div class="col">
<button type="button" class="btn btn-hero-success js-click-ripple-enabled" onclick="generate()" type="submit" data-toggle="click-ripple" style="margin-right:auto;margin-left:auto;overflow: hidden; position: relative; z-index: 1;">Generate an account</button>
</div>
<div class="col">
<div class="form-group row" style="margin-right: auto;margin-left: auto;width: 40%;">
<div class="col-xs-12" data-children-count="1">
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
<div class="content">
<div class="block block-rounded block-bordered">
<h3 style='display: none;'> <i style="display: none;" id="manage" class="fa fa-cog fa-spin"></i> </h3>
<h3 style='display: none;'>
<i style="display: none;" id="image" class="fa fa-cog fa-spin"></i>
</h3>
<div class="block-content">
<div class="animated zoomIn" id="recentdiv" style="display:inline-block;width:100%"></div>
</div>
</div>
</div>
<?php require 'inc/_global/views/page_end.php'; ?>
<script>
logs();
function logs() {
document.getElementById("recentdiv").style.display = "none";
document.getElementById("manage").style.display = "inline";
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("recentdiv").innerHTML = xmlhttp.responseText;
document.getElementById("manage").style.display = "none";
document.getElementById("recentdiv").style.display = "inline-block";
document.getElementById("recentdiv").style.width = "100%";
eval(document.getElementById("ajax").innerHTML);
}
}
xmlhttp.open("GET", "inc/ajax/user/hub/recent.php", true);
xmlhttp.send();
}
function generate() {
var type = document.querySelector('input[name="example-rd-custom-block"]:checked').value;
document.getElementById("image").style.display = "inline";
document.getElementById("div").style.display = "none";
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("image").style.display = "none";
if (xmlhttp.responseText.search("success") != -1) {
logs();
document.getElementById("div").innerHTML = xmlhttp.responseText;
document.getElementById("div").style.display = "inline";
} else {
document.getElementById("div").innerHTML = xmlhttp.responseText;
document.getElementById("div").style.display = "inline";
}
}
}
xmlhttp.open("GET", "inc/ajax/user/hub/hub.php?type=" + type, true);
xmlhttp.send();
}
function generateMultiple() {
var type = document.querySelector('input[name="example-rd-custom-block"]:checked').value;
var nb = document.querySelector('input[name="nb"]').value;
document.getElementById("image").style.display = "inline";
document.getElementById("div").style.display = "none";
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById("image").style.display = "none";
if (xmlhttp.responseText.search("success") != -1) {
logs();
document.getElementById("div").innerHTML = xmlhttp.responseText;
document.getElementById("div").style.display = "inline";
} else {
document.getElementById("div").innerHTML = xmlhttp.responseText;
document.getElementById("div").style.display = "inline";
}
}
}
xmlhttp.open("GET", "inc/ajax/user/hub/hub.php?type=" + type + "&nb=" + nb, true);
xmlhttp.send();
}
</script>
<?php require 'inc/_global/views/footer_start.php'; ?>
<?php require 'inc/_global/views/footer_end.php'; ?>