2020-08-02 05:22:25 +00:00
|
|
|
<?php
|
2023-08-23 16:16:34 +00:00
|
|
|
function displayPage(string $message)
|
|
|
|
{
|
2023-08-23 16:16:34 +00:00
|
|
|
global $RUNTIME;
|
2023-08-23 16:16:34 +00:00
|
|
|
$HTML = new HTML();
|
|
|
|
$HTML->setHTMLTitle("Registrieren");
|
2023-08-23 16:16:35 +00:00
|
|
|
$HTML->importHTML("register.html");
|
2023-08-23 16:16:34 +00:00
|
|
|
|
|
|
|
$HTML->ReplaceLayoutInhalt("%%MESSAGE%%", $message);
|
|
|
|
$HTML->ReplaceLayoutInhalt("%%tosURL%%", $RUNTIME['TOOLS']['TOS'] );
|
2023-08-23 16:16:34 +00:00
|
|
|
$HTML->ReplaceLayoutInhalt("%%INVCODE%%", htmlspecialchars($_REQUEST['code']));
|
2023-08-23 16:16:34 +00:00
|
|
|
|
|
|
|
$HTML->build();
|
|
|
|
echo $HTML->ausgabe();
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
2020-08-02 05:22:25 +00:00
|
|
|
if(!isset($_REQUEST['code']))
|
|
|
|
die("MISSING INVITE CODE!");
|
|
|
|
|
2023-08-23 16:16:36 +00:00
|
|
|
if(strlen($_REQUEST['code']) != 32 || !preg_match('/^[a-f0-9]+$/', $_REQUEST['code'])) {
|
2023-08-23 16:16:34 +00:00
|
|
|
die("INVALID INVITE CODE!");
|
|
|
|
}
|
2020-08-02 05:22:25 +00:00
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
$statementInviteCode = $RUNTIME['PDO']->prepare("SELECT 1 FROM InviteCodes WHERE InviteCode = ? LIMIT 1");
|
|
|
|
$statementInviteCode->execute([$_REQUEST['code']]);
|
|
|
|
|
|
|
|
if($statementInviteCode->rowCount() == 0) {
|
|
|
|
die("INVALID INVITE CODE!");
|
|
|
|
}
|
|
|
|
|
2023-08-23 16:16:35 +00:00
|
|
|
if($_SERVER['REQUEST_METHOD'] != 'POST') {
|
2023-08-23 16:16:34 +00:00
|
|
|
displayPage("");
|
|
|
|
}
|
2020-08-02 05:22:25 +00:00
|
|
|
|
2023-08-23 16:16:35 +00:00
|
|
|
include_once('app/FormValidator.php');
|
2020-08-02 05:22:25 +00:00
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
$validator = new FormValidator(array(
|
2023-08-23 16:16:34 +00:00
|
|
|
'tos' => array('required' => true, 'equals' => 'on'),
|
2023-08-23 16:16:36 +00:00
|
|
|
'username' => array('required' => true, 'regex' => '/^[^\\/<>\s]{1,64}( [^\\/<>\s]{1,64})?$/'),
|
|
|
|
'password' => array('required' => true, 'regex' => '/^.{1,1000}$/'),
|
|
|
|
'email' => array('required' => true, 'regex' => '/^\S{1,64}@\S{1,250}.\S{2,64}$/'),
|
2023-08-23 16:16:34 +00:00
|
|
|
'avatar' => array('required' => true)
|
|
|
|
));
|
2020-08-02 05:22:25 +00:00
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
if(!$validator->isValid($_POST)) {
|
2023-08-23 16:16:35 +00:00
|
|
|
if(!isset($_POST['tos']) || $_POST['tos'] !== true) {
|
2023-08-23 16:16:34 +00:00
|
|
|
displayPage("Du musst die Nutzungsbedingungen lesen und Akzeptieren.");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
displayPage("Ups da stimmt was nicht. Versuche es bitte noch mal.");
|
2020-08-02 05:22:25 +00:00
|
|
|
}
|
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
die();
|
|
|
|
}
|
2020-08-02 05:22:25 +00:00
|
|
|
|
2023-08-23 16:16:35 +00:00
|
|
|
$name = trim($_POST['username']);
|
2023-08-23 16:16:36 +00:00
|
|
|
$nameParts;
|
|
|
|
if($name != "") {
|
2023-08-23 16:16:34 +00:00
|
|
|
$nameParts = explode(" ", $name);
|
2023-08-23 16:16:36 +00:00
|
|
|
if(count($nameParts) == 1) {
|
2023-08-23 16:16:34 +00:00
|
|
|
$name .= " Resident";
|
|
|
|
$nameParts = explode(" ", $name);
|
2020-08-02 05:22:25 +00:00
|
|
|
}
|
2023-08-23 16:16:34 +00:00
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
$statementAvatarName = $RUNTIME['PDO']->prepare("SELECT 1 FROM UserAccounts WHERE FirstName = :FirstName AND LastName = :LastName LIMIT 1");
|
2023-08-23 16:16:34 +00:00
|
|
|
$statementAvatarName->execute(['FirstName' => $nameParts[0], 'LastName' => $nameParts[1]]);
|
2023-08-23 16:16:36 +00:00
|
|
|
if($statementAvatarName->rowCount() > 0) {
|
2023-08-23 16:16:34 +00:00
|
|
|
displayPage("Der gewählte Name ist bereits vergeben.");
|
2020-08-02 05:22:25 +00:00
|
|
|
}
|
|
|
|
}
|
2023-08-23 16:16:36 +00:00
|
|
|
|
|
|
|
$pass = trim($_POST['password']);
|
|
|
|
if(strlen($pass) < $RUNTIME['PASSWORD_MIN_LENGTH']) {
|
|
|
|
displayPage('Dein Passwort muss mindestens '.$RUNTIME['PASSWORD_MIN_LENGTH'].' Zeichen lang sein.');
|
2023-08-23 16:16:34 +00:00
|
|
|
}
|
2023-08-23 16:16:36 +00:00
|
|
|
|
|
|
|
$email = trim($_POST['email']);
|
|
|
|
|
|
|
|
$avatar;
|
|
|
|
if(isset($RUNTIME['DEFAULTAVATAR'][$_POST['avatar']]['UUID'])) {
|
|
|
|
$avatar = trim($_POST['avatar']);
|
|
|
|
}
|
|
|
|
else {
|
2023-08-23 16:16:34 +00:00
|
|
|
displayPage("Der gewählte Standardavatar existiert nicht.");
|
|
|
|
}
|
2023-08-23 16:16:35 +00:00
|
|
|
|
2023-08-23 16:16:35 +00:00
|
|
|
include 'app/OpenSim.php';
|
2023-08-23 16:16:35 +00:00
|
|
|
$opensim = new OpenSim();
|
|
|
|
|
|
|
|
$avatarUUID = $opensim->gen_uuid();
|
2023-08-23 16:16:36 +00:00
|
|
|
$salt = bin2hex(random_bytes(16));
|
|
|
|
$passwordHash = md5(md5($pass).':'.$salt);
|
2023-08-23 16:16:36 +00:00
|
|
|
|
|
|
|
$statementInviteDeleter = $RUNTIME['PDO']->prepare('DELETE FROM InviteCodes WHERE InviteCode = :code');
|
|
|
|
$statementInviteDeleter->execute(['code' => $_REQUEST['code']]);
|
|
|
|
if($statementInviteDeleter->rowCount() == 0) {
|
|
|
|
header('Location: index.php');
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
|
|
|
$RUNTIME['PDO']->beginTransaction();
|
|
|
|
|
|
|
|
$statementAuth = $RUNTIME['PDO']->prepare('INSERT INTO `auth` (`UUID`, `passwordHash`, `passwordSalt`, `webLoginKey`, `accountType`) VALUES (:UUID, :HASHVALUE, :SALT, :WEBKEY, :ACCTYPE)');
|
|
|
|
$statementAuth->execute(['UUID' => $avatarUUID, 'HASHVALUE' => $passwordHash, 'SALT' => $salt, 'WEBKEY' => "00000000-0000-0000-0000-000000000000", 'ACCTYPE' => "UserAccount"]);
|
|
|
|
|
|
|
|
$statementAccounts = $RUNTIME['PDO']->prepare('INSERT INTO `UserAccounts` (`PrincipalID`, `ScopeID`, `FirstName`, `LastName`, `Email`, `ServiceURLs`, `Created`, `UserLevel`, `UserFlags`, `UserTitle`, `active`) VALUES (:PrincipalID, :ScopeID, :FirstName, :LastName, :Email, :ServiceURLs, :Created, :UserLevel, :UserFlags, :UserTitle, :active )');
|
|
|
|
$statementAccounts->execute(['PrincipalID' => $avatarUUID, 'ScopeID' => "00000000-0000-0000-0000-000000000000", 'FirstName' => $nameParts[0], 'LastName' => $nameParts[1], 'Email' => $email, 'ServiceURLs' => "HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI= ", 'Created' => time(), 'UserLevel' => 0, 'UserFlags' => 0, 'UserTitle' => "", 'active' => 1]);
|
|
|
|
|
2023-08-23 16:16:36 +00:00
|
|
|
$statementProfile = $RUNTIME['PDO']->prepare('INSERT INTO `userprofile` (`useruuid`, `profilePartner`, `profileImage`, `profileURL`, `profileFirstImage`, `profileAllowPublish`, `profileMaturePublish`, `profileWantToMask`, `profileWantToText`, `profileSkillsMask`, `profileSkillsText`, `profileLanguages`, `profileAboutText`, `profileFirstText`) VALUES (:useruuid, :profilePartner, :profileImage, :profileURL, :profileFirstImage, :profileAllowPublish, :profileMaturePublish, :profileWantToMask, :profileWantToText, :profileSkillsMask, :profileSkillsText, :profileLanguages, :profileAboutText, :profileFirstText)');
|
|
|
|
$statementProfile->execute(['useruuid' => $avatarUUID, 'profilePartner' => "00000000-0000-0000-0000-000000000000", 'profileImage' => "00000000-0000-0000-0000-000000000000", 'profileURL' => '', 'profileFirstImage' => "00000000-0000-0000-0000-000000000000", "profileAllowPublish" => "0", "profileMaturePublish" => "0", "profileWantToMask" => "0", "profileWantToText" => "", "profileSkillsMask" => "0", "profileSkillsText" => "", "profileLanguages" => "", "profileAboutText" => "", "profileFirstText" => ""]);
|
2023-08-23 16:16:36 +00:00
|
|
|
|
|
|
|
$statementInventoryFolder = $RUNTIME['PDO']->prepare('INSERT INTO `inventoryfolders` (`folderName`, `type`, `version`, `folderID`, `agentID`, `parentFolderID`) VALUES (:folderName, :folderTyp, :folderVersion, :folderID, :agentID, :parentFolderID)');
|
|
|
|
$Inventory = array('Calling Cards' => 2, 'Objects' => 6, 'Landmarks' => 3, 'Clothing' => 5, 'Gestures' => 21, 'Body Parts' => 13, 'Textures' => 0, 'Scripts' => 10, 'Photo Album' => 15, 'Lost And Found' => 16, 'Trash' => 14, 'Notecards' => 7, 'My Inventory' => 8, 'Sounds' => 1, 'Animations' => 20);
|
|
|
|
$InventoryRootFolder = $opensim->gen_uuid();
|
|
|
|
foreach ($Inventory as $FolderName => $InventoryType)
|
2023-08-23 16:16:34 +00:00
|
|
|
{
|
2023-08-23 16:16:36 +00:00
|
|
|
$FolderUUID = $opensim->gen_uuid();
|
|
|
|
if ($InventoryType == 8)
|
|
|
|
{
|
|
|
|
$FolderUUID = $InventoryRootFolder;
|
|
|
|
$FolderParent = "00000000-0000-0000-0000-000000000000";
|
|
|
|
}else{
|
|
|
|
$FolderParent = $InventoryRootFolder;
|
|
|
|
}
|
|
|
|
$statementInventoryFolder->execute(['agentID' => $avatarUUID, 'folderName' => $FolderName, 'folderTyp' => $InventoryType, 'folderVersion' => 1, 'folderID' => $FolderUUID, 'parentFolderID' => $FolderParent]);
|
2023-08-23 16:16:34 +00:00
|
|
|
}
|
2023-08-23 16:16:36 +00:00
|
|
|
|
|
|
|
$RUNTIME['PDO']->commit();
|
|
|
|
} catch (Exception $pdoException) {
|
|
|
|
$RUNTIME['PDO']->rollBack();
|
|
|
|
error_log('Could not create Account: '.$pdoException->getMessage());
|
|
|
|
displayPage('Fehler bei der Erstellung deines Accounts. Bitte versuche es später erneut.');
|
2023-08-23 16:16:34 +00:00
|
|
|
}
|
2023-08-23 16:16:36 +00:00
|
|
|
|
2023-08-23 16:16:34 +00:00
|
|
|
session_unset(); // Unset pre-session variables, next request will generate a new CSRF token
|
2023-08-23 16:16:36 +00:00
|
|
|
$_SESSION['USERNAME'] = trim($name);
|
|
|
|
$_SESSION['FIRSTNAME'] = trim($nameParts[0]);
|
|
|
|
$_SESSION['LASTNAME'] = trim($nameParts[1]);
|
|
|
|
$_SESSION['EMAIL'] = $email;
|
2023-08-23 16:16:34 +00:00
|
|
|
$_SESSION['PASSWORD'] = $passwordHash;
|
2023-08-23 16:16:36 +00:00
|
|
|
$_SESSION['SALT'] = $salt;
|
2023-08-23 16:16:34 +00:00
|
|
|
$_SESSION['UUID'] = $avatarUUID;
|
|
|
|
$_SESSION['LEVEL'] = 0;
|
2023-08-23 16:16:36 +00:00
|
|
|
$_SESSION['DISPLAYNAME'] = strtoupper($name);
|
2023-08-23 16:16:34 +00:00
|
|
|
$_SESSION['LOGIN'] = 'true';
|
2023-08-23 16:16:34 +00:00
|
|
|
|
|
|
|
header('Location: index.php?page=dashboard');
|
2023-08-23 16:16:34 +00:00
|
|
|
die();
|
2020-08-02 05:22:25 +00:00
|
|
|
?>
|