+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 11 to 16 of 16

Thread: cPanel Remote Bandwidth Script

  1. #11
    x10 Lieutenant dest581 is an unknown quantity at this point
    Join Date
    Sep 2006
    Posts
    348

    Re: cPanel Remote Bandwidth Script

    It isn't a replacement for cpanel, since it grabs the data directly from cpanel. It's a way to display the amount used to your users, who (hopefully :D) cannot view your cpanel.

  2. #12
    Community Advocate Derek is an unknown quantity at this point
    Join Date
    May 2005
    Location
    cossacks
    Posts
    3,935

    Re: cPanel Remote Bandwidth Script

    Also if someone views the source can they see your cpanel info?
    -Derek
    Please Click If I helped you!
    Serving for x10 Since December 26, 2004
    Retired. Former Staff.(Account Manager)

  3. #13
    x10 Lieutenant dest581 is an unknown quantity at this point
    Join Date
    Sep 2006
    Posts
    348

    Re: cPanel Remote Bandwidth Script

    In a normal situation, it will not be viewed. Here are the ways that your info could be revealed:

    1) PHP breaks. Apache simply sends out the php script, without processing it
    2) Someone gets FTP access and downloads it that way

    I personally wouldn't use this script because of the tiny chance of hacking. Instead, I'd modify the script so that it updates a txt file with the bandwidth amount. I would then put that script in a non-web-accessable directory, and set up a cron job to run it every 5 minutes.

  4. #14
    Administrator Brandon is an unknown quantity at this point Brandon's Avatar
    Join Date
    Jun 2006
    Location
    The ghetto aka Tbury, Massachusetts
    Posts
    8,260

    Re: cPanel Remote Bandwidth Script

    Before you criticize my 5 minute work, there is another way of doing it this way.

    PHP Code:
     <?php 
    class cpanel 

        
    /**  
        * @var        resource        contains curl resource for communication with cpanel  
        **/ 
        
    var $socket 
        
    /** 
        * @param    string            username          your cpanel username 
        * @param    string            password          your cpanel password 
        * @param    string            hostname          your cpanel hostname 
        * @param    bool            ssl                  indicate ssl availability 
        * @param    string            theme              indicate the theme being used 
        * @return    void 
        * 
        * This will give you the default settings of using ssl and X as the theme 
        * <code><?php $cpanel = new cpanel( 'username', 'password', 'hostname' ); ?></code> 
        *  
        * This will allow you to disable SSL 
        * <code><?php $cpanel = new cpanel( 'username', 'password', 'hostname', false ); ?></code> 
        *  
        * This will allow you to disable SSL and change the theme 
        * <code><?php $cpanel = new cpanel( 'username', 'password', 'hostname', false, 'mytheme' ); ?></code> 
        **/ 
        
    function cpanel$username$password$hostname$ssl true$theme 'x' 
        { 
            
    $this->ssl $ssl 
            
    $this->username $username 
            
    $this->password $password 
            
    $this->hostname $hostname 
            
    $this->request $request 
            
    $this->theme $theme 
             
            if( !( 
    $this->socket = @curl_init( ) ) ): die('FATAL : Cannot initialize curl'); 
                return; 
            else:     
                if( 
    $this->ssl ): 
                    
    curl_setopt$this->socketCURLOPT_SSL_VERIFYPEER);                 
                    
    curl_setopt$this->socketCURLOPT_SSL_VERIFYHOST); 
                endif; 
                 
                
    curl_setopt$this->socketCURLOPT_FOLLOWLOCATION); 
                
    curl_setopt$this->socketCURLOPT_HEADER); 
                
    curl_setopt$this->socketCURLOPT_RETURNTRANSFER); 
                
    curl_setopt$this->socketCURLOPT_HTTPHEADER,  
                array( 
    sprintf"Authorization: Basic %s"base64_encodesprintf'%s:%s'$this->username$this->password ) ) ) ) 
                ); 
            endif;     
             
            if( 
    ereg'Login Attempt Failed'$this->make_requestsprintf'/frontend/%s/'$this->theme ) ) ) ) 
                die(
    "Cannot login to cpanel"); 
        } 
        
    /** 
        * @param    string            request            the page to retrieve from cpanel 
        * @return    string            returns raw data 
        * 
        * This would retrieve the index page from cpanel 
        * <code><?php $cpanel->make_request( "/frontend/$cpanel->theme" ); ?> 
        **/ 
        
    function make_request$request 
        { 
            if( 
    $this->ssl 
                
    curl_setopt$this->socketCURLOPT_URLsprintf"https://%s:2083%s",$this->hostname,  $request ) ); 
            else 
                
    curl_setopt$this->socketCURLOPT_URLsprintf"http://%s:2082%s",$this->hostname,  $request ) ); 
             
            return 
    curl_exec$this->socket ); 
        } 
        
    /** 
        * @return    string            returns html tables of table from cpanel index 
        * 
        * This example method returns all your account information from cpanel index, unformatted 
        * <code><?php echo $cpanel->account_tables( ); ?></code> 
        **/ 
        
    function account_tables( ) 
        { 
            
    preg_match_all'#(<table width="275" border="0" cellspacing="3" cellpadding="4">.*?[^<]</table>)#si',  
                            
    $this->make_requestsprintf"/frontend/%s/"$this->theme ) ),  
                            
    $return  
            
    ); 
            return 
    implode"<br />"$return[0] ); 
        } 
        
    /** 
        * This method closes the curl resource 
        * 
        * <code><?php $cpanel->_close( ); ?></code> 
        **/     
        
    function _close( ) 
        { 
            return @
    curl_close$this->socket ); 
        } 

    $cpanel = new cpanel"username""password""hostname" ); 

    echo 
    $cpanel->account_tables( ); 

    $cpanel->_close( ); 
    ?>
    That of course uses the HTTP autentication.


    I will also work on changing it for cron at a later date, I am busy writing a few classes for my site.
    Last edited by Brandon; 04-28-2007 at 01:52 PM.
    Thanks,
    Brandon, x10Hosting Administrator
    (978) 571-9054

  5. #15
    x10 Elder mr kennedy is an unknown quantity at this point mr kennedy's Avatar
    Join Date
    Aug 2007
    Location
    Toronto, Ontario, Canada
    Posts
    508

    Re: cPanel Remote Bandwidth Script

    ^I like this version better....

  6. #16
    Where's North from here? vigge_sWe is on a distinguished road vigge_sWe's Avatar
    Join Date
    Oct 2007
    Location
    Göteborg, Sweden
    Posts
    4,816

    Re: cPanel Remote Bandwidth Script

    Oh My God!!! Just what I wanted just in time! I must be able to feel these thing happen. Everytime I want something it pops up right in front of me the same day. What a pity it doesen't do the same thing with money...

    Hey brandon, is it possible to do the script show total bandwidth used over time. So if my site have used 50 gb under 1 year it will show that? So it show total bandwidth used from the implementent of the script?

    Some things I noticed:

    1. the variable $number is two diffferent values:
    PHP Code:
    $number explode("<td class=\"index2\">"$finally);
    $number explode(" ",$number[1]); 
    2. It doesen't work: http://jagf.net/bandwidth.php
    Last edited by vigge_sWe; 12-26-2007 at 12:23 PM.







+ Reply to Thread
Page 2 of 2
FirstFirst 1 2

Similar Threads

  1. [OFF] Script Instillations (Now Accepting)
    By kryptonyte in forum The Marketplace
    Replies: 0
    Last Post: 08-02-2006, 02:15 AM
  2. Server UP time Script
    By dharmil in forum Scripts & 3rd Party Apps
    Replies: 2
    Last Post: 04-03-2006, 04:39 PM
  3. CGI - script, Advertisement _HELP.
    By kaliforna in forum Free Hosting
    Replies: 12
    Last Post: 06-02-2005, 06:01 AM
  4. digital.exofire.net | Support | problem#1 = " cPanel "
    By kaliforna in forum Free Hosting
    Replies: 10
    Last Post: 04-12-2005, 11:22 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts