Read Webalizer output from Drupal

Problem: You need to read webalizer output on a daily basis securely.
Answer:In order to read webalizer from inside drupal safely and securely do the following. This assumes that you have unix/linux level access to your host server.

1. Create a folder named “usage” (without quotes) under root folder of your site. It will be a folder /path/to/drupal/sites/YourSite.com/usage.
2. Copy default webalizer.conf to this folder from /etc/webalizer and configure it properly to use YourSite’s access log. Read Webalizer documentation to know more about configuration.
3. Go the /path/to/drupal/sites/YourSite.com/usage folder and run webalizer command without any arguments. This will process YourSite’s access log and create the output file including an index.html.
4. Make sure you can look at the webalizer output from outside by going to www.YourSite.com/usage . If you get “Access Denied” error then you may have to make changes to .htaccess file to allow access to this folder. Once you are able see webalizer output, undo your changes or make changes to disable access to the usage folder via .htaccess. This is very important to ensure no one can look at the usage folder from outside using www.YourSite.com/usage.
5. Log into YourSite.com and Add a role “Administrator” using Administer/User Management/Roles
6. Create a menu “Admin Pages” using Administer/Menu/Add.
7. Make the menu visible to “Administrator” only using Administer/Blocks/Configure
8. Add a node using php input type. Add the following code in the page and save. Do not “Publish” this page. This will ensure only you as Administrator has access to this page.
####################################################

<?php

$script_url = "/node/NodeNumber?file=";
$usage_folder = "sites/Yoursite.com/usage/";
$index_file_name = "index.html";
$index_url = '<a href="'.$script_url.$usage_folder.$index_file_name.'"> YourSite Usage Statistics</a>';

print $index_url;

$file = $_GET['file'];

if ($file) {
$file_handle = fopen($file, "r");
while (!feof($file_handle)) {
$line_of_text = fgets($file_handle);

$search = "/usage(.*)html/";
$replace_with = "usage$1html";

$replace= $script_url.$usage_folder.$replace_with;

$line_of_text2 = preg_replace ($search, $replace, $line_of_text );
print $line_of_text2 ;
}

fclose($file_handle);
}
?>
####################################################

Read Webalizer output from Drupal Part2




Watch Your Bottom Line Improve In Just 30 Days!
Amazing new Invoice and Expense software does all the work for you.
TooLERP Screen Shot

Esitmates
Invoices
Receipts
Expenses
Liabilities
Reports

Windows Linux Mac
MySQL Ruby Apache
Simple and Easy
Download and Unzip
TooLERP Box