Skip to content

Commit b553b2b

Browse files
author
Marius Cramer
committed
Merge remote-tracking branch 'ispc/master' into new-layout-3.1
2 parents 108dd92 + f6174df commit b553b2b

File tree

16 files changed

+175
-169
lines changed

16 files changed

+175
-169
lines changed

interface/web/admin/form/users.tform.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,19 @@
260260
'maxlength' => '2',
261261
'rows' => '',
262262
'cols' => ''
263+
),
264+
'lost_password_function' => array (
265+
'datatype' => 'INTEGER',
266+
'formtype' => 'CHECKBOX',
267+
'regex' => '',
268+
'errmsg' => '',
269+
'default' => 1,
270+
'value' => array(0 => 0, 1 => 1),
271+
'separator' => '',
272+
'width' => '30',
273+
'maxlength' => '255',
274+
'rows' => '',
275+
'cols' => ''
263276
)
264277
//#################################
265278
// ENDE Datenbankfelder

interface/web/admin/lib/lang/de_users.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ $wb['password_mismatch_txt'] = 'Die Passwörter stimmen nicht überein.';
3131
$wb['password_match_txt'] = 'Die Passwörter stimmen überein.';
3232
$wb['username_error_collision'] = 'Der Benutzername darf nicht <b>web<b> oder <b>web<b> gefolgt von einer Zahl sein.';
3333
$wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin';
34+
$wb['lost_password_function_txt'] = 'Passwort vergessen Funktion steht zur Verfügung';
3435
?>

interface/web/admin/lib/lang/en_users.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ $wb['password_mismatch_txt'] = 'The passwords do not match.';
3131
$wb['password_match_txt'] = 'The passwords do match.';
3232
$wb['username_error_collision'] = 'The username may not be web or web plus a number."';
3333
$wb['client_not_admin_err'] = 'A user that belongs to a client can not be set to type: admin';
34+
$wb['lost_password_function_txt'] = 'Forgot password function is available';
3435
?>

interface/web/admin/templates/users_user_edit.htm

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ <h2><tmpl_var name="list_head_txt"></h2>
6060
{tmpl_var name='language'}
6161
</select>
6262
</div>
63+
<div class="ctrlHolder">
64+
<p class="label">{tmpl_var name='lost_password_function_txt'}</p>
65+
<div class="multiField">
66+
{tmpl_var name='lost_password_function'}
67+
</div>
68+
</div>
6369
</fieldset>
6470

6571
<input type="hidden" name="id" value="{tmpl_var name='id'}">
@@ -70,4 +76,4 @@ <h2><tmpl_var name="list_head_txt"></h2>
7076
</div>
7177
</div>
7278

73-
</div>
79+
</div>

