PHP Classes

File: index.php

Recommend this page to a friend!
  Classes of Lucian Sabo   CriosWeb HTML Cleaner   index.php   Download  
File: index.php
Role: Example script
Content type: text/plain
Description: usage example
Class: CriosWeb HTML Cleaner
Remove unwanted tags and data from HTML documents
Author: By
Last change: updated test script
Date: 16 years ago
Size: 1,639 bytes
 

Contents

Class file image Download
<?php /* Created on: 12.07.2007 */ ?>
<html>
<head>
<title>HTMLCleaner :: Clean MS Word HTML quickly</title>
<style type="text/css">
body,table {font-family:tahoma,verdana,arial;font-size:9pt}
</style>
</head>
<body>
<h2>CRIOS<i>WEB</i>'s HTMLCleaner</h2>
<form enctype="multipart/form-data" method="POST" action="<?$_SERVER['PHP_SELF']?>">
Upload HTML Document to be cleaned:
<input type="file" name="doc">
or paste your code here:
<br><br>
<textarea name="html" rows="20" cols="80"></textarea>
<br><br>
<input type="submit" value="Process" name="process">
</form>
<p>HTML source code cleaner (great help for cleaning MS Word content)</p>
<p>PHP class: <a href="http://luci.criosweb.ro/blog/2007/08/04/html-cleaner/" target="_blank">http://luci.criosweb.ro/blog/2007/08/04/html-cleaner/</a></p>

<p>Licenced under Creative Commons LGPL (creativecommons.org/licenses/LGPL/2.1/)<br>
for personal, non-commercial use</p>

<p>For commercial use one developer licence costs 30 EUROs</p>
<?php
$word
=$_POST['html'];
if(isset(
$_POST["process"])){

require(
"HTMLCleaner.php");

if(!
$word){
$filename=$_FILES["doc"]["tmp_name"];

$fp=fopen($filename,"r");
$word=fread($fp,filesize($filename));
fclose($fp);
unlink($filename);
}

$cleaner=new HTMLCleaner();

$cleaner->Options['UseTidy']=false;
$cleaner->Options['OutputXHTML']=false;
$cleaner->Options['Optimize']=true;

$cleaner->html=$word;
$cleanHTML=$cleaner->cleanUp('latin1');

echo
'<textarea style="width:100%;height:300px">'.htmlspecialchars($cleanHTML,ENT_COMPAT,"ISO-8859-1")."</textarea>";
echo
$cleanHTML;
}
?>
</body>
</html>