1 | <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/s/classes/config.inc.php"); ?> |
||
2 | <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/s/classes/db_helper.php"); ?> |
||
3 | <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/s/classes/time_manip.php"); ?> |
||
4 | <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/s/classes/user_helper.php"); ?> |
||
5 | <?php require_once($_SERVER['DOCUMENT_ROOT'] . "/s/classes/video_helper.php"); ?> |
||
6 | <?php $__video_h = new video_helper($__db); ?> |
||
7 | <?php $__user_h = new user_helper($__db); ?> |
||
8 | <?php $__db_h = new db_helper(); ?> |
||
9 | <?php $__time_h = new time_helper(); ?> |
||
10 | <?php |
||
11 | function remove_emoji($text) { |
||
12 | |||
13 | $clean_text = ""; |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
14 | |||
15 | // Match Emoticons |
||
16 | $regexEmoticons = '/[\x{1F600}-\x{1F64F}]/u'; |
||
17 | $clean_text = preg_replace($regexEmoticons, '', $text); |
||
18 | |||
19 | // Match Miscellaneous Symbols and Pictographs |
||
20 | $regexSymbols = '/[\x{1F300}-\x{1F5FF}]/u'; |
||
21 | $clean_text = preg_replace($regexSymbols, '', $clean_text); |
||
22 | |||
23 | // Match Transport And Map Symbols |
||
24 | $regexTransport = '/[\x{1F680}-\x{1F6FF}]/u'; |
||
25 | $clean_text = preg_replace($regexTransport, '', $clean_text); |
||
26 | |||
27 | // Match Miscellaneous Symbols |
||
28 | $regexMisc = '/[\x{2600}-\x{26FF}]/u'; |
||
29 | $clean_text = preg_replace($regexMisc, '', $clean_text); |
||
30 | |||
31 | // Match Dingbats |
||
32 | $regexDingbats = '/[\x{2700}-\x{27BF}]/u'; |
||
33 | $clean_text = preg_replace($regexDingbats, '', $clean_text); |
||
34 | |||
35 | return $clean_text; |
||
36 | } |
||
37 | |||
38 | |||
39 | if($_SERVER['REQUEST_METHOD'] == 'POST' && $_POST['password'] && $_POST['username']) { |
||
40 | $request = (object) [ |
||
41 | "username" => $_POST['username'], |
||
42 | "password" => $_POST['password'], |
||
43 | "email" => $_POST['email'], |
||
44 | "password_hash" => password_hash($_POST['password'], PASSWORD_DEFAULT), |
||
45 | |||
46 | "error" => (object) [ |
||
47 | "message" => "", |
||
48 | "status" => "OK" |
||
49 | ] |
||
50 | ]; |
||
51 | |||
52 | $request->username = remove_emoji($request->username); |
||
53 | |||
54 | /* ALT DETECT */ |
||
55 | $stmt = $__db->prepare("SELECT * FROM users WHERE ip = :ip"); |
||
56 | $stmt->bindParam(":ip", $_SERVER["HTTP_CF_CONNECTING_IP"]); |
||
57 | $stmt->execute(); |
||
58 | |||
59 | if($stmt->rowCount() >= 3) { $request->error->message = "You cannot make alt accounts."; $request->error->status = ""; } |
||
60 | |||
61 | if (!filter_var($request->email, FILTER_VALIDATE_EMAIL)) |
||
62 | { $request->error->message = "Your email is invalid!"; $request->error->status = ""; } |
||
63 | if(strlen($request->username) > 21) |
||
64 | { $request->error->message = "Your username must be shorter than 20 characters."; $request->error->status = ""; } |
||
65 | if(strlen($request->password) < 8) |
||
66 | { $request->error->message = "Your password must at least be 8 characters long."; $request->error->status = ""; } |
||
67 | if(!preg_match('/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/', $request->password)) |
||
68 | { $request->error->message = "Include numbers and letters in your password!"; $request->error->status = ""; } |
||
69 | if(preg_match('/[\'^£$%&*()}{@#~?><>,|=_+¬-]/', $request->username)) |
||
70 | { $request->error->message = "Your username cannot contain any special characters!"; $request->error->status = ""; } |
||
71 | if(!preg_match('/^\S+\w\S{1,}/', $request->username)) |
||
72 | { $request->error->message = "Your username cannot contain any special characters!"; $request->error->status = ""; } |
||
73 | if(empty(trim($request->username))) |
||
74 | { $request->error->message = "Your username cannot be empty!"; $request->error->status = ""; } |
||
75 | |||
76 | $stmt = $__db->prepare("SELECT username FROM users WHERE username = lower(:username)"); |
||
77 | $stmt->bindParam(":username", $request->username); |
||
78 | $stmt->execute(); |
||
79 | if($stmt->rowCount()) |
||
80 | { $request->error->message = "There's already a user with that same username!"; $request->error->status = ""; } |
||
81 | |||
82 | if($request->error->status == "OK") { |
||
83 | $stmt = $__db->prepare("INSERT INTO users (username, email, password) VALUES (:username, :email, :password)"); |
||
84 | $stmt->bindParam(":username", $request->username); |
||
85 | $stmt->bindParam(":email", $request->email); |
||
86 | $stmt->bindParam(":password", $request->password_hash); |
||
87 | $stmt->execute(); |
||
88 | |||
89 | $_SESSION['siteusername'] = $request->username; |
||
90 | header("Location: /"); |
||
91 | } else { |
||
92 | $_SESSION['error'] = $request->error; |
||
93 | header("Location: /sign_up"); |
||
94 | } |
||
95 | } |
||
96 | ?> |
||
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. ![]() |