root/trunk/gui/reseller/settings_layout.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') . '/settings_layout.tpl');
27 $tpl->define_dynamic('page_message', 'page');
28 $tpl->define_dynamic('logged_from', 'page');
29 $tpl->define_dynamic('def_layout', 'page');
30
31 $theme_color = Config::get('USER_INITIAL_THEME');
32
33
34 function save_layout() {
35     $sql = Database::getInstance();
36     global $theme_color;
37
38     if (isset($_POST['uaction']) && $_POST['uaction'] === 'save_layout') {
39
40         $user_id = $_SESSION['user_id'];
41
42         $user_layout = $_POST['def_layout'];
43
44         $query = <<<SQL_QUERY
45             update
46                 user_gui_props
47             set
48                 layout = ?
49             where
50                 user_id = ?
51 SQL_QUERY;
52
53         $rs = exec_query($sql, $query, array($user_layout, $user_id));
54
55         $theme_color = $user_layout;
56
57         $_SESSION['user_theme_color'] = $user_layout;
58     }
59 }
60
61
62 function update_logo() {
63
64     $user_id = $_SESSION['user_id'];
65
66     if (isset($_POST['uaction']) && $_POST['uaction'] === 'delete_logo') {
67
68         $logo = get_own_logo($user_id);
69
70         if (basename($logo) == 'isp_logo.gif') { //default logo
71             return;
72         }
73
74         update_user_gui_props('', $user_id);
75         unlink($logo);
76
77         return;
78
79     } else if (isset($_POST['uaction']) && $_POST['uaction'] === 'upload_logo') {
80
81             if (empty($_FILES['logo_file']['tmp_name'])) {
82                     set_page_message(tr('Upload file error!'));
83                     return;
84             }
85
86             $file_type = $_FILES['logo_file']['type'];
87
88             switch ($file_type) {
89                 case 'image/gif':
90                     $fext = 'gif';
91                     break;
92                 case 'image/jpeg':
93                 case 'image/pjpeg':
94                     $file_type = 'image/jpeg';
95                     $fext = 'jpg';
96                     break;
97                 case 'image/png':
98                     $fext = 'png';
99                     break;
100                 default:
101                     set_page_message(tr('You can only upload images!'));
102                     return ;
103                     break;
104             }
105
106             $fname = $_FILES['logo_file']['tmp_name'];
107
108             // Make sure it is really an image
109             if (image_type_to_mime_type(exif_imagetype($fname)) != $file_type) {
110                 set_page_message(tr('You can only upload images!'));
111                 return ;
112             }
113
114             // get the size of the image to prevent over large images
115             list($fwidth, $fheight, $ftype, $fattr) = getimagesize($fname);
116             if ($fwidth > 195 || $fheight > 195) {
117                 set_page_message(tr('Images have to be smaller than 195 x 195 pixels!'));
118                 return;
119             }
120
121             $newFName = get_user_name($user_id) . '.' . $fext;
122
123             $path = substr($_SERVER['SCRIPT_FILENAME'],0, strpos($_SERVER['SCRIPT_FILENAME'], '/reseller/settings_layout.php')+1);
124
125             $logoFile = $path . '/themes/user_logos/' . $newFName;
126             move_uploaded_file($fname, $logoFile);
127             chmod ($logoFile, 0644);
128
129             update_user_gui_props($newFName, $user_id);
130
131             set_page_message(tr('Your logo was successful uploaded!'));
132
133     }
134 }
135
136
137 function update_user_gui_props($file_name, $user_id) {
138     $sql = Database::getInstance();
139
140     $query = <<<SQL_QUERY
141         update
142             user_gui_props
143         set
144             logo = ?
145         where
146             user_id = ?
147 SQL_QUERY;
148
149     $rs = exec_query($sql, $query, array($file_name, $user_id));
150
151 }
152
153 save_layout();
154
155 gen_def_layout($tpl, $theme_color);
156
157 $tpl->assign(
158             array(
159                 'TR_RESELLER_LAYOUT_DATA_PAGE_TITLE' => tr('ispCP - Reseller/Change Personal Data'),
160                 'THEME_COLOR_PATH' => "../themes/$theme_color",
161                 'OWN_LOGO' => get_own_logo($_SESSION['user_id']),
162                 'THEME_CHARSET' => tr('encoding'),
163                 'ISP_LOGO' => get_logo($_SESSION['user_id']),
164                  )
165           );
166
167 /*
168  *
169  * static page messages.
170  *
171  */
172
173 gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_general_information.tpl');
174 gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_general_information.tpl');
175
176 gen_logged_from($tpl);
177
178 update_logo();
179
180 $tpl->assign(
181                 array(
182                         'TR_LAYOUT_SETTINGS' => tr('Layout settings'),
183                         'TR_INSTALLED_LAYOUTS' => tr('Installed layouts'),
184                         'TR_LAYOUT_NAME' => tr('Layout name'),
185                         'TR_LAYOUT' => tr('Layout'),
186                         'TR_DEFAULT' => tr('default'),
187                         'TR_YES' => tr('yes'),
188                         'TR_SAVE' => tr('Save'),
189                         'TR_UPLOAD_LOGO' => tr('Upload logo'),
190                         'TR_LOGO_FILE' => tr('Logo file'),
191                         'TR_UPLOAD' => tr('Upload'),
192                         'TR_REMOVE' => tr('Remove'),
193                         'TR_CHOOSE_DEFAULT_LAYOUT' => tr('Choose default layout'),
194                      )
195               );
196
197 gen_page_message($tpl);
198
199 $tpl->parse('PAGE', 'page');
200 $tpl->prnt();
201
202 if (Config::get('DUMP_GUI_DEBUG'))
203     dump_gui_debug();
204
205 unset_messages();
206 ?>
Note: See TracBrowser for help on using the browser.