PEAK XOOPS - xhtml valid hack released! in englishin japanese

Archive | RSS |
XOOPS
XOOPS : xhtml valid hack released!
Poster : GIJOE on 2006-03-21 01:43:00 (8306 reads)

in englishin japanese
XHTML ValidでないサイトをValidにするHackです!
やり方は、include/ フォルダに joke_xhtml_valid.php を用意して、mainfile.php のXOOPS_ROOT_PATH定義行の直後に1行加えるだけ!

……な〜んて、もちろん冗談ですが、このサイトみたいに、xhtml validをまったく気にしていないサイトでは、とりあえずhtml-lintで10〜20点は上昇しましたよ

A line insertion into mainfile.php


	define('XOOPS_ROOT_PATH', '...');
	require XOOPS_ROOT_PATH.'/include/joke_xhtml_valid.php' ;


include/joke_xhtml_valid.php

<?php

ob_start( 'joke_xhtml_valid' ) ;


// ob filter
function joke_xhtml_valid( $s )
{
	$s = str_replace( '<br>' , '<br />' , $s ) ;
	$s = str_replace( '<hr>' , '<hr />' , $s ) ;
	$s = str_replace( '<br /><br />' , '<br />' , $s ) ;
	$s = preg_replace_callback( '/\<img [^>]+\>/' , 'joke_xhtml_valid_img_alt' , $s ) ;
	$s = preg_replace_callback( '/\<table [^>]+\>/' , 'joke_xhtml_valid_table_summary' , $s ) ;
	return $s ;
}

function joke_xhtml_valid_img_alt( $matches )
{
	if( stristr( $matches[0] , 'alt=' ) ) {
		return $matches[0] ;
	} else {
		return '<img alt="" ' . substr( $matches[0] , 5 ) ;
	}
}

function joke_xhtml_valid_table_summary( $matches )
{
	if( stristr( $matches[0] , 'summary=' ) ) {
		return $matches[0] ;
	} else {
		return '<table summary="dummy" ' . substr( $matches[0] , 7 ) ;
	}
}
?>

0 comments
Printer friendly page Send this story to a friend

Comments list

Login
Username or e-mail:

Password:

Remember Me

Lost Password?

Register now!