This is a good thing, in the future you may use the OH: HTML to XHTML Converter

Source: Internet
Author: User
Tags array empty join
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.