@@ -113,7 +113,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
113113}
114114
115115
116- $ sql = "SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'webalizer' AND server_id = " .$ conf ['server_id ' ];
116+ $ sql = "SELECT domain_id, domain, document_root, web_folder, type FROM web_domain WHERE stats_type = 'webalizer' AND server_id = " .$ conf ['server_id ' ];
117117$ records = $ app ->db ->queryAllRecords ($ sql );
118118
119119foreach ($ records as $ rec ) {
@@ -128,7 +128,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
128128 }
129129
130130 $ domain = escapeshellcmd ($ rec ['domain ' ]);
131- $ statsdir = escapeshellcmd ($ rec ['document_root ' ].'/web/stats ' );
131+ $ statsdir = escapeshellcmd ($ rec ['document_root ' ].'/ ' .( $ rec [ ' type ' ] == ' vhostsubdomain ' ? $ rec [ ' web_folder ' ] : ' web ' ). ' /stats ' );
132132 $ webalizer = '/usr/bin/webalizer ' ;
133133 $ webalizer_conf_main = '/etc/webalizer/webalizer.conf ' ;
134134 $ webalizer_conf = escapeshellcmd ($ rec ['document_root ' ].'/log/webalizer.conf ' );
@@ -154,7 +154,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
154154// Create awstats statistics
155155#######################################################################################################
156156
157- $ sql = "SELECT domain_id, domain, document_root, system_user, system_group FROM web_domain WHERE stats_type = 'awstats' AND server_id = " .$ conf ['server_id ' ];
157+ $ sql = "SELECT domain_id, domain, document_root, web_folder, type, system_user, system_group FROM web_domain WHERE stats_type = 'awstats' AND server_id = " .$ conf ['server_id ' ];
158158$ records = $ app ->db ->queryAllRecords ($ sql );
159159
160160$ web_config = $ app ->getconf ->get_server_config ($ conf ['server_id ' ], 'web ' );
@@ -169,9 +169,9 @@ function setConfigVar( $filename, $varName, $varValue ) {
169169 continue ;
170170 }
171171 }
172-
172+ $ web_folder = ( $ rec [ ' type ' ] == ' vhostsubdomain ' ? $ rec [ ' web_folder ' ] : ' web ' );
173173 $ domain = escapeshellcmd ($ rec ['domain ' ]);
174- $ statsdir = escapeshellcmd ($ rec ['document_root ' ].'/web /stats ' );
174+ $ statsdir = escapeshellcmd ($ rec ['document_root ' ].'/ ' . $ web_folder . ' /stats ' );
175175 $ awstats_pl = $ web_config ['awstats_pl ' ];
176176 $ awstats_buildstaticpages_pl = $ web_config ['awstats_buildstaticpages_pl ' ];
177177
@@ -213,7 +213,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
213213 }
214214 }
215215
216- // awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web /stats -awstatsprog=/path/to/awstats.pl
216+ // awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/'.$web_folder.' /stats -awstatsprog=/path/to/awstats.pl
217217 // $command = "$awstats_buildstaticpages_pl -update -config='$domain' -lang=".$conf['language']." -dir='$statsdir' -awstatsprog='$awstats_pl'";
218218
219219 $ command = "$ awstats_buildstaticpages_pl -month=' $ awmonth' -year=' $ awyear' -update -config=' $ domain' -lang= " .$ conf ['language ' ]." -dir=' $ statsdir' -awstatsprog=' $ awstats_pl' " ;
@@ -236,18 +236,18 @@ function setConfigVar( $filename, $varName, $varValue ) {
236236
237237 if ($ awstats_pl != '' && $ awstats_buildstaticpages_pl != '' && fileowner ($ awstats_pl ) == 0 && fileowner ($ awstats_buildstaticpages_pl ) == 0 ) {
238238 exec ($ command );
239- if (is_file ($ rec ['document_root ' ].'/web /stats/index.html ' )) unlink ($ rec ['document_root ' ].'/web /stats/index.html ' );
240- rename ($ rec ['document_root ' ].'/web /stats/awstats. ' .$ domain .'.html ' ,$ rec ['document_root ' ].'/web /stats/awsindex.html ' );
241- 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 " );
239+ if (is_file ($ rec ['document_root ' ].'/ ' . $ web_folder . ' /stats/index.html ' )) unlink ($ rec ['document_root ' ].'/ ' . $ web_folder . ' /stats/index.html ' );
240+ rename ($ rec ['document_root ' ].'/ ' . $ web_folder . ' /stats/awstats. ' .$ domain .'.html ' ,$ rec ['document_root ' ].'/ ' . $ web_folder . ' /stats/awsindex.html ' );
241+ if (!is_file ($ rec ['document_root ' ]."/'. $ web_folder .' /stats/index.php " )) copy ("/usr/local/ispconfig/server/conf/awstats_index.php.master " ,$ rec ['document_root ' ]."/ " . $ web_folder . " /stats/index.php " );
242242
243243 $ app ->log ('Created awstats statistics with command: ' .$ command ,LOGLEVEL_DEBUG );
244244 } else {
245245 $ app ->log ("No awstats statistics created. Either $ awstats_pl or $ awstats_buildstaticpages_pl is not owned by root user. " ,LOGLEVEL_WARN );
246246 }
247247
248- if (is_file ($ rec ['document_root ' ]."/web /stats/index.php " )) {
249- chown ($ rec ['document_root ' ]."/web /stats/index.php " ,$ rec ['system_user ' ]);
250- chgrp ($ rec ['document_root ' ]."/web /stats/index.php " ,$ rec ['system_group ' ]);
248+ if (is_file ($ rec ['document_root ' ]."/ " . $ web_folder . " /stats/index.php " )) {
249+ chown ($ rec ['document_root ' ]."/ " . $ web_folder . " /stats/index.php " ,$ rec ['system_user ' ]);
250+ chgrp ($ rec ['document_root ' ]."/ " . $ web_folder . " /stats/index.php " ,$ rec ['system_group ' ]);
251251 }
252252
253253}
0 commit comments