Rev 215 | Rev 261 | 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 | |||
22 | require_once __DIR__ . '/3p/minify/src/Minify.php'; |
||
23 | require_once __DIR__ . '/3p/minify/src/JS.php'; |
||
24 | require_once __DIR__ . '/3p/minify/src/Exception.php'; |
||
218 | daniel-mar | 25 | if (file_exists(__DIR__ . '/includes/config.inc.php')) { |
26 | include_once __DIR__ . '/includes/config.inc.php'; |
||
27 | } |
||
112 | daniel-mar | 28 | |
29 | error_reporting(E_ALL); |
||
30 | |||
215 | daniel-mar | 31 | $files = array(); |
112 | daniel-mar | 32 | |
215 | daniel-mar | 33 | $files[] = __DIR__ . '/3p/jquery/jquery-2.2.1.min.js'; // We are using jQuery 2.2.1, because 3.3.1 seems to be incompatible with jsTree (HTML content will not be loaded into jsTree!) TODO: File bug report |
34 | $files[] = __DIR__ . '/3p/bootstrap/js/bootstrap.min.js'; |
||
35 | $files[] = __DIR__ . '/3p/jstree/jstree.min.js'; |
||
36 | $files[] = __DIR__ . '/3p/tinymce/tinymce.min.js'; |
||
37 | $files[] = __DIR__ . '/3p/jquery-ui/jquery-ui.min.js'; |
||
38 | $files[] = __DIR__ . '/3p/layout/jquery.layout.min.js'; |
||
39 | $files[] = __DIR__ . '/3p/spamspan/spamspan.js'; |
||
40 | $files[] = __DIR__ . '/3p/bignumber.js/bignumber.min.js'; |
||
41 | $files[] = __DIR__ . '/3p/sha3_js/sha3.js'; // https://github.com/emn178/js-sha3 |
||
42 | |||
43 | $files[] = __DIR__ . '/oidplus_base.js'; |
||
44 | |||
112 | daniel-mar | 45 | $ary = glob(__DIR__ . '/plugins/publicPages/'.'*'.'/script.js'); |
46 | sort($ary); |
||
218 | daniel-mar | 47 | $files = array_merge($files, $ary); |
112 | daniel-mar | 48 | |
49 | $ary = glob(__DIR__ . '/plugins/adminPages/'.'*'.'/script.js'); |
||
50 | sort($ary); |
||
218 | daniel-mar | 51 | $files = array_merge($files, $ary); |
112 | daniel-mar | 52 | |
53 | $ary = glob(__DIR__ . '/plugins/raPages/'.'*'.'/script.js'); |
||
54 | sort($ary); |
||
218 | daniel-mar | 55 | $files = array_merge($files, $ary); |
112 | daniel-mar | 56 | |
215 | daniel-mar | 57 | # --- |
58 | |||
59 | $minifier = null; |
||
60 | |||
61 | foreach ($files as $file) { |
||
62 | if (is_null($minifier)) { |
||
63 | $minifier = new Minify\JS($file); |
||
64 | } else { |
||
65 | $minifier->add($file); |
||
66 | } |
||
67 | } |
||
68 | |||
218 | daniel-mar | 69 | if (defined('RECAPTCHA_ENABLED') && RECAPTCHA_ENABLED) { |
70 | $minifier->add('oidplus_external_recaptcha();'); |
||
71 | } |
||
72 | |||
73 | if (!defined('DISABLE_MSIE_COMPAT') || !DISABLE_MSIE_COMPAT) { |
||
74 | $minifier->add('oidplus_external_polyfill();'); |
||
75 | } |
||
76 | |||
112 | daniel-mar | 77 | $out = $minifier->minify(); |
218 | daniel-mar | 78 | |
112 | daniel-mar | 79 | $etag = md5($out); |
80 | header("Etag: $etag"); |
||
81 | if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) { |
||
82 | header("HTTP/1.1 304 Not Modified"); |
||
83 | } else { |
||
84 | header('Content-Type:application/javascript'); |
||
85 | echo $out; |
||
86 | } |