Skip to content

Commit 024e132

Browse files
author
Marius Cramer
committed
- ported some patches
1 parent ce55e07 commit 024e132

File tree

8 files changed

+67
-19
lines changed

8 files changed

+67
-19
lines changed

install/tpl/server.ini.master

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ apps_vhost_ip=_default_
7777
apps_vhost_servername=
7878
php_open_basedir=[website_path]/web:[website_path]/private:[website_path]/tmp:/var/www/[website_domain]/web:/srv/www/[website_domain]/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin
7979
htaccess_allow_override=All
80+
enable_spdy=y
8081
awstats_conf_dir=/etc/awstats
8182
awstats_data_dir=/var/lib/awstats
8283
awstats_pl=/usr/lib/cgi-bin/awstats.pl

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@
321321
'datatype' => 'INTEGER',
322322
'formtype' => 'SELECT',
323323
'default' => '2048',
324-
'value' => array('1024' => 'week (1024)', '2048' => 'normal (2048)', '4096' => 'strong (4096)')
324+
'value' => array('1024' => 'weak (1024)', '2048' => 'normal (2048)', '4096' => 'strong (4096)')
325325
),
326326
'relayhost_password' => array(
327327
'datatype' => 'VARCHAR',
@@ -1024,7 +1024,7 @@
10241024
'enable_spdy' => array (
10251025
'datatype' => 'VARCHAR',
10261026
'formtype' => 'CHECKBOX',
1027-
'default' => 'n',
1027+
'default' => 'y',
10281028
'value' => array (
10291029
0 => 'n',
10301030
1 => 'y'

interface/web/sites/web_sites_stats.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,26 +42,26 @@ function prepareDataRow($rec)
4242
$tmp_month = date('m');
4343
$tmp_rec = $app->db->queryOneRecord("SELECT SUM(traffic_bytes) as t FROM web_traffic WHERE hostname = ? AND YEAR(traffic_date) = ? AND MONTH(traffic_date) = ?", $rec['domain'], $tmp_year, $tmp_month);
4444
$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
45-
$this->sum_this_month += $app->functions->formatBytes($tmp_rec['t']);
45+
$this->sum_this_month += $tmp_rec['t'];
4646

4747

4848
//** Traffic of the current year
4949
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = ? AND YEAR(traffic_date) = ?", $rec['domain'], $tmp_year);
5050
$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
51-
$this->sum_this_year += $app->functions->formatBytes($tmp_rec['t']);
51+
$this->sum_this_year += $tmp_rec['t'];
5252

5353
//** Traffic of the last month
5454
$tmp_year = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
5555
$tmp_month = date('m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
5656
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = ? AND YEAR(traffic_date) = ? AND MONTH(traffic_date) = ?", $rec['domain'], $tmp_year, $tmp_month);
5757
$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
58-
$this->sum_last_month += $app->functions->formatBytes($tmp_rec['t']);
58+
$this->sum_last_month += $tmp_rec['t'];
5959

6060
//** Traffic of the last year
6161
$tmp_year = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
6262
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = ? AND YEAR(traffic_date) = ?", $rec['domain'], $tmp_year);
6363
$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
64-
$this->sum_last_year += $app->functions->formatBytes($tmp_rec['t']);
64+
$this->sum_last_year += $tmp_rec['t'];
6565

6666
//* The variable "id" contains always the index variable
6767
$rec['id'] = $rec[$this->idx_key];
@@ -73,10 +73,10 @@ function onShowEnd()
7373
{
7474
global $app;
7575

76-
$app->tpl->setVar('sum_this_month', number_format($app->functions->intval($this->sum_this_month), 0, '.', ' '));
77-
$app->tpl->setVar('sum_this_year', number_format($app->functions->intval($this->sum_this_year), 0, '.', ' '));
78-
$app->tpl->setVar('sum_last_month', number_format($app->functions->intval($this->sum_last_month), 0, '.', ' '));
79-
$app->tpl->setVar('sum_last_year', number_format($app->functions->intval($this->sum_last_year), 0, '.', ' '));
76+
$app->tpl->setVar('sum_this_month', $app->functions->formatBytes($this->sum_this_month));
77+
$app->tpl->setVar('sum_this_year', $app->functions->formatBytes($this->sum_this_year));
78+
$app->tpl->setVar('sum_last_month', $app->functions->formatBytes($this->sum_last_month));
79+
$app->tpl->setVar('sum_last_year', $app->functions->formatBytes($this->sum_last_year));
8080
$app->tpl->setVar('sum_txt', $app->listform->lng('sum_txt'));
8181

8282
$app->tpl_defaults();

interface/web/sites/web_vhost_domain_edit.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ function onShowEnd() {
635635
if(is_array($ssl_domains)) {
636636
foreach( $ssl_domains as $ssl_domain) {
637637
$selected = ($ssl_domain == $this->dataRecord['ssl_domain'])?'SELECTED':'';
638-
$ssl_domain_select .= "<option value='$ssl_domain' $selected>$ssl_domain</option>\r\n";
638+
$ssl_domain_select .= "<option value='$ssl_domain' $selected>".$app->functions->idn_decode($ssl_domain)."</option>\r\n";
639639
}
640640
}
641641
$app->tpl->setVar("ssl_domain", $ssl_domain_select);

interface/web/themes/default/assets/javascripts/ispconfig.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,11 @@ $(document).on('click', 'th[data-column]', function(e) {
635635

636636
var dir = $self.attr('data-ordered');
637637

638-
act = act + '?orderby=' + column;
638+
var separator = '?';
639+
if(act.indexOf("?") >= 0){
640+
separator = '&';
641+
}
642+
act = act + separator + 'orderby=' + column;
639643
ISPConfig.submitForm(form, act);
640644

641645
$(document).ajaxComplete(function() {

interface/web/themes/default/templates/error.tpl.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div class='alert alert-danger clear'>
2-
<div class='alert-label'><strong>ERROR</strong></div>
2+
<div class='alert-label'><strong><tmpl_var name="error_txt"></strong></div>
33
<div class='alert-content'>
44
<ol>
55
<li>###ERRORMSG###</li>

interface/web/themes/default/templates/tabbed_form.tpl.htm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ <h1><tmpl_var name="form_hint"></h1>
1010
</tmpl_if>
1111
<tmpl_if name="error">
1212
<div class='alert alert-danger clear'>
13-
<div class='alert-label'><strong>ERROR</strong></div>
13+
<div class='alert-label'><strong><tmpl_var name="error_txt"></strong></div>
1414
<div class='alert-content'>
1515
<ol><tmpl_var name="error"></ol>
1616
<div>TODO: IP address is empty.</div>

server/lib/classes/cron.d/100-mailbox_stats.inc.php

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ class cronjob_mailbox_stats extends cronjob {
3232

3333
// job schedule
3434
protected $_schedule = '0 0 * * *';
35+
protected $mailbox_traffic = array();
36+
protected $mail_boxes = array();
37+
protected $mail_rewrites = array();
3538

3639
/* this function is optional if it contains no custom code */
3740
public function onPrepare() {
@@ -164,7 +167,7 @@ function add_mailbox_traffic(&$traffic_array, $address, $traffic) {
164167
$cur_line = false;
165168

166169
if(file_exists($state_file)) {
167-
$prev_line = parse_mail_log_line(trim(file_get_contents($state_file)));
170+
$prev_line = $this->parse_mail_log_line(trim(file_get_contents($state_file)));
168171
//if($prev_line) echo "continuing from previous run, log position: " . $prev_line['message-id'] . " at " . strftime('%d.%m.%Y %H:%M:%S', $prev_line['timestamp']) . "\n";
169172
}
170173

@@ -175,7 +178,8 @@ function add_mailbox_traffic(&$traffic_array, $address, $traffic) {
175178
while($line = fgets($fp, 8192)) {
176179
$l++;
177180
//if($l % 1000 == 0) echo "\rline $l";
178-
$cur_line = parse_mail_log_line($line);
181+
$cur_line = $this->parse_mail_log_line($line);
182+
//print_r($cur_line);
179183
if(!$cur_line) continue;
180184

181185
if($prev_line) {
@@ -190,9 +194,13 @@ function add_mailbox_traffic(&$traffic_array, $address, $traffic) {
190194
}
191195
}
192196

193-
add_mailbox_traffic($mailbox_traffic, $cur_line['from'], $cur_line['size']);
197+
$this->add_mailbox_traffic($cur_line['from'], $cur_line['size']);
198+
//echo "1\n";
199+
//print_r($this->mailbox_traffic);
194200
foreach($cur_line['to'] as $to) {
195-
add_mailbox_traffic($mailbox_traffic, $to, $cur_line['size']);
201+
$this->add_mailbox_traffic($to, $cur_line['size']);
202+
//echo "2\n";
203+
//print_r($this->mailbox_traffic);
196204
}
197205
$last_line = $line; // store for the state file
198206
}
@@ -207,7 +215,7 @@ function add_mailbox_traffic(&$traffic_array, $address, $traffic) {
207215
while($line = fgets($fp, 8192)) {
208216
$l++;
209217
//if($l % 1000 == 0) echo "\rline $l";
210-
$cur_line = parse_mail_log_line($line);
218+
$cur_line = $this->parse_mail_log_line($line);
211219
if(!$cur_line) continue;
212220

213221
if($prev_line) {
@@ -265,6 +273,41 @@ public function onAfterRun() {
265273

266274
parent::onAfterRun();
267275
}
276+
277+
private function parse_mail_log_line($line) {
278+
//Oct 31 17:35:48 mx01 amavis[32014]: (32014-05) Passed CLEAN, [IPv6:xxxxx] [IPv6:xxxxx] <xxx@yyyy> -> <aaaa@bbbb>, Message-ID: <xxxx@yyyyy>, mail_id: xxxxxx, Hits: -1.89, size: 1591, queued_as: xxxxxxx, 946 ms
279+
280+
if(preg_match('/^(\w+\s+\d+\s+\d+:\d+:\d+)\s+[^ ]+\s+amavis.* <([^>]+)>\s+->\s+((<[^>]+>,)+) .*Message-ID:\s+<([^>]+)>.* size:\s+(\d+),.*$/', $line, $matches) == false) return false;
281+
282+
$timestamp = strtotime($matches[1]);
283+
if(!$timestamp) return false;
284+
285+
$to = array();
286+
$recipients = explode(',', $matches[3]);
287+
foreach($recipients as $recipient) {
288+
$recipient = substr($recipient, 1, -1);
289+
if(!$recipient || $recipient == $matches[2]) continue;
290+
$to[] = $recipient;
291+
}
292+
return array('line' => $line, 'timestamp' => $timestamp, 'size' => $matches[6], 'from' => $matches[2], 'to' => $to, 'message-id' => $matches[5]);
293+
}
294+
295+
private function add_mailbox_traffic($address, $traffic) {
296+
297+
$address = strtolower($address);
298+
299+
if(in_array($address, $this->mail_boxes) == true) {
300+
if(!isset($this->mailbox_traffic[$address])) $this->mailbox_traffic[$address] = 0;
301+
$this->mailbox_traffic[$address] += $traffic;
302+
} elseif(array_key_exists($address, $this->mail_rewrites)) {
303+
foreach($this->mail_rewrites[$address] as $address) {
304+
if(!isset($this->mailbox_traffic[$address])) $this->mailbox_traffic[$address] = 0;
305+
$this->mailbox_traffic[$address] += $traffic;
306+
}
307+
} else {
308+
// this is not a local address - skip it
309+
}
310+
}
268311

269312
}
270313

0 commit comments

Comments
 (0)