mirror of https://github.com/mikaku/Monitorix.git
dded support to include Piwik tracking code
This commit is contained in:
parent
89d79e8d60
commit
1cb217a92a
31
monitorix
31
monitorix
|
@ -117,6 +117,8 @@ sub create_index {
|
|||
my $table_back_color;
|
||||
my $title_back_color;
|
||||
my $title_fore_color;
|
||||
my $piwik_code = "";
|
||||
my ($piwik_url, $piwik_sid, $piwik_img);
|
||||
|
||||
# keep backwards compatibility for v3.2.1 and less
|
||||
if(ref($config{theme}) ne "HASH") {
|
||||
|
@ -143,6 +145,34 @@ sub create_index {
|
|||
$title_fore_color = $config{theme}->{$theme}->{title_fg};
|
||||
}
|
||||
|
||||
# Piwik tracking code
|
||||
if(lc($config{piwik_tracking}->{enabled} eq "y")) {
|
||||
$piwik_url = $config{piwik_tracking}->{url} || "";
|
||||
$piwik_sid = $config{piwik_tracking}->{sid} || "";
|
||||
$piwik_img = $config{piwik_tracking}->{img} || "";
|
||||
$piwik_code = <<"EOF";
|
||||
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u=(("https:" == document.location.protocol) ? "https" : "http") + "$piwik_url";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setSiteId', $piwik_sid]);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
|
||||
g.defer=true; g.async=true; g.src=u+'piwik.js';
|
||||
s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<noscript>
|
||||
<p><img src="$piwik_img" style="border:0;" alt=""/></p>
|
||||
</noscript>
|
||||
<!-- End Piwik Code -->
|
||||
EOF
|
||||
}
|
||||
|
||||
# force to only one trailing slash
|
||||
(my $base_url = $config{base_url}) =~ s/\/*$/\//;
|
||||
(my $base_cgi = $config{base_cgi}) =~ s/\/*$/\//;
|
||||
|
@ -158,6 +188,7 @@ sub create_index {
|
|||
<link rel="shortcut icon" href="$base_url$config{favicon}">
|
||||
</head>
|
||||
<body bgcolor="$bgcolor" text="#888888" vlink="#888888" link="#888888">
|
||||
$piwik_code
|
||||
<center>
|
||||
<p>
|
||||
<br>
|
||||
|
|
|
@ -378,6 +378,37 @@ if(!$silent) {
|
|||
my $title;
|
||||
my $str;
|
||||
|
||||
my $piwik_code = "";
|
||||
my ($piwik_url, $piwik_sid, $piwik_img);
|
||||
|
||||
# Piwik tracking code
|
||||
if(lc($config{piwik_tracking}->{enabled} eq "y")) {
|
||||
$piwik_url = $config{piwik_tracking}->{url} || "";
|
||||
$piwik_sid = $config{piwik_tracking}->{sid} || "";
|
||||
$piwik_img = $config{piwik_tracking}->{img} || "";
|
||||
$piwik_code = <<"EOF";
|
||||
|
||||
<!-- Piwik -->
|
||||
<script type="text/javascript">
|
||||
var _paq = _paq || [];
|
||||
_paq.push(['trackPageView']);
|
||||
_paq.push(['enableLinkTracking']);
|
||||
(function() {
|
||||
var u=(("https:" == document.location.protocol) ? "https" : "http") + "$piwik_url";
|
||||
_paq.push(['setTrackerUrl', u+'piwik.php']);
|
||||
_paq.push(['setSiteId', $piwik_sid]);
|
||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
|
||||
g.defer=true; g.async=true; g.src=u+'piwik.js';
|
||||
s.parentNode.insertBefore(g,s);
|
||||
})();
|
||||
</script>
|
||||
<noscript>
|
||||
<p><img src="$piwik_img" style="border:0;" alt=""/></p>
|
||||
</noscript>
|
||||
<!-- End Piwik Code -->
|
||||
EOF
|
||||
}
|
||||
|
||||
print("<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 3.2 Final//EN'>\n");
|
||||
print("<html>\n");
|
||||
print(" <head>\n");
|
||||
|
@ -388,6 +419,7 @@ if(!$silent) {
|
|||
}
|
||||
print(" </head>\n");
|
||||
print(" <body bgcolor='" . $colors{bg_color} . "' vlink='#888888' link='#888888'>\n");
|
||||
print(" $piwik_code\n");
|
||||
print(" <center>\n");
|
||||
print(" <table cellspacing='5' cellpadding='0' bgcolor='" . $colors{graph_bg_color} . "' border='1'>\n");
|
||||
print(" <tr>\n");
|
||||
|
|
|
@ -60,6 +60,14 @@ imap_log_date_format = %b %d
|
|||
secure_log_date_format = %b %e
|
||||
|
||||
|
||||
<piwik_tracking>
|
||||
enabled = n
|
||||
url = "://example.com/piwik/"
|
||||
sid = "1"
|
||||
img = "http://example.com/piwik/piwik.php?idsite=1"
|
||||
</piwik_tracking>
|
||||
|
||||
|
||||
# Graphs (de)activation
|
||||
# -----------------------------------------------------------------------------
|
||||
<graph_enable>
|
||||
|
|
Loading…
Reference in New Issue