|
|
@@ -61,8 +61,27 @@ class Alter {
|
|
61
|
61
|
header('Location: ' . Config::$sys_url . '?page=eventadmin');
|
|
62
|
62
|
die("Error, please enable browser redirects.");
|
|
63
|
63
|
}
|
|
64
|
|
-
|
|
65
|
|
- public static function addUser($username, $password, $realname, $mail, $level) {
|
|
|
64
|
+
|
|
|
65
|
+ public static function addUser($username, $password, $realname, $mail, $level) {
|
|
|
66
|
+ if (Get::checkExists($username)) { // check if user exists
|
|
|
67
|
+ // ERROR USER EXISTS
|
|
|
68
|
+ die();
|
|
|
69
|
+ }
|
|
|
70
|
+
|
|
|
71
|
+ // lets check the variables
|
|
|
72
|
+
|
|
|
73
|
+ if (strlen($username) < 3) { die(); }
|
|
|
74
|
+ elseif (strlen($password) < 5) { die(); }
|
|
|
75
|
+ elseif (strlen($realname) < 5) { die(); }
|
|
|
76
|
+ elseif (strlen($mail) < 5) { die(); }
|
|
|
77
|
+ // Now we know everything contains something.
|
|
|
78
|
+ // Time to sanitize!
|
|
|
79
|
+
|
|
|
80
|
+ $username = filter_var($username, FILTER_SANITIZE_STRING);
|
|
|
81
|
+ $realname = filter_var($realname, FILTER_SANITIZE_STRING);
|
|
|
82
|
+ $mail = filter_var($mail, FILTER_SANITIZE_EMAIL);
|
|
|
83
|
+ // Gr8, we are sanitized. We dont sanitize password, as we hash it anyway using argon2
|
|
|
84
|
+
|
|
66
|
85
|
$db = new DBClass();
|
|
67
|
86
|
$sql = "INSERT INTO `users` (`id`, `realname`, `username`, `password`, `email`, `level`) VALUES (NULL, '$realname', '$username', '" . User::hashPass($password) . "', '$mail', '$level');";
|
|
68
|
87
|
return $db->query($sql);
|