Prev Previous Post   Next Post Next
  #1  
Old 30th March 2009, 00:16
Mouton Mouton is offline
Junior Member
 
Join Date: Apr 2008
Posts: 10
Thanks: 0
Thanked 4 Times in 1 Post
Default ISPconfig 3 - awstats

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

Last edited by Mouton; 30th March 2009 at 00:19.
Reply With Quote
The Following 4 Users Say Thank You to Mouton For This Useful Post:
falko (30th March 2009), grungy (14th April 2009), Stown (7th July 2009), till (30th March 2009)
Sponsored Links
 

Bookmarks

Tags
awstats plugin

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ISPConfig 3.0.0.7 Beta released till General 78 24th December 2008 12:47
Cant update ispconfig and awstats install issue supervos Installation/Configuration 6 4th November 2007 11:12
ISPConfig 2.2.13 released till General 35 23rd July 2007 17:28
Another Awstats Configuration Thingy For ISPConfig asyadiqin Installation/Configuration 2 6th August 2006 14:20
SP-Server Setup - Ubuntu 5.10 "Breezy Badger" - Page 6 (changes) LuisC-SM HOWTO-Related Questions 0 21st April 2006 16:16


All times are GMT +2. The time now is 09:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.