Skip to content
......@@ -274,6 +274,9 @@ $inst->db = new db();
$inst->db->setDBData($conf['mysql']["host"], $conf['mysql']["ispconfig_user"], $conf['mysql']["ispconfig_password"], $conf['mysql']["port"]);
$inst->db->setDBName($conf['mysql']['database']);
//* Check MySQL version
$inst->check_mysql_version();
//* initialize the master DB, if we have a multiserver setup
if($conf['mysql']['master_slave_setup'] == 'y') {
//** Get MySQL root credentials
......@@ -359,17 +362,49 @@ $inst->find_installed_apps();
//** Check for current service config state and compare to our results
if ($conf['mysql']['master_slave_setup'] == 'y') $current_svc_config = $inst->dbmaster->queryOneRecord("SELECT mail_server,web_server,dns_server,xmpp_server,firewall_server,vserver_server,db_server FROM ?? WHERE server_id=?", $conf['mysql']['master_database'] . '.server', $conf['server_id']);
else $current_svc_config = $inst->db->queryOneRecord("SELECT mail_server,web_server,dns_server,xmpp_server,firewall_server,vserver_server,db_server FROM ?? WHERE server_id=?", $conf["mysql"]["database"] . '.server', $conf['server_id']);
$conf['services']['mail'] = check_service_config_state('mail_server', $conf['postfix']['installed']);
$conf['services']['dns'] = check_service_config_state('dns_server', ($conf['powerdns']['installed'] || $conf['bind']['installed'] || $conf['mydns']['installed']));
$conf['services']['web'] = check_service_config_state('web_server', ($conf['apache']['installed'] || $conf['nginx']['installed']));
$conf['services']['xmpp'] = check_service_config_state('xmpp_server', $conf['xmpp']['installed']);
$conf['services']['firewall'] = check_service_config_state('firewall_server', ($conf['ufw']['installed'] || $conf['firewall']['installed']));
$conf['services']['vserver'] = check_service_config_state('vserver_server', $conf['services']['vserver']);
if(isset($conf['postfix']['installed']) && $conf['postfix']['installed'] == true) {
$conf['services']['mail'] = check_service_config_state('mail_server', true);
} else {
$conf['services']['mail'] = check_service_config_state('mail_server', false);
}
if(isset($conf['powerdns']['installed']) && $conf['powerdns']['installed'] == true || isset($conf['bind']['installed']) && $conf['bind']['installed'] == true || isset($conf['mydns']['installed']) && $conf['mydns']['installed'] == true) {
$conf['services']['dns'] = check_service_config_state('dns_server', true);
} else {
$conf['services']['dns'] = check_service_config_state('dns_server', false);
}
if(isset($conf['apache']['installed']) && $conf['apache']['installed'] == true || isset($conf['nginx']['installed']) && $conf['nginx']['installed'] == true) {
$conf['services']['web'] = check_service_config_state('web_server', true);
} else {
$conf['services']['web'] = check_service_config_state('web_server', false);
}
if(isset($conf['xmpp']['installed']) && $conf['xmpp']['installed'] == true) {
$conf['services']['xmpp'] = check_service_config_state('xmpp_server', true);
} else {
$conf['services']['xmpp'] = check_service_config_state('xmpp_server', false);
}
if(isset($conf['ufw']['installed']) && $conf['ufw']['installed'] == true || isset($conf['firewall']['installed']) && $conf['firewall']['installed'] == true) {
$conf['services']['firewall'] = check_service_config_state('firewall_server', true);
} else {
$conf['services']['firewall'] = check_service_config_state('firewall_server', false);
}
if(isset($conf['vserver']['installed']) && $conf['vserver']['installed'] == true) {
$conf['services']['vserver'] = check_service_config_state('vserver_server', true);
} else {
$conf['services']['vserver'] = check_service_config_state('vserver_server', false);
}
$conf['services']['db'] = check_service_config_state('db_server', true); /* Will always offer as MySQL is of course installed on this host as it's a requirement for ISPC to work... */
unset($current_svc_config);
//** Write new decisions into DB
$sql = "UPDATE ?? SET mail_server = '{$conf['services']['mail']}', web_server = '{$conf['services']['web']}', dns_server = '{$conf['services']['dns']}', file_server = '{$conf['services']['file']}', db_server = '{$conf['services']['db']}', vserver_server = '{$conf['services']['vserver']}', proxy_server = '{$conf['services']['proxy']}', firewall_server = '$firewall_server_enabled', xmpp_server = '$xmpp_server_enabled' WHERE server_id = ?";
$sql = "UPDATE ?? SET mail_server = '{$conf['services']['mail']}', web_server = '{$conf['services']['web']}', dns_server = '{$conf['services']['dns']}', file_server = '{$conf['services']['file']}', db_server = '{$conf['services']['db']}', vserver_server = '{$conf['services']['vserver']}', proxy_server = '{$conf['services']['proxy']}', firewall_server = '{$conf['services']['firewall']}', xmpp_server = '{$conf['services']['xmpp']}' WHERE server_id = ?";
$inst->db->query($sql, $conf['mysql']['database'].'.server', $conf['server_id']);
if($conf['mysql']['master_slave_setup'] == 'y') {
$inst->dbmaster->query($sql, $conf['mysql']['master_database'].'.server', $conf['server_id']);
......@@ -562,7 +597,7 @@ if($conf['apache']['installed'] == true) {
if ($inst->install_ispconfig_interface) {
//** Customise the port ISPConfig runs on
$ispconfig_port_number = get_ispconfig_port_number();
if($autoupdate['ispconfig_port'] == 'default') $autoupdate['ispconfig_port'] = $ispconfig_port_number;
if(isset($autoupdate['ispconfig_port']) && $autoupdate['ispconfig_port'] == 'default') $autoupdate['ispconfig_port'] = $ispconfig_port_number;
if($conf['webserver']['server_type'] == 'nginx'){
$conf['nginx']['vhost_port'] = $inst->free_query('ISPConfig Port', $ispconfig_port_number,'ispconfig_port');
} else {
......@@ -607,13 +642,13 @@ if($update_crontab_answer == 'yes') {
//** Restart services:
if($reconfigure_services_answer == 'yes') {
swriteln('Restarting services ...');
if($conf['mysql']['installed'] == true && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
if($conf['mysql']['installed'] == true && isset($conf['mysql']['init_script']) && $conf['mysql']['init_script'] != '') system($inst->getinitcommand($conf['mysql']['init_script'], 'restart').' >/dev/null 2>&1');
if($conf['services']['mail']) {
if($conf['postfix']['installed'] == true && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
if($conf['saslauthd']['installed'] == true && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
if($conf['amavis']['installed'] == true && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
if($conf['rspamd']['installed'] == true && $conf['rspamd']['init_script'] != '') system($inst->getinitcommand($conf['rspamd']['init_script'], 'restart'));
if($conf['clamav']['installed'] == true && $conf['clamav']['init_script'] != '' && $conf['amavis']['installed'] == true) system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
if($conf['postfix']['installed'] == true && isset($conf['postfix']['init_script']) && $conf['postfix']['init_script'] != '') system($inst->getinitcommand($conf['postfix']['init_script'], 'restart'));
if($conf['saslauthd']['installed'] == true && isset($conf['saslauthd']['init_script']) && $conf['saslauthd']['init_script'] != '') system($inst->getinitcommand($conf['saslauthd']['init_script'], 'restart'));
if($conf['amavis']['installed'] == true && isset($conf['amavis']['init_script']) && $conf['amavis']['init_script'] != '') system($inst->getinitcommand($conf['amavis']['init_script'], 'restart'));
if($conf['rspamd']['installed'] == true && isset($conf['rspamd']['init_script']) && $conf['rspamd']['init_script'] != '') system($inst->getinitcommand($conf['rspamd']['init_script'], 'restart'));
if($conf['clamav']['installed'] == true && isset($conf['clamav']['init_script']) && $conf['clamav']['init_script'] != '' && $conf['amavis']['installed'] == true) system($inst->getinitcommand($conf['clamav']['init_script'], 'restart'));
if($conf['courier']['installed'] == true){
if($conf['courier']['courier-authdaemon'] != '') system($inst->getinitcommand($conf['courier']['courier-authdaemon'], 'restart'));
if($conf['courier']['courier-imap'] != '') system($inst->getinitcommand($conf['courier']['courier-imap'], 'restart'));
......@@ -621,8 +656,8 @@ if($reconfigure_services_answer == 'yes') {
if($conf['courier']['courier-pop'] != '') system($inst->getinitcommand($conf['courier']['courier-pop'], 'restart'));
if($conf['courier']['courier-pop-ssl'] != '') system($inst->getinitcommand($conf['courier']['courier-pop-ssl'], 'restart'));
}
if($conf['dovecot']['installed'] == true && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
if($conf['mailman']['installed'] == true && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
if($conf['dovecot']['installed'] == true && isset($conf['dovecot']['init_script']) && $conf['dovecot']['init_script'] != '') system($inst->getinitcommand($conf['dovecot']['init_script'], 'restart'));
if($conf['mailman']['installed'] == true && isset($conf['mailman']['init_script']) && $conf['mailman']['init_script'] != '') system('nohup '.$inst->getinitcommand($conf['mailman']['init_script'], 'restart').' >/dev/null 2>&1 &');
}
if($conf['services']['web'] || $inst->install_ispconfig_interface) {
if($conf['webserver']['server_type'] == 'apache') {
......@@ -636,27 +671,27 @@ if($reconfigure_services_answer == 'yes') {
//* Reload is enough for nginx
if($conf['webserver']['server_type'] == 'nginx'){
if($conf['nginx']['php_fpm_init_script'] != '') system($inst->getinitcommand($conf['nginx']['php_fpm_init_script'], 'reload'));
if($conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
if(isset($conf['nginx']['init_script']) && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'reload'));
}
if($conf['pureftpd']['installed'] == true && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
if($conf['pureftpd']['installed'] == true && isset($conf['pureftpd']['init_script']) && $conf['pureftpd']['init_script'] != '') system($inst->getinitcommand($conf['pureftpd']['init_script'], 'restart'));
}
if($conf['services']['dns']) {
if($conf['mydns']['installed'] == true && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
if($conf['powerdns']['installed'] == true && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
if($conf['bind']['installed'] == true && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
if($conf['mydns']['installed'] == true && isset($conf['mydns']['init_script']) && $conf['mydns']['init_script'] != '') system($inst->getinitcommand($conf['mydns']['init_script'], 'restart').' &> /dev/null');
if($conf['powerdns']['installed'] == true && isset($conf['powerdns']['init_script']) && $conf['powerdns']['init_script'] != '') system($inst->getinitcommand($conf['powerdns']['init_script'], 'restart').' &> /dev/null');
if($conf['bind']['installed'] == true && isset($conf['bind']['init_script']) && $conf['bind']['init_script'] != '') system($inst->getinitcommand($conf['bind']['init_script'], 'restart').' &> /dev/null');
}
if($conf['services']['xmpp']) {
if($conf['xmpp']['installed'] == true && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null');
if($conf['xmpp']['installed'] == true && isset($conf['xmpp']['init_script']) && $conf['xmpp']['init_script'] != '') system($inst->getinitcommand($conf['xmpp']['init_script'], 'restart').' &> /dev/null');
}
if($conf['services']['proxy']) {
// if($conf['squid']['installed'] == true && $conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
if($conf['nginx']['installed'] == true && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
// if($conf['squid']['installed'] == true && isset($conf['squid']['init_script']) && $conf['squid']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['squid']['init_script'])) system($conf['init_scripts'].'/'.$conf['squid']['init_script'].' restart &> /dev/null');
if($conf['nginx']['installed'] == true && isset($conf['nginx']['init_script']) && $conf['nginx']['init_script'] != '') system($inst->getinitcommand($conf['nginx']['init_script'], 'restart').' &> /dev/null');
}
if($conf['services']['firewall']) {
if($conf['ufw']['installed'] == true && $conf['ufw']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['ufw']['init_script'])) system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null');
if($conf['ufw']['installed'] == true && isset($conf['ufw']['init_script']) && $conf['ufw']['init_script'] != '' && is_executable($conf['init_scripts'].'/'.$conf['ufw']['init_script'])) system($conf['init_scripts'].'/'.$conf['ufw']['init_script'].' restart &> /dev/null');
}
}
......
......@@ -39,14 +39,14 @@ ob_start('ob_gzhandler');
if(isset($conf['timezone']) && $conf['timezone'] != '') date_default_timezone_set($conf['timezone']);
//* Set error reporting level when we are not on a developer system
if(DEVSYSTEM == 0) {
@ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_DEPRECATED);
if(DEVSYSTEM !== true) {
@ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_WARNING);
}
/*
Application Class
*/
class app {
class app extends stdClass {
private $_language_inc = 0;
private $_wb;
......
......@@ -47,12 +47,12 @@ class custom_datasource {
if($_SESSION["s"]["user"]["typ"] == 'user') {
// Get the limits of the client
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$client = $app->db->queryOneRecord("SELECT default_dnsserver FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
$sql = "SELECT server_id,server_name FROM server WHERE server_id = ?";
$client = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
$sql = "SELECT server_id,server_name FROM server WHERE server_id in (?)";
} else {
$sql = "SELECT server_id,server_name FROM server WHERE dns_server = 1 ORDER BY server_name AND mirror_server_id = 0";
}
$records = $app->db->queryAllRecords($sql, $client['default_dnsserver']);
$records = $app->db->queryAllRecords($sql, $client['dns_servers']);
$records_new = array();
if(is_array($records)) {
foreach($records as $rec) {
......
......@@ -82,6 +82,8 @@ class db
$this->dbClientFlags = ($flags !== NULL) ? $flags : $conf['db_client_flags'];
$this->_iConnId = mysqli_init();
mysqli_report(MYSQLI_REPORT_OFF);
mysqli_real_connect($this->_iConnId, $this->dbHost, $this->dbUser, $this->dbPass, '', (int)$this->dbPort, NULL, $this->dbClientFlags);
for($try=0;(!is_object($this->_iConnId) || mysqli_connect_errno()) && $try < 5;++$try) {
sleep($try);
......@@ -524,7 +526,7 @@ class db
$sString = '';
}
$cur_encoding = mb_detect_encoding($sString);
$cur_encoding = mb_detect_encoding($sString, "auto");
if($cur_encoding != "UTF-8") {
if($cur_encoding != 'ASCII') {
if(is_object($app) && method_exists($app, 'log')) $app->log('String ' . substr($sString, 0, 25) . '... is ' . $cur_encoding . '.', LOGLEVEL_DEBUG);
......@@ -823,12 +825,13 @@ class db
return true;
}
//** Deletes a record and saves the changes into the datalog
// Updates a datalog record to store an error state.
public function datalogError($errormsg) {
global $app;
if(isset($app->modules->current_datalog_id) && $app->modules->current_datalog_id > 0) $this->query("UPDATE sys_datalog set error = ? WHERE datalog_id = ?", $errormsg, $app->modules->current_datalog_id);
if(isset($app->modules->current_datalog_id) && $app->modules->current_datalog_id > 0) {
$this->query("UPDATE sys_datalog set error = ? WHERE datalog_id = ?", $errormsg, $app->modules->current_datalog_id);
}
return true;
}
......@@ -842,7 +845,11 @@ class db
$login = $_SESSION['s']['user']['username'];
}
$result = $this->queryAllRecords("SELECT COUNT( * ) AS cnt, sys_datalog.action, sys_datalog.dbtable FROM sys_datalog, server WHERE server.server_id = sys_datalog.server_id AND sys_datalog.user = ? AND sys_datalog.datalog_id > server.updated GROUP BY sys_datalog.dbtable, sys_datalog.action", $login);
$result = $this->queryAllRecords("SELECT COUNT( * ) AS cnt, sys_datalog.action, sys_datalog.dbtable
FROM sys_datalog, server
WHERE (server.server_id = sys_datalog.server_id or sys_datalog.server_id = 0) AND sys_datalog.user = ? AND sys_datalog.datalog_id > server.updated
GROUP BY sys_datalog.dbtable, sys_datalog.action",
$login);
foreach($result as $row) {
if(!$row['dbtable'] || in_array($row['dbtable'], array('aps_instances', 'aps_instances_settings', 'mail_access', 'mail_content_filter'))) continue; // ignore some entries, maybe more to come
$return['entries'][] = array('table' => $row['dbtable'], 'action' => $row['action'], 'count' => $row['cnt'], 'text' => $app->lng('datalog_status_' . $row['action'] . '_' . $row['dbtable'])); $return['count'] += $row['cnt'];
......
<?php
/*
Copyright (c) 2023, Adam Biciste <adam@freshost.cz>
All rights reserved.
Copyright (c) 2008, Till Brehm, projektfarm Gmbh
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the name of ISPConfig nor the names of its contributors
may be used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
class dns_wizard
{
function create(array $data)
{
global $app;
$app->uses('getconf');
// get system settings
$settings = $app->getconf->get_global_config();
$error = '';
// get the correct server_id
if (isset($data['server_id'])) {
$server_id = $app->functions->intval($data['server_id']);
$post_server_id = true;
} elseif (isset($data['server_id_value'])) {
$server_id = $app->functions->intval($data['server_id_value']);
$post_server_id = true;
} else {
$server_id = $app->functions->intval($settings['dns']['default_dnsserver']);
if(empty($server_id)) {
$tmp = $app->db->queryOneRecord('SELECT server_id FROM server WHERE dns_server = 1 LIMIT 0,1');
if(!empty($tmp['server_id'])) {
$server_id = $tmp['server_id'];
} else {
$error .= $app->lng('error_no_server_id').'<br />';
}
}
$post_server_id = false;
}
if ($post_server_id)
{
$client_group_id = $app->functions->intval($_SESSION["s"]["user"]["default_group"]);
$client = $app->db->queryOneRecord("SELECT dns_servers FROM sys_group, client WHERE sys_group.client_id = client.client_id and sys_group.groupid = ?", $client_group_id);
$client['dns_servers_ids'] = explode(',', $client['dns_servers']);
// Check if chosen server is in authorized servers for this client
if (!(is_array($client['dns_servers_ids']) && in_array($server_id, $client['dns_servers_ids'])) && $_SESSION["s"]["user"]["typ"] != 'admin') {
$error .= $app->lng('error_not_allowed_server_id').'<br />';
}
}
/*
else
{
$error .= $app->lng('error_no_server_id').'<br />';
}
*/
// apply filters
if(isset($data['domain']) && $data['domain'] != ''){
/* check if the domain module is used - and check if the selected domain can be used! */
if ($settings['domains']['use_domain_module'] == 'y') {
// get domain_id for domain
$tmp = $app->db->queryOneRecord('SELECT domain_id from domain where domain = ?', $data['domain']);
$domain_id = $app->functions->intval( $tmp['domain_id']);
if ($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) {
$data['client_group_id'] = $app->tools_sites->getClientIdForDomain($domain_id);
}
$domain_check = $app->tools_sites->checkDomainModuleDomain($domain_id);
if($domain_check === false) {
// invalid domain selected
$data['domain'] = '';
} else {
$data['domain'] = $domain_check;
}
} else {
$data['domain'] = $app->functions->idn_encode($data['domain']);
$data['domain'] = strtolower($data['domain']);
}
}
if(isset($data['ns1']) && $data['ns1'] != ''){
$data['ns1'] = $app->functions->idn_encode($data['ns1']);
$data['ns1'] = strtolower($data['ns1']);
}
if(isset($data['ns2']) && $data['ns2'] != ''){
$data['ns2'] = $app->functions->idn_encode($data['ns2']);
$data['ns2'] = strtolower($data['ns2']);
}
if(isset($data['email']) && $data['email'] != ''){
$data['email'] = $app->functions->idn_encode($data['email']);
$data['email'] = strtolower($data['email']);
}
# fixme: this regex is pretty poor for domain validation
if(isset($data['domain']) && $data['domain'] == '') $error .= $app->lng('error_domain_empty').'<br />';
elseif(isset($data['domain']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9\-]{2,63}$/', $data['domain'])) $error .= $app->lng('error_domain_regex').'<br />';
if(isset($data['ip']) && $data['ip'] == '') $error .= $app->lng('error_ip_empty').'<br />';
//if(isset($data['ipv6']) && $data['ipv6'] == '') $error .= $app->lng('error_ipv6_empty').'<br />';
# fixme: this regex is pretty poor for hostname validation
if(isset($data['ns1']) && $data['ns1'] == '') $error .= $app->lng('error_ns1_empty').'<br />';
elseif(isset($data['ns1']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9]{2,63}$/', $data['ns1'])) $error .= $app->lng('error_ns1_regex').'<br />';
if(isset($data['ns2']) && $data['ns2'] == '') $error .= $app->lng('error_ns2_empty').'<br />';
elseif(isset($data['ns2']) && !preg_match('/^[\w\.\-]{1,64}\.[a-zA-Z0-9]{2,63}$/', $data['ns2'])) $error .= $app->lng('error_ns2_regex').'<br />';
if(isset($data['email']) && $data['email'] == '') $error .= $app->lng('error_email_empty').'<br />';
elseif(isset($data['email']) && filter_var($data['email'], FILTER_VALIDATE_EMAIL) === false) $error .= $app->lng('error_email_regex').'<br />';
// make sure that the record belongs to the client group and not the admin group when admin inserts it
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($data['client_group_id'])) {
$sys_groupid = $app->functions->intval($data['client_group_id']);
} elseif($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($data['client_group_id'])) {
$sys_groupid = $app->functions->intval($data['client_group_id']);
} else {
$sys_groupid = $_SESSION["s"]["user"]["default_group"];
}
$tform_def_file = "../../web/dns/form/dns_soa.tform.php";
$app->uses('tform');
$app->tform->loadFormDef($tform_def_file);
if($_SESSION['s']['user']['typ'] != 'admin') {
if(!$app->tform->checkClientLimit('limit_dns_zone')) {
$error .= $app->tform->wordbook["limit_dns_zone_txt"];
}
if(!$app->tform->checkResellerLimit('limit_dns_zone')) {
$error .= $app->tform->wordbook["limit_dns_zone_txt"];
}
}
// replace template placeholders
$template_id = (isset($data['template_id']))?$app->functions->intval($data['template_id']):0;
$template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $template_id);
$tpl_content = $template_record['template'];
if($data['domain'] != '') $tpl_content = str_replace('{DOMAIN}', $data['domain'], $tpl_content);
if($data['ip'] != '') $tpl_content = str_replace('{IP}', $data['ip'], $tpl_content);
if($data['ipv6'] != '') $tpl_content = str_replace('{IPV6}',$data['ipv6'],$tpl_content);
if($data['ns1'] != '') $tpl_content = str_replace('{NS1}', $data['ns1'], $tpl_content);
if($data['ns2'] != '') $tpl_content = str_replace('{NS2}', $data['ns2'], $tpl_content);
if($data['email'] != '') $tpl_content = str_replace('{EMAIL}', $data['email'], $tpl_content);
// $enable_dnssec = (($data['dnssec'] == 'Y') ? 'Y' : 'N');
// if(isset($data['dnssec'])) $vars['dnssec_wanted'] = 'Y';
if(isset($data['dnssec'])) $tpl_content = str_replace('[ZONE]', '[ZONE]'."\n".'dnssec_wanted=Y', $tpl_content);
if(isset($data['dkim']) && preg_match('/^[\w\.\-\/]{1,255}\.[a-zA-Z0-9\-]{2,63}[\.]{0,1}$/', $data['domain'])) {
$sql = $app->db->queryOneRecord("SELECT dkim_public, dkim_selector FROM mail_domain WHERE domain = ? AND dkim = 'y' AND ".$app->tform->getAuthSQL('r'), $data['domain']);
$public_key = $sql['dkim_public'];
if ($public_key!='') {
if (empty($sql['dkim_selector'])) $sql['dkim_selector'] = 'default';
$dns_record=str_replace(array("\r\n", "\n", "\r", "-----BEGIN PUBLIC KEY-----", "-----END PUBLIC KEY-----"), '', $public_key);
$tpl_content .= "\n".'TXT|'.$sql['dkim_selector'].'._domainkey.'.$data['domain'].'.|v=DKIM1; t=s; p='.$dns_record;
}
}
// Parse the template
$tpl_rows = explode("\n", $tpl_content);
$section = '';
$vars = array();
$vars['xfer']='';
$vars['dnssec_wanted']='N';
$vars['dnssec_algo']='ECDSAP256SHA256';
$dns_rr = array();
foreach($tpl_rows as $row) {
$row = trim($row);
if(substr($row, 0, 1) == '[') {
if($row == '[ZONE]') {
$section = 'zone';
} elseif($row == '[DNS_RECORDS]') {
$section = 'dns_records';
} else {
die('Unknown section type');
}
} else {
if($row != '') {
// Handle zone section
if($section == 'zone') {
$parts = explode('=', $row);
$key = trim($parts[0]);
$val = trim($parts[1]);
if($key != '') $vars[$key] = $val;
}
// Handle DNS Record rows
if($section == 'dns_records') {
$parts = explode('|', $row);
$dns_rr[] = array(
'name' => $parts[1],
'type' => $parts[0],
'data' => $parts[2],
'aux' => $parts[3],
'ttl' => $parts[4]
);
}
}
}
} // end foreach
if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'<br />';
if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'<br />';
if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'<br />';
if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty').'<br />';
if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'<br />';
if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'<br />';
if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'<br />';
if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'<br />';
if($error == '') {
// Insert the soa record
$sys_userid = $_SESSION['s']['user']['userid'];
$origin = $vars['origin'];
$ns = $vars['ns'];
$mbox = str_replace('@', '.', $vars['mbox']);
$refresh = $vars['refresh'];
$retry = $vars['retry'];
$expire = $vars['expire'];
$minimum = $vars['minimum'];
$ttl = $vars['ttl'];
$xfer = $vars['xfer'];
$also_notify = $vars['also_notify'];
$update_acl = $vars['update_acl'];
$dnssec_wanted = $vars['dnssec_wanted'];
$dnssec_algo = $vars['dnssec_algo'];
$serial = $app->validate_dns->increase_serial(0);
$insert_data = array(
"sys_userid" => $sys_userid,
"sys_groupid" => $sys_groupid,
"sys_perm_user" => 'riud',
"sys_perm_group" => 'riud',
"sys_perm_other" => '',
"server_id" => $server_id,
"origin" => $origin,
"ns" => $ns,
"mbox" => $mbox,
"serial" => $serial,
"refresh" => $refresh,
"retry" => $retry,
"expire" => $expire,
"minimum" => $minimum,
"ttl" => $ttl,
"active" => 'N', // Activated later when all DNS records are added.
"xfer" => $xfer,
"also_notify" => $also_notify,
"update_acl" => $update_acl,
"dnssec_wanted" => $dnssec_wanted,
"dnssec_algo" => $dnssec_algo
);
$dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id');
if($dns_soa_id > 0) $app->plugin->raiseEvent('dns:wizard:on_after_insert', $dns_soa_id);
// Insert the dns_rr records
if(is_array($dns_rr) && $dns_soa_id > 0) {
foreach($dns_rr as $rr) {
$insert_data = array(
"sys_userid" => $sys_userid,
"sys_groupid" => $sys_groupid,
"sys_perm_user" => 'riud',
"sys_perm_group" => 'riud',
"sys_perm_other" => '',
"server_id" => $server_id,
"zone" => $dns_soa_id,
"name" => $rr['name'],
"type" => $rr['type'],
"data" => $rr['data'],
"aux" => $rr['aux'],
"ttl" => $rr['ttl'],
"active" => 'Y'
);
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id');
}
}
// Activate the DNS zone.
$app->db->datalogUpdate('dns_soa', array('active' => 'Y'), 'id', $dns_soa_id);
return 'ok';
} else {
return $error;
}
}
}
......@@ -169,7 +169,7 @@ class ispcmail {
$this->smtp_host = $value;
break;
case 'smtp_port':
if(intval($value) > 0) $this->smtp_port = $value;
if(intval($value) > 0) $this->smtp_port = intval($value);
break;
case 'smtp_user':
$this->smtp_user = $value;
......@@ -585,7 +585,7 @@ class ispcmail {
* @access private
*/
private function _smtp_login() {
$this->_smtp_conn = fsockopen(($this->smtp_crypt == 'ssl' ? 'tls://' : '') . $this->smtp_host, $this->smtp_port, $errno, $errstr, 30);
$this->_smtp_conn = fsockopen(($this->smtp_crypt == 'ssl' ? 'tls://' : '') . $this->smtp_host, (int)$this->smtp_port, $errno, $errstr, 30);
if(empty($this->_smtp_conn)) return false;
$response = fgets($this->_smtp_conn, 515);
......@@ -823,7 +823,7 @@ class ispcmail {
$recipname = trim(str_replace('"', '', $recipname));
if($rec_string != '') $rec_string .= ', ';
if($recipname && !is_numeric($recipname)) $rec_string .= $recipname . '<' . $recip . '>';
if($recipname && !is_numeric($recipname)) $rec_string .= '"' . $recipname . '"<' . $recip . '>';
else $rec_string .= $recip;
}
$to = $this->_encodeHeader($rec_string, $this->mail_charset);
......
......@@ -80,7 +80,7 @@ class listform {
private function getDatasourceData($field)
{
global $app;
global $app, $api;
$values = array();
if($field['datasource']['type'] == 'SQL') {
......@@ -97,7 +97,8 @@ class listform {
$querystring = str_replace("{AUTHSQL}", $app->tform->getAuthSQL('r'), $querystring);
$querystring = str_replace("{AUTHSQL-A}", $app->tform->getAuthSQL('r', 'a'), $querystring);
$querystring = str_replace("{AUTHSQL-B}", $app->tform->getAuthSQL('r', 'b'), $querystring);
$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring);
//$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', create_function('$matches','global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;'), $querystring);
$querystring = preg_replace_callback('@{AUTHSQL::(.+?)}@', function($matches) {global $app; $tmp = $app->tform->getAuthSQL("r", $matches[1]); return $tmp;}, $querystring);
//* Getting the records
$tmp_records = $app->db->queryAllRecords($querystring);
......@@ -195,9 +196,9 @@ class listform {
if(@is_array($this->listDef['item'])) {
foreach($this->listDef['item'] as $i) {
$field = $i['field'];
$table = $i['table'];
$table = (isset($i['table']))?$i['table']:'';
$searchval = $_SESSION['search'][$list_name][$search_prefix.$field];
$searchval = (isset($_SESSION['search'][$list_name][$search_prefix.$field]))?$_SESSION['search'][$list_name][$search_prefix.$field]:'';
// IDN
if($searchval != ''){
if(is_array($i['filters'])) {
......@@ -325,7 +326,7 @@ class listform {
if($this->searchChanged == 1) $_SESSION['search'][$list_name]['page'] = 0;
$sql_von = $app->functions->intval($_SESSION['search'][$list_name]['page'] * $records_per_page);
$record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM ??".($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where", $table);
$record_count = $app->db->queryOneRecord("SELECT count(*) AS anzahl FROM ??".(isset($app->listform->listDef['additional_tables']) && $app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')." WHERE $sql_where", $table);
$pages = $app->functions->intval(($record_count['anzahl'] - 1) / $records_per_page);
......
......@@ -135,7 +135,7 @@ class listform_actions {
}
}
if($_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) $php_sort = true;
if(@$_SESSION['search'][$_SESSION['s']['module']['name'].$app->listform->listDef["name"].$app->listform->listDef['table']]['order_in_php']) $php_sort = true;
// Getting Datasets from DB
$records = $app->db->queryAllRecords($this->getQueryString($php_sort));
......@@ -189,7 +189,7 @@ class listform_actions {
//* substitute value for select fields
if(is_array($app->listform->listDef['item']) && count($app->listform->listDef['item']) > 0) {
foreach($app->listform->listDef['item'] as $field) {
if($rec['active'] == 'n') $rec['warn_inactive'] = 'y';
if(isset($rec['active']) && $rec['active'] == 'n') $rec['warn_inactive'] = 'y';
$key = $field['field'];
if(isset($field['formtype']) && $field['formtype'] == 'SELECT') {
if(strtolower($rec[$key]) == 'y' or strtolower($rec[$key]) == 'n') {
......@@ -226,7 +226,7 @@ class listform_actions {
}
$sql_where = $app->listform->getSearchSQL($sql_where);
if($app->listform->listDef['join_sql']) $sql_where .= ' AND '.$app->listform->listDef['join_sql'];
if(isset($app->listform->listDef['join_sql']) && $app->listform->listDef['join_sql'] != '') $sql_where .= ' AND '.$app->listform->listDef['join_sql'];
$app->tpl->setVar($app->listform->searchValues);
$order_by_sql = $this->SQLOrderBy;
......@@ -245,8 +245,9 @@ class listform_actions {
$table_selects = array();
$table_selects[] = trim($app->listform->listDef['table']).'.*';
$app->listform->listDef['additional_tables'] = trim($app->listform->listDef['additional_tables']);
if($app->listform->listDef['additional_tables'] != ''){
if(isset($app->listform->listDef['additional_tables']) && trim($app->listform->listDef['additional_tables']) != ''){
$app->listform->listDef['additional_tables'] = trim($app->listform->listDef['additional_tables']);
$additional_tables = explode(',', $app->listform->listDef['additional_tables']);
foreach($additional_tables as $additional_table){
$table_selects[] = trim($additional_table).'.*';
......@@ -254,7 +255,7 @@ class listform_actions {
}
$select = implode(', ', $table_selects);
$sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].($app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql";
$sql = 'SELECT '.$select.$extselect.' FROM '.$app->listform->listDef['table'].(isset($app->listform->listDef['additional_tables']) && $app->listform->listDef['additional_tables'] != ''? ','.$app->listform->listDef['additional_tables'] : '')."$join WHERE $sql_where $order_by_sql";
if($no_limit == false) $sql .= " $limit_sql";
//echo $sql;
return $sql;
......
......@@ -326,7 +326,7 @@ class quota_lib {
if($used_ratio >= 0.8) $databases[$i]['display_colour'] = '#fd934f';
if($used_ratio >= 1) $databases[$i]['display_colour'] = '#cc0000';
if($databases[$i]['database_quota'] == 0){
if($databases[$i]['database_quota'] == -1) {
$databases[$i]['database_quota'] = $app->lng('unlimited_txt');
} else {
$databases[$i]['database_quota'] = $databases[$i]['database_quota'] . ' MB';
......
......@@ -44,143 +44,41 @@ class remoting_dns extends remoting {
//* Create Zone with Template
public function dns_templatezone_add($session_id, $client_id, $template_id, $domain, $ip, $ns1, $ns2, $email, $ipv6 = '') {
global $app, $conf;
if(!$this->checkPerm($session_id, 'dns_templatezone_add')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
}
$client = $app->db->queryOneRecord("SELECT default_dnsserver FROM client WHERE client_id = ?", $client_id);
$server_id = $client["default_dnsserver"];
$template_record = $app->db->queryOneRecord("SELECT * FROM dns_template WHERE template_id = ?", $template_id);
$fields = explode(',', $template_record['fields']);
$tform_def_file = "../../web/dns/form/dns_soa.tform.php";
$app->uses('tform');
$app->tform->loadFormDef($tform_def_file);
$app->uses('tpl,validate_dns,remoting_lib');
$client_id = $app->functions->intval($client_id);
// Get client group id
$rec = $app->db->queryOneRecord("SELECT groupid FROM sys_group WHERE client_id = ?", $client_id);
if(isset($rec['groupid'])) {
$client_group_id = $app->functions->intval($rec['groupid']);
} else {
throw new SoapFault('no_group_found', 'There is no group for this client ID.');
return false;
}
$app->uses('remoting_lib,dns_wizard');
$app->remoting_lib->loadUserProfile($client_id);
//* replace template placeholders
$tpl_content = $template_record['template'];
if($domain != '') $tpl_content = str_replace('{DOMAIN}', $domain, $tpl_content);
if($ip != '') $tpl_content = str_replace('{IP}', $ip, $tpl_content);
if($ipv6 != '') $tpl_content = str_replace('{IPV6}', $ipv6, $tpl_content);
if($ns1 != '') $tpl_content = str_replace('{NS1}', $ns1, $tpl_content);
if($ns2 != '') $tpl_content = str_replace('{NS2}', $ns2, $tpl_content);
if($email != '') $tpl_content = str_replace('{EMAIL}', $email, $tpl_content);
//* Parse the template
$tpl_rows = explode("\n", $tpl_content);
$section = '';
$vars = array();
$dns_rr = array();
foreach($tpl_rows as $row) {
$row = trim($row);
if(substr($row, 0, 1) == '[') {
if($row == '[ZONE]') {
$section = 'zone';
} elseif($row == '[DNS_RECORDS]') {
$section = 'dns_records';
} else {
die('Unknown section type');
}
} else {
if($row != '') {
//* Handle zone section
if($section == 'zone') {
$parts = explode('=', $row);
$key = trim($parts[0]);
$val = trim($parts[1]);
if($key != '') $vars[$key] = $val;
}
//* Handle DNS Record rows
if($section == 'dns_records') {
$parts = explode('|', $row);
$dns_rr[] = array(
'name' => $parts[1],
'type' => $parts[0],
'data' => $parts[2],
'aux' => $parts[3],
'ttl' => $parts[4]
);
}
}
}
} // end foreach
if($vars['origin'] == '') $error .= $app->lng('error_origin_empty').'<br />';
if($vars['ns'] == '') $error .= $app->lng('error_ns_empty').'<br />';
if($vars['mbox'] == '') $error .= $app->lng('error_mbox_empty').'<br />';
if($vars['refresh'] == '') $error .= $app->lng('error_refresh_empty').'<br />';
if($vars['retry'] == '') $error .= $app->lng('error_retry_empty').'<br />';
if($vars['expire'] == '') $error .= $app->lng('error_expire_empty').'<br />';
if($vars['minimum'] == '') $error .= $app->lng('error_minimum_empty').'<br />';
if($vars['ttl'] == '') $error .= $app->lng('error_ttl_empty').'<br />';
if(!isset($vars['xfer'])) $vars['xfer'] = '';
if($error == '') {
// Insert the soa record
$tmp = $app->db->queryOneRecord("SELECT userid,default_group FROM sys_user WHERE client_id = ?", $client_id);
$sys_userid = $tmp['userid'];
$sys_groupid = $tmp['default_group'];
unset($tmp);
$origin = $vars['origin'];
$ns = $vars['ns'];
$mbox = str_replace('@', '.', $vars['mbox']);
$refresh = $vars['refresh'];
$retry = $vars['retry'];
$expire = $vars['expire'];
$minimum = $vars['minimum'];
$ttl = $vars['ttl'];
$xfer = $vars['xfer'];
$also_notify = $vars['also_notify'];
$update_acl = $vars['update_acl'];
$serial = $app->validate_dns->increase_serial(0);
$insert_data = array(
"sys_userid" => $sys_userid,
"sys_groupid" => $sys_groupid,
"sys_perm_user" => 'riud',
"sys_perm_group" => 'riud',
"sys_perm_other" => '',
"server_id" => $server_id,
"origin" => $origin,
"ns" => $ns,
"mbox" => $mbox,
"serial" => $serial,
"refresh" => $refresh,
"retry" => $retry,
"expire" => $expire,
"minimum" => $minimum,
"ttl" => $ttl,
"active" => 'Y',
"xfer" => $xfer,
"also_notify" => $also_notify,
"update_acl" => $update_acl
);
$dns_soa_id = $app->db->datalogInsert('dns_soa', $insert_data, 'id');
// Insert the dns_rr records
if(is_array($dns_rr) && $dns_soa_id > 0) {
foreach($dns_rr as $rr) {
$insert_data = array(
"sys_userid" => $sys_userid,
"sys_groupid" => $sys_groupid,
"sys_perm_user" => 'riud',
"sys_perm_group" => 'riud',
"sys_perm_other" => '',
"server_id" => $server_id,
"zone" => $dns_soa_id,
"name" => $rr['name'],
"type" => $rr['type'],
"data" => $rr['data'],
"aux" => $rr['aux'],
"ttl" => $rr['ttl'],
"active" => 'Y'
);
$dns_rr_id = $app->db->datalogInsert('dns_rr', $insert_data, 'id');
}
}
exit;
$create = $app->dns_wizard->create([
'client_group_id' => $client_group_id,
'template_id' => $template_id,
'domain' => $domain,
'ip' => $ip,
'ns1' => $ns1,
'ns2' => $ns2,
'email' => $email,
'ipv6' => $ipv6,
]);
if ($create == 'ok') {
return true;
} else {
throw new SoapFault('permission_denied', $error);
throw new SoapFault('dns_wizard_error', $create);
return false;
}
}
......@@ -844,6 +742,39 @@ class remoting_dns extends remoting {
return false;
}
}
/*
* Set DNSSec Algo and activate it if needed.
*
* @param int session id
* @param int client id
* @param string algorithm 'NSEC3RSASHA1', 'ECDSAP256SHA256' or 'NSEC3RSASHA1,ECDSAP256SHA256' string
* @param boolean update serial
*
* @author Tom Albers <kovoks@kovoks.nl> KovoKs B.V. 2023
*/
public function dns_zone_set_dnssec($session_id, $client_id, $primary_id, $algo, $update_serial=false) {
global $app;
if(!$this->checkPerm($session_id, 'dns_zone_set_status')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
if(!in_array($algo, ['NSEC3RSASHA1', 'ECDSAP256SHA256', 'NSEC3RSASHA1,ECDSAP256SHA256'])) {
throw new SoapFault('permission_denied', 'You are not using a valid algorithm for this function.');
return false;
}
$params["dnssec_wanted"] = "Y";
$params["dnssec_algo"] = $algo;
$affected_rows = $this->updateQuery('../dns/form/dns_soa.tform.php', $client_id, $primary_id, $params);
if($update_serial) {
$this->increase_serial($session_id, $client_id, ["zone" => $primary_id]);
}
return $affected_rows;
}
private function increase_serial($session_id, $client_id, $params) {
global $app;
......
......@@ -60,6 +60,10 @@ class remoting_mail extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// set default value for dkim selector if not set in $params array
if(!isset($params['dkim_selector'])) $params['dkim_selector'] = 'default';
$primary_id = $this->insertQuery('../mail/form/mail_domain.tform.php', $client_id, $params, 'mail:mail_domain:on_after_insert');
return $primary_id;
}
......@@ -223,7 +227,7 @@ class remoting_mail extends remoting {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
// Email addresses must always be lower case
$params['email'] = strtolower($params['email']);
......@@ -331,17 +335,17 @@ class remoting_mail extends remoting {
// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
return $affected_rows;
}
// Mail backup list function by Dominik Müller, info@profi-webdesign.net
// Mail backup list function by Dominik M�ller, info@profi-webdesign.net
public function mail_user_backup_list($session_id, $primary_id = null)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_user_backup')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$params = array();
if ($site_id != null) {
$params[] = $site_id;
......@@ -350,47 +354,47 @@ class remoting_mail extends remoting {
else {
$sql = "SELECT * FROM mail_backup";
}
$result = $app->db->queryAllRecords($sql, true, $params);
return $result;
}
// Mail backup restore/download functions by Dominik Müller, info@profi-webdesign.net
// Mail backup restore/download functions by Dominik M�ller, info@profi-webdesign.net
public function mail_user_backup($session_id, $primary_id, $action_type)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_user_backup')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
//*Set variables
$backup_record = $app->db->queryOneRecord("SELECT * FROM `mail_backup` WHERE `backup_id`=?", $primary_id);
$server_id = $backup_record['server_id'];
//*Set default action state
$action_state = "pending";
$tstamp = time();
//* Basic validation of variables
if ($server_id <= 0) {
throw new SoapFault('invalid_backup_id', "Invalid or non existant backup_id $primary_id");
return false;
}
if (/*$action_type != 'backup_download_mail' and*/ $action_type != 'backup_restore_mail' and $action_type != 'backup_delete_mail') {
throw new SoapFault('invalid_action', "Invalid action_type $action_type");
return false;
}
//* Validate instance
$instance_record = $app->db->queryOneRecord("SELECT * FROM `sys_remoteaction` WHERE `action_param`=? and `action_type`=? and `action_state`='pending'", $primary_id, $action_type);
if ($instance_record['action_id'] >= 1) {
throw new SoapFault('duplicate_action', "There is already a pending $action_type action");
return false;
}
//* Save the record
if ($app->db->query("INSERT INTO `sys_remoteaction` SET `server_id` = ?, `tstamp` = ?, `action_type` = ?, `action_param` = ?, `action_state` = ?", $server_id, $tstamp, $action_type, $primary_id, $action_state)) {
return true;
......@@ -666,7 +670,55 @@ class remoting_mail extends remoting {
$affected_rows = $this->deleteQuery('../mail/form/mail_relay_recipient.tform.php', $primary_id);
return $affected_rows;
}
//* add relay domain
public function mail_relay_domain_add($session_id, $client_id, $params)
{
if(!$this->checkPerm($session_id, 'mail_relay_add'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->insertQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $params);
return $affected_rows;
}
public function mail_relay_domain_delete($session_id, $primary_id)
{
if(!$this->checkPerm($session_id, 'mail_relay_delete'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->deleteQuery('../mail/form/mail_relay_domain.tform.php', $primary_id);
return $affected_rows;
}
public function mail_relay_domain_get($session_id, $primary_id)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_relay_get'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../mail/form/mail_relay_domain.tform.php');
return $app->remoting_lib->getDataRecord($primary_id);
}
public function mail_relay_domain_update($session_id, $client_id, $primary_id, $params)
{
if(!$this->checkPerm($session_id, 'mail_relay_update'))
{
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->updateQuery('../mail/form/mail_relay_domain.tform.php', $client_id, $primary_id, $params);
return $affected_rows;
}
//* Get spamfilter whitelist details
public function mail_spamfilter_whitelist_get($session_id, $primary_id)
{
......@@ -1117,12 +1169,12 @@ class remoting_mail extends remoting {
{
global $app;
$app->uses('quota_lib');
if(!$this->checkPerm($session_id, 'mailquota_get_by_user')) {
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
return $app->quota_lib->get_mailquota_data($client_id, false);
}
......
......@@ -13186,8 +13186,8 @@ class SimplePie_Parse_Date
*/
function __construct()
{
$this->day_pcre = '(' . implode(array_keys($this->day), '|') . ')';
$this->month_pcre = '(' . implode(array_keys($this->month), '|') . ')';
$this->day_pcre = '(' . implode('|', array_keys($this->day)) . ')';
$this->month_pcre = '(' . implode('|', array_keys($this->month)) . ')';
static $cache;
if (!isset($cache[get_class($this)]))
......@@ -13338,9 +13338,9 @@ class SimplePie_Parse_Date
}
// Convert the number of seconds to an integer, taking decimals into account
$second = @round($match[6] + $match[7] / @pow(10, strlen($match[7])));
$second = @round((int)$match[6] + (int)$match[7] / @pow(10, strlen($match[7])));
return gmmktime($match[4], $match[5], $second, $match[2], $match[3], $match[1]) - $timezone;
return gmmktime((int)$match[4], (int)$match[5], (int)$second, (int)$match[2], (int)$match[3], (int)$match[1]) - $timezone;
}
else
{
......
......@@ -33,6 +33,7 @@ class system {
var $client_service = null;
private $_last_exec_out = null;
private $_last_exec_retcode = null;
private $server_count = null;
public function has_service($userid, $service) {
global $app;
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.