This is a good thing, in the future you may use the OH: HTML to XHTML Converter
Last Update:2017-02-28
Source: Internet
Author: User
XHTML;?
if (!empty ($type)) {
if ($type = = "path") {
if (!empty ($path)) {
if (file_exists ($path) && is_file ($path)) {
$file = file ($path);
if (substr ($file [0],0,9)!= <! DOCTYPE ") $doctype = 0;
$file = Join (", $file);
} else {
Die ("No such file.");
}
} else {
Die ("No file specified.");
}
} elseif ($type = = "File") {
if (!empty ($file)) {
} else {
Die ("No file specified.");
}
} else {
Die ("No file specified.");
}
# Specify HTML file, check for DOCTYPE
$file = File ("file.html");
if (substr ($file [0],0,9)!= <! DOCTYPE ") $doctype = 1;
$file = Join (", $file);
# Make tags and properties lower case, close empty elements, quote all properties
$search = Array (<\/?) (\w+) ([^>]*>) ' E ',
"' (<\/?) (BR|INPUT|META|LINK|IMG) ([^>]*) (/>) ' IE ',
"' (<\/?) (BR|INPUT|META|LINK|IMG) ([^>]*) (/>) ' IE ',
"' (<\/?) (BR|INPUT|META|LINK|IMG) ([^>]*) (>) ' IE ',
"' (\w+=) (\w+) ' IE ',
"' (\w+=) (. +?) ' ie ");
$replace = Array (' \\1 '. Strtolower (' \\2 '). \\3 ' ",
"' \\1\\2\\3> '",
"' \\1\\2\\3> '",
"' \\1\\2\\3/\\4 '",
"Strtolower (' \\1 ')." \ "\\2\" ",
"Strtolower (' \\1 ')." \\2 ' ");
$file = Preg_replace ($search, $replace, $file);
# return Xhtml-compliant Document
echo "<textarea cols=\" 100\ "rows=\" 20\ ">";
if (Isset ($doctype)) echo ' <! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Dtd/xhtml1-transitional.dtd" > "." \ n ";
Echo stripslashes (Stripslashes (Stripslashes ($file)));
echo "</textarea>";
} else {
?>
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Dtd/xhtml1-transitional.dtd" >
<body>
<!--Warning:this Input method was a security risk on open servers//-->
<form action= "<?= $PHP _self?>" method= "Get" >
<input type= "hidden" name= "type" value= "path"/>
<font face= "Verdana" >file path:</font> <input "text" type= "path" name= "size="
<input type= "Submit" value= "Submit"/>
</form>
<b><font face= "Verdana" >or</font></b><br/><br/>
<form action= "<?= $PHP _self?>" method= "Get" >
<input type= "hidden" name= "type" value= "file"/>
<font face= "Verdana" >file contents:</font><br/>
<textarea name= "File" rows= "ten" cols= "></textarea><br/>"
<input type= "Submit" value= "Submit"/>
</form>
</body>
?
}
?>
Original from www.evilwalrus.com