Commit e10bb13c authored by Marius Burkard's avatar Marius Burkard

Merge branch 'master' into 'patch-ci-test'

# Conflicts:
#   .gitlab-ci.yml
parents b7794d7d 93edc7d2
......@@ -507,7 +507,7 @@ class installer_dist extends installer_base {
$content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content);
$content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
$content = str_replace('{hostname}', $conf['hostname'], $content);
$content = str_replace('{amavis_config_dir}', $conf['amavis']['config_dir']);
$content = str_replace('{amavis_config_dir}', $conf['amavis']['config_dir'], $content);
wf($conf["amavis"]["config_dir"].'/amavisd.conf', $content);
chmod($conf['amavis']['config_dir'].'/amavisd.conf', 0640);
......
......@@ -91,8 +91,19 @@
</tmpl_if>
<IfModule mod_headers.c>
Header always add Strict-Transport-Security "max-age=15768000"
RequestHeader unset Proxy early
# ISPConfig 3.1 currently requires unsafe-line for both scripts and styles, as well as unsafe-eval
Header set Content-Security-Policy "default-src 'self' 'unsafe-inline' 'unsafe-eval'; img-src 'self' data:; object-src 'none'; upgrade-insecure-requests"
Header set X-Content-Type-Options: nosniff
Header set X-Frame-Options: SAMEORIGIN
Header set X-XSS-Protection: "1; mode=block"
Header always edit Set-Cookie (.*) "$1; HTTPOnly; Secure"
<IfVersion >= 2.4.7>
Header setifempty Strict-Transport-Security "max-age=15768000"
</IfVersion>
<IfVersion < 2.4.7>
Header set Strict-Transport-Security "max-age=15768000"
</IfVersion>
RequestHeader unset Proxy early
</IfModule>
<tmpl_if name='apache_version' op='>=' value='2.3.3' format='version'>
......
......@@ -62,7 +62,11 @@ class app {
$this->_conf = $conf;
if($this->_conf['start_db'] == true) {
$this->load('db_'.$this->_conf['db_type']);
$this->db = new db;
try {
$this->db = new db;
} catch (Exception $e) {
$this->db = false;
}
}
//* Start the session
......
This diff is collapsed.
......@@ -36,7 +36,11 @@ class session {
private $permanent = false;
function __construct($session_timeout = 0) {
$this->db = new db;
try {
$this->db = new db;
} catch (Exception $e) {
$this->db = false;
}
$this->timeout = $session_timeout;
}
......
......@@ -191,7 +191,7 @@ class validate_domain {
/* internal validator function to match regexp */
function _regex_validate($domain_name, $allow_wildcard = false) {
$pattern = '/^' . ($allow_wildcard == true ? '(\*\.)?' : '') . '[\w\.\-]{2,255}\.[a-zA-Z0-9\-]{2,30}$/';
$pattern = '/^' . ($allow_wildcard == true ? '(\*\.)?' : '') . '[\w\.\-]{1,255}\.[a-zA-Z0-9\-]{2,30}$/';
return preg_match($pattern, $domain_name);
}
......
......@@ -71,7 +71,7 @@ class validate_password {
} else if ($points == 1) {
if ($length >= 5 && $length <= 6) {
return 2;
} else if (length >= 7 && length <=10) {
} else if ($length >= 7 && $length <=10) {
return 3;
} else {
return 4;
......
......@@ -8,6 +8,11 @@ class dashlet_databasequota {
//* Loading Template
$app->uses('tpl,quota_lib');
$modules = $_SESSION['s']['user']['modules'];
if (!in_array($modules, 'sites')) {
return '';
}
$tpl = new tpl;
$tpl->newTemplate("dashlets/templates/databasequota.htm");
......
......@@ -8,6 +8,11 @@ class dashlet_quota {
//* Loading Template
$app->uses('tpl,quota_lib');
$modules = $_SESSION['s']['user']['modules'];
if (!in_array($modules, 'sites')) {
return '';
}
$tpl = new tpl;
$tpl->newTemplate("dashlets/templates/quota.htm");
......
......@@ -25,6 +25,9 @@ body {
.form-group input[type='checkbox'] {
margin-top: 10px; }
.form-group .checkbox-inline input[type='checkbox'] {
margin-top: 4px; }
.control-label {
font-weight: normal; }
.control-label:after {
......
......@@ -25,6 +25,9 @@ body
.form-group input[type='checkbox']
margin-top: 10px
.form-group .checkbox-inline input[type='checkbox']
margin-top: 4px
.control-label
font-weight: normal
......@@ -311,4 +314,4 @@ thead.dark
.input-group-field:last-child
border-top-left-radius: 0
border-bottom-left-radius: 0
\ No newline at end of file
border-bottom-left-radius: 0
......@@ -49,32 +49,27 @@ if(isset($_POST['start']) && $_POST['start'] == 1) {
//* CSRF Check
$app->auth->csrf_token_check();
//* Set variable sin template
//* Set variables in template
$app->tpl->setVar('dbhost', $_POST['dbhost'], true);
$app->tpl->setVar('dbname', $_POST['dbname'], true);
$app->tpl->setVar('dbuser', $_POST['dbuser'], true);
$app->tpl->setVar('dbpassword', $_POST['dbpassword'], true);
$app->tpl->setVar('dbssl', 'true', true);
//* Establish connection to external database
$msg .= 'Connecting to external database...<br />';
//* Backup DB login details
/*$conf_bak['db_host'] = $conf['db_host'];
$conf_bak['db_database'] = $conf['db_database'];
$conf_bak['db_user'] = $conf['db_user'];
$conf_bak['db_password'] = $conf['db_password'];*/
//* Set external db client flags
$db_client_flags = 0;
if(isset($_POST['dbssl']) && $_POST['dbssl'] == 1) $db_client_flags |= MYSQLI_CLIENT_SSL;
//* Set external Login details
$conf['imp_db_host'] = $_POST['dbhost'];
$conf['imp_db_database'] = $_POST['dbname'];
$conf['imp_db_user'] = $_POST['dbuser'];
$conf['imp_db_password'] = $_POST['dbpassword'];
$conf['imp_db_charset'] = $conf['db_charset'];
$conf['imp_db_new_link'] = $conf['db_new_link'];
$conf['imp_db_client_flags'] = $conf['db_client_flags'];
//* create new db object
$exdb = new db('imp');
//* create new db object with external login details
try {
$exdb = new db($_POST['dbhost'], $_POST['dbuser'], $_POST['dbpassword'], $_POST['dbname'], 3306, $db_client_flags);
} catch (Exception $e) {
$error .= "Error connecting to Tupa database" . ($e->getMessage() ? ": " . $e->getMessage() : '.') . "<br />\n";
$exdb = false;
}
$server_id = 1;
$sys_userid = 1;
......@@ -159,26 +154,13 @@ if(isset($_POST['start']) && $_POST['start'] == 1) {
);
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id');
//$msg .= $insert_data.'<br />';
}
}
}
}
}
} else {
$error .= $exdb->errorMessage;
}
//* restore db login details
/*$conf['db_host'] = $conf_bak['db_host'];
$conf['db_database'] = $conf_bak['db_database'];
$conf['db_user'] = $conf_bak['db_user'];
$conf['db_password'] = $conf_bak['db_password'];*/
}
$app->tpl->setVar('msg', $msg);
......
......@@ -52,17 +52,17 @@ $app->tpl->setVar($wb);
if(isset($_POST['db_hostname']) && $_POST['db_hostname'] != '') {
//* Set external Login details
$conf['imp_db_host'] = $_POST['db_hostname'];
$conf['imp_db_database'] = $_POST['db_name'];
$conf['imp_db_user'] = $_POST['db_user'];
$conf['imp_db_password'] = $_POST['db_password'];
$conf['imp_db_charset'] = 'utf8';
$conf['imp_db_new_link'] = false;
$conf['imp_db_client_flags'] = 0;
//* create new db object
$exdb = new db('imp');
//* Set external db client flags
$db_client_flags = 0;
if(isset($_POST['db_ssl']) && $_POST['db_ssl'] == 1) $db_client_flags |= MYSQLI_CLIENT_SSL;
//* create new db object with external login details
try {
$exdb = new db($_POST['db_hostname'], $_POST['db_user'], $_POST['db_password'], $_POST['db_name'], 3306, $db_client_flags);
} catch (Exception $e) {
$error .= "Error connecting to database" . ($e->getMessage() ? ": " . $e->getMessage() : '.') . "<br />\n";
$exdb = false;
}
if($exdb !== false) {
$msg .= 'Databse connection succeeded<br />';
......@@ -75,9 +75,6 @@ if(isset($_POST['db_hostname']) && $_POST['db_hostname'] != '') {
} else {
$msg .= 'The server with the ID $local_server_id is not a mail server.<br />';
}
} else {
$msg .= 'Database connection failed<br />';
}
} else {
......@@ -88,6 +85,7 @@ $app->tpl->setVar('db_hostname', $_POST['db_hostname'], true);
$app->tpl->setVar('db_user', $_POST['db_user'], true);
$app->tpl->setVar('db_password', $_POST['db_password'], true);
$app->tpl->setVar('db_name', $_POST['db_name'], true);
$app->tpl->setVar('db_ssl', 'true', true);
$app->tpl->setVar('local_server_id', $_POST['local_server_id'], true);
$app->tpl->setVar('msg', $msg);
$app->tpl->setVar('error', $error);
......
......@@ -4,22 +4,27 @@
<legend>PowerDNS Tupa import</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Tupa database hostname</label>
<label class="col-sm-3 control-label" for="dbhost">Tupa database hostname</label>
<div class="col-sm-9"><input class="form-control" type="text" id="dbhost" value="{tmpl_var name='dbhost'}" name="dbhost" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Tupa database name</label>
<label class="col-sm-3 control-label" for="dbname">Tupa database name</label>
<div class="col-sm-9"><input class="form-control" type="text" id="dbname" value="{tmpl_var name='dbname'}" name="dbname" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Tupa database user</label>
<label class="col-sm-3 control-label" for="dbuser">Tupa database user</label>
<div class="col-sm-9"><input class="form-control" type="text" id="dbuser" value="{tmpl_var name='dbuser'}" name="dbuser" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Tupa database password</label>
<label class="col-sm-3 control-label" for="dbpassword">Tupa database password</label>
<div class="col-sm-9"><input class="form-control" type="text" id="dbpassword" value="{tmpl_var name='dbpassword'}" name="dbpassword" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="dboptions">Tupa database options</label>
<div class="col-sm-9" id="dboptions">
<label class="checkbox-inline" for="dbssl"><input type="checkbox" id="dbssl" value="1" name="dbssl" <tmpl_if name='dbssl' op='==' value='true'>checked</tmpl_if>/> Use SSL</label>
</div>
</div>
<tmpl_if name="msg">
<div id="OKMsg"><p><tmpl_var name="msg"></p></div>
......@@ -34,4 +39,4 @@
<div class="clear"><div class="right">
<button class="btn btn-default formbutton-success" type="button" value="Import" data-submit-form="pageForm" data-form-action="tools/dns_import_tupa.php">Start</button>
<button class="btn btn-default formbutton-default" type="button" value="Cancel" data-load-content="tools/index.php">Cancel</button>
</div></div>
\ No newline at end of file
</div></div>
......@@ -8,26 +8,31 @@
<div class="pnl_formsarea">
<legend>{tmpl_var name="legend_txt"}</legend>
<div class="form-group">
<label class="col-sm-3 control-label">Database Hostname</label>
<label class="col-sm-3 control-label" for="db_hostname">Database Hostname</label>
<div class="col-sm-9"><input class="form-control" type="text" id="db_hostname" value="{tmpl_var name='db_hostname'}" name="db_hostname" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Database Name</label>
<label class="col-sm-3 control-label" for="db_name">Database Name</label>
<div class="col-sm-9"><input class="form-control" type="text" id="db_name" value="{tmpl_var name='db_name'}" name="db_name" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Database User</label>
<label class="col-sm-3 control-label" for="db_user">Database User</label>
<div class="col-sm-9"><input class="form-control" type="text" id="db_user" value="{tmpl_var name='db_user'}" name="db_user" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Database password</label>
<label class="col-sm-3 control-label" for="db_password">Database password</label>
<div class="col-sm-9"><input class="form-control" type="text" id="db_password" value="{tmpl_var name='db_password'}" name="db_password" /></div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label" for="db_options">Tupa database options</label>
<div class="col-sm-9" id="db_options">
<label class="checkbox-inline" for="db_ssl"><input type="checkbox" id="db_ssl" value="1" name="db_ssl" <tmpl_if name='db_ssl' op='==' value='true'>checked</tmpl_if>/> Use SSL</label>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">Server ID of local mailserver</label>
<label class="col-sm-3 control-label" for="local_server_id">Server ID of local mailserver</label>
<div class="col-sm-9"><input class="form-control" type="text" id="local_server_id" value="{tmpl_var name='local_server_id'}" name="local_server_id" /></div>
</div>
</div>
<tmpl_if name="msg">
......
......@@ -43,7 +43,11 @@ class app {
if($conf['start_db'] == true) {
$this->load('db_'.$conf['db_type']);
$this->db = new db;
try {
$this->db = new db;
} catch (Exception $e) {
$this->db = false;
}
/*
Initialize the connection to the master DB,
......@@ -51,7 +55,11 @@ class app {
*/
if($conf['dbmaster_host'] != '' && ($conf['dbmaster_host'] != $conf['db_host'] || ($conf['dbmaster_host'] == $conf['db_host'] && $conf['dbmaster_database'] != $conf['db_database']))) {
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port'], $conf['dbmaster_client_flags']);
try {
$this->dbmaster = new db($conf['dbmaster_host'], $conf['dbmaster_user'], $conf['dbmaster_password'], $conf['dbmaster_database'], $conf['dbmaster_port'], $conf['dbmaster_client_flags']);
} catch (Exception $e) {
$this->dbmaster = false;
}
} else {
$this->dbmaster = $this->db;
}
......
......@@ -95,12 +95,12 @@ class cronjob_monitor_database_size extends cronjob {
if(!is_numeric($quota)) continue;
if($quota < 1 || $quota > $data[$i]['size']) {
print $rec['database_name'] . ' does not exceed quota qize: ' . $quota . ' > ' . $data[$i]['size'] . "\n";
print 'database ' . $rec['database_name'] . ' size does not exceed quota: ' . ($quota < 1 ? 'unlimited' : $quota) . ' (quota) > ' . $data[$i]['size'] . " (used)\n";
if($rec['quota_exceeded'] == 'y') {
$app->dbmaster->datalogUpdate('web_database', array('quota_exceeded' => 'n'), 'database_id', $rec['database_id']);
}
} elseif($rec['quota_exceeded'] == 'n') {
print $rec['database_name'] . ' exceeds quota qize: ' . $quota . ' < ' . $data[$i]['size'] . "\n";
print 'database ' . $rec['database_name'] . ' size exceeds quota: ' . $quota . ' (quota) < ' . $data[$i]['size'] . " (used)\n";
$app->dbmaster->datalogUpdate('web_database', array('quota_exceeded' => 'y'), 'database_id', $rec['database_id']);
}
}
......
......@@ -71,24 +71,26 @@ class cronjob_ftplogfiles extends cronjob {
}
}
$fp = fopen('/var/log/pure-ftpd/transfer.log.1', 'r');
$fp = @fopen('/var/log/pure-ftpd/transfer.log.1', 'r');
$ftp_traffic = array();
// cumule des stats journalière dans un tableau
while($line = fgets($fp))
{
$parsed_line = parse_ftp_log($line);
$sql = "SELECT wd.domain FROM ftp_user AS fu INNER JOIN web_domain AS wd ON fu.parent_domain_id = wd.domain_id WHERE fu.username = ? ";
$temp = $app->db->queryOneRecord($sql, $parsed_line['username'] );
$parsed_line['domain'] = $temp['domain'];
add_ftp_traffic($ftp_traffic, $parsed_line);
if ($fp) {
// cumule des stats journalière dans un tableau
while($line = fgets($fp))
{
$parsed_line = parse_ftp_log($line);
$sql = "SELECT wd.domain FROM ftp_user AS fu INNER JOIN web_domain AS wd ON fu.parent_domain_id = wd.domain_id WHERE fu.username = ? ";
$temp = $app->db->queryOneRecord($sql, $parsed_line['username'] );
$parsed_line['domain'] = $temp['domain'];
add_ftp_traffic($ftp_traffic, $parsed_line);
}
fclose($fp);
}
fclose($fp);
// Save du tableau en BD
foreach($ftp_traffic as $traffic_date => $all_traffic)
{
......@@ -123,4 +125,4 @@ class cronjob_ftplogfiles extends cronjob {
}
}
?>
\ No newline at end of file
?>
......@@ -242,7 +242,7 @@ class cronjob_backup_mail extends cronjob {
if(!is_file($mail_backup_dir.'/'.$backup['filename'])){
$sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?";
$app->db->query($sql, $conf['server_id'], $backup['parent_domain_id'], $backup['filename']);
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $backup['parent_domain_id'], $backup['filename']);
}
}
}
......
This diff is collapsed.
......@@ -815,7 +815,7 @@ class monitor_tools {
$mailSubject = '';
$inHeader = true;
for($l = 0; $l < count($lines); $l++) {
/* Trim only in headers */
/* Trim only in headers */
if($inHeader && trim($lines[$l]) == '') {
$inHeader = false;
continue;
......
......@@ -296,7 +296,7 @@ class backup_plugin {
unlink($mail_backup_file);
$sql = "DELETE FROM mail_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?";
$app->db->query($sql, $conf['server_id'], $mail_backup['parent_domain_id'], $mail_backup['filename']);
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $mail_backup['parent_domain_id'], $mail_backup['filename']);
$app->log('unlink '.$backup_dir.'/'.$mail_backup['filename'], LOGLEVEL_DEBUG);
}
}
......
......@@ -61,7 +61,7 @@ $conf['server_id'] = intval($conf['server_id']);
/*
* Try to Load the server configuration from the master-db
*/
if ($app->dbmaster->connect_error == NULL) {
if ($app->dbmaster->testConnection()) {
$server_db_record = $app->dbmaster->queryOneRecord("SELECT * FROM server WHERE server_id = ?", $conf['server_id']);
if(!is_array($server_db_record)) die('Unable to load the server configuration from database.');
......@@ -152,7 +152,7 @@ $needStartCore = true;
/*
* Next we try to process the datalog
*/
if ($app->db->connect_error == NULL && $app->dbmaster->connect_error == NULL) {
if ($app->db->testConnection() && $app->dbmaster->testConnection()) {
// Check if there is anything to update
if ($conf['mirror_server_id'] > 0) {
......@@ -187,7 +187,7 @@ if ($app->db->connect_error == NULL && $app->dbmaster->connect_error == NULL) {
$needStartCore = false;
} else {
if ($app->db->connect->connect_error == NULL) {
if (!$app->db->connect->testConnection()) {
$app->log('Unable to connect to local server.' . $app->db->errorMessage, LOGLEVEL_WARN);
} else {
$app->log('Unable to connect to master server.' . $app->dbmaster->errorMessage, LOGLEVEL_WARN);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment