Skip to content
Newer
Older
100644 73 lines (61 sloc) 1.68 KB
01a7f58 @rosslagerwall Initial commit
authored
1 <?php
2 function isValidEmail($email)
3 {
4 $pattern = "/^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$/";
5
6 if (preg_match($pattern,$email) == 1)
7 {
8 return true;
9 }
10 else
11 {
12 return false;
13 }
14 }
15
16 if (trim(stripslashes($_POST['username'])) == '' || trim(stripslashes($_POST['password'])) == '')
17 {
18 header("location: register.php?badRegister=2");
19 exit();
20 }
21 else if (strlen(trim(stripslashes($_POST['username']))) < 3 || strlen(trim(stripslashes($_POST['password']))) < 3)
22 {
23 header("location: register.php?badRegister=3");
24 exit();
25 }
26 else if (!isValidEmail(trim(stripslashes($_POST['email']))))
27 {
28 header("location: register.php?badRegister=4");
29 exit();
30 }
31 else if (preg_match("/^\w+$/",trim(stripslashes($_POST['username']))) != 1)
32 {
33 header("location: register.php?badRegister=5");
34 exit();
35 }
36
37 include("class.User.php");
38 session_start();
39
40
41
42 if (file_exists("db/Users/".$_POST['username'].".dat"))
43 {
44 header("location: register.php?badRegister=1");
45 exit();
46 }
47
48 $fh = fopen("db/Users/".$_POST['username'].".dat","w");
49 $hideEmail = 0;
50 if ($_POST['hideEmail'] == "yes")
51 {
52 $hideEmail = 1;
53 }
54
55 $writeString = $_POST['username']."\n".$_POST['password']."\nfalse\n0\n0\n".date("j M Y")."\n1\n\n".$_POST['email']."\n".$hideEmail."\n";
56 fwrite($fh, $writeString);
57 fclose($fh);
58
59 file_put_contents("db/PMs/".$_POST['username'].".dat","");
60
61 $fileC = file("db/forumStatistics.dat",FILE_IGNORE_NEW_LINES);
62 $fileC[3] = $fileC[3] + 1;
63 $fileC[4] = $_POST['username'];
64 $str = "";
65 foreach ($fileC as $temp)
66 {
67 $str .= $temp."\n";
68 }
69 file_put_contents("db/forumStatistics.dat",$str);
70
71 header("location: index.php");
72 ?>
Something went wrong with that request. Please try again.