Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #21  
Old 10th May 2009, 19:03
grungy grungy is offline
Senior Member
 
Join Date: Dec 2008
Posts: 166
Thanks: 14
Thanked 15 Times in 10 Posts
Default

awstats_updateall.pl on Debain is run as following:

Code:
/usr/share/doc/awstats/examples/awstats_updateall.pl now -awstatsprog=/usr/lib/cgi-bin/awstats.pl
The awstats conf file should be more rich, for example:

Code:
                        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 'DNSLookup=\"1\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
                        exec( "echo 'DirData =\"/var/cache/awstats\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
                        exec( "echo 'AllowFullYearView=\"3\"' >> /etc/awstats/awstats.".$data["new"]["domain"].".conf" );
Reply With Quote
Sponsored Links
  #22  
Old 18th May 2009, 14:16
admins admins is offline
Senior Member
 
Join Date: Apr 2009
Location: Switzerland
Posts: 210
Thanks: 6
Thanked 6 Times in 3 Posts
Default

To the simlink: From where to where must I create a symlink
Code:
ln -s ....
Thanks
admins
Reply With Quote
  #23  
Old 25th May 2009, 10:55
djtremors djtremors is offline
Senior Member
 
Join Date: Apr 2006
Location: Sydney
Posts: 278
Thanks: 0
Thanked 12 Times in 10 Posts
Default

Oo this looks to be a good plugin hack. Might add my bit to take logins from mysql and create a .htaccess htpasswd file as i'm migrating my ispc2 accounts to my ispc3 server.

long live the plugins!

Is there a list what hooks are available for plugins? I have a DR design in mind and would like to use this opportunity to mirror when accounts are created and deleted with rsync ability etc.etc.
__________________
www.emperor-it.com for ISPConfig mods/hacks
Reply With Quote
  #24  
Old 25th May 2009, 11:14
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,413
Thanks: 834
Thanked 5,496 Times in 4,326 Posts
Default

There is no list yet. But if you look into the files in mods-available, you can easily find the definitions. Currently these are available:

client_insert, client_update, client_delete
database_insert, database_update, database_delete
mail_domain_insert, mail_domain_update, mail_domain_delete
mail_user_insert, mail_user_update, mail_user_delete
mail_access_insert, mail_access_update, mail_access_delete
mail_forwarding_insert, mail_forwarding_update, mail_forwarding_delete
mail_transport_insert, mail_transport_update, mail_transport_delete
mail_get_insert, mail_get_update, mail_get_delete
mail_content_filter_insert, mail_content_filter_update, mail_content_filter_delete
server_insert, server_update, server_delete
server_ip_insert, server_ip_update, server_ip_delete
firewall_insert, firewall_update, firewall_delete
software_update_inst_insert, software_update_inst_update, software_update_inst_delete
web_domain_insert, web_domain_update, web_domain_delete
ftp_user_insert, ftp_user_update, ftp_user_delete
shell_user_insert, shell_user_update, shell_user_delete

The event names correspond with the database table names.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #25  
Old 28th May 2009, 02:45
BorderAmigos BorderAmigos is offline
Senior Member
 
Join Date: Apr 2008
Location: San Diego & Tijuana
Posts: 302
Thanks: 26
Thanked 33 Times in 31 Posts
Send a message via MSN to BorderAmigos Send a message via Yahoo to BorderAmigos
Default

I did all of the above and still not working. I'll read it thru 5 or 10 more times to find what I'm missing.
__________________
System6Hosting.com, ISPConfig 3, Debian.
Reply With Quote
  #26  
Old 28th May 2009, 10:28
djtremors djtremors is offline
Senior Member
 
Join Date: Apr 2006
Location: Sydney
Posts: 278
Thanks: 0
Thanked 12 Times in 10 Posts
Default

@BorderAmigos : What does "still not working" mean. Did you make a vhost for it

I had to change mine to work with debians apt-get version which was different.


PHP Code:
                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");
                

my /etc/apache2/conf.d/awstats.conf looks like this (for now).
PHP Code:
Alias /awstatsclasses "/usr/share/awstats/classes/"
Alias /awstatscss "/usr/share/awstats/css/"
Alias /awstats-icon "/usr/share/awstats/icon/"
ScriptAlias /stats"/usr/lib/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/share/awstats">
        
Options None
        AllowOverride None
        Order allow
,deny
        Allow from all
</Directory
what I did notice is that this only supports the domain and not the www. autodomains which I'll get around to adding along with authentication (been sick lately any contenders to SQL to get list, be my guest)...
__________________
www.emperor-it.com for ISPConfig mods/hacks
Reply With Quote
  #27  
Old 29th May 2009, 12:52
djtremors djtremors is offline
Senior Member
 
Join Date: Apr 2006
Location: Sydney
Posts: 278
Thanks: 0
Thanked 12 Times in 10 Posts
Default

Ok, got around to making a quick patch to allow my awstats to appear using the configuration method mentioned earlier and using a redirection from /stats to redirect to /ispcstats with the domain.

This will create a .htaccess_stats file with the clients login/password from the database. Change as you please if you want email users to be able to use it instead etc. There is no super admin login atm but that's an easy addition by adding a admin:{hash} to the write routine.

There may be other little tweaks needs in regards to getting awstats part working but this is only the ispc3 side.

Code :
[PHP]Ok, got around to making a quick patch to allow my awstats to appear using the configuration method mentioned earlier and using a redirection from /stats to redirect to /ispcstats with the domain.

This will create a .htaccess_stats file with the clients login/password from the database. Change as you please if you want email users to be able to use it instead etc. There is no super admin login atm but that's an easy addition by adding a admin:{hash} to the write routine.

There may be other little tweaks needs in regards to getting awstats part working but this is only the ispc3 side.

Code :
PHP 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');
                
$app->plugins->registerEvent('client_insert',$this->plugin_name,'client_insert');
                
$app->plugins->registerEvent('client_update',$this->plugin_name,'client_update');
                
$app->plugins->registerEvent('client_delete',$this->plugin_name,'client_delete');
        }

        function 
awstats_update($event_name,$data) {
                global 
$app$conf;
                
$result $app->db->queryAllRecords("SELECT * FROM web_domain wd,sys_group sg,client c where wd.sys_groupid = sg.groupid and sg.client_id = c.client_id");
                
$fp fopen($domroot."/.htpasswd_stats","w");
                if (
$fp)
                {
            foreach(
$result as $row)
                    {
                        
$domain         $row['domain'];
                    
$username       $row['username'];
                            
$password       $row['password'];
                            
$domroot        $row['document_root'];
                            echo 
"Domain::$domain DomRoot::$domroot\n";

                                
fwrite($fp,$username.":".$password."\n");
                        }
                        
fclose($fp);
        }
                
$fp fopen($domroot."/web/stats/.htaccess","w");
                if (
$fp)
                {
                        
$access='AuthType Basic
AuthName "Site Client Access Only"
AuthUserFile '
.$domroot.'/.htpasswd_stats
<limit GET PUT POST>
require valid-user
</limit>
Redirect 301 /stats http://www.'
.$domain.'/ispcstats/awstats.pl?config=www.'.$domain.'
'
;

                        
fwrite($fp,$access);
                        
fclose($fp);
                }
        }

        function 
client_insert($event_name,$data) {
                global 
$app$conf;
                
$this->awstats_update();
        }

        function 
client_update($event_name,$data) {
                global 
$app$conf;
                
$this->awstats_update();
        }

        function 
client_delete($event_name,$data) {
                global 
$app$conf;
                
$this->awstats_update();
        }

        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
?>
__________________
www.emperor-it.com for ISPConfig mods/hacks

Last edited by djtremors; 31st May 2009 at 12:28.
Reply With Quote
  #28  
