Page 1 of 1

Emulating validation pages

Posted: Sun Aug 28, 2005 10:08 pm
by Todd_Z
I would like to know what the headers are that http://validator.w3.org sends so that I can make a custom page validator. Basically I am doing this so that the sessions variables work too, because obviously when the validator goes to a restricted part of the site, it simply gets a "you must be logged in" error. Thanks.

[Edit] I think that explanation sucked. I want to somehow include in a script the page that the user wants to get validated. [the url has been base64 encode] So basically, when they do so, it uses the regular validation headers to be sent to my pages, saves that output as a file, then redirects to the validator:

Code: Select all

<?
	$url = base64_decode( $_GET['q'] );

	ob_start( );
////////////////////////
	include "http://www.chatlance.com$url";
///////////////////////
	$contents = ob_get_contents();
	ob_end_clean();
	
	$file = "/***************/Validation/".md5(time()).".htm";
	$hnd = fopen( $file, "w" );
	fwrite( $hnd, $contents );
	fclose( $hnd );
	
	header( "Location: http://validator.w3.org/check?uri=".urlencode("http://www.chatlance.com/".substr($file,27)).";ss=1" );
?>
I'm trying to figure out what to put inbetween the commented lines so that the session vars will be sent and the validation headers will be sent.

Posted: Sun Aug 28, 2005 10:24 pm
by feyd
"regular validation headers" :?:

Posted: Sun Aug 28, 2005 10:26 pm
by Todd_Z
typical headers that validtor.w3.org sends

Posted: Sun Aug 28, 2005 10:39 pm
by feyd
without checking, I'd very much bet they send a standard get, and nothing else. You could easily check what headers they send if you wrote your own script that records the headers sent to it...

Posted: Sun Aug 28, 2005 10:53 pm
by Todd_Z
But i don't understand how on a server it can call the index of the same server with headers which specify the user-agent that i want to specify.

Posted: Sun Aug 28, 2005 11:01 pm
by feyd

Posted: Sun Aug 28, 2005 11:08 pm
by nielsene
The SimpleTest Browser might be another option if I understand correctly.

You're trying to create a "Gateway" page -- a page you can give to a validator, that returns the contents of a normally protected/not-directly available page. A page that requires some _SESSION from a previous page navigation/form submission history.

I doubt it would be possible to create a "generic" Gateway that always works. If you have a very simple $_SESSION requirement, simply a logined in test, that you could probably script your way through it with the SimpleTest Browse

roughly like (not tested and I might have the interface slightly off, but....)

Code: Select all

$browser =& new SimpleBrowser();
$browser->post($loginScript,array("Username"=>$username,
  "Password"=>$password, "Submit"=>"submit");
$browser->get($desiredTestPage);
$contents = $browser->getContents();

Posted: Mon Aug 29, 2005 4:36 am
by timvw
Or instead of using the w3.org interface, download the source of the validator and run it locally... http://validator.w3.org/source/ ;)