How to display Awstats publicly in Linux shared hosting?

Though, there is no direct way of displaying statistics of your domain on your website, you can use the below Script to accomplish this:

$user = 'username'; //your cpanel username
$pass = 'password'; //your cpanel password
$domain = ''; //do not include 'http://' or 'www.'


//retrieves the file, either .pl or .png
function getFile($fileQuery){
global $user, $pass, $domain;
return file_get_contents("http://$user:$pass@$domain:2082/".$fileQuery,'r');

//it's a .png file...
if(strpos($_SERVER['QUERY_STRING'],'.png')!==false) {
$fileQuery = $_SERVER['QUERY_STRING'];

//probably first time to access page...
$fileQuery = "$domain";

//otherwise, all other accesses
else {
$fileQuery = ''.$_SERVER['QUERY_STRING'];

//now get the file
$file = getFile($fileQuery);

//check again to see if it was a .png file
//if it's not, replace the links

if(strpos($_SERVER['QUERY_STRING'],'.png')===false) {
$file = str_replace('', basename($_SERVER['PHP_SELF']), $file);
$file = str_replace('="/images','="'.basename($_SERVER['PHP_SELF']).'?images',$file);

//if it is a png, output appropriate header
else {
header("Content-type: image/png");

//output the file
echo $file;

Note: This script requires that you save your cpanel username and password in the php file, which is a security risk. Thus, users are requested to use this script at their own risk. Cyberspace Indonesia has not written this script, thus it will not provide any support for any issues arising out of the usage of this script.

NOTE: This article is for the cPanel users only.

Was this answer helpful?

 Print this Article

Also Read

How to change document root folder to some sub-folder using an .htaccess file

By default the web-contents will be loaded from public_html directory of your domain. If you want...

Do you provide SFTP in Linux shared hosting plans?

No, we do not provide SFTP (Secure FTP over SSH). However, we support, FTPS (FTP over explicit...

How to install MediaWiki in Linux hosting?

For example, you wish to install Media Wiki in "wiki" folder then you should extract the...

What is Parked domain?

Pointing one domain to another domain is called Domain Parking. For e.g. ->...

I am having an upload error. What is maximum upload limit in Linux Shared Hosting?

In Linux Shared Hosting, we have restricted the upload size limit to 2 MB but we can raise it to...