,{,},@,\n,\r"; if(!is_array($strings)) { $tr = array(); foreach(explode(',', $strings) as $chr) { $tr[$chr] = sprintf('\x%02X', ord($chr)); } $strings = $tr; } return strtr($string, $strings); } // Any errors would screq up our javascript error_reporting(0); ini_set('display_errors', false); if(trim(@$_REQUEST['content'])) { // PHP's urldecode doesn't understand %uHHHH for unicode $_REQUEST['content'] = preg_replace('/%u([a-f0-9]{4,4})/ei', 'utf8_chr(0x$1)', $_REQUEST['content']); function utf8_chr($num) { if($num<128)return chr($num); if($num<1024)return chr(($num>>6)+192).chr(($num&63)+128); if($num<32768)return chr(($num>>12)+224).chr((($num>>6)&63)+128).chr(($num&63)+128); if($num<2097152)return chr(($num>>18)+240).chr((($num>>12)&63)+128).chr((($num>>6)&63)+128) .chr(($num&63)+128); return ''; } ob_start(); passthru("echo " . escapeshellarg($_REQUEST['content']) . " | tidy -q -i -u -wrap 9999 -utf8 -bare -asxhtml 2>/dev/null", $result); $content = ob_get_contents(); ob_end_clean(); if(strlen($content) < 4) { // Tidy on the local machine failed, try a post $res_1 = PostIt( array ( '_function' => 'tidy', '_html' => $_REQUEST['content'], 'char-encoding' => 'utf8', '_output' => 'warn', 'indent' => 'auto', 'wrap' => 9999, 'break-before-br' => 'y', 'bare' => 'n', 'word-2000' => 'n', 'drop-empty-paras' => 'y', 'drop-font-tags' => 'n', ), 'http://infohound.net/tidy/tidy.pl'); if(preg_match('/