Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- $config_inside = true;
- require("config.php");
- require("httpsocket.php");
- class DirectAdminAPI
- {
- private $sock;
- private $conf;
- public function __construct ($aConfiguration)
- {
- $this->conf = $aConfiguration;
- }
- private function CreateConnection()
- {
- $this->sock = new HTTPSocket;
- if ($this->conf["secure"] == true)
- $this->sock->connect("ssl://". $this->conf["host"], $this->conf["port"]);
- else
- $this->sock->connect($this->conf["host"], $this->conf["port"]);
- $this->sock->set_login($this->conf["username"],$this->conf["password"]);
- echo "CreateConnection<br />\n";
- }
- public function CreateUser($username, $email, $pass, $domain, $package)
- {
- $this->CreateConnection();
- $this->sock->query('/CMD_API_ACCOUNT_USER',
- array(
- 'action' => 'create',
- 'add' => 'Submit',
- 'username' => $username,
- 'email' => $email,
- 'passwd' => $pass,
- 'passwd2' => $pass,
- 'domain' => $domain,
- 'package' => $package,
- 'ip' => $this->conf["host"],
- 'notify' => 'yes'
- )
- );
- $result = $this->sock->fetch_parsed_body();
- //echo "ERROR-". $resultt["error"] ."-"; // debug
- if ($result["error"] != "0")
- {
- echo "<b>Error Creating user ". $username ." on server ". $da_host .":<br />\n";
- echo $result["text"]."<br />\n";
- echo $result["details"]."<br /></b>\n";
- }
- else
- echo "User ". $username ." created on server ". $da_host ."<br />\n";
- echo "CreateUser<br />\n";
- //echo $this->var;
- }
- }
- $wocket = new DirectAdminAPI($da); // $da is defined in config.php
- $username = "pizza";
- $pass = "y8eSEqBl";
- $email = "blah@onetwo.nl";
- $domain = "fourfive.nl";
- $package = "Unlimited";
- $wocket->CreateUser($username, $email, $pass, $domain, $package);
- echo "<b>Done?</b>";
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement