| 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') . '/mail_autoresponder_enable.tpl'); |
|---|
| 27 |
$tpl->define_dynamic('page_message', 'page'); |
|---|
| 28 |
$tpl->define_dynamic('logged_from', 'page'); |
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
function check_email_user(&$sql) { |
|---|
| 33 |
$dmn_name = $_SESSION['user_logged']; |
|---|
| 34 |
$mail_id = $_GET['id']; |
|---|
| 35 |
|
|---|
| 36 |
$query = " |
|---|
| 37 |
select |
|---|
| 38 |
t1.*, |
|---|
| 39 |
t2.domain_id, |
|---|
| 40 |
t2.domain_name |
|---|
| 41 |
from |
|---|
| 42 |
mail_users as t1, |
|---|
| 43 |
domain as t2 |
|---|
| 44 |
where |
|---|
| 45 |
t1.mail_id = ? |
|---|
| 46 |
and |
|---|
| 47 |
t2.domain_id = t1.domain_id |
|---|
| 48 |
and |
|---|
| 49 |
t2.domain_name = ? |
|---|
| 50 |
"; |
|---|
| 51 |
|
|---|
| 52 |
$rs = exec_query($sql, $query, array($mail_id, $dmn_name)); |
|---|
| 53 |
|
|---|
| 54 |
if ($rs->RecordCount() == 0) { |
|---|
| 55 |
set_page_message(tr('User does not exist or you do not have permission to access this interface!')); |
|---|
| 56 |
header('Location: mail_accounts.php'); |
|---|
| 57 |
die(); |
|---|
| 58 |
} |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
function gen_page_dynamic_data(&$tpl, &$sql, $mail_id) { |
|---|
| 62 |
if (isset($_POST['uaction']) && $_POST['uaction'] === 'enable_arsp') { |
|---|
| 63 |
if (empty($_POST['arsp_message'])) { |
|---|
| 64 |
$tpl->assign('ARSP_MESSAGE', ''); |
|---|
| 65 |
set_page_message(tr('Please type your mail autorespond message!')); |
|---|
| 66 |
return; |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
$arsp_message = clean_input($_POST['arsp_message'], false); |
|---|
| 70 |
$item_change_status = Config::get('ITEM_CHANGE_STATUS'); |
|---|
| 71 |
check_for_lock_file(); |
|---|
| 72 |
|
|---|
| 73 |
$query = " |
|---|
| 74 |
update |
|---|
| 75 |
mail_users |
|---|
| 76 |
set |
|---|
| 77 |
status = ?, |
|---|
| 78 |
mail_auto_respond = 1, |
|---|
| 79 |
mail_auto_respond_text = ? |
|---|
| 80 |
where |
|---|
| 81 |
mail_id = ? |
|---|
| 82 |
"; |
|---|
| 83 |
|
|---|
| 84 |
$rs = exec_query($sql, $query, array($item_change_status, $arsp_message, $mail_id)); |
|---|
| 85 |
|
|---|
| 86 |
send_request(); |
|---|
| 87 |
$query = " |
|---|
| 88 |
SELECT |
|---|
| 89 |
`mail_type`, |
|---|
| 90 |
IF(`mail_type` like 'normal_%',t2.`domain_name`, |
|---|
| 91 |
IF(`mail_type` like 'alias_%',t3.`alias_name`, |
|---|
| 92 |
IF(`mail_type` like 'subdom_%',CONCAT(t4.`subdomain_name`,'.',t6.`domain_name`),CONCAT(t5.`subdomain_alias_name`,'.',t7.`alias_name`)) |
|---|
| 93 |
) |
|---|
| 94 |
) AS mailbox |
|---|
| 95 |
FROM |
|---|
| 96 |
`mail_users` as t1 |
|---|
| 97 |
LEFT JOIN (domain as t2) ON (t1.domain_id=t2.domain_id) |
|---|
| 98 |
LEFT JOIN (domain_aliasses as t3) ON (sub_id=alias_id) |
|---|
| 99 |
LEFT JOIN (subdomain as t4) ON (sub_id=subdomain_id) |
|---|
| 100 |
LEFT JOIN (subdomain_alias as t5) ON (sub_id=subdomain_alias_id) |
|---|
| 101 |
LEFT JOIN (domain as t6) ON (t4.domain_id=t6.domain_id) |
|---|
| 102 |
LEFT JOIN (domain_aliasses as t7) ON (t5.alias_id=t7.alias_id) |
|---|
| 103 |
WHERE |
|---|
| 104 |
`mail_id` = ? |
|---|
| 105 |
"; |
|---|
| 106 |
|
|---|
| 107 |
$rs = exec_query($sql, $query, array($mail_id)); |
|---|
| 108 |
$mail_name = $rs->fields['mailbox']; |
|---|
| 109 |
write_log($_SESSION['user_logged'] . ": add mail autoresponder: " . $mail_name); |
|---|
| 110 |
set_page_message(tr('Mail account scheduler for modification!')); |
|---|
| 111 |
header("Location: mail_accounts.php"); |
|---|
| 112 |
exit(0); |
|---|
| 113 |
} else { |
|---|
| 114 |
|
|---|
| 115 |
$query = " |
|---|
| 116 |
SELECT |
|---|
| 117 |
mail_auto_respond_text, mail_acc |
|---|
| 118 |
FROM |
|---|
| 119 |
mail_users |
|---|
| 120 |
WHERE |
|---|
| 121 |
mail_id = ? |
|---|
| 122 |
"; |
|---|
| 123 |
|
|---|
| 124 |
$rs = exec_query($sql, $query, array($mail_id)); |
|---|
| 125 |
$mail_name = $rs->fields['mail_acc']; |
|---|
| 126 |
|
|---|
| 127 |
$tpl->assign('ARSP_MESSAGE', $rs->fields['mail_auto_respond_text']); |
|---|
| 128 |
return; |
|---|
| 129 |
} |
|---|
| 130 |
} |
|---|
| 131 |
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 |
if (isset($_GET['id'])) { |
|---|
| 135 |
$mail_id = $_GET['id']; |
|---|
| 136 |
} else if (isset($_POST['id'])) { |
|---|
| 137 |
$mail_id = $_POST['id']; |
|---|
| 138 |
} else { |
|---|
| 139 |
header("Location: mail_accounts.php"); |
|---|
| 140 |
exit(0); |
|---|
| 141 |
} |
|---|
| 142 |
|
|---|
| 143 |
if (isset($_SESSION['email_support']) && $_SESSION['email_support'] == "no") { |
|---|
| 144 |
header("Location: index.php"); |
|---|
| 145 |
} |
|---|
| 146 |
|
|---|
| 147 |
$theme_color = Config::get('USER_INITIAL_THEME'); |
|---|
| 148 |
|
|---|
| 149 |
$tpl->assign( |
|---|
| 150 |
array( |
|---|
| 151 |
'TR_CLIENT_ENABLE_AUTORESPOND_PAGE_TITLE' => tr('ispCP - Client/Enable Mail Auto Responder'), |
|---|
| 152 |
'THEME_COLOR_PATH' => "../themes/$theme_color", |
|---|
| 153 |
'THEME_CHARSET' => tr('encoding'), |
|---|
| 154 |
'ISP_LOGO' => get_logo($_SESSION['user_id']) |
|---|
| 155 |
) |
|---|
| 156 |
); |
|---|
| 157 |
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 |
check_email_user($sql); |
|---|
| 161 |
gen_page_dynamic_data($tpl, $sql, $mail_id); |
|---|
| 162 |
|
|---|
| 163 |
|
|---|
| 164 |
|
|---|
| 165 |
gen_client_mainmenu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/main_menu_email_accounts.tpl'); |
|---|
| 166 |
gen_client_menu($tpl, Config::get('CLIENT_TEMPLATE_PATH') . '/menu_email_accounts.tpl'); |
|---|
| 167 |
|
|---|
| 168 |
gen_logged_from($tpl); |
|---|
| 169 |
|
|---|
| 170 |
check_permissions($tpl); |
|---|
| 171 |
|
|---|
| 172 |
$tpl->assign( |
|---|
| 173 |
array( |
|---|
| 174 |
'TR_ENABLE_MAIL_AUTORESPONDER' => tr('Enable mail auto responder'), |
|---|
| 175 |
'TR_ARSP_MESSAGE' => tr('Your message'), |
|---|
| 176 |
'TR_ENABLE' => tr('Save'), |
|---|
| 177 |
'TR_CANCEL' => tr('Cancel'), |
|---|
| 178 |
'ID' => $mail_id |
|---|
| 179 |
) |
|---|
| 180 |
); |
|---|
| 181 |
gen_page_message($tpl); |
|---|
| 182 |
|
|---|
| 183 |
$tpl->parse('PAGE', 'page'); |
|---|
| 184 |
$tpl->prnt(); |
|---|
| 185 |
|
|---|
| 186 |
if (Config::get('DUMP_GUI_DEBUG')) |
|---|
| 187 |
dump_gui_debug(); |
|---|
| 188 |
|
|---|
| 189 |
unset_messages(); |
|---|
| 190 |
|
|---|
| 191 |
?> |
|---|