interface/web/dns/dns_soa_edit.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ function onBeforeUpdate () {
283283
if($_SESSION["s"]["user"]["typ"] != 'admin' && !$app->auth->has_clients($_SESSION['s']['user']['userid'])) {
284284
//* We do not allow users to change a domain which has been created by the admin
285285
$rec = $app->db->queryOneRecord("SELECT origin from dns_soa WHERE id = ".$this->id);
286-
if(isset($this->dataRecord["origin"]) && $rec['origin'] != $this->dataRecord["origin"] && $app->tform->checkPerm($this->id, 'u')) {
286+
$drOrigin = (isset($this->dataRecord['origin']))
287+
? $app->functions->idn_encode($this->dataRecord['origin'])
288+
: false;
289+
290+
if($rec['origin'] !== $drOrigin && $app->tform->checkPerm($this->id, 'u')) {
287291
//* Add a error message and switch back to old server
288292
$app->tform->errorMessage .= $app->lng('The Zone (soa) can not be changed. Please ask your Administrator if you want to change the Zone name.');
289293
$this->dataRecord["origin"] = $rec['origin'];

interface/web/login/lib/lang/de.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ $wb['theme_not_compatible'] = 'Das gewählte Design ist mit dieser ISPConfig Ver
2424
$wb['back_txt'] = 'Zur&uuml;ck';
2525
$wb['stay_logged_in_txt'] = 'Dauerhaft eingeloggt bleiben';
2626
$wb['email_error'] = 'Email contains unallowed characters or has a invalid format.';
27+
$wb['lost_password_function_disabled_txt'] = 'Die Passwort vergessen Funktion steht für diesen Benutzer nicht zur Verfügung.';
2728
?>

interface/web/login/lib/lang/en.lng

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ $wb['back_txt'] = 'Back';
2424
$wb['error_maintenance_mode'] = 'This ISPConfig installation is currently under maintenance. We should be back shortly. Thank you for your patience.';
2525
$wb['theme_not_compatible'] = 'The chosen theme is not compatible with the current ISPConfig version. Please check for a new version of the theme.<br />The default theme as been activated automatically.';
2626
$wb['stay_logged_in_txt'] = 'Keep me logged in';
27-
?>
27+
$wb['lost_password_function_disabled_txt'] = 'The lost password function is not available for this user.';
28+
?>

interface/web/login/password_reset.php

Lines changed: 39 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
Redistribution and use in source and binary forms, with or without modification,
88
are permitted provided that the following conditions are met:
99
10-
* Redistributions of source code must retain the above copyright notice,
11-
this list of conditions and the following disclaimer.
12-
* Redistributions in binary form must reproduce the above copyright notice,
13-
this list of conditions and the following disclaimer in the documentation
14-
and/or other materials provided with the distribution.
15-
* Neither the name of ISPConfig nor the names of its contributors
16-
may be used to endorse or promote products derived from this software without
17-
specific prior written permission.
10+
* Redistributions of source code must retain the above copyright notice,
11+
this list of conditions and the following disclaimer.
12+
* Redistributions in binary form must reproduce the above copyright notice,
13+
this list of conditions and the following disclaimer in the documentation
14+
and/or other materials provided with the distribution.
15+
* Neither the name of ISPConfig nor the names of its contributors
16+
may be used to endorse or promote products derived from this software without
17+
specific prior written permission.
1818
1919
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
2020
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
@@ -26,7 +26,7 @@
2626
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
2727
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
2828
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29-
*/
29+
*/
3030

3131
require_once '../../lib/config.inc.php';
3232
require_once '../../lib/app.inc.php';
@@ -54,36 +54,39 @@
5454
$username = $app->db->quote($_POST['username']);
5555
$email = $app->db->quote($_POST['email']);
5656

57-
$client = $app->db->queryOneRecord("SELECT * FROM client WHERE username = '$username' AND email = '$email'");
57+
$client = $app->db->queryOneRecord("SELECT client.*, sys_user.lost_password_function FROM client,sys_user WHERE client.username = '$username' AND client.email = '$email' AND client.client_id = sys_user.client_id");
5858

59-
if($client['client_id'] > 0) {
60-
$new_password = $app->auth->get_random_password();
61-
$new_password_encrypted = $app->auth->crypt_password($new_password);
62-
$new_password_encrypted = $app->db->quote($new_password_encrypted);
63-
64-
$username = $app->db->quote($client['username']);
65-
$app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'");
66-
$app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'");
67-
$app->tpl->setVar("message", $wb['pw_reset']);
68-
69-
$app->uses('getconf,ispcmail');
70-
$mail_config = $app->getconf->get_global_config('mail');
71-
if($mail_config['smtp_enabled'] == 'y') {
72-
$mail_config['use_smtp'] = true;
73-
$app->ispcmail->setOptions($mail_config);
74-
}
75-
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
76-
$app->ispcmail->setSubject($wb['pw_reset_mail_title']);
77-
$app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password);
78-
$app->ispcmail->send(array($client['contact_name'] => $client['email']));
79-
$app->ispcmail->finish();
80-
81-
$app->plugin->raiseEvent('password_reset', true);
82-
$app->tpl->setVar("msg", $wb['pw_reset']);
59+
if($client['lost_password_function'] == 0) {
60+
$app->tpl->setVar("error", $wb['lost_password_function_disabled_txt']);
8361
} else {
84-
$app->tpl->setVar("error", $wb['pw_error']);
62+
if($client['client_id'] > 0) {
63+
$new_password = $app->auth->get_random_password();
64+
$new_password_encrypted = $app->auth->crypt_password($new_password);
65+
$new_password_encrypted = $app->db->quote($new_password_encrypted);
66+
67+
$username = $app->db->quote($client['username']);
68+
$app->db->query("UPDATE sys_user SET passwort = '$new_password_encrypted' WHERE username = '$username'");
69+
$app->db->query("UPDATE client SET password = '$new_password_encrypted' WHERE username = '$username'");
70+
$app->tpl->setVar("message", $wb['pw_reset']);
71+
72+
$app->uses('getconf,ispcmail');
73+
$mail_config = $app->getconf->get_global_config('mail');
74+
if($mail_config['smtp_enabled'] == 'y') {
75+
$mail_config['use_smtp'] = true;
76+
$app->ispcmail->setOptions($mail_config);
77+
}
78+
$app->ispcmail->setSender($mail_config['admin_mail'], $mail_config['admin_name']);
79+
$app->ispcmail->setSubject($wb['pw_reset_mail_title']);
80+
$app->ispcmail->setMailText($wb['pw_reset_mail_msg'].$new_password);
81+
$app->ispcmail->send(array($client['contact_name'] => $client['email']));
82+
$app->ispcmail->finish();
83+
84+
$app->plugin->raiseEvent('password_reset', true);
85+
$app->tpl->setVar("msg", $wb['pw_reset']);
86+
} else {
87+
$app->tpl->setVar("error", $wb['pw_error']);
88+
}
8589
}
86-
8790
} else {
8891
$app->tpl->setVar("msg", $wb['pw_error_noinput']);
8992
}

interface/web/mail/mail_domain_dkim_create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ function new_selector ($old_selector, $domain) {
163163
echo "<privatekey>".$private_key."</privatekey>\n";
164164
echo "<publickey>".$public_key."</publickey>\n";
165165
if ( validate_domain($_POST['domain']) ) {
166-
echo '<dns_record>'.$selector.'_domainkey.'.$_POST['domain'].'. 3600 TXT "v=DKIM1; t=s; p='.$dns_record.'"</dns_record>';
166+
echo '<dns_record>'.$selector.'._domainkey.'.$_POST['domain'].'. 3600 TXT "v=DKIM1; t=s; p='.$dns_record.'"</dns_record>';
167167
}
168168
echo "</formatname>\n";
169169
?>

server/lib/classes/cron.d/500-backup.inc.php

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,13 @@ public function onRunJob() {
7171
} else {
7272
chmod(escapeshellcmd($backup_dir), $backup_dir_permissions);
7373
}
74-
75-
//* mount backup directory, if necessary
76-
$run_backups = true;
77-
$server_config['backup_dir_mount_cmd'] = trim($server_config['backup_dir_mount_cmd']);
78-
if($server_config['backup_dir_is_mount'] == 'y' && $server_config['backup_dir_mount_cmd'] != ''){
79-
if(!$app->system->is_mounted($backup_dir)){
80-
exec(escapeshellcmd($server_config['backup_dir_mount_cmd']));
81-
sleep(1);
82-
if(!$app->system->is_mounted($backup_dir)) $run_backups = false;
83-
}
84-
}
85-
74+
$run_backups = true;
75+
//* mount backup directory, if necessary
76+
if( $server_config['backup_dir_is_mount'] == 'y' && !$app->system->mount_backup_dir($backup_dir) ) $run_backups = false;
8677
if($run_backups){
8778
//* backup only active domains
88-
$sql = "SELECT * FROM web_domain WHERE server_id = '".$conf['server_id']."' AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND active = 'y'";
89-
$records = $app->db->queryAllRecords($sql);
79+
$sql = "SELECT * FROM web_domain WHERE server_id = ? AND (type = 'vhost' OR type = 'vhostsubdomain' OR type = 'vhostalias') AND active = 'y'";
80+
$records = $app->db->queryAllRecords($sql, $conf['server_id']);
9081
if(is_array($records)) {
9182
foreach($records as $rec) {
9283

@@ -138,9 +129,12 @@ public function onRunJob() {
138129
//* Insert web backup record in database
139130
//$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
140131
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
141-
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",".$web_id.",'web','".$backup_mode."',".time().",'".$app->db->quote($web_backup_file)."')";
142-
$app->db->query($sql);
143-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
132+
$filesize = $app->functions->formatBytes(filesize($web_backup_dir.'/'.$web_backup_file));
133+
$sql = "INSERT INTO web_backup (server_id, parent_domain_id, backup_type, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)";
134+
$app->db->query($sql, $conf['server_id'], $web_id, 'web', $backup_mode, time(), $web_backup_file, $filesize);
135+
if($app->db->dbHost != $app->dbmaster->dbHost)
136+
$app->dbmaster->query($sql, $conf['server_id'], $web_id, 'web', $backup_mode, time(), $web_backup_file, $filesize);
137+
unset($filesize);
144138
}
145139
} else {
146140
if(is_file($web_backup_dir.'/'.$web_backup_file)) unlink($web_backup_dir.'/'.$web_backup_file);
@@ -167,9 +161,9 @@ public function onRunJob() {
167161
//$tmp = $app->dbmaster->queryOneRecord($sql);
168162
//$app->dbmaster->datalogDelete('web_backup', 'backup_id', $tmp['backup_id']);
169163
//$sql = "DELETE FROM web_backup WHERE backup_id = ".intval($tmp['backup_id']);
170-
$sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($files[$n])."'";
171-
$app->db->query($sql);
172-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
164+
$sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?";
165+
$app->db->query($sql, $conf['server_id'], $web_id, $files[$n]);
166+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $web_id, $files[$n]);
173167
}
174168
}
175169

@@ -199,16 +193,15 @@ public function onRunJob() {
199193
$web_backup_dir = realpath($backup_dir.'/web'.$web_id);
200194
if(is_dir($web_backup_dir)) {
201195
exec('sudo -u '.escapeshellarg($web_user).' rm -f '.escapeshellarg($web_backup_dir.'/*'));
202-
$sql = "DELETE FROM web_backup WHERE server_id = ".intval($conf['server_id'])." AND parent_domain_id = ".intval($web_id);
203-
$app->db->query($sql);
204-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
196+
$sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ?";
197+
$app->db->query($sql, $conf['server_id'], $web_id);
198+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $web_id);
205199
}
206200
}
207201
}
208202
}
209203

210-
$sql = "SELECT * FROM web_database WHERE server_id = ".$conf['server_id']." AND backup_interval != 'none' AND backup_interval != ''";
211-
$records = $app->db->queryAllRecords($sql);
204+
$records = $app->db->queryAllRecords("SELECT * FROM web_database WHERE server_id = ? AND backup_interval != 'none' AND backup_interval != ''", $conf['server_id']);
212205
if(is_array($records)) {
213206

214207
include 'lib/mysql_clientdb.conf';
@@ -245,9 +238,12 @@ public function onRunJob() {
245238
//* Insert web backup record in database
246239
//$insert_data = "(server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')";
247240
//$app->dbmaster->datalogInsert('web_backup', $insert_data, 'backup_id');
248-
$sql = "INSERT INTO web_backup (server_id,parent_domain_id,backup_type,backup_mode,tstamp,filename) VALUES (".$conf['server_id'].",$web_id,'mysql','sqlgz',".time().",'".$app->db->quote($db_backup_file).".gz')";
249-
$app->db->query($sql);
250-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
241+
$filesize = $app->functions->formatBytes(filesize($db_backup_dir.'/'.$db_backup_file.'.gz'));
242+
$sql = "INSERT INTO web_backup (server_id, parent_domain_id, backup_type, backup_mode, tstamp, filename, filesize) VALUES (?, ?, ?, ?, ?, ?, ?)";
243+
$app->db->query($sql, $conf['server_id'], $web_id, 'mysql', 'sqlgz', time(), $db_backup_file.'.gz', $filesize);
244+
if($app->db->dbHost != $app->dbmaster->dbHost)
245+
$app->dbmaster->query($sql, $conf['server_id'], $web_id, 'mysql', 'sqlgz', time(), $db_backup_file.'.gz', $filesize);
246+
unset($filesize);
251247
}
252248
} else {
253249
if(is_file($db_backup_dir.'/'.$db_backup_file.'.gz')) unlink($db_backup_dir.'/'.$db_backup_file.'.gz');
@@ -277,9 +273,9 @@ public function onRunJob() {
277273
//$sql = "SELECT backup_id FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($filelist[$n])."'";
278274
//$tmp = $app->dbmaster->queryOneRecord($sql);
279275
//$sql = "DELETE FROM web_backup WHERE backup_id = ".intval($tmp['backup_id']);
280-
$sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = $web_id AND filename = '".$app->db->quote($filelist[$n])."'";
281-
$app->db->query($sql);
282-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
276+
$sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?";
277+
$app->db->query($sql, $conf['server_id'], $web_id, $filelist[$n]);
278+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $web_id, $filelist[$n]);
283279
}
284280
}
285281
}
@@ -296,14 +292,14 @@ public function onRunJob() {
296292
}
297293

298294
// remove non-existing backups from database
299-
$backups = $app->db->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ".$conf['server_id']);
295+
$backups = $app->db->queryAllRecords("SELECT * FROM web_backup WHERE server_id = ?", $conf['server_id']);
300296
if(is_array($backups) && !empty($backups)){
301297
foreach($backups as $backup){
302298
$backup_file = $backup_dir.'/web'.$backup['parent_domain_id'].'/'.$backup['filename'];
303299
if(!is_file($backup_file)){
304-
$sql = "DELETE FROM web_backup WHERE server_id = ".$conf['server_id']." AND parent_domain_id = ".$backup['parent_domain_id']." AND filename = '".$backup['filename']."'";
305-
$app->db->query($sql);
306-
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql);
300+
$sql = "DELETE FROM web_backup WHERE server_id = ? AND parent_domain_id = ? AND filename = ?";
301+
$app->db->query($sql, $conf['server_id'], $backup['parent_domain_id'], $backup['filename']);
302+
if($app->db->dbHost != $app->dbmaster->dbHost) $app->dbmaster->query($sql, $conf['server_id'], $backup['parent_domain_id'], $backup['filename']);
307303
}
308304
}
309305
}

0 commit comments

Comments
 (0)