2020-06-03 15:31:18 +00:00
< ? php
2021-01-08 02:53:41 +00:00
$statement = $RUNTIME [ 'PDO' ] -> prepare ( " CREATE TABLE IF NOT EXISTS `iarstates` (`userID` VARCHAR(36) NOT NULL COLLATE 'utf8_unicode_ci', `filesize` BIGINT(20) NOT NULL DEFAULT '0', `iarfilename` VARCHAR(64) NOT NULL COLLATE 'utf8_unicode_ci', `running` INT(1) NOT NULL DEFAULT '0', PRIMARY KEY (`userID`) USING BTREE) COLLATE='utf8_unicode_ci' ENGINE=InnoDB; " );
2021-01-08 01:00:03 +00:00
$statement -> execute ();
2020-08-04 09:44:59 +00:00
$HTML -> setHTMLTitle ( " Dein Profile " );
2023-08-23 16:16:35 +00:00
$HTML -> importSeitenInhalt ( " profile.html " );
2020-06-03 15:31:18 +00:00
2021-01-08 01:00:03 +00:00
//Prüfe ob IAR grade erstellt wird.
$IARRUNNING = FALSE ;
2023-08-23 16:16:34 +00:00
$statementIARCheck = $RUNTIME [ 'PDO' ] -> prepare ( 'SELECT 1 FROM iarstates WHERE userID =:userID' );
2021-01-08 01:00:03 +00:00
$statementIARCheck -> execute ([ 'userID' => $_SESSION [ 'UUID' ]]);
if ( $statementIARCheck -> rowCount () != 0 )
{
2021-01-08 03:20:29 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%IARINFOMESSAGE%% " , '<div class="alert alert-danger" role="alert">Aktuell wird eine IAR erstellt.<br>Warte bitte bis du eine PM bekommst.</div>' );
2021-01-08 01:00:03 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%IARBUTTONSTATE%% " , 'disabled' );
$IARRUNNING = TRUE ;
}
if ( isset ( $_REQUEST [ 'createIAR' ]))
{
2021-01-08 01:29:46 +00:00
if ( $IARRUNNING == FALSE )
2021-01-08 01:00:03 +00:00
{
2021-01-08 01:29:46 +00:00
$iarname = md5 ( time () . $_SESSION [ 'UUID' ] . rand ()) . " .iar " ;
2021-01-08 03:20:29 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%IARINFOMESSAGE%% " , '<div class="alert alert-danger" role="alert">Deine IAR wird jetzt erstellt und der Download Link wird dir per PM zugesendet. ' . $APIResult . '</div>' );
2021-01-08 03:18:42 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%IARBUTTONSTATE%% " , 'disabled' );
2021-01-08 01:59:28 +00:00
$statementIARSTART = $RUNTIME [ 'PDO' ] -> prepare ( 'INSERT INTO iarstates (userID, filesize, iarfilename) VALUES (:userID, :filesize, :iarfilename)' );
$statementIARSTART -> execute ([ 'userID' => $_SESSION [ 'UUID' ], 'filesize' => 0 , 'iarfilename' => $iarname ]);
2021-01-08 01:00:03 +00:00
}
}
2023-08-23 16:16:34 +00:00
if ( isset ( $_REQUEST [ 'formInputFeldVorname' ]) && $_REQUEST [ 'formInputFeldVorname' ] != " " )
2020-06-03 15:31:18 +00:00
{
$NewFirstName = trim ( $_REQUEST [ 'formInputFeldVorname' ]);
if ( $NewFirstName != " " )
{
if ( $_SESSION [ 'FIRSTNAME' ] != $NewFirstName )
{
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE UserAccounts SET FirstName = :FirstName WHERE PrincipalID = :PrincipalID' );
$statement -> execute ([ 'FirstName' => $NewFirstName , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
$_SESSION [ 'FIRSTNAME' ] = $NewFirstName ;
$_SESSION [ 'USERNAME' ] = $_SESSION [ 'FIRSTNAME' ] . " " . $_SESSION [ 'LASTNAME' ];
$_SESSION [ 'DISPLAYNAME' ] = strtoupper ( $_SESSION [ 'USERNAME' ]);
}
}
}
2023-08-23 16:16:34 +00:00
if ( isset ( $_REQUEST [ 'formInputFeldNachname' ]) && $_REQUEST [ 'formInputFeldNachname' ] != " " )
2020-06-03 15:31:18 +00:00
{
$NewLastName = trim ( $_REQUEST [ 'formInputFeldNachname' ]);
if ( $NewLastName != " " )
{
if ( $_SESSION [ 'LASTNAME' ] != $NewLastName )
{
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE UserAccounts SET LastName = :LastName WHERE PrincipalID = :PrincipalID' );
$statement -> execute ([ 'LastName' => $NewLastName , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
$_SESSION [ 'LASTNAME' ] = $NewLastName ;
$_SESSION [ 'USERNAME' ] = $_SESSION [ 'FIRSTNAME' ] . " " . $_SESSION [ 'LASTNAME' ];
$_SESSION [ 'DISPLAYNAME' ] = strtoupper ( $_SESSION [ 'USERNAME' ]);
}
}
}
2023-08-23 16:16:34 +00:00
if ( isset ( $_REQUEST [ 'formInputFeldEMail' ]) && $_REQUEST [ 'formInputFeldEMail' ] != " " )
2020-06-03 15:31:18 +00:00
{
$NewEMail = trim ( $_REQUEST [ 'formInputFeldEMail' ]);
if ( $NewEMail != " " )
{
if ( $_SESSION [ 'EMAIL' ] != $NewEMail )
{
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE UserAccounts SET Email = :Email WHERE PrincipalID = :PrincipalID' );
$statement -> execute ([ 'Email' => $NewEMail , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE usersettings SET email = :Email WHERE useruuid = :PrincipalID' );
$statement -> execute ([ 'Email' => $NewEMail , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
$_SESSION [ 'EMAIL' ] = $NewEMail ;
}
}
}
2023-08-23 16:16:34 +00:00
if ( isset ( $_REQUEST [ 'formInputFeldOfflineIM' ]) && $_REQUEST [ 'formInputFeldOfflineIM' ] != " " )
2020-06-03 15:31:18 +00:00
{
$NewOfflineIM = trim ( $_REQUEST [ 'formInputFeldOfflineIM' ]);
if ( $NewOfflineIM != " " )
{
if ( $NewOfflineIM == " on " || $NewOfflineIM == " true " )
{
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE usersettings SET imviaemail = :IMState WHERE useruuid = :PrincipalID' );
$statement -> execute ([ 'IMState' => 'true' , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
}
}
} else if ( ! isset ( $_REQUEST [ 'formInputFeldOfflineIM' ]) && isset ( $_REQUEST [ 'saveProfileData' ])){
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE usersettings SET imviaemail = :IMState WHERE useruuid = :PrincipalID' );
$statement -> execute ([ 'IMState' => 'false' , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
}
2023-08-23 16:16:35 +00:00
include 'app/OpenSim.php' ;
2023-08-23 16:16:35 +00:00
$opensim = new OpenSim ();
2023-08-23 16:16:34 +00:00
if ( isset ( $_REQUEST [ 'formInputFeldPartnerName' ]) && $_REQUEST [ 'formInputFeldPartnerName' ] != " " )
2020-06-03 15:31:18 +00:00
{
$NewPartner = trim ( $_REQUEST [ 'formInputFeldPartnerName' ]);
2023-08-23 16:16:35 +00:00
$CurrentPartner = $opensim -> getPartner ( $_SESSION [ 'UUID' ]);
2020-06-03 15:31:18 +00:00
2023-08-23 16:16:35 +00:00
if ( $CurrentPartner != " " ) $CurrentPartner = $opensim -> getUserName ( $CurrentPartner );
2020-06-03 15:31:18 +00:00
if ( $NewPartner != " " )
{
if ( $CurrentPartner != $NewPartner )
{
2023-08-23 16:16:35 +00:00
$newPartnerUUID = $opensim -> getUserUUID ( $NewPartner );
2020-06-03 15:31:18 +00:00
if ( $newPartnerUUID != null )
{
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE userprofile SET profilePartner = :profilePartner WHERE useruuid = :PrincipalID' );
$statement -> execute ([ 'profilePartner' => $newPartnerUUID , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
}
}
} else {
$statement = $RUNTIME [ 'PDO' ] -> prepare ( 'UPDATE userprofile SET profilePartner = :profilePartner WHERE useruuid = :PrincipalID' );
$statement -> execute ([ 'profilePartner' => '00000000-0000-0000-0000-000000000000' , 'PrincipalID' => $_SESSION [ 'UUID' ]]);
}
}
2023-08-23 16:16:34 +00:00
$statementLocalUsers = $RUNTIME [ 'PDO' ] -> prepare ( " SELECT FirstName,LastName FROM UserAccounts ORDER BY PrincipalID ASC " );
2020-06-03 15:31:18 +00:00
$statementLocalUsers -> execute ();
$allUsers = " " ;
while ( $row = $statementLocalUsers -> fetch ())
{
$name = '"' .@ $row [ 'FirstName' ] . " " .@ $row [ 'LastName' ] . '"' ;
if ( $allUsers != " " )
{
$allUsers .= " , " . $name ;
} else {
$allUsers .= $name ;
}
}
$allUsers .= '," "' ;
2023-08-23 16:16:35 +00:00
$PartnerUUID = $opensim -> getPartner ( $_SESSION [ 'UUID' ]);
2020-06-03 15:31:18 +00:00
$PartnerName = " " ;
2023-08-23 16:16:35 +00:00
if ( $PartnerUUID != null ) $PartnerName = $opensim -> getUserName ( $PartnerUUID );
2020-06-03 15:31:18 +00:00
2023-08-23 16:16:35 +00:00
if ( $opensim -> allowOfflineIM ( $_SESSION [ 'UUID' ]) == " TRUE " ) $HTML -> ReplaceSeitenInhalt ( " %%offlineIMSTATE%% " , ' checked' );
2020-06-03 15:31:18 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%offlineIMSTATE%% " , ' ' );
2023-08-23 16:16:34 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%firstname%% " , htmlspecialchars ( $_SESSION [ 'FIRSTNAME' ]));
$HTML -> ReplaceSeitenInhalt ( " %%lastname%% " , htmlspecialchars ( $_SESSION [ 'LASTNAME' ]));
$HTML -> ReplaceSeitenInhalt ( " %%partner%% " , htmlspecialchars ( $PartnerName ));
2023-08-23 16:16:35 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%email%% " , htmlspecialchars ( $opensim -> getUserMail ( $_SESSION [ 'UUID' ])));
2020-08-04 10:08:41 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%listAllResidentsAsJSArray%% " , " " );
2020-08-04 10:00:38 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%INFOMESSAGE%% " , ' ' );
2021-01-08 01:00:03 +00:00
$HTML -> ReplaceSeitenInhalt ( " %%IARINFOMESSAGE%% " , ' ' );
$HTML -> ReplaceSeitenInhalt ( " %%IARBUTTONSTATE%% " , '' );
2020-08-04 10:00:38 +00:00
2020-06-03 15:31:18 +00:00
$HTML -> build ();
echo $HTML -> ausgabe ();
?>