Community Forums
Connect with us on LinkedIn
+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    2

    Default Automate Account Creation using PHP Script

    Hello

    I'm new to programming WHM/cPanel but I'm an experienced PHP programmer.

    I need help to find the pages that explains how to write a PHP script to automate account creation.

    I have a reseller account and will be setting up individual web hosting accounts for clients who sign up online.

    My WHM/cPanel version is:
    cPanel 11.25.0-S43473 - WHM 11.25.0 - X 3.9
    CENTOS 5.4 x86_64 standard

    Thank you helping in advance.

  2. #2
    Member
    Join Date
    May 2008
    Posts
    30

    Default

    Have you checked out Matt's PHP XML-API class?

    http://forums.cpanel.net/f42/xml-api...-a-136449.html

    Basically XML-API is the principle way to talking to cpanel programmatically.

    The PHP XML-API class is a pre-packaged way of accessing it via PHP.

    General documentation on xml-api here:

    XML and JSON APIs

    You'll use the main xml-api to do root level things like account creation.

    You'll access API1 and API2 calls as the cpanel user for everything else, such as automating creation of email accounts, ftp accounts, webdisk, etc. etc.

  3. #3
    Member
    Join Date
    Nov 2009
    Posts
    13

    Default Issue in WHM Plugins Creations

    If i want to create a plugin which allow the root or reseller to create Cpanel or Reseller accounts or any other operations than how its going to be done?The following questions in mind.

    1. All codes that cpanel provide is for Remote Integration or Development.
    2. If a file is localy hosted inside server than why should i provide username/password or hash key?
    3. How files are inside system already can a reseller create account at server using that plugin?
    4. Any Cron Job example available which can create accounts or can run any commands that we want to run using plugins but choice again i don't want to give or configure plugin with Hashkey or username and password.
    5. I have also noticed that if reseller access the plugin he can't access php files why?Isn't cpanel programing issue?

    Do you have any solution?

  4. #4
    Integration Developer cPanelDavidN's Avatar
    Join Date
    Dec 2009
    Location
    Houston, TX
    Posts
    525

    Default

    Raonaveed,

    I'm not sure I entirely understand you dilemmas, but I will try to answer the questions you have posed:

    1)Why is all code for cPanel designed for remote integration or development?
    A) We provide may ways to develop and extend cPanel's and WHM's functionality. You can develop custom plugins for WHM or cPanel. As well you can write your own standalone software that talks with cPanel and WHM. Both the plugins and remote standalone code that YOU develop can use our API1 and API2 and XML-API. It depends on what functionality you need as to which API calls are necessary. We do not develop custom code, but instead give developers the tools necessary to extend WHM/cPanel for system administrators and end users

    2) file is on host, why does it need username/password or hash?
    A) Anyone familiar with web host environments will know that many people share the same physical server. Sometimes, the entire server environment is virtualized. Just because you can read a file on the file system doesn't mean you have privilege to execute it or even do anything related to the file's contents. This is basic Unix file system, sub-system, and administration, and applies unilaterally to web hosting environments like WHM/cPanel. If you're using the web interface, it is doubly important to assure access integrity.

    3)I'm very confused by this question, but I think you're asking: If a plugin for account creation is made, how do I give a reseller access to use that plugin?
    A) WHM plugins must be coded to use access control. This is explained in the documentation: CreatingWhmPlugins < AllDocumentation/AutomationIntegration < TWiki . If you have more question about ACL in WHM Plugins, I suggest starting a new thread to discuss it.

    4)How do you make a Cron job that will use the custom plugin, specifically without the hash or root credentials.
    A) If you need a Cron job to create an account, you can do that in much more direct ways that writing a custom plugin and trying to execute it. '/scripts/wwwacct' is a system script that you can use to create accounts. I would consider writing a shell script that performs this command, with the necessary information, and schedule that shell script in Cron. You will not need root credentials if you schedule that for the root crontab. Also, if ever need to perform an action via a remote request, but it's actually a request to the local system and you need to pass root credentials, all you have to do is read the file that contains the root hash, '/root/.accesshash'. You're automated script would need to be running as root, of course, to have read access to '.accesshash'.

    5)A custom plugin, that is accessible by the reseller, can not perform PHP code?
    A) This depends on a couple of things. All WHM and cPanel code gets executes in a particular way and sometimes with certain restrictions. You cannot tell WHM to execute arbitrary code. If you have a particular example of what you're trying to do, we can help. Please post it, otherwise it's a vague question with much to talk about.

    Regards,
    -David
    David Neimeyer
    Integration Developer

    sdk.cpanel.net
    APIs: XML-API API1 & API2
    Check Out: Developer Downloads Integration Blog
    Need Support? Support Ticket Developer Forum Feature Request

Similar Threads & Tags
Similar threads

  1. Postwwwacct script: automate on account creation
    By cPanelDavidN in forum cPanel Developers
    Replies: 0
    Last Post: 05-29-2010, 07:03 PM
  2. Automate account creation
    By EstebanC in forum cPanel and WHM Discussions
    Replies: 0
    Last Post: 03-16-2008, 04:07 AM
  3. Need to automate creation of 400+ account
    By dochallam in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 06-08-2007, 10:37 AM
  4. How to automate new email account creation?
    By dinosm in forum cPanel and WHM Discussions
    Replies: 1
    Last Post: 07-22-2004, 04:59 PM
  5. Automating Account Creation: Shell Script? PHP Script?
    By RangerWest in forum cPanel and WHM Discussions
    Replies: 2
    Last Post: 07-13-2003, 09:24 AM
Linkedin       Facebook       Twitter       RSS       Flickr       YouTube