Updated: Changed meaning of '#' and '' for stored prefixes
6 files modified
1 files added
New file |
| | |
| | | |
| | | 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; |
| | |
| | | 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; // 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. |
| | | |
| | |
| | | function getPrefix($currentPrefix, $userPrefix, $adminPrefix = false) { |
| | | global $app; |
| | | |
| | | if($currentPrefix !== '') return ($currentPrefix == '#' ? '' : $currentPrefix); // return the currently set prefix for this entry (# = empty) |
| | | if($currentPrefix !== '#') return $currentPrefix; // return the currently set prefix for this entry (# = no prefix set yet) |
| | | |
| | | if($adminPrefix === false) $adminPrefix = $userPrefix; |
| | | |
| | |
| | | //* Prevent that the database name and charset is changed |
| | | $old_record = $app->tform->getDataRecord($this->id); |
| | | $dbname_prefix = $app->tools_sites->getPrefix($old_record['database_name_prefix'], $dbname_prefix); |
| | | $this->dataRecord['database_name_prefix'] = ($dbname_prefix === '' ? '#' : $dbname_prefix); |
| | | $this->dataRecord['database_name_prefix'] = $dbname_prefix; |
| | | |
| | | if($old_record["database_name"] != $dbname_prefix . $this->dataRecord["database_name"]) { |
| | | $app->tform->errorMessage .= $app->tform->wordbook["database_name_change_txt"].'<br />'; |
| | |
| | | $app->uses('getconf,tools_sites'); |
| | | $global_config = $app->getconf->get_global_config('sites'); |
| | | $dbname_prefix = $app->tools_sites->replacePrefix($global_config['dbname_prefix'], $this->dataRecord); |
| | | $this->dataRecord['database_name_prefix'] = ($dbname_prefix === '' ? '#' : $dbname_prefix); |
| | | $this->dataRecord['database_name_prefix'] = $dbname_prefix; |
| | | |
| | | if(strlen($dbname_prefix . $this->dataRecord['database_name']) > 64) $app->tform->errorMessage .= str_replace('{db}',$dbname_prefix . $this->dataRecord['database_name'],$app->tform->wordbook["database_name_error_len"]).'<br />'; |
| | | |
| | |
| | | $this->oldDataRecord = $app->db->queryOneRecord("SELECT * FROM web_database_user WHERE database_user_id = '".$this->id."'"); |
| | | |
| | | $dbuser_prefix = $app->tools_sites->getPrefix($this->oldDataRecord['database_user_prefix'], $dbuser_prefix); |
| | | $this->dataRecord['database_user_prefix'] = ($dbuser_prefix === '' ? '#' : $dbuser_prefix); |
| | | $this->dataRecord['database_user_prefix'] = $dbuser_prefix; |
| | | |
| | | //* Database username shall not be empty |
| | | if($this->dataRecord['database_user'] == '') $app->tform->errorMessage .= $app->tform->wordbook["database_user_error_empty"].'<br />'; |
| | |
| | | $global_config = $app->getconf->get_global_config('sites'); |
| | | $dbuser_prefix = $app->tools_sites->replacePrefix($global_config['dbuser_prefix'], $this->dataRecord); |
| | | |
| | | $this->dataRecord['database_user_prefix'] = ($dbuser_prefix === '' ? '#' : $dbuser_prefix); |
| | | $this->dataRecord['database_user_prefix'] = $dbuser_prefix; |
| | | |
| | | if(strlen($dbuser_prefix . $this->dataRecord['database_user']) > 16) $app->tform->errorMessage .= str_replace('{user}',$dbuser_prefix . $this->dataRecord['database_user'],$app->tform->wordbook["database_user_error_len"]).'<br />'; |
| | | |
| | |
| | | $global_config = $app->getconf->get_global_config('sites'); |
| | | $ftpuser_prefix = $app->tools_sites->replacePrefix($global_config['ftpuser_prefix'], $this->dataRecord); |
| | | |
| | | $this->dataRecord['username_prefix'] = ($ftpuser_prefix === '' ? '#' : $ftpuser_prefix); |
| | | $this->dataRecord['username_prefix'] = $ftpuser_prefix; |
| | | |
| | | if ($app->tform->errorMessage == '') { |
| | | $this->dataRecord['username'] = $ftpuser_prefix . $this->dataRecord['username']; |
| | |
| | | |
| | | $old_record = $app->tform->getDataRecord($this->id); |
| | | $ftpuser_prefix = $app->tools_sites->getPrefix($old_record['username_prefix'], $ftpuser_prefix); |
| | | $this->dataRecord['username_prefix'] = ($ftpuser_prefix === '' ? '#' : $ftpuser_prefix); |
| | | $this->dataRecord['username_prefix'] = $ftpuser_prefix; |
| | | |
| | | /* restrict the names */ |
| | | if ($app->tform->errorMessage == '') { |
| | |
| | | $global_config = $app->getconf->get_global_config('sites'); |
| | | $shelluser_prefix = $app->tools_sites->replacePrefix($global_config['shelluser_prefix'], $this->dataRecord); |
| | | |
| | | $this->dataRecord['username_prefix'] = ($shelluser_prefix === '' ? '#' : $shelluser_prefix); |
| | | $this->dataRecord['username_prefix'] = $shelluser_prefix; |
| | | /* restrict the names */ |
| | | $this->dataRecord['username'] = $shelluser_prefix . $this->dataRecord['username']; |
| | | } |
| | |
| | | |
| | | $old_record = $app->tform->getDataRecord($this->id); |
| | | $shelluser_prefix = $app->tools_sites->getPrefix($old_record['username_prefix'], $shelluser_prefix); |
| | | $this->dataRecord['username_prefix'] = ($shelluser_prefix === '' ? '#' : $shelluser_prefix); |
| | | $this->dataRecord['username_prefix'] = $shelluser_prefix; |
| | | |
| | | /* restrict the names */ |
| | | $this->dataRecord['username'] = $shelluser_prefix . $this->dataRecord['username']; |
| | |
| | | $global_config = $app->getconf->get_global_config('sites'); |
| | | $webdavuser_prefix = $app->tools_sites->replacePrefix($global_config['webdavuser_prefix'], $this->dataRecord); |
| | | |
| | | $this->dataRecord['username_prefix'] = ($webdavuser_prefix === '' ? '#' : $webdavuser_prefix); |
| | | $this->dataRecord['username_prefix'] = $webdavuser_prefix; |
| | | |
| | | /* restrict the names */ |
| | | $this->dataRecord['username'] = $webdavuser_prefix . $this->dataRecord['username']; |