Skip to content

Commit 355efb9

Browse files
committed
Merged revisions 2886-2909 from stable branch.
1 parent 8544443 commit 355efb9

37 files changed

+219
-79
lines changed

install/update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@
9696
$conf["mysql"]["ispconfig_password"] = $conf_old["db_password"];
9797
$conf['language'] = $conf_old['language'];
9898
if($conf['language'] == '{language}') $conf['language'] = 'en';
99-
$conf['timezone'] = $conf_old['timezone'];
99+
$conf['timezone'] = (isset($conf_old['timezone']))?$conf_old['timezone']:'UTC';
100100
if($conf['timezone'] == '{timezone}' or trim($conf['timezone']) == '') $conf['timezone'] = 'UTC';
101101

102102
if(isset($conf_old["dbmaster_host"])) $conf["mysql"]["master_host"] = $conf_old["dbmaster_host"];

interface/lib/classes/functions.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'a
4545
$content = file_get_contents($filepath);
4646
$content = chunk_split(base64_encode($content));
4747
$uid = strtoupper(md5(uniqid(time())));
48+
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
4849

4950
if($filename == '') {
5051
$path_parts = pathinfo($filepath);
@@ -75,6 +76,7 @@ public function mail($to, $subject, $text, $from, $filepath = '', $filetype = 'a
7576
$header = "From: $from\nReply-To: $from\n";
7677
$header .= "Content-Type: text/plain;\n\tcharset=\"UTF-8\"\n";
7778
$header .= "Content-Transfer-Encoding: 8bit\n\n";
79+
$subject = "=?utf-8?B?".base64_encode($subject)."?=";
7880
mail($to, $subject, $text, $header);
7981
}
8082

interface/lib/classes/remoting.inc.php

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,8 @@ public function mail_user_filter_delete($session_id, $primary_id)
348348
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
349349
return false;
350350
}
351-
$affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id);
352-
$app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
351+
$affected_rows = $this->deleteQuery('../mail/form/mail_user_filter.tform.php', $primary_id,'mail:mail_user_filter:on_after_delete');
352+
// $app->plugin->raiseEvent('mail:mail_user_filter:on_after_delete',$this);
353353
return $affected_rows;
354354
}
355355

@@ -2180,20 +2180,29 @@ protected function klientadd($formdef_file, $reseller_id, $params)
21802180

21812181
//* Get the SQL query
21822182
$sql = $app->remoting_lib->getSQL($params,'INSERT',0);
2183-
$app->db->query($sql);
21842183

21852184
//* Check if no system user with that username exists
21862185
$username = $app->db->quote($params["username"]);
2187-
$tmp = $app->db->queryOneRecord("SELECT count(userid) as number FROm sys_user WHERE username = '$username'");
2186+
$tmp = $app->db->queryOneRecord("SELECT count(userid) as number FROM sys_user WHERE username = '$username'");
21882187
if($tmp['number'] > 0) $app->remoting_lib->errorMessage .= "Duplicate username<br />";
21892188

2189+
//* Stop on error while preparing the sql query
21902190
if($app->remoting_lib->errorMessage != '') {
21912191
$this->server->fault('data_processing_error', $app->remoting_lib->errorMessage);
21922192
return false;
21932193
}
21942194

2195+
//* Execute the SQL query
2196+
$app->db->query($sql);
21952197
$insert_id = $app->db->insertID();
21962198

2199+
2200+
//* Stop on error while executing the sql query
2201+
if($app->remoting_lib->errorMessage != '') {
2202+
$this->server->fault('data_processing_error', $app->remoting_lib->errorMessage);
2203+
return false;
2204+
}
2205+
21972206
$this->id = $insert_id;
21982207
$this->dataRecord = $params;
21992208

