echo ' "' . $filename . '" (cached) '; flush(); $minifiedSize = filesize($minifiedPathname); $fullSize = filesize($pathname); } else { // Het bestand moet (opnieuw) geminified worden echo " Processing: \"" . $filename . "\""; flush(); $script = file_get_contents($pathname); $fullSize = strlen($script); if ($type === 'css') { $minifiedScript = \CssMin::minify($script); } elseif ($type === 'javascript') { $minifiedScript = \JSMinPlus::minify($script); } else { $minifiedScript = ImageOptimizer::minify($script, $filename); } if ($minifiedScript === false) { // Is het minify proces mislukt? $minifiedScript = $script; // Gebruik dan het orginele bestand. } $minifiedSize = strlen($minifiedScript); mkdirs(dirname($minifiedPathname) . '/'); if (file_put_contents($minifiedPathname, $minifiedScript) === false) { echo "\n FAILED.\n"; exit; } } echo " " . round(($minifiedSize - $fullSize) / 1024, 2) . 'KiB (' . round((1 - $minifiedSize / $fullSize) * 100) . "%)\n"; //echo " ".round((1 - ($minifiedSize / $fullSize)) * 100).'% ('.round($minifiedSize / 1024, 2).' / '.round($fullSize / 1024, 2)." KiB)\n";
error_log('Requesting a public folder without a trailing slash, redirecting to "' . $uriPath . '/"', E_NOTICE); redirect($uriPath . '/'); // Redirect naar dezelfde url, maar dan als mapnaam } $extension = strtolower(file_extension($filename)); if (in_array($extension, array('js', 'css', 'png', 'jpeg', 'jpg'))) { $minifiedPathname = TMP_DIR . 'minify' . substr($filename, strlen($modulePath)); if (file_exists($minifiedPathname) == false || filemtime($minifiedPathname) < filemtime($filename)) { // Is het cache bestand niet up2date? require_once $modulePath . '/core/bootstrap.php'; if ($extension === 'js') { $minified = \JSMinPlus::minify(file_get_contents($filename), $filename); } elseif ($extension === 'css') { $minified = \CssMin::minify(file_get_contents($filename)); } else { $minified = ImageOptimizer::minify(file_get_contents($filename), $filename); } mkdirs(dirname($minifiedPathname)); if ($minified === false) { // Minify failed? copy($filename, $minifiedPathname); // Use full version } else { file_put_contents($minifiedPathname, $minified); } } render_file($minifiedPathname); } render_file($filename); // Render het gewone bestand. }