blob: 0d4d8681e2e1606ac1419d0e8042bffad9f02ac2 (
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
<?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(forceslash($base).@$GLOBALS['MANDATOR']);
}
$base = ssl() ? 'https://' : 'http://';
$base .= $_SERVER['HTTP_HOST'];
$base .= forceslash(dirname($_SERVER['SCRIPT_NAME']));
return forceslash(forceslash($base).@$GLOBALS['MANDATOR']);
}
function forceslash($url)
{
$url = rtrim($url, '/');
if(strlen($url) > 0)
$url .= '/';
return $url;
}
function startswith($needle, $haystack)
{
return substr($haystack, 0, strlen($needle)) == $needle;
}
function handle_lesscss_request($lessfile, $relative_path)
{
$dir = forceslash(sys_get_temp_dir());
$css_file = Less_Cache::Get([
$lessfile => $relative_path,
], [
'sourceMap' => true,
'compress' => true,
'relativeUrls' => true,
'cache_dir' => $dir,
]);
$css = file_get_contents($dir.$css_file);
header('Content-Type: text/css');
header('Content-Length: '.strlen($css));
print($css);
}
|