From: Tim Düsterhus Date: Wed, 11 May 2022 10:55:09 +0000 (+0200) Subject: Remove getFont.php X-Git-Tag: 6.0.0_Alpha_1~1291^2~9 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c09ba0f63a320b7a47dbbe5d72b43d9349161598;p=GitHub%2FWoltLab%2FWCF.git Remove getFont.php This was required to properly support multi-domain setups and thus is obsolete now. --- diff --git a/wcfsetup/install/files/font/getFont.php b/wcfsetup/install/files/font/getFont.php deleted file mode 100644 index 713c6a4c30..0000000000 --- a/wcfsetup/install/files/font/getFont.php +++ /dev/null @@ -1,94 +0,0 @@ - - */ - -// phpcs:disable PSR1.Files.SideEffects - -// list of known font types -$types = [ - 'eot' => 'application/vnd.ms-fontobject', - 'ttf' => 'application/octet-stream', - // best supported, but this is not the right one according to http://www.w3.org/TR/WOFF/#appendix-b - 'woff' => 'application/x-woff', - // the specs at http://dev.w3.org/webfonts/WOFF2/spec/ are not perfectly clear, but font/woff2 seems to be the most sane one and is currently used by Google Fonts - 'woff2' => 'font/woff2', -]; - -function badRequest($reason) -{ - \header("HTTP/1.1 400 Bad Request"); - \header("Content-Type: text/plain; charset=UTF-8"); - - exit($reason); -} - -function notFound($reason = "Unable to find font.") -{ - \header("HTTP/1.1 404 Not Found"); - \header("Content-Type: text/plain; charset=UTF-8"); - - exit($reason); -} - -if (empty($_GET['filename'])) { - if (empty($_GET['type'])) { - badRequest('Neither filename nor type is given.'); - } - $filename = (!empty($_GET['font']) ? \basename($_GET['font']) : 'fontawesome-webfont') . '.' . $_GET['type']; -} else { - $filename = __DIR__ . '/'; - if (!empty($_GET['family'])) { - $filename .= 'families/' . \basename($_GET['family']) . '/'; - } - $filename .= \basename($_GET['filename']); -} - -$type = \pathinfo($filename, \PATHINFO_EXTENSION); - -if (!isset($types[$type])) { - badRequest('Invalid type given.'); -} - -if (!\is_readable($filename)) { - notFound(); -} - -$filemtime = \filemtime($filename); - -$etag = '"' . \md5($filemtime . $filename) . '"'; -$clientEtag = (!empty($_SERVER['HTTP_IF_NONE_MATCH'])) ? \trim($_SERVER['HTTP_IF_NONE_MATCH']) : ''; -$clientLastModified = (!empty($_SERVER['HTTP_IF_MODIFIED_SINCE'])) ? \trim($_SERVER['HTTP_IF_MODIFIED_SINCE']) : 0; -$clientLastModified = @\strtotime($clientLastModified); - -// ignore request if client seems to already have fetched this file -if (($clientLastModified && $clientEtag) ? (($clientLastModified == $filemtime) && ($clientEtag == $etag)) : ($clientLastModified == $filemtime)) { - \header("HTTP/1.1 304 Not Modified"); - - exit; -} - -$data = \file_get_contents($filename); - -// send cache and type headers -// allow font fetching from all domains (CORS) -const MAX_AGE = 86400 * 14; - -\header('Access-Control-Allow-Origin: *'); -\header('Content-Type: ' . $types[$type]); -\header('Cache-Control: max-age=' . MAX_AGE . ', public'); -\header('ETag: ' . $etag); -\header('Expires: ' . \gmdate("D, d M Y H:i:s", \time() + MAX_AGE) . ' GMT'); -\header('Last-Modified: ' . \gmdate('D, d M Y H:i:s', $filemtime) . ' GMT'); -\header('Content-Length: ' . \strlen($data)); - -exit($data);