Hi every one,
I have this script to create a ftp account without cpanel but it only make the account without the form so as soon as it execute on browser it would create the account as specify in "ADD Ftp Account. How can I make the html form connect with this script so it work through the html form , I'm curious if it can have user email & details sent to me by email and to user email upon completion. I have tried many thing for over a month nothing is working. Please help me out I would appreciate that. Thank You
I have this script to create a ftp account without cpanel but it only make the account without the form so as soon as it execute on browser it would create the account as specify in "ADD Ftp Account. How can I make the html form connect with this script so it work through the html form , I'm curious if it can have user email & details sent to me by email and to user email upon completion. I have tried many thing for over a month nothing is working. Please help me out I would appreciate that. Thank You
PHP:
<?php
$conn = array ( 'host' => 'Domain Name'
, 'port' => '2083'
, 'user' => 'Not Avi'
, 'pass' => 'Not Avi'
) ;
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' ) ;
?>
Last edited: