PHP class for communicating with DA

Code:
        $da = new HTTPSocket;

        $da->connect('http://122.200.136.9',2222);
        $da->set_login('admin','xxxx');

        $da->query('/CMD_API_SHOW_ALL_USERS');
        $users = $da->fetch_parsed_body();
        
        print_r($users);

Try this. :)

Hi there
Thanks for you reply

I tried your example above but still get Array().

This is frustrating as i need to get the api to work for my database to talk to DA ..

Can you think of any other reason it dont work.

I also tried the example to add a user but it also dont work etc..

Any assistance appreciated
 
Code:
        $da = new HTTPSocket;

        $da->connect('122.200.136.9',2222);
        $da->set_login('admin','xxxx');

        $da->query('/CMD_API_SHOW_ALL_USERS');
        $users = $da->fetch_parsed_body();
        
        print_r($users);

Whoops, you don't need the http:// . :)
 
Code:
        $da = new HTTPSocket;

        $da->connect('122.200.136.9',2222);
        $da->set_login('admin','xxxx');

        $da->query('/CMD_API_SHOW_ALL_USERS');
        $users = $da->fetch_parsed_body();
        
        print_r($users);

Whoops, you don't need the http:// . :)

Thankyou Nivko

I knew it had to be something simple.

It good to see people willing to help.

Im sure i will have some other questions and hope many more are willing to help as you are.

Again thankyou.
 
HI
i need help
how to write the function that..
1) edit SUBDOMAIN?
2)delete SUBDOMAIN?

please help
thank
 
This is not a problem to delete one subdomain if is only one subdomain at domain

PHP:
include("httpsocket.php");
$sock = new HTTPSocket;
$sock->connect('xxxxxx',2222);
$sock->set_login("xxxxxxx","xxxxxxxxxxx");
$sock->set_method('POST');

$sock->query('/CMD_SUBDOMAIN',
    array(
        'action' => 'delete',
        'domain' => 'maindomain.com',
        'select0' => 'subdomain'
    ));
$result = $sock->fetch_body();
echo $result;

but if i have 2 or more subdomains and i want to delete third subdomain that is a problem ;-)

Because every subdomain have own select input named selectID (0,1,2,3..n)
and if I delete subdomain with select2, the select3 will change to select2.
If i want to delete select2 and select4 and select7 after delete select2 select4 will be select3, you know what I have to tell you.

And I dont know how to repair it ;-)
 
This is not a problem to delete one subdomain if is only one subdomain at domain

PHP:
include("httpsocket.php");
$sock = new HTTPSocket;
$sock->connect('xxxxxx',2222);
$sock->set_login("xxxxxxx","xxxxxxxxxxx");
$sock->set_method('POST');

$sock->query('/CMD_SUBDOMAIN',
    array(
        'action' => 'delete',
        'domain' => 'maindomain.com',
        'select0' => 'subdomain'
    ));
$result = $sock->fetch_body();
echo $result;

but if i have 2 or more subdomains and i want to delete third subdomain that is a problem ;-)

Because every subdomain have own select input named selectID (0,1,2,3..n)
and if I delete subdomain with select2, the select3 will change to select2.
If i want to delete select2 and select4 and select7 after delete select2 select4 will be select3, you know what I have to tell you.

And I dont know how to repair it ;-)

no
it's not work

PHP:
<?php

include 'httpsocket.php';

	$sock = new HTTPSocket;
	$sock->connect('******',2222);

	$sock->set_login("**","***");

	$sock->set_method('POST');

	$sock->query('/CMD_SUBDOMAIN',
		array(
			'action' => 'delete',
			'domain' => '***',
			'select0' => '***'
		));
	$result = $sock->fetch_body();
	echo $result; 

?>

i have only one domain
please help
 
This is not a problem to delete one subdomain if is only one subdomain at domain

PHP:
include("httpsocket.php");
$sock = new HTTPSocket;
$sock->connect('xxxxxx',2222);
$sock->set_login("xxxxxxx","xxxxxxxxxxx");
$sock->set_method('POST');

$sock->query('/CMD_SUBDOMAIN',
    array(
        'action' => 'delete',
        'domain' => 'maindomain.com',
        'select0' => 'subdomain'
    ));
$result = $sock->fetch_body();
echo $result;

but if i have 2 or more subdomains and i want to delete third subdomain that is a problem ;-)

Because every subdomain have own select input named selectID (0,1,2,3..n)
and if I delete subdomain with select2, the select3 will change to select2.
If i want to delete select2 and select4 and select7 after delete select2 select4 will be select3, you know what I have to tell you.

And I dont know how to repair it ;-)

yeh i have more of 1 subdomain
please help me someone
 
Note I'm NOT a php programmer; this is simply a stab in the dark.

Is there any way you can select the array key without going through a loop?

Jeff
 
This is not a problem to delete one subdomain if is only one subdomain at domain

PHP:
include("httpsocket.php");
$sock = new HTTPSocket;
$sock->connect('xxxxxx',2222);
$sock->set_login("xxxxxxx","xxxxxxxxxxx");
$sock->set_method('POST');

$sock->query('/CMD_SUBDOMAIN',
    array(
        'action' => 'delete',
        'domain' => 'maindomain.com',
        'select0' => 'subdomain'
    ));
$result = $sock->fetch_body();
echo $result;

but if i have 2 or more subdomains and i want to delete third subdomain that is a problem ;-)

Because every subdomain have own select input named selectID (0,1,2,3..n)
and if I delete subdomain with select2, the select3 will change to select2.
If i want to delete select2 and select4 and select7 after delete select2 select4 will be select3, you know what I have to tell you.

And I dont know how to repair it ;-)

