| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 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') { |
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 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 |
?> |
|---|