/** * @internal Returns a CSS resource * @attribute[RequestParam('res','string')] */ function skin($res) { $res = explode("?", $res); $res = realpath(__DIR__ . "/../../skin/" . $res[0]); header('Content-Type: text/css'); WdfResource::ValidatedCacheResponse($res); readfile($res); die; }
/** * @internal Compiles a LESS file to CSS and delivers that to the browser * @attribute[RequestParam('file','string')] */ function CompileLess($file) { $less = resFile(basename($file), true); $css = sys_get_temp_dir() . '/' . md5($file) . '.css'; $cacheFile = sys_get_temp_dir() . '/' . md5($file) . '.cache'; header('Content-Type: text/css'); if (file_exists($css) && file_exists($cacheFile)) { $cache = unserialize(file_get_contents($cacheFile)); } else { $cache = $less; } require_once __DIR__ . '/lessphp/lessc.inc.php'; $compiler = new \lessc(); $newCache = $compiler->cachedCompile($cache); if (!is_array($cache) || $newCache["updated"] > $cache["updated"]) { file_put_contents($cacheFile, serialize($newCache)); file_put_contents($css, $newCache['compiled']); } WdfResource::ValidatedCacheResponse($less); readfile($css); die; }