| // +--------------------------------------------------------------------+ // // $Id$ // // Inicialization {{{ umask('002'); require_once 'HTML/Template/HIT.php'; require_once 'BIFE/Parser.php'; require_once 'BIFE/Translate.php'; // }}} // Selects the file to view {{{ if (@$_SERVER['PATH_INFO']) { $file = $_SERVER['PATH_INFO']; // If it ends with a slash it's a directory so we add index.xbf. if (substr($_SERVER['PATH_INFO'], strlen($_SERVER['PATH_INFO'])-1) == '/') { $file .= 'index.xbf'; } } else { $file = 'index.xbf'; } // }}} // Looks if we want to show the source {{{ if (@$_REQUEST['S']) { if (@$_REQUEST['B']) { // We want to see the BIFE file source. exec('enscript -q -p - -Ehtml --language=html --color ' . escapeshellarg($file), $buffer); $buffer = join("\n", $buffer); $buffer = strstr($buffer, '
'); $buffer = substr($buffer, 0, strpos($buffer, '')); $buffer = str_replace(array(''), $buffer); echo $buffer; #echo htmlentities(join('', file($file))); } else { // We want to see the php file source. highlight_file($_SERVER['SCRIPT_FILENAME']); } exit; } // }}} // If we are not looking at the source, we use BIFE to show the page {{{ $template =& new HTML_Template_HIT('templates'); $parser =& new BIFE_Parser('BIFE_Translate'); $page =& $parser->parseFile($file); $parser->__destruct(); // We now see if we want to show the HTML output if (@$_REQUEST['H']) { $f = fopen("$file.tmp.html", 'w'); fputs($f, $page->render($template)); fclose($f); exec('enscript -q -p - -Ehtml --language=html --color ' . escapeshellarg("$file.tmp.html"), $buffer); unlink("$file.tmp.html"); $buffer = join("\n", $buffer); $buffer = strstr($buffer, '
'); $buffer = substr($buffer, 0, strpos($buffer, '')); $buffer = str_replace(array(''), $buffer); echo $buffer; //echo '
' . htmlentities($page->render($template)) . ''; } else { echo $page->render($template); } // }}} ?>