View file isp_api/func/file.inside.php

File size: 4.47Kb
<?php

if (isset($_GET['plid']) and isset($_GET['elid'])) {
    $content = api_query('https://' . $server . '/manager/ispmgr?func=file&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=file&elid=' . urlencode($_GET['elid']) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
} else {
    $content = api_query('https://' . $server . '/manager/ispmgr?func=file&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
}

$parse_xml = simplexml_load_string($content);
foreach($parse_xml->elem as $var) {
    if ((string)$var->name == $_GET['file']) {
        $dname = htmlentities((string)$var->dname, ENT_QUOTES, 'UTF-8');
        $user = htmlentities((string)$var->user, ENT_QUOTES, 'UTF-8');
        $group = htmlentities((string)$var->group, ENT_QUOTES, 'UTF-8');
        $attr = htmlentities((string)$var->attr, ENT_QUOTES, 'UTF-8');
        $size = (int)$var->size;
        $time = htmlentities((string)$var->time, ENT_QUOTES, 'UTF-8');
        break;
    }
}

echo '<b>Объект:</b> ' . htmlentities($_GET['file'], ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
if ($_GET['xprop'] == '99') {
    echo '<b>Ссылается на:</b> ' . $dname . '<br />' . "\n";
}
if ($attr <> '') {
    echo '<b>CHMOD:</b> ' . $attr . '<br />' . "\n";
    echo '<b>Владелец:</b> ' . $user . '<br />' . "\n";
    echo '<b>Группа:</b> ' . $group . '<br />' . "\n";
}
if ($_GET['xprop'] <> '99' and $_GET['xprop'] <> '0') {

    // --------------- Функция форматированого вывода размера объектов -------- //
    function formatsize($object_size)
    {
        if ($object_size >= 1048576000) {
            $object_size = round(($object_size / 1073741824), 2) . 'Gb';
        } elseif ($object_size >= 1024000) {
            $object_size = round(($object_size / 1048576), 2) . 'Mb';
        } elseif ($object_size >= 1000) {
            $object_size = round(($object_size / 1024), 2) . 'Kb';
        } else {
            $object_size = round($object_size) . 'b';
        }
        return $object_size;
    }
    // --------------- Функция форматированого вывода размера объектов -------- //

    echo '<b>Размер:</b> ' . formatsize($size) . '<br />' . "\n";
}

echo '<b>Дата изменения:</b> ' . $time . '<br />' . "\n";

if ($_GET['xprop'] == '1' or $_GET['xprop'] == '2' or $_GET['xprop'] == '3' or $_GET['xprop'] == '4' or $_GET['xprop'] == '5' or $_GET['xprop'] == '6') {
    echo '&#187; <a href="?func=file&amp;elid=' . urlencode($_GET['file']) . '&amp;';
    if (isset($_GET['elid']) and isset($_GET['plid'])) {
        echo '&amp;plid=' . urlencode($_GET['plid'] . '/' . $_GET['elid']);
    } elseif (isset($_GET['elid'])) {
        echo '&amp;plid=' . urlencode($_GET['elid']);
    }
    echo '">Открыть архив</a><br />' . "\n";

    echo '&#187; <a href="?func=file.extract&amp;file=' . urlencode($_GET['file']);
    if (isset($_GET['elid'])) {
        echo '&amp;elid=' . urlencode($_GET['elid']);
    }
    if (isset($_GET['plid'])) {
        echo '&amp;plid=' . urlencode($_GET['plid']);
    }
    echo '">Распаковать</a><br />' . "\n";
}

echo '&#187; <a href="?func=file.attr&amp;file=' . urlencode($_GET['file']);
if (isset($_GET['elid'])) {
    echo '&amp;elid=' . urlencode($_GET['elid']);
}
if (isset($_GET['plid'])) {
    echo '&amp;plid=' . urlencode($_GET['plid']);
}
echo '">Изменить атрибуты</a><br />' . "\n";

if ($_GET['xprop'] == '100' or $_GET['xprop'] == '101') {
    echo '&#187; <a href="?func=file.edit&amp;file=' . urlencode($_GET['file']);
    if (isset($_GET['elid'])) {
        echo '&amp;elid=' . urlencode($_GET['elid']);
    }
    if (isset($_GET['plid'])) {
        echo '&amp;plid=' . urlencode($_GET['plid']);
    }
    echo '">Редактировать</a>' . "\n";
}

echo '<hr />' . "\n";
echo '<img src="images/t-back.png" alt=".." /><a href="?func=file';
if (isset($_GET['elid'])) {
    echo '&amp;elid=' . urlencode($_GET['elid']);
}
if (isset($_GET['plid'])) {
    echo '&amp;plid=' . urlencode($_GET['plid']);
}
echo '">Вернуться</a><br />' . "\n";
echo '<img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n";

?>