array("pipe", "r"), 1 => array("pipe", "w") ); $process = @proc_open("tidy -utf8 -config {$cwd}html-tidy-config.cfg", $descriptorspec, $pipes); // Make sure the program started and we got the hooks... // Either way, get some source code into $source if (is_resource($process)) { // Feed untidy source into the stdin fwrite($pipes[0], $source); fclose($pipes[0]); // Read clean source out to the browser while (!feof($pipes[1])) { //echo fgets($pipes[1], 1024); $newsrc .= fgets($pipes[1], 1024); } fclose($pipes[1]); // Clean up after ourselves proc_close($process); } else { /* Use tidy if it's available from PECL */ if( function_exists('tidy_parse_string') ) { $tempsrc = tidy_parse_string($source); tidy_clean_repair(); $newsrc = tidy_get_output(); } else { // Better give them back what they came with, so they don't lose it all... $newsrc = "
\n" .$source. "\n"; } } // Split our source into an array by lines $srcLines = preg_split("/\n/",$newsrc,-1,PREG_SPLIT_NO_EMPTY); // Get only the lines between the body tags $startLn = 0; while ( strpos( $srcLines[$startLn++], ' var ns=""; editor.setHTML(ns); } ?>