<?php

$content = api_query('https://' . $server . '/manager/ispmgr?func=email&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=email.edit">Создать почтовый ящик</a>' . "\n";
echo '</div>' . "\n";
foreach($parse_xml->elem as $var) {
    echo '<div class="post">';
    $size_attributes = $var->size->attributes();
    if (isset($var->disabled)) {
        echo '<img src="images/p-off.png" alt="off" />';
    } else {
        echo '<img src="images/p-on.png" alt="on" />';
    }
    if (isset($var->forward)) {
        echo '<img src="images/p-redirect.png" alt="r" />';
    }
    if (isset($var->vacation)) {
        echo '<img src="images/p-mail-ar.png" alt="v" />';
    }
    echo htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    echo '<b>Размер:</b> ' . (string)$size_attributes['used'] . '/' . (string)$size_attributes['limit'] . '<br />';
    if (isset($var->note)) {
        echo '<b>Примечание:</b> ' . htmlentities((string)$var->note, ENT_QUOTES, 'UTF-8') . '<br />';
    }
    if (isset($var->disabled)) {
        echo '&#187; <a href="?func=email.enable&amp;elid=' . urlencode((string)$var->name) . '">Включить</a><br />' . "\n";
    } else {
        echo '&#187; <a href="?func=email.disable&amp;elid=' . urlencode((string)$var->name) . '">Выключить</a><br />' . "\n";
    }
    echo '&#187; <a href="?func=email.vacation&amp;elid=' . urlencode((string)$var->name) . '">Автоответчик</a><br />' . "\n";
    echo '&#187; <a href="?func=email.edit&amp;elid=' . urlencode((string)$var->name) . '">Изменить</a><br />' . "\n";
    echo '&#187; <a href="?func=email.clear&amp;elid=' . urlencode((string)$var->name) . '">Очистить</a><br />' . "\n";
    echo '&#187; <a href="?func=email.delete&amp;elid=' . urlencode((string)$var->name) . '">Удалить</a>' . "\n";
    echo '</div>' . "\n";
}
echo '<div class="menu"><img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n</div>";

?>