-
Notifications
You must be signed in to change notification settings - Fork 106
/
base.php
92 lines (76 loc) · 3.31 KB
/
base.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
<?php
/* $Id$ */
/* {{{ Copyright (c) 2003-2005 The dotProject Development Team <core-developers@dotproject.net>
This file is part of dotProject.
dotProject is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
dotProject is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with dotProject; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
}}} */
ini_set('display_errors', 0);
if (defined('E_DEPRECATED')) {
error_reporting(E_ALL & ~(E_DEPRECATED|E_NOTICE|E_STRICT));
} else {
error_reporting(E_ALL & ~E_NOTICE);
}
if (function_exists('date_default_timezone_set')) {
# this is a bit of a hack in that it will guess from the system what
# the timezone is.
date_default_timezone_set(date_default_timezone_get());
}
global $baseDir;
global $baseUrl;
$baseDir = dirname(__FILE__);
//Make sure directoy separator is at the end so that paths are well-formed
//$baseDir .= ((substr_compare($baseDir, DIRECTORY_SEPERATOR, -1 , 1) == 0) ? '' : DIRECTORY_SEPERATOR);
// Define to deprecate the global baseDir
define('DP_BASE_DIR', $baseDir);
// dprint(__FILE__, __LINE__, 8, "[DEBUG] Base dir is '" . DP_BASE_DIR . "'");
require_once ($baseDir . '/includes/dP_compat.php');
// only rely on env variables if not using a apache handler
function safe_get_env($name)
{
if (isset($_SERVER[$name])) {
return $_SERVER[$name];
} else if (mb_strpos(php_sapi_name(), 'apache') === false) {
getenv($name);
} else {
return '';
}
}
// automatically define the base url
$baseUrl = (((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
|| $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
? 'https://' : 'http://');
$baseUrl .= safe_get_env('HTTP_HOST');
// check if webserver is not running on default port
// This seems to only apply if using older Apache servers
if (($_SERVER['SERVER_PORT'] != 80 || $_SERVER['SERVER_PORT'] != 443) && strpos($baseUrl, ':') === FALSE) {
$baseUrl .= ':' . safe_get_env('SERVER_PORT');
}
$pathInfo = safe_get_env('PATH_INFO');
if (@$pathInfo) {
$baseUrl .= str_replace('\\','/',dirname($pathInfo));
} else {
$baseUrl .= str_replace('\\','/', dirname(safe_get_env('SCRIPT_NAME')));
}
$baseUrl = preg_replace('#/$#D', '', $baseUrl);
// Define to deprecate the global baseUrl
define('DP_BASE_URL', $baseUrl);
// And now we need to ensure we have a valid path for included pear libraries.
// This dependency sucks, but if we don't do it we have no idea what versions we have
$dpLib = DP_BASE_DIR.DIRECTORY_SEPARATOR.'lib';
$pear = $dpLib . DIRECTORY_SEPARATOR. 'PEAR';
// If you want a really secure path, comment the second one out and uncomment this
// set_include_path('.'.PATH_SEPARATOR.$dpLib.PATH_SEPARATOR.$pear);
set_include_path('.'.PATH_SEPARATOR.$dpLib.PATH_SEPARATOR.$pear.PATH_SEPARATOR.get_include_path());
// required includes for start-up
global $dPconfig;
$dPconfig = array();