-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
executable file
·139 lines (113 loc) · 4.25 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
<?php
/**
* This is the main control script for the application.
*
* @package segue
*
* @copyright Copyright © 2005, Middlebury College
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License (GPL)
*
* @version $Id: index.php,v 1.17 2008/04/10 17:35:20 adamfranco Exp $
*/
/*********************************************************
* Define a Constant reference to this application directory.
*********************************************************/
define("MYDIR",dirname(__FILE__));
if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
$protocol = 'https';
else
$protocol = 'http';
if ($_SERVER['SCRIPT_NAME'])
$scriptPath = $_SERVER['SCRIPT_NAME'];
else
$scriptPath = $_SERVER['PHP_SELF'];
define("MYPATH", $protocol."://".$_SERVER['HTTP_HOST'].str_replace(
"\\", "/",
dirname($scriptPath)));
// The following lines set the MYURL constant.
if (file_exists(MYDIR.'/config/url.conf.php'))
include_once (MYDIR.'/config/url.conf.php');
else
include_once (MYDIR.'/config/url_default.conf.php');
if (!defined("MYURL"))
define("MYURL", trim(MYPATH, '/')."/index.php");
define("LOAD_GUI", true);
/*********************************************************
* Include our libraries
*********************************************************/
require_once(dirname(__FILE__)."/main/include/libraries.inc.php");
try {
/*********************************************************
* Include our configuration and setup scripts
*********************************************************/
require_once(dirname(__FILE__)."/main/include/setup.inc.php");
/*********************************************************
* Execute our actions
*********************************************************/
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
require_once(HARMONI."/utilities/Timer.class.php");
$execTimer = new Timer;
$execTimer->start();
ob_start();
}
try {
/*********************************************************
* Redirect for short form /sites/mysitename urls
*********************************************************/
if (isset($_SERVER['PATH_INFO'])
&& preg_match('/^\/sites\/([\w_-]+)\/?/', $_SERVER['PATH_INFO'], $matches))
{
$harmoni->request->setRequestParam('site', $matches[1]);
$harmoni->request->setModuleAction('view', 'html');
}
$harmoni->execute();
} catch (UnknownActionException $e) {
// If we are passed a Segue1-style URL, forward to an appropriate place.
Segue1UrlResolver::forwardCurrentIfNeeded();
// If we were not forwarded, re-throw
throw $e;
} catch (UnknownIdException $e) {
// If we are passed a Segue1-style URL, forward to an appropriate place.
Segue1UrlResolver::forwardCurrentIfNeeded();
// If we were not forwarded, re-throw
throw $e;
}
// Handle certain types of uncaught exceptions specially. In particular,
// Send back HTTP Headers indicating that an error has ocurred to help prevent
// crawlers from continuing to pound invalid urls.
} catch (UnknownActionException $e) {
SegueErrorPrinter::handleException($e, 404);
} catch (NullArgumentException $e) {
SegueErrorPrinter::handleException($e, 400);
} catch (PermissionDeniedException $e) {
SegueErrorPrinter::handleException($e, 403);
} catch (UnknownIdException $e) {
SegueErrorPrinter::handleException($e, 404);
}
// Default
catch (Exception $e) {
SegueErrorPrinter::handleException($e, 500);
}
if (defined('ENABLE_TIMERS') && ENABLE_TIMERS) {
$execTimer->end();
$output = ob_get_clean();
ob_start();
print "\n<table>\n<tr><th align='right'>Execution Time:</th>\n<td align='right'><pre>";
printf("%1.6f", $execTimer->printTime());
print "</pre></td></tr>\n</table>";
$dbhandler = Services::getService("DBHandler");
printpre("NumQueries: ".$dbhandler->getTotalNumberOfQueries());
if (isset($dbhandler->recordQueryCallers) && $dbhandler->recordQueryCallers)
print $dbhandler->getQueryCallerStats();
try {
$db = Harmoni_Db::getDatabase('segue_db');
print "<br/><div>".$db->getStats()."</div>";
} catch (UnknownIdException $e) {
}
// printpreArrayExcept($_SESSION, array('__temporarySets'));
// debug::output(session_id());
// Debug::printAll();
print "\n\t</body>\n</html>";
print preg_replace('/<\/body>\s*<\/html>/i', ob_get_clean(), $output);
}
?>