<?php

if (isset($_GET['elid'])) {
    $content = api_query('https://' . $server . '/manager/ispmgr?func=userbandwidth&elid=' . urlencode($_GET['elid']) . '&out=xml&auth=' . urlencode($_SESSION['auth']));
} else {
    $content = api_query('https://' . $server . '/manager/ispmgr?func=userbandwidth&out=xml&auth=' . urlencode($_SESSION['auth']));
}
$parse_xml = simplexml_load_string($content);
echo '<div class="menu"><b>Статистика трафика</b>' . "\n";
echo '</div>' . "\n";
foreach($parse_xml->elem as $var) {
    echo '<div class="post"><b>Дата:</b> ';
    if (empty($_GET['elid'])) {
        echo '<a href="?func=userbandwidth&amp;elid=' . urlencode((string)$var->date) . '">' . htmlentities((string)$var->date, ENT_QUOTES, 'UTF-8') . '</a><br />' . "\n";
    } else {
        echo htmlentities((string)$var->date, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    }
    echo '<b>Исходящий:</b> ' . htmlentities((string)$var->http_in, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    echo '<b>Входящий:</b> ' . htmlentities((string)$var->http_out, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    echo '<b>Всего исходящий:</b> ' . htmlentities((string)$var->total_in, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    echo '<b>Всего входящий:</b> ' . htmlentities((string)$var->total_out, ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    echo '<b>Единица:</b> ' . htmlentities((string)$var->unit, ENT_QUOTES, 'UTF-8') . "\n";
    echo '</div>' . "\n";
}
if (isset($_GET['elid'])) {
    echo '<img src="images/t-back.png" alt=".." /><a href="?func=userbandwidth">Вернуться</a><br />' . "\n";
}
echo '<div class="menu"><img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n</div>";

?>