#!/usr/local/bin/php -c /usr/local/lib/php.ini
No domains found!"); if ((sizeof($domains)>1)&&(is_null($awdomain))) { echo "

Select Domain to Activate

"; for ($x=0;$x$domains[$x]
"; die(); } elseif (sizeof($domains)==1) $awdomain=0; if (!$config) { echo "

Install AwStats on this domain*

"; echo "
Show Stats

"; echo "
Tune AwStats

"; echo "

* this will reset the passwords and any other configurations you made"; die(); } $location=$_SERVER["HOME"]."/domains/$domains[$awdomain]/public_html/awstats"; echo "Checking if there is already something installed..
"; if (file_exists($location)) echo "AwStats Directory already exists on domain
"; else { echo "Creating AwStats dir on domain
"; mkdir($location); echo "Setting Directory Permissions"; chgrp($location,$_SERVER['USER']); } echo "Checking if awstats files are available"; if (file_exists("$location/lib")) echo "."; else { symlink("$dir/cgi-bin/lib","$location/lib"); if (file_exists("$location/lib")) echo "+"; else echo "Error linking lib dir $location/lib from $dir/cgi-bin/lib"; } if (file_exists("$location/icon")) echo "."; else { symlink("$dir/cgi-bin/icon","$location/icon"); if (file_exists("$location/icon")) echo "+"; else echo "Error linking icon dir $location/icon from $dir/cgi-bin/icon"; } if (file_exists("$location/lang")) echo "."; else { symlink("$dir/cgi-bin/lang","$location/lang"); if (file_exists("$location/lang")) echo "+"; else echo "Error linking lang dir $location/lang from $dir/cgi-bin/lang"; } if (file_exists("$location/plugins")) echo "."; else { symlink("$dir/cgi-bin/plugins","$location/plugins"); if (file_exists("$location/plugins")) echo "+"; else echo "Error linking plugin dir $location/plugins from $dir/cgi-bin/plugins"; } echo "
Checking for AwStats itself
"; if (file_exists("$location/awstats.pl")) { echo "Awstats already exists.
So I will delete it..."; unlink("$location/awstats.pl") or die("Please delete $location/awstats.pl manualy!"); echo "Deleted!
"; } echo "Going to install the awstats.pl
"; copy ("$dir/cgi-bin/awstats.pl","$location/awstats.pl"); if (file_exists("$location/awstats.pl")) echo "+"; else echo "Error linking awstats.pl $location/awstats.pl from $dir/cgi-bin/awstats.pl"; echo "
(Re-)Activating CGI for dir
"; if (file_exists("$location/.htaccess")) { echo "Ok .htaccess already exists let's delete it.."; unlink("$location/.htaccess") or die("Please delete $location/.htaccess manualy!"); echo "Deleted!
"; } copy ("$dir/cgi-bin/.htaccess","$location/.htaccess"); chmod ("$location/.htaccess",0755); chown ("$location/.htaccess",$_SERVER['USER']); echo "Doing an extra permission setting through shell.."; @system("chmod 755 $location/.htaccess"); @system("chmod -L 755 $location/.htaccess"); if (file_exists("$location/.htaccess")) echo "+"; else echo "Error linking .htaccess $location/.htaccess from $dir/cgi-bin/.htaccess"; echo "(Re-)Setting permissions
"; chmod ("$location/awstats.pl",0755); chown ("$location/awstats.pl",$_SERVER['USER']); echo "Doing an extra permission setting through shell.."; @system("chmod 755 $location/awstats.pl"); @system("chmod -L 755 $location/awstats.pl"); echo "Done
Now (re-)creating your configuration file.
"; $fp=fopen("$dir/cgi-bin/awstats.none.conf","r"); $fp2=fopen("/etc/awstats/awstats.$domains[$awdomain].conf","w+"); $cont=fread($fp,filesize("$dir/cgi-bin/awstats.none.conf")); fclose($fp); $cont=ereg_replace("#%LOG%#","/var/log/httpd/domains/$domains[$awdomain].log",$cont); $cont=ereg_replace("#%DOMAIN%#","www.$domains[$awdomain]",$cont); fwrite($fp2,$cont); fclose($fp2); echo "Config file has been created and your statistics are now setup!

"; echo "You can now view the statistics for your domain at: $domains[$awdomain]/awstats/"; ?>