0,0 → 1,49 |
<?php |
|
/* |
* OIDplus 2.0 |
* Copyright 2019 Daniel Marschall, ViaThinkSoft |
* |
* Licensed under the Apache License, Version 2.0 (the "License"); |
* you may not use this file except in compliance with the License. |
* You may obtain a copy of the License at |
* |
* http://www.apache.org/licenses/LICENSE-2.0 |
* |
* Unless required by applicable law or agreed to in writing, software |
* distributed under the License is distributed on an "AS IS" BASIS, |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
* See the License for the specific language governing permissions and |
* limitations under the License. |
*/ |
|
// We do this stuff to avoid that the client includes an externa JavaScript from polyfill.io, |
// since some users might have a problem with that (in regards privacy of their IP address etc.) |
// So, the OIDplus webserver will act as proxy. |
|
if (!isset($_SERVER['HTTP_USER_AGENT'])) die(); |
|
$ua = $_SERVER['HTTP_USER_AGENT']; |
|
$opts = [ |
"http" => [ |
"method" => "GET", |
"header" => "User-Agent: ".$ua."\r\n" |
] |
]; |
|
$context = stream_context_create($opts); |
$out = file_get_contents('https://polyfill.io/v3/polyfill.min.js?features=fetch%2CURL', false, $context); |
|
# --- |
|
$etag = md5($out); |
header("Etag: $etag"); |
header('Content-MD5: '.$etag); // RFC 2616 clause 14.15 |
if (isset($_SERVER['HTTP_IF_NONE_MATCH']) && (trim($_SERVER['HTTP_IF_NONE_MATCH']) == $etag)) { |
header("HTTP/1.1 304 Not Modified"); |
} else { |
header('Content-Type:application/javascript'); |
echo $out; |
} |
|