r2169 - add some comments for future reference
[racktables] / index.php
index 9f5edf1..da9c9c7 100644 (file)
--- a/index.php
+++ b/index.php
@@ -1,11 +1,20 @@
 <?php
 
 require 'inc/init.php';
-authorize();
+// no ctx override is necessary
+fixContext();
+if (!permitted())
+{
+       renderAccessDenied();
+       die;
+}
+// Only store the tab name after clearance is got. Any failure is unhandleable.
+setcookie ('RTLT-' . $pageno, $tabno, time() + getConfigVar ('COOKIE_TTL'));
 
 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, $tabno) . "</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' />";
 echo "<style type='text/css'>\n";
@@ -19,23 +28,9 @@ foreach (array ('F', 'A', 'U', 'T', 'Th', 'Tw', 'Thw') as $statecode)
        echo "}\n\n";
 }
 ?>
-.validation-error {
-       border:1px solid red;
-}
-
-.validation-success {
-       border:1px solid green;
-}
        </style>
-       <script language='javascript' type='text/javascript' src='live_validation.js'></script>
-       <script type="text/javascript">
-       function init() {
-               document.add_new_range.range.setAttribute('match', "^\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\.\\d\\d?\\d?\\/\\d\\d?$");
-
-               Validate.init();
-       }
-       window.onload=init;
-       </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>
@@ -69,10 +64,34 @@ foreach (array ('F', 'A', 'U', 'T', 'Th', 'Tw', 'Thw') as $statecode)
  <tr>
   <td colspan=2>
 <?php
-if (isset ($page[$pageno]['handler']))
+if (isset ($tabhandler[$pageno][$tabno]))
+{
+       if (isset ($page[$pageno]['bypass']) && isset ($page[$pageno]['bypass_type']))
+       {
+               switch ($page[$pageno]['bypass_type'])
+               {
+                       case 'uint':
+                               assertUIntArg ($page[$pageno]['bypass'], 'index');
+                               break;
+                       case 'uint0':
+                               assertUIntArg ($page[$pageno]['bypass'], 'index', TRUE);
+                               break;
+                       case 'inet4':
+                               assertIPv4Arg ($page[$pageno]['bypass'], 'index');
+                               break;
+                       default:
+                               showError ('Dispatching error for bypass parameter', __FILE__);
+                               break;
+               }
+               $tabhandler[$pageno][$tabno] ($_REQUEST[$page[$pageno]['bypass']]);
+       }
+       else
+               $tabhandler[$pageno][$tabno] ();
+}
+elseif (isset ($page[$pageno]['handler']))
        $page[$pageno]['handler'] ($tabno);
 else
-       showError ("Failed to find handler for page '${pageno}'");
+       showError ("Failed to find handler for page '${pageno}', tab '${tabno}'", __FILE__);
 ?>
        </td>
        </tr>