#1 (permalink)  
Old 06-20-2009, 11:24 AM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Create and delete ftp account and subdomains

Hello,

I would try to create and delete ftp accounts and subdomains throught the API.

Create in the same time and delete ine the same time all in PHP.

I read the documentation but it is not very clear

I try to check the mybrandedhost.com website, but it seems doesn't work.

Have you got any little code snippets to make this ? (API1 or API2 never mind !)

Thank you,
Have a nice day.

Last edited by nazoreen; 06-22-2009 at 05:31 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 06-22-2009, 11:38 AM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Thank you,

But how to connect, request (input) and get response (output) throught PHP ?

The documentation is not clear, it could be better have something like this :

Chapter 1 : getting start
1.1 Perl
1.1.0 Connection
1.1.1 Input
1.1.2 Output
1.1.3 Available functions (list)

1.2 PHP
1.2.0 Connection
1.2.1 Input
1.2.2 Output
1.2.3 Available functions (list)

With an example for each of paragraph. It is very easy to make this, and it will be better for developper to find informations.

Have a nice day.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 06-22-2009, 12:00 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by nazoreen View Post
Thank you,

But how to connect, request (input) and get response (output) throught PHP ?

The documentation is not clear, it could be better have something like this :

Chapter 1 : getting start
1.1 Perl
1.1.0 Connection
1.1.1 Input
1.1.2 Output
1.1.3 Available functions (list)

1.2 PHP
1.2.0 Connection
1.2.1 Input
1.2.2 Output
1.2.3 Available functions (list)

With an example for each of paragraph. It is very easy to make this, and it will be better for developper to find informations.

Have a nice day.
The API receives a URL and outputs information in XML. Hence our documentation references XML rather than any specific language that can be used to process XML.

If you're looking for an easy to use interface to the XML API, I recommend using Matt's PHP 5 Class: XMLAPI php class
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 06-22-2009, 01:13 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Well addftp is OK.
But delftp delete the public_html folder

This is because developpers must have a clear documentation with every command and variables (required and optionals) !!! We can't guess.

Actually I didn't find documentation on your website for addftp, delftp, addsubdomain and delsubdomain ! I tried using your search engine and tried using Google.

I think it is not very serious !

This is the minimum we need.

How to list all functions (and args) for cPanel ?

Thank you,
Have a nice day.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 06-22-2009, 01:19 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Well I understood why delftp removed public_html folder, this is because I chose / as homedir.

But where is the information about this ?

It is not a problem because I used a demo domain, but developpers need this information.

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 06-22-2009, 01:56 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Well addsubdomain is OK but there is something "bizarre" !

The $FORM{'dir'} accept all these type of variable :
/test
public_html/test
/public_html/test

And all types create the subdomain http://test.domain.ext

May be it could be interesting to restrict to /test variable only to prevent errors in the future.

Actually I don't know exactly how to implement :
Code:
<?cp SubDomain::delsubdomain(% %,result,reason) domain=$FORM{'domain'} ?>
in PHP

I don't understand exactly what are %, result and reason... is there sentences ?

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 06-22-2009, 02:16 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Just to report a broken link or no content link at this page :
ApiTwo < AllDocumentation/AutomationIntegration < TWiki

The chapter : Subdomains

The link : Api2DeleteSubdomain < AllDocumentation/AutomationIntegration < TWiki

It redirect to Cpanel::StatsBar::stat page.

Thank you.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 06-22-2009, 02:18 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Below the xmlin variable for Cpanel::SubDomain::delsubdomain I try to make :
Code:
<cpanelaction><module>SubDomain</module><func>delsubdomain</func><apiversion>2</apiversion><args>...</args></cpanelaction>
Could you tell me which args i must insert (with little example), please ?

Thank you,
Have a nice day.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 06-22-2009, 02:52 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by nazoreen View Post
Well addftp is OK.
But delftp delete the public_html folder

This is because developpers must have a clear documentation with every command and variables (required and optionals) !!! We can't guess.

Actually I didn't find documentation on your website for addftp, delftp, addsubdomain and delsubdomain ! I tried using your search engine and tried using Google.

I think it is not very serious !

This is the minimum we need.

How to list all functions (and args) for cPanel ?

