-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathindex.php
executable file
·78 lines (65 loc) · 1.79 KB
/
index.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<?php
/**
* The location of this system folder
*/
$system = dirname(__FILE__).'/';
/**
* The environment class helps us handle errors
* and autoloading of classes. It's not required
* to make Scaffold function, but makes it a bit
* nicer to use.
*/
include $system.'/lib/Scaffold/Environment.php';
/**
* Set timezone, just in case it isn't set. PHP 5.3+
* throws a tantrum if you try and use time() without
* this being set.
*/
date_default_timezone_set('GMT');
/**
* Automatically load any Scaffold Classes
*/
Scaffold_Environment::auto_load();
/**
* Let Scaffold handle errors
*/
Scaffold_Environment::handle_errors();
/**
* Set the view to use for errors and exceptions
*/
Scaffold_Environment::set_view(realpath($system.'/views/error.php'));
// =========================================
// = Start the scaffolding magic =
// =========================================
// Make sure the config var is set
if(!isset($config)) $config = array();
// The container creates Scaffold objects
$container = new Scaffold_Container($system,$config);
// This is where the magic happens
$scaffold = $container->build();
// Get the requested source
if(isset($_GET['file']))
{
$source = new Scaffold_Source_File( $scaffold->helper->load->file($_GET['file']) );
}
elseif(isset($_GET['url']) AND $config['enable_url'] === true)
{
$source = new Scaffold_Source_Url($_GET['url']);
}
elseif(isset($_GET['string']) AND $config['enable_string'] === true)
{
$source = new Scaffold_Source_String($_GET['string']);
}
elseif(isset($config['default_source']))
{
$source = new Scaffold_Source_File($config['default_source']);
}
else
{
echo 'No source :(';
exit;
}
// Compiles the source object
$source = $scaffold->compile($source);
// Use the result to render it to the browser. Hooray!
$scaffold->render($source);