equo25

Member
Jun 28, 2017
5
1
3
Italy
cPanel Access Level
Reseller Owner
Hello everybody,
I has a reseller account and before last update I was able to give customers an access to awstats page from outside cpanel, using a simple php code and a config file into a password protected directory. This index.php was able to access awstats page via port 2083 and customer easily read his stats. After last update this is not working anymore.
Got similar experience? Is anybody able to solve it?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Hello,

There is no native functionality that will allow access or reports from Awstats without first logging in via cPanel. However, I encourage you to vote and add feedback to the existing feature request at:

Feature Request - View Awstats without accessing cPanel

As far as why your script stopped working, it's possibly related to the removal of the X3 theme from the product. Review your script to see if some of the links you were using have changed since the switch to Paper Lantern.

Thank you.
 

equo25

Member
Jun 28, 2017
5
1
3
Italy
cPanel Access Level
Reseller Owner
Ok, encouraging the future request is a good idea... Anyway, I found a php code that allowed to do that, but this is not working anymore. Have been made changes in cpanel? Or simply server's admin closed 2083 door?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Ok, encouraging the future request is a good idea... Anyway, I found a php code that allowed to do that, but this is not working anymore. Have been made changes in cpanel? Or simply server's admin closed 2083 door?
It's possibly related to the removal of the X3 theme from the product. Review your script to see if some of the links have changed since the switch to Paper Lantern.

Thank you.
 

equo25

Member
Jun 28, 2017
5
1
3
Italy
cPanel Access Level
Reseller Owner
I hope that posting my script will not be a problem. It never changed since first time I uploaded... Of course, needs a config file with username and password

Code:
<?php
foreach (array('_GET', '_POST', '_COOKIE', '_SERVER') as $_SG) {
  foreach ($$_SG as $_SGK => $_SGV) {
    $$_SGK = $_SGV;
  }
}

require_once("/home/gianfran/config.php");


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

//it's a .png file...
if(strpos($_SERVER['QUERY_STRING'],'.png')!==false) {
$fileQuery = $_SERVER['QUERY_STRING'];
}
//probably first time to access page...
elseif(empty($_SERVER['QUERY_STRING'])){
$fileQuery = "awstats.pl?config=$domain";
}
//otherwise, all other accesses
else {
$fileQuery = 'awstats.pl?'.$_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('awstats.pl', 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;
?>
 
Last edited by a moderator:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Hello,

Assistance with third-party code is unavailable, but one option to consider is installing a manual copy of Awstats directly to the website instead of attempting to setup a direct link to the cPanel Awstats feature.

Thank you.
 

equo25

Member
Jun 28, 2017
5
1
3
Italy
cPanel Access Level
Reseller Owner
Hello,

Assistance with third-party code is unavailable, but one option to consider is installing a manual copy of Awstats directly to the website instead of attempting to setup a direct link to the cPanel Awstats feature.
Thank you for your suggestion. I thought to do that, but I fear that twice awstats installed (in different directories...) could be a problem or create a mismatch. Is it so? Example: I install awstats in public_html/myawstats - will this get same datas from preinstalled awstats?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,270
463
Thank you for your suggestion. I thought to do that, but I fear that twice awstats installed (in different directories...) could be a problem or create a mismatch. Is it so? Example: I install awstats in public_html/myawstats - will this get same datas from preinstalled awstats?
Here's a third-party URL you may find helpful:

Access Awstats without logging into cPanel

Thank you.