Thank you,
Have a nice day.
We are currently in the process of finalizing documentation for API1 and API2. In the meantime, you can look at the source code of the X3 theme to find the functions (and their arguments). The X3 theme source can be found at /usr/local/cpanel/base/frontend/x3/

For example, look at /usr/local/cpanel/base/frontend/x3/ftp/realdodelftp.html to see how to delete a FTP account:

Code:
<cpanel Ftp="delftp($FORM{'login'},$FORM{'destroy'})">
The first parameter is the FTP login and the second parameter is 1 if you want to destroy (delete) the folder associated with that FTP login upon deleting the account.

If you are uncomfortable looking through the source code, let me know and I'll gladly provide you with the functions and arguments to make up for our lack of documentation at this time.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 06-22-2009, 03:05 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by nazoreen View Post
Well addsubdomain is OK but there is something "bizarre" !

The $FORM{'dir'} accept all these type of variable :
/test
public_html/test
/public_html/test

And all types create the subdomain http://test.domain.ext

May be it could be interesting to restrict to /test variable only to prevent errors in the future.

Actually I don't know exactly how to implement :
Code:
<?cp SubDomain::delsubdomain(% %,result,reason) domain=$FORM{'domain'} ?>
in PHP

I don't understand exactly what are %, result and reason... is there sentences ?

Thank you.
Yeah, that's mostly for output. API2 syntax can get rather confusing. You can review my reference slides for API2 beginning on slide 23 of this presentation from our 2007 cPanel Conference:

http://twiki.cpanel.net/twiki/pub/Al...ing_cPanel.pdf

For the function you pasted, there would only be 1 input parameter, and it would be named domain. In API2, parameters are named. In API1, they're just passed in sequence. This means API2 can have more flexibility regarding required and optional parameters.

As for your dir parameter, I'm not understanding what you see so abnormal about that. Perhaps I am overlooking something? That parameter can take in any folder within a user's home directory, and the name doesn't need to match the name of the subdomain (e.g. test.example.com could just serve content from ~/example).
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 06-22-2009, 03:05 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by nazoreen View Post
Below the xmlin variable for Cpanel::SubDomain::delsubdomain I try to make :
Code:
<cpanelaction><module>SubDomain</module><func>delsubdomain</func><apiversion>2</apiversion><args>...</args></cpanelaction>
Could you tell me which args i must insert (with little example), please ?

Thank you,
Have a nice day.
You are very close... here's what I would use if I was removing subdomain.example.com from my account:

Code:
<cpanelaction><module>SubDomain</module><func>delsubdomain</func><apiversion>2</apiversion><args><domain>subdomain.example.com</domain></args></cpanelaction>
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 06-22-2009, 03:06 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by nazoreen View Post
Just to report a broken link or no content link at this page :
ApiTwo < AllDocumentation/AutomationIntegration < TWiki

The chapter : Subdomains

The link : Api2DeleteSubdomain < AllDocumentation/AutomationIntegration < TWiki

It redirect to Cpanel::StatsBar::stat page.

Thank you.
Thanks for bringing that to my attention. I've had our documentation team fix that link and they are auditing that section of our documentation site to see if there are any other incorrect links.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 06-22-2009, 04:28 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Quote:
Originally Posted by cPanelDavidG View Post
You are very close... here's what I would use if I was removing subdomain.example.com from my account:

Code:
<cpanelaction><module>SubDomain</module><func>delsubdomain</func><apiversion>2</apiversion><args><domain>subdomain.example.com</domain></args></cpanelaction>
Thank you but isn't it subdomain_example.com instead of subdomain.example.com ?

Have a nice day.

I will look on the server at /usr/local/cpanel/base/frontend/x3/ for others functions

Byebye
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 06-22-2009, 05:25 PM
Registered User
 
Join Date: May 2003
Posts: 34
nazoreen
Thank you davidbon and cPanelDavidG,

Below the "work fine" code I made :

Code:
<?php
$conn = array ( 'host' => '127.0.0.1'
              , 'port' => '2083'
              , 'user' => 'cpanel_user'
              , 'pass' => 'cpanel_pass'
              ) ;

