Файл: mobile/func/diskusage.php
Строк: 131
<?php
if (isset($_GET['plid']) and isset($_GET['elid'])) {
$content = api_query('https://' . $server . '/manager/ispmgr?func=diskusage&elid=' . urlencode($_GET['elid']) . '&plid=' . urlencode($_GET['plid']) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
} elseif (isset($_GET['elid'])) {
$content = api_query('https://' . $server . '/manager/ispmgr?func=diskusage&elid=' . urlencode($_GET['elid']) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
} else {
$content = api_query('https://' . $server . '/manager/ispmgr?func=diskusage&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
}
$parse_xml = simplexml_load_string($content);
echo '<b>Использование диска</b>' . "n";
echo '<hr />' . "n";
echo 'Путь: /';
if (isset($_GET['plid'])) {
echo htmlentities($_GET['plid'], ENT_QUOTES, 'UTF-8');
}
if (isset($_GET['elid']) and isset($_GET['plid'])) {
echo '/';
}
if (isset($_GET['elid'])) {
echo htmlentities($_GET['elid'], ENT_QUOTES, 'UTF-8');
}
echo "n" . '<hr />' . "n";
if (isset($_GET['plid']) and isset($_GET['elid'])) {
$elid = strrchr($_GET['plid'], '/');
if ($elid !== false) {
$elid = substr($elid, 1);
}
$plid = array_reverse(explode('/', $_GET['plid']));
$count_plid = sizeof($plid);
if ($count_plid > 1) {
unset($plid[0]);
$plid = implode('/', array_reverse($plid));
} else {
$plid = $plid[0];
}
echo '<a href="?func=diskusage';
if ($elid !== false) {
echo '&elid=' . urlencode($elid) . '&plid=' . urlencode($plid);
} else {
echo '&elid=' . urlencode($_GET['plid']);
}
echo '"><img src="images/back.gif" alt=".." /></a><br />' . "n";
} elseif (isset($_GET['elid'])) {
echo '<a href="?func=diskusage"><img src="images/back.gif" alt=".." /></a><br />' . "n";
}
$list_dir = array();
$list_file = array();
foreach($parse_xml->elem as $var) {
$dname_attributes = $var->name->attributes();
if ($dname_attributes['xprop'] == '0') {
$list_dir["'.(string)$var->name.'"] = array((string)$var->name, '0', (string)$var->size);
} elseif ($dname_attributes['xprop'] == '100') {
$list_file["'.(string)$var->name.'"] = array((string)$var->name, '100', (string)$var->size);
}
}
ksort($list_dir);
ksort($list_file);
$list_all = array_merge($list_dir, $list_file);
foreach($list_all as $var) {
$list_all_num[] = $var;
}
unset($list_all);
if (isset($list_all_num)) {
$count_all_num = sizeof($list_all_num);
$s_max = ceil($count_all_num / $_SESSION['rows']);
if (isset($_GET['s'])) {
$s = (int)$_GET['s'];
if ($s > $s_max) {
$s = $s_max;
} elseif ($s < 1) {
$s = 1;
}
} else {
$s = 1;
}
$rows_max = $s * $_SESSION['rows']-1;
$rows_min = $rows_max - $_SESSION['rows'] + 1;
if ($rows_max > $count_all_num-1) {
$rows_max = $count_all_num-1;
}
for($i = $rows_min; $i <= $rows_max; $i++) {
if ($list_all_num[$i][1] == '0') {
echo '<img src="images/p-file-0.png" alt="d" /> <a href="?func=diskusage&elid=' . urlencode($list_all_num[$i][0]);
if (isset($_GET['elid']) and isset($_GET['plid'])) {
echo '&plid=' . urlencode($_GET['plid'] . '/' . $_GET['elid']);
} elseif (isset($_GET['elid'])) {
echo '&plid=' . urlencode($_GET['elid']);
}
echo '">' . htmlentities((string)$list_all_num[$i][0], ENT_QUOTES, 'UTF-8') . '</a> ' . $list_all_num[$i][2] . 'Mb<br />' . "n";
} elseif ($list_all_num[$i][1] == '100') {
echo '<img src="images/p-file-100.png" alt="f" /> ' . htmlentities($list_all_num[$i][0], ENT_QUOTES, 'UTF-8') . ' ' . $list_all_num[$i][2] . 'Mb<br />' . "n";
}
}
} else {
echo '<br />' . "n";
echo 'Папка пуста<br />' . "n";
}
// --------------------------- Постраничная навигация ------------------------- //
if (isset($list_all_num)) {
if ($s_max > 1) {
echo '<hr />' . "n";
echo 'Страницы:<br />' . "n";
$s_prev = $s-2;
$s_next = $s + 2;
if ($s_prev < 1) {
$s_prev = 1;
}
if ($s_next > $s_max) {
$s_next = $s_max;
}
if ($s_prev > 2) {
echo '<a href="?func=diskusage&';
if (isset($_GET['elid'])) {
echo 'elid=' . urlencode($_GET['elid']) . '&';
}
if (isset($_GET['plid'])) {
echo 'plid=' . urlencode($_GET['plid']) . '&';
}
echo 's=1">1</a> ... ';
} elseif ($s_prev == 2) {
echo '<a href="?func=diskusage&';
if (isset($_GET['elid'])) {
echo 'elid=' . urlencode($_GET['elid']) . '&';
}
if (isset($_GET['plid'])) {
echo 'plid=' . urlencode($_GET['plid']) . '&';
}
echo 's=1">1</a> ';
}
for($i = $s_prev; $i <= $s_next; $i++) {
if ($i == $s) {
echo $i . ' ';
} else {
echo '<a href="?func=diskusage&';
if (isset($_GET['elid'])) {
echo 'elid=' . urlencode($_GET['elid']) . '&';
}
if (isset($_GET['plid'])) {
echo 'plid=' . urlencode($_GET['plid']) . '&';
}
echo 's=' . $i . '">' . $i . '</a> ';
}
}
if ($s_next < $s_max-1) {
echo '... <a href="?func=diskusage&';
if (isset($_GET['elid'])) {
echo 'elid=' . urlencode($_GET['elid']) . '&';
}
if (isset($_GET['plid'])) {
echo 'plid=' . urlencode($_GET['plid']) . '&';
}
echo 's=' . $s_max . '">' . $s_max . '</a>';
} elseif ($s_next == $s_max-1) {
echo '<a href="?func=diskusage&';
if (isset($_GET['elid'])) {
echo 'elid=' . urlencode($_GET['elid']) . '&';
}
if (isset($_GET['plid'])) {
echo 'plid=' . urlencode($_GET['plid']) . '&';
}
echo 's=' . $s_max . '">' . $s_max . '</a>';
}
echo "n";
}
}
// --------------------------- Постраничная навигация ------------------------- //
echo '<hr />' . "n";
echo '<img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "n";
?>