Commit 10b4c85a authored by tbrehm's avatar tbrehm
Browse files

Merged revisons 3687-3748 from 3.0.5 stable branch.

parent 3ee39be0
......@@ -941,6 +941,11 @@ class installer_dist extends installer_base {
} else {
$content = str_replace('{ssl_comment}', '#', $content);
}
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
$content = str_replace('{ssl_bundle_comment}', '', $content);
} else {
$content = str_replace('{ssl_bundle_comment}', '#', $content);
}
wf("$vhost_conf_dir/ispconfig.vhost", $content);
......@@ -972,11 +977,11 @@ class installer_dist extends installer_base {
$content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content);
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
$content = str_replace('{ssl_on}', ' ssl', $content);
$content = str_replace('{ssl_on}', ' on', $content);
$content = str_replace('{ssl_comment}', '', $content);
$content = str_replace('{fastcgi_ssl}', 'on', $content);
} else {
$content = str_replace('{ssl_on}', '', $content);
$content = str_replace('{ssl_on}', ' off', $content);
$content = str_replace('{ssl_comment}', '#', $content);
$content = str_replace('{fastcgi_ssl}', 'off', $content);
}
......
......@@ -929,6 +929,11 @@ class installer extends installer_base
} else {
$content = str_replace('{ssl_comment}', '#', $content);
}
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
$content = str_replace('{ssl_bundle_comment}', '', $content);
} else {
$content = str_replace('{ssl_bundle_comment}', '#', $content);
}
$vhost_path = $conf['apache']['vhost_conf_dir'].'/ispconfig.vhost';
$this->write_config_file($vhost_path, $content);
......@@ -954,11 +959,11 @@ class installer extends installer_base
$content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content);
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
$content = str_replace('{ssl_on}', ' ssl', $content);
$content = str_replace('{ssl_on}', ' on', $content);
$content = str_replace('{ssl_comment}', '', $content);
$content = str_replace('{fastcgi_ssl}', 'on', $content);
} else {
$content = str_replace('{ssl_on}', '', $content);
$content = str_replace('{ssl_on}', ' off', $content);
$content = str_replace('{ssl_comment}', '#', $content);
$content = str_replace('{fastcgi_ssl}', 'off', $content);
}
......
......@@ -977,6 +977,11 @@ class installer_dist extends installer_base {
} else {
$content = str_replace('{ssl_comment}', '#', $content);
}
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
$content = str_replace('{ssl_bundle_comment}', '', $content);
} else {
$content = str_replace('{ssl_bundle_comment}', '#', $content);
}
$content = str_replace('/var/www/', '/srv/www/', $content);
......@@ -1015,11 +1020,11 @@ class installer_dist extends installer_base {
$content = str_replace('{vhost_port}', $conf['nginx']['vhost_port'], $content);
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key')) {
$content = str_replace('{ssl_on}', ' ssl', $content);
$content = str_replace('{ssl_on}', ' on', $content);
$content = str_replace('{ssl_comment}', '', $content);
$content = str_replace('{fastcgi_ssl}', 'on', $content);
} else {
$content = str_replace('{ssl_on}', '', $content);
$content = str_replace('{ssl_on}', ' off', $content);
$content = str_replace('{ssl_comment}', '#', $content);
$content = str_replace('{fastcgi_ssl}', 'off', $content);
}
......
......@@ -1885,6 +1885,11 @@ class installer_base {
} else {
$content = str_replace('{ssl_comment}', '#', $content);
}
if(is_file($install_dir.'/interface/ssl/ispserver.crt') && is_file($install_dir.'/interface/ssl/ispserver.key') && is_file($install_dir.'/interface/ssl/ispserver.bundle')) {
$content = str_replace('{ssl_bundle_comment}', '', $content);
} else {
$content = str_replace('{ssl_bundle_comment}', '#', $content);
}
wf($vhost_conf_dir.'/ispconfig.vhost', $content);
......
ALTER TABLE `web_database` ADD `database_name_prefix` VARCHAR( 50 ) NOT NULL AFTER `database_name`;
UPDATE `web_database` SET `database_name_prefix` = '#' WHERE 1;
ALTER TABLE `web_database_user` ADD `database_user_prefix` VARCHAR( 50 ) NOT NULL AFTER `database_user`;
UPDATE `web_database_user` SET `database_user_prefix` = '#' WHERE 1;
ALTER TABLE `ftp_user` ADD `username_prefix` VARCHAR( 50 ) NOT NULL AFTER `username`;
UPDATE `ftp_user` SET `username_prefix` = '#' WHERE 1;
ALTER TABLE `shell_user` ADD `username_prefix` VARCHAR( 50 ) NOT NULL AFTER `username`;
UPDATE `shell_user` SET `username_prefix` = '#' WHERE 1;
ALTER TABLE `webdav_user` ADD `username_prefix` VARCHAR( 50 ) NOT NULL AFTER `username`;
UPDATE `webdav_user` SET `username_prefix` = '#' WHERE 1;
\ No newline at end of file
......@@ -526,6 +526,7 @@ CREATE TABLE `ftp_user` (
`server_id` int(11) unsigned NOT NULL default '0',
`parent_domain_id` int(11) unsigned NOT NULL default '0',
`username` varchar(64) default NULL,
`username_prefix` varchar(50) NOT NULL default '',
`password` varchar(64) default NULL,
`quota_size` bigint(20) NOT NULL default '-1',
`active` enum('n','y') NOT NULL default 'y',
......@@ -1179,6 +1180,7 @@ CREATE TABLE `shell_user` (
`server_id` int(11) unsigned NOT NULL default '0',
`parent_domain_id` int(11) unsigned NOT NULL default '0',
`username` varchar(64) default NULL,
`username_prefix` varchar(50) NOT NULL default '',
`password` varchar(64) default NULL,
`quota_size` bigint(20) NOT NULL default '-1',
`active` enum('n','y') NOT NULL default 'y',
......@@ -1608,6 +1610,7 @@ CREATE TABLE `webdav_user` (
`server_id` int(11) unsigned NOT NULL DEFAULT '0',
`parent_domain_id` int(11) unsigned NOT NULL DEFAULT '0',
`username` varchar(64) DEFAULT NULL,
`username_prefix` varchar(50) NOT NULL default '',
`password` varchar(64) DEFAULT NULL,
`active` enum('n','y') NOT NULL DEFAULT 'y',
`dir` varchar(255) DEFAULT NULL,
......@@ -1648,6 +1651,7 @@ CREATE TABLE `web_database` (
`parent_domain_id` int(11) unsigned NOT NULL DEFAULT '0',
`type` varchar(16) NOT NULL DEFAULT 'y',
`database_name` varchar(64) DEFAULT NULL,
`database_name_prefix` varchar(50) NOT NULL default '',
`database_user_id` int(11) unsigned DEFAULT NULL,
`database_ro_user_id` int(11) unsigned DEFAULT NULL,
`database_charset` varchar(64) DEFAULT NULL,
......@@ -1676,6 +1680,7 @@ CREATE TABLE IF NOT EXISTS `web_database_user` (
`sys_perm_other` varchar(5) DEFAULT NULL,
`server_id` int(11) UNSIGNED NOT NULL DEFAULT '0',
`database_user` varchar(64) DEFAULT NULL,
`database_user_prefix` varchar(50) NOT NULL default '',
`database_password` varchar(64) DEFAULT NULL,
PRIMARY KEY (`database_user_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......
......@@ -25,6 +25,7 @@ NameVirtualHost *:{vhost_port}
Order allow,deny
Allow from all
</Directory>
IPCCommTimeout 7200
</IfModule>
# <IfModule mod_php5.c>
......@@ -52,6 +53,7 @@ NameVirtualHost *:{vhost_port}
{ssl_comment}SSLEngine On
{ssl_comment}SSLCertificateFile /usr/local/ispconfig/interface/ssl/ispserver.crt
{ssl_comment}SSLCertificateKeyFile /usr/local/ispconfig/interface/ssl/ispserver.key
{ssl_bundle_comment}SSLCACertificateFile /usr/local/ispconfig/interface/ssl/ispserver.bundle
</VirtualHost>
......
......@@ -44,7 +44,6 @@ website_basedir=/var/www
website_path=/var/www/clients/client[client_id]/web[website_id]
website_symlinks=/var/www/[website_domain]/:/var/www/clients/client[client_id]/[website_domain]/
website_symlinks_rel=n
vhost_rewrite_v6=n
vhost_conf_dir=/etc/apache2/sites-available
vhost_conf_enabled_dir=/etc/apache2/sites-enabled
nginx_vhost_conf_dir=/etc/nginx/sites-available
......
......@@ -22,6 +22,7 @@ webdavuser_prefix=[CLIENTNAME]
dblist_phpmyadmin_link=y
phpmyadmin_url=/phpmyadmin
webftp_url=
client_username_web_check_disabled=n
[tools]
......@@ -34,4 +35,8 @@ dashboard_atom_url_admin=http://www.ispconfig.org/atom
dashboard_atom_url_reseller=http://www.ispconfig.org/atom
dashboard_atom_url_client=http://www.ispconfig.org/atom
monitor_key=
tab_change_discard=n
tab_change_warning=n
use_loadindicator=y
use_combobox=y
maintenance_mode=n
......@@ -285,7 +285,7 @@ class ApsGUIController extends ApsBase
}
//* Find a free db username for the app
for($n = 1; $n <= 1000; $n++) {
$mysql_db_user = ($dbname_prefix != '' ? $dbname_prefix.'aps'.$n : uniqid('aps'));
$mysql_db_user = ($dbuser_prefix != '' ? $dbuser_prefix.'aps'.$n : uniqid('aps'));
$tmp = $app->db->queryOneRecord("SELECT count(database_user_id) as number FROM web_database_user WHERE database_user = '".$app->db->quote($mysql_db_user)."'");
if($tmp['number'] == 0) break;
}
......@@ -293,13 +293,13 @@ class ApsGUIController extends ApsBase
$mysql_db_password = $settings['main_database_password'];
//* Create the mysql database user
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `database_user`, `database_password`)
VALUES( ".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', 0, '$mysql_db_user', PASSWORD('$mysql_db_password'))";
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `database_user`, `database_user_prefix`, `database_password`)
VALUES( ".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', 0, '$mysql_db_user', '".$app->db->quote($dbuser_prefix) . "', PASSWORD('$mysql_db_password'))";
$mysql_db_user_id = $app->db->datalogInsert('web_database_user', $insert_data, 'database_user_id');
//* Create the mysql database
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `parent_domain_id`, `type`, `database_name`, `database_user_id`, `database_ro_user_id`, `database_charset`, `remote_access`, `remote_ips`, `backup_copies`, `active`, `backup_interval`)
VALUES( ".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', $mysql_db_server_id, ".$websrv['domain_id'].", 'mysql', '$mysql_db_name', '$mysql_db_user_id', 0, '', '$mysql_db_remote_access', '$mysql_db_remote_ips', ".$websrv['backup_copies'].", 'y', '".$websrv['backup_interval']."')";
$insert_data = "(`sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `parent_domain_id`, `type`, `database_name`, `database_name_prefix`, `database_user_id`, `database_ro_user_id`, `database_charset`, `remote_access`, `remote_ips`, `backup_copies`, `active`, `backup_interval`)
VALUES( ".$websrv['sys_userid'].", ".$websrv['sys_groupid'].", 'riud', '".$websrv['sys_perm_group']."', '', $mysql_db_server_id, ".$websrv['domain_id'].", 'mysql', '$mysql_db_name', '" . $app->db->quote($dbname_prefix) . "', '$mysql_db_user_id', 0, '', '$mysql_db_remote_access', '$mysql_db_remote_ips', ".$websrv['backup_copies'].", 'y', '".$websrv['backup_interval']."')";
$app->db->datalogInsert('web_database', $insert_data, 'database_id');
//* Add db details to package settings
......@@ -542,7 +542,7 @@ class ApsGUIController extends ApsBase
// is not empty for further validation
if(!empty($doc_root))
{
$used_path = $docroot['document_root'];
$used_path = $doc_root['document_root'];
if(substr($used_path, -1) != '/') $used_path .= '/';
$location_for_domain = $app->db->queryOneRecord("SELECT value
......@@ -550,7 +550,7 @@ class ApsGUIController extends ApsBase
AND instance_id = '".$app->db->quote($instance_domains[$i]['instance_id'])."';");
// The location might be empty but the DB return must not be false!
if($location_for_domain) $used_path .= $location_for_domain['value'];
if($location_for_domain) $used_path .= $location_for_domain['value'];
if($new_path == $used_path)
{
......
......@@ -303,7 +303,7 @@ class functions {
}
public function intval($string, $force_numeric = false) {
if(intval($string) == 2147483647) {
if(intval($string) == 2147483647 || ($string > 0 && intval($string) < 0)) {
if($force_numeric == true) return floatval($string);
elseif(preg_match('/^([-]?)[0]*([1-9][0-9]*)([^0-9].*)*$/', $string, $match)) return $match[1].$match[2];
else return 0;
......
......@@ -142,7 +142,8 @@ class listform_actions {
if($_SESSION['s']['user']['typ'] == "admin") {
$sql_where = '';
} else {
$sql_where = $app->tform->getAuthSQL('r').' and';
$sql_where = $app->tform->getAuthSQL('r', $app->listform->listDef['table']).' and';
//$sql_where = $app->tform->getAuthSQL('r').' and';
}
}
if($this->SQLExtWhere != '') {
......
......@@ -244,6 +244,55 @@ class remoting {
return $affected_rows;
}
//* Get alias details
public function mail_aliasdomain_get($session_id, $primary_id)
{
global $app;
if(!$this->checkPerm($session_id, 'mail_aliasdomain_get')) {
$this->server->fault('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_aliasdomain.tform.php');
return $app->remoting_lib->getDataRecord($primary_id);
}
//* aliasy email
public function mail_aliasdomain_add($session_id, $client_id, $params)
{
if (!$this->checkPerm($session_id, 'mail_aliasdomain_add'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->insertQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $params);
return $affected_rows;
}
public function mail_aliasdomain_update($session_id, $client_id, $primary_id, $params)
{
if (!$this->checkPerm($session_id, 'mail_aliasdomain_update'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->updateQuery('../mail/form/mail_aliasdomain.tform.php', $client_id, $primary_id, $params);
return $affected_rows;
}
public function mail_aliasdomain_delete($session_id, $primary_id)
{
if (!$this->checkPerm($session_id, 'mail_aliasdomain_delete'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->deleteQuery('../mail/form/mail_aliasdomain.tform.php', $primary_id);
return $affected_rows;
}
//* Get mail mailinglist details
public function mail_mailinglist_get($session_id, $primary_id)
{
......@@ -432,11 +481,21 @@ class remoting {
//* aliasy email
public function mail_alias_add($session_id, $client_id, $params)
{
global $app;
if (!$this->checkPerm($session_id, 'mail_alias_add'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
//* Check if there is no active mailbox with this address
$tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'");
if($tmp['number'] > 0) {
$this->server->fault('duplicate','There is already a mailbox with this email address.');
}
unset($tmp);
$affected_rows = $this->insertQuery('../mail/form/mail_alias.tform.php', $client_id, $params);
return $affected_rows;
}
......@@ -444,13 +503,23 @@ class remoting {
public function mail_alias_update($session_id, $client_id, $primary_id, $params)
{
if (!$this->checkPerm($session_id, 'mail_alias_update'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
$affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
return $affected_rows;
global $app;
if (!$this->checkPerm($session_id, 'mail_alias_update'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
//* Check if there is no active mailbox with this address
$tmp = $app->db->queryOneRecord("SELECT count(mailuser_id) as number FROM mail_user WHERE postfix = 'y' AND email = '".$app->db->quote($params["source"])."'");
if($tmp['number'] > 0) {
$this->server->fault('duplicate','There is already a mailbox with this email address.');
}
unset($tmp);
$affected_rows = $this->updateQuery('../mail/form/mail_alias.tform.php', $client_id, $primary_id, $params);
return $affected_rows;
}
public function mail_alias_delete($session_id, $primary_id)
......@@ -1363,23 +1432,56 @@ class remoting {
//* Update a record
public function sites_database_user_update($session_id, $client_id, $primary_id, $params)
{
global $app;
if(!$this->checkPerm($session_id, 'sites_database_user_update')) {
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../sites/form/database_user.tform.php');
$old_rec = $app->remoting_lib->getDataRecord($primary_id);
$result = $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params);
$new_rec = $app->remoting_lib->getDataRecord($primary_id);
$records = $app->db->queryAllRecords("SELECT DISTINCT server_id FROM web_database WHERE database_user_id = '".$app->functions->intval($primary_id)."' UNION SELECT DISTINCT server_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($primary_id)."'");
foreach($records as $rec) {
$tmp_rec = $new_rec;
$tmp_rec['server_id'] = $rec['server_id'];
$app->remoting_lib->datalogSave('UPDATE', $primary_id, $old_rec, $tmp_rec);
}
unset($new_rec);
unset($old_rec);
unset($records);
return $this->updateQuery('../sites/form/database_user.tform.php', $client_id, $primary_id, $params);
return $result;
}
//* Delete a record
public function sites_database_user_delete($session_id, $primary_id)
{
global $app;
if(!$this->checkPerm($session_id, 'sites_database_user_delete')) {
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
return false;
}
$app->db->datalogDelete('web_database_user', 'database_user_id', $primary_id);
$affected_rows = $this->deleteQuery('../sites/form/database_user.tform.php',$primary_id);
$records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_user_id = '".$app->functions->intval($primary_id)."'");
foreach($records as $rec) {
$app->db->datalogUpdate('web_database','database_user_id=NULL','database_id', $rec['database_id']);
}
$records = $app->db->queryAllRecords("SELECT database_id FROM web_database WHERE database_ro_user_id = '".$app->functions->intval($primary_id)."'");
foreach($records as $rec) {
$app->db->datalogUpdate('web_database','database_ro_user_id=NULL','database_id', $rec['database_id']);
}
return $affected_rows;
}
......
......@@ -114,6 +114,7 @@ class remoting_lib {
var $sys_default_group;
var $sys_groups;
var $client_id;
var $dataRecord;
//* Load the form definition from file.
......@@ -390,6 +391,7 @@ class remoting_lib {
if($dbencode == true) $new_record[$key] = $app->db->quote($new_record[$key]);
}
}
if(isset($record['_ispconfig_pw_crypted'])) $new_record['_ispconfig_pw_crypted'] = $record['_ispconfig_pw_crypted']; // this one is not in form definitions!
return $new_record;
}
......@@ -655,6 +657,7 @@ class remoting_lib {
$this->action = $action;
$this->primary_id = $primary_id;
$this->dataRecord = $record;
$record = $this->encode($record,true);
$sql_insert_key = '';
......@@ -845,7 +848,7 @@ class remoting_lib {
$language = $app->db->quote($params["language"]);
$groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('$username','','$insert_id')", 'groupid');
$groups = $groupid;
$password = $app->auth->crypt_password(stripslashes($password));
if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($password));
$sql1 = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
VALUES ('$username','$password','$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,$insert_id)";
$app->db->query($sql1);
......@@ -856,7 +859,8 @@ class remoting_lib {
$username = $app->db->quote($params["username"]);
$clear_password = $app->db->quote($params["password"]);
$client_id = $app->functions->intval($client_id);
$password = $app->auth->crypt_password(stripslashes($clear_password));
if(!isset($params['_ispconfig_pw_crypted']) || $params['_ispconfig_pw_crypted'] != 1) $password = $app->auth->crypt_password(stripslashes($clear_password));
else $password = $clear_password;
if ($clear_password) $pwstring = ", passwort = '$password'"; else $pwstring ="" ;
$sql = "UPDATE sys_user set username = '$username' $pwstring WHERE client_id = $client_id";
$app->db->query($sql);
......
......@@ -687,7 +687,7 @@ class tform {
}
break;
case 'INTEGER':
$new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
$new_record[$key] = (isset($record[$key]))?$app->functions->intval($record[$key]):0;
//if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default'];
//if($key == 'refresh') die($record[$key]);
break;
......@@ -856,7 +856,7 @@ class tform {
}
break;
case 'ISINT':
if(function_exists('filter_var')) {
if(function_exists('filter_var') && $field_value < 2147483647) {
if($field_value != '' && filter_var($field_value, FILTER_VALIDATE_INT) === false) {
$errmsg = $validator['errmsg'];
if(isset($this->wordbook[$errmsg])) {
......
......@@ -54,7 +54,29 @@ class tools_sites {
}
return $name;
}
function removePrefix($name, $currentPrefix, $globalPrefix) {
if($name == "") return "";
if($currentPrefix === '') return $name; // empty prefix, do not change name
if($currentPrefix === '#') $currentPrefix = $globalPrefix; // entry has no prefix set, maybe it was created before this function was introduced
if($currentPrefix === '') return $name; // no current prefix and global prefix is empty -> nothing to remove here.
return preg_replace('/^' . preg_quote($currentPrefix, '/') . '/', '', $name); // return name without prefix
}
function getPrefix($currentPrefix, $userPrefix, $adminPrefix = false) {
global $app;
if($currentPrefix !== '#') return $currentPrefix; // return the currently set prefix for this entry (# = no prefix set yet)
if($adminPrefix === false) $adminPrefix = $userPrefix;
if($_SESSION["s"]["user"]["typ"] == 'admin' || $app->auth->has_clients($_SESSION['s']['user']['userid'])) return $adminPrefix;
else return $userPrefix;
}
function getClientName($dataRecord) {
global $app, $conf;
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
......@@ -121,6 +143,33 @@ class tools_sites {
}
return $res;
}
function getDomainModuleDomains() {
global $app;
$sql = "SELECT domain_id, domain FROM domain WHERE";
if ($_SESSION["s"]["user"]["typ"] == 'admin') {
$sql .= " 1";
} else {
$groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0;
$sql .= " sys_groupid IN (".$groups.")";
}
$sql .= " ORDER BY domain";
return $app->db->queryAllRecords($sql);
}
function checkDomainModuleDomain($domain_id) {
global $app;
$sql = "SELECT domain_id, domain FROM domain WHERE domain_id = " . $app->functions->intval($domain_id);
if ($_SESSION["s"]["user"]["typ"] != 'admin') {
$groups = ( $_SESSION["s"]["user"]["groups"] ) ? $_SESSION["s"]["user"]["groups"] : 0;
$sql .= " AND sys_groupid IN (".$groups.")";
}
$domain = $app->db->queryOneRecord($sql);
if(!$domain || !$domain['domain_id']) return false;
return $domain['domain'];
}
}
?>
......@@ -81,7 +81,8 @@ class validate_client {
($global_config['ftpuser_prefix'] == '[CLIENTNAME]' ||
$global_config['ftpuser_prefix'] == '' ||
$global_config['shelluser_prefix'] == '[CLIENTNAME]' ||
$global_config['shelluser_prefix'] == '' )) {
$global_config['shelluser_prefix'] == '' ) &&
$global_config['client_username_web_check_disabled'] == 'n') {
$errmsg = $validator['errmsg'];
if(isset($app->tform->wordbook[$errmsg])) {
return $app->tform->wordbook[$errmsg]."<br>\r\n";
......
......@@ -106,20 +106,171 @@ class validate_domain {
/* check if the domain hostname is unique (keep in mind the auto subdomains!) */
function _check_unique($domain_name, $only_domain = false) {
global $app;
global $app, $page;
if(isset($app->remoting_lib->primary_id)) {
$primary_id = $app->remoting_lib->primary_id;
$domain = $app->remoting_lib->dataRecord;
} else {
$primary_id = $app->tform->primary_id;
$domain = $page->dataRecord;
}
if($domain['ip_address'] == '' || $domain['ipv6_address'] == ''){
if($domain['parent_domain_id'] > 0){
$parent_domain = $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$domain['parent_domain_id']);
}
}
// check if domain has alias/subdomains - if we move a web to another IP, make sure alias/subdomains are checked as well
$aliassubdomains = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$app->functions->intval($primary_id)." AND (type = 'alias' OR type = 'subdomain')");
$additional_sql1 = '';
$additional_sql2 = '';
if(is_array($aliassubdomains) && !empty($aliassubdomains)){
foreach($aliassubdomains as $aliassubdomain){
$additional_sql1 .= " OR `domain` = '".$app->db->quote($aliassubdomain['domain'])."'";
$additional_sql2 .= " OR CONCAT(`subdomain`, '.', `domain`) = '".$app->db->quote($aliassubdomain['domain'])."'";