-
Notifications
You must be signed in to change notification settings - Fork 0
/
showtemplate.php
49 lines (33 loc) · 1.12 KB
/
showtemplate.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// Crude.
require './setup.php';
if(!defined('XML_HTMLSAX3'))
define('XML_HTMLSAX3', 'XML/');
require_once(XML_HTMLSAX3 . '/HTMLSax3.php');
require_once('./src/lmbMacroTemplateHighlightHandler.class.php');
function contains($str, $sub) {
return gettype(strpos($str, $sub)) == "integer";
}
if(!isset($_GET['file']))
die('file param is not set!');
$file = $_GET['file'];
if (contains($file, "..") || contains($file, "//") || (substr($file, 0, 1) == '/')) {
exit;
}
$filename = './examples/' . $file;
if(!file_exists($filename))
exit;
$page = new lmbMacroTemplate('macrofile.html');
$parser = new XML_HTMLSax3();
$handler = new lmbMacroTemplateHighlightHandler();
$parser->set_object($handler);
$parser->set_element_handler('openHandler','closeHandler');
$parser->set_data_handler('dataHandler');
$parser->set_escape_handler('escapeHandler');
$parser->set_pi_handler('processPHPCode');
$parser->parse(file_get_contents($filename));
$html = $handler->getHtml();
$page->set('template_path', $file);
$page->set('template_content', $html);
echo $page->render();
?>