2 // vim: set expandtab tabstop=4 shiftwidth=4 foldmethod=marker:
3 // +--------------------------------------------------------------------+
4 // | BIFE - Buil It FastEr |
5 // +--------------------------------------------------------------------+
6 // | This file is part of BIFE. |
8 // | BIFE is free software; you can redistribute it and/or modify it |
9 // | under the terms of the GNU General Public License as published by |
10 // | the Free Software Foundation; either version 2 of the License, or |
11 // | (at your option) any later version. |
13 // | BIFE is distributed in the hope that it will be useful, but |
14 // | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 // | General Public License for more details. |
18 // | You should have received a copy of the GNU General Public License |
19 // | along with Hooks; if not, write to the Free Software Foundation, |
20 // | Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
21 // +--------------------------------------------------------------------+
22 // | Created: Wed May 17 18:16:54 ART 2003 |
23 // | Authors: Leandro Lucarella <luca@lugmen.org.ar> |
24 // +--------------------------------------------------------------------+
31 require_once 'HTML/Template/HIT.php';
32 require_once 'BIFE/Parser.php';
33 require_once 'BIFE/Translate.php';
36 // Selects the file to view {{{
37 if (@$_SERVER['PATH_INFO']) {
38 $file = $_SERVER['PATH_INFO'];
39 // If it ends with a slash it's a directory so we add index.xbf.
40 if (substr($_SERVER['PATH_INFO'], strlen($_SERVER['PATH_INFO'])-1) == '/') {
48 // Looks if we want to show the source {{{
49 if (@$_REQUEST['S']) {
50 if (@$_REQUEST['B']) {
51 // We want to see the BIFE file source.
52 exec('enscript -q -p - -Ehtml --language=html --color '
53 . escapeshellarg($file), $buffer);
54 $buffer = join("\n", $buffer);
55 $buffer = strstr($buffer, '<PRE>');
56 $buffer = substr($buffer, 0, strpos($buffer, '</PRE>'));
57 $buffer = str_replace(array('<FONT COLOR="', '</FONT>'),
58 array('<SPAN style="color: ', '</SPAN>'), $buffer);
60 #echo htmlentities(join('', file($file)));
62 // We want to see the php file source.
63 highlight_file($_SERVER['SCRIPT_FILENAME']);
69 // If we are not looking at the source, we use BIFE to show the page {{{
70 $template =& new HTML_Template_HIT('templates');
71 $parser =& new BIFE_Parser('BIFE_Translate');
72 $page =& $parser->parseFile($file);
73 $parser->__destruct();
74 // We now see if we want to show the HTML output
75 if (@$_REQUEST['H']) {
76 $f = fopen("$file.tmp.html", 'w');
77 fputs($f, $page->render($template));
79 exec('enscript -q -p - -Ehtml --language=html --color '
80 . escapeshellarg("$file.tmp.html"), $buffer);
81 unlink("$file.tmp.html");
82 $buffer = join("\n", $buffer);
83 $buffer = strstr($buffer, '<PRE>');
84 $buffer = substr($buffer, 0, strpos($buffer, '</PRE>'));
85 $buffer = str_replace(array('<FONT COLOR="', '</FONT>'),
86 array('<SPAN style="color: ', '</SPAN>'), $buffer);
88 //echo '<PRE>' . htmlentities($page->render($template)) . '</PRE>';
90 echo $page->render($template);