x10Hosting Forums


If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.





Reply
Old 04-28-2007, 12:02 PM   #11 (permalink)
x10 Lieutenant
 
Join Date: Sep 2006
Posts: 348
Credits: 3,856
dest581 is on a distinguished road
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.
dest581 is offline   Reply With Quote
Old 04-28-2007, 12:06 PM   #12 (permalink)
x10 Spammer
 
Join Date: May 2005
Location: cossacks
Posts: 3,780
Credits: 6,485
Derek is a splendid one to behold
Re: cPanel Remote Bandwidth Script

Also if someone views the source can they see your cpanel info?
__________________
-Derek
Serving for x10 Since December 26, 2004
Retired. Former Staff.(Account Manager)
http://www.i628.net - http://www.derekchai.com

Derek is offline   Reply With Quote
Old 04-28-2007, 01:35 PM   #13 (permalink)
x10 Lieutenant
 
Join Date: Sep 2006
Posts: 348
Credits: 3,856
dest581 is on a distinguished road
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.
dest581 is offline   Reply With Quote
Old 04-28-2007, 01:41 PM   #14 (permalink)
Retired
 
Brandon's Avatar
 
Join Date: Jun 2006
Location: The ghetto aka Tbury, Massachusetts
Posts: 7,926
Credits: 6,200
Brandon is a glorious beacon of light
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.
__________________
Thanks,
Brandon

Script Development In Progress: PHP Load Tester (free)

Last edited by Brandon; 04-28-2007 at 01:52 PM..
Brandon is offline   Reply With Quote
Old 12-22-2007, 01:56 AM   #15 (permalink)
VIP User
 
mr kennedy's Avatar
 
Join Date: Aug 2007
Location: Toronto, Canada/Muntinlupa City, Philippines
Posts: 496
Credits: 243
mr kennedy will become famous soon enough
Send a message via MSN to mr kennedy Send a message via Yahoo to mr kennedy
Re: cPanel Remote Bandwidth Script

^I like this version better....
__________________

It's me, dgenx210
If you find my posts helpful, please add it to my reputation () or spare me some x10˘'s.
I would really appreciate it if you do any of the two.
---------------
Tutorials!:
Webmail Login Script v.1.00(By Passing the Popup Prompt)
---------------

---------------


mr kennedy is offline   Reply With Quote
Old 12-26-2007, 12:02 PM   #16 (permalink)
OHAIDER
 
vigge_sWe's Avatar
 
Join Date: Oct 2007
Location: Göteborg, Sweden
Posts: 3,321
Credits: 13,387
vigge_sWe has a reputation beyond reputevigge_sWe has a reputation beyond repute
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..
vigge_sWe is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT -5. The time now is 02:59 AM. Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.0
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
Copyright 2008+ x10Hosting LLC.
Ad Management by RedTyger




CO.CC:Free Domain

Vote for us!