PHP DirectAdmin API示例脚本

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP DirectAdmin API示例脚本相关的知识,希望对你有一定的参考价值。

<?

$server_ip="11.22.33.44";
$server_login="admin";
$server_pass="yourpass";
$server_ssl="N";


$username=$_POST['username'];
$domain=$_POST['domain'];
$email=$_POST['email'];
$pass=$_POST['pass'];
$package=$_POST['package'];


if (isset($_POST['action']) && $_POST['action'] == "add")
{

echo "Creating user $username on server $ip.... <br>\n";
 
 $sock = new HTTPSocket;
 if ($server_ssl == 'Y')
 {
  $sock->connect("ssl://".$server_ip, 2222);
 }
 else
 { 
  $sock->connect($server_ip, 2222);
 }
 
 $sock->set_login($server_login,$server_pass);
 
 $sock->query('/CMD_API_ACCOUNT_USER',
     array(
  'action' => 'create',
  'add' => 'Submit',
  'username' => $username,
  'email' => $email,
  'passwd' => $pass,
  'passwd2' => $pass,
  'domain' => $domain,
  'package' => $package,
  'ip' => $server_ip,
  'notify' => 'yes'
     ));
 
 $result = $sock->fetch_parsed_body();
 
 if ($result['error'] != "0")
 {
  echo "<b>Error Creating user $username on server $server_ip:<br>\n";
  echo $result['text']."<br>\n";
  echo $result['details']."<br></b>\n";
 }
 else
 {
  echo "User $username created on server $server_ip<br>\n";
 }

 exit 0;
}

?>


<form action=? method="POST">
<input type=hidden name=action value="add">
Username: <input type=text name=username><br>
Domain:<input type=text name=domain><br>
Email: <input type=text name=email><br>
Pass: <input type=password name=pass><br>
Packge: <input type=text name=package><br>
</form>

以上是关于PHP DirectAdmin API示例脚本的主要内容,如果未能解决你的问题,请参考以下文章

PHP DirectAdmin API httpsocket.php

Directadmin CMD_API_SHOW_DOMAINS 域数组

DirectAdmin mysql连接统一游戏问题

如何在Directadmin中启用/安装PHP exif?

DirectAdmin 使用 PHP 以编程方式创建子域

DirectAdmin APIhttpsocket.php文件