| 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 |
$theme_color = Config::get('USER_INITIAL_THEME'); |
|---|
| 26 |
|
|---|
| 27 |
$tpl = new pTemplate(); |
|---|
| 28 |
$tpl->define_dynamic('page', Config::get('RESELLER_TEMPLATE_PATH') . '/index.tpl'); |
|---|
| 29 |
$tpl->define_dynamic('def_language', 'page'); |
|---|
| 30 |
$tpl->define_dynamic('def_layout', 'page'); |
|---|
| 31 |
$tpl->define_dynamic('no_messages', 'page'); |
|---|
| 32 |
$tpl->define_dynamic('msg_entry', 'page'); |
|---|
| 33 |
$tpl->define_dynamic('traff_warn', 'page'); |
|---|
| 34 |
$tpl->define_dynamic('layout', 'page'); |
|---|
| 35 |
$tpl->define_dynamic('logged_from', 'page'); |
|---|
| 36 |
$tpl->define_dynamic('traff_warn', 'page'); |
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
function gen_system_message(&$tpl, &$sql) { |
|---|
| 40 |
$user_id = $_SESSION['user_id']; |
|---|
| 41 |
|
|---|
| 42 |
$query = <<<SQL_QUERY |
|---|
| 43 |
select |
|---|
| 44 |
count(ticket_id) as cnum |
|---|
| 45 |
from |
|---|
| 46 |
tickets |
|---|
| 47 |
where |
|---|
| 48 |
(ticket_to = ? or ticket_from = ?) |
|---|
| 49 |
and |
|---|
| 50 |
(ticket_status = '1' or ticket_status = '4') |
|---|
| 51 |
and |
|---|
| 52 |
ticket_reply = 0 |
|---|
| 53 |
SQL_QUERY; |
|---|
| 54 |
|
|---|
| 55 |
$rs = exec_query($sql, $query, array($user_id, $user_id)); |
|---|
| 56 |
|
|---|
| 57 |
$num_question = $rs->fields('cnum'); |
|---|
| 58 |
|
|---|
| 59 |
if ($num_question == 0) { |
|---|
| 60 |
$tpl->assign(array('MSG_ENTRY' => '')); |
|---|
| 61 |
} else { |
|---|
| 62 |
$tpl->assign( |
|---|
| 63 |
array( |
|---|
| 64 |
'TR_NEW_MSGS' => tr('You have <b>%d</b> new support questions', $num_question), |
|---|
| 65 |
'TR_VIEW' => tr('View') |
|---|
| 66 |
) |
|---|
| 67 |
); |
|---|
| 68 |
|
|---|
| 69 |
$tpl->parse('MSG_ENTRY', 'msg_entry'); |
|---|
| 70 |
} |
|---|
| 71 |
} |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
function gen_traff_usage(&$tpl, $usage, $max_usage, $bars_max) { |
|---|
| 75 |
if (0 !== $max_usage) { |
|---|
| 76 |
list($percent, $bars) = calc_bars($usage, $max_usage, $bars_max); |
|---|
| 77 |
$traffic_usage_data = tr('%1$s%% [%2$s of %3$s]', $percent, sizeit($usage), sizeit($max_usage)); |
|---|
| 78 |
} else { |
|---|
| 79 |
$percent = 0; |
|---|
| 80 |
$bars = 0; |
|---|
| 81 |
$traffic_usage_data = tr('%1$s%% [%2$s of unlimited]', $percent, sizeit($usage), sizeit($max_usage)); |
|---|
| 82 |
} |
|---|
| 83 |
|
|---|
| 84 |
$tpl->assign( |
|---|
| 85 |
array('TRAFFIC_USAGE_DATA' => $traffic_usage_data, |
|---|
| 86 |
'TRAFFIC_BARS' => $bars |
|---|
| 87 |
) |
|---|
| 88 |
); |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
function gen_disk_usage(&$tpl, $usage, $max_usage, $bars_max) { |
|---|
| 92 |
if (0 !== $max_usage) { |
|---|
| 93 |
list($percent, $bars) = calc_bars($usage, $max_usage, $bars_max); |
|---|
| 94 |
$traffic_usage_data = tr('%1$s%% [%2$s of %3$s]', $percent, sizeit($usage), sizeit($max_usage)); |
|---|
| 95 |
} else { |
|---|
| 96 |
$percent = 0; |
|---|
| 97 |
$bars = 0; |
|---|
| 98 |
$traffic_usage_data = tr('%1$s%% [%2$s of unlimited]', $percent, sizeit($usage)); |
|---|
| 99 |
} |
|---|
| 100 |
|
|---|
| 101 |
$tpl->assign( |
|---|
| 102 |
array('DISK_USAGE_DATA' => $traffic_usage_data, |
|---|
| 103 |
'DISK_BARS' => $bars |
|---|
| 104 |
) |
|---|
| 105 |
); |
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
function generate_page_data(&$tpl, $reseller_id, $reseller_name) { |
|---|
| 109 |
$sql = Database::getInstance(); |
|---|
| 110 |
global $crnt_month, $crnt_year; |
|---|
| 111 |
$crnt_month = date("m"); |
|---|
| 112 |
$crnt_year = date("Y"); |
|---|
| 113 |
|
|---|
| 114 |
$tmpArr = get_reseller_default_props($sql, $reseller_id); |
|---|
| 115 |
|
|---|
| 116 |
if ($tmpArr != NULL) { |
|---|
| 117 |
list ($rdmn_current, $rdmn_max, |
|---|
| 118 |
$rsub_current, $rsub_max, |
|---|
| 119 |
$rals_current, $rals_max, |
|---|
| 120 |
$rmail_current, $rmail_max, |
|---|
| 121 |
$rftp_current, $rftp_max, |
|---|
| 122 |
$rsql_db_current, $rsql_db_max, |
|---|
| 123 |
$rsql_user_current, $rsql_user_max, |
|---|
| 124 |
$rtraff_current, $rtraff_max, |
|---|
| 125 |
$rdisk_current, $rdisk_max |
|---|
| 126 |
) = $tmpArr; |
|---|
| 127 |
} else { |
|---|
| 128 |
list ($rdmn_current, $rdmn_max, |
|---|
| 129 |
$rsub_current, $rsub_max, |
|---|
| 130 |
$rals_current, $rals_max, |
|---|
| 131 |
$rmail_current, $rmail_max, |
|---|
| 132 |
$rftp_current, $rftp_max, |
|---|
| 133 |
$rsql_db_current, $rsql_db_max, |
|---|
| 134 |
$rsql_user_current, $rsql_user_max, |
|---|
| 135 |
$rtraff_current, $rtraff_max, |
|---|
| 136 |
$rdisk_current, $rdisk_max |
|---|
| 137 |
) = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); |
|---|
| 138 |
} |
|---|
| 139 |
|
|---|
| 140 |
list ($udmn_current, $udmn_max, $udmn_uf, |
|---|
| 141 |
$usub_current, $usub_max, $usub_uf, |
|---|
| 142 |
$uals_current, $uals_max, $uals_uf, |
|---|
| 143 |
$umail_current, $umail_max, $umail_uf, |
|---|
| 144 |
$uftp_current, $uftp_max, $uftp_uf, |
|---|
| 145 |
$usql_db_current, $usql_db_max, $usql_db_uf, |
|---|
| 146 |
$usql_user_current, $usql_user_max, $usql_user_uf, |
|---|
| 147 |
$utraff_current, $utraff_max, $utraff_uf, |
|---|
| 148 |
$udisk_current, $udisk_max, $udisk_uf |
|---|
| 149 |
) = generate_reseller_user_props($reseller_id); |
|---|
| 150 |
|
|---|
| 151 |
$rtraff_max = $rtraff_max * 1024 * 1024; |
|---|
| 152 |
|
|---|
| 153 |
$rtraff_current = $rtraff_current * 1024 * 1024; |
|---|
| 154 |
|
|---|
| 155 |
$rdisk_max = $rdisk_max * 1024 * 1024; |
|---|
| 156 |
|
|---|
| 157 |
$rdisk_current = $rdisk_current * 1024 * 1024; |
|---|
| 158 |
|
|---|
| 159 |
$utraff_max = $utraff_max * 1024 * 1024; |
|---|
| 160 |
|
|---|
| 161 |
$udisk_max = $udisk_max * 1024 * 1024; |
|---|
| 162 |
|
|---|
| 163 |
list($traff_percent, $traff_red, $traff_green) = make_usage_vals($utraff_current, $rtraff_max); |
|---|
| 164 |
|
|---|
| 165 |
list($disk_percent, $disk_red, $disk_green) = make_usage_vals($udisk_current, $rdisk_max); |
|---|
| 166 |
|
|---|
| 167 |
gen_traff_usage($tpl, $utraff_current, $rtraff_max, 400); |
|---|
| 168 |
|
|---|
| 169 |
gen_disk_usage($tpl, $udisk_current, $rdisk_max, 400); |
|---|
| 170 |
|
|---|
| 171 |
if ($rtraff_max > 0) { |
|---|
| 172 |
if ($utraff_current > $rtraff_max) { |
|---|
| 173 |
$tpl->assign('TR_TRAFFIC_WARNING', tr('You are exceeding your traffic limit!') |
|---|
| 174 |
); |
|---|
| 175 |
} else { |
|---|
| 176 |
$tpl->assign('TRAFF_WARN', ''); |
|---|
| 177 |
} |
|---|
| 178 |
} else { |
|---|
| 179 |
$tpl->assign('TRAFF_WARN', ''); |
|---|
| 180 |
} |
|---|
| 181 |
|
|---|
| 182 |
if ($rdisk_max > 0) { |
|---|
| 183 |
if ($udisk_current > $rdisk_max) { |
|---|
| 184 |
$tpl->assign('TR_DISK_WARNING', tr('You are exceeding your disk limit!') |
|---|
| 185 |
); |
|---|
| 186 |
} else { |
|---|
| 187 |
$tpl->assign('DISK_WARN', ''); |
|---|
| 188 |
} |
|---|
| 189 |
} else { |
|---|
| 190 |
$tpl->assign('DISK_WARN', ''); |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
$tpl->assign( |
|---|
| 194 |
array( |
|---|
| 195 |
'ACCOUNT_NAME' => tr("Account name"), |
|---|
| 196 |
'GENERAL_INFO' => tr("General information"), |
|---|
| 197 |
"DOMAINS" => tr("User accounts"), |
|---|
| 198 |
"SUBDOMAINS" => tr("Subdomains"), |
|---|
| 199 |
"ALIASES" => tr("Aliases"), |
|---|
| 200 |
"MAIL_ACCOUNTS" => tr("Mail account"), |
|---|
| 201 |
"TR_FTP_ACCOUNTS" => tr("FTP account"), |
|---|
| 202 |
"SQL_DATABASES" => tr("SQL databases"), |
|---|
| 203 |
"SQL_USERS" => tr("SQL users"), |
|---|
| 204 |
"TRAFFIC" => tr("Traffic"), |
|---|
| 205 |
"DISK" => tr("Disk"), |
|---|
| 206 |
"TR_EXTRAS" => tr("Extras") |
|---|
| 207 |
) |
|---|
| 208 |
); |
|---|
| 209 |
|
|---|
| 210 |
$tpl->assign( |
|---|
| 211 |
array( |
|---|
| 212 |
'RESELLER_NAME' => $reseller_name, |
|---|
| 213 |
|
|---|
| 214 |
'TRAFF_RED' => $traff_red * 3, |
|---|
| 215 |
'TRAFF_GREEN' => $traff_green * 3, |
|---|
| 216 |
'TRAFF_PERCENT' => $traff_percent, |
|---|
| 217 |
|
|---|
| 218 |
'TRAFF_MSG' => ($rtraff_max) ? |
|---|
| 219 |
tr('%1$s / %2$s of <b>%3$d</b>', sizeit($utraff_current), sizeit($rtraff_current), sizeit($rtraff_max)) : |
|---|
| 220 |
tr('%1$s / %2$s of <b>unlimited</b>', sizeit($utraff_current), sizeit($rtraff_current)), |
|---|
| 221 |
|
|---|
| 222 |
'DISK_MSG' => ($rdisk_max) ? |
|---|
| 223 |
tr('%1$s / %2$s of <b>%3$d</b>', sizeit($udisk_current), sizeit($rdisk_current), sizeit($rdisk_max)) : |
|---|
| 224 |
tr('%1$s / %2$s of <b>unlimited</b>', sizeit($udisk_current), sizeit($rdisk_current)), |
|---|
| 225 |
|
|---|
| 226 |
'DMN_MSG' => ($rdmn_max) ? |
|---|
| 227 |
tr('%1$d / %2$d of <b>%3$d</b>', $udmn_current, $rdmn_current, $rdmn_max): |
|---|
| 228 |
tr('%1$d / %2$d of <b>unlimited</b>', $udmn_current, $rdmn_current), |
|---|
| 229 |
|
|---|
| 230 |
'SUB_MSG' => ($rsub_max) ? |
|---|
| 231 |
tr('%1$d / %2$d of <b>%3$d</b>', $usub_current, $rsub_current, $rsub_max): |
|---|
| 232 |
tr('%1$d / %2$d of <b>unlimited</b>', $usub_current, $rsub_current), |
|---|
| 233 |
|
|---|
| 234 |
'ALS_MSG' => ($rals_max) ? |
|---|
| 235 |
tr('%1$d / %2$d of <b>%3$d</b>', $uals_current, $rals_current, $rals_max): |
|---|
| 236 |
tr('%1$d / %2$d of <b>unlimited</b>', $uals_current, $rals_current), |
|---|
| 237 |
|
|---|
| 238 |
'MAIL_MSG' => ($rmail_max) ? |
|---|
| 239 |
tr('%1$d / %2$d of <b>%3$d</b>', $umail_current, $rmail_current, $rmail_max): |
|---|
| 240 |
tr('%1$d / %2$d of <b>unlimited</b>', $umail_current, $rmail_current), |
|---|
| 241 |
|
|---|
| 242 |
'FTP_MSG' => ($rftp_max) ? |
|---|
| 243 |
tr('%1$d / %2$d of <b>%3$d</b>', $uftp_current, $rftp_current, $rftp_max): |
|---|
| 244 |
tr('%1$d / %2$d of <b>unlimited</b>', $uftp_current, $rftp_current), |
|---|
| 245 |
|
|---|
| 246 |
'SQL_DB_MSG' => ($rsql_db_max) ? |
|---|
| 247 |
tr('%1$d / %2$d of <b>%3$d</b>', $usql_db_current, $rsql_db_current, $rsql_db_max): |
|---|
| 248 |
tr('%1$d / %2$d of <b>unlimited</b>', $usql_db_current, $rsql_db_current), |
|---|
| 249 |
|
|---|
| 250 |
'SQL_USER_MSG' => ($rsql_user_max) ? |
|---|
| 251 |
tr('%1$d / %2$d of <b>%3$d</b>', $usql_user_current, $rsql_user_current, $rsql_user_max): |
|---|
| 252 |
tr('%1$d / %2$d of <b>unlimited</b>', $usql_user_current, $rsql_user_current), |
|---|
| 253 |
'EXTRAS' => '' |
|---|
| 254 |
|
|---|
| 255 |
) |
|---|
| 256 |
); |
|---|
| 257 |
} |
|---|
| 258 |
|
|---|
| 259 |
function gen_messages_table (&$tpl, $admin_id) { |
|---|
| 260 |
$sql = Database::getInstance(); |
|---|
| 261 |
|
|---|
| 262 |
$query = <<<SQL_QUERY |
|---|
| 263 |
select |
|---|
| 264 |
ticket_id |
|---|
| 265 |
from |
|---|
| 266 |
tickets |
|---|
| 267 |
where |
|---|
| 268 |
(ticket_from = ? or ticket_to = ?) |
|---|
| 269 |
and |
|---|
| 270 |
ticket_reply = '0' |
|---|
| 271 |
and |
|---|
| 272 |
(ticket_status = '1' or ticket_status = '4') |
|---|
| 273 |
SQL_QUERY; |
|---|
| 274 |
$res = exec_query($sql, $query, array($admin_id, $admin_id)); |
|---|
| 275 |
|
|---|
| 276 |
$questions = $res->RowCount(); |
|---|
| 277 |
|
|---|
| 278 |
if ($questions == 0) { |
|---|
| 279 |
$tpl->assign( |
|---|
| 280 |
array('TR_NO_NEW_MESSAGES' => tr('You have no new support questions!'), |
|---|
| 281 |
'MSG_ENTRY' => '' |
|---|
| 282 |
) |
|---|
| 283 |
); |
|---|
| 284 |
} else { |
|---|
| 285 |
$tpl->assign( |
|---|
| 286 |
array('TR_NEW_MSGS' => tr('You have <b>%d</b> new support questions', $questions), |
|---|
| 287 |
'NO_MESSAGES' => '', |
|---|
| 288 |
'TR_VIEW' => tr('View') |
|---|
| 289 |
) |
|---|
| 290 |
); |
|---|
| 291 |
|
|---|
| 292 |
$tpl->parse('MSG_ENTRY', '.msg_entry'); |
|---|
| 293 |
} |
|---|
| 294 |
} |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
$tpl->assign( |
|---|
| 298 |
array( |
|---|
| 299 |
'TR_RESELLER_MAIN_INDEX_PAGE_TITLE' => tr('ispCP - Reseller/Main Index'), |
|---|
| 300 |
'TR_SAVE' => tr('Save'), |
|---|
| 301 |
'TR_MESSAGES' => tr('Messages'), |
|---|
| 302 |
'TR_LANGUAGE' => tr('Language'), |
|---|
| 303 |
'TR_CHOOSE_DEFAULT_LANGUAGE' => tr('Choose default language'), |
|---|
| 304 |
'TR_CHOOSE_DEFAULT_LAYOUT' => tr('Choose default layout'), |
|---|
| 305 |
'TR_LAYOUT' => tr('Layout'), |
|---|
| 306 |
'TR_TRAFFIC_USAGE' => tr('Traffic usage'), |
|---|
| 307 |
'TR_DISK_USAGE' => tr ('Disk usage'), |
|---|
| 308 |
'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| 309 |
'THEME_CHARSET' => tr('encoding'), |
|---|
| 310 |
'ISP_LOGO' => get_logo($_SESSION['user_id']) |
|---|
| 311 |
) |
|---|
| 312 |
); |
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
generate_page_data($tpl, $_SESSION['user_id'], $_SESSION['user_logged']); |
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
if (!isset($_SESSION['logged_from']) && !isset($_SESSION['logged_from_id'])) { |
|---|
| 320 |
list($user_def_lang, $user_def_layout) = get_user_gui_props($sql, $_SESSION['user_id']); |
|---|
| 321 |
} else { |
|---|
| 322 |
$user_def_layout = $_SESSION['user_theme']; |
|---|
| 323 |
$user_def_lang = $_SESSION['user_def_lang']; |
|---|
| 324 |
} |
|---|
| 325 |
|
|---|
| 326 |
gen_messages_table($tpl, $_SESSION['user_id']); |
|---|
| 327 |
|
|---|
| 328 |
gen_logged_from($tpl); |
|---|
| 329 |
|
|---|
| 330 |
gen_def_language($tpl, $sql, $user_def_lang); |
|---|
| 331 |
|
|---|
| 332 |
gen_def_layout($tpl, $user_def_layout); |
|---|
| 333 |
|
|---|
| 334 |
gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_general_information.tpl'); |
|---|
| 335 |
gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_general_information.tpl'); |
|---|
| 336 |
|
|---|
| 337 |
gen_system_message($tpl, $sql); |
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
gen_page_message($tpl); |
|---|
| 342 |
|
|---|
| 343 |
$tpl->assign('LAYOUT', ''); |
|---|
| 344 |
$tpl->parse('PAGE', 'page'); |
|---|
| 345 |
$tpl->prnt(); |
|---|
| 346 |
|
|---|
| 347 |
if (Config::get('DUMP_GUI_DEBUG')) |
|---|
| 348 |
dump_gui_debug(); |
|---|
| 349 |
|
|---|
| 350 |
unset_messages(); |
|---|
| 351 |
|
|---|
| 352 |
?> |
|---|