root/trunk/gui/reseller/alias_edit.php

Revision 1327, 5.7 kB (checked in by rats, 4 months ago)

* Fixed: --scan-knownbad-files and --check-deleted are no longer supported by rkhunter
* Fixed #1471: chkrootkit should be in lenny / hardy
* Updated Chinese (simplified)
* Updated German
* Fixed #1475: typo on installation (ispcp-setup)
* Fixed: default user for rkhunter.log

Line 
1 <?php
2 /**
3  * ispCP ω (OMEGA) a Virtual Hosting Control System
4  *
5  * @copyright     2001-2006 by moleSoftware GmbH
6  * @copyright     2006-2008 by ispCP | http://isp-control.net
7  * @version     SVN: $Id$
8  * @link         http://isp-control.net
9  * @author         ispCP Team
10  *
11  * @license
12  *   This program is free software; you can redistribute it and/or modify it under
13  *   the terms of the MPL General Public License as published by the Free Software
14  *   Foundation; either version 1.1 of the License, or (at your option) any later
15  *   version.
16  *   You should have received a copy of the MPL Mozilla Public License along with
17  *   this program; if not, write to the Open Source Initiative (OSI)
18  *   http://opensource.org | osi@opensource.org
19  */
20
21 require '../include/ispcp-lib.php';
22
23 check_login(__FILE__);
24
25 $tpl = new pTemplate();
26 $tpl->define_dynamic('page', Config::get('RESELLER_TEMPLATE_PATH') . '/edit_alias.tpl');
27 $tpl->define_dynamic('page_message', 'page');
28 $tpl->define_dynamic('logged_from', 'page');
29
30 $theme_color = Config::get('USER_INITIAL_THEME');
31
32 $tpl->assign(
33             array(
34                 'TR_EDIT_ALIAS_PAGE_TITLE' => tr('ispCP - Manage Domain Alias/Edit Alias'),
35                 'THEME_COLOR_PATH' => "../themes/$theme_color",
36                 'THEME_CHARSET' => tr('encoding'),
37                 'ISP_LOGO' => get_logo($_SESSION['user_id'])
38             )
39     );
40
41 /*
42  *
43  * static page messages.
44  *
45  */
46 $tpl->assign(
47             array(
48                 'TR_MANAGE_DOMAIN_ALIAS' => tr('Manage domain alias'),
49                 'TR_EDIT_ALIAS' => tr('Edit domain alias'),
50                 'TR_ALIAS_NAME' => tr('Alias name'),
51                 'TR_DOMAIN_IP' => tr('Domain IP'),
52                 'TR_FORWARD' => tr('Forward to URL'),
53                 'TR_MODIFY' => tr('Modify'),
54                 'TR_CANCEL' => tr('Cancel'),
55                 'TR_ENABLE_FWD' => tr("Enable Forward"),
56                 'TR_ENABLE' => tr("Enable"),
57                 'TR_DISABLE' => tr("Disable"),
58                 'TR_FWD_HELP' => tr("A Forward URL has to start with 'http://'")
59             )
60     );
61
62 gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_users_manage.tpl');
63 gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_users_manage.tpl');
64
65 gen_logged_from($tpl);
66
67 // "Modify" button has ben pressed
68 if (isset($_POST['uaction']) && ('modify' === $_POST['uaction'])) {
69     if (isset($_SESSION['edit_ID'])) {
70         $editid = $_SESSION['edit_ID'];
71     } else if (isset($_GET['edit_id'])) {
72         $editid = $_GET['edit_id'];
73     } else {
74         unset($_SESSION['edit_ID']);
75
76         $_SESSION['aledit'] = '_no_';
77         header('Location: alias.php');
78         die();
79     }
80     // Save data to db
81     if (check_fwd_data($tpl, $editid)) {
82         $_SESSION['aledit'] = "_yes_";
83         header("Location: alias.php");
84         die();
85     }
86 } else {
87     // Get user id that come for edit
88     if (isset($_GET['edit_id'])) {
89         $editid = $_GET['edit_id'];
90     }
91
92     $_SESSION['edit_ID'] = $editid;
93     $tpl->assign('PAGE_MESSAGE', "");
94 }
95
96 gen_editalias_page($tpl, $editid);
97
98 $tpl->parse('PAGE', 'page');
99 $tpl->prnt();
100
101 if (Config::get('DUMP_GUI_DEBUG'))
102     dump_gui_debug();
103
104 unset_messages();
105
106 // Begin function block
107
108 // Show user data
109 function gen_editalias_page(&$tpl, $edit_id) {
110     $sql = Database::getInstance();
111
112     $reseller_id = $_SESSION['user_id'];
113
114     $query = <<<SQL_QUERY
115     select
116       t1.domain_id,
117       t1.alias_id,
118       t1.alias_name,
119       t2.domain_id,
120       t2.domain_created_id
121     from
122       domain_aliasses as t1,
123       domain as t2
124     where
125             t1.alias_id = ?
126         and
127             t1.domain_id = t2.domain_id
128         and
129             t2.domain_created_id = ?
130 SQL_QUERY;
131
132     $rs = exec_query($sql, $query, array($edit_id, $reseller_id));
133
134     if ($rs->RecordCount() == 0) {
135         set_page_message(tr('User does not exist or you do not have permission to access this interface!'));
136         header('Location: alias.php');
137         die();
138     }
139     // Get data from sql
140     $res = exec_query($sql, "select * from domain_aliasses where alias_id = ?", array($edit_id));
141
142     if ($res->RecordCount() <= 0) {
143         $_SESSION['aledit'] = '_no_';
144         header('Location: alias.php');
145         die();
146     }
147     $data = $res->FetchRow();
148     // Get ip-data
149     $ipres = exec_query($sql, "select * from server_ips where ip_id = ?", array($data['alias_ip_id']));
150     $ipdat = $ipres->FetchRow();
151     $ip_data = $ipdat['ip_number'] . ' (' . $ipdat['ip_alias'] . ')';
152
153     if (isset($_POST['uaction']) && ($_POST['uaction'] == 'modify'))
154         $url_forward = decode_idna($_POST['forward']);
155     else
156         $url_forward = decode_idna($data['url_forward']);
157
158     if ($data["url_forward"] == "no") {
159         $check_en = "";
160         $check_dis = "checked=\"checked\"";
161         $url_forward = "";
162     } else {
163         $check_en = "checked=\"checked\"";
164         $check_dis = "";
165     }
166     // Fill in the fileds
167     $tpl->assign(
168             array(
169                 'ALIAS_NAME' => decode_idna($data['alias_name']),
170                 'DOMAIN_IP' => $ip_data,
171                 'FORWARD' => $url_forward,
172                 'CHECK_EN' => $check_en,
173                 'CHECK_DIS' => $check_dis,
174                 'ID' => $edit_id
175             )
176         );
177 } // End of gen_editalias_page()
178
179 // Check input data
180 function check_fwd_data(&$tpl, $alias_id) {
181     $sql = Database::getInstance();
182
183     $forward_url = encode_idna($_POST['forward']);
184     $status = $_POST['status'];
185     // unset errors
186     $ed_error = '_off_';
187     $admin_login = '';
188
189     if ($forward_url != 'no') {
190         if (!chk_forward_url($forward_url)) {
191             $ed_error = tr("Incorrect forward syntax");
192         }
193         if (!preg_match("/\/$/", $forward_url)) {
194             $forward_url .= "/";
195         }
196     }
197
198     if ($ed_error === '_off_') {
199         if ($_POST['status'] == 0) {
200             $forward_url = "no";
201         }
202
203         $query = <<<SQL
204             UPDATE
205                 domain_aliasses
206             SET
207                 url_forward = ?,
208                 alias_status = ?
209             WHERE
210                 alias_id = ?
211 SQL;
212
213         exec_query($sql, $query, array($forward_url, Config::get('ITEM_CHANGE_STATUS'), $alias_id));
214         check_for_lock_file();
215         send_request();
216
217         $admin_login = $_SESSION['user_logged'];
218         write_log("$admin_login: changes domain alias forward: " . $rs->fields['t1.alias_name']);
219         unset($_SESSION['edit_ID']);
220         $tpl->assign('MESSAGE', "");
221         return true;
222     } else {
223         $tpl->assign('MESSAGE', $ed_error);
224         $tpl->parse('PAGE_MESSAGE', 'page_message');
225         return false;
226     }
227 } //End of check_user_data()
228
229 ?>
Note: See TracBrowser for help on using the browser.