<?php

if (is_array($_POST['check'])) {
    $count_del = sizeof($_POST['check']);
} else {
    $count_del = 0;
}

if ($count_del == 0) {
    echo '<div class="post"><div style="text-align:center">' . "\n";
    echo 'Ошибка!<br />' . "\n";
    echo 'Ничего не выбрано!<br />' . "\n";
    echo '<a href="?func=file&amp;elid=' . urlencode($_GET['elid']);
    if (isset($_GET['plid'])) {
        echo '&amp;plid=' . urlencode($_GET['plid']);
    }
    echo '">Продолжить&#187;</a>' . "\n";
    echo '</div></div>' . "\n";
} else {
    if (isset($_GET['plid']) and isset($_GET['elid'])) {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=file.delete&elid=' . urlencode(implode(', ', $_POST['check'])) . '&plid=' . urlencode($_GET['plid'] . '/' . $_GET['elid']) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
    } elseif (isset($_GET['elid'])) {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=file.delete&elid=' . urlencode(implode(', ', $_POST['check'])) . '&plid=' . urlencode($_GET['elid']) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
    } else {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=file.delete&elid=' . urlencode(implode(', ', $_POST['check'])) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
    }
    $parse_xml = simplexml_load_string($content);
    if (isset($parse_xml->ok)) {
        echo '<div class="post"><div style="text-align:center">' . "\n";
        echo 'Удаление успешно!<br />' . "\n";
        echo '<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 '">Продолжить&#187;</a>' . "\n";
        echo '</div></div>' . "\n";
    } else {
        echo '<div class="post"><div style="text-align:center">' . "\n";
        echo 'Ошибка при удалении!<br />' . "\n";
        echo '<a href="?func=file&amp;elid=' . urlencode($_GET['elid']);
        if (isset($_GET['plid'])) {
            echo '&amp;plid=' . urlencode($_GET['plid']);
        }
        echo '">Продолжить&#187;</a>' . "\n";
        echo '</div></div>' . "\n";
    }
}

?>