<?php

$content = api_query('https://' . $server . '/manager/ispmgr?func=ftp&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
$parse_xml = simplexml_load_string($content);
echo '<div class="menu"><img src="images/t-new.png" alt="." /><a href="?func=ftp.edit">Создать новый FTP аккаунт</a>' . "\n</div>";
echo '' . "\n";
foreach($parse_xml->elem as $var) {echo '<div class="post">';
    if (isset($var->disabled)) {
        echo '<img src="images/p-off.png" alt="off" />';
    } else {
        echo '<img src="images/p-on.png" alt="on" />';
    }
    echo '<b>' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '</b> (FTP';
    if (isset($var->shell)) {
        echo ',SSH';
    }
    echo ')<br />' . "\n";
    echo '<b>Домашняя директория:</b> ' . htmlentities((string)$var->home, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    if (isset($var->disk)) {
        $disk_attributes = $var->disk->attributes();
        echo '<b>Диск:</b> ' . (string)$disk_attributes['used'] . '/' . (string)$disk_attributes['limit'] . ' Мб<br />' . "\n";
    }
    if (isset($var->note)) {
        echo '<b>Заметки:</b> ' . htmlentities((string)$var->note, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    }

    echo '&raquo; <a href="?func=ftp.edit&amp;elid=' . urlencode((string)$var->name) . '">Изменить</a><br />' . "\n";

    if ($var->name <> $_SESSION['username']) {
        if (isset($var->disabled)) {
            echo '&raquo; <a href="?func=ftp.enable&amp;elid=' . urlencode((string)$var->name) . '">Включить</a><br />' . "\n";
        } else {
            echo '&raquo; <a href="?func=ftp.disable&amp;elid=' . urlencode((string)$var->name) . '">Выключить</a><br />' . "\n";
        }
        echo '&raquo; <a href="?func=ftp.delete&amp;elid=' . urlencode((string)$var->name) . '">Удалить</a><br />' . "\n";
    }
    echo '</div>' . "\n";
}
echo '<div class="menu"><img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n</div>";

?>