Old 23rd November 2009, 11:13
sirrus sirrus is offline
Junior Member
 
Join Date: May 2009
Location: Frankfurt am Main
Posts: 15
Thanks: 4
Thanked 1 Time in 1 Post
Send a message via ICQ to sirrus Send a message via Skype™ to sirrus
Default

Thank you for this plugin.

It is not creating awstat conf files in my case. A lot of people use secured php where exec is denied. I think it is at least one securtiy rights issue.

I suggest to rewrite this code to use fwrite:

Code:
function domain_insert($event_name,$data) {
        global $app, $conf;

        $newfile = "/etc/awstats/awstats.".$data["new"]["domain"].".conf";
        $oldfile = "/etc/awstats/awstats.".$data["old"]["domain"].".conf";

        if(!@is_file($newfile) || ($oldfile != '' && $newfile != $oldfile)) {
                if ( @is_file($oldfile) )
                        exec("rm -f ".$oldfile);

                $fp = fopen($newfile,"w");
                if ($fp) {
                        $awcon = "Include \"/etc/awstats/awstats.conf\"\n" .
                        "LogFile=\"/var/log/ispconfig/httpd/".$data["new"]["domain"]."/access.log\"\n" .
                        "SiteDomain=\"".$data["new"]["domain"]."\"\n" .
                        "DNSLookup=\"1\"\n" .
                        "DirData =\"/var/cache/awstats\"\n" .
                        "AllowFullYearView=\"3\"";
                        //$awcon .= "\nAllowAccessFromWebToFollowingAuthenticatedUsers=\"".$ht_user_list."\"";
                        fwrite($fp, $awcon);
                        fclose($fp);
                }
        }
}

Last edited by sirrus; 23rd November 2009 at 12:59.
Reply With Quote
  #29  
Old 16th January 2010, 06:46
korbynn korbynn is offline
Member
 
Join Date: May 2009
Posts: 81
Thanks: 2
Thanked 4 Times in 4 Posts
Unhappy

I am running on CentOS 4.3.

I did all that was suggested in the last 2 posts (Thankyou) but awstats is still not processing the website stats or are the stats else where.
My client really likes awstats as opposed to webalizer.

I noticed that the /etc/awstats/awstats.conf did not exist so I
cp awstats.model.conf awstats.conf
hoping that this would make the config for awstats to work.

Any thoughts or pointers to other info is appreciated.
Reply With Quote
  #30  
Old 27th January 2010, 17:28
stefanr stefanr is offline
HowtoForge Supporter
 
Join Date: Dec 2005
Posts: 48
Thanks: 0
Thanked 1 Time in 1 Post
 
Default

Hello,

i have tried the following things

1.)
aptitute install awstats

2.)
vim /usr/local/ispconfig/server/plugins-available/awstats_plugin.inc.php and write the code from post #27 and post #28 into the file.

3.)
ln -s /usr/local/ispconfig/server/plugins-available/awstats_plugin.inc.php /usr/local/ispconfig/server/plugins-enabled/awstats_plugin.inc.php

4.)
vim /usr/local/ispconfig/server/lib/config.inc.php and insert the row $conf['services']['awstats'] = true;

i think this is all what i must do on the ispconfig server. And now at all domains the www.domain.de/stats should be replaced by the awstats files and i must see it under www.domain.de/stats.

It doesent works at the moment have anyone a idea?

kind regards
Stefan
Reply With Quote
Reply

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 11:47
Cant update ispconfig and awstats install issue supervos Installation/Configuration 6 4th November 2007 10:12
ISPConfig 2.2.13 released till General 35 23rd July 2007 16:28
Another Awstats Configuration Thingy For ISPConfig asyadiqin Installation/Configuration 2 6th August 2006 13:20
SP-Server Setup - Ubuntu 5.10 "Breezy Badger" - Page 6 (changes) LuisC-SM HOWTO-Related Questions 0 21st April 2006 15:16


All times are GMT +2. The time now is 22:56.


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