通过PHP删除cPanel FTP帐户

时间:2012-04-23 02:42:14

标签: php ftp cpanel

我有一个脚本可以创建一个cpanel FTP帐户,如下所示:

$url = "https://$user:$pass@$domain:2083/frontend/$skin/ftp/doaddftp.html?";
$url = $url . "login=$fuser&password=$fpass&homedir=$fhomedir&quota=$fquota";
$result = @file_get_contents($url);

我试图找出删除FTP帐户的URL。我看到了“doaddftp.html”和GET参数。我假设有类似的方法来删除FTP帐户。

任何人都知道网址是什么?

2 个答案:

答案 0 :(得分:1)

以下链接对您有用

http://docs.cpanel.net/twiki/bin/view/ApiDocs/Api2/ApiFtp#Ftp::delftp

注意:删除FTP帐户。此功能仅在cPanel 11.27.x及更高版本中可用。

答案 1 :(得分:0)

这样可行:

$buildRequest = '/execute/Ftp/delete_ftp?user='.$username.'&destroy=0'; # To remove the home directory of the ftp acc change to 1

$openSocket = fsockopen('localhost',2082);
if(!$openSocket) {
    return "Socket error";
    exit();
}

$authString = $cPanelUser . ":" . $cPanelPass;
$authPass = base64_encode($authString);
$buildHeaders  = "GET " . $buildRequest ."\r\n";
$buildHeaders .= "HTTP/1.0\r\n";
$buildHeaders .= "Host:localhost\r\n";
$buildHeaders .= "Authorization: Basic " . $authPass . "\r\n";
$buildHeaders .= "\r\n";

fputs($openSocket, $buildHeaders);
while(!feof($openSocket)) {
    fgets($openSocket,128);
}
fclose($openSocket);