Skip to content

Commit 39bc773

Browse files
committed
Fixed: FS#1690 - Awstats shows only the last month.
1 parent 32ed1e4 commit 39bc773

File tree

2 files changed

+103
-2
lines changed

2 files changed

+103
-2
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2+
<html xmlns="http://www.w3.org/1999/xhtml">
3+
<head>
4+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
5+
<title>AWAstats Statistics</title>
6+
<script>
7+
function load_content(url)
8+
{
9+
var iframe = document.getElementById("content");
10+
iframe.src = url;
11+
}
12+
</script>
13+
</head>
14+
<body>
15+
<?php
16+
$aw['aw_jump_text'] = 'Jump to previous stats: ';
17+
$aw['aw_renamed_index'] = 'awsindex.html';
18+
19+
if ($handle = opendir('.'))
20+
{
21+
while(false !== ($file = readdir($handle)))
22+
{
23+
if (substr($file,0,1) != "." && is_dir($file))
24+
{
25+
$awprev[] = $file;
26+
}
27+
}
28+
29+
$month = date("m")+1-1;
30+
31+
if (date("d") == 1)
32+
{
33+
$month = date("m")-1;
34+
}
35+
36+
$year = date("Y");
37+
38+
if (date("m") == 1)
39+
{
40+
$year = date("Y")-1;
41+
$month = "12";
42+
}
43+
44+
$awprev[] = $year."-".$month;
45+
closedir($handle);
46+
}
47+
48+
echo '<div style="width: 97%; margin-left: 4px; height: 20px; background-color: #FFFFFF; position: fixed; padding: 7px; border: 2px solid #cccccc;><div align="left"><font color="#000000" size="2" face="Verdana, Arial, Helvetica, sans-serif">' .$aw["aw_jump_text"]. '</font </div>';
49+
50+
echo "<select name='awdate' onchange=\"load_content(this.value)\">";
51+
rsort($awprev);
52+
53+
foreach ($awprev as $key => $value)
54+
{
55+
if($key == 0)
56+
{
57+
echo "<option selected=\"selected\" value=\"".$aw['aw_renamed_index']."\"> $value</option>";
58+
}
59+
else
60+
{
61+
echo "<option value='$value/".$aw['aw_renamed_index']."'> $value</option>";
62+
}
63+
}
64+
65+
echo '</select></div><iframe src="'.$aw['aw_renamed_index'].'" frameborder="0" scrolling="Yes" width="100%" height="100%" style="margin-top:25px" id="content"></iframe>';
66+
67+
?>
68+
</body>
69+
</html>

server/cron_daily.php

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,44 @@ function setConfigVar( $filename, $varName, $varValue ) {
200200
if(is_link('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log')) unlink('/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
201201
symlink($logfile,'/var/log/ispconfig/httpd/'.$domain.'/yesterday-access.log');
202202

203+
$awmonth = date("m");
204+
if (date("d") == 1) {
205+
$awmonth = date("m")-1;
206+
}
207+
208+
$awyear = date("Y");
209+
if (date("m") == 1) {
210+
$awyear = date("Y")-1;
211+
$awmonth = "12";
212+
}
213+
203214
// awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web/stats -awstatsprog=/path/to/awstats.pl
204-
$command = "$awstats_buildstaticpages_pl -update -config='$domain' -lang=".$conf['language']." -dir='$statsdir' -awstatsprog='$awstats_pl'";
215+
// $command = "$awstats_buildstaticpages_pl -update -config='$domain' -lang=".$conf['language']." -dir='$statsdir' -awstatsprog='$awstats_pl'";
216+
217+
$command = "$awstats_buildstaticpages_pl -month='$awmonth' -year='$awyear' -update -config='$domain' -lang=".$conf['language']." -dir='$statsdir' -awstatsprog='$awstats_pl'";
218+
219+
if (date("d") == 2) {
220+
$awmonth = date("m")-1;
221+
if (date("m") == 1) {
222+
$awyear = date("Y")-1;
223+
$awmonth = "12";
224+
}
225+
226+
$statsdirold = $statsdir."/".$awyear."-".$awmonth."/";
227+
mkdir($statsdirold);
228+
$files = scandir($statsdir);
229+
foreach ($files as $file) {
230+
if (substr($file,0,1) != "." && !is_dir($file) && substr($file,0,1) != "w" && substr($file,0,1) != "i") copy("$statsdir"."/"."$file","$statsdirold"."$file");
231+
}
232+
}
233+
205234

206235
if($awstats_pl != '' && $awstats_buildstaticpages_pl != '' && fileowner($awstats_pl) == 0 && fileowner($awstats_buildstaticpages_pl) == 0) {
207236
exec($command);
208-
rename($rec['document_root'].'/web/stats/awstats.'.$domain.'.html',$rec['document_root'].'/web/stats/index.html');
237+
if(is_file($rec['document_root'].'/web/stats/index.html')) unlink($rec['document_root'].'/web/stats/index.html');
238+
rename($rec['document_root'].'/web/stats/awstats.'.$domain.'.html',$rec['document_root'].'/web/stats/awsindex.html');
239+
if(!is_file($rec['document_root']."/web/stats/index.php")) copy("/usr/local/ispconfig/server/conf/awstats_index.php.master",$rec['document_root']."/web/stats/index.php");
240+
209241
$app->log('Created awstats statistics with command: '.$command,LOGLEVEL_DEBUG);
210242
} else {
211243
$app->log("No awstats statistics created. Either $awstats_pl or $awstats_buildstaticpages_pl is not owned by root user.",LOGLEVEL_WARN);

0 commit comments

Comments
 (0)