I’ve just configured AWStats to work with IIS7 on my web server (see my post, IIS7 Statistics Reporting with Log Parser and AWStats), and now I would like to integrate it into my DotNetNuke (DNN) website.
Here’s an outline of what I would like to do:
- Be able to log into my DNN web site as an authenticated user and navigate to a web statistics page. I don’t want anonymous users to view my stats.
- Create a script that runs in the background to keep the statistics up to date and have it re-generate the html page for the stats.
- See if I can programmatically adjust the LoadPlugin=”timezone –7” for US Central daylight savings or standard time. I really don’t want to have to remember this 2x per year.
So the first thing I did was to open the IIS7 Manager and navigate to my DNN website. I then Right Clicked on it and selected ‘Add Virtual Directory…’. I then choose ‘Statistics’ for my Alias, and navigated to the correct directory path of the AWStats webroot or ‘C:\AWStats\wwwroot’. I then opened up IE and navigated to my web site at https://www.larrybrouwer.com/stats/larrybrouwer_com_stats.html, and it displayed just fine.
My first approach to add the statistics html page was to first add a new page to the DNN website logged in as the site administrator, and then have it permanently redirect as a URL to the statistics page. At first, this seemed to work fine. The only problem was when I tried to restrict access to the file, it didn’t have any effect. In other words, I could enter the URL directly into the browser, and I could open the statistics page.
After much fiddling around with various settings, I decided to try another approach. This time, I again created a new page and deleted the default HTML module on the page. I then added an IFrame Module and set the Location to the URL for the statistics page. I set the Width and Height to 100%, checked the Auto height, disabled Scrolling and Border by setting both of them to ‘No’. This seemed to work much better. Now, when I directly enter the URL for the DNN Statistics page, it redirects me to the login screen! Pretty cool.
There’s only one catch… And that is, I can still access the statistics page by directly entering the URL of the actual page. After about 2 hours of Googling and fiddling around with Web.config settings, I came up with the solution. I went into IIS7 Manager, and selected the Statistics virtual directory. I then clicked on the Authorization Rules. I then clicked ‘Add Deny Rule…’. I then selected ‘All anonymous users’ to Deny access to anyone who isn’t a user with a valid id. So I think I’ve got it! This action resulted in a Web.config file being generated in the Statistics virtual directory (or c:\AWStats\wwwroot). Here’s the contents of the Web.config file:
<configuration>
<location path=””>
<system.webServer>
<security>
<authorization>
<add accessType=”Deny” users=”?” />
</authorization>
</security>
</system.webServer>
</location>
</configuration>
This concludes step 1! On to the next. The second step should be pretty straight forward. All I think I need to do is create a script with essentially two (2) steps in it. First, regenerate the AWStats, then regenerate the html for it. Here’s the script I came up with:
cd \AWStats\wwwroot\cgi-bin
awstats.pl -config=www.domain.com
awstats.pl -config=www.domain.com -output -staticlinks > ..\domain_com_stats.html
exit
I then added the script to the Task Scheduler. I initially set it up to run every 10 minutes.
The next day (4/27/2010)
I discovered today that I’m still having issues with access security on the direct URL’s. So I decided to install AWStats directly in the DotNetNuke root folder. To me, this makes a lot more sense now, and should help me solve some problems with using virtual directories, etc. I’ll tackle that problem later today, hopefully.
I also fixed a problem with the icons not displaying correctly (see my other post for more details here).
I also updated my script to generate all the reports automatically:
G:
cd \data\www\DotNetNuke\AWStats\tools
awstats_buildstaticpages.pl -config=DotNetNuke -staticlinks -update -configdir=..\wwwroot\cgi-bin – awstatsprog=..\wwwroot\cgi-bin\awstats.pl -dir=..\wwwroot
awstats_buildstaticpages.pl -config=TechNotes -staticlinks -update -configdir=..\wwwroot\cgi-bin – awstatsprog=..\wwwroot\cgi-bin\awstats.pl -dir=..\wwwroot
I also changed DNN to allow for uploading of .html files. Host / Host Settings / Advanced Settings / Other Settings / Allowable File Extensions which in an attempt to fix my file security issues. More on that later.
Leave a Reply
You must be logged in to post a comment.