Merged upstream/master to encrypted passwords, refs #852
Signed-off-by: Andreas Burchert (scarya) <scarya@froxlor.org>
This commit is contained in:
@@ -51,6 +51,15 @@ return array(
|
||||
'default' => '/var/customers/mail/',
|
||||
'save_method' => 'storeSettingField',
|
||||
),
|
||||
'system_vmail_maildirname' => array(
|
||||
'label' => $lng['serversettings']['vmail_maildirname'],
|
||||
'settinggroup' => 'system',
|
||||
'varname' => 'vmail_maildirname',
|
||||
'type' => 'string',
|
||||
'string_type' => 'dir',
|
||||
'default' => 'Maildir',
|
||||
'save_method' => 'storeSettingField',
|
||||
),
|
||||
'panel_sendalternativemail' => array(
|
||||
'label' => $lng['serversettings']['sendalternativemail'],
|
||||
'settinggroup' => 'panel',
|
||||
@@ -95,4 +104,4 @@ return array(
|
||||
),
|
||||
);
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -1239,7 +1239,7 @@ if($page == 'customers'
|
||||
|
||||
if($deactivated != $result['deactivated'])
|
||||
{
|
||||
$db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix`='" . (($deactivated) ? 'N' : 'Y') . "', `pop3`='" . (($deactivated) ? '0' : '1') . "', `imap`='" . (($deactivated) ? '0' : '1') . "' WHERE `customerid`='" . (int)$id . "'");
|
||||
$db->query("UPDATE `" . TABLE_MAIL_USERS . "` SET `postfix`='" . (($deactivated) ? 'N' : 'Y') . "', `pop3`='" . (($deactivated) ? '0' : (int)$result['pop3']) . "', `imap`='" . (($deactivated) ? '0' : (int)$result['imap']) . "' WHERE `customerid`='" . (int)$id . "'");
|
||||
$db->query("UPDATE `" . TABLE_FTP_USERS . "` SET `login_enabled`='" . (($deactivated) ? 'N' : 'Y') . "' WHERE `customerid`='" . (int)$id . "'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_DOMAINS . "` SET `deactivated`='" . (int)$deactivated . "' WHERE `customerid`='" . (int)$id . "'");
|
||||
|
||||
|
||||
@@ -1126,7 +1126,7 @@ if($page == 'domains'
|
||||
$db->query("UPDATE `" . TABLE_PANEL_ADMINS . "` SET `domains_used` = `domains_used` - 1 WHERE `adminid` = '" . (int)$result['adminid'] . "' ");
|
||||
}
|
||||
|
||||
$ssfs = isset($_POST['specialsettingsforsubdomains']) ? intval($_POST['specialsettingsforsubdomains']) : 1;
|
||||
$ssfs = isset($_POST['specialsettingsforsubdomains']) ? 1 : 0;
|
||||
if($ssfs == 1)
|
||||
{
|
||||
$upd_specialsettings = ", `specialsettings`='" . $db->escape($specialsettings) . "' ";
|
||||
|
||||
@@ -237,7 +237,7 @@ elseif($page == 'emails')
|
||||
standard_error('emailiswrong', $email_full);
|
||||
}
|
||||
|
||||
$email_check = $db->query_first("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE ( `email`='" . $db->escape($email) . "' OR `email_full` = '" . $db->escape($email_full) . "' ) AND `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
$email_check = $db->query_first("SELECT `id`, `email`, `email_full`, `iscatchall`, `destination`, `customerid` FROM `" . TABLE_MAIL_VIRTUAL . "` WHERE (`email` = '" . strtolower($db->escape($email)) . "' OR `email_full` = '" . strtolower($db->escape($email_full)) . "') AND `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
|
||||
if($email == ''
|
||||
|| $email_full == ''
|
||||
@@ -253,7 +253,7 @@ elseif($page == 'emails')
|
||||
{
|
||||
standard_error('maindomainnonexist', $domain);
|
||||
}
|
||||
elseif($email_check['email_full'] == $email_full)
|
||||
elseif(strtolower($email_check['email_full']) == strtolower($email_full))
|
||||
{
|
||||
standard_error('emailexistalready', $email_full);
|
||||
}
|
||||
@@ -440,11 +440,41 @@ elseif($page == 'accounts')
|
||||
}
|
||||
|
||||
$cryptPassword = makeCryptPassword($db->escape($password),1);
|
||||
$db->query("INSERT INTO `" . TABLE_MAIL_USERS . "` (`customerid`, `email`, `username`, " . ($settings['system']['mailpwcleartext'] == '1' ? '`password`, ' : '') . " `password_enc`, `homedir`, `maildir`, `uid`, `gid`, `domainid`, `postfix`, `quota`, `imap`, `pop3`) VALUES ('" . (int)$userinfo['customerid'] . "', '" . $db->escape($email_full) . "', '" . $db->escape($username) . "', " . ($settings['system']['mailpwcleartext'] == '1' ? "'" . $db->escape($password) . "'," : '') . " '" . $db->escape($cryptPassword) . "', '" . $db->escape($settings['system']['vmail_homedir']) . "', '" . $db->escape($userinfo['loginname'] . '/' . $email_full . '/') . "', '" . (int)$settings['system']['vmail_uid'] . "', '" . (int)$settings['system']['vmail_gid'] . "', '" . (int)$result['domainid'] . "', 'y', '" . (int)$quota . "', '" . (int)$userinfo['imap'] . "', '" . (int)$userinfo['pop3'] . "')");
|
||||
|
||||
$email_user=substr($email_full,0,strrpos($email_full,"@"));
|
||||
$email_domain=substr($email_full,strrpos($email_full,"@")+1);
|
||||
$maildirname=trim($settings['system']['vmail_maildirname']);
|
||||
// Add trailing slash to Maildir if needed
|
||||
$maildirpath=$maildirname;
|
||||
if (!empty($maildirname) and substr($maildirname,-1) != "/") $maildirpath.="/";
|
||||
|
||||
$db->query("INSERT INTO `" . TABLE_MAIL_USERS .
|
||||
"` (`customerid`, `email`, `username`, " . ($settings['system']['mailpwcleartext'] == '1' ? '`password`, ' : '') . " `password_enc`, `homedir`, `maildir`, `uid`, `gid`, `domainid`, `postfix`, `quota`, `imap`, `pop3`) ".
|
||||
"VALUES (".
|
||||
"'" . (int)$userinfo['customerid'] . "', ".
|
||||
"'" . $db->escape($email_full) . "', ".
|
||||
"'" . $db->escape($username) . "', " .
|
||||
($settings['system']['mailpwcleartext'] == '1' ? "'" . $db->escape($password) . "', " : '') .
|
||||
"'" . $db->escape($cryptPassword) . "', ".
|
||||
"'" . $db->escape($settings['system']['vmail_homedir']) . "', '" . $db->escape($userinfo['loginname'] . '/' . $email_domain . "/" . $email_user . "/" . $maildirpath) . "', ".
|
||||
"'" . (int)$settings['system']['vmail_uid'] . "', ".
|
||||
"'" . (int)$settings['system']['vmail_gid'] . "', ".
|
||||
"'" . (int)$result['domainid'] . "', ".
|
||||
"'y', ".
|
||||
"'" . (int)$quota . "', ".
|
||||
"'" . (int)$userinfo['imap'] . "', ".
|
||||
"'" . (int)$userinfo['pop3'] . "')");
|
||||
|
||||
$popaccountid = $db->insert_id();
|
||||
$result['destination'].= ' ' . $email_full;
|
||||
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET `destination` = '" . $db->escape(makeCorrectDestination($result['destination'])) . "', `popaccountid` = '" . (int)$popaccountid . "' WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET `email_accounts_used`=`email_accounts_used`+1, `email_quota_used`=`email_quota_used`+" . (int)$quota . " WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
$db->query("UPDATE `" . TABLE_MAIL_VIRTUAL . "` SET ".
|
||||
"`destination` = '" . $db->escape(makeCorrectDestination($result['destination'])) . "', ".
|
||||
"`popaccountid` = '" . (int)$popaccountid . "' ".
|
||||
"WHERE `customerid`='" . (int)$userinfo['customerid'] . "' AND `id`='" . (int)$id . "'");
|
||||
$db->query("UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET ".
|
||||
"`email_accounts_used`=`email_accounts_used`+1, ".
|
||||
"`email_quota_used`=`email_quota_used`+" . (int)$quota . " ".
|
||||
"WHERE `customerid`='" . (int)$userinfo['customerid'] . "'");
|
||||
$log->logAction(USR_ACTION, LOG_INFO, "added email account for '" . $email_full . "'");
|
||||
$replace_arr = array(
|
||||
'EMAIL' => $email_full,
|
||||
|
||||
@@ -466,6 +466,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('syste
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_uid', '2000');
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_gid', '2000');
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_homedir', '/var/customers/mail/');
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_maildir', 'Maildir');
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bind_enable', '1');
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bindconf_directory', '/etc/bind/');
|
||||
INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'bindreload_command', '/etc/init.d/bind9 reload');
|
||||
|
||||
@@ -1914,5 +1914,12 @@ if(isFroxlorVersion('0.9.28-svn2')) {
|
||||
// change lenght of passwd column
|
||||
$db->query("ALTER TABLE `" . TABLE_FTP_USERS . "` MODIFY `password` varchar(128) NOT NULL default ''");
|
||||
|
||||
// Add default setting for vmail_maildirname if not already in place
|
||||
$handle = $db->query("SELECT `value` FROM `panel_settings` WHERE `settinggroup` = 'system' AND `varname` = 'vmail_maildirname';");
|
||||
if ($db->num_rows($handle) < 1) {
|
||||
showUpdateStep("Adding default Maildir value into Mailserver settings.");
|
||||
$db->query("INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES ('system', 'vmail_maildirname', 'Maildir');");
|
||||
}
|
||||
|
||||
updateToVersion('0.9.28-svn3');
|
||||
}
|
||||
|
||||
@@ -30,7 +30,10 @@ function maildirExists($result = null)
|
||||
{
|
||||
$loginname = getCustomerDetail($result['customerid'], 'loginname');
|
||||
if($loginname !== false) {
|
||||
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $loginname .'/'. $result['email_full']);
|
||||
$email_user=substr($result['email_full'],0,strrpos($result['email_full'],"@"));
|
||||
$email_domain=substr($result['email_full'],strrpos($result['email_full'],"@")+1);
|
||||
$maildirname=trim($settings['system']['vmail_maildirname']);
|
||||
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $loginname .'/'. $email_domain .'/'. $email_user . (!empty($maildirname)?'/'.$maildirname:''));
|
||||
if(@file_exists($maildir)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -209,6 +209,10 @@ function getOutstandingTasks()
|
||||
$task_desc = $lng['tasks']['deleting_customerfiles'];
|
||||
$task_desc = str_replace('%loginname%', $loginname, $task_desc);
|
||||
}
|
||||
elseif($row['type'] == '7')
|
||||
{
|
||||
$task_desc = $lng['tasks']['remove_emailacc_files'];
|
||||
}
|
||||
/*
|
||||
* Set FS - quota
|
||||
*/
|
||||
|
||||
@@ -73,6 +73,6 @@ define('PACKAGE_ENABLED', 2);
|
||||
|
||||
// VERSION INFO
|
||||
|
||||
$version = '0.9.28-svn2';
|
||||
$version = '0.9.28-svn3';
|
||||
$dbversion = '2';
|
||||
$branding = '';
|
||||
|
||||
@@ -1917,3 +1917,7 @@ $lng['panel']['cancel'] = 'Cancel';
|
||||
$lng['admin']['delete_statistics'] = 'Delete Statistics';
|
||||
$lng['admin']['speciallogwarning'] = 'WARNING: By changing this setting you will lose all your old statistics for this domain. If you are 100% sure you wish to change this type "'.$lng['admin']['delete_statistics'].'" in the field below and click the "'.$lng['panel']['delete'].'" button.<br /><br />';
|
||||
|
||||
// ADDED IN 0.9.28-svn2
|
||||
$lng['serversettings']['vmail_maildirname']['title'] = 'Maildir name';
|
||||
$lng['serversettings']['vmail_maildirname']['description'] = 'Maildir directory into user\'s account. Normally \'Maildir\', in some implementations \'.maildir\', and directly into user\'s directory if left blank.';
|
||||
$lng['tasks']['remove_emailacc_files'] = 'Delete customer e-mail data.';
|
||||
|
||||
@@ -310,7 +310,6 @@ while($row = $db->fetch_array($result_tasks))
|
||||
safe_exec('rm -rf '.escapeshellarg($backupdir));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* remove maildir
|
||||
*/
|
||||
@@ -318,7 +317,10 @@ while($row = $db->fetch_array($result_tasks))
|
||||
|
||||
if($maildir != '/'
|
||||
&& $maildir != $settings['system']['vmail_homedir']
|
||||
&& substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'])
|
||||
&& substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']
|
||||
&& is_dir($maildir)
|
||||
&& fileowner($maildir) == $settings['system']['vmail_uid']
|
||||
&& filegroup($maildir) == $settings['system']['vmail_gid'])
|
||||
{
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir));
|
||||
safe_exec('rm -rf '.escapeshellarg($maildir));
|
||||
@@ -388,11 +390,25 @@ while($row = $db->fetch_array($result_tasks))
|
||||
/*
|
||||
* remove specific maildir
|
||||
*/
|
||||
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $row['data']['email']);
|
||||
$email_full = $row['data']['email'];
|
||||
if (empty($email_full)) {
|
||||
$cronlog->logAction(CRON_ACTION, LOG_ERROR, 'FATAL: Task7 asks to delete a email account but email field is empty!');
|
||||
}
|
||||
$email_user=substr($email_full,0,strrpos($email_full,"@"));
|
||||
$email_domain=substr($email_full,strrpos($email_full,"@")+1);
|
||||
$maildirname=trim($settings['system']['vmail_maildirname']);
|
||||
// Add trailing slash to Maildir if needed
|
||||
$maildirpath=$maildirname;
|
||||
if (!empty($maildirname) and substr($maildirname,-1) != "/") $maildirpath.="/";
|
||||
$maildir = makeCorrectDir($settings['system']['vmail_homedir'] .'/'. $row['data']['loginname'] .'/'. $email_domain .'/'. $email_user);
|
||||
|
||||
if($maildir != '/'
|
||||
if($maildir != '/' && !empty($maildir) && !empty($email_full)
|
||||
&& $maildir != $settings['system']['vmail_homedir']
|
||||
&& substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir'])
|
||||
&& substr($maildir, 0, strlen($settings['system']['vmail_homedir'])) == $settings['system']['vmail_homedir']
|
||||
&& is_dir($maildir)
|
||||
&& is_dir(makeCorrectDir($maildir.'/'.$maildirpath))
|
||||
&& fileowner($maildir) == $settings['system']['vmail_uid']
|
||||
&& filegroup($maildir) == $settings['system']['vmail_gid'])
|
||||
{
|
||||
$cronlog->logAction(CRON_ACTION, LOG_NOTICE, 'Running: rm -rf ' . escapeshellarg($maildir));
|
||||
safe_exec('rm -rf '.escapeshellarg($maildir));
|
||||
|
||||
Reference in New Issue
Block a user