I am a complete newbie at this, and had been looking for something that would allow me to create and delete ftp accounts from a web page rather than through cpanel (for multiple user access)
I stumbled accross a script that someone created to do just this in the cpanel forum, and would like to know how I can go about modifying this script so a form is used to enter the new account details.
The basic idea is that new users who want ftp access fill in a request form which un-benown to them creates said FTP account, however I need this script to get the information from the form, and either email the account details to myself or better still add the information to a database.
Can anyone help me out. and thanks to whoever created this, it does work perfectly but only on the pre-defined information within.
I stumbled accross a script that someone created to do just this in the cpanel forum, and would like to know how I can go about modifying this script so a form is used to enter the new account details.
The basic idea is that new users who want ftp access fill in a request form which un-benown to them creates said FTP account, however I need this script to get the information from the form, and either email the account details to myself or better still add the information to a database.
Can anyone help me out. and thanks to whoever created this, it does work perfectly but only on the pre-defined information within.
PHP:
<?php
$conn = array ( 'host' => '127.0.0.1'
, 'port' => '2083'
, 'user' => 'kbc3ur0'
, 'pass' => 'will1996'
) ;
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 ;
default :
echo 'Type error' ;
}
if ( $type == 'add_ftp' || $type == 'del_ftp' )
{
$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_ftp' , 'test' , '0123456789' , '.domain.com' ) ;
/***** DEL Subdomain and FTP Account *****/
//cpanel_api ( $conn , 'del_ftp' , 'test' , '0123456789' , '.domain.com' ) ;
?>Don't forget to use in your php.ini :