| 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('CLIENT_TEMPLATE_PATH') . '/hosting_plan_update.tpl'); |
|---|
| 27 |
$tpl->define_dynamic('page_message', 'page'); |
|---|
| 28 |
$tpl->define_dynamic('def_language', 'page'); |
|---|
| 29 |
$tpl->define_dynamic('logged_from', 'page'); |
|---|
| 30 |
$tpl->define_dynamic('hosting_plans', 'page'); |
|---|
| 31 |
$tpl->define_dynamic('hp_order', 'page'); |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 |
|
|---|
| 39 |
function gen_hp(&$tpl, &$sql, $user_id) { |
|---|
| 40 |
$availabe_order = 0; |
|---|
| 41 |
$hp_title = tr('Hosting plans available for update'); |
|---|
| 42 |
|
|---|
| 43 |
$query = <<<SQL_QUERY |
|---|
| 44 |
select |
|---|
| 45 |
* |
|---|
| 46 |
from |
|---|
| 47 |
orders |
|---|
| 48 |
where |
|---|
| 49 |
customer_id=? |
|---|
| 50 |
and |
|---|
| 51 |
status<>? |
|---|
| 52 |
SQL_QUERY; |
|---|
| 53 |
$rs = exec_query($sql, $query, array($user_id, 'added')); |
|---|
| 54 |
|
|---|
| 55 |
if ($rs->RecordCount() > 0) { |
|---|
| 56 |
$availabe_order = 1; |
|---|
| 57 |
$availabe_hp_id = $rs->fields['plan_id']; |
|---|
| 58 |
|
|---|
| 59 |
$query = <<<SQL_QUERY |
|---|
| 60 |
select |
|---|
| 61 |
* |
|---|
| 62 |
from |
|---|
| 63 |
hosting_plans |
|---|
| 64 |
where |
|---|
| 65 |
id=? |
|---|
| 66 |
SQL_QUERY; |
|---|
| 67 |
|
|---|
| 68 |
$rs = exec_query($sql, $query, array($availabe_hp_id)); |
|---|
| 69 |
$count = 2; |
|---|
| 70 |
$purchase_text = tr('Cancel order'); |
|---|
| 71 |
$purchase_link = 'delete_id'; |
|---|
| 72 |
$hp_title = tr('Your order'); |
|---|
| 73 |
} else { |
|---|
| 74 |
|
|---|
| 75 |
if (Config::exists('HOSTING_PLANS_LEVEL') && Config::get('HOSTING_PLANS_LEVEL') === 'admin') { |
|---|
| 76 |
$query = <<<SQL_QUERY |
|---|
| 77 |
SELECT |
|---|
| 78 |
t1.*, |
|---|
| 79 |
t2.admin_id, t2.admin_type |
|---|
| 80 |
FROM |
|---|
| 81 |
hosting_plans as t1, |
|---|
| 82 |
admin as t2 |
|---|
| 83 |
WHERE |
|---|
| 84 |
t2.admin_type = ? |
|---|
| 85 |
AND |
|---|
| 86 |
t1.reseller_id = t2.admin_id |
|---|
| 87 |
AND |
|---|
| 88 |
t1.status=1 |
|---|
| 89 |
ORDER BY |
|---|
| 90 |
t1.name |
|---|
| 91 |
SQL_QUERY; |
|---|
| 92 |
|
|---|
| 93 |
$rs = exec_query($sql, $query, array('admin')); |
|---|
| 94 |
|
|---|
| 95 |
$count = $rs->RecordCount(); |
|---|
| 96 |
$count++; |
|---|
| 97 |
} else { |
|---|
| 98 |
$query = <<<SQL_QUERY |
|---|
| 99 |
SELECT |
|---|
| 100 |
* |
|---|
| 101 |
FROM |
|---|
| 102 |
hosting_plans |
|---|
| 103 |
WHERE |
|---|
| 104 |
reseller_id = ? |
|---|
| 105 |
AND |
|---|
| 106 |
status='1' |
|---|
| 107 |
SQL_QUERY; |
|---|
| 108 |
|
|---|
| 109 |
$count_query = <<<SQL_QUERY |
|---|
| 110 |
SELECT |
|---|
| 111 |
COUNT(id) AS cnum |
|---|
| 112 |
FROM |
|---|
| 113 |
hosting_plans |
|---|
| 114 |
WHERE |
|---|
| 115 |
reseller_id = ? |
|---|
| 116 |
AND |
|---|
| 117 |
status='1' |
|---|
| 118 |
SQL_QUERY; |
|---|
| 119 |
|
|---|
| 120 |
$cnt = exec_query($sql, $count_query, array($_SESSION['user_created_by'])); |
|---|
| 121 |
$rs = exec_query($sql, $query, array($_SESSION['user_created_by'])); |
|---|
| 122 |
$count = $cnt->fields['cnum'] + 1; |
|---|
| 123 |
} |
|---|
| 124 |
|
|---|
| 125 |
$purchase_text = tr('Purchase'); |
|---|
| 126 |
$purchase_link = 'order_id'; |
|---|
| 127 |
} |
|---|
| 128 |
|
|---|
| 129 |
if ($rs->RecordCount() == 0) { |
|---|
| 130 |
$tpl->assign( |
|---|
| 131 |
array( |
|---|
| 132 |
'TR_HOSTING_PLANS' => $hp_title, |
|---|
| 133 |
'HOSTING_PLANS' => '', |
|---|
| 134 |
'HP_ORDER' => '', |
|---|
| 135 |
'COLSPAN' => 2 |
|---|
| 136 |
) |
|---|
| 137 |
); |
|---|
| 138 |
|
|---|
| 139 |
set_page_message(tr('There are no available updates')); |
|---|
| 140 |
return; |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
$tpl->assign('COLSPAN', $count); |
|---|
| 144 |
$i = 0; |
|---|
| 145 |
while (!$rs->EOF) { |
|---|
| 146 |
list($hp_php, $hp_cgi, $hp_sub, $hp_als, $hp_mail, $hp_ftp, $hp_sql_db, $hp_sql_user, $hp_traff, $hp_disk) = explode(";", $rs->fields['props']); |
|---|
| 147 |
|
|---|
| 148 |
$details = ''; |
|---|
| 149 |
|
|---|
| 150 |
if ($hp_php === '_yes_') { |
|---|
| 151 |
$details = tr('PHP Support: enabled') . "<br>"; |
|---|
| 152 |
$php = "yes"; |
|---|
| 153 |
} else { |
|---|
| 154 |
$details = tr('PHP Support: disabled') . "<br>"; |
|---|
| 155 |
$php = "no"; |
|---|
| 156 |
} |
|---|
| 157 |
if ($hp_cgi === '_yes_') { |
|---|
| 158 |
$cgi = "yes"; |
|---|
| 159 |
$details .= tr('CGI Support: enabled') . "<br>"; |
|---|
| 160 |
} else { |
|---|
| 161 |
$cgi = "no"; |
|---|
| 162 |
$details .= tr('CGI Support: disabled') . "<br>"; |
|---|
| 163 |
} |
|---|
| 164 |
$hdd_usage = tr('Disk limit') . ": " . translate_limit_value($hp_disk, true) . "<br>"; |
|---|
| 165 |
|
|---|
| 166 |
$traffic_usage = tr('Traffic limit') . ": " . translate_limit_value($hp_traff, true); |
|---|
| 167 |
|
|---|
| 168 |
$details .= tr('Aliases') . ": " . translate_limit_value($hp_als) . "<br>"; |
|---|
| 169 |
$details .= tr('Subdomains') . ": " . translate_limit_value($hp_sub) . "<br>"; |
|---|
| 170 |
$details .= tr('Emails') . ": " . translate_limit_value($hp_mail) . "<br>"; |
|---|
| 171 |
$details .= tr('FTPs') . ": " . translate_limit_value($hp_ftp) . "<br>"; |
|---|
| 172 |
$details .= tr('SQL Databases') . ": " . translate_limit_value($hp_sql_db) . "<br>"; |
|---|
| 173 |
$details .= tr('SQL Users') . ": " . translate_limit_value($hp_sql_user) . "<br>"; |
|---|
| 174 |
$details .= $hdd_usage . $traffic_usage; |
|---|
| 175 |
|
|---|
| 176 |
$price = $rs->fields['price']; |
|---|
| 177 |
if ($price == 0 || $price == '') { |
|---|
| 178 |
$price = tr('free of charge'); |
|---|
| 179 |
} else { |
|---|
| 180 |
$price = $price . " " . $rs->fields['value'] . " " . $rs->fields['payment']; |
|---|
| 181 |
} |
|---|
| 182 |
|
|---|
| 183 |
$check_query = <<<SQL_QUERY |
|---|
| 184 |
select |
|---|
| 185 |
domain_id |
|---|
| 186 |
from |
|---|
| 187 |
domain |
|---|
| 188 |
where |
|---|
| 189 |
domain_admin_id=? |
|---|
| 190 |
and |
|---|
| 191 |
domain_mailacc_limit=? |
|---|
| 192 |
and |
|---|
| 193 |
domain_ftpacc_limit=? |
|---|
| 194 |
and |
|---|
| 195 |
domain_traffic_limit=? |
|---|
| 196 |
and |
|---|
| 197 |
domain_sqld_limit=? |
|---|
| 198 |
and |
|---|
| 199 |
domain_sqlu_limit=? |
|---|
| 200 |
and |
|---|
| 201 |
domain_alias_limit=? |
|---|
| 202 |
and |
|---|
| 203 |
domain_subd_limit=? |
|---|
| 204 |
and |
|---|
| 205 |
domain_disk_limit=? |
|---|
| 206 |
and |
|---|
| 207 |
domain_php=? |
|---|
| 208 |
and |
|---|
| 209 |
domain_cgi=? |
|---|
| 210 |
|
|---|
| 211 |
SQL_QUERY; |
|---|
| 212 |
$check = exec_query($sql, $check_query, array($_SESSION['user_id'], $hp_mail, $hp_ftp, $hp_traff, $hp_sql_db, $hp_sql_user, $hp_als, $hp_sub, $hp_disk, $php, $cgi)); |
|---|
| 213 |
if ($check->RecordCount() == 0) { |
|---|
| 214 |
$tpl->assign( |
|---|
| 215 |
array( |
|---|
| 216 |
'HP_NAME' => stripslashes($rs->fields['name']), |
|---|
| 217 |
'HP_DESCRIPTION' => stripslashes($rs->fields['description']), |
|---|
| 218 |
'HP_DETAILS' => stripslashes($details), |
|---|
| 219 |
'HP_COSTS' => $price, |
|---|
| 220 |
'ID' => $rs->fields['id'], |
|---|
| 221 |
'TR_PURCHASE' => $purchase_text, |
|---|
| 222 |
'LINK' => $purchase_link, |
|---|
| 223 |
'TR_HOSTING_PLANS' => $hp_title, |
|---|
| 224 |
'ITHEM' => ($i % 2 == 0) ? 'content' : 'content2' |
|---|
| 225 |
) |
|---|
| 226 |
); |
|---|
| 227 |
|
|---|
| 228 |
$tpl->parse('HOSTING_PLANS', '.hosting_plans'); |
|---|
| 229 |
$tpl->parse('HP_ORDER', '.hp_order'); |
|---|
| 230 |
$i++; |
|---|
| 231 |
} |
|---|
| 232 |
|
|---|
| 233 |
$rs->MoveNext(); |
|---|
| 234 |
} |
|---|
| 235 |
if ($i == 0) { |
|---|
| 236 |
$tpl->assign( |
|---|
| 237 |
array( |
|---|
| 238 |
'HOSTING_PLANS' => '', |
|---|
| 239 |
'HP_ORDER' => '', |
|---|
| 240 |
'TR_HOSTING_PLANS' => $hp_title, |
|---|
| 241 |
'COLSPAN' => '2' |
|---|
| 242 |
) |
|---|
| 243 |
); |
|---|
| 244 |
|
|---|
| 245 |
set_page_message(tr('There are no available hosting plans for update')); |
|---|
| 246 |
} |
|---|
| 247 |
} |
|---|
| 248 |
|
|---|
| 249 |
$theme_color = Config::get('USER_INITIAL_THEME'); |
|---|
| 250 |
$tpl->assign( |
|---|
| 251 |
array( |
|---|
| 252 |
'TR_CLIENT_UPDATE_HP' => tr('ispCP - Update hosting plan'), |
|---|
| 253 |
'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| 254 |
'THEME_CHARSET' => tr('encoding'), |
|---|
| 255 |
'ISP_LOGO' => get_logo($_SESSION['user_id']) |
|---|
| 256 |
) |
|---|
| 257 |
); |
|---|
| 258 |
|
|---|
| 259 |
function add_new_order(&$tpl, &$sql, $order_id, $user_id) { |
|---|
| 260 |
$date = time(); |
|---|
| 261 |
$status = "update"; |
|---|
| 262 |
$query = <<<SQL_QUERY |
|---|
| 263 |
INSERT INTO orders |
|---|
| 264 |
(user_id, |
|---|
| 265 |
plan_id, |
|---|
| 266 |
date, |
|---|
| 267 |
domain_name, |
|---|
| 268 |
customer_id, |
|---|
| 269 |
fname, |
|---|
| 270 |
lname, |
|---|
| 271 |
firm, |
|---|
| 272 |
zip, |
|---|
| 273 |
city, |
|---|
| 274 |
country, |
|---|
| 275 |
email, |
|---|
| 276 |
phone, |
|---|
| 277 |
fax, |
|---|
| 278 |
street1, |
|---|
| 279 |
street2, |
|---|
| 280 |
status) |
|---|
| 281 |
VALUES |
|---|
| 282 |
(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) |
|---|
| 283 |
SQL_QUERY; |
|---|
| 284 |
|
|---|
| 285 |
$rs = exec_query($sql, $query, array($_SESSION['user_created_by'], $order_id, $date, $_SESSION['user_logged'], |
|---|
| 286 |
$user_id, '', '', '', '', '', '', '', '', '', '', '', $status)); |
|---|
| 287 |
set_page_message(tr('Your request for hosting pack update was added successfully')); |
|---|
| 288 |
|
|---|
| 289 |
$query = <<<SQL_QUERY |
|---|
| 290 |
SELECT |
|---|
| 291 |
t1.email AS reseller_mail, |
|---|
| 292 |
t2.email AS user_mail |
|---|
| 293 |
FROM |
|---|
| 294 |
admin AS t1, |
|---|
| 295 |
admin AS t2 |
|---|
| 296 |
WHERE |
|---|
| 297 |
t1.admin_id = ? |
|---|
| 298 |
AND |
|---|
| 299 |
t2.admin_id = ? |
|---|
| 300 |
SQL_QUERY; |
|---|
| 301 |
|
|---|
| 302 |
$rs = exec_query($sql, $query, array($_SESSION['user_created_by'], $_SESSION['user_id'])); |
|---|
| 303 |
|
|---|
| 304 |
$to = $rs->fields['reseller_mail']; |
|---|
| 305 |
$from = $rs->fields['user_mail']; |
|---|
| 306 |
|
|---|
| 307 |
$headers = "From: " . $from . "\n"; |
|---|
| 308 |
$headers .= "MIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 7bit\n"; |
|---|
| 309 |
$headers .= "X-Mailer: ispCP auto mailer"; |
|---|
| 310 |
|
|---|
| 311 |
$subject = tr("[ispCP OrderPanel] - You have an update order"); |
|---|
| 312 |
|
|---|
| 313 |
$message = tr('You have an update order for the account {ACCOUNT} |
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
Please login into your ispCP control panel for more details'); |
|---|
| 317 |
|
|---|
| 318 |
$message = str_replace('{ACCOUNT}', $_SESSION['user_logged'], $message); |
|---|
| 319 |
|
|---|
| 320 |
$mail_result = mail($to, $subject, $message, $headers); |
|---|
| 321 |
} |
|---|
| 322 |
|
|---|
| 323 |
function del_order(&$tpl, &$sql, $order_id, $user_id) { |
|---|
| 324 |
$query = <<<SQL_QUERY |
|---|
| 325 |
delete from |
|---|
| 326 |
orders |
|---|
| 327 |
where |
|---|
| 328 |
user_id=? |
|---|
| 329 |
and |
|---|
| 330 |
customer_id = ? |
|---|
| 331 |
SQL_QUERY; |
|---|
| 332 |
|
|---|
| 333 |
$rs = exec_query($sql, $query, array($_SESSION['user_created_by'], $user_id)); |
|---|
| 334 |
set_page_message(tr('Your request for hosting pack update was removed successfully')); |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
|
|---|
| 343 |
if (isset($_GET['delete_id']) && is_numeric($_GET['delete_id'])) { |
|---|
| 344 |
del_order($tpl, $sql, $_GET['delete_id'], $_SESSION['user_id']); |
|---|
| 345 |
} |
|---|
| 346 |
|
|---|
| 347 |
if (isset($_GET['order_id']) && is_numeric($_GET['order_id'])) { |
|---|
| 348 |
add_new_order($tpl, $sql, $_GET['order_id'], $_SESSION['user_id']); |
|---|
| 349 |
} |
|---|
| 350 |
|
|---|
| 351 |
gen_hp($tpl, $sql, $_SESSION['user_id']); |
|---|
| 352 |
|
|---|
| 353 |
gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_general_information.tpl'); |
|---|
| 354 |
gen_client_menu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/menu_general_information.tpl'); |
|---|
| 355 |
|
|---|
| 356 |
gen_logged_from($tpl); |
|---|
| 357 |
|
|---|
| 358 |
check_permissions($tpl); |
|---|
| 359 |
|
|---|
| 360 |
$tpl->assign( |
|---|
| 361 |
array( |
|---|
| 362 |
'TR_LANGUAGE' => tr('Language'), |
|---|
| 363 |
'TR_SAVE' => tr('Save'), |
|---|
| 364 |
) |
|---|
| 365 |
); |
|---|
| 366 |
|
|---|
| 367 |
gen_page_message($tpl); |
|---|
| 368 |
|
|---|
| 369 |
$tpl->parse('PAGE', 'page'); |
|---|
| 370 |
|
|---|
| 371 |
$tpl->prnt(); |
|---|
| 372 |
|
|---|
| 373 |
if (Config::get('DUMP_GUI_DEBUG')) dump_gui_debug(); |
|---|
| 374 |
|
|---|
| 375 |
unset_messages(); |
|---|
| 376 |
|
|---|
| 377 |
?> |
|---|