Ticket #1998: php.2.patch

File php.2.patch, 22.5 KB (added by JCD, 2 years ago)

Updated patch for client subdomain manage files

  • gui/client/domains_manage.php

     
    148148        } 
    149149} 
    150150 
     151function gen_user_sub_forward($sub_id, $sub_status, $url_forward, $dmn_type) { 
     152    if ($url_forward === 'no') { 
     153        if ($sub_status === Config::get('ITEM_OK_STATUS')) { 
     154            return array('-', 'subdomain_edit.php?edit_id='.$sub_id.'&dmn_type='.$dmn_type, tr('Edit')); 
     155        } else if ($sub_status === Config::get('ITEM_ORDERED_STATUS')) { 
     156            return array('-', '#', tr('N/A')); 
     157        } else { 
     158            return array(tr('N/A'), '#', tr('N/A')); 
     159        } 
     160    } else { 
     161        if ($sub_status === Config::get('ITEM_OK_STATUS')) { 
     162            return array($url_forward, 'subdomain_edit.php?edit_id='.$sub_id.'&dmn_type='.$dmn_type, tr('Edit')); 
     163        } else if ($sub_status === Config::get('ITEM_ORDERED_STATUS')) { 
     164            return array($url_forward, '#', tr('N/A')); 
     165        } else { 
     166            return array(tr('N/A'), '#', tr('N/A')); 
     167        } 
     168    } 
     169} 
     170 
    151171function gen_user_sub_list(&$tpl, &$sql, $user_id) { 
    152172        $domain_id = get_user_domain_id($sql, $user_id); 
    153173 
     
    156176                        `subdomain_id`, 
    157177                        `subdomain_name`, 
    158178                        `subdomain_mount`, 
     179            `subdomain_url_forward`, 
    159180                        `subdomain_status`, 
    160181                        `domain_name` 
    161182                FROM 
     
    173194                        `subdomain_alias_id`, 
    174195                        `subdomain_alias_name`, 
    175196                        `subdomain_alias_mount`, 
     197            `subdomain_alias_url_forward`, 
    176198                        `subdomain_alias_status`, 
    177199                        `alias_name` 
    178200                FROM 
     
    197219                        $tpl->assign('ITEM_CLASS', ($counter % 2 == 0) ? 'content' : 'content2'); 
    198220 
    199221                        list($sub_action, $sub_action_script) = gen_user_sub_action($rs->fields['subdomain_id'], $rs->fields['subdomain_status']); 
     222            list($sub_forward, $sub_edit_link, $sub_edit) = gen_user_sub_forward($rs->fields['subdomain_id'], $rs->fields['subdomain_status'], $rs->fields['subdomain_url_forward'], 'dmn'); 
    200223                        $sbd_name = decode_idna($rs->fields['subdomain_name']); 
     224            $sub_forward = decode_idna($sub_forward); 
    201225                        $tpl->assign( 
    202226                                array( 
    203227                                        'SUB_NAME'                      => $sbd_name, 
    204228                                        'SUB_ALIAS_NAME'        => $rs->fields['domain_name'], 
    205229                                        'SUB_MOUNT'                     => $rs->fields['subdomain_mount'], 
     230                    'SUB_FORWARD'       => $sub_forward, 
    206231                                        'SUB_STATUS'            => translate_dmn_status($rs->fields['subdomain_status']), 
     232            'SUB_EDIT_LINK'     => $sub_edit_link, 
     233                    'SUB_EDIT'          => $sub_edit, 
    207234                                        'SUB_ACTION'            => $sub_action, 
    208235                                        'SUB_ACTION_SCRIPT'     => $sub_action_script 
    209236                                ) 
     
    216243                        $tpl->assign('ITEM_CLASS', ($counter % 2 == 0) ? 'content' : 'content2'); 
    217244 
    218245                        list($sub_action, $sub_action_script) = gen_user_alssub_action($rs2->fields['subdomain_alias_id'], $rs2->fields['subdomain_alias_status']); 
     246            list($sub_forward, $sub_edit_link, $sub_edit) = gen_user_sub_forward($rs2->fields['subdomain_alias_id'], $rs2->fields['subdomain_alias_status'], $rs2->fields['subdomain_alias_url_forward'], 'als'); 
    219247                        $sbd_name = decode_idna($rs2->fields['subdomain_alias_name']); 
     248            $sub_forward = decode_idna($sub_forward); 
    220249                        $tpl->assign( 
    221250                                array( 
    222251                                        'SUB_NAME'                      => $sbd_name, 
    223252                                        'SUB_ALIAS_NAME'        => $rs2->fields['alias_name'], 
    224253                                        'SUB_MOUNT'                     => $rs2->fields['subdomain_alias_mount'], 
     254                    'SUB_FORWARD'       => $sub_forward, 
    225255                                        'SUB_STATUS'            => translate_dmn_status($rs2->fields['subdomain_alias_status']), 
     256                    'SUB_EDIT_LINK'     => $sub_edit_link, 
     257                    'SUB_EDIT'          => $sub_edit, 
    226258                                        'SUB_ACTION'            => $sub_action, 
    227259                                        'SUB_ACTION_SCRIPT'     => $sub_action_script 
    228260                                ) 
     
    363395                'TR_SUBDOMAINS'         => tr('Subdomains'), 
    364396                'TR_SUB_NAME'           => tr('Name'), 
    365397                'TR_SUB_MOUNT'          => tr('Mount point'), 
     398    'TR_SUB_FORWARD'    => tr('Forward'), 
    366399                'TR_SUB_STATUS'         => tr('Status'), 
    367400                'TR_SUB_ACTION'         => tr('Actions'), 
    368401                'TR_MESSAGE_DELETE'     => tr('Are you sure you want to delete %s?', true, '%s'), 
  • gui/client/subdomain_add.php

     
    7070} 
    7171 
    7272function gen_user_add_subdomain_data(&$tpl, &$sql, $user_id) { 
     73    // initialize variables 
     74    $subdomain_name = $subdomain_mnt_pt = $forward = $forward_prefix = ''; 
    7375        $query = " 
    7476                SELECT 
    7577                        `domain_name`, 
     
    9294        gen_dmn_als_list($tpl, $sql, $rs->fields['domain_id'], 'no'); 
    9395 
    9496        if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_subd') { 
     97        if($_POST['status'] == 1) { 
     98            $forward_prefix = clean_input($_POST['forward_prefix']); 
     99            $check_en = 'checked="checked"'; 
     100            $check_dis = ''; 
     101            $forward = strtolower(clean_input($_POST['forward'])); 
    95102                $tpl->assign( 
    96103                        array( 
    97                                 'SUBDOMAIN_NAME' => clean_input($_POST['subdomain_name']), 
    98                                 'SUBDOMAIN_MOUNT_POINT' => clean_input($_POST['subdomain_mnt_pt']) 
     104                    'READONLY_FORWARD' => '', 
     105                    'DISABLE_FORWARD' => '', 
    99106                        ) 
    100107                ); 
    101108        } else { 
     109            $check_en = ''; 
     110            $check_dis = 'checked="checked"'; 
     111            $forward = ''; 
    102112                $tpl->assign( 
    103113                        array( 
    104                                 'SUBDOMAIN_NAME' => '', 
    105                                 'SUBDOMAIN_MOUNT_POINT' => '' 
     114                    'READONLY_FORWARD' => ' readonly', 
     115                    'DISABLE_FORWARD' => ' disabled="disabled"', 
     116                    ) 
     117            ); 
     118        } 
     119        $tpl->assign( 
     120                array( 
     121                'HTTP_YES' => ($forward_prefix === 'http://') ? 'selected="selected"' : '', 
     122                'HTTPS_YES' => ($forward_prefix === 'https://') ? 'selected="selected"' : '', 
     123                'FTP_YES' => ($forward_prefix === 'ftp://') ? 'selected="selected"' : '' 
     124                ) 
     125        ); 
     126 
     127        $subdomain_name = clean_input($_POST['subdomain_name']); 
     128        $subdomain_mnt_pt = clean_input($_POST['subdomain_mnt_pt']); 
     129    } else { 
     130        $check_en = ''; 
     131        $check_dis = 'checked="checked"'; 
     132        $forward = ''; 
     133        $tpl->assign( 
     134                array( 
     135                'READONLY_FORWARD' => ' readonly', 
     136                'DISABLE_FORWARD' => ' disabled="disabled"', 
    106137                        ) 
    107138                ); 
    108139        } 
    109140 
    110         return $rs->fields['domain_name']; 
     141    $tpl->assign( 
     142            array( 
     143            'SUBDOMAIN_NAME' => $subdomain_name, 
     144            'SUBDOMAIN_MOUNT_POINT' => $subdomain_mnt_pt, 
     145            'FORWARD'   => $forward, 
     146            'CHECK_EN'  => $check_en, 
     147            'CHECK_DIS' => $check_dis 
     148            ) 
     149    ); 
     150    /** @todo Do we need to return anything here? 
     151     return $rs->fields['domain_name']; */ 
    111152} 
    112153 
    113154function gen_dmn_als_list(&$tpl, &$sql, $dmn_id, $post_check) { 
     
    280321        return false; 
    281322} 
    282323 
    283 function subdomain_schedule(&$sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt) { 
     324function subdomain_schedule(&$sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt, $forward) { 
    284325        $status_add = Config::get('ITEM_ADD_STATUS'); 
    285326 
    286327        if ($_POST['dmn_type'] == 'als') { 
     
    290331                                        (`alias_id`, 
    291332                                        `subdomain_alias_name`, 
    292333                                        `subdomain_alias_mount`, 
     334                                        `subdomain_alias_url_forward`, 
    293335                                        `subdomain_alias_status`) 
    294336                        VALUES 
    295                                 (?, ?, ?, ?) 
     337                                (?, ?, ?, ?, ?) 
    296338                "; 
    297339        } else { 
    298340                $query = " 
     
    301343                                        (`domain_id`, 
    302344                                        `subdomain_name`, 
    303345                                        `subdomain_mount`, 
     346                                        `subdomain_url_forward`, 
    304347                                        `subdomain_status`) 
    305348                        VALUES 
    306                                 (?, ?, ?, ?) 
     349                                (?, ?, ?, ?, ?) 
    307350                "; 
    308351        } 
    309352 
    310         $rs = exec_query($sql, $query, array($domain_id, $sub_name, $sub_mnt_pt, $status_add)); 
     353    $rs = exec_query($sql, $query, array($domain_id, $sub_name, $sub_mnt_pt, $forward, $status_add)); 
    311354 
    312355        update_reseller_c_props(get_reseller_id($domain_id)); 
    313356 
     
    320363        send_request(); 
    321364} 
    322365 
    323 function check_subdomain_data(&$tpl, &$sql, $user_id, $dmn_name) { 
    324  
     366function check_subdomain_data(&$tpl, &$sql, &$err_sub, $user_id, $dmn_name) { 
    325367        global $validation_err_msg; 
    326368        $dmn_id = $domain_id = get_user_domain_id($sql, $user_id); 
    327369 
    328370        if (isset($_POST['uaction']) && $_POST['uaction'] === 'add_subd') { 
    329371 
    330372                if (empty($_POST['subdomain_name'])) { 
    331                         set_page_message(tr('Please specify subdomain name!')); 
     373            $err_sub = tr('Please specify subdomain name!'); 
    332374                        return; 
    333375                } 
    334376                $sub_name = strtolower($_POST['subdomain_name']); 
    335377 
     378        if ($_POST['status'] == 1) { 
     379            $forward = strtolower(clean_input($_POST['forward'])); 
     380            $forward_prefix = clean_input($_POST['forward_prefix']); 
     381        } else { 
     382            $forward = 'no'; 
     383            $forward_prefix = ''; 
     384        } 
     385 
    336386                // Should be perfomed after domain names syntax validation now 
    337387                //$sub_name = encode_idna($sub_name); 
    338388 
     
    346396                if ($_POST['dmn_type'] === 'als') { 
    347397 
    348398                        if (!isset($_POST['als_id'])) { 
    349                                 set_page_message(tr('No valid alias domain selected!')); 
     399                $err_sub = tr('No valid alias domain selected!'); 
    350400                                return; 
    351401                        } 
    352402 
     
    371421                        $domain_id = $_POST['als_id']; 
    372422                } 
    373423 
    374                 // First check if input string is a valid domain names 
     424        // First check if input string is a valid domain name 
    375425                if(!validates_subdname($sub_name, decode_idna($dmn_name))) { 
    376                         set_page_message($validation_err_msg); 
     426            $err_sub = $validation_err_msg; 
    377427                        return; 
    378428                } 
    379429 
     
    381431                $sub_name = encode_idna($sub_name); 
    382432 
    383433                if (subdmn_exists($sql, $user_id, $domain_id, $sub_name)) { 
    384                         set_page_message(tr('Subdomain already exists or is not allowed!')); 
     434            $err_sub = tr('Subdomain already exists or is not allowed!'); 
    385435                } elseif (mount_point_exists($dmn_id, array_decode_idna($sub_mnt_pt, true))) { 
    386                         set_page_message(tr('Mount point already in use!')); 
     436            $err_sub = tr('Mount point already in use!'); 
    387437                } elseif (!validates_mpoint($sub_mnt_pt)) { 
    388                         set_page_message(tr('Incorrect mount point syntax!')); 
     438            $err_sub = tr('Incorrect mount point syntax!'); 
     439        } elseif ($_POST['status'] == 1) { 
     440            $ret = validates_uri($forward); 
     441            if(!$ret) { 
     442                $err_sub = tr('Wrong domain part in forward URL!'); 
     443            } else { 
     444                $forward = encode_idna($forward_prefix.$forward); 
     445            } 
    389446                } else { 
    390447                        // now let's fix the mountpoint 
     448            $mount_point = array_decode_idna($mount_point, true); 
    391449                        $sub_mnt_pt = array_decode_idna($sub_mnt_pt, true); 
    392  
    393                         subdomain_schedule($sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt); 
     450        } 
     451        if ('_off_' !== $err_sub) { 
     452            return; 
     453        } 
     454        subdomain_schedule($sql, $user_id, $domain_id, $sub_name, $sub_mnt_pt, $forward); 
    394455                        set_page_message(tr('Subdomain scheduled for addition!')); 
    395456                        user_goto('domains_manage.php'); 
    396457                } 
    397458        } 
    398 } 
    399459 
    400460// common page data. 
    401461 
     
    415475        ) 
    416476); 
    417477 
    418 // dynamic page data. 
    419  
    420 $dmn_name = check_subdomain_permissions($sql, $_SESSION['user_id']); 
    421 gen_user_add_subdomain_data($tpl, $sql, $_SESSION['user_id']); 
    422 check_subdomain_data($tpl, $sql, $_SESSION['user_id'], $dmn_name); 
    423  
    424478// static page messages. 
    425479 
    426480gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_manage_domains.tpl'); 
     
    436490                'TR_SUBDOMAIN_DATA' => tr('Subdomain data'), 
    437491                'TR_SUBDOMAIN_NAME' => tr('Subdomain name'), 
    438492                'TR_DIR_TREE_SUBDOMAIN_MOUNT_POINT' => tr('Directory tree mount point'), 
     493        'TR_FORWARD' => tr('Forward to URL'), 
    439494                'TR_ADD' => tr('Add'), 
    440                 'TR_DMN_HELP' => tr("You do not need 'www.' ispCP will add it on its own.") 
     495        'TR_DMN_HELP' => tr("You do not need 'www.' ispCP will add it on its own."), 
     496        'TR_ENABLE_FWD' => tr("Enable Forward"), 
     497        'TR_ENABLE' => tr("Enable"), 
     498        'TR_DISABLE' => tr("Disable"), 
     499        'TR_PREFIX_HTTP' => 'http://', 
     500        'TR_PREFIX_HTTPS' => 'https://', 
     501        'TR_PREFIX_FTP' => 'ftp://' 
    441502        ) 
    442503); 
    443504 
    444 gen_page_message($tpl); 
     505 
     506$err_txt = '_off_'; 
     507 
     508// dynamic page data. 
     509 
     510$dmn_name = check_subdomain_permissions($sql, $_SESSION['user_id']); 
     511gen_user_add_subdomain_data($tpl, $sql, $_SESSION['user_id']); 
     512 
     513function gen_page_msg(&$tpl, $erro_txt) { 
     514 
     515    if ($erro_txt != '_off_') { 
     516        $tpl->assign('MESSAGE', $erro_txt); 
     517        $tpl->parse('PAGE_MESSAGE', 'page_message'); 
     518    } else { 
     519        $tpl->assign('PAGE_MESSAGE', ''); 
     520    } 
     521 
     522} // End of gen_page_msg() 
     523 
     524check_subdomain_data($tpl, $sql, $err_txt, $_SESSION['user_id'], $dmn_name); 
     525 
     526gen_page_msg($tpl, $err_txt); 
    445527 
    446528$tpl->parse('PAGE', 'page'); 
    447529$tpl->prnt(); 
  • gui/client/subdomain_edit.php

     
     1<?php 
     2/** 
     3 * ispCP ω (OMEGA) a Virtual Hosting Control System 
     4 * 
     5 * @copyright   2001-2006 by moleSoftware GmbH 
     6 * @copyright   2006-2010 by ispCP | http://isp-control.net 
     7 * @version     SVN: $Id: alias_edit.php 2599 2010-02-11 15:08:57Z benedikt $ 
     8 * @link                http://isp-control.net 
     9 * @author              ispCP Team 
     10 * 
     11 * @license 
     12 * The contents of this file are subject to the Mozilla Public License 
     13 * Version 1.1 (the "License"); you may not use this file except in 
     14 * compliance with the License. You may obtain a copy of the License at 
     15 * http://www.mozilla.org/MPL/ 
     16 * 
     17 * Software distributed under the License is distributed on an "AS IS" 
     18 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the 
     19 * License for the specific language governing rights and limitations 
     20 * under the License. 
     21 * 
     22 * The Original Code is "VHCS - Virtual Hosting Control System". 
     23 * 
     24 * The Initial Developer of the Original Code is moleSoftware GmbH. 
     25 * Portions created by Initial Developer are Copyright (C) 2001-2006 
     26 * by moleSoftware GmbH. All Rights Reserved. 
     27 * Portions created by the ispCP Team are Copyright (C) 2006-2010 by 
     28 * isp Control Panel. All Rights Reserved. 
     29 */ 
     30 
     31require '../include/ispcp-lib.php'; 
     32 
     33check_login(__FILE__); 
     34 
     35$tpl = new pTemplate(); 
     36$tpl->define_dynamic('page', Config::get('CLIENT_TEMPLATE_PATH') . '/subdomain_edit.tpl'); 
     37$tpl->define_dynamic('page_message', 'page'); 
     38$tpl->define_dynamic('logged_from', 'page'); 
     39 
     40$theme_color = Config::get('USER_INITIAL_THEME'); 
     41 
     42$tpl->assign( 
     43        array( 
     44        'TR_EDIT_SUBDOMAIN_PAGE_TITLE' => tr('ispCP - Manage Subdomain/Edit Subdomain'), 
     45        'THEME_COLOR_PATH' => "../themes/$theme_color", 
     46        'THEME_CHARSET' => tr('encoding'), 
     47        'ISP_LOGO' => get_logo($_SESSION['user_id']) 
     48        ) 
     49); 
     50 
     51/* 
     52 * 
     53 * static page messages. 
     54 * 
     55*/ 
     56$tpl->assign( 
     57        array( 
     58        'TR_MANAGE_SUBDOMAIN' => tr('Manage subdomain'), 
     59        'TR_EDIT_SUBDOMAIN' => tr('Edit subdomain'), 
     60        'TR_SUBDOMAIN_NAME' => tr('Subdomain name'), 
     61        'TR_FORWARD' => tr('Forward to URL'), 
     62        'TR_MOUNT_POINT' => tr('Mount Point'), 
     63        'TR_MODIFY' => tr('Modify'), 
     64        'TR_CANCEL' => tr('Cancel'), 
     65        'TR_ENABLE_FWD' => tr("Enable Forward"), 
     66        'TR_ENABLE' => tr("Enable"), 
     67        'TR_DISABLE' => tr("Disable"), 
     68        'TR_FWD_HELP' => tr("A Forward URL has to start with 'http://'"), 
     69        'TR_PREFIX_HTTP' => 'http://', 
     70        'TR_PREFIX_HTTPS' => 'https://', 
     71        'TR_PREFIX_FTP' => 'ftp://' 
     72        ) 
     73); 
     74 
     75gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_manage_domains.tpl'); 
     76gen_client_menu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/menu_manage_domains.tpl'); 
     77 
     78gen_logged_from($tpl); 
     79 
     80// "Modify" button has been pressed 
     81if (isset($_POST['uaction']) && ($_POST['uaction'] === 'modify')) { 
     82    if (isset($_GET['edit_id'])) { 
     83        $editid = $_GET['edit_id']; 
     84    } else if (isset($_SESSION['edit_ID'])) { 
     85        $editid = $_SESSION['edit_ID']; 
     86    } else { 
     87        unset($_SESSION['edit_ID']); 
     88 
     89        $_SESSION['subedit'] = '_no_'; 
     90        user_goto('domains_manage.php'); 
     91    } 
     92    // Get subdomain type 
     93    if (isset($_POST['dmn_type'])) { 
     94        $dmntype = $_POST['dmn_type']; 
     95    } else { 
     96        unset($_SESSION['edit_ID']); 
     97 
     98        $_SESSION['subedit'] = '_no_'; 
     99        user_goto('domains_manage.php'); 
     100    } 
     101    // Save data to db 
     102    if (check_fwd_data($tpl, $editid, $dmntype)) { 
     103        $_SESSION['subedit'] = "_yes_"; 
     104        user_goto('domains_manage.php'); 
     105    } 
     106} else { 
     107    // Get user id that comes for edit 
     108    if (isset($_GET['edit_id'])) { 
     109        $editid = $_GET['edit_id']; 
     110    } 
     111 
     112    // Get subdomain type 
     113    if (isset($_GET['dmn_type'])) { 
     114        $dmntype = $_GET['dmn_type']; 
     115    } else { 
     116        user_goto('domains_manage.php'); 
     117    } 
     118 
     119    $_SESSION['edit_ID'] = $editid; 
     120    $tpl->assign('PAGE_MESSAGE', ""); 
     121} 
     122gen_editsubdomain_page($tpl, $editid, $dmntype); 
     123 
     124$tpl->parse('PAGE', 'page'); 
     125$tpl->prnt(); 
     126 
     127if (Config::get('DUMP_GUI_DEBUG')) { 
     128    dump_gui_debug(); 
     129} 
     130unset_messages(); 
     131 
     132// Begin function block 
     133 
     134/** 
     135 * Show user data 
     136 */ 
     137function gen_editsubdomain_page(&$tpl, $edit_id, $dmn_type) { 
     138    $sql = Database::getInstance(); 
     139    // Get data from sql 
     140    list($domain_id, $domain_name) = get_domain_default_props($sql, $_SESSION['user_id']); 
     141 
     142    if ($dmn_type === 'dmn') { 
     143        $res = exec_query($sql, "SELECT * FROM `subdomain` WHERE `subdomain_id` = ? AND `domain_id` = ?", array($edit_id, $domain_id)); 
     144    } else { 
     145        $query = " 
     146                 SELECT 
     147                    t1.`subdomain_alias_name` AS subdomain_name, 
     148                    t1.`subdomain_alias_mount` AS subdomain_mount, 
     149                    t1.`subdomain_alias_url_forward` AS subdomain_url_forward, 
     150                    t2.`alias_name` AS domain_name 
     151                 FROM 
     152                    `subdomain_alias` t1 
     153                 LEFT JOIN 
     154                    (`domain_aliasses` AS t2) ON (t1.`alias_id` = t2.`alias_id`) 
     155                 WHERE 
     156                    t1.`alias_id` IN (SELECT `alias_id` FROM `domain_aliasses` WHERE `domain_id` = ?) 
     157                 AND 
     158                    `subdomain_alias_id` = ?"; 
     159 
     160        $res = exec_query($sql, $query, array($domain_id, $edit_id)); 
     161    } 
     162 
     163    if ($res->RecordCount() <= 0) { 
     164        $_SESSION['subedit'] = '_no_'; 
     165        user_goto('domains_manage.php'); 
     166    } 
     167    $data = $res->FetchRow(); 
     168 
     169    if ($dmn_type === 'als') { 
     170        $domain_name = $data['domain_name']; 
     171    } 
     172 
     173    if (isset($_POST['uaction']) && ($_POST['uaction'] == 'modify')) { 
     174        $url_forward = strtolower(clean_input($_POST['forward'])); 
     175    } else { 
     176        $url_forward = decode_idna(preg_replace("(ftp://|https://|http://)", "", $data['subdomain_url_forward'])); 
     177 
     178        if ($data['subdomain_url_forward'] == 'no') { 
     179            $check_en = ''; 
     180            $check_dis = 'checked="checked"'; 
     181            $url_forward = ''; 
     182            $tpl->assign( 
     183                    array( 
     184                    'READONLY_FORWARD' => ' readonly', 
     185                    'DISABLE_FORWARD' => ' disabled="disabled"' 
     186                    ) 
     187            ); 
     188        } else { 
     189            $check_en = 'checked="checked"'; 
     190            $check_dis = ''; 
     191            $tpl->assign( 
     192                    array( 
     193                    'READONLY_FORWARD' => '', 
     194                    'DISABLE_FORWARD' => '', 
     195                    'HTTP_YES' => (preg_match("/http:\/\//", $data['subdomain_url_forward'])) ? 'selected="selected"' : '', 
     196                    'HTTPS_YES' => (preg_match("/https:\/\//", $data['subdomain_url_forward'])) ? 'selected="selected"' : '', 
     197                    'FTP_YES' => (preg_match("/ftp:\/\//", $data['subdomain_url_forward'])) ? 'selected="selected"' : '' 
     198                    ) 
     199            ); 
     200        } 
     201        $tpl->assign( 
     202                array( 
     203                'CHECK_EN' => $check_en, 
     204                'CHECK_DIS' => $check_dis 
     205                ) 
     206        ); 
     207    } 
     208    // Fill in the fields 
     209    $tpl->assign( 
     210            array( 
     211            'SUBDOMAIN_NAME' => decode_idna($data['subdomain_name']) . '.' . $domain_name, 
     212            'FORWARD' => $url_forward, 
     213            'MOUNT_POINT' => $data['subdomain_mount'], 
     214            'ID' => $edit_id, 
     215            'DMN_TYPE' => $dmn_type 
     216            ) 
     217    ); 
     218 
     219} // End of gen_editsubdomain_page() 
     220 
     221/** 
     222 * Check input data 
     223 */ 
     224function check_fwd_data(&$tpl, $subdomain_id, $dmn_type) { 
     225    $sql = Database::getInstance(); 
     226 
     227    $forward_url = strtolower(clean_input($_POST['forward'])); 
     228    $status = $_POST['status']; 
     229    // unset errors 
     230    $ed_error = '_off_'; 
     231    $admin_login = ''; 
     232 
     233    if (isset($_POST['status']) && $_POST['status'] == 1) { 
     234        $forward_prefix = clean_input($_POST['forward_prefix']); 
     235        $ret = validates_uri($forward_url, true); 
     236        if(!$ret) { 
     237            $ed_error = tr("Wrong domain part in forward URL!"); 
     238        } else { 
     239            $forward_url = encode_idna($forward_prefix.$forward_url); 
     240        } 
     241 
     242        $check_en = 'checked="checked"'; 
     243        $check_dis = ''; 
     244        $tpl->assign( 
     245                array( 
     246                'FORWARD' => $forward_url, 
     247                'HTTP_YES' => ($forward_prefix === 'http://') ? 'selected="selected"' : '', 
     248                'HTTPS_YES' => ($forward_prefix === 'https://') ? 'selected="selected"' : '', 
     249                'FTP_YES' => ($forward_prefix === 'ftp://') ? 'selected="selected"' : '', 
     250                'CHECK_EN' => $check_en, 
     251                'CHECK_DIS' => $check_dis, 
     252                ) 
     253        ); 
     254    } else { 
     255        $check_en = ''; 
     256        $check_dis = 'checked="checked"'; 
     257        $forward_url = 'no'; 
     258        $tpl->assign( 
     259                array( 
     260                'READONLY_FORWARD' => ' readonly', 
     261                'DISABLE_FORWARD' => ' disabled="disabled"', 
     262                'CHECK_EN' => $check_en, 
     263                'CHECK_DIS' => $check_dis, 
     264                ) 
     265        ); 
     266    } 
     267    if ($ed_error === '_off_') { 
     268        if ($dmn_type === 'dmn') { 
     269            $query = " 
     270                       UPDATE 
     271                          `subdomain` 
     272                       SET 
     273                          `subdomain_url_forward` = ?, 
     274                          `subdomain_status` = ? 
     275                       WHERE 
     276                          `subdomain_id` = ? 
     277                     "; 
     278        } else { 
     279            $query = " 
     280                       UPDATE 
     281                          `subdomain_alias` 
     282                       SET 
     283                          `subdomain_alias_url_forward` = ?, 
     284                          `subdomain_alias_status` = ? 
     285                       WHERE 
     286                          `subdomain_alias_id` = ? 
     287                     "; 
     288        } 
     289 
     290        exec_query($sql, $query, array($forward_url, Config::get('ITEM_CHANGE_STATUS'), $subdomain_id)); 
     291 
     292        send_request(); 
     293 
     294        $admin_login = $_SESSION['user_logged']; 
     295        write_log("$admin_login: change domain alias forward: " . $rs->fields['t1.alias_name']); 
     296        unset($_SESSION['edit_ID']); 
     297        $tpl->assign('MESSAGE', ""); 
     298        return true; 
     299    } else { 
     300        $tpl->assign('MESSAGE', $ed_error); 
     301        $tpl->parse('PAGE_MESSAGE', 'page_message'); 
     302        return false; 
     303    } 
     304} // End of check_fwd_data()