Ok - I’ve attempted to create a script to get the awstats file for the previous month. It uses cURL and mail().
Usage …
Copy the stats_email.inc to your server (this is the email script - kindly borrowed from phpWizard - Modified by Tobias Ratschiller)
You would add an entry in to cron to get call the stats.inc script on the 2nd of the month. This would then email the awstats for the previous month to the recipient(s). NOTE: Stats.inc needs to be modified for your domain.
Issues …
a. Currently only works for awstats.
b. Only seems to send to gmail address (instant) and AOL at present (took time to reach AOL address) - tested with hotmail as well, still not recieved.
c. Images do not appear in the report, meaning graphs arent coloured.
d. Coding might not be the best.
Please feel free to modify and work on - only request I as is that you post any new stuff back here for all to use …
I cleaned up and modified this script to make it easier for people to configure it. Unfortunately, the graphical components are still not part of the attachments so the graphs don’t work well in the AwStats report.
Yeah - that was a problem I was having … being able to grab the graphs/images … going to investigate curl a bit more to see if there is anyway to grab the images as well.
I was thinking … once you hit the page via curl in the browser the images are displayed … wonder could we make a PDF of it and use this in the mail?
Also, I wreckon it wouldnt be hard to modify the script to grab stats for Analog or Webalizer.
The thing is when you use display the result of curl in a browser, it is the browser that goes off and gets the images from the storage location – not curl. I was thinking of modifying all the different img directives (and there are a lot of different ones mainly due to different colors, etc) to use one simple image that I could include as an attachment to the email. I would also then want the report to actually be in the body of the email message so the email client would know how to embed the simple image properly.
The other possibility is to completely replace the img and modify the table cells with different background colors. The graphs would have the different colors but it would look flat.
Creating a PDF from the report might be another idea but I need to check for scripts out there that can render HTML into a PDF.
I might find time to work on this again this weekend… then again nice weather tends to pull me outside