| 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 |
|
|---|
| 27 |
$tpl->define_dynamic('page', Config::get('RESELLER_TEMPLATE_PATH') . '/domain_alias.tpl'); |
|---|
| 28 |
$tpl->define_dynamic('page_message', 'page'); |
|---|
| 29 |
$tpl->define_dynamic('logged_from', 'page'); |
|---|
| 30 |
$tpl->define_dynamic('table_list', 'page'); |
|---|
| 31 |
$tpl->define_dynamic('table_item', 'table_list'); |
|---|
| 32 |
$tpl->define_dynamic('scroll_prev', 'page'); |
|---|
| 33 |
$tpl->define_dynamic('scroll_next_gray', 'page'); |
|---|
| 34 |
$tpl->define_dynamic('scroll_next', 'page'); |
|---|
| 35 |
|
|---|
| 36 |
$theme_color = Config::get('USER_INITIAL_THEME'); |
|---|
| 37 |
|
|---|
| 38 |
$tpl->assign( |
|---|
| 39 |
array( |
|---|
| 40 |
'TR_ALIAS_PAGE_TITLE' => tr('ispCP - Manage Domain/Alias'), |
|---|
| 41 |
'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| 42 |
'THEME_CHARSET' => tr('encoding'), |
|---|
| 43 |
'ISP_LOGO' => get_logo($_SESSION['user_id']), |
|---|
| 44 |
) |
|---|
| 45 |
); |
|---|
| 46 |
|
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
|
|---|
| 52 |
|
|---|
| 53 |
gen_reseller_mainmenu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/main_menu_users_manage.tpl'); |
|---|
| 54 |
gen_reseller_menu($tpl, Config::get('RESELLER_TEMPLATE_PATH') . '/menu_users_manage.tpl'); |
|---|
| 55 |
|
|---|
| 56 |
gen_logged_from($tpl); |
|---|
| 57 |
|
|---|
| 58 |
$err_txt = "_off_"; |
|---|
| 59 |
|
|---|
| 60 |
generate_als_list($tpl, $_SESSION['user_id'], $err_txt); |
|---|
| 61 |
|
|---|
| 62 |
generate_als_messages($tpl, $err_txt); |
|---|
| 63 |
|
|---|
| 64 |
$tpl->assign( |
|---|
| 65 |
array( |
|---|
| 66 |
'TR_MANAGE_ALIAS' => tr('Manage alias'), |
|---|
| 67 |
'TR_NAME' => tr('Name'), |
|---|
| 68 |
'TR_REAL_DOMAIN' => tr('Real domain'), |
|---|
| 69 |
'TR_FORWARD' => tr('Forward'), |
|---|
| 70 |
'TR_STATUS' => tr('Status'), |
|---|
| 71 |
'TR_ACTION' => tr('Action'), |
|---|
| 72 |
'TR_ADD_ALIAS' => tr('Add alias'), |
|---|
| 73 |
'TR_MESSAGE_DELETE' => tr('Are you sure you want to delete %s?', true, '%s') |
|---|
| 74 |
) |
|---|
| 75 |
); |
|---|
| 76 |
|
|---|
| 77 |
$tpl->parse('PAGE', 'page'); |
|---|
| 78 |
|
|---|
| 79 |
$tpl->prnt(); |
|---|
| 80 |
|
|---|
| 81 |
if (Config::get('DUMP_GUI_DEBUG')) |
|---|
| 82 |
dump_gui_debug(); |
|---|
| 83 |
|
|---|
| 84 |
unset_messages(); |
|---|
| 85 |
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
function generate_als_list(&$tpl, $reseller_id, &$als_err) { |
|---|
| 90 |
$sql = Database::getInstance(); |
|---|
| 91 |
|
|---|
| 92 |
$have_aliases = '_no_'; |
|---|
| 93 |
|
|---|
| 94 |
$start_index = 0; |
|---|
| 95 |
|
|---|
| 96 |
$rows_per_page = Config::get('DOMAIN_ROWS_PER_PAGE'); |
|---|
| 97 |
|
|---|
| 98 |
$current_psi = 0; |
|---|
| 99 |
$_SESSION['search_for'] = ''; |
|---|
| 100 |
$search_common = ''; |
|---|
| 101 |
$search_for = ''; |
|---|
| 102 |
|
|---|
| 103 |
if (isset($_GET['psi'])) { |
|---|
| 104 |
$start_index = $_GET['psi']; |
|---|
| 105 |
$current_psi = $_GET['psi']; |
|---|
| 106 |
} |
|---|
| 107 |
|
|---|
| 108 |
if (isset($_POST['uaction']) && !empty($_POST['uaction'])) { |
|---|
| 109 |
$_SESSION['search_for'] = trim(clean_input($_POST['search_for'])); |
|---|
| 110 |
|
|---|
| 111 |
$_SESSION['search_common'] = $_POST['search_common']; |
|---|
| 112 |
|
|---|
| 113 |
$search_for = $_SESSION['search_for']; |
|---|
| 114 |
|
|---|
| 115 |
$search_common = $_SESSION['search_common']; |
|---|
| 116 |
} else { |
|---|
| 117 |
if (isset($_SESSION['search_for']) && !isset($_GET['psi'])) { |
|---|
| 118 |
unset($_SESSION['search_for']); |
|---|
| 119 |
|
|---|
| 120 |
unset($_SESSION['search_common']); |
|---|
| 121 |
} |
|---|
| 122 |
} |
|---|
| 123 |
$tpl->assign( |
|---|
| 124 |
array( |
|---|
| 125 |
'PSI' => $current_psi, |
|---|
| 126 |
'SEARCH_FOR' => stripslashes($search_for), |
|---|
| 127 |
'TR_SEARCH' => tr('Search'), |
|---|
| 128 |
'M_ALIAS_NAME' => tr('Alias name'), |
|---|
| 129 |
'M_ACCOUNT_NAME' => tr('Account name'), |
|---|
| 130 |
) |
|---|
| 131 |
); |
|---|
| 132 |
|
|---|
| 133 |
if (isset($_SESSION['search_for']) && $_SESSION['search_for'] != '') { |
|---|
| 134 |
if (isset($search_common) && $search_common == 'alias_name') { |
|---|
| 135 |
$query = <<<SQL_QUERY |
|---|
| 136 |
SELECT |
|---|
| 137 |
t1.*, |
|---|
| 138 |
t2.domain_id, |
|---|
| 139 |
t2.domain_name, |
|---|
| 140 |
t2.domain_created_id |
|---|
| 141 |
FROM |
|---|
| 142 |
domain_aliasses AS t1, |
|---|
| 143 |
domain AS t2 |
|---|
| 144 |
WHERE |
|---|
| 145 |
alias_name RLIKE '$search_for' |
|---|
| 146 |
AND |
|---|
| 147 |
t2.domain_created_id = ? |
|---|
| 148 |
AND |
|---|
| 149 |
t1.domain_id = t2.domain_id |
|---|
| 150 |
ORDER BY |
|---|
| 151 |
t1.alias_name ASC |
|---|
| 152 |
LIMIT |
|---|
| 153 |
$start_index, $rows_per_page |
|---|
| 154 |
SQL_QUERY; |
|---|
| 155 |
|
|---|
| 156 |
$count_query = <<<SQL_QUERY |
|---|
| 157 |
SELECT |
|---|
| 158 |
COUNT(alias_id) AS cnt |
|---|
| 159 |
FROM |
|---|
| 160 |
domain_aliasses AS t1, |
|---|
| 161 |
domain AS t2 |
|---|
| 162 |
WHERE |
|---|
| 163 |
t2.domain_created_id = ? |
|---|
| 164 |
AND |
|---|
| 165 |
alias_name RLIKE '$search_for' |
|---|
| 166 |
AND |
|---|
| 167 |
t1.domain_id = t2.domain_id |
|---|
| 168 |
SQL_QUERY; |
|---|
| 169 |
} else { |
|---|
| 170 |
$query = <<<SQL_QUERY |
|---|
| 171 |
SELECT |
|---|
| 172 |
t1.*, |
|---|
| 173 |
t2.domain_id, |
|---|
| 174 |
t2.domain_name, |
|---|
| 175 |
t2.domain_created_id |
|---|
| 176 |
FROM |
|---|
| 177 |
domain_aliasses AS t1, |
|---|
| 178 |
domain AS t2 |
|---|
| 179 |
WHERE |
|---|
| 180 |
t2.domain_name RLIKE '$search_for' |
|---|
| 181 |
AND |
|---|
| 182 |
t1.domain_id = t2.domain_id |
|---|
| 183 |
AND |
|---|
| 184 |
t2.domain_created_id = ? |
|---|
| 185 |
ORDER BY |
|---|
| 186 |
t1.alias_name ASC |
|---|
| 187 |
LIMIT |
|---|
| 188 |
$start_index, $rows_per_page |
|---|
| 189 |
SQL_QUERY; |
|---|
| 190 |
|
|---|
| 191 |
$count_query = <<<SQL_QUERY |
|---|
| 192 |
SELECT |
|---|
| 193 |
COUNT(alias_id) AS cnt |
|---|
| 194 |
FROM |
|---|
| 195 |
domain_aliasses AS t1, |
|---|
| 196 |
domain AS t2 |
|---|
| 197 |
WHERE |
|---|
| 198 |
t2.domain_created_id = ? |
|---|
| 199 |
AND |
|---|
| 200 |
t2.domain_name RLIKE '$search_for' |
|---|
| 201 |
AND |
|---|
| 202 |
t1.domain_id = t2.domain_id |
|---|
| 203 |
SQL_QUERY; |
|---|
| 204 |
} |
|---|
| 205 |
} else { |
|---|
| 206 |
$query = <<<SQL_QUERY |
|---|
| 207 |
SELECT |
|---|
| 208 |
t1.*, |
|---|
| 209 |
t2.domain_id, |
|---|
| 210 |
t2.domain_name, |
|---|
| 211 |
t2.domain_created_id |
|---|
| 212 |
FROM |
|---|
| 213 |
domain_aliasses AS t1, |
|---|
| 214 |
domain AS t2 |
|---|
| 215 |
WHERE |
|---|
| 216 |
t1.domain_id = t2.domain_id |
|---|
| 217 |
AND |
|---|
| 218 |
t2.domain_created_id = ? |
|---|
| 219 |
ORDER BY |
|---|
| 220 |
t1.alias_name ASC |
|---|
| 221 |
LIMIT |
|---|
| 222 |
$start_index, $rows_per_page |
|---|
| 223 |
SQL_QUERY; |
|---|
| 224 |
|
|---|
| 225 |
$count_query = <<<SQL_QUERY |
|---|
| 226 |
SELECT |
|---|
| 227 |
COUNT(alias_id) AS cnt |
|---|
| 228 |
FROM |
|---|
| 229 |
domain_aliasses AS t1, |
|---|
| 230 |
domain AS t2 |
|---|
| 231 |
WHERE |
|---|
| 232 |
t1.domain_id = t2.domain_id |
|---|
| 233 |
AND |
|---|
| 234 |
t2.domain_created_id = ? |
|---|
| 235 |
SQL_QUERY; |
|---|
| 236 |
} |
|---|
| 237 |
|
|---|
| 238 |
$rs = exec_query($sql, $count_query, array($reseller_id)); |
|---|
| 239 |
$records_count = $rs->fields['cnt']; |
|---|
| 240 |
|
|---|
| 241 |
$rs = exec_query($sql, $query, array($reseller_id)); |
|---|
| 242 |
|
|---|
| 243 |
if ($records_count == 0) { |
|---|
| 244 |
$tpl->assign( |
|---|
| 245 |
array( |
|---|
| 246 |
'TABLE_LIST' => '', |
|---|
| 247 |
'USERS_LIST' => '', |
|---|
| 248 |
'SCROLL_PREV' => '', |
|---|
| 249 |
'SCROLL_NEXT' => '', |
|---|
| 250 |
) |
|---|
| 251 |
); |
|---|
| 252 |
|
|---|
| 253 |
if (isset($_SESSION['search_for'])) { |
|---|
| 254 |
$als_err = tr('Not found user records matching the search criteria!'); |
|---|
| 255 |
} else { |
|---|
| 256 |
$als_err = tr('You have no alias records.'); |
|---|
| 257 |
} |
|---|
| 258 |
return; |
|---|
| 259 |
} else { |
|---|
| 260 |
$prev_si = $start_index - $rows_per_page; |
|---|
| 261 |
|
|---|
| 262 |
if ($start_index == 0) { |
|---|
| 263 |
$tpl->assign('SCROLL_PREV', ''); |
|---|
| 264 |
} else { |
|---|
| 265 |
$tpl->assign( |
|---|
| 266 |
array( |
|---|
| 267 |
'SCROLL_PREV_GRAY' => '', |
|---|
| 268 |
'PREV_PSI' => $prev_si |
|---|
| 269 |
) |
|---|
| 270 |
); |
|---|
| 271 |
} |
|---|
| 272 |
|
|---|
| 273 |
$next_si = $start_index + $rows_per_page; |
|---|
| 274 |
|
|---|
| 275 |
if ($next_si + 1 > $records_count) { |
|---|
| 276 |
$tpl->assign('SCROLL_NEXT', ''); |
|---|
| 277 |
} else { |
|---|
| 278 |
$tpl->assign( |
|---|
| 279 |
array( |
|---|
| 280 |
'SCROLL_NEXT_GRAY' => '', |
|---|
| 281 |
'NEXT_PSI' => $next_si |
|---|
| 282 |
) |
|---|
| 283 |
); |
|---|
| 284 |
} |
|---|
| 285 |
} |
|---|
| 286 |
|
|---|
| 287 |
$i = 1; |
|---|
| 288 |
|
|---|
| 289 |
while (!$rs->EOF) { |
|---|
| 290 |
$als_id = $rs->fields['alias_id']; |
|---|
| 291 |
$domain_id = $rs->fields['domain_id']; |
|---|
| 292 |
$als_name = $rs->fields['alias_name']; |
|---|
| 293 |
$als_mount_point = $rs->fields['alias_mount']; |
|---|
| 294 |
$als_status = $rs->fields['alias_status']; |
|---|
| 295 |
$als_ip_id = $rs->fields['alias_ip_id']; |
|---|
| 296 |
$als_fwd = $rs->fields['url_forward']; |
|---|
| 297 |
$show_als_fwd = ($als_fwd == 'no') ? "-" : $als_fwd; |
|---|
| 298 |
|
|---|
| 299 |
$domain_name = decode_idna($rs->fields['domain_name']); |
|---|
| 300 |
|
|---|
| 301 |
if ($als_mount_point == '') $als_mount_point = "/"; |
|---|
| 302 |
|
|---|
| 303 |
$query = "select ip_number, ip_domain from server_ips where ip_id = ?"; |
|---|
| 304 |
|
|---|
| 305 |
$alsip_r = exec_query($sql, $query, array($als_ip_id)); |
|---|
| 306 |
$alsip_d = $alsip_r->FetchRow(); |
|---|
| 307 |
|
|---|
| 308 |
$als_ip = $alsip_d['ip_number']; |
|---|
| 309 |
$als_ip_name = $alsip_d['ip_domain']; |
|---|
| 310 |
|
|---|
| 311 |
if ($i % 2 == 0) { |
|---|
| 312 |
$page_cont = 'content'; |
|---|
| 313 |
} else { |
|---|
| 314 |
$page_cont = 'content2'; |
|---|
| 315 |
} |
|---|
| 316 |
|
|---|
| 317 |
if ($als_status === Config::get('ITEM_OK_STATUS')) { |
|---|
| 318 |
$delete_link = "alias_delete.php?del_id=" . $als_id; |
|---|
| 319 |
$edit_link = "alias_edit.php?edit_id=" . $als_id; |
|---|
| 320 |
$action_text = tr("Delete"); |
|---|
| 321 |
$edit_text = tr("Edit"); |
|---|
| 322 |
} else if ($als_status === Config::get('ITEM_ORDERED_STATUS')){ |
|---|
| 323 |
$delete_link = "alias_order.php?action=delete&del_id=".$als_id; |
|---|
| 324 |
$edit_link = "alias_order.php?action=activate&act_id=".$als_id; |
|---|
| 325 |
$action_text = tr("Delete order"); |
|---|
| 326 |
$edit_text = tr("Activate"); |
|---|
| 327 |
} else { |
|---|
| 328 |
$delete_link = "#"; |
|---|
| 329 |
$edit_link = "#"; |
|---|
| 330 |
$action_text = tr('N/A'); |
|---|
| 331 |
$edit_text = tr('N/A'); |
|---|
| 332 |
} |
|---|
| 333 |
$als_status = translate_dmn_status($als_status); |
|---|
| 334 |
$als_name = decode_idna($als_name); |
|---|
| 335 |
$show_als_fwd = decode_idna($show_als_fwd); |
|---|
| 336 |
|
|---|
| 337 |
if (isset($_SESSION['search_common']) && $_SESSION['search_common'] === 'account_name') { |
|---|
| 338 |
$domain_name_selected = ""; |
|---|
| 339 |
$account_name_selected = "selected"; |
|---|
| 340 |
} else { |
|---|
| 341 |
$domain_name_selected = "selected"; |
|---|
| 342 |
$account_name_selected = ""; |
|---|
| 343 |
} |
|---|
| 344 |
|
|---|
| 345 |
$tpl->assign( |
|---|
| 346 |
array( |
|---|
| 347 |
'NAME' => $als_name, |
|---|
| 348 |
'ALIAS_IP' => "$als_ip ($als_ip_name)", |
|---|
| 349 |
'REAL_DOMAIN' => $domain_name, |
|---|
| 350 |
'REAL_DOMAIN_MOUNT' => $als_mount_point, |
|---|
| 351 |
'FORWARD' => $show_als_fwd, |
|---|
| 352 |
'STATUS' => $als_status, |
|---|
| 353 |
'ID' => $als_id, |
|---|
| 354 |
'DELETE' => $action_text, |
|---|
| 355 |
'CONTENT' => $page_cont, |
|---|
| 356 |
'DELETE_LINK' => $delete_link, |
|---|
| 357 |
'EDIT_LINK' => $edit_link, |
|---|
| 358 |
'EDIT' => $edit_text, |
|---|
| 359 |
'M_DOMAIN_NAME_SELECTED' => $domain_name_selected, |
|---|
| 360 |
'M_ACCOUN_NAME_SELECTED' => $account_name_selected, |
|---|
| 361 |
) |
|---|
| 362 |
); |
|---|
| 363 |
|
|---|
| 364 |
$i++; |
|---|
| 365 |
$tpl->parse('TABLE_ITEM', '.table_item'); |
|---|
| 366 |
$rs->MoveNext(); |
|---|
| 367 |
} |
|---|
| 368 |
} |
|---|
| 369 |
|
|---|
| 370 |
function generate_als_messages(&$tpl, $als_err) { |
|---|
| 371 |
if ($als_err != '_off_') { |
|---|
| 372 |
$tpl->assign( |
|---|
| 373 |
array('MESSAGE' => $als_err) |
|---|
| 374 |
); |
|---|
| 375 |
$tpl->parse('PAGE_MESSAGE', 'page_message'); |
|---|
| 376 |
return; |
|---|
| 377 |
} else if (isset($_SESSION["dahavemail"])) { |
|---|
| 378 |
$tpl->assign('MESSAGE', tr('Domain alias you are trying to remove has email accounts !<br>First remove them!')); |
|---|
| 379 |
unset($_SESSION['dahavemail']); |
|---|
| 380 |
} else if (isset($_SESSION["dahaveftp"])) { |
|---|
| 381 |
$tpl->assign('MESSAGE', tr('Domain alias you are trying to remove has FTP accounts!<br>First remove them!')); |
|---|
| 382 |
unset($_SESSION['dahavemail']); |
|---|
| 383 |
} else if (isset($_SESSION["aldel"])) { |
|---|
| 384 |
if ('_yes_' === $_SESSION['aldel']) |
|---|
| 385 |
$tpl->assign('MESSAGE', tr('Domain alias added for termination!')); |
|---|
| 386 |
else |
|---|
| 387 |
$tpl->assign('MESSAGE', tr('Domain alias not added for termination!')); |
|---|
| 388 |
|
|---|
| 389 |
unset($_SESSION['aldel']); |
|---|
| 390 |
} else if (isset($_SESSION['aladd'])) { |
|---|
| 391 |
if ('_yes_' === $_SESSION['aladd']) |
|---|
| 392 |
$tpl->assign('MESSAGE', tr('Domain alias added!')); |
|---|
| 393 |
else |
|---|
| 394 |
$tpl->assign('MESSAGE', tr('Domain alias not added!')); |
|---|
| 395 |
|
|---|
| 396 |
unset($_SESSION['aladd']); |
|---|
| 397 |
} else if (isset($_SESSION['aledit'])) { |
|---|
| 398 |
if ('_yes_' === $_SESSION['aledit']) |
|---|
| 399 |
$tpl->assign('MESSAGE', tr('Domain alias modified!')); |
|---|
| 400 |
else |
|---|
| 401 |
$tpl->assign('MESSAGE', tr('Domain alias not modified!')); |
|---|
| 402 |
|
|---|
| 403 |
unset($_SESSION['aledit']); |
|---|
| 404 |
} else if(isset($_SESSION['orderaldel'])){ |
|---|
| 405 |
if('_no_' === $_SESSION['orderaldel']) { |
|---|
| 406 |
$tpl -> assign('MESSAGE', tr('Ordered domain alias not deleted!')); |
|---|
| 407 |
} |
|---|
| 408 |
unset($_SESSION['orderaldel']); |
|---|
| 409 |
} else if(isset($_SESSION['orderalact'])){ |
|---|
| 410 |
if('_yes_' === $_SESSION['orderalact']) |
|---|
| 411 |
$tpl -> assign('MESSAGE', tr('Ordered domain alias activated!')); |
|---|
| 412 |
else |
|---|
| 413 |
$tpl -> assign('MESSAGE', tr('Ordered domain alias not activated!')); |
|---|
| 414 |
|
|---|
| 415 |
unset($_SESSION['orderalact']); |
|---|
| 416 |
} else { |
|---|
| 417 |
$tpl->assign('MESSAGE', ''); |
|---|
| 418 |
$tpl->assign('PAGE_MESSAGE', ""); |
|---|
| 419 |
} |
|---|
| 420 |
} |
|---|
| 421 |
|
|---|
| 422 |
?> |
|---|
| 423 |
|
|---|