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.

modify quota and bandwidth

Discussion in 'cPanel Developers' started by scottc, Jun 7, 2007.

  1. scottc

    scottc Well-Known Member

    Joined:
    Apr 21, 2002
    Messages:
    48
    Likes Received:
    0
    Trophy Points:
    6
    Is there a way to modify a domain's quota or bandwidth with xml-api? Or do we have to stick with /scripts/editquota and /scripts2/dolimitbw ?

    Scott
     
  2. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    I would like to know this as well. I would like to know how to access bandwidth quotas and usage with the api as well. As far as what i have seen and been told, its not possible with cpanel 11.
     
  3. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    come on, i really really need this.
     
  4. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator

    I still cant figure out how to modify bandwidth with the api in cpanel 11. /scripts2/dolimitbw doesnt even exist anymore. Can someone please help?
     
  5. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Are you doing this for an individual account or for an entire package? If you are editing a package, you can use EditPkg in the XML-API.
     
  6. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    Individual accounts. I definitely dont want to modify the packages.
     
  7. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    David, can you please finish helping me?
     
  8. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    At this time there is no means by which to modify the bandwidth allocation for a user without modifying the package their account is associated with.

    If you desire this functionality, I would recommend you submit this as a feature request to:

    http://bugzilla.cpanel.net
     
  9. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    So your saying that cpanel 11 does allow this, but cpanel 10 did? That just doesnt make sense to do that. I rely on this functionality.
     
  10. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    That functionality was not available in the WHM API used in cPanel 10.
     
  11. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    oh, i thought you could do it with /scripts/editquota and /scripts2/dolimitbw
     
  12. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    If you want to use /scripts/editquota, that's fine for now - just remember that since it isn't an API, it is subject to change without notice.

    /scripts2 is undocumented functionality, use that at your own risk.
     
  13. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    the problem is that cpanel 11 doesnt have /scripts2 anymore, so as far as i can see, there is no scripts or api for modifying a domains bw. Am i correct?
     
  14. cPanelDavidG

    cPanelDavidG Technical Product Specialist

    Joined:
    Nov 29, 2006
    Messages:
    11,279
    Likes Received:
    8
    Trophy Points:
    38
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    You can modify a domain's bandwidth by editing the package associated with that domain via the XML API. If you want to edit that domain's bandwidth outside of editing that package, then I am not aware of any API function to handle that.

    You are always welcome to login via SSH as root and list the scripts in /scripts to determine if using any of those would be of assistance for your endeavor.
     
  15. MACscr

    MACscr Well-Known Member

    Joined:
    Sep 30, 2003
    Messages:
    190
    Likes Received:
    1
    Trophy Points:
    18
    cPanel Access Level:
    Root Administrator
    updating a package is useless as it will then update everyone else as well.

    I looked in the /scripts folder and from at least file name,couldnt find anything that would modify an accounts domain.

    Could i take the script (dolimitbw) from a cpanel 10 server and use it on the cpanel 11 server?

    Is there a cpanel developer that can step in here and give me some ideas?
     
  16. wsenter

    wsenter Well-Known Member

    Joined:
    Aug 5, 2003
    Messages:
    88
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    Texas
    This will work for now. Again this is not totally per cPanel API as cPanelDavidG but it does the trick for sure. I have this up and running on cPanel version 11.

    Assumptions: The server that you are running this script on has php and curl installed.

    It can be used to access ANY other cPanel server (or the server you are running this script on) and NONE of the "other servers" require php OR curl (though realistically they are probably on there anyway)

    Enjoy my free php code for you....
    Code:
    <?php 
    // start the session and pass the Session parameter
    session_start(); 
    header("Cache-control: private"); //IE 6 Fix
    
    ######### Set up basic variables #########
    $serverIPaddress="192.168.1.1:2087";
    $whmusername="root";
    $whmpassword="123456";
    
    //set the username of the account you are working with
    $user = "bobby12";
    
    //set a variable to be used for bandwidth limit
    //this number is expressed in "megs" NOT "gigs".
    //example "1.5" is 1.5 MEGS NOT gigs
    $bndwidth = 500";
    
    //set a variable to be used for quota limit
    $quota = 20000':
    
    
    ######## set environment variables #########
    ## you shouldn't need to change any of these ###
    $server="https://$whmusername:$whmpassword@$serverIPaddress";
    $agent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)";
    
    
    //build string to later be used with curl to change user's quota
    $url="$server/scripts/editquota?user=$user&quota=$quota";
    
    //bandwidth
    $url="$server/scripts2/dolimitbw?user=$user&bwlimit=$bndwidth";
    
    
    ######### Here are few MORE example of many of the items that you could do with curl.  It will not execute until the very bottom #########
    
    //change user's password
    $url="$server/scripts/passwd?password=$passwd&domain=$user&user=$user";
    
    //enable shell access		
    $url="$server/scripts2/domanageshells?user=$user&shell=Enable+Jailed+Shell&user=$user";
    
    //suspend an account
    $url="$server/scripts2/suspendacct?domain=$user&user=$user&suspend-domain=Suspend&reason=";
    
    //UN-suspend an account
    $url="$server/scripts2/suspendacct?domain=$user&user=$user&unsuspend-domain=UnSuspend&reason=";
    
    //add front page extensions
    $url="$server/scripts/installfp?domain=$user&user=$user&submit-domain=Install";
    
    //remove front page extensions
    $url="$server/scripts/uninstallfp?domain=$user&user=$user&submit-domain=UnInstall";
    
    //add a domain pointer
    $url="$server/scripts/park?txtdomain=&domain=$domain&ndomain=$NewDomain";
    		
    //modify the account
    $url="$server/scripts/saveedituser?user=$user&BWLIMIT";
    $url.="=$BWLIMIT&FEATURELIST=$FEATURELIST&IP=$IP&OWNER";
    $url.="=$OWNER&PLAN=$PLAN&STARTDATE=$STARTDATE&DNS=$domain";
    $url.="&RS=$RS&LANG=english&newuser=$user&seeshell=$shell&MAXPOP";
    $url.="=$MAXPOP&MAXFTP=$MAXFTP&MAXLST=$MAXLST&MAXSUB=$MAXSUB&MAXSQL";
    $url.="=$MAXSQL&MAXPARK=$MAXPARK&MAXADDON=$MAXADDON";
    
    //generate a csr
     //need to replace spaces in all of the variables with the '+' sign
    $host = str_replace(" ","+",$host);
    $country = str_replace(" ","+",$country);
    $state = str_replace(" ","+",$state);
    $city = str_replace(" ","+",$city);
    $cod = str_replace(" ","+",$cod);
    $co = str_replace(" ","+",$co);
    $email = str_replace(" ","+",$email);
    $pass = str_replace(" ","+",$pass);
    $url="$server/scripts/gencrt?xemail=$xemail&host=$host&country";
    $url.="=$country&state=$state&city=$city&co=$co&cod=$cod&email=$email&pass=$pass";
    		
    ######### execute curl #########
    
    $ch=curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
    curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookie.txt');
    curl_setopt($ch, CURLOPT_MAXREDIRS, 4);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 120);
    curl_setopt($ch, CURLOPT_USERAGENT, $agent);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
    $buffer = curl_exec($ch);
    curl_close($ch);
    
    ?>
    Again these are NOT API compliant. They definitely DO work NOW but are no guarantees that they will continue to work as new cpanel versions come out. I have been using these (without modification) though since cpanel 8.
     
Loading...

Share This Page