Wow thats hard :P, just reverse your array
array array_reverse ( array $array [, bool $preserve_keys ] )

@ ababcc

change CMD_SUBDOMAIN to CMD_API_SUBDOMAINS

@jlasman
Why would you wanna do that?
 
Last edited:
@jlasman
Why would you wanna do that?
Because then he could delete only the ones he wanted to delete. As I mentioned, I'm NOT a PHP programmer. My answer was meant to be generic.

The only reason I responded at all was because there was no reply for two days.

Jeff
 
Hi,

I think I found a bug in this script. When emailaddresses contain a dot, like [email protected] the script returns an array with the dot in the emailaddress converted to underscore. So it returns [email protected] instead of [email protected].

I think it has something to with urldecode but I can't fix the problem.

This is my query:

$mydata = array(
'action' => 'list',
'domain' => $domain,
'type' => 'quota',


);
$sock->query('/CMD_API_POP',$mydata);
$result = $sock->fetch_parsed_body();

Thanks for your answer, solution.

Greets Anthony
 
mmm.. I have a problem!!!

PHP:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('mydomain.net',2222);

$sock->set_login("usernamereseller","passwordreseller");

$sock->set_method('POST');


$sock->query('/CMD_API_ACCOUNT_USER',
    array('action' => 'create',
        'username' => 'oooook',
        								'email' => '[email protected]',
										'passwd' => 'password1',
										'passwd2' => 'password1',
										'domain' => 'dominiotest.com',
										'package' => 'pacchetto1',
										'ip' => 'IP TO USE',
										'notify' => 'no' 
));
$result = $sock->fetch_body();

echo $result;

?>

the result is:

error=0&text=User oooook created&details=<br> Unix User created successfully<br> <br> User's System Quotas set<br> User's data directory created successfully<br> Domains directory created successfully<br> Domains directory created successfully in user's home<br> <br> <br> <br> Domain Created Successfully<br> <br> <br>

the user is successfully created, but the limit and permissions are not set.

can you help me please?

thank you
 
Hi, I was just wondering if there is a possibilty to check services status using this class. I mean - httpd, exim, etc.

Regards,

Mike
 
mmm.. I have a problem!!!

PHP:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('mydomain.net',2222);

$sock->set_login("usernamereseller","passwordreseller");

$sock->set_method('POST');


$sock->query('/CMD_API_ACCOUNT_USER',
    array('action' => 'create',
        'username' => 'oooook',
        								'email' => '[email protected]',
										'passwd' => 'password1',
										'passwd2' => 'password1',
										'domain' => 'dominiotest.com',
										'package' => 'pacchetto1',
										'ip' => 'IP TO USE',
										'notify' => 'no' 
));
$result = $sock->fetch_body();

echo $result;

?>

the result is:



the user is successfully created, but the limit and permissions are not set.

can you help me please?

thank you

I am having the exact same issue.
I create a user using CMD_API_ACCOUNT_USER, specify package, and all other required information. The user is created, but limits/permissions are not set. My code is identical to what's listed above.

I refuse to custom set every single limit/permission by using custom user creation. The purpose of a package is so I don't have to do that.

A possible workaround may be using one of the show_package functions to pull the permissions/limits out of DirectAdmin, then use that information to set a custom user. However, once again, I shouldn't have to do that.
 
Script hangs

Hey guys,

I've been trying to get this working for a few days on and off and it just hangs on me. I'm using the latest version of the script with the following code:

PHP:
<?php
include "httpsocket.php";

$socket = new HTTPSocket;

$socket->connect('xxx.xxx.xxx.xxx', 2222);
$socket->set_login('admin', 'xxxxxxxx');
// $socket->set_method('POST');

$socket->query('/CMD_API_SHOW_ALL_USERS');
$users = $socket->fetch_parsed_body();

print_r($users);

Am I doing something wrong?

When I try with http or https before the URL it returns an empty array. When I have just the IP address the browser hangs, seems like it's waiting for something.
 
Last edited:
Hey guys,

I've been trying to get this working for a few days on and off and it just hangs on me. I'm using the latest version of the script with the following code:

PHP:
<?php
include "httpsocket.php";

$socket = new HTTPSocket;

$socket->connect('xxx.xxx.xxx.xxx', 2222);
$socket->set_login('admin', 'xxxxxxxx');
// $socket->set_method('POST');

$socket->query('/CMD_API_SHOW_ALL_USERS');
$users = $socket->fetch_parsed_body();

print_r($users);

Am I doing something wrong?

When I try with http or https before the URL it returns an empty array. When I have just the IP address the browser hangs, seems like it's waiting for something.

CMD_API_SHOW_ALL_USERS can use either GET or POST. Maybe try using one or the other and see if your results differ.
 
When connecting 127.0.0.1 will it use the Current user logged-in? Or can I set it to use admin user and such..?

the set_login does a difference at all?

I want to use ADMIN API's without using his password. plugins can do that?
 
Hey guys,

I've been trying to get this working for a few days on and off and it just hangs on me. I'm using the latest version of the script with the following code:

PHP:
<?php
include "httpsocket.php";

$socket = new HTTPSocket;

$socket->connect('xxx.xxx.xxx.xxx', 2222);
$socket->set_login('admin', 'xxxxxxxx');
// $socket->set_method('POST');

$socket->query('/CMD_API_SHOW_ALL_USERS');
$users = $socket->fetch_parsed_body();

print_r($users);

Am I doing something wrong?

When I try with http or https before the URL it returns an empty array. When I have just the IP address the browser hangs, seems like it's waiting for something.

I have exactly the same problem. Are you connecting from a other server too? That might be the problem? - tested this, but has the same effect on the server itself.

Anyone who can help us out here?
 
Last edited:
Back
Top