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.

Free PHP interface for cPanel API

Discussion in 'cPanel Developers' started by Patiek, Jul 16, 2006.

  1. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    I wrote this script one day for fun a few months ago and I decided to share it since I really haven't used it and I release most of my scripts under gnu gpl anyway ;)

    I honestly do not know the state of this script as I wrote / tested it to some degree a few months ago. Therefore I do not know what still works or never worked. I do know that I originally tested a bunch of the functionality. However, I do not think I tested subdomains extensively (as I found a bug or two related to subs when documenting it just now) and that makes me think other parts *may* not be tested. Remember, the script was written a few months ago so html for some parts could possibly have changed (requiring regex change) and if so just tell me.

    Originally the script was designed to be run as root so I have no idea if URLs that it access are valid for resellers as well (I would guess they are). Never tested for reseller account though (only as root). The original file is PHP 5, so I have produced both PHP 5 and PHP 4 versions, with PHP 4 version completely untested (simply has PHP 5 specific tags stripped out).

    The primary functions are as follows:
    createAccount()
    changeOwner()
    addReseller()
    setResellerLimits()
    suspendAccount()
    enableAccount()
    deleteAccount()
    getAccountList()
    getPackageList()
    getError()
    isReseller()
    isUser()
    isDomain()
    getUser()
    getPackage()
    getDomain()
    getAllDomains()
    isSubdomain()
    getSubdomains()
    getAllSubdomains()

    Most of those functions accept various arguments and I just now went through and tried to document the large majority of it. The methods are fairly well commented but I haven't gone through the code to comment any of it yet as I usually do. Again, this was original intended for private use exclusively so I didn't count on others seeing this... so feel free to point out errors. The main goal of the script was to add reseller functionality.

    If for nothing else, this script would certainly be a good start on a more developed interface to cPanel API for various people who make such requests. I attached a version / identification to it in the event I decide to develop it.

    You can find download attached. Use _PHP4 version of file if you have PHP 4.x (not tested).
     

    Attached Files:

    #1 Patiek, Jul 16, 2006
    Last edited: Jul 16, 2006
  2. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    I have updated it again (actually, this is my third time).

    Fixed a few bugs:
    PHP 4 version's constructor had a typo. Reseller usernames' included html underline and subdomains were not being correctly handled in some cases.

    I also updated the examples to be a bit better looking. If anyone encounters any errors in new version, please post them.
     
  3. -jdk-

    -jdk- Well-Known Member

    Joined:
    Aug 28, 2005
    Messages:
    63
    Likes Received:
    0
    Trophy Points:
    6
    How about a request: Multi add addon domains :) That would be a nice feature.
     
  4. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    The ability to park a domain (functionality of /scripts/prepark in WHM)?
     
  5. arshem

    arshem Member

    Joined:
    Jul 16, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Warning: Invalid argument supplied for foreach() in /home/*/public_html/order/EP_Dev_cPanel_API_PHP4.php on line 497
    Packages:

    Any way to fix that...?
     
  6. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    Make sure you are using the latest version (the BETA 3 zip file) that I updated yesterday. There were some bugs with my first two releases simply because I didn't do much testing before hand and the script was a few months old.

    I tested the beta 3 version using root on two separate servers using default WHM skin. The specific error you posted is the result of one or more of the following:
    a) Constructor not being called (fixed in beta 3).
    b) Command to API failing.
    c) regex not working when parsing accounts (non-standard or non-default WHM html perhaps).

    In other words, it is the result of fetchAccountList() failing. You should make sure commands in general are working.
     
    #6 Patiek, Jul 17, 2006
    Last edited: Jul 17, 2006
  7. arshem

    arshem Member

    Joined:
    Jul 16, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I am usin the latest one(downlaoded just not 5 mintues ago) and it's showing a Webhost Login page...am supose to addon on to cpanel(my host for some reason disabled the addons for cpanel)
     
  8. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    This script will only work with root access at the moment (because of /scripts/reslist). I will see if I can implement a secondary account parsing function. Of course reseller creation capability is not possible without root access or third party hacks / add-ons to cPanel.
     
  9. arshem

    arshem Member

    Joined:
    Jul 16, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    I can create accounts manually through WHM but for some reason they have disabled add-ons
     
  10. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    I think I posted this in the wrong forum and you are confused because of it.

    This is not an add-on. As stated in the title, it is a PHP interface for cPanel API.
     
  11. arshem

    arshem Member

    Joined:
    Jul 16, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    1
    Okay i was JUST making srue, and could i use the script if i can access WHM?i can add users and stuff so i didnt know...it does shwo all the packages but that thats all the ones on the entire server..which i would like to narrow down to just mine any suggestiosn?
     
  12. Patiek

    Patiek Active Member

    Joined:
    May 23, 2003
    Messages:
    36
    Likes Received:
    0
    Trophy Points:
    6
    I already answered that question:

     
  13. B12Org

    B12Org Well-Known Member

    Joined:
    Jul 15, 2003
    Messages:
    692
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Seattle Washington
    cPanel Access Level:
    Root Administrator
    Hi guys,

    I was wondering, how would I call these scripts from a remote machine, sort of as a publicly available web service/api.

    The reason I ask is becuase i want to use one api to connect to and manage the account through this api - one that would reside on multiple servers, and the main api would connect to the machine's whm/cpanel api accordingly.
     
Loading...

Share This Page