Skip to content

Commit

Permalink
v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coax committed Feb 8, 2017
1 parent 644da35 commit 48bde7c
Show file tree
Hide file tree
Showing 11 changed files with 113 additions and 106 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Common issues: https://www.hmailserver.com/documentation/latest/?page=ts_setup_p

Changelog
-----
Version 1.0 (2017-02-08)
- stable release
- minor tweaks and improvements

Version 0.9.8 beta (2017-02-03)
- [new] powerful log parser (using server-side logs)
- [new] datepicker for date fields
Expand Down Expand Up @@ -132,12 +136,12 @@ Version 0.9 beta (2016-12-28)
- [jQuery](https://jquery.com/)
- [Modernizr](https://modernizr.com/)
- [Defunkt Facebox](http://defunkt.io/facebox/Defunkt Facebox)
- [tablesort](http://github.com/kylefox/jquery-tablesorttablesort)
- [tablesort](https://github.com/kylefox/jquery-tablesorttablesort)
- [datepicker](https://github.com/fengyuanchen/datepicker)
- [timeago](http://timeago.yarp.com/timeago)
- [Chartist](https://gionkunz.github.io/chartist-js/Chartist)
- [CodyHouse Responsive Sidebar Navigation](https://codyhouse.co/gem/responsive-sidebar-navigation/)
- [Open Iconic](https://useiconic.com/open/)
- [hMailServer log viewer](https://github.com/hazarkarabay/hmailserver-logviewer)

Questions and contributions
-----
Expand Down
2 changes: 1 addition & 1 deletion hMailAdmin/hm_account.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
PrintCheckboxRow("vacationmessageexpires", "Automatically expires", $vacationmessageexpires);
?>
<p><?php EchoTranslation("Expiration date (YYYY-MM-DD)")?></p>
<input type="text" name="vacationmessageexpiresdate" value="<?php echo $vacationmessageexpiresdate ?>" maxlength="10" data-toggle="datepicker" class="small">
<input type="text" name="vacationmessageexpiresdate" value="<?php echo $vacationmessageexpiresdate ?>" maxlength="10" data-toggle="datepicker" class="medium">
</div>
<h3><a href="#"><?php EchoTranslation("Forwarding")?></a></h3>
<div class="hidden">
Expand Down
2 changes: 1 addition & 1 deletion hMailAdmin/hm_accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
$AccountEnabled = $obAccount->Active ? $obLanguage->String("Yes") : $obLanguage->String("No");
$AccountSize = $obAccount->Size();
$Color = "green";
if($accountmaxsize != 0){
if($accountmaxsize > 0){
$Percentage = Round((($accountmaxsize - $AccountSize) / ($accountmaxsize)) * 100);
if ($Percentage<=10) $Color = "red";
elseif ($Percentage<=30) $Color = "yellow";
Expand Down
14 changes: 7 additions & 7 deletions hMailAdmin/hm_logviewer.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,34 @@
hmailHackingAttemp();
?>
<div class="box large">
<h2>hMailServer Log Parser</h2>
<h2><?php EchoTranslation("hMailServer Log Parser") ?></h2>
<div style="margin:0 18px 18px;">
<form action="" class="cd-form" id="log-parser">
<?php
PrintHiddenCsrfToken();
?>
<p>Date:</p>
<p><?php EchoTranslation("Date") ?>:</p>
<input type="text" name="LogFilename" value="<?php echo date("Y-m-d") ?>" maxlength="10" data-toggle="datepicker" class="small">
<p>Show logs only for:</p>
<p><?php EchoTranslation("Show logs only for") ?>:</p>
<select name="LogType" class="small">
<option value="SMTPD" selected>SMTP server (daemon)</option>
<option value="SMTPC">SMTP client</option>
<option value="POP3D">POP3</option>
<option value="POP3C">POP3 fetch</option>
<option value="IMAPD">IMAP</option>
<option value="DEBUG">Debug</option>
<option value="TCPIP">Tcp IP</option>
<option value="TCPIP">TCP/IP</option>
<option value="APPLICATION">Application</option>
<option value="ERROR">Errors</option>
<option value="ALL">All</option>
<option value="RAW">Unparsed (raw)</option>
</select>
<p>Filter results by:</p>
<p><?php EchoTranslation("Filter results by") ?>:</p>
<input type="text" name="LogFilter" value="" maxlength="50" class="small">
<div class="buttons"><input type="submit" value="Parse log"></div>
<p>Results:</p>
<p><?php EchoTranslation("Results") ?>:</p>
<div id="results">
Click on "Parse log" button
<?php EchoTranslation("Click on \"Parse log\" button") ?>
</div>
<div class="buttons"><input type="button" value="Clear results"></div>
</form>
Expand Down
2 changes: 1 addition & 1 deletion hMailAdmin/hm_securityrange.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
PrintHidden("action", $action);
PrintHidden("securityrangeid", $securityrangeid);

PrintPropertyEditRow("securityrangename", "Name", $securityrangename);
PrintPropertyEditRow("securityrangename", "Name", $securityrangename, 255);
PrintPropertyEditRow("securityrangepriority", "Priority", $securityrangepriority, 5, "number", "small");
PrintPropertyEditRow("securityrangelowerip", "Lower IP", $securityrangelowerip, 30, "ip");
PrintPropertyEditRow("securityrangeupperip", "Upper IP", $securityrangeupperip, 30, "ip");
Expand Down
23 changes: 9 additions & 14 deletions hMailAdmin/hm_securityranges.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<?php
function humanTiming($time) {
$time = $time - time();
$time = ($time<1) ? 0 : $time;
if($time < 1) return 'Expired';
$tokens = array (
31536000 => 'year',
2592000 => 'month',
Expand All @@ -36,14 +36,11 @@ function humanTiming($time) {
1 => 'second'
);

if ($time == 0)
return 'Never';
else
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits . ' ' . $text . (($numberOfUnits>1) ? 's' : '');
}
foreach ($tokens as $unit => $text) {
if ($time < $unit) continue;
$numberOfUnits = floor($time / $unit);
return $numberOfUnits . ' ' . $text . (($numberOfUnits>1) ? 's' : '');
}
}

for ($i = 0; $i < $Count; $i++) {
Expand All @@ -52,15 +49,13 @@ function humanTiming($time) {
$securityrangeid = $obSecurityRange->ID;

$securityrangename = PreprocessOutput($securityrangename);
$securityrangepriority = $obSecurityRange->Priority; //added
//$ExpiresTime = $obSecurityRange->Expires ? ceil((strtotime($obSecurityRange->ExpiresTime)-time())/60):'Never expires'; //added
$ExpiresTime = $obSecurityRange->ExpiresTime;

$securityrangepriority = $obSecurityRange->Priority;
$ExpiresTime = $obSecurityRange->Expires ? humanTiming(strtotime(makeIsoDate($obSecurityRange->ExpiresTime))) : 'Never';

echo ' <tr>
<td><a href="?page=securityrange&action=edit&securityrangeid=' . $securityrangeid . '"' . (strpos($securityrangename,'Auto-ban:')!==false?' class="red"':'') . '>' . $securityrangename . '</a></td>
<td>' . $securityrangepriority . '</td>
<td>' . humanTiming(strtotime($ExpiresTime)) . '</td>
<td>' . $ExpiresTime . '</td>
<td><a href="#" onclick="return Confirm(\'Confirm delete <b>' . $securityrangename . '</b>:\',\'Yes\',\'?page=background_securityrange_save&csrftoken=' . $csrftoken . '&action=delete&securityrangeid=' . $securityrangeid . '\');" class="delete">Delete</a></td>
</tr>' . PHP_EOL;
}
Expand Down
2 changes: 1 addition & 1 deletion hMailAdmin/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
include "include_treemenu.php";
?>
</ul>
<a href="modern/impressum.php" rel="facebox" class="impressum">hMailAdmin 0.9.8 [beta]</a>
<a href="modern/impressum.php" rel="facebox" class="impressum">hMailAdmin 1.0</a>
</nav>

<div class="content-wrapper">
Expand Down
5 changes: 5 additions & 0 deletions hMailAdmin/modern/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ b {font-weight:700;}
/* boxes */
.box, .box.medium, .box.large {width:100%;}
.box {float:left; display:block; position:relative; overflow:hidden; background:#fff; margin:0 3% 3% 0; border-radius:3px;}
.box:nth-child(3) {margin-right:0;}
.box .grey {border-top:1px solid #f2f2f2; background:#f9fafa; padding:18px;}
.box .grey div {display:inline-block; width:32%; text-align:center; color:#acacac; font-size:12px;}
.box .grey span {font-size:18px; color:#3e454c; line-height:120%;}
Expand All @@ -84,6 +85,7 @@ table td a:nth-child(1) {padding-left:10px;}
table.queue th:nth-child(1), table.queue th:nth-child(6), table.queue td:nth-child(1), table.queue td:nth-child(6) {width:8%;}
table.queue th:nth-child(2), table.queue th:nth-child(5), table.queue td:nth-child(2), table.queue td:nth-child(5) {width:17%; overflow:hidden; overflow-x:auto;}
table.queue th:nth-child(3), table.queue th:nth-child(4), table.queue td:nth-child(3), table.queue td:nth-child(4) {width:25%; overflow:hidden; overflow-x:auto;}
table.queue tbody tr td {font-size:12px;}

/* chartist */
.ct-series-a .ct-point, .ct-series-a .ct-line, .ct-series-a .ct-bar, .ct-series-a .ct-slice-donut {stroke:#3dbef9;}
Expand All @@ -98,6 +100,7 @@ table.queue th:nth-child(3), table.queue th:nth-child(4), table.queue td:nth-chi
.chartist-tooltip:after {position:absolute; left:50%; bottom:-6px; content:' '; height:0; margin:0 0 0 -6px; border-right:5px solid transparent; border-left:5px solid transparent; border-top:6px solid rgba(255,255,255,.95); line-height:0;}
.chartist-tooltip.tooltip-show {opacity:1;}
.ct-area, .ct-line {pointer-events:none;}
.ct-vertical {font-size:9px;}

/* facebox modal */
#facebox {position:absolute; top:0; left:0; z-index:100; text-align:left; display:none;}
Expand Down Expand Up @@ -234,6 +237,8 @@ input.wait, input:hover.wait {background:url('../../modern/css/wait.gif') 50% no
.cd-form #results > div ul li div:first-child {width:180px;}
.cd-form #results > div ul li div em {font-style:normal; color:#ff7e66;}
.cd-form #results > div sup {font-size:9px;}
.cd-form #results > div ul li.sent {color:#1784c7;}
.cd-form #results > div ul li.recieved {color:#87c442;}

/* tablet */
@media only screen and (min-width:768px) {
Expand Down
4 changes: 2 additions & 2 deletions hMailAdmin/modern/impressum.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h2>Impressum</h2>
<div style="margin:0 18px 18px;">
<p>hMailServer web admin redesign &amp; coding by <a href="http://www.matecic.com/" target="_blank">Matija Matečić</a></p>
<p>hMailServer web admin redesign &amp; coding by <a href="http://www.matecic.com/" target="_blank">Matija Matecic</a></p>
<p>Additional coding by Andreas Tunberg</p>
<p>Version 0.9.8 [beta], source on <a href="https://github.com/coax/hmailserver-webadmin" target="_blank">GitHub</a>
<p>Version 1.0, source on <a href="https://github.com/coax/hmailserver-webadmin" target="_blank">GitHub</a>
<p>hMailServer author Martin Knafve</p>
<p>License information <a href="https://www.hmailserver.com/documentation/latest/?page=information_copyright" target="_blank">here</a></p>
<h3>Third party components</h3>
Expand Down
42 changes: 39 additions & 3 deletions hMailAdmin/modern/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ jQuery(document).ready(function(){
data: params,
cache: false,
timeout: 50000,
dataType: 'json',
beforeSend: function() {
result.html('Please wait... this might take some time.');
button.prop('disabled', true).addClass('wait');
},
success: function(data) {
result.html(data);
result.html(parseLog(data));
button.prop('disabled', false).removeClass('wait');
}
});
Expand All @@ -60,16 +61,17 @@ jQuery(document).ready(function(){
axisX: {
offset: 0,
showLabel: false,
showGrid: false,
showGrid: false
},
axisY: {
offset: 0,
showLabel: false,
showGrid: false,
onlyInteger: true
},
showLine: true,
showPoint: false,
showArea: true,
showArea: true
});


Expand Down Expand Up @@ -427,4 +429,38 @@ function CallAjax(url,result) {
result.html('<div class="warning">' + data + '</div>');
}
});
}

//log parsing magic
function parseLog(data) {
if(typeof data == 'string') return data;
var out = '';
$.each(data,function(k,v){
out += parseLogGroup(v);
});
return out;
}

function parseLogGroup(data) {
if(data[0][0]=='RAW') return parseLogRaw(data);
var out = '<div><span>' + data[0][0];
if(data[0][0]=='SMTPD'||data[0][0]=='SMTPC'||data[0][0]=='POP3D'||data[0][0]=='POP3C'||data[0][0]=='IMAPD')
out += ' &nbsp;&ndash;&nbsp; ' + data[0][1] + ' &nbsp;&ndash;&nbsp; ' + data[0][2] + ' <sup><a href="https://href.li/?http://ip-api.com/line/' + data[0][2] + '" target="_blank">?</a></sup>';
out += '</span><ul>';
$.each(data[1],function(k,v){
var css = '';
if (v[1].indexOf('RECEIVED:') > -1) css = 'recieved';
else if (v[1].indexOf('SENT:') > -1) css = 'sent';
out += '<li class="' + css + '"><div>' + v[0] + '</div><div>' + v[1] + '</div></li>';
});
out += '</ul></div>';
return out;
}

function parseLogRaw(data) {
var out = '';
$.each(data[1],function(k,v){
out += v + '<br>';
});
return out;
}
Loading

0 comments on commit 48bde7c

Please sign in to comment.