|
|||
|
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. |
|
|||
|
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. |
|
||||
|
Quote:
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 |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
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'} ?>
I don't understand exactly what are %, result and reason... is there sentences ? Thank you. |
|
|||
|
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. |
|
|||
|
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> Thank you, Have a nice day. |
|
||||
|
Quote:
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'})">
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 |
|
||||
|
Quote:
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 |
|
||||
|
Quote:
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 |
|
||||
|
Quote:
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit |
|
|||
|
Quote:
Have a nice day. I will look on the server at /usr/local/cpanel/base/frontend/x3/ for others functions ![]() Byebye |
|
|||
|
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' ) ;
?>
allow_url_fopen = On Have a nice day ! Last edited by nazoreen; 06-22-2009 at 05:29 PM. |
|
||||
|
Quote:
.
__________________
Want our technical analysts to login to your server to assist you? You can contact our technical analysts at: http://tickets.cPanel.net/submit |
![]() |
| Thread Tools | |
| Display Modes | |
|
|
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 |