<?php

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

?>