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.

Few Commands Needed

Discussion in 'cPanel Developers' started by fanfavorite, Jan 8, 2009.

  1. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    I have been using the XML-API for a while now, calling API2 and API1 commands where needed. I have searched the web and found what I could, but couldn't find anything for the following:

    1) listforwards/listmxs - You have to list by domain it seems, is there a way to get by cpanel account? The reason is I want all parked domains to be listed as well. I guess I could call the function for every parked domain, but just checking to see if this can be done with 1 call.

    2) What functions add and edit cron jobs?

    3) Is there any API functions for Spam Assassin?

    4) Is there any way to link to phpMyAdmin directly?

    5) Is there a way to get the arguments of calls to be thrown out? I can figure out the functions, but the arguments are not always as easy.

    Any help is appreciated.

    Thanks!

    -JC
     
  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
    For listforwards and listmxs, if domain is an empty string, it will list all forwarders for that account.

    Refer to the following thread for comprehensive information on this: http://forums.cpanel.net/showthread.php?t=103661

    Yes, just check out the x3 source for the Spam Assassin functionality (in /usr/local/cpanel/base/frontend/x3/mail/spam). Was there any specific API call you were looking for?

    Not via the APIs. Though sometimes people just link directly to pages within the cPanel interface (e.g. https://SERVER:2083/frontend/x3/sql/PhpMyAdmin.html). Alternatively, you could install your own installation of phpMyAdmin that you can control logins to accordingly.


    The easiest trick to this is look at the source of the x3 themed page that is calling this function. However, the API2 calls can get rather complex so if you need help with determining the parameters to be passed to a function, just let me know.
     
  3. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    I had tried this with no success before, but realized after your post that you leave out the domain arg in the call like:

    $this->connect("/xml-api/cpanel?user=$user&xmlin=<cpanelaction><module>Email</module><func>listforwards</func></cpanelaction>");

    Thanks, will check it out.

    Well not sure really. Want to allow clients to enable/disable for sure. Might not go more than that. I don't have root access so can't see the source code of the cpanel. I guess it may be best to download a trial until we switch to a dedicated server.

    I don't mind linking directly, but want to auto log them in, so I can make my own logins. Can I pass POST vars to that URL? If so, I could use cURL to hide the login info. If I installed a separate version of phpMyAdmin, would I have to set it up for every client I add through whm?

    I have no problem going through source code, just need to get the source code, as we are on a reseller server and not a dedicated one for now.

    Thanks for the help David!
     
  4. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Hey David,

    Here are some of the commands I need to clarify whether they are correct and what version (API1 or API2) they are and what the args are.

    CPanel::Email::delforward - Delete Email Forward
    CPanel::Email::deldomainforwards - Delete Email Domain Forward
    CPanel::Email::addmxs - Add MX Records
    CPanel::Email::delmxs - Delete MX Records
    CPanel::AddonDomain::listaddondomains - List add on domains
    CPanel::SubDomain::addsubdomain - Add SubDomains
    CPanel::Park::addparkeddomain - Add Parked Domain - FOUND - <module>Park</module><func>park</func><apiversion>1</apiversion><args>$domain</args>
    CPanel::Park::delparkeddomain - Delete Parked Domain

    Those should be most, if not all the ones I can't figure out (without source code). I went to download a trial and it wants me to register ip's and such. I don't plan on installing it on a server, just want to see the source code to figure out commands such as above. Is there another way I could see the code?

    Anyways, any help is appreciated.

    Thanks!
     
    #4 fanfavorite, Jan 9, 2009
    Last edited: Jan 9, 2009
  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

    API1:
    Code:
    <cpanel Email="delforward(email)">

    API1:
    Code:
    <cpanel Email="deldforward(domain)">
    API1:
    Code:
    <cpanel Email="changemx(domain,mx,priority,alwaysaccept)">
    The parameters for that function line up with the columns displayed on the MX Entry Maintenance Page in the cPanel interface.

    API1:
    Code:
    <cpanel Email="delmx(domain,mx,priority)">

    API2:
    Code:
    <?cp Park::listaddondomains() ?>
    This function does have optional parameters, but if you're just looking for a list of addon domains for an account, this will work.

    API1:
    Code:
    <cpanel SubDomain="addsubdomain(domain,rootdomain,0,0,dir)">
    domain is the subdomain (e.g. subdomain1 in subdomain1.example.com)

    rootdomain is the domain (e.g. example.com in subdomain1.example.com)

    dir is the relative path from ~ where files for this subdomain are to be stored

    API1:
    Code:
    <cpanel Park="unpark(domain)">
     
  6. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Awesome thanks David!

    I am having some trouble with Cpanel::SubDomain::delsubdomain. When I pass in a parked domain subdomain, it adds my main domain to the end of it.

    For example:

    cname.parkeddomain.com is passed, but error is:

    [reason] => cname.parkeddomain.com.mymaindomain.com not found in httpd.conf.
    Bind reloading on armada using rndc zone: [mymaindomain.com]
    The subdomain, cname.parkeddomain.com.mymaindomain.com has been removed.

    If cname.mymaindomain.com is passed, it deletes just fine. How do I get around this?
     
  7. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    I am also having trouble with <cpanel Email="delforward(email)">

    Doesn't delete anything or give me any results or errors in the data field.

    /xml-api/cpanel?user=$user&xmlin=<cpanelaction><module>Email</module><func>delforward</func><apiversion>1</apiversion><args>$email</args></cpanelaction>

    SimpleXMLElement Object (
    [module] => Email
    [func] => delforward
    [type] => event
    [source] => internal
    [apiversion] => 1
    [data] => SimpleXMLElement Object(
    [result] => SimpleXMLElement Object(
    )

    )

    )
     
  8. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Few other things:

    /xml-api/cpanel?user=$user&xmlin=<cpanelaction><module>Email</module>
    <func>setdefaultaddress</func><args><fwdemail>$email</fwdemail>
    <failmsgs>$failmsg</failmsgs><fwdopt>$fwdopt</fwdopt>
    <domain>$domain</domain></args></cpanelaction>

    If $fwdopt is "fwd" it works fine, but if $fwdopt is "fail" it only works if $failmsg is blank. Not sure why. Any ideas?

    Also, I am looking for two more functions:

    - clear spambox
    - add domain forward

    Thanks.
     
    #8 fanfavorite, Jan 12, 2009
    Last edited: Jan 12, 2009
  9. 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
    Thanks for pointing this out. I have been able to replicate this behavior as have my colleagues in QA. We are currently looking into this further. Internal Case 18758
     
  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
    Have you tried setting $fwdopt to :fail: instead of fail?

    To add a domain forwarder:

    Code:
    <cpanel Email="adddforward(domain,forward)">
    domain = the domain whose email to forward
    forward = the domain to forward the mail to

    Clearing the Spambox:

    Code:
    <cpanel Email="clearspambox()">
    Both of these are API1 functions.
     
  11. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Yeah I tried that and didn't work, but I was playing around more and realized that it actually was working except that if $failmsg has any spaces, it won't add.
     
  12. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    You are awesome David! Thanks for all the help so far. Just wanted to bring your attention to Cpanel::SubDomain::delsubdomain that I mentioned earlier as well, just in case you missed it between posts and the problem I have in the previous post.

    Also, I have a few other commands I am looking for:

    FTP: Change Quota
    FTP: Session Delete
    Email: Add Autoresponder

    After that, I think I have everything else running properly. Thanks David!
     
  13. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    fanfavorite: you can actually look all of these up extremely easy by looking in /usr/local/cpanel/base/frontend/x3, most of the files will contain the API calls (they are usually in a file called do<actionname>.html )

    most of the APIs calls will be there, and you should be able to get an idea of how to construct them into XML-API commands by looking at david's examples or reading http://www.cpanel.net/plugins/xmlapi/cpanel.html
     
  14. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Thanks Matt. I know about viewing source code. Problem is that I don't have root access because I am on a reseller account and don't have a Linux workstation to install cpanel.

    I know how to use XML-API's and have guessed a lot of functions. I just have been listing the ones that I can't figure out or get problems with.

    These are the last ones I need this time around if you would be so kind to list what these functions are?

    Thanks.
     
  15. 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
    FTP Change Quota:

    Code:
    <cpanel Ftp="ftpquota(acct,quota)">
    FTP Session Delete, you mean FTP Session Disconnect, because that is:

    Code:
    <cpanel Ftp="kill_ftp_session(login)">
    Creating an Autoresponder:

    Code:
    <cpanel Email="addautoresponder(email,from,subject,arbody,domain,html,charset)">
    Most of those parameters are self-explanatory. However email is just the part before @, domain being the part after the @.
     
  16. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Thanks David, your help is greatly appreciated.

    My post about "setdefaultaddress" I resolved by encoding variable for URL. I discovered the issue when testing addautoresponder. Just thought I would post that to let everyone else know if they have the issue.

    Do you know a solution to my post #6 in this thread about deleting a parked domains subdomain?
     
    #16 fanfavorite, Jan 13, 2009
    Last edited: Jan 13, 2009
  17. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    fanfavorite, in order to remove a subdomain of a parked (or addon) domain, you'll need to change how the API is called. You'll have to change the break between the subdomain and the rootdomain to a _ rather than a .

    Rather than saying this.somedomain.com you'll need to pass this_somedomain.com

    For Example:

    Code:
    READABLE XMLin: 
     <cpanelaction>
      <module>SubDomain</module>
      <func>delsubdomain</func>
      <apiversion>2</apiversion>
      <args>
        <domain>some_somedomain.com</domain>
      </args>
    </cpanelaction>
    
    
    QUERY IS: https://192.168.1.243:2087/xml-api/cpanel?user=cptest&xmlin=%3Ccpanelaction%3E%3Cmodule%3ESubDomain%3C%2Fmodule%3E%3Cfunc%3Edelsubdomain%3C%2Ffunc%3E%3Capiversion%3E2%3C%2Fapiversion%3E%3Cargs%3E%3Cdomain%3Esome_somedomain.com%3C%2Fdomain%3E%3C%2Fargs%3E%3C%2Fcpanelaction%3E
    
    RESPONSE IS: 
       <cpanelresult>
        <apiversion>2</apiversion>
        <data>
          <reason>Removed some.somedomain.com Server at line: 674.
    Removed Entry from httpd.conf
    Bind reloading on rhubarb using rndc zone: [somedomain.com]
    The subdomain, some.somedomain.com has been removed.</reason>
          <result>1</result>
        </data>
        <func>delsubdomain</func>
        <module>SubDomain</module>
      </cpanelresult>
    
     
    #17 MattDees, Jan 14, 2009
    Last edited: Jan 14, 2009
  18. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
  19. fanfavorite

    fanfavorite Active Member

    Joined:
    Jun 1, 2008
    Messages:
    28
    Likes Received:
    0
    Trophy Points:
    1
    Btw, is there a support page to view the status on internal cases? I am just curious as to how I could check up on Internal Case 18758.
     
  20. MattDees

    MattDees cPanel Product Owner
    Staff Member

    Joined:
    Apr 29, 2005
    Messages:
    417
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    Unfortunately you cannot look at the status on internal cases. At this point that case is still being reviewed by our development department to find the source of the issue. It's been a rather busy week with stable & dnsonly getting released.
     
Loading...

Share This Page