-
Notifications
You must be signed in to change notification settings - Fork 1
/
core.php
54 lines (43 loc) · 1.26 KB
/
core.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
<?php
/*
All Emoncms code is released under the GNU Affero General Public License.
See COPYRIGHT.txt and LICENSE.txt.
---------------------------------------------------------------------
Part of the OpenEnergyMonitor project:
http://openenergymonitor.org
*/
// no direct access
function get_application_path()
{
// Default to http protocol
$proto = "http";
// Detect if we are running HTTPS or proxied HTTPS
if (server('HTTPS') == 'on') {
// Web server is running native HTTPS
$proto = "https";
} elseif (server('HTTP_X_FORWARDED_PROTO') == "https") {
// Web server is running behind a proxy which is running HTTPS
$proto = "https";
}
if( isset( $_SERVER['HTTP_X_FORWARDED_SERVER'] ))
$path = dirname("$proto://" . server('HTTP_X_FORWARDED_SERVER') . server('SCRIPT_NAME')) . "/";
else
$path = dirname("$proto://" . server('HTTP_HOST') . server('SCRIPT_NAME')) . "/";
return $path;
}
function view($filepath, array $args)
{
extract($args);
ob_start();
include "$filepath";
$content = ob_get_clean();
return $content;
}
function server($index)
{
$val = null;
if (isset($_SERVER[$index])) {
$val = $_SERVER[$index];
}
return $val;
}