Skip to content

Commit cc7931d

Browse files
author
Till Brehm
committed
Merge branch 'master' into 'master'
Master See merge request ispconfig/ispconfig3!895
2 parents 708631d + d0dd670 commit cc7931d

File tree

8 files changed

+80
-20
lines changed

8 files changed

+80
-20
lines changed

install/sql/incremental/upd_dev_collection.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,12 @@ CREATE TABLE IF NOT EXISTS `sys_mailqueue` (
166166

167167
ALTER TABLE `web_domain` ADD `jailkit_jkupdate_cron` enum('n','y') NOT NULL DEFAULT 'y' AFTER `custom_php_ini`;
168168
ALTER TABLE `sys_datalog` ADD `session_id` varchar(64) NOT NULL DEFAULT '' AFTER `error`;
169+
170+
CREATE TABLE IF NOT EXISTS `sys_login` (
171+
`session_id` varchar(64) NOT NULL,
172+
`username` varchar(64) NOT NULL default '',
173+
`ip` varchar(255) NOT NULL default '',
174+
`login-time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
175+
PRIMARY KEY (`session_id`)
176+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
177+

install/sql/ispconfig3.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,6 +1556,21 @@ CREATE TABLE `sys_group` (
15561556
PRIMARY KEY (`groupid`)
15571557
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
15581558

1559+
-- --------------------------------------------------------
1560+
1561+
--
1562+
-- Table structure for table `sys_login`
1563+
--
1564+
1565+
CREATE TABLE `sys_login` (
1566+
`session_id` varchar(64) NOT NULL,
1567+
`username` varchar(64) NOT NULL default '',
1568+
`ip` varchar(255) NOT NULL default '',
1569+
`login-time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
1570+
PRIMARY KEY (`session_id`)
1571+
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
1572+
1573+
15591574
-- --------------------------------------------------------
15601575

15611576
--

interface/web/login/index.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,13 @@
262262
$app->plugin->raiseEvent('login', $username);
263263

264264
//* Save successfull login message to var
265-
$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s') . ' with session ID ' .session_id();
265+
//$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s');
266+
$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s') . ' with session ID ' .session_id();
266267
$authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
267268
fwrite($authlog_handle, $authlog ."\n");
268269
fclose($authlog_handle);
269-
270+
$app->db->query("INSERT INTO sys_login (`session_id`, `username`, `ip`, `login-time`) VALUES (?, ?, ?, CURRENT_TIMESTAMP) ON DUPLICATE KEY UPDATE `login-time`=CURRENT_TIMESTAMP", session_id(), $username, $_SERVER['REMOTE_ADDR']);
271+
270272
// get last IP used to login
271273
$user_data = $app->db->queryOneRecord("SELECT last_login_ip,last_login_at FROM sys_user WHERE username = ?", $username);
272274

@@ -275,12 +277,13 @@
275277
if(!$loginAs) {
276278
$app->db->query("UPDATE sys_user SET last_login_ip = ?, last_login_at = ? WHERE username = ?", $_SERVER['REMOTE_ADDR'], time(), $username);
277279
}
280+
278281
/*
279282
* We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
280283
* new theme, if the logged-in user has another
281284
*/
282285

283-
if($loginAs) {
286+
if ($loginAs){
284287
echo 'LOGIN_REDIRECT:'.$_SESSION['s']['module']['startpage'];
285288
exit;
286289
} else {
@@ -292,7 +295,8 @@
292295
$error = $app->lng('error_user_blocked');
293296
}
294297
} else {
295-
if(!$alreadyfailed['times']) {
298+
if(!$alreadyfailed['times'] )
299+
{
296300
//* user login the first time wrong
297301
$sql = "INSERT INTO `attempts_login` (`ip`, `times`, `login_time`) VALUES (?, 1, NOW())";
298302
$app->db->query($sql, $ip);
@@ -351,17 +355,7 @@
351355
//die(isset($_SESSION['s']['theme']) ? $_SESSION['s']['theme'] : 'default');
352356

353357
// Logo
354-
$logo = $app->db->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1");
355-
if($logo['custom_logo'] != ''){
356-
$base64_logo_txt = $logo['custom_logo'];
357-
} else {
358-
$base64_logo_txt = $logo['default_logo'];
359-
}
360-
$tmp_base64 = explode(',', $base64_logo_txt, 2);
361-
$logo_dimensions = $app->functions->getimagesizefromstring(base64_decode($tmp_base64[1]));
362-
$app->tpl->setVar('base64_logo_width', $logo_dimensions[0].'px');
363-
$app->tpl->setVar('base64_logo_height', $logo_dimensions[1].'px');
364-
$app->tpl->setVar('base64_logo_txt', $base64_logo_txt);
358+
$app->tpl->logo();
365359

366360
// Title
367361
if (!empty($sys_config['company_name'])) {

interface/web/monitor/dataloghistory_view.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,18 @@
5757

5858
$out['session_id'] = $record['session_id'];
5959

60+
if ($out['session_id'] != '') {
61+
$temp = $app->db->queryOneRecord("SELECT username, ip FROM sys_login WHERE session_id = ?", $out['session_id']);
62+
$out['datalog_username'] = $temp['username'];
63+
$out['datalog_userip'] = $temp['ip'];
64+
unset($temp);
65+
}
66+
6067
if(!$data = unserialize(stripslashes($record['data']))) {
6168
$data = unserialize($record['data']);
6269
}
6370

64-
$out = describe($record['dbtable'], $data, $out);
71+
$out = describe($record['dbtable'], $data, $out, $record['action']);
6572

6673
switch ($record['action']) {
6774
case 'i':
@@ -118,7 +125,7 @@ function show_diff_if_needed($old, $new) {
118125
global $app;
119126

120127
$diff_min_lines = 6;
121-
128+
$where = @($action == 'd')?$data['old']['parent_domain_id']:$data['new']['parent_domain_id'];
122129
if (substr_count($old, "\n") >= $diff_min_lines || substr_count($new, "\n") >= $diff_min_lines) {
123130
$opcodes = FineDiff::getDiffOpcodes($old, $new);
124131
$html = FineDiff::renderUTF8DiffToHTMLFromOpcodes($old, $opcodes);
@@ -128,15 +135,16 @@ function show_diff_if_needed($old, $new) {
128135
}
129136
}
130137

131-
function describe($dbtable, $data, $out) {
138+
function describe($dbtable, $data, $out, $action) {
132139
global $app;
133140
$out['describe'] = $app->lng('describe_'.$dbtable);
134141
switch ($dbtable) {
135142
case 'client':
136143
$check = 'username';
137144
break;
138145
case 'cron':
139-
$temp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']);
146+
$where = @($action == 'd')?$data['old']['parent_domain_id']:$data['new']['parent_domain_id'];
147+
$temp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $where);
140148
$out['describe_data'] = $temp['domain'];
141149
break;
142150
case 'directive_snippets':
@@ -148,6 +156,14 @@ function describe($dbtable, $data, $out) {
148156
case 'ftp_user':
149157
$check = 'username';
150158
break;
159+
case 'mail_archive':
160+
$check = 'storage';
161+
break;
162+
case 'mail_archive_store':
163+
$where = @($action == 'd')?$data['old']['domain_id']:$data['new']['domain_id'];
164+
$temp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain_id = ?", $where);
165+
$out['describe_data'] = $temp['domain'];
166+
break;
151167
case 'mail_domain':
152168
$check = 'domain';
153169
break;
@@ -160,6 +176,12 @@ function describe($dbtable, $data, $out) {
160176
case 'mail_user_filter':
161177
$check = 'rulename';
162178
break;
179+
case 'managed_monitor_checks':
180+
$check = 'description';
181+
break;
182+
case 'managed_php':
183+
$check = 'version';
184+
break;
163185
case 'remote_user':
164186
$check = 'remote_username';
165187
break;
@@ -189,7 +211,7 @@ function describe($dbtable, $data, $out) {
189211
break;
190212
}
191213

192-
if(!isset($out['describe_data'])) {
214+
if(!isset($out['describe_data'])) {
193215
$out['describe_data'] = @(isset($data['old'][$check]) && $data['old'][$check] != $data['new'][$check])?$data['old'][$check].'/'.$data['new'][$check]:$data['new'][$check];
194216
}
195217

interface/web/monitor/lib/lang/de_dataloghistory_view.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ $wb['new_txt'] = 'Neu';
2323
$wb['btn_cancel_txt'] = 'Zurück';
2424
$wb['undo_txt'] = 'Rückgängig machen';
2525
$wb['undo_confirmation_txt'] = 'Soll diese Änderung wirklich rückgängig gemacht werden?';
26+
$wb['datalog_username_txt'] = 'Username';
27+
$wb['datalog_userip_txt'] = 'IP';
2628
$wb['describe_client'] = 'Username';
2729
$wb['describe_cron'] = 'Webseite';
2830
$wb['describe_directive_snippets'] = 'Direktiven Schnippsel';
2931
$wb['describe_domain'] = 'Domain';
3032
$wb['describe_ftp_user'] = 'FTP-User';
33+
$wb['describe_mail_archive'] = 'Mail-Archiv';
34+
$wb['describe_mail_archive_store'] = 'Archiviert Email-Domain';
3135
$wb['describe_mail_domain'] = 'Email-Domain';
3236
$wb['describe_mail_forwarding'] = 'Quelle';
3337
$wb['describe_mail_user'] = 'Email';
3438
$wb['describe_mail_user_filter'] = 'Mailuser-Filter';
39+
$wb['describe_managed_php'] = 'PHP Version';
40+
$wb['describe_managed_monitor_checks'] = 'Check';
3541
$wb['describe_remote_user'] = 'Remote-User';
3642
$wb['describe_server_php'] = 'PHP Version';
3743
$wb['describe_shell_user'] = 'Shell-User';

interface/web/monitor/lib/lang/en_dataloghistory_view.lng

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,21 @@ $wb['new_txt'] = 'New';
2323
$wb['btn_cancel_txt'] = 'Back';
2424
$wb['undo_txt'] = 'Undo action';
2525
$wb['undo_confirmation_txt'] = 'Do you really want to undo this action?';
26+
$wb['datalog_username_txt'] = 'Username';
27+
$wb['datalog_userip_txt'] = 'IP';
2628
$wb['describe_client'] = 'Username';
2729
$wb['describe_cron'] = 'Website';
2830
$wb['describe_directive_snippets'] = 'Direktive Snippet';
2931
$wb['describe_domain'] = 'Domain';
3032
$wb['describe_ftp_user'] = 'FTP-User';
33+
$wb['describe_mail_archive'] = 'Mail-Archiv';
34+
$wb['describe_mail_archive_store'] = 'Archived Email-Domain';
3135
$wb['describe_mail_domain'] = 'Email-Domain';
3236
$wb['describe_mail_forwarding'] = 'Source';
3337
$wb['describe_mail_user'] = 'Email';
3438
$wb['describe_mail_user_filter'] = 'Mailuser-Filter';
39+
$wb['describe_managed_monitor_checks'] = 'Check';
40+
$wb['describe_managed_php'] = 'PHP Version';
3541
$wb['describe_remote_user'] = 'Remote-User';
3642
$wb['describe_shell_user'] = 'Shell-User';
3743
$wb['describe_server_php'] = 'PHP Version';

interface/web/monitor/templates/dataloghistory_view.htm

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ <h1><tmpl_var name="list_head_txt"></h1>
3434
<td><tmpl_var name="session_id_txt"></td>
3535
<td><tmpl_var name="session_id"></td>
3636
</tr>
37+
<tmpl_if name="datalog_username" op="!=" value="">
38+
<tr>
39+
<td><tmpl_var name="datalog_username_txt"></td>
40+
<td><tmpl_var name="datalog_username"> (<tmpl_var name="datalog_userip_txt">: <tmpl_var name="datalog_userip">)</td>
41+
</tr>
42+
</tmpl_if>
3743
</tbody>
3844
</table>
3945
</div>

server/lib/classes/cron.d/200-logfiles.inc.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ public function onRunJob() {
206206
}
207207
}
208208

209+
$app->db->query("DELETE FROM `sys_login` WHERE `login-time` < ADDDATE(NOW(), INTERVAL -? DAY)", $max_syslog);
210+
209211
//######################################################################################################
210212
// Cleanup website tmp directories
211213
//######################################################################################################

0 commit comments

Comments
 (0)