From f30eab656131fde71c02108d9cb12ebb24ba7a5d Mon Sep 17 00:00:00 2001 From: Christopher Date: Sun, 2 Aug 2020 07:22:25 +0200 Subject: [PATCH] now the register works --- classen/OpenSim.php | 23 +++++++ pages/register.php | 132 ++++++++++++++++++++++++++++++++++++++ style/login/register.html | 82 +++++++++++++++++++++++ 3 files changed, 237 insertions(+) create mode 100644 pages/register.php create mode 100644 style/login/register.html diff --git a/classen/OpenSim.php b/classen/OpenSim.php index 706061e..2c83424 100644 --- a/classen/OpenSim.php +++ b/classen/OpenSim.php @@ -152,5 +152,28 @@ $statementUser->execute(); return $statementUser->rowCount(); } + + public function gen_uuid() + { + return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', + // 32 bits for "time_low" + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), + + // 16 bits for "time_mid" + mt_rand( 0, 0xffff ), + + // 16 bits for "time_hi_and_version", + // four most significant bits holds version number 4 + mt_rand( 0, 0x0fff ) | 0x4000, + + // 16 bits, 8 bits for "clk_seq_hi_res", + // 8 bits for "clk_seq_low", + // two most significant bits holds zero and one for variant DCE1.1 + mt_rand( 0, 0x3fff ) | 0x8000, + + // 48 bits for "node" + mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) + ); + } } ?> \ No newline at end of file diff --git a/pages/register.php b/pages/register.php new file mode 100644 index 0000000..c2b4409 --- /dev/null +++ b/pages/register.php @@ -0,0 +1,132 @@ +prepare("SELECT * FROM InviteCodes WHERE InviteCode = ? LIMIT 1"); + $statementInviteCode->execute([@$_REQUEST['code']]); + + if($statementInviteCode->rowCount() != 0) + { + $RUNTIME['REGISTER']['Name'] = null; + $RUNTIME['REGISTER']['PASS'] = null; + $RUNTIME['REGISTER']['EMAIL'] = null; + $RUNTIME['REGISTER']['AVATAR'] = null; + + if(isset($_REQUEST['username']) || @$_REQUEST['username'] != "") + { + $name = trim($_REQUEST['username']); + + if($name != "") + { + $nameParts = explode(" ", $name); + + if(count($nameParts) == 1) + { + $name .= " Resident"; + $nameParts = explode(" ", $name); + } + + if(count($nameParts) <= 2) + { + $statementAvatarName = $RUNTIME['PDO']->prepare("SELECT * FROM UserAccounts WHERE FirstName = :FirstName AND LastName = :LastName LIMIT 1"); + $statementAvatarName->execute(['FirstName' => $nameParts[0], 'LastName' => $nameParts[1]]); + + if($statementAvatarName->rowCount() == 0) + { + $RUNTIME['REGISTER']['Name'] = $name; + } + } + } + } + + if(isset($_REQUEST['password']) || @$_REQUEST['password'] != "") + { + $pass = trim($_REQUEST['password']); + + if($pass != "") + { + $RUNTIME['REGISTER']['PASS'] = $pass; + } + } + + if(isset($_REQUEST['email']) || @$_REQUEST['email'] != "") + { + $email = trim($_REQUEST['email']); + + if($email != "") + { + $RUNTIME['REGISTER']['EMAIL'] = $email; + } + } + + if(isset($_REQUEST['avatar']) || @$_REQUEST['avatar'] != "") + { + $avatar = trim($_REQUEST['avatar']); + + if($avatar != "") + { + if(isset($RUNTIME['DEFAULTAVATAR'][$avatar]['UUID'])) + { + $RUNTIME['REGISTER']['AVATAR'] = $avatar; + } + } + } + + $HTML = new HTML(); + $HTML->setHTMLTitle("Registrieren"); + $HTML->importHTML("style/login/register.html"); + + if(isset($_REQUEST['doRegister']) || @$_REQUEST['doRegister'] != "") + { + if($RUNTIME['REGISTER']['AVATAR'] != null && $RUNTIME['REGISTER']['EMAIL'] != null && $RUNTIME['REGISTER']['PASS'] != null && $RUNTIME['REGISTER']['Name'] != null) + { + $avatarUUID = $RUNTIME['OPENSIM']->gen_uuid(); + $passwordSalt = md5($avatarUUID.time()); + $passwordHash = md5(md5($RUNTIME['REGISTER']['PASS']).":".$passwordSalt); + $avatarNameParts = explode(" ", $RUNTIME['REGISTER']['Name']); + + $statementAuth = $RUNTIME['PDO']->prepare('INSERT INTO `auth` (`UUID`, `passwordHash`, `passwordSalt`, `webLoginKey`, `accountType`) VALUES (:UUID, :HASHVALUE, :SALTVALUE, :WEBKEY, :ACCTYPE)'); + $statementAuth->execute(['UUID' => $avatarUUID, 'HASHVALUE' => $passwordHash, 'SALTVALUE' => $passwordSalt, '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' => $avatarNameParts[0], 'LastName' => $avatarNameParts[1], 'Email' => $RUNTIME['REGISTER']['EMAIL'], 'ServiceURLs' => "HomeURI= GatekeeperURI= InventoryServerURI= AssetServerURI= ", 'Created' => time(), 'UserLevel' => 0, 'UserFlags' => 0, 'UserTitle' => "", 'active' => 1]); + + $statementProfile = $RUNTIME['PDO']->prepare('INSERT INTO `userprofile` (`useruuid`, `profilePartner`, `profileImage`, `profileFirstImage`) VALUES (:useruuid, :profilePartner, :profileImage, :profileFirstImage)'); + $statementProfile->execute(['useruuid' => $avatarUUID, 'profilePartner' => "00000000-0000-0000-0000-000000000000", 'profileImage' => "00000000-0000-0000-0000-000000000000", 'profileFirstImage' => "00000000-0000-0000-0000-000000000000"]); + + $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 = $RUNTIME['OPENSIM']->gen_uuid(); + + foreach ($Inventory as $FolderName => $InventoryType) + { + $FolderUUID = $RUNTIME['OPENSIM']->gen_uuid(); + + if ($InventoryType == 8) + { + $FolderUUID = $InventoryRootFolder; + $FolderParent = "00000000-0000-0000-0000-000000000000"; + }else{ + $FolderParent = $InventoryRootFolder; + } + + $statementInventoryFolder = $RUNTIME['PDO']->prepare('INSERT INTO `inventoryfolders` (`folderName`, `type`, `version`, `folderID`, `agentID`, `parentFolderID`) VALUES (:folderName, :folderTyp, :folderVersion, :folderID, :agentID, :parentFolderID)'); + $statementInventoryFolder->execute(['agentID' => $avatarUUID, 'folderName' => $FolderName, 'folderTyp' => $InventoryType, 'folderVersion' => 1, 'folderID' => $FolderUUID, 'parentFolderID' => $FolderParent]); + } + + }else{ + $HTML->ReplaceLayoutInhalt("%%MESSAGE%%", "Ups da stimmt was nicht. Versuche es bitte noch mal."); + } + } + + + $HTML->ReplaceLayoutInhalt("%%MESSAGE%%", ""); + $HTML->ReplaceLayoutInhalt("%%INVCODE%%", $_REQUEST['code']); + + $HTML->build(); + echo $HTML->ausgabe(); + die(); + + }else{ + die("INVALID INVITE CODE!"); + } +?> \ No newline at end of file diff --git a/style/login/register.html b/style/login/register.html new file mode 100644 index 0000000..2940686 --- /dev/null +++ b/style/login/register.html @@ -0,0 +1,82 @@ + + + + + + Registrieren + + + + + + + + + + + + + + + +
+
+
+
+ + Registrieren + + +
+ %%MESSAGE%% +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ Wähle deinen Standart Avatar aus: +
+ +
+ +
+ +
+ + +
+
+
+
+
+ + + + + + + + + + + + + + \ No newline at end of file