function write_user($newUser) { //create salt here, because we want it to be the same on the web/server $hashpass = crypt($newUser["pass"], WebUsers::generateSALT()); $params = array('Login' => $newUser["name"], 'Password' => $hashpass, 'Email' => $newUser["mail"]); try { //make new webuser $user_id = WebUsers::createWebuser($params['Login'], $params['Password'], $params['Email']); //Create the user on the shard + in case shard is offline put copy of query in query db //returns: ok, shardoffline or liboffline $result = WebUsers::createUser($params, $user_id); Users::createPermissions(array($newUser["name"])); } catch (PDOException $e) { //go to error page or something, because can't access website db print_r($e); throw new SystemExit(); } return $result; }
if ($roleSupport) { // Load AMS Library if ($continue) { try { require_once $AMS_LIB . '/libinclude.php'; } catch (Exception $e) { printalert("danger", "Failed to include AMS <em>libinclude.php</em>"); $continue = false; } } // Create AMS Admin user if ($continue) { $hashpass = crypt($_POST["amsAdminPassword"], Users::generateSALT()); $params = array('Login' => $_POST["amsAdminUsername"], 'Password' => $hashpass, 'Email' => "localhost@localhost"); try { $user_id = WebUsers::createWebuser($params['Login'], $params['Password'], $params['Email']); $result = Webusers::createUser($params, $user_id); Users::createPermissions(array($params['Login'])); $dbl = new DBLayer("lib"); $dbl->execute("UPDATE ticket_user SET Permission = 3 WHERE TUserId = :user_id", array('user_id' => $user_id)); printalert("success", "AMS Admin account <em>" . htmlentities($_POST["amsAdminUsername"]) . "</em> created"); } catch (PDOException $e) { printalert("danger", "Failed to create AMS Admin account"); $continue = false; } } } if ($roleDomain) { // TODO: Register the domain with the nel database etc } if ($continue && $roleService) {