/
createPlayer.php
67 lines (60 loc) · 1.73 KB
/
createPlayer.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
<?php
//Registers a new player into the player master table.
if($_SERVER["REQUEST_METHOD"] == "POST")
{
//Verifies Name is in valid format
if(isset($_POST['rMemName']) && preg_match("/^[a-zA-Z0-9.' ]+$/",$_POST['rMemName']) && strlen($_POST['rMemName']) < 35)
{
$playerName = $_POST['rMemName'];
}
else
{
header("Location:index.html?type=err");
}
//Verifies Email is in valid format
if(isset($_POST['rMemEmail']) && preg_match('/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{1,4}$/',$_POST['rMemEmail']) && strlen($_POST['rMemEmail']) < 50)
{
$playerEmail = $_POST['rMemEmail'];
}
else
{
header("Location:index.html?type=err");
}
//Verifies Password is in valid format
if(isset($_POST['rMemPassword']) && preg_match('/^[a-zA-Z0-9._%+!$@ ]+$/',$_POST['rMemPassword']) && strlen($_POST['rMemPassword']) < 30)
{
$playerPassword = $_POST['rMemPassword'];
}
else
{
header("Location:index.html?type=err");
}
//Verifies the captcha is set
if(isset($_POST['g-recaptcha-response']))
{
$captcha=$_POST['g-recaptcha-response'];
}
else
{
header("Location:index.html?type=err");
}
//get captcha secret
$config = parse_ini_file('config.php');
$secret = $config['secret'];
//Validates the captcha value from google server
$response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=$secret&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
$data = json_decode($response);
//If its a bot it redirects to index
if($data->success==false)
{
header("Location:index.html?type=err");
}
//If not a bot then tries to register the player
else
{
include('player_access.php');
$register = new access();
$register->register_player($playerName,$playerEmail,$playerPassword);
}
}
?>