Subversion Repositories oidplus

Rev

Rev 112 | Rev 143 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
112 daniel-mar 1
<?php
2
 
3
/*
4
 * OIDplus 2.0
5
 * Copyright 2019 Daniel Marschall, ViaThinkSoft
6
 *
7
 * Licensed under the Apache License, Version 2.0 (the "License");
8
 * you may not use this file except in compliance with the License.
9
 * You may obtain a copy of the License at
10
 *
11
 *     http://www.apache.org/licenses/LICENSE-2.0
12
 *
13
 * Unless required by applicable law or agreed to in writing, software
14
 * distributed under the License is distributed on an "AS IS" BASIS,
15
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
 * See the License for the specific language governing permissions and
17
 * limitations under the License.
18
 */
19
 
20
use MatthiasMullie\Minify;
21
 
142 daniel-mar 22
define('DO_MINIFY', true);
23
 
112 daniel-mar 24
require_once __DIR__ . '/3p/minify/path-converter/ConverterInterface.php';
25
require_once __DIR__ . '/3p/minify/path-converter/Converter.php';
26
require_once __DIR__ . '/3p/minify/src/Minify.php';
27
require_once __DIR__ . '/3p/minify/src/CSS.php';
28
require_once __DIR__ . '/3p/minify/src/Exception.php';
29
 
142 daniel-mar 30
require_once __DIR__ . '/includes/color_utils.inc.php';
31
 
112 daniel-mar 32
error_reporting(E_ALL);
33
 
142 daniel-mar 34
$out = '';
112 daniel-mar 35
 
142 daniel-mar 36
# ---
112 daniel-mar 37
 
142 daniel-mar 38
function process_file($filename) {
39
        if (DO_MINIFY) {
40
                $minifier = new Minify\CSS(__DIR__.'/'.$filename);
41
                $cont = $minifier->minify();
42
                $cont = str_ireplace("url(data:", "url###(data:", $cont);
43
                $cont = str_ireplace("url(", "url(".dirname($filename).'/', $cont);
44
        } else {
45
                $cont = file_get_contents(__DIR__.'/'.$filename);
46
                $cont = str_ireplace('url("data:', 'url###("data:', $cont);
47
                $cont = str_ireplace('url("', 'url("'.dirname($filename).'/', $cont);
48
                $cont = str_ireplace("url('data:", "url###('data:", $cont);
49
                $cont = str_ireplace("url('", "url('".dirname($filename).'/', $cont);
50
        }
51
        $cont = str_ireplace("url###(", "url(", $cont);
52
        return $cont;
53
}
112 daniel-mar 54
 
142 daniel-mar 55
# ---
112 daniel-mar 56
 
142 daniel-mar 57
$out .= process_file('oidplus.css')."\n\n";
58
 
59
foreach (array('publicPages','adminPages','raPages') as $pudir) {
60
        $ary = glob(__DIR__ . '/plugins/'.$pudir.'/'.'*'.'/style.css');
61
        sort($ary);
62
        foreach ($ary as $a) $out .= process_file($a);
63
}
64
 
65
$out .= process_file('3p/jstree/themes/default/style.css')."\n\n";
66
$out .= process_file('3p/bootstrap/css/bootstrap.css')."\n\n";
67
 
68
# ---
69
 
70
$hs = isset($_REQUEST['h_shift']) ? $_REQUEST['h_shift'] : 0;
71
$ss = isset($_REQUEST['s_shift']) ? $_REQUEST['s_shift'] : 0;
72
$vs = isset($_REQUEST['v_shift']) ? $_REQUEST['v_shift'] : 0;
73
if (($hs != 0) ||($ss != 0) || ($vs != 0))
74
$out = changeHueOfCSS($out, $hs, $ss, $vs);
75
 
76
# ---
77
 
112 daniel-mar 78
$etag = md5($out);
79
header("Etag: $etag");
80
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) {
81
        header("HTTP/1.1 304 Not Modified");
82
} else {
83
        header('Content-Type:text/css');
84
        echo $out;
85
}