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

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

if (empty($_GET['elid'])) {
    if (empty($_POST['submit'])) {
        echo '<img src="images/t-new.png" alt="." />Создание почтового редиректа<br />' . "\n";
        echo '<br />' . "\n";
        echo '<form action="?func=emailredirect.edit" method="post">' . "\n";
        echo 'Имя редиректа:<br />' . "\n";
        echo '<input name="name" /><br />' . "\n";
        echo 'Почтовый домен:<br />' . "\n";
        echo '<select name="domain">' . "\n";
        $content = api_query('https://' . $server . '/manager/ispmgr?func=emaildomain&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        $parse_xml_domain = simplexml_load_string($content);
        foreach($parse_xml_domain->elem as $var) {
            echo '<option value="' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '">' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '</option>' . "\n";
        }
        echo '</select><br />' . "\n";
        echo 'Перенаправлять на:<br />' . "\n";
        echo '<input name="forward" /><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=emailredirect">Вернуться</a>' . "\n";
    } else {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=emailredirect.edit&name=' . urlencode($_POST['name']) . '&domain=' . urlencode($_POST['domain']) . '&forward=' . urlencode($_POST['forward']) . '&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=emailredirect">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
        } else {
            echo '<div style="text-align:center">' . "\n";
            echo 'Ошибка при создании почтового редиректа!<br />' . "\n";
            echo '<a href="?func=emailredirect">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
        }
    }
} else {
    if (empty($_POST['submit'])) {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=emailredirect.edit&elid=' . urlencode($_GET['elid']) . '&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['elid'], ENT_QUOTES, 'UTF-8') . '<br />' . "\n";
        echo '<br />' . "\n";
        echo '<form action="?func=emailredirect.edit&amp;elid=' . urlencode($_GET['elid']) . '" 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 '<select name="domain">' . "\n";
        $content = api_query('https://' . $server . '/manager/ispmgr?func=emaildomain&out=xml&authinfo=' . urlencode($_SESSION['username']) . ':' . urlencode($_SESSION['password']));
        $parse_xml_domain = simplexml_load_string($content);
        foreach($parse_xml_domain->elem as $var) {
            echo '<option value="' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '"';
            if ((string)$parse_xml->domain == (string)$var->name) {
                echo ' selected="selected"';
            }
            echo '>' . htmlentities((string)$var->name, ENT_QUOTES, 'UTF-8') . '</option>' . "\n";
        }
        echo '</select><br />' . "\n";
        echo 'Перенаправлять на:<br />' . "\n";
        echo '<input name="forward" value="' . htmlentities((string)$parse_xml->forward, ENT_QUOTES, 'UTF-8') . '" /><br />' . "\n";
        echo '<input name="submit" type="submit" value="Изменить" />' . "\n";
        echo '</form>' . "\n";
        echo '<br />' . "\n";
        echo '<img src="images/t-back.png" alt=".." /><a href="?func=emailredirect">Вернуться</a>' . "\n";
    } else {
        $content = api_query('https://' . $server . '/manager/ispmgr?func=emailredirect.edit&elid=' . urlencode($_GET['elid']) . '&name=' . urlencode($_POST['name']) . '&domain=' . urlencode($_POST['domain']) . '&forward=' . urlencode($_POST['forward']) . '&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=emailredirect">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
        } else {
            echo '<div style="text-align:center">' . "\n";
            echo 'Ошибка при изменении почтового редиректа!<br />' . "\n";
            echo '<a href="?func=emailredirect">Продолжить&#187;</a>' . "\n";
            echo '</div>' . "\n";
        }
    }
}

?>