Advertisement
Guest User

Untitled

a guest
Nov 1st, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.07 KB | None | 0 0
  1. <?php
  2.  
  3.     error_reporting(0); ini_set('display_errors', FALSE);
  4.     // error_reporting(-1); ini_set('display_errors', 1);
  5.     mb_regex_encoding('UTF-8');
  6.  
  7.     $allowed_tags = '<b><i><sup><sub><em><strong><u><br>';
  8.  
  9.  
  10.     $tmp_cache = 'tmp_cache/';
  11.  
  12.     if($_FILES) {
  13.  
  14.         if($_FILES['file']['type'] == 'text/html') {
  15.  
  16.             $html = file_get_contents($_FILES['file']['tmp_name']);
  17.             // $parsed_html = preg_replace('/<!--\[[\s\S]*?\]-->/s', '', $html);
  18.             $parsed_html = preg_replace('/<!--\[if gte vml 1\]*?--><!\[if !vml\]>/s', '', $html);
  19.  
  20.             $parsed_html = str_replace('<![endif]--><![if !vml]>', '', $parsed_html);
  21.             $parsed_html = str_replace('<p class-MsoNormal style-\'text-align:justify;line-height:115%\'>',
  22.                 '<p class="MsoNormal" style="text-align:justify;line-height:115%lmargin-bottom:10px;">', $parsed_html);
  23.  
  24.             $parsed_html = str_replace('<html xmlns:v="urn:schemas-microsoft-com:vml"' ,'', $parsed_html);
  25.             $parsed_html = str_replace('xmlns:o="urn:schemas-microsoft-com:office:office"' ,'', $parsed_html);
  26.             $parsed_html = str_replace('xmlns:w="urn:schemas-microsoft-com:office:word"' ,'', $parsed_html);
  27.             $parsed_html = str_replace('xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"' ,'', $parsed_html);
  28.             $parsed_html = str_replace('xmlns="http://www.w3.org/TR/REC-html40">' ,'', $parsed_html);
  29.  
  30.             // $parsed_html = htmlentities('<html>'."\n". trim($parsed_html));
  31.  
  32.             file_put_contents($tmp_cache . time() .'.html' , $parsed_html);
  33.  
  34.             die('<!DOCTYPE html><body><pre style="padding: 0;
  35.    margin-top: 0;
  36.    margin-bottom: 0;
  37.    background-color: transparent;
  38.    border: 0;
  39.     display: block;
  40.    padding: 9.5px;
  41.    margin: 0 0 10px;
  42.    font-size: 13px;
  43.    line-height: 1.42857143;
  44.    color: #333;
  45.    word-break: break-all;
  46.    word-wrap: break-word;
  47.    background-color: #f5f5f5;
  48.    border: 1px solid #ccc;
  49.    border-radius: 4px;">&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;'."\n". trim(str_replace('<', '&lt;', $parsed_html)) .'</pre></body></html>');
  50.  
  51.         }
  52.  
  53.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement