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.

Function for Create FTP Account,EMAIL,MYSQL Database

Discussion in 'cPanel Developers' started by weblizzer, Mar 29, 2009.

  1. weblizzer

    weblizzer Registered

    Joined:
    Mar 29, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    Hi, i would like to ask if how can i execute this list of functions from xmlapi or api2 because, i'm doing a script for handling cpanel accounts and peform this functions.

    1. create/edit/delete ftp account
    2. create/edit/delete sub domain
    3. create/edit/delete database and users
    4. upload files, extract files from file manager.


    for a basic this is just what i want and hope you guys can help me with it.

    I'm trying to used some cpanel class from phpclasses.org but it seems that it's not working anymore.. hope you can help me thanks a lot.
     
  2. 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
    To create a FTP account, use this API1 function:

    Code:
    <cpanel Ftp="addftp(login, password, homedir, quota,,homedir)">
    
    login = FTP username without @domain (cPanel adds that automatically)
    password = FTP password
    homedir = directory to which the FTP account has access
    quota = FTP user's quota in megabytes

    To remove a FTP account:

    Code:
    <cpanel Ftp="delftp(login, destroy)">
    destroy = 1 if you want to remove all files within the directory that the FTP user had access to.

    To change a FTP account quota:

    Code:
    <cpanel Ftp="ftpquota(acct, quota)">
    To change a FTP account password:

    Code:
    <cpanel Ftp="passwdftp(acct, password)>
    Here's a thread on creating subdomains: http://forums.cpanel.net/showthread.php?p=358383#post358383

    Here's the raw API2 call cPanel uses to remove a subdomain:

    Code:
    <?cp SubDomain::delsubdomain(% %,result,reason) domain=$FORM{'domain'} ?>
    Raw API1 code for setting a redirect on a subdomain

    Code:
    <cpanel SubDomain="setsuburl($FORM{'domain'},$FORM{'url'})">
    Raw API1 code for adding a MySQL database:
    Code:
    <cpanel Mysql="adddb($FORM{'db'})">
    Raw API1 code for removing a MySQL database:
    Code:
    <cpanel Mysql="deldb($FORM{'db'})">
    Raw API1 code for creating a MySQL user:
    Code:
    cpanel Mysql="adduser($FORM{'user'},$FORM{'pass'})">
    Raw API1 code for deleting a MySQL user:
    Code:
    <cpanel Mysql="deluser($FORM{'user'})">
    Raw API1 code for adding a MySQL user to a MySQL Database with Permissions:
    Code:
    <cpanel Mysql="adduserdb($FORM{'db'},$FORM{'user'},$FORM{'ALTER'} $FORM{'CREATEROUTINE'} $FORM{'CREATETEMPORARYTABLES'} $FORM{'CREATE'} $FORM{'DELETE'} $FORM{'DROP'} $FORM{'SELECT'} $FORM{'INSERT'} $FORM{'UPDATE'} $FORM{'REFERENCES'} $FORM{'INDEX'} $FORM{'LOCKTABLES'} $FORM{'ALL'})"> 
    Note, the last parameter is generally just "ALL" (without quotes). These are actual words, not 1/0 binary options. If you want to apply specific privileges, let me know.

    Edit a database user by re-adding an existing user.

    Here's the raw API1 code for extracting a file as if it was done in File manager:

    Code:
    <cpanel Fileman="extractfile($FORM{'dir'},$FORM{'file'})">
    Uploading files isn't as straightforward. You can look at the HTML and API code of /usr/local/cpanel/base/frontend/x3/files/doupload.html and upload.html to determine how cPanel handles such functions.
     
    #2 cPanelDavidG, Mar 30, 2009
    Last edited: Jun 4, 2009
  3. weblizzer

    weblizzer Registered

    Joined:
    Mar 29, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    hi david i really thank you for your inputs, i'm trying to find the api1 docs but i can't see on the site, or can you please try to give the url for api docs so that i'll know how i can create such functions that want to....
     
  4. 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
    The documentation for API1 and API2 is still very much a work in progress:

    http://www.cpanel.net/plugins/api2/index.html

    To find the API functions you need yourself, simply look at the code for our x3 theme located at /usr/local/cpanel/base/frontend/x3. The x3 theme is coded in HTML, JavaScript (including the YUI libraries), CSS and our APIs.
     
  5. weblizzer

    weblizzer Registered

    Joined:
    Mar 29, 2009
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    thanks a lot for your time, i really appreciate your effort... I already see the stuff under api2 and think there a lot of functions which are not yet documented, such like those functions that you just input i didn't see them on the documentation i guess the documentation is for the api2 but i didn't see the api doc... but i'm looking forward for it.

    Unfortunately i don't have access from the root server, any idea how i can navigate that x3 themes having a shared hosting account thanks? :):):):)
     
  6. 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
    With only a shared hosting account, you will not be able to navigate to those folders on the server to view the API calls yourself. So feel welcome to post to the forums or email sales@cpanel.net (with ATTN: DavidG) if you need any API calls.

    Typically anything that can be done via the cPanel interface can be done via the APIs. However, some things are trickier to do with our APIs (e.g. file uploads) and may be best left to other supported methods (e.g. FTP upload). The behavior of the APIs typically mirrors the behavior of the cPanel interface as well.
     
Loading...

Share This Page