-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
156 lines (113 loc) · 2.66 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
/**
* leafo.net 5
*
* @author leafo
* @version 1.0
*/
session_start(); // don't use this for gamingw, smf does it
// set_error_handler('phpError');
date_default_timezone_set('America/New_York');
require './class_profiling.inc.php';
$prof = new profiling();
/**
* debug print
* print_r the variable under question
*/
function trace($var, $caption = null)
{
echo '<div class="error">';
if ($caption) echo '<h2>'.$caption.'</h2>';
echo '<pre>'.htmlentities(print_r($var, 1)). '</pre></div>';
}
$debug = false;
$tidyPage = false && ob_start();
require_once './include/util.php';
$path = realpath(dirname(__FILE__)).'/';
$url = '/beta/';
// $url = 'http://leafo.rh.rit.edu/leafo/';
// initialize the registry
$r = r::load(array(
'default_page' => 'board',
'base_path' => $path,
'forum_path' => $path.'forums/',
'base_url' => $url,
'forum_url' => $url.'forums/',
));
require './include/database.php';
require './include/template.php'; r::$tpl = $tpl = new Template;
r::$link = new SimpleLink;
require './include/user.php';
// make user accessable in registery and template manager
r::$me = $tpl->v__me = $user;
require './include/validator.php';
function phpError($eno, $error, $file, $line)
{
// ignore indexing error
// if ($eno == E_NOTICE) return;
r::$tpl->v__top_failure .=
"<div class='error'>{$eno} Error {$file}[{$line}]".
$error.'<br /></div>';
}
if (!is_file($r->page_dir.$r->act.'.page.php'))
{
$r->act = $r->default_page;
}
require $r->page_dir.$r->act.'.page.php';
$class = $r->act.'Page';
$page = new $class();
// Gencontent and dump it
$tpl->grab('content');
{
$prof->add('start rendering page');
$page->select();
$prof->add('end rendering page');
if ($debug) {
// dump the template variables for debugging
// we grab it inside the content so we don't see
// a copy of the content in the dump
$tpl->grab('template');
{
echo $tpl;
}
$tpl->end();
// dump all the queries used for debugging
$tpl->grab('queries');
{
echo '<pre>';
foreach (db::get()->query_history as $q)
echo $q."\n\n";
echo '</pre>';
}
$tpl->end();
$tpl->grab('registry');
{
echo r::dump();
}
$tpl->end();
}
}
$tpl->end();
$tpl->v__debug = $debug;
$tpl->render('index.tpl');
if ($tidyPage)
{
$page = ob_get_clean();
$tidy_config = array(
'indent' => true,
'output-xhtml' => true,
'wrap' => 200);
$tidy = new tidy;
$tidy->parseString($page, $tidy_config);
$tidy->cleanRepair();
echo $tidy;
}
$prof->end();
/*
echo '<div style="background: white">';
echo $prof->get_result();
echo '</div>';
$mem = memory_get_usage(1);
trace(($mem/1000).'kb', 'base');
*/
?>