Emulating validation pages

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Emulating validation pages

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

"regular validation headers" :?:
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post by Todd_Z »

typical headers that validtor.w3.org sends
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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...
User avatar
Todd_Z
Forum Regular
Posts: 708
Joined: Thu Nov 25, 2004 9:53 pm
Location: U Michigan

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post 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();
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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/ ;)
Post Reply