Commit cc7931df authored by Till Brehm's avatar Till Brehm

Merge branch 'master' into 'master'

Master

See merge request !895
parents 708631d7 d0dd6702
......@@ -166,3 +166,12 @@ CREATE TABLE IF NOT EXISTS `sys_mailqueue` (
ALTER TABLE `web_domain` ADD `jailkit_jkupdate_cron` enum('n','y') NOT NULL DEFAULT 'y' AFTER `custom_php_ini`;
ALTER TABLE `sys_datalog` ADD `session_id` varchar(64) NOT NULL DEFAULT '' AFTER `error`;
CREATE TABLE IF NOT EXISTS `sys_login` (
`session_id` varchar(64) NOT NULL,
`username` varchar(64) NOT NULL default '',
`ip` varchar(255) NOT NULL default '',
`login-time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
......@@ -1556,6 +1556,21 @@ CREATE TABLE `sys_group` (
PRIMARY KEY (`groupid`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
-- --------------------------------------------------------
--
-- Table structure for table `sys_login`
--
CREATE TABLE `sys_login` (
`session_id` varchar(64) NOT NULL,
`username` varchar(64) NOT NULL default '',
`ip` varchar(255) NOT NULL default '',
`login-time` TIMESTAMP ON UPDATE CURRENT_TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`session_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
-- --------------------------------------------------------
--
......
......@@ -262,11 +262,13 @@ if(count($_POST) > 0) {
$app->plugin->raiseEvent('login', $username);
//* Save successfull login message to var
$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s') . ' with session ID ' .session_id();
//$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s');
$authlog = 'Successful login for user \''. $username .'\' from '. $_SERVER['REMOTE_ADDR'] .' at '. date('Y-m-d H:i:s') . ' with session ID ' .session_id();
$authlog_handle = fopen($conf['ispconfig_log_dir'].'/auth.log', 'a');
fwrite($authlog_handle, $authlog ."\n");
fclose($authlog_handle);
$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']);
// get last IP used to login
$user_data = $app->db->queryOneRecord("SELECT last_login_ip,last_login_at FROM sys_user WHERE username = ?", $username);
......@@ -275,12 +277,13 @@ if(count($_POST) > 0) {
if(!$loginAs) {
$app->db->query("UPDATE sys_user SET last_login_ip = ?, last_login_at = ? WHERE username = ?", $_SERVER['REMOTE_ADDR'], time(), $username);
}
/*
* We need LOGIN_REDIRECT instead of HEADER_REDIRECT to load the
* new theme, if the logged-in user has another
*/
if($loginAs) {
if ($loginAs){
echo 'LOGIN_REDIRECT:'.$_SESSION['s']['module']['startpage'];
exit;
} else {
......@@ -292,7 +295,8 @@ if(count($_POST) > 0) {
$error = $app->lng('error_user_blocked');
}
} else {
if(!$alreadyfailed['times']) {
if(!$alreadyfailed['times'] )
{
//* user login the first time wrong
$sql = "INSERT INTO `attempts_login` (`ip`, `times`, `login_time`) VALUES (?, 1, NOW())";
$app->db->query($sql, $ip);
......@@ -351,17 +355,7 @@ $app->tpl->setVar('current_theme', isset($_SESSION['s']['theme']) ? $_SESSION['s
//die(isset($_SESSION['s']['theme']) ? $_SESSION['s']['theme'] : 'default');
// Logo
$logo = $app->db->queryOneRecord("SELECT * FROM sys_ini WHERE sysini_id = 1");
if($logo['custom_logo'] != ''){
$base64_logo_txt = $logo['custom_logo'];
} else {
$base64_logo_txt = $logo['default_logo'];
}
$tmp_base64 = explode(',', $base64_logo_txt, 2);
$logo_dimensions = $app->functions->getimagesizefromstring(base64_decode($tmp_base64[1]));
$app->tpl->setVar('base64_logo_width', $logo_dimensions[0].'px');
$app->tpl->setVar('base64_logo_height', $logo_dimensions[1].'px');
$app->tpl->setVar('base64_logo_txt', $base64_logo_txt);
$app->tpl->logo();
// Title
if (!empty($sys_config['company_name'])) {
......
......@@ -57,11 +57,18 @@ $out['action_name'] = $app->lng($record['action']);
$out['session_id'] = $record['session_id'];
if ($out['session_id'] != '') {
$temp = $app->db->queryOneRecord("SELECT username, ip FROM sys_login WHERE session_id = ?", $out['session_id']);
$out['datalog_username'] = $temp['username'];
$out['datalog_userip'] = $temp['ip'];
unset($temp);
}
if(!$data = unserialize(stripslashes($record['data']))) {
$data = unserialize($record['data']);
}
$out = describe($record['dbtable'], $data, $out);
$out = describe($record['dbtable'], $data, $out, $record['action']);
switch ($record['action']) {
case 'i':
......@@ -118,7 +125,7 @@ function show_diff_if_needed($old, $new) {
global $app;
$diff_min_lines = 6;
$where = @($action == 'd')?$data['old']['parent_domain_id']:$data['new']['parent_domain_id'];
if (substr_count($old, "\n") >= $diff_min_lines || substr_count($new, "\n") >= $diff_min_lines) {
$opcodes = FineDiff::getDiffOpcodes($old, $new);
$html = FineDiff::renderUTF8DiffToHTMLFromOpcodes($old, $opcodes);
......@@ -128,7 +135,7 @@ function show_diff_if_needed($old, $new) {
}
}
function describe($dbtable, $data, $out) {
function describe($dbtable, $data, $out, $action) {
global $app;
$out['describe'] = $app->lng('describe_'.$dbtable);
switch ($dbtable) {
......@@ -136,7 +143,8 @@ function describe($dbtable, $data, $out) {
$check = 'username';
break;
case 'cron':
$temp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $data['new']['parent_domain_id']);
$where = @($action == 'd')?$data['old']['parent_domain_id']:$data['new']['parent_domain_id'];
$temp = $app->db->queryOneRecord("SELECT domain FROM web_domain WHERE domain_id = ?", $where);
$out['describe_data'] = $temp['domain'];
break;
case 'directive_snippets':
......@@ -148,6 +156,14 @@ function describe($dbtable, $data, $out) {
case 'ftp_user':
$check = 'username';
break;
case 'mail_archive':
$check = 'storage';
break;
case 'mail_archive_store':
$where = @($action == 'd')?$data['old']['domain_id']:$data['new']['domain_id'];
$temp = $app->db->queryOneRecord("SELECT domain FROM mail_domain WHERE domain_id = ?", $where);
$out['describe_data'] = $temp['domain'];
break;
case 'mail_domain':
$check = 'domain';
break;
......@@ -160,6 +176,12 @@ function describe($dbtable, $data, $out) {
case 'mail_user_filter':
$check = 'rulename';
break;
case 'managed_monitor_checks':
$check = 'description';
break;
case 'managed_php':
$check = 'version';
break;
case 'remote_user':
$check = 'remote_username';
break;
......@@ -189,7 +211,7 @@ function describe($dbtable, $data, $out) {
break;
}
if(!isset($out['describe_data'])) {
if(!isset($out['describe_data'])) {
$out['describe_data'] = @(isset($data['old'][$check]) && $data['old'][$check] != $data['new'][$check])?$data['old'][$check].'/'.$data['new'][$check]:$data['new'][$check];
}
......
......@@ -23,15 +23,21 @@ $wb['new_txt'] = 'Neu';
$wb['btn_cancel_txt'] = 'Zurück';
$wb['undo_txt'] = 'Rückgängig machen';
$wb['undo_confirmation_txt'] = 'Soll diese Änderung wirklich rückgängig gemacht werden?';
$wb['datalog_username_txt'] = 'Username';
$wb['datalog_userip_txt'] = 'IP';
$wb['describe_client'] = 'Username';
$wb['describe_cron'] = 'Webseite';
$wb['describe_directive_snippets'] = 'Direktiven Schnippsel';
$wb['describe_domain'] = 'Domain';
$wb['describe_ftp_user'] = 'FTP-User';
$wb['describe_mail_archive'] = 'Mail-Archiv';
$wb['describe_mail_archive_store'] = 'Archiviert Email-Domain';
$wb['describe_mail_domain'] = 'Email-Domain';
$wb['describe_mail_forwarding'] = 'Quelle';
$wb['describe_mail_user'] = 'Email';
$wb['describe_mail_user_filter'] = 'Mailuser-Filter';
$wb['describe_managed_php'] = 'PHP Version';
$wb['describe_managed_monitor_checks'] = 'Check';
$wb['describe_remote_user'] = 'Remote-User';
$wb['describe_server_php'] = 'PHP Version';
$wb['describe_shell_user'] = 'Shell-User';
......
......@@ -23,15 +23,21 @@ $wb['new_txt'] = 'New';
$wb['btn_cancel_txt'] = 'Back';
$wb['undo_txt'] = 'Undo action';
$wb['undo_confirmation_txt'] = 'Do you really want to undo this action?';
$wb['datalog_username_txt'] = 'Username';
$wb['datalog_userip_txt'] = 'IP';
$wb['describe_client'] = 'Username';
$wb['describe_cron'] = 'Website';
$wb['describe_directive_snippets'] = 'Direktive Snippet';
$wb['describe_domain'] = 'Domain';
$wb['describe_ftp_user'] = 'FTP-User';
$wb['describe_mail_archive'] = 'Mail-Archiv';
$wb['describe_mail_archive_store'] = 'Archived Email-Domain';
$wb['describe_mail_domain'] = 'Email-Domain';
$wb['describe_mail_forwarding'] = 'Source';
$wb['describe_mail_user'] = 'Email';
$wb['describe_mail_user_filter'] = 'Mailuser-Filter';
$wb['describe_managed_monitor_checks'] = 'Check';
$wb['describe_managed_php'] = 'PHP Version';
$wb['describe_remote_user'] = 'Remote-User';
$wb['describe_shell_user'] = 'Shell-User';
$wb['describe_server_php'] = 'PHP Version';
......
......@@ -34,6 +34,12 @@
<td><tmpl_var name="session_id_txt"></td>
<td><tmpl_var name="session_id"></td>
</tr>
<tmpl_if name="datalog_username" op="!=" value="">
<tr>
<td><tmpl_var name="datalog_username_txt"></td>
<td><tmpl_var name="datalog_username"> (<tmpl_var name="datalog_userip_txt">: <tmpl_var name="datalog_userip">)</td>
</tr>
</tmpl_if>
</tbody>
</table>
</div>
......
......@@ -206,6 +206,8 @@ class cronjob_logfiles extends cronjob {
}
}
$app->db->query("DELETE FROM `sys_login` WHERE `login-time` < ADDDATE(NOW(), INTERVAL -? DAY)", $max_syslog);
//######################################################################################################
// Cleanup website tmp directories
//######################################################################################################
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment