return long2ip($quad);
}
+// translate static URI
+function TSURI ($URI)
+{
+ global $racktables_static_dir;
+ if (! isset ($racktables_static_dir))
+ return $URI;
+ return "?module=tsuri&uri=${URI}";
+}
+
+// make "A" HTML element
function mkA ($text, $nextpage, $bypass = NULL, $nexttab = NULL)
{
global $page, $tab;
return '<a href="' . makeHref ($args) . '">' . $text . '</a>';
}
+// make "HREF" HTML attribute
function makeHref($params = array())
{
$ret = 'index.php?';
if ($item['type'] == 'inline')
echo '<style type="text/css">' . "\n" . trim ($item['style'], "\r\n") . "\n</style>\n";
elseif ($item['type'] == 'file')
- echo '<link rel="stylesheet" type="text/css" href="' . htmlspecialchars ($item['style']) . "\" />\n";
+ echo '<link rel="stylesheet" type="text/css" href="' . TSURI ($item['style']) . "\" />\n";
// add JS scripts
foreach (addJS (NULL) as $group_name => $js_list)
if ($item['type'] == 'inline')
echo '<script type="text/javascript">' . "\n" . trim ($item['script'], "\r\n") . "\n</script>\n";
elseif ($item['type'] == 'file')
- echo '<script type="text/javascript" src="' . htmlspecialchars($item['script']) . "\"></script>\n";
+ echo '<script type="text/javascript" src="' . TSURI ($item['script']) . "\"></script>\n";
}
function strerror8021Q ($errno)
return NULL;
}
+function proxyStaticURI ($URI)
+{
+ $content_type = array
+ (
+ 'css' => 'text/css',
+ 'js' => 'text/javascript',
+ 'html' => 'text/html',
+ 'png' => 'image/png',
+ 'gif' => 'image/gif',
+ );
+ global $racktables_static_dir;
+ $my_static_root = isset ($racktables_static_dir) ? $racktables_static_dir : '.';
+ $file_path = $my_static_root . '/' . $URI;
+ if (! file_exists ($file_path))
+ {
+ header ('404 Not Found');
+?><!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<html><head>
+<title>404 Not Found</title>
+</head><body>
+<h1>Not Found</h1>
+<p>The requested file was not found in this instance.</p>
+<hr>
+<address>RackTables static content proxy</address>
+</body></html><?php
+ exit;
+ }
+ $extension = preg_replace ('/^.+\.([a-z]+)$/', '$1', $URI);
+ header ('Content-type: ' . $content_type[$extension]);
+ readfile ($file_path);
+}
+
?>
echo getImageHREF ($tag, $title, $do_input, $tabindex);
}
+// this would be better called mkIMG(), make "IMG" HTML element
function getImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0)
{
global $image;
if (!isset ($image[$tag]))
$tag = 'error';
$img = $image[$tag];
+ $img['path'] = TSURI ($img['path']);
if ($do_input == TRUE)
return
"<input type=image name=submit class=icon " .
<?php
ob_start();
try {
-require 'inc/interface.php';
require 'inc/init.php';
+if (array_key_exists ('module', $_REQUEST))
+{
+ switch ($_REQUEST['module'])
+ {
+ case 'tsuri':
+ genericAssertion ('uri', 'string');
+ proxyStaticURI ($_REQUEST['uri']);
+ break;
+ default:
+ throw new InvalidRequestArgException ('module', $_REQUEST['module']);
+ }
+ exit;
+}
+
+require 'inc/interface.php';
prepareNavigation();
// no ctx override is necessary
fixContext();