mirror of
https://git.code.sf.net/p/quake/website
synced 2025-03-14 05:30:42 +00:00
PHP 7 doesn't like the old short tags we were using (it's possible to re-enable them, but won't be for version 8, so we might as well switch now), and the old MySQL APIs are now gone entirely, replaced with something different. This should make everything work at least as well as it used to. Also, one file used to be checked in with CRLF line endings. ??
28 lines
575 B
PHP
28 lines
575 B
PHP
<?php
|
|
have ("cache");
|
|
|
|
function cachedURL ($url)
|
|
{
|
|
$cacheDir = siteHome . "/cache";
|
|
$cacheTime = 1800;
|
|
$cacheFile = $cacheDir . '/cached_' . md5 ($url);
|
|
|
|
$timeDifference = @(time () - filemtime ($cacheFile));
|
|
|
|
if ($cacheTime < $timeDifference) { // stale, make a new one
|
|
if ($f = @fopen ($url, 'r')) {
|
|
$content = '';
|
|
while (!feof ($f)) {
|
|
$content .= fgets ($f, 4096);
|
|
}
|
|
fclose ($f);
|
|
if ($f = fopen ($cacheFile, 'w')) {
|
|
fwrite ($f, $content, strlen ($content));
|
|
fclose ($f);
|
|
}
|
|
}
|
|
}
|
|
|
|
return file ($cacheFile);
|
|
}
|
|
?>
|