vastly simplified .htaccess and cleaned up how we use variables a little

git-svn-id: http://www.observium.org/svn/observer/trunk@2446 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2011-09-12 04:57:56 +00:00
parent 399b00589a
commit 99c6fc3e65
14 changed files with 128 additions and 148 deletions

View File

@@ -8,44 +8,12 @@ RewriteCond %{REQUEST_URI} !^(.*)\.jpg$
RewriteCond %{REQUEST_URI} !^(.*)\.gif$ RewriteCond %{REQUEST_URI} !^(.*)\.gif$
RewriteCond %{REQUEST_URI} !^(.*)\.png$ RewriteCond %{REQUEST_URI} !^(.*)\.png$
RewriteRule ^cust/ ?page=cust RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6&optf=$7&optg=$8&opth=$9
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6&optf=$7&optg=$8
RewriteRule ^bare/(.+)/ index-bare.php?page=$1 RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6&optf=$7
RewriteRule ^bare/(.+)/(.+)/ index-bare.php?page=$1&opta=$2 RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6
RewriteRule ^bare/(.+)/(.+)/(.+)/ index-bare.php?page=$1&opta=$2&optb=$3 RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4
RewriteRule ^mobile/([a-z|0-9]+)/(.+)/(.+)/ mobile.php?page=$1&opta=$2&optb=$3 RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3
RewriteRule ^mobile/([a-z|0-9]+)/(.+)/ mobile.php?page=$1&opta=$2 RewriteRule ^([a-z|0-9]+)/(.+)/$ ?page=$1&opta=$2
RewriteRule ^mobile/([a-z|0-9]+)/ mobile.php?page=$1 RewriteRule ^([a-z|0-9]+)/$ ?page=$1
RewriteRule ^mobile/ mobile.php
## Rewrites for Devices
RewriteRule ^devices/location/(.+)/ ?page=devices&location=$1
RewriteRule ^devices/alerted/ ?page=devices&status=alerted
RewriteRule ^devices/alerted/ ?page=devices&status=alerted
RewriteRule ^devices/(.+)/ ?page=devices&type=$1
RewriteRule ^interfaces/(.+)/ ?page=interfaces&type=$1
RewriteRule ^vrf/(.+)/(.+)/(.+)/ ?page=vrf&id=$1&opta=$2&optb=$3
RewriteRule ^vrf/(.+)/(.+)/ ?page=vrf&id=$1&opta=$2
RewriteRule ^vrf/(.+)/ ?page=vrf&id=$1
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7&optf=$8&optg=$9
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7&optf=$8
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4&optc=$5&optd=$6&opte=$7
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4&optc=$5&optd=$6
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4&optc=$5
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3&optb=$4
RewriteRule ^device/([0-9]+)/([a-z]+)/(.+)/ ?page=device&id=$1&section=$2&opta=$3
RewriteRule ^device/([0-9]+)/([a-z]+)/ ?page=device&id=$1&section=$2
RewriteRule ^device/([0-9]+) ?page=device&id=$1
RewriteRule ^([a-z|0-9\-]+)/$ ?page=$1
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5&opte=$6
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4&optd=$5
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3&optc=$4
RewriteRule ^([a-z|0-9]+)/(.+)/(.+)/$ ?page=$1&opta=$2&optb=$3
RewriteRule ^([a-z|0-9]+)/(.+)/$ ?page=$1&opta=$2

View File

@@ -217,7 +217,7 @@ if ($config['show_locations'])
<?php <?php
foreach (getlocations() as $location) foreach (getlocations() as $location)
{ {
echo(' <li><a href="?page=devices&amp;location=' . urlencode($location) . '"><img src="images/16/building.png" border="0" align="absmiddle" /> ' . $location . ' </a></li>'); echo(' <li><a href="devices/location|' . urlencode($location) . '/"><img src="images/16/building.png" border="0" align="absmiddle" /> ' . $location . ' </a></li>');
} }
?> ?>
</ul> </ul>

View File

