Create Add-On Domain through a script?

azz0r

Registered
Apr 22, 2008
2
0
51
Hello.

My boss has set me the task of creating a form that auto-generated an add-on domain.

What I was wondering, is there away to somehow using PHP auto generate this task?

I figured the servers using cPanel so there might be a way to trigger the behaviour in Cpanel via a PHP command.

Any help grealy appreciated :)

- Aaron
 

brianoz

Well-Known Member
Mar 13, 2004
1,146
7
168
Melbourne, Australia
cPanel Access Level
Root Administrator
One basic method is to simulate a cpanel web client by submitting to the cpanel server as if you were a web browser with a user creating addon domains.

Otherwise, you could write stuff running as root to fiddle with the configuration files, but I'm not sure which files exactly are required.
 

cPanelDavidG

Technical Product Specialist
Nov 29, 2006
11,216
12
313
Houston, TX
cPanel Access Level
Root Administrator
Hello.

My boss has set me the task of creating a form that auto-generated an add-on domain.

What I was wondering, is there away to somehow using PHP auto generate this task?

I figured the servers using cPanel so there might be a way to trigger the behaviour in Cpanel via a PHP command.

Any help grealy appreciated :)

- Aaron
I recommend calling the appropriate API to generate the add-on domain for the cPanel account. This API is actually cPanel's API2 which can be triggered via our XML-API that can be used through any language that supports XML and HTTP/S, such as PHP.

Determining the API you need to call is very easy. First, navigate to the page where you can add a domain within the X3 theme. Note the path in the URL bar starting with frontend/x3/

Now login to the server as root via SSH and navigate to /usr/local/cpanel/base/frontend/x3. The path after the frontend/x3/ in your address bar indicates the file you should look at for the source code. The source code is very easy to read (It's just cPanel API calls embedded in some CSS, HTML and Yahoo UI code.). Find the API the X3 interface calls and use that!

Instructions for using API1 and API2 calls from the XML-API can be found on our website at:

http://www.cPanel.net/plugins/xmlapi

I'll also be covering some of this in my advanced branding presentation at this year's conference if you want to come: http://conference.cpanel.net