-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathverification.php
440 lines (370 loc) · 20.8 KB
/
verification.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
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<?php
$title = 'Verification';
include_once 'includes/layout/header.php';
include_once "includes/functions.php";
include_once "includes/botconfig.php";
include_once __DIR__.'/../vendor/autoload.php';
?>
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
ini_set('max_execution_time', 300); //300 seconds = 5 minutes. In case if your CURL is slow and is loading too much (Can be IPv6 problem)
error_reporting(E_ALL);
define('OAUTH2_CLIENT_ID', '816007320454430798');
define('OAUTH2_CLIENT_SECRET', 'FjY6v6hTRPjcQmT4Te6KXGmWmpT5Vbxy');
$authorizeURL = 'https://discord.com/api/oauth2/authorize';
$tokenURL = 'https://discord.com/api/oauth2/token';
$apiURLBase = 'https://discord.com/api/users/@me';
@session_start();
// Start the login process by sending the user to Discord's authorization page
if(get('action') == 'login') {
$params = array(
'client_id' => OAUTH2_CLIENT_ID,
'redirect_uri' => 'https://ixwhere.online/verification',
'response_type' => 'code',
'scope' => 'identify guilds'
);
// Redirect the user to Discord's authorization page
header('Location: https://discordapp.com/api/oauth2/authorize' . '?' . http_build_query($params));
die();
}
unset($_SESSION['access_token']);
// When Discord redirects the user back here, there will be a "code" and "state" parameter in the query string
if(get('code')) {
// Exchange the auth code for a token
$token = apiRequest($tokenURL, array(
"grant_type" => "authorization_code",
'client_id' => OAUTH2_CLIENT_ID,
'client_secret' => OAUTH2_CLIENT_SECRET,
'redirect_uri' => 'https://ixwhere.online/verification',
'code' => get('code')
));
$logout_token = $token->access_token;
$_SESSION['access_token'] = $token->access_token;
header('Location: ' . $_SERVER['PHP_SELF']);
}
if(session('access_token')) {
$user = apiRequest($apiURLBase);
$discordID = htmlspecialchars($user->id);
if(checkVerification($user->id) == 1){
if(checkVerified($user->id) == 0){
try{
if(checkDiscordID($user->id) == 1){
$user = pdoQuery($db, "SELECT `username` FROM `users` WHERE `discordID`=?", [htmlspecialchars($discordID)])->fetchColumn();
$checkBanned = pdoQuery($db, "SELECT `banned` FROM `users` WHERE `discordID`=?", [htmlspecialchars($discordID)])->fetchColumn();
$checkBanreason = pdoQuery($db, "SELECT `banreason` FROM `users` WHERE `discordID`=?", [htmlspecialchars($discordID)])->fetchColumn();
if($checkBanned == 1){
try{
$discord->channel->createMessage(
[
'channel.id' => $verificationChannel,
'embed' => [
'timestamp' => date("c"),
"color" => hexdec("#ff0000"),
'title' => 'On-Site Verification Failed '.date('Y-m-d H:i:s'),
"thumbnail" => [
"url" => "https://ixwhere.online/resources/img/logo.png"
],
"image" => [
"url" => "https://ixwhere.online/resources/img/IXWARE.gif"
],
"author" => [
"name" => "IXWare",
"url" => "https://www.ixwhere.online/"
],
"footer" => [
"text" => "Powered by ixwhere.online",
"icon_url" => "https://ixwhere.online/resources/img/logo.png"
],
"fields" => [
[
"name" => "Username",
"value" => htmlspecialchars($user)
],
[
"name" => "ID",
"value" => htmlspecialchars($discordID)
],
[
"name" => "Reason",
"value" => "Banned"
],
[
"name" => "Ban Reason",
"value" => htmlspecialchars($checkBanreason)
],
]
],
]
);
}catch(Exception $e){}
$PDODelete = $db -> prepare('DELETE FROM `discord_verification` WHERE `id` = :id');
$PDODelete -> execute(array(':id' => $id));
try{
$discord->channel->createMessage(['channel.id' => $publicVerifyChannel, 'content' => "<@$discordID> you are banned from IXWare and can't get verified."]);
}catch(Exception $e){}
}
}
// Input your options for this query including your optional API Key and query flags.
$proxycheck_options = array(
'API_KEY' => '6l6v42-5704xl-8et094-01q584', // Your API Key.
'ASN_DATA' => 1, // Enable ASN data response.
'DAY_RESTRICTOR' => 7, // Restrict checking to proxies seen in the past # of days.
'VPN_DETECTION' => 1, // Check for both VPN's and Proxies instead of just Proxies.
'RISK_DATA' => 1, // 0 = Off, 1 = Risk Score (0-100), 2 = Risk Score & Attack History.
'INF_ENGINE' => 1, // Enable or disable the real-time inference engine.
'TLS_SECURITY' => 0, // Enable or disable transport security (TLS).
'QUERY_TAGGING' => 1, // Enable or disable query tagging.
);
$result_array = \proxycheck\proxycheck::check(realIP(), $proxycheck_options);
if ($result_array['block'] == "yes" ) {
try{
$discord->channel->createMessage(
[
'channel.id' => $verificationChannel,
'embed' => [
'timestamp' => date("c"),
"color" => hexdec("#ff0000"),
'title' => 'On-Site Verification Failed '.date('Y-m-d H:i:s'),
"thumbnail" => [
"url" => "https://ixwhere.online/resources/img/logo.png"
],
"image" => [
"url" => "https://ixwhere.online/resources/img/IXWARE.gif"
],
"author" => [
"name" => "IXWare",
"url" => "https://www.ixwhere.online/"
],
"footer" => [
"text" => "Powered by ixwhere.online",
"icon_url" => "https://ixwhere.online/resources/img/logo.png"
],
"fields" => [
[
"name" => "ID",
"value" => htmlspecialchars($discordID)
],
[
"name" => "Reason",
"value" => htmlspecialchars($result_array['block_reason'])
],
[
"name" => "IP",
"value" => realIP()
],
]
],
]
);
}catch(Exception $e){}
try{
$discord->channel->createMessage(['channel.id' => $publicVerifyChannel, 'content' => "<@$discordID> verification failed, contact an administrator."]);
}catch(Exception $e){}
}
if(empty($error)){
try{
$check = json_encode($discord->guild->getGuildMember(['guild.id' => $guildid, 'user.id' => (int)$discordID]));
if(strpos($check, "nick")){
$discordJSON = json_decode($check, 1);
$discordJSON1 = json_encode($discordJSON["user"]);
$discordJSON2 = json_decode($discordJSON1, 1);
$PDOLog = $db -> prepare('INSERT INTO `discord_verified` VALUES(:id, :username, :ip, :agent, :date)');
$PDOLog -> execute(array(':id' => htmlspecialchars($discordJSON2['id']), ':username' => htmlspecialchars($discordJSON2['username']) . '#' . htmlspecialchars($discordJSON2['discriminator']), ':ip' => encrypt(realIP()), ':agent' => htmlspecialchars($_SERVER['HTTP_USER_AGENT']), ':date' => date("Y-m-d H:i:s")));
$PDODelete = $db -> prepare('DELETE FROM `discord_verification` WHERE `discordID` = :id');
$PDODelete -> execute(array(':id' => $discordID));
if(checkDiscordID($discordID)){
$discord->guild->addGuildMemberRole(['guild.id' => $guildid, 'user.id' => (int)$discordID, 'role.id' => $registeredID]);
$discordIDRank = pdoQuery($db, "SELECT `rank` FROM `users` WHERE `discordID`=?", [htmlspecialchars($discordID)])->fetchColumn(0);
if($discordIDRank == "Premium"){
$discord->guild->addGuildMemberRole(['guild.id' => $guildid, 'user.id' => (int)$discordID, 'role.id' => $membershipID]);
}
}
$discord->guild->addGuildMemberRole(['guild.id' => $guildid, 'user.id' => (int)$discordID, 'role.id' => $regularID]);
try{
$discord->channel->createMessage(['channel.id' => $publicVerifyChannel, 'content' => " <@$discordID> Successfully verified."]);
}catch(Exception $e){}
if(checkAlts(encrypt(realIP())) > 1){
$get = pdoQuery($db, "SELECT * FROM `discord_verified` WHERE `ip`=?", [htmlspecialchars(encrypt(realIP()))]);
$results = $get->fetchAll(PDO::FETCH_ASSOC);
$a = array();
foreach($results as $result){
$id = htmlspecialchars($result['id']);
$user = htmlspecialchars($result['username']);
$tog = "$id - $user";
array_push($a, $tog);
}
array_pop($a);
$string = rtrim(implode("\xA", $a), "\xA");
$color = "#ff0000";
//$discord->guild->createGuildBan(['guild.id' => $guildid, 'user.id' => (int)$id, 'delete-message-days' => "7", 'reason' => "Alts"]);
}else{
$string = "None";
$color = "#00ff04";
}
$success = "Successfully verified your discord account.";
$user = pdoQuery($db, "SELECT `username` FROM `discord_verified` WHERE `id`=?", [htmlspecialchars($discordID)])->fetchColumn(0);
try{
$discord->channel->createMessage(
[
'channel.id' => $verificationChannel,
'embed' => [
'timestamp' => date("c"),
"color" => hexdec($color),
'title' => 'On-Site Verification '.date('Y-m-d H:i:s'),
"thumbnail" => [
"url" => "https://ixwhere.online/resources/img/logo.png"
],
"image" => [
"url" => "https://ixwhere.online/resources/img/IXWARE.gif"
],
"author" => [
"name" => "IXWare",
"url" => "https://www.ixwhere.online/"
],
"footer" => [
"text" => "Powered by ixwhere.online",
"icon_url" => "https://ixwhere.online/resources/img/logo.png"
],
"fields" => [
[
"name" => "Username",
"value" => htmlspecialchars($user)
],
[
"name" => "ID",
"value" => htmlspecialchars($discordID)
],
[
"name" => "Alt's Detected (Banned Main and Alt)",
"value" => "```$string```"
],
]
],
]
);
}catch(Exception $e){}
}else{
$PDODelete = $db -> prepare('DELETE FROM `discord_verification` WHERE `id` = :id');
$PDODelete -> execute(array(':id' => $id));
$error = "An error occured. Make sure you are in the discord server.";
}
}catch(Exception $e){
$error = "An error occured. Ignore this message if you still got verified in the discord server.";
}
}
}catch(Exception $e){
if(checkVerified($discordUserID) == 1){
$PDODelete = $db -> prepare('DELETE FROM `discord_verified` WHERE `id` = :id');
$PDODelete -> execute(array(':id' => $discordUserID));
}
try{
$discord->channel->createMessage(['channel.id' => $publicVerifyChannel, 'content' => "<@$discordID> couldn't verify you, discord bot is most likely ratelimited, please try again later."]);
}catch(Exception $e){}
}
}
}
}
function apiRequest($url, $post=FALSE, $headers=array()) {
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
if($post)
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post));
$headers[] = 'Accept: application/json';
if(session('access_token'))
$headers[] = 'Authorization: Bearer ' . session('access_token');
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
return json_decode($response);
}
function get($key, $default=NULL) {
return array_key_exists($key, $_GET) ? $_GET[$key] : $default;
}
function session($key, $default=NULL) {
return array_key_exists($key, $_SESSION) ? $_SESSION[$key] : $default;
}
?>
<body>
<!--Main Navigation-->
<nav class="navbar navbar-expand-lg bg-transparent navbar-dark fixed-top scrolling-navbar">
<div class="logo-wrapper waves-light mt-1 ml-3 d-none d-sm-block" style="width:100%">
<a class="navbar-brand" href="index">ixwhere.online</a>
</div>
<div class="container-fluid">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent-7"
aria-controls="navbarSupportedContent-7" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent-7">
<ul class="navbar-nav nav-flex-icons ml-auto">
<li class="nav-item">
<a class="nav-link waves-effect waves-light" href="<?php echo htmlspecialchars(discordserver()); ?>" target="_blank"><i class="fab fa-discord"></i></a>
</li>
<li class="nav-item">
<a class="nav-link waves-effect waves-light" href="https://youtu.be/PSSq5jKGNKU" target="_blank"><i class="fab fa-youtube"></i></a>
</li>
</ul>
</div>
</div>
</nav>
<section id="particles-js" class="purple-gradient-rgba" style="position: fixed;height:100%;width:100%;">
<div class="mask">
<div class="container-fluid h-100 d-flex justify-content-center align-items-center ">
<div class="row">
<div class="col-xl-4 col-12 col-sm-10 col-lg-7 col-md-11 centered">
<div class="card opacity-card">
<div class="card-body d-flex flex-column">
<div style="display:inline-block;">
<button type='button' data-toggle="modal" data-target="#view-modal" style="border: none; outline: none; background: none; cursor: pointer; color: #fff; padding: 0; text-decoration: underline; font-family: inherit; font-size: inherit;">On-Site verification safety</button>
</div>
<h4 class="text-center text-white mt-5">IXWare</h4>
<p class="text-center text-white">We need to verify your discord account</p>
<?php
if(!empty($error)){
echo '<div class="animated fadeIn sticky-top">'.error(htmlspecialchars($error)).'</div>';
}
if(!empty($success)){
echo '<div class="animated fadeIn sticky-top">'.success(htmlspecialchars($success)).'</div>';
}
?>
<div class="text-center">
<a href="?action=login" class="btn btn-outline-light text-darkwhite w-75 btn-login" style="width: 100%;">Verify with discord</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
<!--Main Navigation-->
<!-- Central Modal Small -->
<div class="modal fade" id="view-modal" tabdashboard="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<!-- Change class .modal-sm to change the size of the modal -->
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header bg-dark text-darkwhite">
<h5 class="modal-title w-100" id="myModalLabel">On-Site verification safety</h5>
<button type="button" class="close text-white" data-dismiss="modal" aria-label="Close" id="modalButton">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body bg-dark text-darkwhite">
The on-site verification works via OAuth2 which means we work with the discord api to verify your discord account in our server. We only have access to your id and your guilds. Your ID will be stored in our database for future verifications.
</div>
</div>
</div>
</div>
<!-- Central Modal Small -->
<!-- SCRIPTS -->
<?php require_once 'includes/layout/footer.php'; ?>
<!-- Particles -->
<script src="resources/js/particles.js"></script>
<script src="resources/js/app.js"></script>
</body>
</html>