-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompiled.php
More file actions
36 lines (24 loc) · 867 Bytes
/
compiled.php
File metadata and controls
36 lines (24 loc) · 867 Bytes
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
<?php
// Crude.
require './setup.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;
$filename = realpath($filename);
$dir = substr($filename, 0, strpos($filename, 'templates'));
set_include_path($dir . PATH_SEPARATOR . get_include_path());
$page = new lmbMacroTemplate('phpfile.html');
$page->set('Filename', $file);
list($compiled_name, ) = $page->compile(realpath($filename));
$highlighted_string = highlight_string(file_get_contents($compiled_name), true);
$page->set('SourceCode', $highlighted_string);
echo $page->render();
?>