PDA

View Full Version : DA API Error



andrew971218
06-19-2010, 05:36 AM
Here's my script of CMD_API_ACCOUNT_USER:
<?
/**
* Acccreate.php
*
* This is the Admin Center page. Only administrators
* are allowed to view this page. This page displays the
* database table of users and banned users. Admins can
* choose to delete specific users, delete inactive users,
* ban users, update user levels, etc.
*
* Written by: andrew971218
* All rights Reserved.
*/
include("../include/session.php");
/**
* User not an administrator, redirect to main page
* automatically.
*/
if(!$session->isAdmin()){
header("Location: ../main.php");
}
else{
/**
* Administrator is viewing page, so display all
* forms.
*/
?>
<html>
<head>
<title>New Hosting Account Create</title>
<body>
<center><h3>New Hosting Account Create</h3>
<?

$server_ip="66.154.118.133";
$server_login="XXXXXXX";
$server_pass="XXXXXXX";
$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);

$query = array('/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'
));

$this->$sock->query('/CMD_API_ACCOUNT_USER', $query);
$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;
}

?>


<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>
<?}?>

But When I use it, it shows

Fatal error: Class 'HTTPSocket' not found in /home/andrew9712/domains/mhhk.tk/public_html/admin/acccreate.php on line 53

Where's the problem:confused:

andrew971218
06-20-2010, 07:03 PM
Please help me!

scsi
06-21-2010, 07:50 AM
You need an include to the class file.

localhost
06-21-2010, 03:37 PM
Well the script is trying to load a class that is not defined:



$sock = new HTTPSocket;


I think you either must include the php file where there is something like


class HTTPSocket {
... }

or you can just add the missing class in this script.

ranz
06-21-2010, 05:23 PM
You need to call the class like:


include('httpsocket.php');


I wrote a script that calls the API (might help you in code) look here:

http://www.directadmin.com/forum/showpost.php?p=179058&postcount=2

You get the httpsocket.php file from here:

http://files.directadmin.com/service...httpsocket.php