forked from lholliger/ATC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate.php
More file actions
36 lines (32 loc) · 975 Bytes
/
generate.php
File metadata and controls
36 lines (32 loc) · 975 Bytes
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
<?php
ini_set('display_errors', 1);
error_reporting(~0);
$password = $_POST['pass0'];
$passwor2 = $_POST['pass1'];
$pass = 0;
if ($password != $passwor2) {
$pass = 1;
$res = "Passwords dont match";
}
if (file_exists("../data/users/" . $_POST['username'])) {
$pass = 1;
$res = "Username in use";
}
if(preg_match("/^[a-zA-Z0-9-_]+$/", $_POST['username']) != 1) {
$pass = 1;
$res = "Username can only contain a-z 0-9";
}
if ($pass == 0) {
$path = "../data/users/" . $_POST['username'];
mkdir($path);
$pass = password_hash($password, PASSWORD_DEFAULT);
file_put_contents("$path/password", $pass);// password storage
file_put_contents("$path/points", "0"); // will change each time they win
file_put_contents("$path/verified", "0"); // will change to 1 when they are verified
header("Location: index.php?notify=acc_m");
} else {
require("header.php");
echo("An error occured during account creation.<br><br>");
echo("Reason: $res");
}
?>