PDA

View Full Version : HTTPSocket Class


AtomicRax
02-14-2004, 07:30 PM
I am trying to disable an account through HTTPSocket. I have this:


include ($DOCUMENT_ROOT . '/directadmin.php');
$sock = new HTTPSocket;
$sock->connect('$serveraddy',2222);

$sock->set_login("admin|webadmin","******");

$sock->set_method('GET');

$sock->query('/CMD_SELECT_USERS',array( 'select0' => '$qusername', 'suspend' => 'Suspend/Unsuspend'));
$result = $sock->fetch_result();

$html = $result;


Variables used:
$serveraddy = server address (ns1.atomicrax.net)
$qusername = user I want to disable

It doesn't work. I don't know if that's how I'm supposed to do it, I just tried it....

Anyone know how to fix this?

l0rdphi1
02-14-2004, 07:47 PM
Try 'POST' inplace of 'GET'. :)

AtomicRax
02-14-2004, 07:58 PM
Still not working...

l0rdphi1
02-14-2004, 08:09 PM
In PHP you can't put variables inside single quotes. Use double quotes.

AtomicRax
02-14-2004, 08:15 PM
Nope, still nothing.

l0rdphi1
02-14-2004, 08:44 PM
Yes, of course. This is what I use: http://www.l0rdphi1.com/tools/httpsocket/examples/example.suspend_user.phps

Compare my query to yours. :)

AtomicRax
02-14-2004, 09:01 PM
Ok, I now have this...


include ($DOCUMENT_ROOT . '/directadmin.php');
$sock = new HTTPSocket;
$sock->connect('$serveraddy',2222);

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

$sock->set_method('POST');
$sock->query('/CMD_SELECT_USERS',
array(
'location' => 'CMD_SELECT_USERS',
'suspend' => 'Suspend',
'select0' => "$qusername"
));
$result = $sock->fetch_body();
echo $result;


Still nothing.

l0rdphi1
02-14-2004, 09:02 PM
Still have $serveraddy in single quotes. Should be doubles.

AtomicRax
02-14-2004, 09:07 PM
sorry, didn't catch that one, but it still doesn't work... :(

l0rdphi1
02-14-2004, 09:09 PM
Check the contents of $sock->error:print_r($sock->error);(after echo $result;)

Also, what kind of output is $result throwing?

AtomicRax
02-14-2004, 09:14 PM
All $sock->error is giving is Array ( )

And I get nothing from $result

l0rdphi1
02-14-2004, 09:19 PM
Try getting rid of the $sock->set_method('POST'); line entirely.

Hmm... why are you logging in as "webadmin"?

AtomicRax
02-14-2004, 09:20 PM
Because it's my admin account.

l0rdphi1
02-14-2004, 09:24 PM
I'm running low on ideas here. This is probably something silly though. You're sure the connect address is right? :)

Append echo $sock->result; to your program and see what it has to say.

AtomicRax
02-14-2004, 09:29 PM
Got rid of the $sock->set_method('POST'); line, replaced the variable $serveraddy with the real address, ns1.atomicrax.net and added echo $sock->result; which says nothing.

l0rdphi1
02-14-2004, 09:37 PM
Maybe this is the problem:Pinging ns1.atomicrax.net [198.87.82.150]:

Ping #1: * [No response]
Ping #2: * [No response]
Ping #3: * [No response]
Ping #4: * [No response]

Done pinging ns1.atomicrax.net!

AtomicRax
02-14-2004, 09:39 PM
Bocacom disables all ping requests. The server works good, you just can't ping it. Do to the recent attacks that many people have been experiancing. Bocacom.net owns the datacenter my server is in.

l0rdphi1
02-14-2004, 09:44 PM
http://ns1.atomicrax.net:2222 isn't working for me or Sam Spade (http://www.samspade.org/t/safe?u=http%3A%2F%2Fns1.atomicrax.net%3A2222).

AtomicRax
02-14-2004, 09:47 PM
It's secure...

https://ns1.atomicrax.net:2222

l0rdphi1
02-14-2004, 09:49 PM
AHHHHHHHHHHHHHH! I see the light!

Use$sock->connect("https://$serveraddy",2222);

AtomicRax
02-14-2004, 09:54 PM
Now I get:

Array ( [0] => 0 - Success )

But the account doesn't become suspended.

l0rdphi1
02-14-2004, 10:00 PM
I updated http://www.l0rdphi1.com/tools/httpsocket/httpsocket.phps with a possible fix for https. Cut 'n paste that over what you're using.

AtomicRax
02-14-2004, 10:10 PM
$this->result still has no output and $sock->error gives Array ( [0] => 0 - Success ) and the account still does not become suspended.

l0rdphi1
02-14-2004, 10:17 PM
$this->result? Should be using $sock->result

AtomicRax
02-14-2004, 10:19 PM
either way, I still get nothing.

l0rdphi1
02-14-2004, 10:23 PM
Line 86 of httpsocket.php: You should see "@fsockopen", change that to read "fsockopen". (remove the @)

Run the script. If we're lucky it'll error out and that should tell us more.

AtomicRax
02-14-2004, 10:28 PM
AH HA (httpsocket.php was renamed to directadmin.php)

Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/webadmin/......./directadmin.php on line 86

Warning: fsockopen(): unable to connect to https://ns1.atomicrax.net:2222 in /home/webadmin/......./directadmin.php on line 86

l0rdphi1
02-14-2004, 10:39 PM
Originally posted by AtomicRax
AH HA (httpsocket.php was renamed to directadmin.php)That really shouldn't matter.

Now here we go...

Originally posted by AtomicRax
Warning: fsockopen(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/webadmin/......./directadmin.php on line 86

Warning: fsockopen(): unable to connect to https://ns1.atomicrax.net:2222 in /home/webadmin/......./directadmin.php on line 86 Basically that's saying it doesn't know what the hell to do. Try changing https:// to ssl:// in the connect address

AtomicRax
02-14-2004, 10:43 PM
Warning: fsockopen(): no SSL support in this build in /home/webadmin/......./directadmin.php on line 86

Warning: fsockopen(): unable to connect to ns1.atomicrax.net:2222 in /home/webadmin/......./directadmin.php on line 86

l0rdphi1
02-14-2004, 11:04 PM
Switch back to https://, that I'm pretty sure is correct now.

We need to recompile PHP with OpenSSL so that it can recognize https URLs. I'm having a bit of trouble getting that to work. =\

AtomicRax
02-14-2004, 11:23 PM
So you think my best bet for now would be to switch to no SSL?

l0rdphi1
02-14-2004, 11:32 PM
Yeah, I think. I posted here (http://www.directadmin.com/forum/showthread.php?s=&postid=12553) on my OpenSSL problems.