$result = $sock->fetch_body(); not getting the full html code

dauser

New member
Joined
Jun 10, 2007
Messages
4
Hello,
I've made an accounts creator with the help of httpsocket.php
Everything works fine,But I'm attempting to make an errors checker (Check whether the username and subdomain already exists)
$result = $sock->fetch_body();
I'm attempting to use the instr command to find the error message in $ result.
But the problem is that $result is not always getiting the whole HTML source.
Is there some way to make sure that $result will get the whole HTML source?
Thanks in advance!
Best regards,
DAUser.
 
Hi,

HTTPSocket->fetch_body() should be retrieving the full body.

Is it always stopping at the same spot?

Are there only certain queries where it's not retrieving the full body?

Are there any related entries in any of DA's error logs?

What about anything in HTTPSocket->error array?

Perhaps with more information we will have a better idea what's going wrong. :)

Phil
 
Hello,
Sometimes it retrieves the whole HTML source fine,But usually,It only retrieve until the end of the header (Until the </head> tag)
So here's the content of the $result :
Code:
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>DirectAdmin v1.29.4</title>
	<script language="JavaScript">
	<!-- // start preload code
		home_image = new Image();
		home_image.src = "/IMG_SKIN_NAV_HOME_OVER";
		webmail_image = new Image();
		webmail_image.src = "/IMG_SKIN_NAV_WEBMAIL_OVER";
		password_image = new Image();
		password_image.src = "/IMG_SKIN_NAV_PASSWORD_OVER";
		fileman_image = new Image();
		fileman_image.src = "/IMG_SKIN_NAV_FILEMAN_OVER";
		help_image = new Image();
		help_image.src = "/IMG_SKIN_NAV_HELP_OVER";
		logout_image = new Image();
		logout_image.src = "/IMG_SKIN_NAV_LOGOUT_OVER";
		logout_image2 = new Image();
		logout_image2.src = "/IMG_SKIN_NAV_LOGOUT2_OVER";
	// done with preload code -->
	</script>

	<style type="text/css">
	not found.


<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>DirectAdmin v1.29.4</title>
	<script language="JavaScript">
	<!-- // start preload code
		home_image = new Image();
		home_image.src = "/IMG_SKIN_NAV_HOME_OVER";
		webmail_image = new Image();
		webmail_image.src = "/IMG_SKIN_NAV_WEBMAIL_OVER";
		password_image = new Image();
		password_image.src = "/IMG_SKIN_NAV_PASSWORD_OVER";
		fileman_image = new Image();
		fileman_image.src = "/IMG_SKIN_NAV_FILEMAN_OVER";
		help_image = new Image();
		help_image.src = "/IMG_SKIN_NAV_HELP_OVER";
		logout_image = new Image();
		logout_image.src = "/IMG_SKIN_NAV_LOGOUT_OVER";
		logout_image2 = new Image();
		logout_image2.src = "/IMG_SKIN_NAV_LOGOUT2_OVER";
	// done with preload code -->
	</script>

	<style type="text/css">

Quite weird that fetch_body retrieve the header as well.
 
Last edited:
Well,
I'm still unable to figure it out.:(
Here's the code: (I've changed the domain,username and password)
PHP:
<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('mywebsite.com',2222);

$sock->set_login("username","password");

$sock->set_method('POST');

$sock->query('/CMD_ACCOUNT_USER',
    array(
        'action' => 'create',
        'username' => 'tester1',
        'email' => '[email protected]',
        'passwd' => '132123',
        'passwd2' => '132123',
         'domain' => 'domain.net',
        'bandwidth' => '0',
        'ubandwidth' => 'ON',
         'quota' => '150',
         'unsubdomains' => 'ON',
         'unemails' => 'ON',
         'unemailf' => 'ON',
         'unemailml' => 'ON',
         'unemailr' => 'ON',	 	
         'umysql' => 'ON',
         'udomainptr' => 'ON',
          'uftp' => 'ON',
          'cgi' => 'ON',
          'php' => 'ON',
          'spam' => 'ON',
          'catchall' => 'ON',
          'ssl' => 'ON',
          'cron' => 'ON',
          'sysinfo' => 'OFF',
          'dnscontrol' => 'ON',
          'suspend_at_limit' => 'ON',
          'skin' => 'enhanced',
        'ip' => '123.456.789.012', 
        'notify' => 'yes',
        'add' => 'Submit'
    ));
sleep(10);

$result=$sock->fetch_body();   
$stringtf = "That username already exists on the system";
if(strstr($result,$stringtf)) {
echo "found it.";
} else {
echo "not found.";
}



?>

The content of $result is always:
Code:
<html>

<head>
	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
	<title>DirectAdmin v1.29.4</title>
	<script language="JavaScript">
	<!-- // start preload code
		home_image = new Image();
		home_image.src = "/IMG_SKIN_NAV_HOME_OVER";
		webmail_image = new Image();
		webmail_image.src = "/IMG_SKIN_NAV_WEBMAIL_OVER";
		password_image = new Image();
		password_image.src = "/IMG_SKIN_NAV_PASSWORD_OVER";
		fileman_image = new Image();
		fileman_image.src = "/IMG_SKIN_NAV_FILEMAN_OVER";
		help_image = new Image();
		help_image.src = "/IMG_SKIN_NAV_HELP_OVER";
		logout_image = new Image();
		logout_image.src = "/IMG_SKIN_NAV_LOGOUT_OVER";
		logout_image2 = new Image();
		logout_image2.src = "/IMG_SKIN_NAV_LOGOUT2_OVER";
	// done with preload code -->
	</script>

	<style type="text/css">
	*
{
	FONT-SIZE: 8pt;
	FONT-FAMILY: verdana, arial, helvetica, sans-serif;
	line-height:16px;
}

a
{
	TEXT-DECORATION: none;
	COLOR: black;
}

a:hover
{
	COLOR: #9999CC;
	TEXT-DECORATION: underline;
}

.toptext
{
	COLOR: #666666;
}

u
{
	TEXT-DECORATION: underline;
}

input
{
	line-height: 12px
	
}
.tree
{
	
	COLOR: #C0C0C0;
}

.title
{
	COLOR: #000000;
	FONT-WEIGHT: bold;
	FONT-SIZE: 12pt;
}

td.header
{
	FONT-WEIGHT: 600;
	FONT-SIZE: 10pt;
	COLOR: #EEEEEE;
	BACKGROUND: #425984;
}

.mnot found.

What am I doing wrong?
Thanks in advance!
 
Hi,

Good to hear you got it working.

I've actually been using a completely reworked version of this class for a while now (much better written IMO). The reworked version currently relies on either a CURL binary or PHP's CURL extension, but I want to do a PHP Socket driver for the class when I get time. I'll update the HTTP Socket post with a wrapper for the new class after I get the PHP Socket driver finished.

Cheers, Phil
 
Back
Top