r4073 minor change in UI for recent change: VST form commit on ENTER and hints on...
[racktables] / index.php
index 454e410..50f1a43 100644 (file)
--- a/index.php
+++ b/index.php
@@ -3,28 +3,18 @@ ob_start();
 try {
 require 'inc/interface.php';
 require 'inc/init.php';
+prepareNavigation();
 // no ctx override is necessary
-redirectIfNecessary();
 fixContext();
+redirectIfNecessary();
 if (!permitted())
        renderAccessDenied();
+header ('Content-Type: text/html; charset=UTF-8');
 // Only store the tab name after clearance is got. Any failure is unhandleable.
-$_SESSION['RTLT'][$pageno] = $tabno;
+if (isset ($_REQUEST['tab']) and ! isset ($_SESSION['RTLT'][$pageno]['dont_remember']))
+       $_SESSION['RTLT'][$pageno] = array ('tabname' => $tabno, 'time' => time());
 
-echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
-echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'."\n";
-echo '<head><title>' . getTitle ($pageno) . "</title>\n";
-echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
-echo "<link rel=stylesheet type='text/css' href=pi.css />\n";
-echo "<link rel=icon href='" . getFaviconURL() . "' type='image/x-icon' />";
-printStyle();
 ?>
-       <script language='javascript' type='text/javascript' src='js/racktables.js'></script>
-       <script language='javascript' type='text/javascript' src='js/jquery-1.3.1.min.js'></script>
-       <script language='javascript' type='text/javascript' src='js/live_validation.js'></script>
-       <script language='javascript' type='text/javascript' src='js/codepress/codepress.js'></script>
-       </head>
-<body>
  <table border=0 cellpadding=0 cellspacing=0 width='100%' height='100%' class=maintable>
  <tr class=mainheader>
   <td colspan=2>
@@ -63,27 +53,27 @@ if (isset ($tabhandler[$pageno][$tabno]))
                switch ($page[$pageno]['bypass_type'])
                {
                        case 'uint':
-                               assertUIntArg ($page[$pageno]['bypass'], 'index');
+                               assertUIntArg ($page[$pageno]['bypass']);
                                break;
                        case 'uint0':
-                               assertUIntArg ($page[$pageno]['bypass'], 'index', TRUE);
+                               assertUIntArg ($page[$pageno]['bypass'], TRUE);
                                break;
                        case 'inet4':
-                               assertIPv4Arg ($page[$pageno]['bypass'], 'index');
+                               assertIPv4Arg ($page[$pageno]['bypass']);
                                break;
                        case 'string':
-                               assertStringArg ($page[$pageno]['bypass'], 'index');
+                               assertStringArg ($page[$pageno]['bypass']);
                                break;
                        default:
-                               throw new RuntimeException ('Dispatching error for bypass parameter');
+                               throw new RackTablesError ('Dispatching error for bypass parameter', RackTablesError::INTERNAL);
                }
                showMessageOrError();
-               $tabhandler[$pageno][$tabno] ($_REQUEST[$page[$pageno]['bypass']]);
+               call_user_func ($tabhandler[$pageno][$tabno], $_REQUEST[$page[$pageno]['bypass']]);
        }
        else
        {
                showMessageOrError();
-               $tabhandler[$pageno][$tabno] ();
+               call_user_func ($tabhandler[$pageno][$tabno]);
        }
 }
 elseif (isset ($page[$pageno]['handler']))
@@ -92,16 +82,24 @@ elseif (isset ($page[$pageno]['handler']))
        $page[$pageno]['handler'] ($tabno);
 }
 else
-       throw new RuntimeException ("Failed to find handler for page '${pageno}', tab '${tabno}'");
+       throw new RackTablesError ("Failed to find handler for page '${pageno}', tab '${tabno}'", RackTablesError::INTERNAL);
 ?>
        </td>
        </tr>
        </table>
-</body>
-</html>
 <?php
-       ob_end_flush();
+       $body = ob_get_clean();
+       ob_start();
+       echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
+       echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">'."\n";
+       echo '<head><title>' . getTitle ($pageno) . "</title>\n";
+       printPageHeaders();
+       echo "</head>\n";
+       echo "<body>\n$body</body>\n";
+       echo '</html>';
+       ob_flush();
 } catch (Exception $e) {
        ob_end_clean();
        printException($e);
 }
+