if (isset($_GET['pdf'])) {
     $pdf = $_GET['pdf'];
     exportFile(PATH_TEMPLATES . '/' . $pdf . '.pdf');
 } else {
     if (isset($_GET['erd'])) {
         //define ('PATH_TMP',SRC_ROOT.'/sites/tmp/');
         $erd = rawurldecode($_GET['erd']);
         // export research data
         /*
         		if (file_exists($erd)) {
         			$pi=pathinfo($erd);
         			var_dump($pi);
         		} else {
         			echo $erd.'does not exst'; 
         		}		*/
         exportFile($erd);
         unlink($erd);
     } else {
         if (isset($_GET['m'])) {
             $m = $_GET['m'];
             switch ($m) {
                 case 'widget':
                     // local iframe - from widget
                     if (isset($_GET['id'])) {
                         if (!is_numeric($_GET['id'])) {
                             exit;
                         }
                         require_once PATH_CORE . '/classes/widgets.class.php';
                         $wt = new WidgetsTable();
                         $code .= $wt->fetchWidgetCode($_GET['id']);
                     } else {
<?php

/* Cache file server */
// serves CSS and JS files via HTTP
if (isset($_GET['cf'])) {
    $cf = $_GET['cf'];
    exportFile(PATH_CACHE . '/' . $cf);
}
function exportFile($path = '')
{
    if (file_exists($path)) {
        $pi = pathinfo($path);
        // ,PATHINFO_EXTENSION
        switch ($pi['extension']) {
            default:
                $contentType = 'text/html';
                break;
            case 'css':
                $contentType = 'text/css';
                break;
            case 'js':
                $contentType = 'text/javascript';
                break;
        }
        header("Content-type: " . $contentType);
        readfile($path);
    } else {
        die;
    }
}