tpl->addExtension($_ctx); $core->tpl->getLoader()->addPath(dirname(__FILE__).'/admin/default-templates'); // TODO: Find a better way to add plugins templates paths # --BEHAVIOR-- adminPrepend $core->callBehavior('adminPrepend',$core,$_ctx); } else { // TODO: dcPublicContext ... //$core->tpl->getLoader()->addPath(dirname(__FILE__).'/public/default-templates'); } # Clean up requested filename $f = path::clean($_GET['tf']); # Find templates paths then plugins paths $paths = $core->tpl->getLoader()->getPaths(); rsort($paths); // read default-templates last /* // TODO: Find a better way to add plugins templates paths $plugins_paths = array_reverse(explode(PATH_SEPARATOR,DC_PLUGINS_ROOT)); $paths = array_merge($paths,$plugins_paths); //*/ # Check all paths to see if file exists foreach ($paths as $path) { $file = path::real($path.'/'.$f); if ($file !== false) { break; } } unset($paths); # Can't find requested file if ($file === false || !is_file($file) || !is_readable($file)) { header('Content-Type: text/plain'); http::head(404,'Not Found'); exit; } # Limit type of files to serve $allow_types = array('png','jpg','jpeg','gif','css','js','swf'); # File extension is not allowed if (!in_array(files::getExtension($file),$allow_types)) { header('Content-Type: text/plain'); http::head(404,'Not Found'); exit; } # Display file http::$cache_max_age = 7200; http::cache(array_merge(array($file),get_included_files())); header('Content-Type: '.files::getMimeType($file)); # Temporary hack css files to regain relative path if (files::getExtension($file) == 'css') { $content = preg_replace( '/url\((\'|)([^:].*?)(\'|)\)/msi', 'url($1?tf='.dirname($f).'/$2$3)', file_get_contents($file) ); header('Content-Length: '.strlen($content)); echo $content; } else { header('Content-Length: '.filesize($file)); readfile($file); } exit; ?>