How do I display Awstats publicly in Linux Shared Hosting?

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 article is for the cPanel users only. 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. has not written this script, thus it will not provide any support for any issues arising out of the usage of this script.

  • 650 Users Found This Useful

Was this answer helpful?

Related Articles

Fix :: file_load_file(): wrapper is disabled in the server configuration by allow_url_fopen

Error Message file_load_file($p_url); Severity: Warning Message: file_load_file(): http://...

When I connect to FTP account through filezilla it always says certificate is unknown. What am I missing here?

This error is common because FTP service of our shared server is bound with server's Self-Signed...

How do I create SRV record for my domain?

This article will assist you to add an SRV record to your domain. Services Resource Record (SRV)...

AccuWebHosting Offers PHP 7 Hosting

If you are following recent PHP developments, you must be aware about the latest php version (PHP...

Do you provide Remote MySQL in Linux Shared Hosting?

No. Due to security reasons, we do not provide remote MySQL in Linux Shared Hosting. If you need...