1
0
Fork 0
Manager/pages/friends.php

56 lines
2.5 KiB
PHP
Raw Normal View History

2020-08-06 01:15:07 +00:00
<?php
2023-08-27 03:31:32 +00:00
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
if (isset($_POST['remove'])) {
include_once 'app/FormValidator.php';
$validator = new FormValidator(array(
'uuid' => array('required' => true, 'regex' => '/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/')
));
2023-08-27 03:31:32 +00:00
if ($validator->isValid($_POST)) {
$statementMembership = $RUNTIME['PDO']->prepare("DELETE FROM Friends WHERE Friend = ? AND PrincipalID = ?");
$statementMembership->execute(array($_REQUEST['uuid'], $_SESSION['UUID']));
$statementMembership = $RUNTIME['PDO']->prepare("DELETE FROM Friends WHERE PrincipalID = ? AND Friend = ?");
$statementMembership->execute(array($_REQUEST['uuid'], $_SESSION['UUID']));
}
}
2023-08-23 16:16:34 +00:00
header('Location: index.php?page=friends');
die();
2021-01-06 14:42:48 +00:00
}
2023-08-23 16:16:36 +00:00
$HTML->setHTMLTitle("Deine Freunde");
2023-08-27 03:31:32 +00:00
$HTML->importSeitenInhalt("online-anzeige.html");
2023-08-23 16:16:34 +00:00
2020-08-06 01:15:07 +00:00
$table = '<table class="table"><thead><tr><th scope="col">Name</th><th scope="col">Optionen</th></thead><tbody>%%ENTRY%%</tbody></table>';
2023-08-23 16:16:34 +00:00
$statement = $RUNTIME['PDO']->prepare("SELECT PrincipalID,Friend FROM Friends WHERE PrincipalID = ? ORDER BY Friend ASC");
2023-08-27 03:31:32 +00:00
$statement->execute([$_SESSION['UUID']]);
2020-08-06 01:15:07 +00:00
2023-08-27 03:31:32 +00:00
include_once 'app/OpenSim.php';
$opensim = new OpenSim();
while ($row = $statement->fetch()) {
2020-08-06 01:15:07 +00:00
$PrincipalID = explode(";", $row['PrincipalID'])[0];
$FriendData = explode(";", $row['Friend']);
$Friend = $FriendData[0];
$name = trim($opensim->getUserName($Friend));
2023-08-27 03:31:32 +00:00
if (count($FriendData) > 1) {
2020-08-06 01:15:07 +00:00
$FriendData[1] = str_replace("http://", "", $FriendData[1]);
$FriendData[1] = str_replace("https://", "", $FriendData[1]);
$FriendData[1] = str_replace("/", "", $FriendData[1]);
$name = $name.' @ '.strtolower($FriendData[1]);
2020-08-06 01:15:07 +00:00
}
$entry = '<tr><td>'.htmlspecialchars($name).'</td><td><form action="index.php?page=friends" method="post">%%CSRF%%<input type="hidden" name="uuid" value="'.htmlspecialchars($row['Friend']).'"><button type="submit" name="remove" class="btn btn-danger btn-sm">LÖSCHEN</button></form></td></tr>';
2020-08-06 01:15:07 +00:00
$table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table);
}
$table = str_replace("%%ENTRY%%", "", $table);
$HTML->ReplaceSeitenInhalt("%%ONLINE-LIST%%", $table);
$HTML->build();
echo $HTML->ausgabe();