Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0); ini_set('display_errors', FALSE);
- // error_reporting(-1); ini_set('display_errors', 1);
- mb_regex_encoding('UTF-8');
- $allowed_tags = '<b><i><sup><sub><em><strong><u><br>';
- $tmp_cache = 'tmp_cache/';
- if($_FILES) {
- if($_FILES['file']['type'] == 'text/html') {
- $html = file_get_contents($_FILES['file']['tmp_name']);
- // $parsed_html = preg_replace('/<!--\[[\s\S]*?\]-->/s', '', $html);
- $parsed_html = preg_replace('/<!--\[if gte vml 1\]*?--><!\[if !vml\]>/s', '', $html);
- $parsed_html = str_replace('<![endif]--><![if !vml]>', '', $parsed_html);
- $parsed_html = str_replace('<p class-MsoNormal style-\'text-align:justify;line-height:115%\'>',
- '<p class="MsoNormal" style="text-align:justify;line-height:115%lmargin-bottom:10px;">', $parsed_html);
- $parsed_html = str_replace('<html xmlns:v="urn:schemas-microsoft-com:vml"' ,'', $parsed_html);
- $parsed_html = str_replace('xmlns:o="urn:schemas-microsoft-com:office:office"' ,'', $parsed_html);
- $parsed_html = str_replace('xmlns:w="urn:schemas-microsoft-com:office:word"' ,'', $parsed_html);
- $parsed_html = str_replace('xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"' ,'', $parsed_html);
- $parsed_html = str_replace('xmlns="http://www.w3.org/TR/REC-html40">' ,'', $parsed_html);
- // $parsed_html = htmlentities('<html>'."\n". trim($parsed_html));
- file_put_contents($tmp_cache . time() .'.html' , $parsed_html);
- die('<!DOCTYPE html><body><pre style="padding: 0;
- margin-top: 0;
- margin-bottom: 0;
- background-color: transparent;
- border: 0;
- display: block;
- padding: 9.5px;
- margin: 0 0 10px;
- font-size: 13px;
- line-height: 1.42857143;
- color: #333;
- word-break: break-all;
- word-wrap: break-word;
- background-color: #f5f5f5;
- border: 1px solid #ccc;
- border-radius: 4px;"><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n". trim(str_replace('<', '<', $parsed_html)) .'</pre></body></html>');
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement