diff --git a/cont/adduser.php b/cont/adduser.php
index 7945db7..1934912 100644
--- a/cont/adduser.php
+++ b/cont/adduser.php
@@ -1,12 +1,14 @@
-
Benutzer hinzufügen
-
+
+
diff --git a/install/adduser.php b/install/adduser.php
index 7945db7..1934912 100644
--- a/install/adduser.php
+++ b/install/adduser.php
@@ -1,12 +1,14 @@
-
Benutzer hinzufügen
-
+
+
diff --git a/php/classes.user.php b/php/classes.user.php
index cd89b33..1391ca4 100644
--- a/php/classes.user.php
+++ b/php/classes.user.php
@@ -32,5 +32,25 @@
print_r("1");
}
}
+
+ function new($uname, $password){
+ session_start();
+ include $_SESSION["docroot"].'/php/connect.php';
+ include $_SESSION["docroot"].'/php/hash.php';
+
+ $query = "SELECT `uid` FROM `users` WHERE `username` = '$uname'";
+ $result = $mysqli->query($query);
+ if($result->num_rows==0){
+ $salt = create_salt();
+ $passhash = hash_password($password, $salt);
+ $query = "INSERT INTO `users` (`username`, `password`, `salt`, `last_login`) VALUES ('$uname', '$passhash', '$salt', CURRENT_TIMESTAMP);";
+ $result = $mysqli->query($query);
+ unset($salt);
+ unset($password);
+ print_r(0);
+ }
+ else{print_r(1);}
+ $mysqli->close();
+ }
}
?>
diff --git a/php/edit-user.php b/php/edit-user.php
index 48c4f5f..4729fee 100644
--- a/php/edit-user.php
+++ b/php/edit-user.php
@@ -2,13 +2,19 @@
session_start();
include $_SESSION["docroot"].'/php/classes.user.php';
$user = new user;
- $user->get_info($_COOKIE["token"]);
+ if($_POST["function"]!="new-user"){
+ $user->get_info($_COOKIE["token"]);
+ }
switch ($_POST["function"]) {
case 'change-pw':
$user->change_password($_POST["current"], $_POST["new"]);
break;
+ case 'new-user':
+ $user->new($_POST["username"], $_POST["passwd"]);
+ break;
+
default:
// code...
break;