The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to Access 'AWstats' without login in to CP...

Discussion in 'General Discussion' started by billau, Jul 17, 2004.

  1. billau

    billau Well-Known Member

    Joined:
    Dec 24, 2003
    Messages:
    65
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Brisbane, Australia
    Here is the php code ::


    <?php
    //dv

    $user = 'username';
    $pass = 'password';
    $url = 'www.mydomain.com';//do not include 'http://'

    //retrieves the webalizer file, either .html or .png
    function getFile($file){
    global $user, $pass, $url;
    return file_get_contents("http://$user:$pass@$url:2082/tmp/$user/webalizer/$file",'r');
    }
    //alters links, either .html or .png
    function changeLinks($subject, $type) {
    global $user, $pass, $url;
    return preg_replace("/($type=\")(?!http)(.*?)\"/is","$1$PHP_SELF?$2\"",$subject);
    }

    if(!empty($_SERVER['QUERY_STRING'])){

    //get file (whether png or html)
    $page = getFile($_SERVER['QUERY_STRING']);

    //if png, output appropriate header
    if(strpos($_SERVER['QUERY_STRING'],'.png')!==false){
    header("Content-type: image/png");
    }
    //change the .png src(s)
    else {
    $page = changeLinks($page, 'src');
    }
    }
    else {
    //get index
    $page = getFile('index.html');

    //change links
    $page = changeLinks($page, 'href');

    //change the usage.png src
    $page = changeLinks($page, 'src');
    }
    //output it
    echo $page;

    ?>
     
  2. sawbuck

    sawbuck Well-Known Member

    Joined:
    Jan 18, 2004
    Messages:
    1,367
    Likes Received:
    5
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    Looks like you mean Webalizer not AWstats. Not nearly as helpful as AWstats reports.
     
  3. navertise

    navertise Member

    Joined:
    Sep 18, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Does anyone know how to do this with Awstats? I don't want my clients to have access to the cpanel, but I do want them to be able to view awstats.
     
  4. kmsd

    kmsd Well-Known Member

    Joined:
    May 21, 2003
    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    6
  5. navertise

    navertise Member

    Joined:
    Sep 18, 2004
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I tried the above php for viewing Webalizer stats, and the .png file came through as a broken image.

    The source of the page that results has the following for the img link:
    <IMG SRC="?usage.png" ALT="Usage summary for inkandblood.com" HEIGHT=256 WIDTH=512><P>

    The odd thing is that my browser is reporting that it had no problems retrieving the image, and displays the full URL to it, not the "?usage.png" version, which allows me to see the image.

    Any ideas?
     
Loading...

Share This Page