2010-01-20 16:55:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2010-01-25 10:06:34 +00:00
|
|
|
* This file is part of the Froxlor project.
|
2010-01-20 16:55:27 +00:00
|
|
|
* Copyright (c) 2003-2009 the SysCP Team (see authors).
|
2010-01-25 10:06:34 +00:00
|
|
|
* Copyright (c) 2010 the Froxlor Team (see authors).
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the COPYING
|
|
|
|
* file that was distributed with this source code. You can also view the
|
2010-01-25 10:06:34 +00:00
|
|
|
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
|
2010-01-20 16:55:27 +00:00
|
|
|
*
|
|
|
|
* @copyright (c) the authors
|
2010-01-25 10:06:34 +00:00
|
|
|
* @author Florian Lippert <flo@syscp.org> (2003-2009)
|
|
|
|
* @author Froxlor team <team@froxlor.org> (2010-)
|
|
|
|
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
|
2010-01-20 16:55:27 +00:00
|
|
|
* @package Panel
|
2011-05-04 09:59:20 +00:00
|
|
|
*
|
2010-01-20 16:55:27 +00:00
|
|
|
*/
|
|
|
|
define('AREA', 'customer');
|
2013-11-18 11:53:33 +00:00
|
|
|
require './lib/init.php';
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2018-12-19 15:57:03 +00:00
|
|
|
use Froxlor\Database\Database;
|
|
|
|
use Froxlor\Settings;
|
2018-12-18 12:45:05 +00:00
|
|
|
use Froxlor\Api\Commands\Emails as Emails;
|
|
|
|
use Froxlor\Api\Commands\EmailAccounts as EmailAccounts;
|
|
|
|
use Froxlor\Api\Commands\EmailForwarders as EmailForwarders;
|
|
|
|
|
2016-07-27 11:45:54 +00:00
|
|
|
// redirect if this customer page is hidden via settings
|
2018-12-21 11:24:07 +00:00
|
|
|
if (Settings::IsInList('panel.customer_hide_options', 'email')) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo('customer_index.php');
|
2016-07-27 11:45:54 +00:00
|
|
|
}
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($_POST['id'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$id = intval($_POST['id']);
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif (isset($_GET['id'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$id = intval($_GET['id']);
|
|
|
|
}
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if ($page == 'overview') {
|
2018-12-26 14:51:26 +00:00
|
|
|
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email");
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/email") . "\";");
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($page == 'emails') {
|
|
|
|
if ($action == '') {
|
2018-12-26 14:51:26 +00:00
|
|
|
$log->logAction(\Froxlor\FroxlorLogger::USR_ACTION, LOG_NOTICE, "viewed customer_email::emails");
|
2010-01-20 16:55:27 +00:00
|
|
|
$fields = array(
|
2020-02-29 08:50:29 +00:00
|
|
|
'd.domain_ace' => $lng['domains']['domainname'],
|
2018-12-22 07:15:31 +00:00
|
|
|
'm.email_full' => $lng['emails']['emailaddress'],
|
|
|
|
'm.destination' => $lng['emails']['forwarders']
|
2010-01-20 16:55:27 +00:00
|
|
|
);
|
2019-11-10 17:35:32 +00:00
|
|
|
try {
|
|
|
|
// get total count
|
|
|
|
$json_result = Emails::getLocal($userinfo)->listingCount();
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
// initialize pagination and filtering
|
|
|
|
$paging = new \Froxlor\UI\Pagination($userinfo, $fields, $result);
|
|
|
|
// get list
|
|
|
|
$json_result = Emails::getLocal($userinfo, $paging->getApiCommandParams())->listing();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$sortcode = $paging->getHtmlSortCode($lng);
|
|
|
|
$arrowcode = $paging->getHtmlArrowCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$searchcode = $paging->getHtmlSearchCode($lng);
|
|
|
|
$pagingcode = $paging->getHtmlPagingCode($filename . '?page=' . $page . '&s=' . $s);
|
|
|
|
$emails = array();
|
2019-11-10 17:35:32 +00:00
|
|
|
$emailscount = $paging->getEntries();
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
foreach ($result['list'] as $row) {
|
2018-12-21 11:24:07 +00:00
|
|
|
if (! isset($emails[$row['domain']]) || ! is_array($emails[$row['domain']])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$emails[$row['domain']] = array();
|
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2010-01-20 16:55:27 +00:00
|
|
|
$emails[$row['domain']][$row['email_full']] = $row;
|
|
|
|
}
|
|
|
|
|
2020-02-29 08:50:29 +00:00
|
|
|
if ($paging->sortfield == 'd.domain_ace' && $paging->sortorder == 'desc') {
|
2010-01-20 16:55:27 +00:00
|
|
|
krsort($emails);
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
ksort($emails);
|
|
|
|
}
|
|
|
|
|
|
|
|
$count = 0;
|
|
|
|
$accounts = '';
|
|
|
|
$emails_count = 0;
|
|
|
|
$domainname = '';
|
2013-11-17 20:40:50 +00:00
|
|
|
foreach ($emails as $domainid => $emailaddresses) {
|
|
|
|
if ($paging->sortfield == 'm.email_full' && $paging->sortorder == 'desc') {
|
2010-01-20 16:55:27 +00:00
|
|
|
krsort($emailaddresses);
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
ksort($emailaddresses);
|
|
|
|
}
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
foreach ($emailaddresses as $row) {
|
2019-11-10 17:35:32 +00:00
|
|
|
if ($domainname != $idna_convert->decode($row['domain'])) {
|
|
|
|
$domainname = $idna_convert->decode($row['domain']);
|
|
|
|
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_domain") . "\";");
|
|
|
|
}
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
$emails_count ++;
|
|
|
|
$row['email'] = $idna_convert->decode($row['email']);
|
|
|
|
$row['email_full'] = $idna_convert->decode($row['email_full']);
|
|
|
|
$row['destination'] = explode(' ', $row['destination']);
|
|
|
|
uasort($row['destination'], 'strcasecmp');
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
$dest_list = $row['destination'];
|
|
|
|
foreach ($dest_list as $dest_id => $destination) {
|
|
|
|
$row['destination'][$dest_id] = $idna_convert->decode($row['destination'][$dest_id]);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
if ($row['destination'][$dest_id] == $row['email_full']) {
|
|
|
|
unset($row['destination'][$dest_id]);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2019-11-10 17:35:32 +00:00
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
$destinations_count = count($row['destination']);
|
|
|
|
$row['destination'] = implode(', ', $row['destination']);
|
2010-01-20 16:55:27 +00:00
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
if (strlen($row['destination']) > 35) {
|
|
|
|
$row['destination'] = substr($row['destination'], 0, 32) . '... (' . $destinations_count . ')';
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2019-11-10 17:35:32 +00:00
|
|
|
$row['mboxsize'] = \Froxlor\PhpHelper::sizeReadable($row['mboxsize'], 'GiB', 'bi', '%01.' . (int) Settings::Get('panel.decimal_places') . 'f %s');
|
|
|
|
|
|
|
|
$row = \Froxlor\PhpHelper::htmlentitiesArray($row);
|
|
|
|
eval("\$accounts.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_email") . "\";");
|
|
|
|
$count ++;
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-15 06:25:23 +00:00
|
|
|
$result_stmt = Database::prepare("
|
|
|
|
SELECT COUNT(`id`) as emaildomains
|
|
|
|
FROM `" . TABLE_PANEL_DOMAINS . "`
|
|
|
|
WHERE `customerid`= :cid AND `isemaildomain` = '1'
|
|
|
|
");
|
2020-07-29 06:46:50 +00:00
|
|
|
$result2 = Database::pexecute_first($result_stmt, array(
|
2020-02-15 06:25:23 +00:00
|
|
|
"cid" => $userinfo['customerid']
|
|
|
|
));
|
2020-07-29 06:46:50 +00:00
|
|
|
$emaildomains_count = $result2['emaildomains'];
|
2010-05-04 06:43:23 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails") . "\";");
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-03-08 10:49:28 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-03-08 10:49:28 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-08 10:49:28 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['email']) && $result['email'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-08 10:49:28 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
Emails::getLocal($userinfo, array(
|
2020-11-12 07:54:52 +00:00
|
|
|
'id' => $id,
|
|
|
|
'delete_userfiles' => ($_POST['delete_userfiles'] ?? 0)
|
2018-03-08 10:49:28 +00:00
|
|
|
))->delete();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-06-02 05:57:44 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => $page,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2013-11-30 15:40:27 +00:00
|
|
|
if ($result['popaccountid'] != '0') {
|
2010-07-24 17:26:24 +00:00
|
|
|
$show_checkbox = true;
|
|
|
|
} else {
|
|
|
|
$show_checkbox = false;
|
|
|
|
}
|
2018-12-24 12:50:45 +00:00
|
|
|
\Froxlor\UI\HTML::askYesNoWithCheckbox('email_reallydelete', 'admin_customer_alsoremovemail', $filename, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
), $idna_convert->decode($result['email_full']), $show_checkbox);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'add') {
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['emails_used'] < $userinfo['emails'] || $userinfo['emails'] == '-1') {
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-06 13:02:27 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, $_POST)->add();
|
2018-03-06 13:02:27 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-03-06 13:02:27 +00:00
|
|
|
$result = json_decode($json_result, true)['data'];
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => $page,
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $result['id'],
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
|
|
|
$result_stmt = Database::prepare("SELECT `id`, `domain`, `customerid` FROM `" . TABLE_PANEL_DOMAINS . "`
|
|
|
|
WHERE `customerid`= :cid
|
|
|
|
AND `isemaildomain`='1'
|
2020-02-29 08:50:29 +00:00
|
|
|
ORDER BY `domain_ace` ASC");
|
2018-12-21 11:24:07 +00:00
|
|
|
Database::pexecute($result_stmt, array(
|
2018-12-22 07:15:31 +00:00
|
|
|
"cid" => $userinfo['customerid']
|
2018-12-21 11:24:07 +00:00
|
|
|
));
|
2010-01-20 16:55:27 +00:00
|
|
|
$domains = '';
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
while ($row = $result_stmt->fetch(PDO::FETCH_ASSOC)) {
|
2018-12-21 17:31:06 +00:00
|
|
|
$domains .= \Froxlor\UI\HTML::makeoption($idna_convert->decode($row['domain']), $row['domain']);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
2018-12-21 17:31:06 +00:00
|
|
|
// $iscatchall = \Froxlor\UI\HTML::makeyesno('iscatchall', '1', '0', '0');
|
2011-02-12 15:18:24 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
$email_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_add.php';
|
2012-08-21 18:08:20 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (Settings::Get('catchall.catchall_enabled') != '1') {
|
2012-08-21 18:08:20 +00:00
|
|
|
unset($email_add_data['emails_add']['sections']['section_a']['fields']['iscatchall']);
|
|
|
|
}
|
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
$email_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($email_add_data);
|
2011-02-12 16:17:13 +00:00
|
|
|
|
|
|
|
$title = $email_add_data['emails_add']['title'];
|
|
|
|
$image = $email_add_data['emails_add']['image'];
|
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails_add") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('allresourcesused');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'edit' && $id != 0) {
|
2018-03-08 10:49:28 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-03-08 10:49:28 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-08 10:49:28 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['email']) && $result['email'] != '') {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email'] = $idna_convert->decode($result['email']);
|
|
|
|
$result['email_full'] = $idna_convert->decode($result['email_full']);
|
|
|
|
$result['destination'] = explode(' ', $result['destination']);
|
|
|
|
uasort($result['destination'], 'strcasecmp');
|
|
|
|
$forwarders = '';
|
|
|
|
$forwarders_count = 0;
|
|
|
|
|
2017-11-06 06:36:51 +00:00
|
|
|
foreach ($result['destination'] as $dest_id => $destination) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$destination = $idna_convert->decode($destination);
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if ($destination != $result['email_full'] && $destination != '') {
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("\$forwarders.=\"" . \Froxlor\UI\Template::getTemplate("email/emails_edit_forwarder") . "\";");
|
2018-12-21 11:24:07 +00:00
|
|
|
$forwarders_count ++;
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$result['destination'][$dest_id] = $destination;
|
|
|
|
}
|
|
|
|
|
|
|
|
$destinations_count = count($result['destination']);
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
2011-02-12 15:18:24 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
$email_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_edit.php';
|
2012-08-21 18:08:20 +00:00
|
|
|
|
2013-12-15 11:24:32 +00:00
|
|
|
if (Settings::Get('catchall.catchall_enabled') != '1') {
|
2012-08-21 18:08:20 +00:00
|
|
|
unset($email_edit_data['emails_edit']['sections']['section_a']['fields']['mail_catchall']);
|
|
|
|
}
|
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
$email_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($email_edit_data);
|
2011-02-12 16:17:13 +00:00
|
|
|
|
|
|
|
$title = $email_edit_data['emails_edit']['title'];
|
|
|
|
$image = $email_edit_data['emails_edit']['image'];
|
2013-11-17 20:40:50 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/emails_edit") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'togglecatchall' && $id != 0) {
|
2018-03-08 10:49:28 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-03-08 10:49:28 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-08 10:49:28 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
|
|
|
|
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
Emails::getLocal($userinfo, array(
|
2018-03-08 10:49:28 +00:00
|
|
|
'id' => $id,
|
|
|
|
'iscatchall' => ($result['iscatchall'] == '1' ? 0 : 1)
|
|
|
|
))->update();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => $page,
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($page == 'accounts') {
|
|
|
|
if ($action == 'add' && $id != 0) {
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['email_accounts'] == '-1' || ($userinfo['email_accounts_used'] < $userinfo['email_accounts'])) {
|
2018-03-12 12:44:44 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-03-12 12:44:44 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2013-11-30 15:07:23 +00:00
|
|
|
}
|
2018-03-12 12:44:44 +00:00
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2018-03-12 13:13:35 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
EmailAccounts::getLocal($userinfo, $_POST)->add();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-12 13:13:35 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => 'emails',
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2018-03-12 13:13:35 +00:00
|
|
|
} else {
|
2016-03-10 09:54:32 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
if (\Froxlor\Validate\Check::checkMailAccDeletionState($result['email_full'])) {
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::standard_error(array(
|
|
|
|
'mailaccistobedeleted'
|
|
|
|
), $result['email_full']);
|
2018-03-12 13:13:35 +00:00
|
|
|
}
|
2016-03-10 09:54:32 +00:00
|
|
|
|
2018-03-12 13:13:35 +00:00
|
|
|
$result['email_full'] = $idna_convert->decode($result['email_full']);
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
2018-03-12 13:13:35 +00:00
|
|
|
$quota = Settings::Get('system.mail_quota');
|
2011-02-12 15:18:24 +00:00
|
|
|
|
2018-03-12 13:13:35 +00:00
|
|
|
$account_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addaccount.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$account_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($account_add_data);
|
2011-02-12 16:24:07 +00:00
|
|
|
|
2018-03-12 13:13:35 +00:00
|
|
|
$title = $account_add_data['emails_addaccount']['title'];
|
|
|
|
$image = $account_add_data['emails_addaccount']['image'];
|
2011-02-12 16:24:07 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_add") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::standard_error(array(
|
|
|
|
'allresourcesused',
|
|
|
|
'allocatetoomuchquota'
|
|
|
|
), $quota);
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'changepw' && $id != 0) {
|
2018-03-12 13:13:35 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-12 13:13:35 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['popaccountid']) && $result['popaccountid'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-12 13:13:35 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
EmailAccounts::getLocal($userinfo, $_POST)->update();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2014-05-18 09:16:35 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => 'emails',
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email_full'] = $idna_convert->decode($result['email_full']);
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
2011-02-12 15:18:24 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
$account_changepw_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangepasswd.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$account_changepw_form = \Froxlor\UI\HtmlForm::genHTMLForm($account_changepw_data);
|
2011-02-12 16:24:07 +00:00
|
|
|
|
|
|
|
$title = $account_changepw_data['emails_accountchangepasswd']['title'];
|
|
|
|
$image = $account_changepw_data['emails_accountchangepasswd']['image'];
|
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_changepw") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-12-15 11:24:32 +00:00
|
|
|
} elseif ($action == 'changequota' && Settings::Get('system.mail_quota_enabled') == '1' && $id != 0) {
|
2018-03-12 13:13:35 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-12 13:13:35 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['popaccountid']) && $result['popaccountid'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-12 13:13:35 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
EmailAccounts::getLocal($userinfo, $_POST)->update();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => 'emails',
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email_full'] = $idna_convert->decode($result['email_full']);
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
2011-02-12 15:18:24 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
$quota_edit_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_accountchangequota.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$quota_edit_form = \Froxlor\UI\HtmlForm::genHTMLForm($quota_edit_data);
|
2011-02-12 16:24:07 +00:00
|
|
|
|
|
|
|
$title = $quota_edit_data['emails_accountchangequota']['title'];
|
|
|
|
$image = $quota_edit_data['emails_accountchangequota']['image'];
|
2013-11-17 20:40:50 +00:00
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/account_changequota") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-03-12 13:13:35 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-12 13:13:35 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['popaccountid']) && $result['popaccountid'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-12 13:13:35 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
EmailAccounts::getLocal($userinfo, $_POST)->delete();
|
2018-03-12 13:13:35 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-07-19 06:03:49 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => 'emails',
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2018-12-24 12:50:45 +00:00
|
|
|
\Froxlor\UI\HTML::askYesNoWithCheckbox('email_reallydelete_account', 'admin_customer_alsoremovemail', $filename, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
), $idna_convert->decode($result['email_full']));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($page == 'forwarders') {
|
|
|
|
if ($action == 'add' && $id != 0) {
|
2018-12-22 07:15:31 +00:00
|
|
|
if ($userinfo['email_forwarders_used'] < $userinfo['email_forwarders'] || $userinfo['email_forwarders'] == '-1') {
|
2018-03-11 09:24:17 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
2018-03-11 09:24:17 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-11 09:24:17 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['email']) && $result['email'] != '') {
|
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-11 09:24:17 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
EmailForwarders::getLocal($userinfo, $_POST)->add();
|
2018-03-11 09:24:17 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => 'emails',
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$result['email_full'] = $idna_convert->decode($result['email_full']);
|
2018-12-24 12:50:45 +00:00
|
|
|
$result = \Froxlor\PhpHelper::htmlentitiesArray($result);
|
2011-02-12 15:18:24 +00:00
|
|
|
|
2018-12-21 11:24:07 +00:00
|
|
|
$forwarder_add_data = include_once dirname(__FILE__) . '/lib/formfields/customer/email/formfield.emails_addforwarder.php';
|
2018-12-21 10:22:03 +00:00
|
|
|
$forwarder_add_form = \Froxlor\UI\HtmlForm::genHTMLForm($forwarder_add_data);
|
2011-02-12 16:24:07 +00:00
|
|
|
|
|
|
|
$title = $forwarder_add_data['emails_addforwarder']['title'];
|
|
|
|
$image = $forwarder_add_data['emails_addforwarder']['image'];
|
|
|
|
|
2018-12-21 10:22:03 +00:00
|
|
|
eval("echo \"" . \Froxlor\UI\Template::getTemplate("email/forwarder_add") . "\";");
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::standard_error('allresourcesused');
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif ($action == 'delete' && $id != 0) {
|
2018-03-11 09:24:17 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
$json_result = Emails::getLocal($userinfo, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id
|
|
|
|
))->get();
|
2018-03-11 09:24:17 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-11 09:24:17 +00:00
|
|
|
}
|
|
|
|
$result = json_decode($json_result, true)['data'];
|
2013-12-15 11:24:32 +00:00
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['destination']) && $result['destination'] != '') {
|
|
|
|
if (isset($_POST['forwarderid'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$forwarderid = intval($_POST['forwarderid']);
|
2013-11-17 20:40:50 +00:00
|
|
|
} elseif (isset($_GET['forwarderid'])) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$forwarderid = intval($_GET['forwarderid']);
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2010-01-20 16:55:27 +00:00
|
|
|
$forwarderid = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$result['destination'] = explode(' ', $result['destination']);
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($result['destination'][$forwarderid]) && $result['email'] != $result['destination'][$forwarderid]) {
|
2010-01-20 16:55:27 +00:00
|
|
|
$forwarder = $result['destination'][$forwarderid];
|
|
|
|
|
2013-11-17 20:40:50 +00:00
|
|
|
if (isset($_POST['send']) && $_POST['send'] == 'send') {
|
2018-03-11 09:24:17 +00:00
|
|
|
try {
|
2018-12-22 07:15:31 +00:00
|
|
|
EmailForwarders::getLocal($userinfo, $_POST)->delete();
|
2018-03-11 09:24:17 +00:00
|
|
|
} catch (Exception $e) {
|
2018-12-21 10:22:03 +00:00
|
|
|
\Froxlor\UI\Response::dynamic_error($e->getMessage());
|
2018-03-11 09:24:17 +00:00
|
|
|
}
|
2018-12-21 11:24:07 +00:00
|
|
|
\Froxlor\UI\Response::redirectTo($filename, array(
|
|
|
|
'page' => 'emails',
|
|
|
|
'action' => 'edit',
|
|
|
|
'id' => $id,
|
|
|
|
's' => $s
|
|
|
|
));
|
2013-11-17 20:40:50 +00:00
|
|
|
} else {
|
2018-12-24 12:50:45 +00:00
|
|
|
\Froxlor\UI\HTML::askYesNo('email_reallydelete_forwarder', $filename, array(
|
2018-12-21 11:24:07 +00:00
|
|
|
'id' => $id,
|
|
|
|
'forwarderid' => $forwarderid,
|
|
|
|
'page' => $page,
|
|
|
|
'action' => $action
|
|
|
|
), $idna_convert->decode($result['email_full']) . ' -> ' . $idna_convert->decode($forwarder));
|
2010-01-20 16:55:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|