-
Notifications
You must be signed in to change notification settings - Fork 8
/
checkem.php
58 lines (55 loc) · 1.23 KB
/
checkem.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
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
if (isset($_SERVER['REQUEST_METHOD']) && is_string($_SERVER['REQUEST_METHOD']))
{
if (strtoupper($_SERVER['REQUEST_METHOD']) !== 'POST')
{
// Ignore a GET request
header('HTTP/1.1 400 Bad Request');
exit;
}
}
global $db;
require_once('global_func.php');
if (!is_ajax())
{
header('HTTP/1.1 400 Bad Request');
exit;
}
/**
* @param $email
* @return bool
*/
function valid_email($email): bool
{
return (filter_var($email, FILTER_VALIDATE_EMAIL) === $email);
}
require_once('globals_nonauth.php');
$email = isset($_POST['email']) ? stripslashes($_POST['email']) : '';
if (empty($email))
{
die("<font color='red'>Invalid - Blank</font>");
}
if (!valid_email($email))
{
die("<font color='red'>Invalid - Bad Format</font>");
}
$e_email = $db->escape($email);
$q =
$db->query(
"SELECT COUNT(`userid`) FROM users WHERE `email` = '{$e_email}'");
if ($db->fetch_single($q) != 0)
{
echo '<font color=\'red\'>Invalid - Already In Use</font>';
}
else
{
echo '<font color=\'green\'>Valid</font>';
}
$db->free_result($q);