在Cpanel中创建FTP帐户 - 没有域

时间:2012-01-17 00:37:12

标签: php ftp cpanel whm

我一直在使用此脚本非常成功地创建FTP帐户

// your cPanel username
$cpanel_user = 'usernam';

// your cPanel password
$cpanel_pass = 'password';

// your cPanel skin
$cpanel_skin = 'x3';

// your cPanel domain
$cpanel_host = 'domain.com';

// ftp username
$ftp_user = 'user';

 // ftp password
$ftp_pass = 'ftp_password';

// ftp home directory
$ftp_home = 'home';

// ftp quota
$ftp_quota = '0';

// create the ftp account
$request = "http://{$cpanel_user}:{$cpanel_pass}@{$cpanel_host}:2082";
$request .= "/frontend/{$cpanel_skin}/ftp/doaddftp.html";
$request .= "?login={$ftp_user}";
$request .= "&password={$ftp_pass}";
$request .= "&homedir=public_html/{$ftp_user}";
//$request .= "a={$ftp_quota}";
$result = file_get_contents($request);
echo $result;
?> 

但是这假设我有域指向托管。我想让这个脚本与一个尚未指向域的域一起工作。

示例:http://123.456.78.910~user/

这有意义吗?

2 个答案:

答案 0 :(得分:0)

如果您打开该IP地址和cPanel端口,则可以使用任何用户帐户登录。因此,现在只需在$cpanel_host而不是域中设置IP地址。它会创建它,因为您可以访问cPanel(跟随您的示例IP)http://123.456.78.910:2082,并且您可以登录,就像通过域本身一样。

答案 1 :(得分:0)

尝试并经过测试......

您需要输入变量

$cpaneluser = Your cpanel username
$cpanelpass = Your cpanel password
$domain = your domain name ( xyz.com )
$fuser = ftp username
$fpass = ftp password
$homedir = ftp directory 

$url = "http://$cpaneluser:$cpanelpass@$domain:2082/json-api/cpanel?";
$url .= "cpanel_jsonapi_version=2&cpanel_jsonapi_module=Ftp&cpanel_jsonapi_func=addftp&";
$url .= "user=$fuser&pass=$fpass&homedir=$fhomedir&quota=0";

var_dump($url);
$result = @file_get_contents($url);
if ($result === FALSE) 
die("ERROR: FTP Account not created. Please make sure you passed correct parameters.");
echo $result;
希望它有所帮助..