filemtime('./cache')) {
rrmdir('./cache');
}
if (!is_dir('./cache')) {
mkdir('./cache');
}
$url = base64_encode($url.(isset($_GET['urlprefix']) ? '&urlprefix='.$_GET['urlprefix'] : ''));
if ($isFontData == false) {
header('Content-type: text/css; charset=utf-8');
}
else {
if (isset($ext)) {
header('Content-type: font/'.$ext);
}
}
getFile($url);
function getFile($url)
{
$filename = md5($url) . '.cache';
if (!file_exists('./cache/' . $filename)) {
echo cacheFile($url, './cache/' . $filename);
}
else {
echo file_get_contents('./cache/' . $filename);
}
}
function cacheFile($url, $filepath) {
$url = base64_decode($url);
$content = file_get_contents($url);
if (strlen($content) > 0) {
$content = str_replace($_ENV['PROTOCOL'].'://', $_ENV['BASE_URL'].'?url='.$_ENV['PROTOCOL'].'://', $content);
file_put_contents($filepath, $content);
}
return $content;
}
function rrmdir($src) {
if (file_exists($src)) {
$dir = opendir($src);
while (false !== ($file = readdir($dir))) {
if (($file != '.') && ($file != '..')) {
$full = $src . '/' . $file;
if (is_dir($full)) {
rrmdir($full);
} else {
unlink($full);
}
}
}
closedir($dir);
rmdir($src);
}
}