blob: eb9fc6dc7cbdbe23ab1f390339a8b005bb3a11b3 (
plain)
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
|
<?php
function ssl()
{
return isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on');
}
function proto()
{
return ssl() ? 'https' : 'http';
}
function baseurl()
{
if(isset($GLOBALS['CONFIG']['BASEURL']))
{
$base = $GLOBALS['CONFIG']['BASEURL'];
if(startswith('//', $base))
$base = proto().':'.$base;
return forceslash($base.'/'.$GLOBALS['CLIENT']);
}
$base = ssl() ? 'https://' : 'http://';
$base .= $_SERVER['HTTP_HOST'];
$base .= forceslash(dirname($_SERVER['SCRIPT_NAME']));
return forceslash($base.$GLOBALS['CLIENT']);
}
function forceslash($url)
{
$url = rtrim($url, '/');
if(strlen($url) > 0)
$url .= '/';
return $url;
}
function startswith($needle, $haystack)
{
return substr($haystack, 0, strlen($needle)) == $needle;
}
|