View file isp_api/func/wwwdomain.edit.php

File size: 10.92Kb
<?php

if (empty($_GET['elid'])) {
    if (empty($_POST['submit'])) {
        echo '<img src="images/t-new.png" alt="." />Создание WWW домена<br />' . "\n";
        echo '<br />' . "\n";
        echo '<form action="?func=wwwdomain.edit" method="post">' . "\n";
        echo 'Доменное имя:<br />' . "\n";
        echo '<input name="domain" /><br />' . "\n";
        echo 'Псевдонимы:<br />' . "\n";
        echo '<input name="alias" /><br />' . "\n";
        echo 'Корневая папка:<br />' . "\n";
        echo '<input name="docroot" value="auto" /><br />' . "\n";
        echo 'IP-адрес:<br />' . "\n";
        echo '<select name="ip">' . "\n";
        $content = api_query('https://' . $server . '/manager/ispmgr?func=iplist&out=xml&auth=' . urlencode($_SESSION['auth']));
        $parse_xml = simplexml_load_string($content);
        foreach($parse_xml->elem as $var) {
            echo '<option value="' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '">' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . ' (' . htmlentities((string)$var->stat, ENT_QUOTES, 'UTF-8') . ')</option>' . "\n";
        }
        echo '</select><br />' . "\n";
        $content = api_query('https://' . $server . '/manager/ispmgr?func=wwwdomain.edit&out=xml&auth=' . urlencode($_SESSION['auth']));
        $parse_xml = simplexml_load_string($content);
        echo 'E-Mail администратора:<br />' . "\n";
        echo '<input name="admin" value="' . htmlentities((string)$parse_xml->admin, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo 'Кодировка:<br />' . "\n";
        echo '<input name="charset" /><br />' . "\n";
        echo 'Индексная страница:<br />' . "\n";
        echo '<input name="index" /><br />' . "\n";
        echo 'PHP:<br />' . "\n";
        echo '<select name="php">' . "\n";
        echo '<option value="phpnone">Нет поддержки PHP</option>' . "\n";
        echo '<option value="phpmod">PHP как модуль Apache</option>' . "\n";
        #echo '<option value="phpcgi">PHP как CGI</option>' . "\n";
        echo '</select><br />' . "\n";
        #echo '<input name="cgi" type="checkbox" value="on" /> Cgi-bin<br />' . "\n";
        #echo '<input name="ssi" type="checkbox" value="on" /> SSI<br />' . "\n";
        #echo 'Расширения файлов SSI:<br />' . "\n";
        #echo '<input name="ssiext" /><br />' . "\n";
        #echo '<input name="ssl" type="checkbox" value="on" /> SSL<br />' . "\n";
        #echo 'SSL порт:<br />' . "\n";
        #echo '<input name="sslport" value="443" /><br />' . "\n";
        echo '<input name="switchispmgr" type="checkbox" value="on" /> Отключить ISPmanager<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=wwwdomain">Вернуться</a>' . "\n";
    } else {
        $cgi = isset($_POST['cgi'])?'on':'';
        $ssi = isset($_POST['ssi'])?'on':'';
        $ssl = isset($_POST['ssl'])?'on':'';
        $switchispmgr = isset($_POST['switchispmgr'])?'on':'';
        $content = api_query('https://' . $server . '/manager/ispmgr?func=wwwdomain.edit&domain=' . urlencode($_POST['domain']) . '&alias=' . urlencode($_POST['alias']) . '&docroot=' . urlencode($_POST['docroot']) . '&ip=' . urlencode($_POST['ip']) . '&admin=' . urlencode($_POST['admin']) . '&charset=' . urlencode($_POST['charset']) . '&index=' . urlencode($_POST['index']) . '&php=' . urlencode($_POST['php']) . '&cgi=' . $cgi . '&ssi=' . $ssi . '&ssiext=' . urlencode($_POST['ssiext']) . '&ssl=' . $ssl . '&sslport=' . urlencode($_POST['sslport']) . '&switchispmgr=' . $switchispmgr . '&sok=ok&out=xml&auth=' . urlencode($_SESSION['auth']));
        $parse_xml = simplexml_load_string($content);
        if (isset($parse_xml->ok)) {
            echo '<div style="text-align:center">' . "\n";
            echo 'WWW домен успешно создан!<br />' . "\n";
            echo 'Подождите несколько секунд, для перезагрузки сервера, и нажмите &quot;продолжить&quot;.<br />' . "\n";
            echo '<a href="?func=wwwdomain">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
            api_query('https://' . $server . '/manager/ispmgr?func=restart&auth=' . urlencode($_SESSION['auth']));
        } else {
            echo '<div style="text-align:center">' . "\n";
            echo 'Ошибка при создании WWW домена!<br />' . "\n";
            echo '<a href="?func=wwwdomain">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
        }
    }
} else {
    if (empty($_POST['submit'])) {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=wwwdomain.edit&elid=' . urlencode($_GET['elid']) . '&out=xml&auth=' . urlencode($_SESSION['auth']));
        $parse_xml = simplexml_load_string($content);
        echo '<img src="images/t-edit.png" alt="." />Изменение WWW домена<br />' . "\n";
        echo '<br />' . "\n";
        echo '<form action="?func=wwwdomain.edit&amp;elid=' . urlencode($_GET['elid']) . '" method="post">' . "\n";
        echo 'Доменное имя:<br />' . "\n";
        echo '<input name="domain" value="' . htmlentities((string)$parse_xml->domain, ENT_QUOTES, 'UTF-8') . '" readonly="readonly" /><br />' . "\n";
        echo 'Псевдонимы:<br />' . "\n";
        echo '<input name="alias" value="' . htmlentities((string)$parse_xml->alias, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo 'IP-адрес:<br />' . "\n";
        echo '<select name="ip">' . "\n";
        $content = api_query('https://' . $server . '/manager/ispmgr?func=iplist&out=xml&auth=' . urlencode($_SESSION['auth']));
        $parse_xml_ip = simplexml_load_string($content);
        foreach($parse_xml_ip->elem as $var) {
            echo '<option value="' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '"';
            if ((string)$parse_xml->ip == (string)$var->name) {
                echo ' selected="selected"';
            }
            echo '>' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . ' (' . htmlentities((string)$var->stat, ENT_QUOTES, 'UTF-8') . ')</option>' . "\n";
        }
        echo '</select><br />' . "\n";
        echo 'E-Mail администратора:<br />' . "\n";
        echo '<input name="admin" value="' . htmlentities((string)$parse_xml->admin, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo 'Кодировка:<br />' . "\n";
        echo '<input name="charset" value="' . htmlentities((string)$parse_xml->charset, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo 'Индексная страница:<br />' . "\n";
        echo '<input name="index" value="' . htmlentities((string)$parse_xml->index, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo 'PHP:<br />' . "\n";
        echo '<select name="php">' . "\n";
        echo '<option value="phpnone"';
        if ((string)$parse_xml->php == 'phpnone') {
            echo ' selected="selected"';
        }
        echo '>Нет поддержки PHP</option>' . "\n";
        echo '<option value="phpmod"';
        if ((string)$parse_xml->php == 'phpmod') {
            echo ' selected="selected"';
        }
        echo '>PHP как модуль Apache</option>' . "\n";
        #echo '<option value="phpcgi"';
        #if ((string)$parse_xml->php == 'phpcgi') {
        #    echo ' selected="selected"';
        #}
        #echo '>PHP как CGI</option>' . "\n";
        echo '</select><br />' . "\n";
        #echo '<input name="cgi" type="checkbox" value="on"';
        #if (isset($parse_xml->cgi)) {
        #    echo ' checked="checked"';
        #}
        #echo ' /> Cgi-bin<br />' . "\n";
        #echo '<input name="ssi" type="checkbox" value="on"';
        #if (isset($parse_xml->ssi)) {
        #    echo ' checked="checked"';
        #}
        #echo ' /> SSI<br />' . "\n";
        #echo 'Расширения файлов SSI:<br />' . "\n";
        #echo '<input name="ssiext" value="' . htmlentities((string)$parse_xml->ssiext, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        #echo '<input name="ssl" type="checkbox" value="on"';
        #if (isset($parse_xml->ssl)) {
        #    echo ' checked="checked"';
        #}
        #echo ' /> SSL<br />' . "\n";
        #echo 'SSL порт:<br />' . "\n";
        #echo '<input name="sslport" value="';
        #if (empty($parse_xml->sslport)) {
        #    echo '443';
        #} else {
        #    echo htmlentities((string)$parse_xml->sslport, ENT_QUOTES, 'UTF-8');
        #}
        #echo '" /><br />' . "\n";
        echo '<input name="switchispmgr" type="checkbox" value="on"';
        if (isset($parse_xml->switchispmgr)) {
            echo ' checked="checked"';
        }
        echo ' /> Отключить ISPmanager<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=wwwdomain">Вернуться</a>' . "\n";
    } else {
        $cgi = isset($_POST['cgi'])?'on':'';
        $ssi = isset($_POST['ssi'])?'on':'';
        $ssl = isset($_POST['ssl'])?'on':'';
        $switchispmgr = isset($_POST['switchispmgr'])?'on':'';
        $content = api_query('https://' . $server . '/manager/ispmgr?func=wwwdomain.edit&elid=' . urlencode($_GET['elid']) . '&domain=' . urlencode($_GET['elid']) . '&alias=' . urlencode($_POST['alias']) . '&ip=' . urlencode($_POST['ip']) . '&admin=' . urlencode($_POST['admin']) . '&charset=' . urlencode($_POST['charset']) . '&index=' . urlencode($_POST['index']) . '&php=' . urlencode($_POST['php']) . '&cgi=' . $cgi . '&ssi=' . $ssi . '&ssiext=' . urlencode($_POST['ssiext']) . '&ssl=' . $ssl . '&sslport=' . urlencode($_POST['sslport']) . '&switchispmgr=' . $switchispmgr . '&sok=ok&out=xml&auth=' . urlencode($_SESSION['auth']));
        $parse_xml = simplexml_load_string($content);
        if (isset($parse_xml->ok)) {
            echo '<div style="text-align:center">' . "\n";
            echo 'Параметры WWW домена успешно изменены!<br />' . "\n";
            echo 'Подождите несколько секунд, для перезагрузки сервера, и нажмите &quot;продолжить&quot;.<br />' . "\n";
            echo '<a href="?func=wwwdomain">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
            api_query('https://' . $server . '/manager/ispmgr?func=restart&auth=' . urlencode($_SESSION['auth']));
        } else {
            echo '<div style="text-align:center">' . "\n";
            echo 'Ошибка при изменении WWW домена!<br />' . "\n";
            echo '<a href="?func=wwwdomain">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
        }
    }
}

?>