示例#1
0
文件: mod_tidy.php 项目: poef/ariadne
 function clean($html, $config = false)
 {
     global $AR;
     if (!$config) {
         $config["path"] = $this->tidy;
         $config["temp"] = $this->temp;
         $config["options"] = $this->options;
     }
     if ($AR->OS == "WIN32") {
         include_once $AR->dir->install . "/lib/modules/mod_unicode.php";
         $html = unicode::utf8convert($html);
     }
     $html = preg_replace('|(<[?]xml:namespace[^/]*office[^/]*/>)|i', '', $html);
     $file = tempnam($config["temp"], 'tidy-php-tmp');
     $errfile = tempnam($config["temp"], 'tidy-php-err');
     $fd = fopen($file, "w");
     fwrite($fd, $html, strlen($html));
     fclose($fd);
     $pd = popen($config["path"] . " -f " . $errfile . " " . $config["options"] . " " . $file, "r");
     while (!feof($pd)) {
         $outhtml .= fread($pd, 1024);
     }
     pclose($pd);
     $fd = fopen($errfile, "r");
     while (!feof($fd)) {
         $errors .= fread($fd, 1024);
     }
     fclose($fd);
     unlink($file);
     unlink($errfile);
     $ret['html'] = $outhtml;
     $ret['errors'] = $errors;
     return $ret;
 }
示例#2
0
 function utf8toiso8859($string, $entities = true)
 {
     return unicode::utf8convert($string, 0xff, $entities);
 }