Exemple #1
0
function proxyStaticURI($URI)
{
    $content_type = array('css' => 'text/css', 'js' => 'text/javascript', 'html' => 'text/html', 'png' => 'image/png', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'ico' => 'image/x-icon');
    $matches = array();
    if (!preg_match(RE_STATIC_URI, $URI, $matches) or !in_array($matches[1], array('pix', 'css', 'js')) or !array_key_exists(strtolower($matches[2]), $content_type)) {
        printStatic404();
    }
    global $local_staticdir, $racktables_staticdir;
    if (isset($local_staticdir)) {
        $fh = @fopen("{$local_staticdir}/{$URI}", 'r');
    }
    if (!isset($fh) or FALSE === $fh) {
        $fh = @fopen("{$racktables_staticdir}/{$URI}", 'r');
    }
    if (FALSE === $fh) {
        printStatic404();
    }
    if (FALSE !== ($stat = fstat($fh))) {
        if (checkCachedResponse(max($stat['mtime'], $stat['ctime']), 0)) {
            exit;
        }
    }
    header('Content-type: ' . $content_type[$matches[2]]);
    fpassthru($fh);
    fclose($fh);
}
Exemple #2
0
         ob_clean();
         printSVGMessageBar('RT error: ' . $e->getMessage(), array(), array('fill' => 'red', 'stroke' => 'black'));
     } catch (Exception $e) {
         ob_clean();
         printSVGMessageBar('unknown error', array(), array('fill' => 'red', 'stroke' => 'black'));
     }
     break;
 case 'progressbar' == $_REQUEST['module']:
     # Unlike images (and like static content), progress bars are processed
     # without a permission check, but only for authenticated users.
     require_once 'inc/init.php';
     require_once 'inc/solutions.php';
     try {
         genericAssertion('done', 'uint0');
         // 'progressbar's never change, make browser cache the result
         if (checkCachedResponse(0, CACHE_DURATION)) {
             break;
         }
         renderProgressBarImage($_REQUEST['done']);
     } catch (Exception $e) {
         ob_clean();
         renderProgressBarError();
     }
     break;
 case 'progressbar4' == $_REQUEST['module']:
     # Unlike images (and like static content), progress bars are processed
     # without a permission check, but only for authenticated users.
     require_once 'inc/init.php';
     require_once 'inc/solutions.php';
     try {
         renderProgressBar4Image($_REQUEST['px1'], $_REQUEST['px2'], $_REQUEST['px3']);