@@ -2332,22 +2341,23 @@ protected function deleteQuery($formdef_file, $primary_id, $event_identifier = '
23322341
// set a few values for compatibility with tform actions, mostly used by plugins
23332342
$this->oldDataRecord = $old_rec;
23342343
$this->id = $primary_id;
2335-
$this->dataRecord = $params;
2344+
$this->dataRecord = $old_rec;
2345+
//$this->dataRecord = $params;
23362346

23372347
//* Get the SQL query
23382348
$sql = $app->remoting_lib->getDeleteSQL($primary_id);
2339-
2349+
$app->db->errorMessage = '';
23402350
$app->db->query($sql);
2351+
$affected_rows = $app->db->affectedRows();
23412352

23422353
if($app->db->errorMessage != '') {
2343-
2344-
if($event_identifier != '') $app->plugin->raiseEvent($event_identifier,$this);
2345-
23462354
$this->server->fault('database_error', $app->db->errorMessage . ' '.$sql);
23472355
return false;
23482356
}
23492357

2350-
$affected_rows = $app->db->affectedRows();
2358+
if($event_identifier != '') {
2359+
$app->plugin->raiseEvent($event_identifier,$this);
2360+
}
23512361

23522362
//* Save changes to Datalog
23532363
if($app->remoting_lib->formDef["db_history"] == 'yes') {

interface/lib/classes/remoting_lib.inc.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -536,11 +536,16 @@ function getSQL($record, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '
536536
if($field['formtype'] == 'PASSWORD') {
537537
$sql_insert_key .= "`$key`, ";
538538
if($field['encryption'] == 'CRYPT') {
539-
$record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
539+
$record[$key] = $app->auth->crypt_password(stripslashes($record[$key]));
540+
$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
541+
} elseif ($field['encryption'] == 'MYSQL') {
542+
$sql_insert_val .= "PASSWORD('".$app->db->quote($record[$key])."'), ";
543+
} elseif ($field['encryption'] == 'CLEARTEXT') {
544+
$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
540545
} else {
541-
$record[$key] = md5($record[$key]);
546+
$record[$key] = md5(stripslashes($record[$key]));
547+
$sql_insert_val .= "'".$app->db->quote($record[$key])."', ";
542548
}
543-
$sql_insert_val .= "'".$record[$key]."', ";
544549
} elseif ($field['formtype'] == 'CHECKBOX') {
545550
$sql_insert_key .= "`$key`, ";
546551
if($record[$key] == '') {
@@ -645,7 +650,11 @@ function getDataRecord($primary_id) {
645650
foreach($primary_id as $key => $val) {
646651
$key = $app->db->quote($key);
647652
$val = $app->db->quote($val);
648-
$sql_where .= "$key = '$val' AND ";
653+
if(stristr($val,'%')) {
654+
$sql_where .= "$key like '$val' AND ";
655+
} else {
656+
$sql_where .= "$key = '$val' AND ";
657+
}
649658
}
650659
$sql_where = substr($sql_where,0,-5);
651660
$sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$sql_where;

interface/web/admin/software_update_list.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
foreach($installed_packages as $ip) {
162162

163163
// Get version number of the latest installed version
164-
$sql = "SELECT v1, v2, v3, v4 FROM software_update, software_update_inst WHERE software_update.software_update_id = software_update_inst.software_update_id AND server_id = 1 ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC LIMIT 0,1";
164+
$sql = "SELECT v1, v2, v3, v4 FROM software_update, software_update_inst WHERE software_update.software_update_id = software_update_inst.software_update_id AND server_id = ".$server_id." ORDER BY v1 DESC , v2 DESC , v3 DESC , v4 DESC LIMIT 0,1";
165165
$lu = $app->db->queryOneRecord($sql);
166166

167167
// Get all installable updates

interface/web/dns/dns_slave_edit.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,14 @@ function onShowEnd() {
106106

107107
}
108108

109+
if($this->id > 0) {
110+
//* we are editing a existing record
111+
$app->tpl->setVar("edit_disabled", 1);
112+
$app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
113+
} else {
114+
$app->tpl->setVar("edit_disabled", 0);
115+
}
116+
109117
parent::onShowEnd();
110118
}
111119

interface/web/dns/dns_soa_edit.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ function onShowEnd() {
116116

117117
}
118118

119+
if($this->id > 0) {
120+
//* we are editing a existing record
121+
$app->tpl->setVar("edit_disabled", 1);
122+
$app->tpl->setVar("server_id_value", $this->dataRecord["server_id"]);
123+
} else {
124+
$app->tpl->setVar("edit_disabled", 0);
125+
}
126+
119127
parent::onShowEnd();
120128
}
121129

@@ -180,19 +188,36 @@ function onAfterInsert() {
180188
// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
181189
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
182190
$client_group_id = intval($this->dataRecord["client_group_id"]);
183-
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
191+
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
184192
// And we want to update all rr records too, that belong to this record
185193
$app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
186194
}
187195
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
188196
$client_group_id = intval($this->dataRecord["client_group_id"]);
189-
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
197+
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
190198
// And we want to update all rr records too, that belong to this record
191199
$app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
192200
}
193201

194202
}
195203

204+
function onBeforeUpdate () {
205+
global $app, $conf;
206+
207+
//* Check if the server has been changed
208+
// We do this only for the admin or reseller users, as normal clients can not change the server ID anyway
209+
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
210+
//* We do not allow users to change a domain which has been created by the admin
211+
$rec = $app->db->queryOneRecord("SELECT origin from dns_soa WHERE id = ".$this->id);
212+
if(isset($this->dataRecord["origin"]) && $rec['origin'] != $this->dataRecord["origin"] && $app->tform->checkPerm($this->id,'u')) {
213+
//* Add a error message and switch back to old server
214+
$app->tform->errorMessage .= $app->lng('The Zone (soa) can not be changed. Please ask your Administrator if you want to change the Zone name.');
215+
$this->dataRecord["origin"] = $rec['origin'];
216+
}
217+
unset($rec);
218+
}
219+
}
220+
196221
function onAfterUpdate() {
197222
global $app, $conf;
198223

@@ -206,13 +231,13 @@ function onAfterUpdate() {
206231
// make sure that the record belongs to the client group and not the admin group when a dmin inserts it
207232
if($_SESSION["s"]["user"]["typ"] == 'admin' && isset($this->dataRecord["client_group_id"])) {
208233
$client_group_id = intval($this->dataRecord["client_group_id"]);
209-
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
234+
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'ru' WHERE id = ".$this->id);
210235
// And we want to update all rr records too, that belong to this record
211236
$app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
212237
}
213238
if($app->auth->has_clients($_SESSION['s']['user']['userid']) && isset($this->dataRecord["client_group_id"])) {
214239
$client_group_id = intval($this->dataRecord["client_group_id"]);
215-
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id WHERE id = ".$this->id);
240+
$app->db->query("UPDATE dns_soa SET sys_groupid = $client_group_id, sys_perm_group = 'riud' WHERE id = ".$this->id);
216241
// And we want to update all rr records too, that belong to this record
217242
$app->db->query("UPDATE dns_rr SET sys_groupid = $client_group_id WHERE zone = ".$this->id);
218243
}

interface/web/dns/form/dns_alias.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
'validators' => array ( 0 => array ( 'type' => 'NOTEMPTY',
8181
'errmsg'=> 'name_error_empty'),
8282
1 => array ( 'type' => 'REGEX',
83-
'regex' => '/^[\w\.\-]{1,64}$/',
83+
'regex' => '/^[\w\.\-]{1,255}$/',
8484
'errmsg'=> 'name_error_regex'),
8585
),
8686
'default' => '',

interface/web/dns/form/dns_cname.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
'datatype' => 'VARCHAR',
7979
'formtype' => 'TEXT',
8080
'validators' => array ( 0 => array ( 'type' => 'REGEX',
81-
'regex' => '/^[\w\.\-\*]{0,64}$/',
81+
'regex' => '/^[\w\.\-\*]{0,255}$/',
8282
'errmsg'=> 'name_error_regex'),
8383
),
8484
'default' => '',

interface/web/dns/form/dns_ns.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
'datatype' => 'VARCHAR',
7979
'formtype' => 'TEXT',
8080
'validators' => array ( 0 => array ( 'type' => 'REGEX',
81-
'regex' => '/^[\w\.\-]{0,64}$/',
81+
'regex' => '/^[\w\.\-]{0,255}$/',
8282
'errmsg'=> 'name_error_regex'),
8383
),
8484
'default' => '',

0 commit comments

Comments
 (0)