Commit 024e1329 authored by Marius Cramer's avatar Marius Cramer

- ported some patches

parent ce55e07a
......@@ -77,6 +77,7 @@ apps_vhost_ip=_default_
apps_vhost_servername=
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
htaccess_allow_override=All
enable_spdy=y
awstats_conf_dir=/etc/awstats
awstats_data_dir=/var/lib/awstats
awstats_pl=/usr/lib/cgi-bin/awstats.pl
......
......@@ -321,7 +321,7 @@ $form["tabs"]['mail'] = array(
'datatype' => 'INTEGER',
'formtype' => 'SELECT',
'default' => '2048',
'value' => array('1024' => 'week (1024)', '2048' => 'normal (2048)', '4096' => 'strong (4096)')
'value' => array('1024' => 'weak (1024)', '2048' => 'normal (2048)', '4096' => 'strong (4096)')
),
'relayhost_password' => array(
'datatype' => 'VARCHAR',
......@@ -1024,7 +1024,7 @@ $form["tabs"]['web'] = array(
'enable_spdy' => array (
'datatype' => 'VARCHAR',
'formtype' => 'CHECKBOX',
'default' => 'n',
'default' => 'y',
'value' => array (
0 => 'n',
1 => 'y'
......
......@@ -42,26 +42,26 @@ class list_action extends listform_actions {
$tmp_month = date('m');
$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);
$rec['this_month'] = $app->functions->formatBytes($tmp_rec['t']);
$this->sum_this_month += $app->functions->formatBytes($tmp_rec['t']);
$this->sum_this_month += $tmp_rec['t'];
//** Traffic of the current year
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = ? AND YEAR(traffic_date) = ?", $rec['domain'], $tmp_year);
$rec['this_year'] = $app->functions->formatBytes($tmp_rec['t']);
$this->sum_this_year += $app->functions->formatBytes($tmp_rec['t']);
$this->sum_this_year += $tmp_rec['t'];
//** Traffic of the last month
$tmp_year = date('Y', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
$tmp_month = date('m', mktime(0, 0, 0, date("m")-1, date("d"), date("Y")));
$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);
$rec['last_month'] = $app->functions->formatBytes($tmp_rec['t']);
$this->sum_last_month += $app->functions->formatBytes($tmp_rec['t']);
$this->sum_last_month += $tmp_rec['t'];
//** Traffic of the last year
$tmp_year = date('Y', mktime(0, 0, 0, date("m"), date("d"), date("Y")-1));
$tmp_rec = $app->db->queryOneRecord("SELECT sum(traffic_bytes) as t FROM web_traffic WHERE hostname = ? AND YEAR(traffic_date) = ?", $rec['domain'], $tmp_year);
$rec['last_year'] = $app->functions->formatBytes($tmp_rec['t']);
$this->sum_last_year += $app->functions->formatBytes($tmp_rec['t']);
$this->sum_last_year += $tmp_rec['t'];
//* The variable "id" contains always the index variable
$rec['id'] = $rec[$this->idx_key];
......@@ -73,10 +73,10 @@ class list_action extends listform_actions {
{
global $app;
$app->tpl->setVar('sum_this_month', number_format($app->functions->intval($this->sum_this_month), 0, '.', ' '));
$app->tpl->setVar('sum_this_year', number_format($app->functions->intval($this->sum_this_year), 0, '.', ' '));
$app->tpl->setVar('sum_last_month', number_format($app->functions->intval($this->sum_last_month), 0, '.', ' '));
$app->tpl->setVar('sum_last_year', number_format($app->functions->intval($this->sum_last_year), 0, '.', ' '));
$app->tpl->setVar('sum_this_month', $app->functions->formatBytes($this->sum_this_month));
$app->tpl->setVar('sum_this_year', $app->functions->formatBytes($this->sum_this_year));
$app->tpl->setVar('sum_last_month', $app->functions->formatBytes($this->sum_last_month));
$app->tpl->setVar('sum_last_year', $app->functions->formatBytes($this->sum_last_year));
$app->tpl->setVar('sum_txt', $app->listform->lng('sum_txt'));
$app->tpl_defaults();
......
......@@ -635,7 +635,7 @@ class page_action extends tform_actions {
if(is_array($ssl_domains)) {
foreach( $ssl_domains as $ssl_domain) {
$selected = ($ssl_domain == $this->dataRecord['ssl_domain'])?'SELECTED':'';
$ssl_domain_select .= "<option value='$ssl_domain' $selected>$ssl_domain</option>\r\n";
$ssl_domain_select .= "<option value='$ssl_domain' $selected>".$app->functions->idn_decode($ssl_domain)."</option>\r\n";
}
}
$app->tpl->setVar("ssl_domain", $ssl_domain_select);
......
......@@ -635,7 +635,11 @@ $(document).on('click', 'th[data-column]', function(e) {
var dir = $self.attr('data-ordered');
act = act + '?orderby=' + column;
var separator = '?';
if(act.indexOf("?") >= 0){
separator = '&';
}
act = act + separator + 'orderby=' + column;
ISPConfig.submitForm(form, act);
$(document).ajaxComplete(function() {
......
<div class='alert alert-danger clear'>
<div class='alert-label'><strong>ERROR</strong></div>
<div class='alert-label'><strong><tmpl_var name="error_txt"></strong></div>
<div class='alert-content'>
<ol>
<li>###ERRORMSG###</li>
......
......@@ -10,7 +10,7 @@
</tmpl_if>
<tmpl_if name="error">
<div class='alert alert-danger clear'>
<div class='alert-label'><strong>ERROR</strong></div>
<div class='alert-label'><strong><tmpl_var name="error_txt"></strong></div>
<div class='alert-content'>
<ol><tmpl_var name="error"></ol>
<div>TODO: IP address is empty.</div>
......
......@@ -32,6 +32,9 @@ class cronjob_mailbox_stats extends cronjob {
// job schedule
protected $_schedule = '0 0 * * *';
protected $mailbox_traffic = array();
protected $mail_boxes = array();
protected $mail_rewrites = array();
/* this function is optional if it contains no custom code */
public function onPrepare() {
......@@ -164,7 +167,7 @@ class cronjob_mailbox_stats extends cronjob {
$cur_line = false;
if(file_exists($state_file)) {
$prev_line = parse_mail_log_line(trim(file_get_contents($state_file)));
$prev_line = $this->parse_mail_log_line(trim(file_get_contents($state_file)));
//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";
}
......@@ -175,7 +178,8 @@ class cronjob_mailbox_stats extends cronjob {
while($line = fgets($fp, 8192)) {
$l++;
//if($l % 1000 == 0) echo "\rline $l";
$cur_line = parse_mail_log_line($line);
$cur_line = $this->parse_mail_log_line($line);
//print_r($cur_line);
if(!$cur_line) continue;
if($prev_line) {
......@@ -190,9 +194,13 @@ class cronjob_mailbox_stats extends cronjob {
}
}
add_mailbox_traffic($mailbox_traffic, $cur_line['from'], $cur_line['size']);
$this->add_mailbox_traffic($cur_line['from'], $cur_line['size']);
//echo "1\n";
//print_r($this->mailbox_traffic);
foreach($cur_line['to'] as $to) {
add_mailbox_traffic($mailbox_traffic, $to, $cur_line['size']);
$this->add_mailbox_traffic($to, $cur_line['size']);
//echo "2\n";
//print_r($this->mailbox_traffic);
}
$last_line = $line; // store for the state file
}
......@@ -207,7 +215,7 @@ class cronjob_mailbox_stats extends cronjob {
while($line = fgets($fp, 8192)) {
$l++;
//if($l % 1000 == 0) echo "\rline $l";
$cur_line = parse_mail_log_line($line);
$cur_line = $this->parse_mail_log_line($line);
if(!$cur_line) continue;
if($prev_line) {
......@@ -265,6 +273,41 @@ class cronjob_mailbox_stats extends cronjob {
parent::onAfterRun();
}
private function parse_mail_log_line($line) {
//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
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;
$timestamp = strtotime($matches[1]);
if(!$timestamp) return false;
$to = array();
$recipients = explode(',', $matches[3]);
foreach($recipients as $recipient) {
$recipient = substr($recipient, 1, -1);
if(!$recipient || $recipient == $matches[2]) continue;
$to[] = $recipient;
}
return array('line' => $line, 'timestamp' => $timestamp, 'size' => $matches[6], 'from' => $matches[2], 'to' => $to, 'message-id' => $matches[5]);
}
private function add_mailbox_traffic($address, $traffic) {
$address = strtolower($address);
if(in_array($address, $this->mail_boxes) == true) {
if(!isset($this->mailbox_traffic[$address])) $this->mailbox_traffic[$address] = 0;
$this->mailbox_traffic[$address] += $traffic;
} elseif(array_key_exists($address, $this->mail_rewrites)) {
foreach($this->mail_rewrites[$address] as $address) {
if(!isset($this->mailbox_traffic[$address])) $this->mailbox_traffic[$address] = 0;
$this->mailbox_traffic[$address] += $traffic;
}
} else {
// this is not a local address - skip it
}
}
}
......
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