I quickly wrote this small plugin to create awstats config file automatically (base on the ISPconfig 2 plugin)
It really needs improvement and automation but that's a start for whoever has time to write more about it...
Do not hesitate to improve or fix it....
PS: congrats for the 3.0.1 version !
Just paste the following code in a awstats_plugin.inc.php file in the plugins-available directory.
Code:
<?php
class awstats_plugin {
var $plugin_name = 'awstats_plugin';
var $class_name = 'awstats_plugin';
//* This function is called during ispconfig installation to determine
// if a symlink shall be created for this plugin.
function onInstall() {
global $conf;
if(@$conf['services']['awstats'] == true) {
return true;
} else {
return false;
}
}
/*
This function is called when the plugin is loaded
*/
function onLoad() {
global $app;
/*
Register for the events
*/
//* Mail Domains
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'domain_insert');
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'domain_update');
$app->plugins->registerEvent('web_domain_delete',$this->plugin_name,'domain_delete');
}
function user_insert($event_name,$data) {
// TODO: handle users for awstats access
}
function user_update($event_name,$data) {
// TODO: handle users for awstats access
}
function user_delete($event_name,$data) {
// TODO: handle users for awstats access
}
function domain_update($event_name,$data) {
global $app, $conf;
$this->domain_insert($event_name, $data);
}
function domain_insert($event_name,$data) {
global $app, $conf;
if(!@is_file("/etc/awstats/awstats.".$data["new"]["domain"].".conf") || ($data["old"]["domain"] != '' && $data["new"]["domain"] != $data["old"]["domain"])) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
exec( "echo 'Include \"/etc/awstats/awstats.conf\"' > /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
exec( "echo 'SiteDomain=\"".$data["new"]["domain"]."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
// exec( "echo 'AllowAccessFromWebToFollowingAuthenticatedUsers=\"".$ht_user_list."\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf");
}
}
function domain_delete($event_name,$data) {
global $app, $conf;
if($data["old"]["domain"] != '' ) {
if ( @is_file("/etc/awstats/awstats.".$data["old"]["domain"].".conf") )
exec("rm -f /etc/awstats/awstats.".$data["old"]["domain"].".conf");
}
}
} // end class
?>
Recent comments
1 day 9 hours ago
1 day 11 hours ago
1 day 23 hours ago
2 days 2 hours ago
2 days 6 hours ago
2 days 12 hours ago
2 days 22 hours ago
3 days 5 min ago
3 days 8 hours ago
3 days 9 hours ago