1
0
Fork 0
Manager/pages/regions.php

81 lines
3.2 KiB
PHP
Raw Permalink Normal View History

2020-06-03 15:31:18 +00:00
<?php
$HTML->setHTMLTitle("Deine Regionen");
$HTML->importSeitenInhalt("pages/HTML/deine-regionen.html");
2021-01-08 14:14:09 +00:00
function cleanSize($bytes)
{
if ($bytes > 0)
{
$unit = intval(log($bytes, 1024));
$units = array('B', 'KB', 'MB', 'GB');
if (array_key_exists($unit, $units) === true)
{
return sprintf('%d %s', $bytes / pow(1024, $unit), $units[$unit]);
}
}
return $bytes;
}
function getRegionStatsData($regionID)
{
global $RUNTIME;
$statement = $RUNTIME['PDO']->prepare("SELECT * FROM regions_info WHERE regionID = ?");
$statement->execute([$regionID]);
if($row = $statement->fetch())
{
$return = array();
$return['Prims'] = $row['Prims'];
$return['SimFPS'] = $row['SimFPS'];
$return['PhyFPS'] = $row['PhyFPS'];
$return['ProcMem'] = cleanSize(str_replace(".", "", str_replace(",", ".", $row['ProcMem']))."000");
2021-01-08 14:17:32 +00:00
$return['RegionVersion'] = trim($row['RegionVersion']);
2021-01-08 14:14:09 +00:00
return $return;
}
return array();
}
2021-01-06 14:42:48 +00:00
if(@$_REQUEST['action'] == 'remove' && @$_REQUEST['region'] != '')
{
if(@$_SESSION['LEVEL'] >= 100)
{
$statementMembership = $RUNTIME['PDO']->prepare("DELETE FROM regions WHERE uuid = ?");
$statementMembership->execute(array($_REQUEST['region']));
}else{
$statementMembership = $RUNTIME['PDO']->prepare("DELETE FROM regions WHERE uuid = ? AND owner_uuid = ?");
$statementMembership->execute(array($_REQUEST['region'], $_SESSION['UUID']));
}
}
2020-06-03 15:31:18 +00:00
$table = '<table class="table"><thead><tr><th scope="col">Region Name</th><th scope="col">Eigentümer</th><th scope="col">Position</th><th scope="col">Aktionen</th></thead><tbody>%%ENTRY%%</tbody></table>';
2021-01-06 14:42:48 +00:00
if(@$_SESSION['LEVEL'] >= 100 && @$_REQUEST['SHOWALL'] == "1")
2020-06-03 15:31:18 +00:00
{
$statement = $RUNTIME['PDO']->prepare("SELECT * FROM regions ORDER BY owner_uuid ASC");
$statement->execute(array($_SESSION['UUID']));
}else{
$statement = $RUNTIME['PDO']->prepare("SELECT * FROM regions WHERE owner_uuid = ? ORDER BY uuid ASC");
$statement->execute(array($_SESSION['UUID']));
}
$statement->execute(array($_SESSION['UUID']));
while($row = $statement->fetch())
{
2021-01-08 14:14:09 +00:00
$stats = getRegionStatsData($row['uuid']);
$entry = '<tr><td>'.$row['regionName'].'<div class="blockquote-footer">Prims: '.$stats['Prims'].'; RAM-Nutzung: '.$stats['ProcMem'].'; SIM/PHYS FPS: '.$stats['SimFPS'].'/'.$stats['PhyFPS'].' ('.$stats['RegionVersion'].')</div></td><td>'.$RUNTIME['OPENSIM']->getUserName($row['owner_uuid']).'</td><td>'.fillString(($row['locX'] / 256), 4).' / '.fillString(($row['locY'] / 256), 4).'</td><td><a href="index.php?page=regions&action=remove&region='.$row['uuid'].'">LÖSCHEN</a></td></tr>';
2020-06-03 15:31:18 +00:00
$table = str_replace("%%ENTRY%%", $entry."%%ENTRY%%", $table);
}
$table = str_replace("%%ENTRY%%", "", $table);
$HTML->ReplaceSeitenInhalt("%%REGION-LIST%%", $table);
$HTML->build();
echo $HTML->ausgabe();
?>