1
0
Fork 0

now the register works

master
Christopher 2020-08-02 07:22:25 +02:00
parent 9590a11647
commit f30eab6561
3 changed files with 237 additions and 0 deletions

View File

@ -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 )
);
}
}
?>

132
pages/register.php Normal file
View File

@ -0,0 +1,132 @@
<?php
if(!isset($_REQUEST['code']))
die("MISSING INVITE CODE!");
$statementInviteCode = $RUNTIME['PDO']->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!");
}
?>

82
style/login/register.html Normal file
View File

@ -0,0 +1,82 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Registrieren</title>
<link rel="stylesheet" type="text/css" href="./style/login/vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="./style/login/fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="./style/login/fonts/Linearicons-Free-v1.0.0/icon-font.min.css">
<link rel="stylesheet" type="text/css" href="./style/login/vendor/animate/animate.css">
<link rel="stylesheet" type="text/css" href="./style/login/vendor/css-hamburgers/hamburgers.min.css">
<link rel="stylesheet" type="text/css" href="./style/login/vendor/animsition/css/animsition.min.css">
<link rel="stylesheet" type="text/css" href="./style/login/vendor/select2/select2.min.css">
<link rel="stylesheet" type="text/css" href="./style/login/vendor/daterangepicker/daterangepicker.css">
<link rel="stylesheet" type="text/css" href="./style/login/css/util.css">
<link rel="stylesheet" type="text/css" href="./style/login/css/main.css">
<link href="./style/4Creative.ico" rel="icon">
<link href="./style/4Creative.ico" rel="apple-touch-icon">
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-50 p-b-90">
<form class="login100-form validate-form flex-sb flex-w" action="index.php?page=register" method="post">
<span class="login100-form-title p-b-51">
Registrieren
</span>
<div class="flex-sb-m w-full p-t-3 p-b-24" style="color: red;">
%%MESSAGE%%
</div>
<div class="wrap-input100 validate-input m-b-16" data-validate="Bitte gebe dein Benutzernamen an.">
<input class="input100" type="text" name="username" placeholder="Benutzername">
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 validate-input m-b-16" data-validate="Bitte gebe dein Passwort ein.">
<input class="input100" type="password" name="password" placeholder="Passwort">
<span class="focus-input100"></span>
</div>
<div class="wrap-input100 validate-input m-b-16" data-validate="Bitte gebe deine E-Mail ein.">
<input class="input100" type="text" name="email" placeholder="E-Mail">
<span class="focus-input100"></span>
</div>
<div class="flex-sb-m w-full p-t-3 p-b-24"">
Wähle deinen Standart Avatar aus:
</div>
<div class="wrap-input100 validate-input m-b-16" data-validate="Bitte wähle einen Standart Avatar aus.">
<select class="input100" name="avatar">
<option>Twinster Kid</option>
</select>
</div>
<div class="container-login100-form-btn m-t-17">
<input type="hidden" name="code" value="%%INVCODE%%">
<button class="login100-form-btn" name="doRegister">
Registrieren
</button>
</div>
</form>
</div>
</div>
</div>
<div id="dropDownSelect1"></div>
<script src="./style/login/vendor/jquery/jquery-3.2.1.min.js"></script>
<script src="./style/login/vendor/animsition/js/animsition.min.js"></script>
<script src="./style/login/vendor/bootstrap/js/popper.js"></script>
<script src="./style/login/vendor/bootstrap/js/bootstrap.min.js"></script>
<script src="./style/login/vendor/select2/select2.min.js"></script>
<script src="./style/login/vendor/daterangepicker/moment.min.js"></script>
<script src="./style/login/vendor/daterangepicker/daterangepicker.js"></script>
<script src="./style/login/vendor/countdowntime/countdowntime.js"></script>
<script src="./style/login/js/main.js"></script>
</body>
</html>