Location: PHPKode > projects > OpenWolf Guidelines Validator > openWolf 0.9.9/parse.php
<?php

/*************************************************

openWolf - an HTML accessibility guidelines validator
Author: Geoff Munn (hide@address.com)
Version: 0.9.9

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

You may contact the author of openWolf by e-mail at: hide@address.com

The latest version of openWolf can be obtained from:
http://openwolf.sourceforge.net/

*************************************************/

if($_REQUEST['show_errors']=='t'){
	ini_set('display_errors', true);
	error_reporting(E_ALL);
} else {
	ini_set('display_errors', false);
	error_reporting(0);
}

set_time_limit(300);
ini_set('memory_limit','120M');

include_once('css_functions.php');
include_once('red_baron.class.php');
include_once('w3Validator.class.php');
include_once('basic_functions.php');
include_once('parse.core.class.php');
include_once('colours.class.php');
include_once('dictionaries.php');
			
if(!isset($url))
	$url=get_request('url');
if(!isset($snippit))
	$snippit=get_request('snippit');

if($snippit!='')
	$is_snippit=true;
else $is_snippit=false;

//$style=get_request('style');

if(can_check($url) || $snippit!=''){
	
	if(!isset($type))
		$type=get_request('type');
		
	$options=Array();
	
	include_once($type . '/rules.php');
	include_once($type . '/html_output.php');
	include_once($type . '/parse.class.php');

	//The main class for getting element details:
	$parse = new parse($url);
	
	$colours=new colours();
	
	//NZ WSR-specific parse values
	switch($type){
		case 'wai':
			//WAI-specific form fields:
			$priority1=get_request('priority1', false);
			$priority2=get_request('priority2', false);
			$priority3=get_request('priority3', false);
			
			if($priority1=='t')
				$priority1=true;
				
			if($priority2=='t')
				$priority2=true;
				
			if($priority3=='t')
				$priority3=true;
				
			$options['priority1']=$priority1;
			$options['priority2']=$priority2;
			$options['priority3']=$priority3;
			
			$output_options=Array('url'=>$url, 'header'=>$html_header, 'appendix'=>$html_appendix, 'footer'=>$html_footer);
		
			break;
		case 'nz':
			//NZ WSR-specific form fields:
			//$parse->departmentName(get_request('department_name'));
			$parse->departmentName($department_name);
			
			$parse->check_links($check_links);
			$output_options=Array('url'=>$url, 'header1'=>$html_header1, 'header2'=>$html_header2, 'footer'=>$html_footer);
		
			break;
	}

	create_message('Loading page', '', false);
	
	//fix up the url if necessary:
	$bits=parse_url($url);
	$url='';
	$url=@$bits['scheme'] . '://' . @$bits['host'];
	
	if(!isset($bits['path']))
		$url=$url . '/';
	else $url.=$bits['path'];
	
	if(isset($bits['query']))
		$url.='?' . $bits['query'];
	if(isset($bits['fragment']))
		$url.='#' . $bits['fragment'];

	if($url!='')
		$headers=fetch_file($url);
	else
		$headers='';
		
	if($snippit!='' || is_response_good($headers)){
		
		create_message('Page received', '', false);
		
		if($snippit=='')
			$contents=$headers['contents'];
		else {
			$snippit=stripslashes($snippit);
			$contents=$snippit;
		}
		
		//Possibly the two most important lines in the program! :)
		$parse->parse_HTML($contents, true);
		
		$parse->parse_stylesheet(Array('all'));
		
		create_message('Page parsed', '', false);
		
		$results=Array();
		
		$results=rules($parse, $colours, $options);
		
		//Generate the report:
		if($ajax=='f'){
			header('Content-Type: text/html; charset=utf-8');
			output_results($results, $parse, $output_options, $is_snippit);
		} else {
			session_start();
			
			$contents='';
			$contents.=$type . "---linebreak---\n";
			$contents.=serialize($parse) . "---linebreak---\n";;
			$contents.=serialize($output_options) . "---linebreak---\n";;
			$contents.=serialize($results);
			
			$suffix=$_SESSION['job_id'];
			$file_name='./files/results_' . $suffix . '.txt';
			$fh=fopen($file_name, 'w');
			fwrite($fh, $contents);
			fclose($fh);
						
			$_SESSION['finished']=true;
			$_SESSION['success']=true;
			
			header("Content-type: text/xml");
			$xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
			$xml.="<status type=\"good\">finished</status>";
			
			print $xml;
			session_write_close();
		}
	} else {
		if($ajax=='f'){
			//a 404 for instance...
			$output_options=$_SESSION['output_options'];
			
			$url=$output_options['url'];
			
			include_once('default/no_file.php');
			
			$output_options['no_file']=$no_file;
			
			session_destroy();
			
			output_404($output_options);
			
		} else {
			session_start();
			//$_SESSION['status']='no file';
			$_SESSION['output_options']=$output_options;
			//$_SESSION['is_loading']=true;
			$_SESSION['finished']=true;
			$_SESSION['success']=false;
			
			header("Content-type: text/xml");
			$xml="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
			$xml.="<status type=\"bad\">File not found</status>";
			print $xml;
			session_write_close();
		}
	}
	
}

?>
Return current item: OpenWolf Guidelines Validator