@@ -1,18 +1,18 @@
<?php <?php
if ($_GET['id']) { $_GET['id'] = mres($_GET['id']); } if ($_GET['opta']) { $_GET['opta'] = mres($_GET['opta']); }
if ($_GET['section'] == "port" && is_numeric($_GET['opta']) && port_permitted($_GET['opta'])) if ($_GET['optb'] == "port" && is_numeric($_GET['opta']) && port_permitted($_GET['optc']))
{ {
$check_device = get_device_id_by_interface_id($_GET['opta']); $check_device = get_device_id_by_interface_id($_GET['opta']);
$permit_ports = 1; $permit_ports = 1;
} }
if (device_permitted($_GET['id']) || $check_device == $_GET['id']) if (device_permitted($_GET['opta']) || $check_device == $_GET['opta'])
{ {
$selected['iface'] = "selected"; $selected['iface'] = "selected";
$section = str_replace(".", "", mres($_GET['section'])); $section = str_replace(".", "", mres($_GET['optb']));
if (!$section) if (!$section)
{ {
@@ -21,7 +21,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
$select[$section] = "selected"; $select[$section] = "selected";
$device = device_by_id_cache($_GET['id']); $device = device_by_id_cache($_GET['opta']);
$attribs = get_dev_attribs($device['device_id']); $attribs = get_dev_attribs($device['device_id']);
if ($config['os'][$device['os']]['group']) { $device['os_group'] = $config['os'][$device['os']]['group']; } if ($config['os'][$device['os']]['group']) { $device['os_group'] = $config['os'][$device['os']]['group']; }
@@ -252,7 +252,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
echo("</ul>"); echo("</ul>");
} }
if(device_permitted($device['device_id']) || $check_device == $_GET['id']) { if(device_permitted($device['device_id']) || $check_device == $_GET['opta']) {
echo('<div class="contentstyle">'); echo('<div class="contentstyle">');
include("pages/device/".mres(basename($section)).".inc.php"); include("pages/device/".mres(basename($section)).".inc.php");

View File

@@ -10,27 +10,27 @@ foreach (dbFetchRows("SELECT * FROM `applications` WHERE `device_id` = ?", array
{ {
echo($sep); echo($sep);
if (!$_GET['opta']) { $_GET['opta'] = $app['app_type']; } if (!$_GET['optc']) { $_GET['optc'] = $app['app_type']; }
if ($_GET['opta'] == $app['app_type']) if ($_GET['optc'] == $app['app_type'])
{ {
echo("<span class='pagemenu-selected'>"); echo("<span class='pagemenu-selected'>");
#echo('<img src="images/icons/'.$app['app_type'].'.png" class="optionicon" />'); #echo('<img src="images/icons/'.$app['app_type'].'.png" class="optionicon" />');
} else { } else {
#echo('<img src="images/icons/greyscale/'.$app['app_type'].'.png" class="optionicon" />'); #echo('<img src="images/icons/greyscale/'.$app['app_type'].'.png" class="optionicon" />');
} }
echo("<a href='device/".$device['device_id']."/apps/" . $app['app_type'] . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $app['app_type'] ."</a>"); echo("<a href='device/".$device['device_id']."/apps/" . $app['app_type'] . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . $app['app_type'] ."</a>");
if ($_GET['opta'] == $app['app_type']) { echo("</span>"); } if ($_GET['optc'] == $app['app_type']) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
print_optionbar_end(); print_optionbar_end();
$app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?", array($device['device_id'], $_GET['opta'])); $app = dbFetchRow("SELECT * FROM `applications` WHERE `device_id` = ? AND `app_type` = ?", array($device['device_id'], $_GET['optc']));
if (is_file("pages/device/apps/".mres($_GET['opta']).".inc.php")) if (is_file("pages/device/apps/".mres($_GET['optc']).".inc.php"))
{ {
include("pages/device/apps/".mres($_GET['opta']).".inc.php"); include("pages/device/apps/".mres($_GET['optc']).".inc.php");
} }
?> ?>

View File

@@ -51,11 +51,11 @@ print_optionbar_start();
$plugins = collectd_list_plugins($device['hostname']); $plugins = collectd_list_plugins($device['hostname']);
unset($sep); unset($sep);
foreach ($plugins as &$plugin) { foreach ($plugins as &$plugin) {
if (!$_GET['opta']) { $_GET['opta'] = $plugin; } if (!$_GET['optc']) { $_GET['optc'] = $plugin; }
echo($sep); echo($sep);
if ($_GET['opta'] == $plugin) { echo("<span class='pagemenu-selected'>"); } if ($_GET['optc'] == $plugin) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='device/" . $device['device_id'] . "/collectd/" . $plugin . "/'>" . htmlspecialchars($plugin) ."</a>"); echo("<a href='device/" . $device['device_id'] . "/collectd/" . $plugin . "/'>" . htmlspecialchars($plugin) ."</a>");
if ($_GET['opta'] == $plugin) { echo("</span>"); } if ($_GET['optc'] == $plugin) { echo("</span>"); }
$sep = ' | '; $sep = ' | ';
} }
unset ($sep); unset ($sep);
@@ -64,13 +64,13 @@ print_optionbar_end();
$i=0; $i=0;
$pinsts = collectd_list_pinsts($device['hostname'], $_GET['opta']); $pinsts = collectd_list_pinsts($device['hostname'], $_GET['optc']);
foreach ($pinsts as &$instance) { foreach ($pinsts as &$instance) {
$types = collectd_list_types($device['hostname'], $_GET['opta'], $instance); $types = collectd_list_types($device['hostname'], $_GET['optc'], $instance);
foreach ($types as &$type) { foreach ($types as &$type) {
$typeinstances = collectd_list_tinsts($device['hostname'], $_GET['opta'], $instance, $type); $typeinstances = collectd_list_tinsts($device['hostname'], $_GET['optc'], $instance, $type);
if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); } if ($MetaGraphDefs[$type]) { $typeinstances = array($MetaGraphDefs[$type]); }
@@ -81,16 +81,16 @@ print_optionbar_end();
echo('<div style="background-color: '.$row_colour.';">'); echo('<div style="background-color: '.$row_colour.';">');
echo('<div class="graphhead" style="padding:4px 0px 0px 8px;">'); echo('<div class="graphhead" style="padding:4px 0px 0px 8px;">');
if ($tinst) { if ($tinst) {
echo($_GET['opta']." $instance - $type - $tinst"); echo($_GET['optc']." $instance - $type - $tinst");
} else { } else {
echo($_GET['opta']." $instance - $type"); echo($_GET['optc']." $instance - $type");
} }
echo("</div>"); echo("</div>");
$graph_array['type'] = "device_collectd"; $graph_array['type'] = "device_collectd";
$graph_array['id'] = $device['device_id']; $graph_array['id'] = $device['device_id'];
$graph_array['c_plugin'] = $_GET['opta']; $graph_array['c_plugin'] = $_GET['optc'];
$graph_array['c_plugin_instance'] = $instance; $graph_array['c_plugin_instance'] = $instance;
$graph_array['c_type'] = $type; $graph_array['c_type'] = $type;
$graph_array['c_type_instance'] = $tinst; $graph_array['c_type_instance'] = $tinst;

View File

@@ -25,9 +25,9 @@ if ($_SESSION['userlevel'] < '7')
unset($sep); unset($sep);
foreach ($panes as $type => $text) foreach ($panes as $type => $text)
{ {
if (!isset($_GET['opta'])) { $_GET['opta'] = $type; } if (!isset($_GET['optc'])) { $_GET['optc'] = $type; }
echo($sep); echo($sep);
if ($_GET['opta'] == $type) if ($_GET['optc'] == $type)
{ {
echo("<span class='pagemenu-selected'>"); echo("<span class='pagemenu-selected'>");
#echo('<img src="images/icons/'.$type.'.png" class="optionicon" />'); #echo('<img src="images/icons/'.$type.'.png" class="optionicon" />');
@@ -35,16 +35,16 @@ if ($_SESSION['userlevel'] < '7')
#echo('<img src="images/icons/greyscale/'.$type.'.png" class="optionicon" />'); #echo('<img src="images/icons/greyscale/'.$type.'.png" class="optionicon" />');
} }
echo("<a href='device/".$device['device_id']."/edit/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $text ."</a>"); echo("<a href='device/".$device['device_id']."/edit/" . $type . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . $text ."</a>");
if ($_GET['opta'] == $type) { echo("</span>"); } if ($_GET['optc'] == $type) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
print_optionbar_end(); print_optionbar_end();
if (is_file("pages/device/edit/".mres($_GET['opta']).".inc.php")) if (is_file("pages/device/edit/".mres($_GET['optc']).".inc.php"))
{ {
include("pages/device/edit/".mres($_GET['opta']).".inc.php"); include("pages/device/edit/".mres($_GET['optc']).".inc.php");
} }
} }

View File

@@ -24,15 +24,15 @@ foreach ($config['graph_sections'] as $section)
if (isset($graph_enable) && is_array($graph_enable[$section])) if (isset($graph_enable) && is_array($graph_enable[$section]))
{ {
$type = strtolower($section); $type = strtolower($section);
if (!$_GET['opta']) { $_GET['opta'] = $type; } if (!$_GET['optc']) { $_GET['optc'] = $type; }
echo($sep); echo($sep);
if ($_GET['opta'] == $type) if ($_GET['optc'] == $type)
{ {
echo('<span class="pagemenu-selected">'); echo('<span class="pagemenu-selected">');
} }
echo("<a href='device/".$device['device_id']."/graphs/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . ucfirst($type) ."</a>"); echo("<a href='device/".$device['device_id']."/graphs/" . $type . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . ucfirst($type) ."</a>");
if ($_GET['opta'] == $type) if ($_GET['optc'] == $type)
{ {
echo("</span>"); echo("</span>");
} }
@@ -43,7 +43,7 @@ foreach ($config['graph_sections'] as $section)
unset ($sep); unset ($sep);
print_optionbar_end(); print_optionbar_end();
$graph_enable = $graph_enable[$_GET['opta']]; $graph_enable = $graph_enable[$_GET['optc']];
foreach ($config['graph_types']['device'] as $graph => $entry) foreach ($config['graph_types']['device'] as $graph => $entry)
{ {

View File

@@ -44,28 +44,28 @@ print_optionbar_start();
echo("<span style='font-weight: bold;'>Health</span> &#187; "); echo("<span style='font-weight: bold;'>Health</span> &#187; ");
if (!$_GET['opta']) { $_GET['opta'] = "overview"; } if (!$_GET['optc']) { $_GET['optc'] = "overview"; }
unset($sep); unset($sep);
foreach ($datas as $type) foreach ($datas as $type)
{ {
echo($sep); echo($sep);
if ($_GET['opta'] == $type) if ($_GET['optc'] == $type)
{ {
echo('<span class="pagemenu-selected">'); echo('<span class="pagemenu-selected">');
} }
echo("<a href='device/".$device['device_id']."/health/" . $type . ($_GET['optb'] ? "/" . $_GET['optb'] : ''). "/'> " . $type_text[$type] ."</a>"); echo("<a href='device/".$device['device_id']."/health/" . $type . ($_GET['optd'] ? "/" . $_GET['optd'] : ''). "/'> " . $type_text[$type] ."</a>");
if ($_GET['opta'] == $type) { echo("</span>"); } if ($_GET['optc'] == $type) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
print_optionbar_end(); print_optionbar_end();
if (is_file("pages/device/health/".mres($_GET['opta']).".inc.php")) if (is_file("pages/device/health/".mres($_GET['optc']).".inc.php"))
{ {
include("pages/device/health/".mres($_GET['opta']).".inc.php"); include("pages/device/health/".mres($_GET['optc']).".inc.php");
} else { } else {
foreach ($datas as $type) foreach ($datas as $type)
{ {

View File

@@ -1,8 +1,8 @@
<?php <?php
if (!isset($_GET['optb']) ) { $_GET['optb'] = "graphs"; } if (!isset($_GET['optd']) ) { $_GET['optd'] = "graphs"; }
$interface = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($_GET['opta'])); $interface = dbFetchRow("SELECT * FROM `ports` WHERE `interface_id` = ?", array($_GET['optc']));
$port_details = 1; $port_details = 1;
@@ -51,90 +51,90 @@ echo("<div style='clear: both;'>");
print_optionbar_start(); print_optionbar_start();
if ($_GET['optb'] == "graphs" || !$_GET['optb']) { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "graphs" || !$_GET['optd']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/'>Graphs</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/'>Graphs</a>");
if ($_GET['optb'] == "graphs" || !$_GET['optb']) { echo("</span>"); } if ($_GET['optd'] == "graphs" || !$_GET['optd']) { echo("</span>"); }
echo(" | "); echo(" | ");
if ($_GET['optb'] == "realtime" || !$_GET['optb']) { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "realtime" || !$_GET['optd']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/'>Real Time</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/realtime/'>Real Time</a>");
if ($_GET['optb'] == "realtime" || !$_GET['optb']) { echo("</span>"); } if ($_GET['optd'] == "realtime" || !$_GET['optd']) { echo("</span>"); }
if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$interface['interface_id']."'") ) if (dbFetchCell("SELECT COUNT(*) FROM `ports_adsl` WHERE `interface_id` = '".$interface['interface_id']."'") )
{ {
echo(" | "); echo(" | ");
if ($_GET['optb'] == "adsl") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "adsl") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/port/".$interface['interface_id']."/adsl/'>ADSL</a>"); echo("<a href='".$config['base_url']."/device/".$device['device_id']."/port/".$interface['interface_id']."/adsl/'>ADSL</a>");
if ($_GET['optb'] == "adsl") { echo("</span>"); } if ($_GET['optd'] == "adsl") { echo("</span>"); }
} }
echo(" | "); echo(" | ");
if ($_GET['optb'] == "arp") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "arp") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/arp/'>ARP Table</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/arp/'>ARP Table</a>");
if ($_GET['optb'] == "arp") { echo("</span>"); } if ($_GET['optd'] == "arp") { echo("</span>"); }
if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '". if (dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `pagpGroupIfIndex` = '".
$interface['ifIndex']."' and `device_id` = '".$device['device_id']."'") ) $interface['ifIndex']."' and `device_id` = '".$device['device_id']."'") )
{ {
echo(" | "); echo(" | ");
if ($_GET['optb'] == "pagp") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "pagp") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/pagp/'>PAgP</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/pagp/'>PAgP</a>");
if ($_GET['optb'] == "pagp") { echo("</span>"); } if ($_GET['optd'] == "pagp") { echo("</span>"); }
} }
if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'") > "0" ) if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE interface_id = '".$interface['interface_id']."'") > "0" )
{ {
echo(" | Mac Accounting : "); echo(" | Mac Accounting : ");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "bits" && !$_GET['optd']) { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && !$_GET['optf']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/'>Bits</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/'>Bits</a>");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "bits" && !$_GET['optd']) { echo("</span>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && !$_GET['optf']) { echo("</span>"); }
echo("("); echo("(");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "bits" && $_GET['optd'] == "thumbs") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/thumbs/'>Mini</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/thumbs/'>Mini</a>");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "bits" && $_GET['optd'] == "thumbs") { echo("</span>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "thumbs") { echo("</span>"); }
echo('|'); echo('|');
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "bits" && $_GET['optd'] == "top10") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "top10") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/top10/'>Top10</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/bits/top10/'>Top10</a>");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "bits" && $_GET['optd'] == "top10") { echo("</span>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "bits" && $_GET['optf'] == "top10") { echo("</span>"); }
echo(") | "); echo(") | ");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "pkts" && !$_GET['optd']) { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && !$_GET['optf']) { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/'>Packets</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/'>Packets</a>");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "pkts" && !$_GET['optd']) { echo("</span>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && !$_GET['optf']) { echo("</span>"); }
echo("("); echo("(");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "pkts" && $_GET['optd'] == "thumbs") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && $_GET['optf'] == "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/thumbs/'>Mini</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/macaccounting/pkts/thumbs/'>Mini</a>");
if ($_GET['optb'] == "macaccounting" && $_GET['optc'] == "pkts" && $_GET['optd'] == "thumbs") { echo("</span>"); } if ($_GET['optd'] == "macaccounting" && $_GET['opte'] == "pkts" && $_GET['optf'] == "thumbs") { echo("</span>"); }
echo(")"); echo(")");
} }
if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$interface['interface_id']."'") > "0" ) if (dbFetchCell("SELECT COUNT(*) FROM juniAtmVp WHERE interface_id = '".$interface['interface_id']."'") > "0" )
{ {
echo(" | ATM VPs : "); echo(" | ATM VPs : ");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "bits") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/bits/'>Bits</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/bits/'>Bits</a>");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "bits") { echo("</span>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
echo(" | "); echo(" | ");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "packets") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "packets") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/packets/'>Packets</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/packets/'>Packets</a>");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "bits") { echo("</span>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
echo(" | "); echo(" | ");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "cells") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "cells") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/cells/'>Cells</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/cells/'>Cells</a>");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "bits") { echo("</span>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
echo(" | "); echo(" | ");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "errors") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "errors") { echo("<span class='pagemenu-selected'>"); }
echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/errors/'>Errors</a>"); echo("<a href='".$config['base_url']."/device/" . $device['device_id'] . "/port/".$interface['interface_id']."/junose-atm-vp/errors/'>Errors</a>");
if ($_GET['optb'] == "junose-atm-vp" && $_GET['optc'] == "bits") { echo("</span>"); } if ($_GET['optd'] == "junose-atm-vp" && $_GET['opte'] == "bits") { echo("</span>"); }
} }
print_optionbar_end(); print_optionbar_end();
echo("<div style='margin: 5px;'>"); echo("<div style='margin: 5px;'>");
include("pages/device/port/".mres($_GET['optb']).".inc.php"); include("pages/device/port/".mres($_GET['optd']).".inc.php");
echo("</div>"); echo("</div>");
?> ?>

