Advertisement
Guest User

Untitled

a guest
May 8th, 2017
666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.80 KB | None | 0 0
  1. <?
  2. $config_inside = true;
  3. require("config.php");
  4. require("httpsocket.php");
  5.  
  6. class DirectAdminAPI
  7. {
  8.     private $sock;
  9.     private $conf;
  10.    
  11.     public function __construct ($aConfiguration)
  12.     {
  13.         $this->conf = $aConfiguration;
  14.     }
  15.        
  16.     private function CreateConnection()
  17.     {  
  18.         $this->sock = new HTTPSocket;
  19.        
  20.         if ($this->conf["secure"] == true)
  21.             $this->sock->connect("ssl://". $this->conf["host"], $this->conf["port"]);
  22.         else
  23.             $this->sock->connect($this->conf["host"], $this->conf["port"]);
  24.         $this->sock->set_login($this->conf["username"],$this->conf["password"]);
  25.         echo "CreateConnection<br />\n";
  26.     }
  27.  
  28.     public function CreateUser($username, $email, $pass, $domain, $package)
  29.     {
  30.         $this->CreateConnection();
  31.         $this->sock->query('/CMD_API_ACCOUNT_USER',
  32.             array(
  33.                 'action' => 'create',
  34.                 'add' => 'Submit',
  35.                 'username' => $username,
  36.                 'email' => $email,
  37.                 'passwd' => $pass,
  38.                 'passwd2' => $pass,
  39.                 'domain' => $domain,
  40.                 'package' => $package,
  41.                 'ip' => $this->conf["host"],
  42.                 'notify' => 'yes'
  43.             )
  44.         );
  45.  
  46.         $result = $this->sock->fetch_parsed_body();
  47.         //echo "ERROR-". $resultt["error"] ."-"; // debug
  48.         if ($result["error"] != "0")
  49.         {
  50.             echo "<b>Error Creating user ". $username ." on server ". $da_host .":<br />\n";
  51.             echo $result["text"]."<br />\n";
  52.             echo $result["details"]."<br /></b>\n";
  53.         }
  54.         else
  55.             echo "User ". $username ." created on server ". $da_host ."<br />\n";
  56.            
  57.         echo "CreateUser<br />\n";
  58.         //echo $this->var;
  59.     }
  60. }
  61.  
  62. $wocket = new DirectAdminAPI($da); // $da is defined in config.php
  63.  
  64. $username = "pizza";
  65. $pass = "y8eSEqBl";
  66. $email = "jarno@jfdhosting.nl";
  67. $domain = "newyorkpizza.nl";
  68. $package = "Unlimited";
  69.  
  70. $wocket->CreateUser($username, $email, $pass, $domain, $package);
  71. echo "<b>Done?</b>";
  72. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement