/
registerExecute.php
72 lines (61 loc) · 1.68 KB
/
registerExecute.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
<?php
function isValidEmail($email)
{
$pattern = "/^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/";
if (preg_match($pattern,$email) == 1)
{
return true;
}
else
{
return false;
}
}
if (trim(stripslashes($_POST['username'])) == '' || trim(stripslashes($_POST['password'])) == '')
{
header("location: register.php?badRegister=2");
exit();
}
else if (strlen(trim(stripslashes($_POST['username']))) < 3 || strlen(trim(stripslashes($_POST['password']))) < 3)
{
header("location: register.php?badRegister=3");
exit();
}
else if (!isValidEmail(trim(stripslashes($_POST['email']))))
{
header("location: register.php?badRegister=4");
exit();
}
else if (preg_match("/^\w+$/",trim(stripslashes($_POST['username']))) != 1)
{
header("location: register.php?badRegister=5");
exit();
}
include("class.User.php");
session_start();
if (file_exists("db/Users/".$_POST['username'].".dat"))
{
header("location: register.php?badRegister=1");
exit();
}
$fh = fopen("db/Users/".$_POST['username'].".dat","w");
$hideEmail = 0;
if ($_POST['hideEmail'] == "yes")
{
$hideEmail = 1;
}
$writeString = $_POST['username']."\n".$_POST['password']."\nfalse\n0\n0\n".date("j M Y")."\n1\n\n".$_POST['email']."\n".$hideEmail."\n";
fwrite($fh, $writeString);
fclose($fh);
file_put_contents("db/PMs/".$_POST['username'].".dat","");
$fileC = file("db/forumStatistics.dat",FILE_IGNORE_NEW_LINES);
$fileC[3] = $fileC[3] + 1;
$fileC[4] = $_POST['username'];
$str = "";
foreach ($fileC as $temp)
{
$str .= $temp."\n";
}
file_put_contents("db/forumStatistics.dat",$str);
header("location: index.php");
?>