Просмотр файла isp_api/func/file.attr.php

Размер файла: 8.59Kb
<?php

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

    $pu = 0;
    if (isset($parse_xml->pur)) {
        $pu = $pu + 4;
    }
    if (isset($parse_xml->puw)) {
        $pu = $pu + 2;
    }
    if (isset($parse_xml->pux)) {
        $pu = $pu + 1;
    }

    $pg = 0;
    if (isset($parse_xml->pgr)) {
        $pg = $pg + 4;
    }
    if (isset($parse_xml->pgw)) {
        $pg = $pg + 2;
    }
    if (isset($parse_xml->pgx)) {
        $pg = $pg + 1;
    }

    $po = 0;
    if (isset($parse_xml->por)) {
        $po = $po + 4;
    }
    if (isset($parse_xml->pow)) {
        $po = $po + 2;
    }
    if (isset($parse_xml->pox)) {
        $po = $po + 1;
    }

    echo '<img src="images/t-edit.png" alt="." />Атрибуты объекта ' . htmlentities($_GET['file'], ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
    echo '<br />' . "\n";
    echo '<form action="?func=file.attr&amp;file=' . urlencode($_GET['file']);
    if (isset($_GET['elid'])) {
        echo '&amp;elid=' . urlencode($_GET['elid']);
    }
    if (isset($_GET['plid'])) {
        echo '&amp;plid=' . urlencode($_GET['plid']);
    }
    echo '" method="post">' . "\n";
    echo 'Имя:<br />' . "\n";
    echo '<input name="name" value="' . htmlentities($_GET['file'], ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
    if (isset($parse_xml->dest)) {
        echo 'Ссылается на:<br />' . "\n";
        echo '<input name="dest" value="' . htmlentities((string)$parse_xml->dest, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
    }
    echo 'Права доступа:<br />' . "\n";
    echo '<input name="mode" value="' . $pu . $pg . $po . '" /><br />' . "\n";
    echo '<input name="submit" type="submit" value="Изменить" />' . "\n";
    echo '</form>' . "\n";
    echo '<hr />' . "\n";
    echo '<img src="images/t-back.png" alt=".." /><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 '">Вернуться</a><br />' . "\n";
} else {
    $mode = (string)$_POST['mode'];

    $pur = '';
    $puw = '';
    $pux = '';
    if ($mode{0} == '7') {
        $pur = 'on';
        $puw = 'on';
        $pux = 'on';
    } elseif ($mode{0} == '6') {
        $pur = 'on';
        $puw = 'on';
    } elseif ($mode{0} == '5') {
        $pur = 'on';
        $pux = 'on';
    } elseif ($mode{0} == '4') {
        $pur = 'on';
    } elseif ($mode{0} == '3') {
        $puw = 'on';
        $pux = 'on';
    } elseif ($mode{0} == '2') {
        $puw = 'on';
    } elseif ($mode{0} == '1') {
        $pux = 'on';
    }

    $pgr = '';
    $pgw = '';
    $pgx = '';
    if ($mode{1} == '7') {
        $pgr = 'on';
        $pgw = 'on';
        $pgx = 'on';
    } elseif ($mode{1} == '6') {
        $pgr = 'on';
        $pgw = 'on';
    } elseif ($mode{1} == '5') {
        $pgr = 'on';
        $pgx = 'on';
    } elseif ($mode{1} == '4') {
        $pgr = 'on';
    } elseif ($mode{1} == '3') {
        $pgw = 'on';
        $pgx = 'on';
    } elseif ($mode{1} == '2') {
        $pgw = 'on';
    } elseif ($mode{1} == '1') {
        $pgx = 'on';
    }

    $por = '';
    $pow = '';
    $pox = '';
    if ($mode{2} == '7') {
        $por = 'on';
        $pow = 'on';
        $pox = 'on';
    } elseif ($mode{2} == '6') {
        $por = 'on';
        $pow = 'on';
    } elseif ($mode{2} == '5') {
        $por = 'on';
        $pox = 'on';
    } elseif ($mode{2} == '4') {
        $por = 'on';
    } elseif ($mode{2} == '3') {
        $pow = 'on';
        $pox = 'on';
    } elseif ($mode{2} == '2') {
        $pow = 'on';
    } elseif ($mode{2} == '1') {
        $pox = 'on';
    }

    if (isset($_GET['plid'])) {
        if (isset($_POST['dest'])) {
            $content = api_query('https://' . $server . '/manager/ispmgr?func=file.attr&elid=' . urlencode($_GET['file']) . '&name=' . urlencode($_POST['name']) . '&dest=' . urlencode($_POST['dest']) . '&pur=' . $pur . '&puw=' . $puw . '&pux=' . $pux . '&pgr=' . $pgr . '&pgw=' . $pgw . '&pgx=' . $pgx . '&por=' . $por . '&pow=' . $pow . '&pox=' . $pox . '&plid=' . urlencode($_GET['plid'] . '/' . $_GET['elid']) . '&sok=ok&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        } else {
            $content = api_query('https://' . $server . '/manager/ispmgr?func=file.attr&elid=' . urlencode($_GET['file']) . '&name=' . urlencode($_POST['name']) . '&pur=' . $pur . '&puw=' . $puw . '&pux=' . $pux . '&pgr=' . $pgr . '&pgw=' . $pgw . '&pgx=' . $pgx . '&por=' . $por . '&pow=' . $pow . '&pox=' . $pox . '&plid=' . urlencode($_GET['plid'] . '/' . $_GET['elid']) . '&sok=ok&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        }
    } elseif (isset($_GET['elid'])) {
        if (isset($_POST['dest'])) {
            $content = api_query('https://' . $server . '/manager/ispmgr?func=file.attr&elid=' . urlencode($_GET['file']) . '&name=' . urlencode($_POST['name']) . '&dest=' . urlencode($_POST['dest']) . '&pur=' . $pur . '&puw=' . $puw . '&pux=' . $pux . '&pgr=' . $pgr . '&pgw=' . $pgw . '&pgx=' . $pgx . '&por=' . $por . '&pow=' . $pow . '&pox=' . $pox . '&plid=' . urlencode($_GET['elid']) . '&sok=ok&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        } else {
            $content = api_query('https://' . $server . '/manager/ispmgr?func=file.attr&elid=' . urlencode($_GET['file']) . '&name=' . urlencode($_POST['name']) . '&pur=' . $pur . '&puw=' . $puw . '&pux=' . $pux . '&pgr=' . $pgr . '&pgw=' . $pgw . '&pgx=' . $pgx . '&por=' . $por . '&pow=' . $pow . '&pox=' . $pox . '&plid=' . urlencode($_GET['elid']) . '&sok=ok&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        }
    } else {
        if (isset($_POST['dest'])) {
            $content = api_query('https://' . $server . '/manager/ispmgr?func=file.attr&elid=' . urlencode($_GET['file']) . '&name=' . urlencode($_POST['name']) . '&dest=' . urlencode($_POST['dest']) . '&pur=' . $pur . '&puw=' . $puw . '&pux=' . $pux . '&pgr=' . $pgr . '&pgw=' . $pgw . '&pgx=' . $pgx . '&por=' . $por . '&pow=' . $pow . '&pox=' . $pox . '&sok=ok&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        } else {
            $content = api_query('https://' . $server . '/manager/ispmgr?func=file.attr&elid=' . urlencode($_GET['file']) . '&name=' . urlencode($_POST['name']) . '&pur=' . $pur . '&puw=' . $puw . '&pux=' . $pux . '&pgr=' . $pgr . '&pgw=' . $pgw . '&pgx=' . $pgx . '&por=' . $por . '&pow=' . $pow . '&pox=' . $pox . '&sok=ok&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        }
    }
    $parse_xml = simplexml_load_string($content);
    if (isset($parse_xml->ok)) {
        echo '<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>' . "\n";
    } else {
        echo '<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>' . "\n";
    }
}

?>