View File

@@ -1,8 +1,8 @@
<?php <?php
if ($_GET['opta'] == 'graphs') if ($_GET['optc'] == 'graphs')
{ {
if ($_GET['optb']) { $graph_type = "port_" . $_GET['optb']; } else { $graph_type = "port_bits"; } if ($_GET['optd']) { $graph_type = "port_" . $_GET['optd']; } else { $graph_type = "port_bits"; }
} }
print_optionbar_start(); print_optionbar_start();
@@ -20,15 +20,15 @@ if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'"))
$menu_options['adsl'] = 'ADSL'; $menu_options['adsl'] = 'ADSL';
} }
if (!$_GET['opta']) { $_GET['opta'] = "basic"; } if (!$_GET['optc']) { $_GET['optc'] = "basic"; }
$sep = ""; $sep = "";
foreach ($menu_options as $option => $text) foreach ($menu_options as $option => $text)
{ {
echo($sep); echo($sep);
if ($_GET['opta'] == $option) { echo("<span class='pagemenu-selected'>"); } if ($_GET['optc'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/' . $option . ($_GET['optb'] ? '/' . $_GET['optb'] : ''). '/">' . $text . '</a>'); echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/' . $option . ($_GET['optd'] ? '/' . $_GET['optd'] : ''). '/">' . $text . '</a>');
if ($_GET['opta'] == $option) { echo("</span>"); } if ($_GET['optc'] == $option) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
@@ -45,21 +45,21 @@ $graph_types = array("bits" => "Bits",
foreach ($graph_types as $type => $descr) foreach ($graph_types as $type => $descr)
{ {
echo("$type_sep"); echo("$type_sep");
if ($_GET['optb'] == $type && $_GET['optc'] != "thumbs") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == $type && $_GET['opte'] != "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/graphs/'.$type.'/">'.$descr.'</a>'); echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/graphs/'.$type.'/">'.$descr.'</a>');
if ($_GET['optb'] == $type && $_GET['optc'] != "thumbs") { echo("</span>"); } if ($_GET['optd'] == $type && $_GET['opte'] != "thumbs") { echo("</span>"); }
echo('('); echo('(');
if ($_GET['optb'] == $type && $_GET['optc'] == "thumbs") { echo("<span class='pagemenu-selected'>"); } if ($_GET['optd'] == $type && $_GET['opte'] == "thumbs") { echo("<span class='pagemenu-selected'>"); }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/graphs/'.$type.'/thumbs/">Mini</a>'); echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/ports/graphs/'.$type.'/thumbs/">Mini</a>');
if ($_GET['optb'] == $type && $_GET['optc'] == "thumbs") { echo("</span>"); } if ($_GET['optd'] == $type && $_GET['opte'] == "thumbs") { echo("</span>"); }
echo(')'); echo(')');
$type_sep = " | "; $type_sep = " | ";
} }
print_optionbar_end(); print_optionbar_end();
if ($_GET['optc'] == thumbs) if ($_GET['opte'] == thumbs)
{ {
$timeperiods = array('-1day','-1week','-1month','-1year'); $timeperiods = array('-1day','-1week','-1month','-1year');
$from = '-1day'; $from = '-1day';
@@ -81,11 +81,11 @@ if ($_GET['optc'] == thumbs)
} }
echo("</div>"); echo("</div>");
} else { } else {
if ($_GET['opta'] == "arp" || $_GET['opta'] == "adsl" || $_GET['opta'] == "neighbours") if ($_GET['optc'] == "arp" || $_GET['optc'] == "adsl" || $_GET['optc'] == "neighbours")
{ {
include("ports/".$_GET['opta'].".inc.php"); include("ports/".$_GET['optc'].".inc.php");
} else { } else {
if ($_GET['opta'] == "details") { $port_details = 1; } if ($_GET['optc'] == "details") { $port_details = 1; }
echo("<div style='margin: 0px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>"); echo("<div style='margin: 0px;'><table border=0 cellspacing=0 cellpadding=5 width=100%>");
$i = "1"; $i = "1";

View File

@@ -14,25 +14,25 @@ unset($sep);
foreach ($routing_tabs as $type) foreach ($routing_tabs as $type)
{ {
if (!$_GET['opta']) { $_GET['opta'] = $type; } if (!$_GET['optc']) { $_GET['optc'] = $type; }
echo($sep); echo($sep);
if ($_GET['opta'] == $type) if ($_GET['optc'] == $type)
{ {
echo('<span class="pagemenu-selected">'); echo('<span class="pagemenu-selected">');
} }
echo("<a href='".$config['base_url']."/device/".$device['device_id']."/routing/" . $type . "/'> " . $type_text[$type] ." (".$device_routing_count[$type].")</a>"); echo("<a href='".$config['base_url']."/device/".$device['device_id']."/routing/" . $type . "/'> " . $type_text[$type] ." (".$device_routing_count[$type].")</a>");
if ($_GET['opta'] == $type) { echo("</span>"); } if ($_GET['optc'] == $type) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
print_optionbar_end(); print_optionbar_end();
if (is_file("pages/device/routing/".mres($_GET['opta']).".inc.php")) if (is_file("pages/device/routing/".mres($_GET['optc']).".inc.php"))
{ {
include("pages/device/routing/".mres($_GET['opta']).".inc.php"); include("pages/device/routing/".mres($_GET['optc']).".inc.php");
} else { } else {
foreach ($routing_tabs as $type) foreach ($routing_tabs as $type)
{ {

View File

@@ -5,18 +5,18 @@ echo("<span style='font-weight: bold;'>Services</span> &#187; ");
$menu_options = array('basic' => 'Basic', $menu_options = array('basic' => 'Basic',
'details' => 'Details'); 'details' => 'Details');
if (!$_GET['opta']) { $_GET['opta'] = "basic"; } if (!$_GET['optc']) { $_GET['optc'] = "basic"; }
$sep = ""; $sep = "";
foreach ($menu_options as $option => $text) foreach ($menu_options as $option => $text)
{ {
echo($sep); echo($sep);
if ($_GET['opta'] == $option) if ($_GET['optc'] == $option)
{ {
echo("<span class='pagemenu-selected'>"); echo("<span class='pagemenu-selected'>");
} }
echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/services/' . $option . ($_GET['optb'] ? '/' . $_GET['optb'] : ''). '/">' . $text . '</a>'); echo('<a href="'.$config['base_url'].'/device/' . $device['device_id'] . '/services/' . $option . ($_GET['optd'] ? '/' . $_GET['optd'] : ''). '/">' . $text . '</a>');
if ($_GET['opta'] == $option) if ($_GET['optc'] == $option)
{ {
echo("</span>"); echo("</span>");
} }
@@ -35,7 +35,7 @@ if (dbFetchCell("SELECT COUNT(service_id) FROM `services` WHERE device_id = ?",
{ {
include("includes/print-service.inc.php"); include("includes/print-service.inc.php");
if ($_GET['opta'] == "details") if ($_GET['optc'] == "details")
{ {
$graph_array['height'] = "100"; $graph_array['height'] = "100";
$graph_array['width'] = "210"; $graph_array['width'] = "210";

View File

@@ -19,7 +19,7 @@ if ($_SESSION['userlevel'] >= "7")
echo("<span style='font-weight: bold;'>Config</span> &#187; "); echo("<span style='font-weight: bold;'>Config</span> &#187; ");
if (!$_GET['opta']) { if (!$_GET['optc']) {
echo('<span class="pagemenu-selected">'); echo('<span class="pagemenu-selected">');
echo("<a href='device/".$device['device_id']."/showconfig/'> Latest</a>"); echo("<a href='device/".$device['device_id']."/showconfig/'> Latest</a>");
echo("</span>"); echo("</span>");
@@ -38,10 +38,10 @@ if ($_SESSION['userlevel'] >= "7")
echo($sep); echo($sep);
$revlist[] = $svnlog["rev"]; $revlist[] = $svnlog["rev"];
if ($_GET['opta'] == $svnlog["rev"]) { echo('<span class="pagemenu-selected">'); } if ($_GET['optc'] == $svnlog["rev"]) { echo('<span class="pagemenu-selected">'); }
echo("<a href='device/".$device['device_id']."/showconfig/" . $svnlog["rev"] . "/'> r" . $svnlog["rev"] ." <small>". date("d M H:i", strtotime($svnlog["date"])) . "</small></a>"); echo("<a href='device/".$device['device_id']."/showconfig/" . $svnlog["rev"] . "/'> r" . $svnlog["rev"] ." <small>". date("d M H:i", strtotime($svnlog["date"])) . "</small></a>");
if ($_GET['opta'] == $svnlog["rev"]) { echo("</span>"); } if ($_GET['optc'] == $svnlog["rev"]) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
@@ -49,8 +49,8 @@ if ($_SESSION['userlevel'] >= "7")
print_optionbar_end(); print_optionbar_end();
if (function_exists('svn_log') && in_array($_GET['opta'], $revlist)) { if (function_exists('svn_log') && in_array($_GET['optc'], $revlist)) {
list($diff, $errors) = svn_diff($file, $_GET['opta']-1, $file, $_GET['opta']); list($diff, $errors) = svn_diff($file, $_GET['optc']-1, $file, $_GET['optc']);
if (!$diff) { if (!$diff) {
$text = "No Difference"; $text = "No Difference";
} else { } else {

View File

@@ -1,18 +1,30 @@
<?php <?php
### FIXME - this code might suck cock. is there a better way?
### Turn /devices/os|linux/location|France/ into
### $_POST[os] = "linux"; $_POST['location'] = "France"
foreach($_GET as $key=>$get_var) {
if(strstr($key, "opt")) {
list($name, $value) = explode("|", $get_var);
$_POST[$name] = $value;
}
}
### FIXME - build this string in new method
if ($_POST['hostname']) { $where .= " AND hostname LIKE '%".mres($_POST['hostname'])."%'"; } if ($_POST['hostname']) { $where .= " AND hostname LIKE '%".mres($_POST['hostname'])."%'"; }
if ($_POST['os']) { $where .= " AND os = '".mres($_POST['os'])."'"; } if ($_POST['os']) { $where .= " AND os = '".mres($_POST['os'])."'"; }
if ($_POST['version']) { $where .= " AND version = '".mres($_POST['version'])."'"; } if ($_POST['version']) { $where .= " AND version = '".mres($_POST['version'])."'"; }
if ($_POST['hardware']) { $where .= " AND hardware = '".mres($_POST['hardware'])."'"; } if ($_POST['hardware']) { $where .= " AND hardware = '".mres($_POST['hardware'])."'"; }
if ($_POST['features']) { $where .= " AND features = '".mres($_POST['features'])."'"; } if ($_POST['features']) { $where .= " AND features = '".mres($_POST['features'])."'"; }
if ($_GET['type']) { $where .= " AND type = '" .mres($_GET[type]). "'"; }
if (isset($_REQUEST['location'])) if ($_GET['location'] == "Unset") { $location_filter = ''; }
{ if ($_GET['location'] && !isset($_POST['location'])) { $location_filter = $_GET['location']; }
if ($_GET['location'] == "Unset") { $location_filter = ''; } if ($_POST['location']) { $location_filter = $_POST['location']; }
if ($_GET['location'] && !isset($_POST['location'])) { $location_filter = $_GET['location']; }
if ($_POST['location']) { $location_filter = $_POST['location']; } print_r($_POST);
}
print_optionbar_start(62); print_optionbar_start(62);
?> ?>