Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
I
ISPConfig 3
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Manoa Ratefiarison
ISPConfig 3
Commits
58c2101b
Commit
58c2101b
authored
14 years ago
by
tbrehm
Browse files
Options
Downloads
Patches
Plain Diff
Implemented: FS#903 - Awstats instead Webalizer
parent
379a4b6e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/cron_daily.php
+59
-19
59 additions, 19 deletions
server/cron_daily.php
server/plugins-available/apache2_plugin.inc.php
+42
-0
42 additions, 0 deletions
server/plugins-available/apache2_plugin.inc.php
with
101 additions
and
19 deletions
server/cron_daily.php
+
59
−
19
View file @
58c2101b
...
@@ -38,7 +38,7 @@ $conf["server_id"] = intval($conf["server_id"]);
...
@@ -38,7 +38,7 @@ $conf["server_id"] = intval($conf["server_id"]);
// Load required base-classes
// Load required base-classes
$app
->
uses
(
'ini_parser,file,services'
);
$app
->
uses
(
'ini_parser,file,services
,getconf
'
);
#######################################################################################################
#######################################################################################################
...
@@ -112,7 +112,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
...
@@ -112,7 +112,7 @@ function setConfigVar( $filename, $varName, $varValue ) {
}
}
$sql
=
"SELECT domain_id, domain, document_root FROM web_domain WHERE server_id = "
.
$conf
[
"server_id"
];
$sql
=
"SELECT domain_id, domain, document_root FROM web_domain WHERE
stats_type = 'webalizer' AND
server_id = "
.
$conf
[
"server_id"
];
$records
=
$app
->
db
->
queryAllRecords
(
$sql
);
$records
=
$app
->
db
->
queryAllRecords
(
$sql
);
foreach
(
$records
as
$rec
)
{
foreach
(
$records
as
$rec
)
{
...
@@ -120,32 +120,72 @@ foreach($records as $rec) {
...
@@ -120,32 +120,72 @@ foreach($records as $rec) {
$logfile
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/'
.
$yesterday
.
'-access.log'
);
$logfile
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/'
.
$yesterday
.
'-access.log'
);
if
(
!@
is_file
(
$logfile
))
{
if
(
!@
is_file
(
$logfile
))
{
$logfile
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/'
.
$yesterday
.
'-access.log.gz'
);
$logfile
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/'
.
$yesterday
.
'-access.log.gz'
);
if
(
!@
is_file
(
$logfile
))
{
if
(
!@
is_file
(
$logfile
))
{
continue
;
continue
;
}
}
}
}
$domain
=
escapeshellcmd
(
$rec
[
"domain"
]);
$domain
=
escapeshellcmd
(
$rec
[
"domain"
]);
$statsdir
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/web/stats'
);
$statsdir
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/web/stats'
);
$webalizer
=
'/usr/bin/webalizer'
;
$webalizer
=
'/usr/bin/webalizer'
;
$webalizer_conf_main
=
'/etc/webalizer/webalizer.conf'
;
$webalizer_conf_main
=
'/etc/webalizer/webalizer.conf'
;
$webalizer_conf
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/webalizer.conf'
);
$webalizer_conf
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/webalizer.conf'
);
if
(
!@
is_file
(
$webalizer_conf
))
{
if
(
!@
is_file
(
$webalizer_conf
))
{
exec
(
"cp
$webalizer_conf_main
$webalizer_conf
"
);
exec
(
"cp
$webalizer_conf_main
$webalizer_conf
"
);
}
}
if
(
@
is_file
(
$webalizer_conf
))
{
if
(
@
is_file
(
$webalizer_conf
))
{
setConfigVar
(
$webalizer_conf
,
'Incremental'
,
'yes'
);
setConfigVar
(
$webalizer_conf
,
'Incremental'
,
'yes'
);
setConfigVar
(
$webalizer_conf
,
'IncrementalName'
,
$statsdir
.
'/webalizer.current'
);
setConfigVar
(
$webalizer_conf
,
'IncrementalName'
,
$statsdir
.
'/webalizer.current'
);
setConfigVar
(
$webalizer_conf
,
'HistoryName'
,
$statsdir
.
'/webalizer.hist'
);
setConfigVar
(
$webalizer_conf
,
'HistoryName'
,
$statsdir
.
'/webalizer.hist'
);
}
}
if
(
!@
is_dir
(
$statsdir
))
mkdir
(
$statsdir
);
if
(
!@
is_dir
(
$statsdir
))
mkdir
(
$statsdir
);
exec
(
"
$webalizer
-c
$webalizer_conf
-n
$domain
-s
$domain
-r
$domain
-q -T -p -o
$statsdir
$logfile
"
);
exec
(
"
$webalizer
-c
$webalizer_conf
-n
$domain
-s
$domain
-r
$domain
-q -T -p -o
$statsdir
$logfile
"
);
}
}
#######################################################################################################
// Create awstats statistics
#######################################################################################################
$sql
=
"SELECT domain_id, domain, document_root FROM web_domain WHERE stats_type = 'awstats' AND server_id = "
.
$conf
[
"server_id"
];
$records
=
$app
->
db
->
queryAllRecords
(
$sql
);
$web_config
=
$app
->
getconf
->
get_server_config
(
$conf
[
"server_id"
],
'web'
);
foreach
(
$records
as
$rec
)
{
$yesterday
=
date
(
"Ymd"
,
time
()
-
86400
);
$logfile
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/'
.
$yesterday
.
'-access.log'
);
if
(
!@
is_file
(
$logfile
))
{
$logfile
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/log/'
.
$yesterday
.
'-access.log.gz'
);
if
(
!@
is_file
(
$logfile
))
{
continue
;
}
}
$domain
=
escapeshellcmd
(
$rec
[
"domain"
]);
$statsdir
=
escapeshellcmd
(
$rec
[
"document_root"
]
.
'/web/stats'
);
$awstats_pl
=
$web_config
[
'awstats_pl'
];
$awstats_updateall_pl
=
$web_config
[
'awstats_updateall_pl'
];
if
(
!@
is_dir
(
$statsdir
))
mkdir
(
$statsdir
);
// awstats_buildstaticpages.pl -update -config=mydomain.com -lang=en -dir=/var/www/domain.com/web/stats -awstatsprog=/path/to/awstats.pl
$command
=
"
$awstats_updateall_pl
-update -config='
$domain
' -lang=en -dir='
$statsdir
' -awstatsprog='
$awstats_pl
'"
;
if
(
$awstats_pl
!=
''
&&
$awstats_updateall_pl
!=
''
&&
fileowner
(
$awstats_pl
)
==
0
&&
fileowner
(
$awstats_updateall_pl
)
==
0
)
{
exec
(
$command
);
$app
->
log
(
"Created awstats statistics with command:
$command
"
,
LOGLEVEL_DEBUG
);
}
else
{
$app
->
log
(
"No awstats statistics created. Either
$awstats_pl
or
$awstats_updateall_pl
is not owned by root user."
,
LOGLEVEL_WARN
);
}
}
#######################################################################################################
#######################################################################################################
// Make the web logfiles directories world readable to enable ftp access
// Make the web logfiles directories world readable to enable ftp access
#######################################################################################################
#######################################################################################################
...
...
This diff is collapsed.
Click to expand it.
server/plugins-available/apache2_plugin.inc.php
+
42
−
0
View file @
58c2101b
...
@@ -838,6 +838,11 @@ class apache2_plugin {
...
@@ -838,6 +838,11 @@ class apache2_plugin {
unset
(
$htp_file
);
unset
(
$htp_file
);
}
}
}
}
//* Create awstats configuration
if
(
$data
[
"new"
][
"stats_type"
]
==
'awstats'
&&
$data
[
"new"
][
"type"
]
==
"vhost"
)
{
$this
->
awstats_update
(
$data
,
$web_config
);
}
if
(
$apache_chrooted
)
{
if
(
$apache_chrooted
)
{
...
@@ -942,6 +947,11 @@ class apache2_plugin {
...
@@ -942,6 +947,11 @@ class apache2_plugin {
$command
.
=
' '
.
$data
[
"old"
][
"system_user"
];
$command
.
=
' '
.
$data
[
"old"
][
"system_user"
];
exec
(
$command
);
exec
(
$command
);
if
(
$apache_chrooted
)
$this
->
_exec
(
"chroot "
.
escapeshellcmd
(
$web_config
[
'website_basedir'
])
.
" "
.
$command
);
if
(
$apache_chrooted
)
$this
->
_exec
(
"chroot "
.
escapeshellcmd
(
$web_config
[
'website_basedir'
])
.
" "
.
$command
);
//* Remove the awstats configuration file
if
(
$data
[
"old"
][
"stats_type"
]
==
'awstats'
)
{
$this
->
awstats_delete
(
$data
,
$web_config
);
}
}
}
}
}
...
@@ -1196,6 +1206,38 @@ class apache2_plugin {
...
@@ -1196,6 +1206,38 @@ class apache2_plugin {
file_put_contents
(
$fileName
,
$output
);
file_put_contents
(
$fileName
,
$output
);
}
}
//* Update the awstats configuration file
private
function
awstats_update
(
$data
,
$web_config
)
{
global
$app
;
if
(
!@
is_file
(
$awstats_conf_dir
.
"/awstats."
.
$data
[
"new"
][
"domain"
]
.
".conf"
)
||
(
$data
[
"old"
][
"domain"
]
!=
''
&&
$data
[
"new"
][
"domain"
]
!=
$data
[
"old"
][
"domain"
]))
{
if
(
@
is_file
(
$awstats_conf_dir
.
"/awstats."
.
$data
[
"old"
][
"domain"
]
.
".conf"
)
)
{
unlink
(
$awstats_conf_dir
.
"/awstats."
.
$data
[
"old"
][
"domain"
]
.
".conf"
);
}
$content
=
''
;
$content
.
=
"Include '"
.
$awstats_conf_dir
.
"/awstats.conf'
\n
"
;
$content
.
=
"LogFile='/var/log/ispconfig/httpd/"
.
$data
[
"new"
][
"domain"
]
.
"/access.log'
\n
"
;
$content
.
=
"SiteDomain='"
.
$data
[
"new"
][
"domain"
]
.
"'
\n
"
;
$content
.
=
"HostAliases='www."
.
$data
[
"new"
][
"domain"
]
.
" localhost 127.0.0.1'
\n
"
;
file_put_contents
(
$awstats_conf_dir
.
'/awstats.'
.
$data
[
"new"
][
"domain"
]
.
'.conf'
,
$content
);
$app
->
log
(
"Created awstats config file: "
.
$awstats_conf_dir
.
'/awstats.'
.
$data
[
"new"
][
"domain"
]
.
'.conf'
,
LOGLEVEL_DEBUG
);
}
}
//* Delete the awstats configuration file
private
function
awstats_delete
(
$data
,
$web_config
)
{
global
$app
;
$awstats_conf_dir
=
$web_config
[
'awstats_conf_dir'
];
if
(
@
is_file
(
$awstats_conf_dir
.
"/awstats."
.
$data
[
"old"
][
"domain"
]
.
".conf"
)
)
{
unlink
(
$awstats_conf_dir
.
"/awstats."
.
$data
[
"old"
][
"domain"
]
.
".conf"
);
$app
->
log
(
"Removed awstats config file: "
.
$awstats_conf_dir
.
'/awstats.'
.
$data
[
"old"
][
"domain"
]
.
'.conf'
,
LOGLEVEL_DEBUG
);
}
}
//* Wrapper for exec function for easier debugging
//* Wrapper for exec function for easier debugging
private
function
_exec
(
$command
)
{
private
function
_exec
(
$command
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment