NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Webmaster Tutorials
Reload this Page [TUTORIAL] Get Awstats outside of cpanel

Webmaster Tutorials Instructional webmaster-related how-to's and tutorials.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 10-27-2006, 12:39 AM THREAD STARTER               #1 (permalink)
NamePros Regular
Join Date: Jan 2006
Location: Sparkling Bottled Awsome Country
Posts: 876
Marcvs is just really niceMarcvs is just really niceMarcvs is just really niceMarcvs is just really nice
 



[TUTORIAL] Get Awstats outside of cpanel


Here is a more secure version of getting your awstats outside of cpanel.

Demo

Rep Appreciated

First Create a file called;

awconfig.php

enter this into it (edit to suit your domain)

PHP Code:

<?

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

$config_domain 'onebuckdirectory.com'//The Domain You want the Awstats to show (can be altered in browser) 

$dynamic_images true//Ignore at the moment
$image_directory './awstats_images/'//Ignore at the moment! 

?>
Then create a second file called index.php

Put This code in (no need to edit anything)

PHP Code:

<?


require ('awconfig.php');

//retrieves the file, either .pl or .png
function get_file($fileQuery)
????: NamePros.com http://www.namepros.com/webmaster-tutorials/251364-tutorial-get-awstats-outside-of-cpanel.html
{
  global 
$user$pass$domain;
  return 
file_get_contents("http://$user:$pass@$domain:2082/".$fileQuery);
}

$requesting_image = (strpos($_SERVER['QUERY_STRING'],'.png')===false)?false:true;

if(
$requesting_image//it's a .png file...
{
  if(!
$dynamic_images && !is_dir($image_directory))
  {
    exit;
  }
  
$fileQuery $_SERVER['QUERY_STRING'];
}
elseif(empty(
$_SERVER['QUERY_STRING']))//probably first time to access page...
{
    if(empty(
$config_domain))
    {
        
$config_domain $domain;
    }
  
$fileQuery "awstats.pl?config=$config_domain";
}
else 
//otherwise, all other accesses
{
  
$fileQuery 'awstats.pl?'.$_SERVER['QUERY_STRING'];
}

$file get_file($fileQuery);

//check again to see if it was a .png file
//if it's not, replace the links
if(!$requesting_image)
{
  
$file str_replace('awstats.pl'basename($_SERVER['PHP_SELF']), $file);

  if(
$dynamic_images)
  {
    
$imgsrc_search '="/images';
    
$imgsrc_replace '="'.basename($_SERVER['PHP_SELF']).'?images';
  }
  else
  {
    
$imgsrc_search 'src="http://cdn.namepros.com/images/awstats/';
    
$imgsrc_replace 'src="'.$image_directory;
????: NamePros.com http://www.namepros.com/showthread.php?t=251364
  }

  
$file str_replace($imgsrc_search$imgsrc_replace$file);
  
$file str_replace($spam_words'SPAM'$file);
}
else 
//if it is a png, output appropriate header
{
  
header("Content-type: image/png");
}

//output the file
echo $file;
?>
Then upload both to your webserver in an awstats directory and away you go, i will soon do a version where the config is outside the public_html folder.

Marcvs
Last edited by Marcvs; 11-03-2006 at 01:02 PM.
Marcvs is offline  
Old 10-27-2006, 06:25 AM   #2 (permalink)
Freelance Web Designer
 
Janine's Avatar
Join Date: May 2006
Location: Philippines
Posts: 3,019
Janine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond reputeJanine has a reputation beyond repute
 



Cystic Fibrosis Save a Life
Wow.
I really need this.
i'll try this if it'll work
rep added
Janine is offline  
Old 10-27-2006, 08:48 AM THREAD STARTER               #3 (permalink)
NamePros Regular
Join Date: Jan 2006
Location: Sparkling Bottled Awsome Country
Posts: 876
Marcvs is just really niceMarcvs is just really niceMarcvs is just really niceMarcvs is just really nice
 



if you get an error just reply here and ill bug check it!

updated to!
Marcvs is offline  
Old 10-28-2006, 03:57 AM   #4 (permalink)
NamePros Regular
Join Date: Apr 2006
Posts: 261
unknownserv is on a distinguished road
 



Shows this for a PNG file:
Code:
Warning: Cannot modify header information - headers already sent by (output started at /home/user/public_html/stats/index.php:1) in /home/user/public_html/stats/index.php on line 60
unknownserv is offline  
Old 10-28-2006, 05:07 AM THREAD STARTER               #5 (permalink)
NamePros Regular
Join Date: Jan 2006
Location: Sparkling Bottled Awsome Country
Posts: 876
Marcvs is just really niceMarcvs is just really niceMarcvs is just really niceMarcvs is just really nice
 



which PNG?
Marcvs is offline  
Old 10-28-2006, 06:11 AM   #6 (permalink)
NamePros Regular
Join Date: Apr 2006
Posts: 261
unknownserv is on a distinguished road
 



Any, I think.
unknownserv is offline  
Old 10-28-2006, 06:18 AM THREAD STARTER               #7 (permalink)
NamePros Regular
Join Date: Jan 2006
Location: Sparkling Bottled Awsome Country
Posts: 876
Marcvs is just really niceMarcvs is just really niceMarcvs is just really niceMarcvs is just really nice
 



hmm :S

anyone else got this problem...

ill finish of the dynamic images one which is morre advanced but harder to do
Marcvs is offline  
Old 12-13-2006, 07:19 AM   #8 (permalink)
New Member
 
eNOOBz's Avatar
Join Date: Dec 2006
Posts: 3
eNOOBz is an unknown quantity at this point
 



Hi Marcvs,

How do you make the Awstats to 'Update Now'?. Thanks.
__________________
The Internet Newbie Universe
eNOOBz is offline  
Old 12-13-2006, 05:17 PM   #9 (permalink)
Senior Member
 
PolurNET's Avatar
Join Date: Jul 2004
Location: I ♥ Business Law
Posts: 3,082
PolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant futurePolurNET has a brilliant future
 

Member of the Month
January 2007
Alzheimer's Cancer Survivorship Third World Education Autism Save a Life Cystic Fibrosis Parkinson's Disease Lou Gehrig's Disease (ALS) Autism Multiple Sclerosis SIDS
Originally Posted by eNOOBz
Hi Marcvs,
????: NamePros.com http://www.namepros.com/showthread.php?t=251364

How do you make the Awstats to 'Update Now'?. Thanks.
Step 1: Go to /tmp/awstats/

Step 2: Edit awstats.yourdomain.com.conf and change AllowToUpdateStatsFromBrowser=0 to AllowToUpdateStatsFromBrowser=1

Step 3: Goto Awstats and use the Update Now button/link which will now appear
PolurNET is offline  
Old 12-14-2006, 08:21 AM   #10 (permalink)
New Member
 
eNOOBz's Avatar
Join Date: Dec 2006
Posts: 3
eNOOBz is an unknown quantity at this point
 



Thanks polurNET but my hosting admin has just do that for me. Anyway thanks for the tip.
__________________
The Internet Newbie Universe
eNOOBz is offline  
Old 12-14-2006, 09:03 PM   #11 (permalink)
Senior Member
 
cyberoptik's Avatar
Join Date: Aug 2003
Location: Chicago Burbs
Posts: 1,106
cyberoptik is a name known to allcyberoptik is a name known to allcyberoptik is a name known to allcyberoptik is a name known to allcyberoptik is a name known to allcyberoptik is a name known to allcyberoptik is a name known to allcyberoptik is a name known to all
 


Breast Cancer
Heres another link, you could probably use it for fixing any bugs (I haven't tested this)

http://wiki.jumba.com.au/wiki/View_a...side_of_cPanel
__________________
Website Scripts - The Best Scripts on the Web
Follow Scripteen on Facebook!
cyberoptik is offline  
Old 02-15-2007, 04:10 PM   #12 (permalink)
Account Closed
Join Date: Sep 2006
Posts: 1,075
YesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to allYesBrilliant is a name known to all
 



Originally Posted by PolurNET
Step 1: Go to /tmp/awstats/
????: NamePros.com http://www.namepros.com/showthread.php?t=251364

Step 2: Edit awstats.yourdomain.com.conf and change AllowToUpdateStatsFromBrowser=0 to AllowToUpdateStatsFromBrowser=1

Step 3: Goto Awstats and use the Update Now button/link which will now appear
That is very useful.

Thanks for sharing.
YesBrilliant is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 10:02 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger