Commit 7b47c0aa authored by tbrehm's avatar tbrehm

Merged revisions 4069-4117 from stable branch.

parent 2332b227
......@@ -163,7 +163,23 @@ class installer_dist extends installer_base {
if(!is_group($cf['vmail_groupname'])) caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
$command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
//* These postconf commands will be executed on installation and update
$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
unset($server_ini_rec);
//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update
$rbl_list = '';
if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') {
$rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list']));
foreach ($rbl_hosts as $key => $value) {
$rbl_list .= ", reject_rbl_client ". $value;
}
}
unset($rbl_hosts);
unset($server_ini_array);
//* These postconf commands will be executed on installation and update
$postconf_placeholders = array('{config_dir}' => $config_dir,
......
......@@ -178,6 +178,22 @@ class installer_dist extends installer_base {
if($cf['vmail_mailbox_base'] != '' && strlen($cf['vmail_mailbox_base']) >= 10 && $this->is_update === false) exec('chown -R '.$cf['vmail_username'].':'.$cf['vmail_groupname'].' '.$cf['vmail_mailbox_base']);
//* These postconf commands will be executed on installation and update
$server_ini_rec = $this->db->queryOneRecord("SELECT config FROM server WHERE server_id = ".$conf['server_id']);
$server_ini_array = ini_to_array(stripslashes($server_ini_rec['config']));
unset($server_ini_rec);
//* If there are RBL's defined, format the list and add them to smtp_recipient_restrictions to prevent removeal after an update
$rbl_list = '';
if (@isset($server_ini_array['mail']['realtime_blackhole_list']) && $server_ini_array['mail']['realtime_blackhole_list'] != '') {
$rbl_hosts = explode(",",str_replace(" ", "", $server_ini_array['mail']['realtime_blackhole_list']));
foreach ($rbl_hosts as $key => $value) {
$rbl_list .= ", reject_rbl_client ". $value;
}
}
unset($rbl_hosts);
unset($server_ini_array);
//* These postconf commands will be executed on installation and update
$postconf_placeholders = array('{config_dir}' => $config_dir,
'{vmail_mailbox_base}' => $cf['vmail_mailbox_base'],
......
......@@ -571,7 +571,8 @@ if($install_mode == 'standard') {
}*/
//** Configure ISPConfig :-)
if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),'y')) == 'y') {
$install_ispconfig_interface_default = ($conf['mysql']['master_slave_setup'] == 'y')?'n':'y';
if(strtolower($inst->simple_query('Install ISPConfig Web Interface',array('y','n'),$install_ispconfig_interface_default)) == 'y') {
swriteln('Installing ISPConfig');
//** We want to check if the server is a module or cgi based php enabled server
......
......@@ -400,7 +400,7 @@ class installer_base {
$this->warning('Unable to set rights of user in master database: '.$value['db']."\n Query: ".$query."\n Error: ".$this->dbmaster->errorMessage);
}
$query = "GRANT SELECT, UPDATE(`status`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
$query = "GRANT SELECT, UPDATE(`status`, `error`) ON ".$value['db'].".`sys_datalog` TO '".$value['user']."'@'".$host."' ";
if ($verbose){
echo $query ."\n";
}
......@@ -2094,8 +2094,8 @@ class installer_base {
}
$root_cron_jobs = array(
"* * * * * ".$install_dir."/server/server.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log",
"30 00 * * * ".$install_dir."/server/cron_daily.sh > /dev/null 2>> ".$conf['ispconfig_log_dir']."/cron.log"
"* * * * * ".$install_dir."/server/server.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done",
"30 00 * * * ".$install_dir."/server/cron_daily.sh 2>&1 > /dev/null | while read line; do echo `/bin/date` \"\$line\" >> ".$conf['ispconfig_log_dir']."/cron.log; done"
);
if ($conf['nginx']['installed'] == true) {
......
......@@ -35,7 +35,7 @@ class db
var $dbUser = ""; // database authorized user
var $dbPass = ""; // user's password
var $dbCharset = ""; // what charset comes and goes to mysql: utf8 / latin1
var $linkId = 0; // last result of mysql_connect()
var $linkId = false; // last result of mysql_connect()
var $queryId = 0; // last result of mysql_query()
var $record = array(); // last record fetched
var $autoCommit = 1; // Autocommit Transactions
......@@ -61,8 +61,8 @@ class db
// error handler
function updateError($location)
{
$this->errorNumber = mysql_errno();
$this->errorMessage = mysql_error();
$this->errorNumber = mysqli_errno($this->linkId);
$this->errorMessage = mysqli_error($this->linkId);
$this->errorLocation = $location;
if($this->errorNumber && $this->show_error_messages)
{
......@@ -73,16 +73,16 @@ class db
function connect()
{
if($this->linkId == 0)
if(!$this->linkId)
{
$this->linkId = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass);
$this->linkId = mysqli_connect($this->dbHost, $this->dbUser, $this->dbPass);
if(!$this->linkId)
{
$this->updateError('DB::connect()<br />mysql_connect');
$this->updateError('DB::connect()<br />mysqli_connect');
return false;
}
$this->queryId = @mysql_query('SET NAMES '.$this->dbCharset, $this->linkId);
$this->queryId = @mysqli_query($this->linkId, 'SET NAMES '.$this->dbCharset);
}
return true;
}
......@@ -94,14 +94,14 @@ class db
return false;
}
if($this->dbName != '') {
if(!mysql_select_db($this->dbName, $this->linkId))
if(!mysqli_select_db($this->linkId, $this->dbName))
{
$this->updateError('DB::connect()<br />mysql_select_db');
$this->updateError('DB::connect()<br />mysqli_select_db');
return false;
}
}
$this->queryId = @mysql_query($queryString, $this->linkId);
$this->updateError('DB::query('.$queryString.')<br />mysql_query');
$this->queryId = @mysqli_query($this->linkId, $queryString);
$this->updateError('DB::query('.$queryString.')<br />mysqli_query');
if(!$this->queryId)
{
return false;
......@@ -138,8 +138,8 @@ class db
// returns the next record in an array
function nextRecord()
{
$this->record = mysql_fetch_assoc($this->queryId);
$this->updateError('DB::nextRecord()<br />mysql_fetch_array');
$this->record = mysqli_fetch_assoc($this->queryId);
$this->updateError('DB::nextRecord()<br />mysqli_fetch_array');
if(!$this->record || !is_array($this->record))
{
return false;
......@@ -151,18 +151,18 @@ class db
// returns number of rows returned by the last select query
function numRows()
{
return mysql_num_rows($this->queryId);
return mysqli_num_rows($this->queryId);
}
function affectedRows()
{
return mysql_affected_rows($this->linkId);
return mysqli_affected_rows($this->linkId);
}
// returns mySQL insert id
function insertID()
{
return mysql_insert_id($this->linkId);
return mysqli_insert_id($this->linkId);
}
// Check der variablen
......@@ -175,7 +175,7 @@ class db
// Check der variablen
function quote($formfield)
{
return mysql_real_escape_string($formfield);
return mysqli_real_escape_string($this->linkId, $formfield);
}
// Check der variablen
......@@ -359,11 +359,22 @@ class db
if($database_name == ''){
$database_name = $this->dbName;
}
$result = mysql_query("SHOW TABLES FROM `$database_name`");
$tables = $this->queryAllRecords("SHOW TABLES FROM `$database_name`");
$tb_names = array();
if(is_array($tables) && !empty($tables)){
for($i = 0; $i < sizeof($tables); $i++){
$tb_names[$i] = $tables[$i]['Tables_in_'.$database_name];
}
}
/*
$result = mysqli_query("SHOW TABLES FROM `$database_name`");
$tb_names = array();
for ($i = 0; $i < mysql_num_rows($result); $i++) {
for ($i = 0; $i < mysqli_num_rows($result); $i++) {
$tb_names[$i] = mysql_tablename($result, $i);
}
*/
return $tb_names;
}
......@@ -438,35 +449,7 @@ class db
} else {
return false;
}
//$this->createTable('tester',$columns);
/*
$result = mysql_list_fields($go_info["server"]["db_name"],$table_name);
$fields = mysql_num_fields ($result);
$i = 0;
$table = mysql_field_table ($result, $i);
while ($i < $fields) {
$name = mysql_field_name ($result, $i);
$type = mysql_field_type ($result, $i);
$len = mysql_field_len ($result, $i);
$flags = mysql_field_flags ($result, $i);
print_r($flags);
$columns = array(name => $name,
type => "",
defaultValue => "",
isnull => 1,
option => "");
$returnvar[] = $columns;
$i++;
}
*/
}
function mapType($metaType,$typeValue) {
......
ALTER TABLE `web_backup` CHANGE `backup_type` `backup_type` enum('web','mongodb','mysql') NOT NULL DEFAULT 'web';
ALTER TABLE `web_database_user` ADD `database_password_mongo` varchar(32) DEFAULT NULL AFTER `database_password`;
ALTER TABLE `sys_datalog` ADD `error` MEDIUMTEXT NULL DEFAULT NULL;
CREATE TABLE `client_template_assigned` (
`assigned_template_id` bigint(20) NOT NULL auto_increment,
`client_id` bigint(11) NOT NULL DEFAULT '0',
`client_template_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`assigned_template_id`),
KEY `client_id` (`client_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
ALTER TABLE `client` ADD `gender` enum('','m','f') NOT NULL DEFAULT '' AFTER `company_id`,
ADD `locked` enum('n','y') NOT NULL DEFAULT 'n' AFTER `created_at`,
ADD `canceled` enum('n','y') NOT NULL DEFAULT 'n' AFTER `locked`,
ADD `tmp_data` mediumblob AFTER `canceled` ;
......@@ -145,6 +145,7 @@ CREATE TABLE `client` (
`sys_perm_other` varchar(5) DEFAULT NULL,
`company_name` varchar(64) DEFAULT NULL,
`company_id` varchar(30) DEFAULT NULL,
`gender` enum('','m','f') NOT NULL DEFAULT '',
`contact_name` varchar(64) DEFAULT NULL,
`customer_no` varchar(64) DEFAULT NULL,
`vat_id` varchar(64) DEFAULT NULL,
......@@ -225,6 +226,9 @@ CREATE TABLE `client` (
`template_master` int(11) unsigned NOT NULL DEFAULT '0',
`template_additional` text NOT NULL DEFAULT '',
`created_at` bigint(20) DEFAULT NULL,
`locked` enum('n','y') NOT NULL DEFAULT 'n',
`canceled` enum('n','y') NOT NULL DEFAULT 'n',
`tmp_data` mediumblob,
`id_rsa` varchar(2000) NOT NULL DEFAULT '',
`ssh_rsa` varchar(600) NOT NULL DEFAULT '',
PRIMARY KEY (`client_id`)
......@@ -315,6 +319,19 @@ CREATE TABLE `client_template` (
-- --------------------------------------------------------
--
-- Table structure for table `client_template_assigned`
--
CREATE TABLE `client_template_assigned` (
`assigned_template_id` bigint(20) NOT NULL auto_increment,
`client_id` bigint(11) NOT NULL DEFAULT '0',
`client_template_id` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`assigned_template_id`),
KEY `client_id` (`client_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `country`
--
......@@ -1428,6 +1445,7 @@ CREATE TABLE `sys_datalog` (
`user` varchar(255) NOT NULL default '',
`data` longtext NOT NULL,
`status` set('pending','ok','warning','error') NOT NULL default 'ok',
`error` mediumtext,
PRIMARY KEY (`datalog_id`),
KEY `server_id` (`server_id`,`status`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
......@@ -2179,6 +2197,6 @@ INSERT INTO `sys_user` (`userid`, `sys_userid`, `sys_groupid`, `sys_perm_user`,
-- Dumping data for table `sys_config`
--
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.5.2');
INSERT INTO sys_config VALUES ('1','db','db_version','3.0.5.3');
SET FOREIGN_KEY_CHECKS = 1;
......@@ -56,7 +56,7 @@ $revision = str_replace(array('Revision:','$',' '), '', $svn_revision);
//** Application
define('ISPC_APP_TITLE', 'ISPConfig');
define('ISPC_APP_VERSION', '3.0.5.2');
define('ISPC_APP_VERSION', '3.0.5.3');
define('DEVSYSTEM', 0);
......
......@@ -41,3 +41,9 @@ tab_change_warning=n
use_loadindicator=y
use_combobox=y
maintenance_mode=n
admin_dashlets_left=
admin_dashlets_right=
reseller_dashlets_left=
reseller_dashlets_right=
client_dashlets_left=
client_dashlets_right=
......@@ -193,11 +193,15 @@ class listform {
public function getPagingSQL($sql_where = '1')
{
global $app, $conf;
//* Add Global Limit from selectbox
if(!empty($_POST['search_limit']) AND $app->functions->intval($_POST['search_limit'])){
//* Add Global Limit from selectbox
if(!empty($_POST['search_limit']) AND $app->functions->intval($_POST['search_limit']) > 0){
$_SESSION['search']['limit'] = $app->functions->intval($_POST['search_limit']);
}
if(preg_match('{^[0-9]$}',$_SESSION['search']['limit'])){
$_SESSION['search']['limit'] = 15;
}
//* Get Config variables
$list_name = $this->listDef['name'];
......
......@@ -55,6 +55,12 @@ class plugin_backuplist extends plugin_base {
if(isset($_GET['backup_action'])) {
$backup_id = $app->functions->intval($_GET['backup_id']);
//* check if the user is owner of the parent domain
$domain_backup = $app->db->queryOneRecord("SELECT parent_domain_id FROM web_backup WHERE backup_id = ".$backup_id);
if(!$app->tform->checkOwnerPermisssions($this->dataRecord["parent_domain_id"])){
$app->error($app->tform->lng('no_domain_perm'));
}
if($_GET['backup_action'] == 'download' && $backup_id > 0) {
$sql = "SELECT count(action_id) as number FROM sys_remoteaction WHERE action_state = 'pending' AND action_type = 'backup_download' AND action_param = '$backup_id'";
$tmp = $app->db->queryOneRecord($sql);
......
......@@ -1103,7 +1103,40 @@ class remoting {
}
$app->uses('remoting_lib');
$app->remoting_lib->loadFormDef('../client/form/client.tform.php');
return $app->remoting_lib->getDataRecord($client_id);
$data = $app->remoting_lib->getDataRecord($client_id);
// we need to get the new-style templates for backwards-compatibility - maybe we remove this in a later version
if(is_array($data) && count($data) > 0) {
if(isset($data['client_id'])) {
// this is a single record
if($data['template_additional'] == '') {
$tpls = $app->db->queryAllRecords('SELECT CONCAT(`assigned_template_id`, \':\', `client_template_id`) as `item` FROM `client_template_assigned` WHERE `client_id` = ' . $data['client_id']);
$tpl_arr = array();
if($tpls) {
foreach($tpls as $tpl) $tpl_arr[] = $tpl['item'];
}
$data['template_additional'] = implode('/', $tpl_arr);
unset($tpl_arr);
unset($tpls);
}
} elseif(isset($data[0]['client_id'])) {
// multiple client records
foreach($data as $index => $client) {
if($client['template_additional'] == '') {
$tpls = $app->db->queryAllRecords('SELECT CONCAT(`assigned_template_id`, \':\', `client_template_id`) as `item` FROM `client_template_assigned` WHERE `client_id` = ' . $client['client_id']);
$tpl_arr = array();
if($tpls) {
foreach($tpls as $tpl) $tpl_arr[] = $tpl['item'];
}
$data[$index]['template_additional'] = implode('/', $tpl_arr); // dont use the $client array here - changes would not be returned to soap
}
unset($tpl_arr);
unset($tpls);
}
}
}
return $data;
}
public function client_get_id($session_id, $sys_userid)
......@@ -1169,6 +1202,33 @@ class remoting {
$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('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php');
$old_rec = $app->remoting_lib->getDataRecord($client_id);
// we need the previuos templates assigned here
$this->oldTemplatesAssigned = $app->db->queryAllRecords('SELECT * FROM `client_template_assigned` WHERE `client_id` = ' . $client_id);
if(!is_array($this->oldTemplatesAssigned) || count($this->oldTemplatesAssigned) < 1) {
// check previous type of storing templates
$tpls = explode('/', $old_rec['template_additional']);
$this->oldTemplatesAssigned = array();
foreach($tpls as $item) {
$item = trim($item);
if(!$item) continue;
$this->oldTemplatesAssigned[] = array('assigned_template_id' => 0, 'client_template_id' => $item, 'client_id' => $client_id);
}
unset($tpls);
}
if(isset($params['template_additional'])) {
$app->uses('client_templates');
$templates = explode('/', $params['template_additional']);
$params['template_additional'] = '';
$app->client_templates->update_client_templates($client_id, $templates);
unset($templates);
}
if(!isset($params['parent_client_id']) || $params['parent_client_id'] == 0) $params['parent_client_id'] = $reseller_id;
$affected_rows = $this->updateQuery('../client/form/' . (isset($params['limit_client']) && $params['limit_client'] > 0 ? 'reseller' : 'client') . '.tform.php', $reseller_id, $client_id, $params, 'client:' . ($reseller_id ? 'reseller' : 'client') . ':on_after_update');
......@@ -1176,7 +1236,120 @@ class remoting {
return $affected_rows;
}