function cpanel_api ( $conn , $type , $user , $pass , $domain )
{
 if ( $conn [ 'port' ] == '2087' || $conn [ 'port' ] == '2083' || $conn [ 'port' ] == '443' )
 {
 	$site = 'https://' . $conn [ 'host' ] . ':' . $conn [ 'port' ] ;
 } else {
 	$site = 'http://' . $conn [ 'host' ] . ':' . $conn [ 'port' ] ;
 }
 
 switch ( $type )
 {
 	case 'add_ftp' :
 	 $xmlin = '<cpanelaction><module>Ftp</module><func>addftp</func><apiversion>1</apiversion><args>' . $user . '</args><args>' . $pass . '</args><args>/' . $user . '</args><args>20</args></cpanelaction>' ;
 	 break ;
 	 
 	case 'del_ftp' :
 	 $xmlin = '<cpanelaction><module>Ftp</module><func>delftp</func><apiversion>1</apiversion><args>' . $user . '</args><args>1</args></cpanelaction>' ;
 	 break ;
 	 
 	case 'add_subdomain' :
 	 $xmlin = '<cpanelaction><module>SubDomain</module><func>addsubdomain</func><apiversion>1</apiversion><args>' . $user . '</args><args>' . $domain . '</args><args>0</args><args>0</args><args>/' . $user . '</args></cpanelaction>' ;
 	 break ;
 	 
 	case 'del_subdomain' :
 	 $xmlin = '<cpanelaction><module>SubDomain</module><func>delsubdomain</func><apiversion>2</apiversion><args><domain>' . $user . $domain . '</domain></args></cpanelaction>' ;
 	 break ;
 	 
 	default :
 	 echo 'Type error' ;
 }
 
 if ( $type == 'add_ftp' || $type == 'del_ftp' || $type == 'add_subdomain' || $type == 'del_subdomain' )
 {
  $query = '/xml-api/cpanel?user=' . $conn [ 'user' ] . '&xmlin=' . $xmlin ;
  
  $curl = curl_init ( ) ;
  curl_setopt ( $curl, CURLOPT_SSL_VERIFYPEER , 0 ) ;
  curl_setopt ( $curl, CURLOPT_RETURNTRANSFER , 1 ) ;
  curl_setopt ( $curl, CURLOPT_SSL_VERIFYHOST , 0 ) ;
  curl_setopt ( $curl, CURLOPT_USERPWD        , $conn [ 'user' ] . ':' . $conn [ 'pass' ] ) ;
  curl_setopt ( $curl, CURLOPT_HEADER         , 0 ) ;
  curl_setopt ( $curl, CURLOPT_URL            , $site . $query ) ;
  $result = curl_exec ( $curl ) ;
  curl_close ( $curl ) ;
 }
}

/***** ADD Subdomain and FTP Account *****/
cpanel_api ( $conn , 'add_subdomain' , 'test' , '0123456789' , '.domain.com' ) ;
cpanel_api ( $conn , 'add_ftp'       , 'test' , '0123456789' , '.domain.com' ) ;

/***** DEL Subdomain and FTP Account *****/
//cpanel_api ( $conn , 'del_subdomain' , 'test' , '0123456789' , '.domain.com' ) ;
//cpanel_api ( $conn , 'del_ftp'       , 'test' , '0123456789' , '.domain.com' ) ;
?>
Don't forget to use in your php.ini :
allow_url_fopen = On

Have a nice day !

Last edited by nazoreen; 06-22-2009 at 05:29 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #15 (permalink)  
Old 06-22-2009, 05:26 PM
cPanelDavidG's Avatar
cPanel Technical Sales
 
Join Date: Nov 2006
Location: Houston, TX
Posts: 7,995
cPanelDavidG is on a distinguished road
Quote:
Originally Posted by nazoreen View Post
Thank you but isn't it subdomain_example.com instead of subdomain.example.com ?

Have a nice day.

I will look on the server at /usr/local/cpanel/base/frontend/x3/ for others functions

Byebye
You are correct, I always forget that .
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Can create, but not delete account?! mstuebner Developer Discussions 6 01-08-2009 02:49 PM
FTP - No delete account? Boriskag cPanel and WHM Discussions 2 09-26-2007 03:37 PM
Can I Create FTP Without Delete Permission? aryapsh cPanel and WHM Discussions 1 08-07-2007 01:01 PM
I Can´t Create ou delete account audisat cPanel and WHM Discussions 8 06-09-2007 12:48 AM
script to create subdomains and ftp account theBassTender cPanel and WHM Discussions 3 08-04-2005 09:48 PM


All times are GMT -5. The time now is 05:09 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© cPanel Inc