@@ -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