Просмотр файла isp_api/func/domain.sublist.edit.php

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

if (empty($_GET['elid'])) {
    if (empty($_POST['sdtype'])) {
        echo '<img src="images/t-new.png" alt="." />Создание записи домена ' . htmlentities($_GET['plid'], ENT_QUOTES, 'UTF-8') . "\n";
        echo '<hr />' . "\n";
        echo '<form action="?func=domain.sublist.edit&amp;plid=' . urlencode($_GET['plid']) . '" method="post">' . "\n";
        echo 'Тип записи домена:<br />' . "\n";
        echo '<select name="sdtype">' . "\n";
        echo '<option value="A">A (адрес Internet v4)</option>' . "\n";
        echo '<option value="AAAA">AAAA (адрес Internet v6)</option>' . "\n";
        echo '<option value="CNAME">CNAME (каноническое имя)</option>' . "\n";
        echo '<option value="NS">NS (сервер имён)</option>' . "\n";
        echo '<option value="MX">MX (почтовый сервер)</option>' . "\n";
        echo '<option value="TXT">TXT (текстовая запись)</option>' . "\n";
        echo '<option value="SRV">SRV (сетевой сервис)</option>' . "\n";
        echo '<option value="RTP">RTP (реверсная запись)</option>' . "\n";
        echo '</select><br />' . "\n";
        echo '<input type="submit" value="Продолжить" />' . "\n";
        echo '</form>' . "\n";
        echo '<hr />' . "\n";
        echo '<img src="images/t-back.png" alt="." /><a href="?func=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Вернуться</a><br />' . "\n";
        echo '<img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n";
    } else {
        if (empty($_POST['submit'])) {
            echo '<img src="images/t-new.png" alt="." />Создание записи домена ' . htmlentities($_GET['plid'], ENT_QUOTES, 'UTF-8') . "\n";
            echo '<hr />' . "\n";
            echo '<form action="?func=domain.sublist.edit&amp;plid=' . urlencode($_GET['plid']) . '" method="post">' . "\n";
            echo 'Имя:<br />' . "\n";
            echo '<input name="name" /><br />' . "\n";
            echo 'Адрес:<br />' . "\n";
            echo '<input name="addr" /><br />' . "\n";
            if ($_POST['sdtype'] == 'MX') {
                echo 'Приоритет:<br />' . "\n";
                echo '<input name="prio" /><br />' . "\n";
            } elseif ($_POST['sdtype'] == 'SRV') {
                echo 'Приоритет:<br />' . "\n";
                echo '<input name="prio" /><br />' . "\n";
                echo 'Условный вес SRV-записи:<br />' . "\n";
                echo '<input name="wght" /><br />' . "\n";
                echo 'Порт:<br />' . "\n";
                echo '<input name="port" /><br />' . "\n";
            }
            echo '<input name="sdtype" type="hidden" value="' . htmlentities($_POST['sdtype'], ENT_QUOTES, 'UTF-8') . '" />' . "\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=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Вернуться</a><br />' . "\n";
            echo '<img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n";
        } else {
            $prio = isset($_POST['prio'])?$_POST['prio']:'';
            $wght = isset($_POST['wght'])?$_POST['wght']:'';
            $port = isset($_POST['port'])?$_POST['port']:'';
            $content = api_query('https://' . $server . '/manager/ispmgr?name=' . urlencode($_POST['name']) . '&addr=' . urlencode($_POST['addr']) . '&prio=' . urlencode($prio) . '&wght=' . urlencode($wght) . '&port=' . urlencode($port) . '&sdtype=' . urlencode($_POST['sdtype']) . '&sok=ok&func=domain.sublist.edit&plid=' . urlencode($_GET['plid']) . '&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=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Продолжить</a>' . "\n";
                echo '</div>' . "\n";
            } else {
                echo '<div style="text-align:center">' . "\n";
                echo 'Ошибка при создании записи домена!<br />' . "\n";
                echo '<a href="?func=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Продолжить</a>' . "\n";
                echo '</div>' . "\n";
            }
        }
    }
} else {
    if (empty($_POST['submit'])) {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=domain.sublist.edit&elid=' . urlencode($_GET['elid']) . '&plid=' . urlencode($_GET['plid']) . '&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        $parse_xml = simplexml_load_string($content);
        echo '<img src="images/t-edit.png" alt="." />Изменение записи домена ' . htmlentities($_GET['plid'], ENT_QUOTES, 'UTF-8') . "\n";
        echo '<hr />' . "\n";
        echo '<form action="?func=domain.sublist.edit&amp;elid=' . urlencode($_GET['elid']) . '&amp;plid=' . urlencode($_GET['plid']) . '" method="post">' . "\n";
        echo 'Имя:<br />' . "\n";
        echo '<input name="name" value="' . htmlentities((string)$parse_xml->name, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo 'Адрес:<br />' . "\n";
        echo '<input name="addr" value="' . htmlentities((string)$parse_xml->addr, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        if ($parse_xml->sdtype == 'MX') {
            echo 'Приоритет:<br />' . "\n";
            echo '<input name="prio" value="' . htmlentities((string)$parse_xml->prio, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        } elseif ($parse_xml->sdtype == 'SRV') {
            echo 'Приоритет:<br />' . "\n";
            echo '<input name="prio" value="' . htmlentities((string)$parse_xml->prio, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
            echo 'Условный вес SRV-записи:<br />' . "\n";
            echo '<input name="wght" value="' . htmlentities((string)$parse_xml->wght, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
            echo 'Порт:<br />' . "\n";
            echo '<input name="port" value="' . htmlentities((string)$parse_xml->port, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        }
        echo '<input name="sdtype" type="hidden" value="' . htmlentities((string)$parse_xml->sdtype, ENT_QUOTES, 'UTF-8') . '" />' . "\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=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Вернуться</a><br />' . "\n";
        echo '<img src="images/sb-menu.png" alt="." /><a href="?func=menu">Вернуться в меню</a>' . "\n";
    } else {
        $prio = isset($_POST['prio'])?$_POST['prio']:'';
        $wght = isset($_POST['wght'])?$_POST['wght']:'';
        $port = isset($_POST['port'])?$_POST['port']:'';
        $content = api_query('https://' . $server . '/manager/ispmgr?elid=' . urlencode($_GET['elid']) . '&name=' . urlencode($_POST['name']) . '&addr=' . urlencode($_POST['addr']) . '&prio=' . urlencode($prio) . '&wght=' . urlencode($wght) . '&port=' . urlencode($port) . '&sdtype=' . urlencode($_POST['sdtype']) . '&sok=ok&func=domain.sublist.edit&plid=' . urlencode($_GET['plid']) . '&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=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Продолжить</a>' . "\n";
            echo '</div>' . "\n";
        } else {
            echo '<div style="text-align:center">' . "\n";
            echo 'Ошибка при изменении записи домена!<br />' . "\n";
            echo '<a href="?func=domain.sublist&amp;elid=' . urlencode($_GET['plid']) . '">Продолжить</a>' . "\n";
            echo '</div>' . "\n";
        }
    }
}

?>