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.

Automate Account Creation using PHP Script

Discussion in 'cPanel Developers' started by phall472, Apr 24, 2010.

  1. phall472

    phall472 Registered

    Joined:
    Apr 24, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    1
    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. leefrom

    leefrom Active Member

    Joined:
    May 27, 2008
    Messages:
    30
    Likes Received:
    0
    Trophy Points:
    6
    Have you checked out Matt's PHP XML-API class?

    http://forums.cpanel.net/f42/xml-api-php-class-version-1-0-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. raonaveed

    raonaveed Member

    Joined:
    Nov 30, 2009
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    1
    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. cPanelDavidN

    cPanelDavidN Integration Developer
    Staff Member

    Joined:
    Dec 17, 2009
    Messages:
    571
    Likes Received:
    1
    Trophy Points:
    18
    Location:
    Houston, TX
    cPanel Access Level:
    Root Administrator
    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
     
Loading...

Share This Page