Return to Snippet

Revision: 20064
at November 5, 2009 21:30 by shaunjanssens

Initial Code



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);
  $sock->connect($server_ip, 2222);
  '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";
  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>

Initial URL

Initial Description
Do not use this php file exactly as it is. 
It's only to demonstrate the basics of the api.
You *must* do form checking to ensure safe values are passed.
Also, it's a really bad and very insecure practice to put a form like this publicly on your website for anyone to use.
If you do, you'll end up with a server full users you did not create (this script creates accounts without any involvment with an admin: bad)

Initial Title
DirectAdmin API sample script

Initial Tags
script, api

Initial Language