syntaxer run, removes dos newlines from 2 files

git-svn-id: http://www.observium.org/svn/observer/trunk@2597 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-09-27 13:22:38 +00:00
parent ae558c7dbd
commit 9ff0fdb443
4 changed files with 293 additions and 294 deletions
+172 -172
View File
@@ -1,172 +1,172 @@
<?php <?php
if ($_POST['addbill'] == "yes") if ($_POST['addbill'] == "yes")
{ {
$updated = '1'; $updated = '1';
$insert = array('bill_name' => $_POST['bill_name'], 'bill_type' => $_POST['bill_type'], 'bill_cdr' => $_POST['bill_cdr'], 'bill_day' => $_POST['bill_day'], 'bill_gb' => $_POST['bill_quota'], $insert = array('bill_name' => $_POST['bill_name'], 'bill_type' => $_POST['bill_type'], 'bill_cdr' => $_POST['bill_cdr'], 'bill_day' => $_POST['bill_day'], 'bill_gb' => $_POST['bill_quota'],
'bill_custid' => $_POST['bill_custid'], 'bill_ref' => $_POST['bill_ref'], 'bill_notes' => $_POST['bill_notes']); 'bill_custid' => $_POST['bill_custid'], 'bill_ref' => $_POST['bill_ref'], 'bill_notes' => $_POST['bill_notes']);
$affected = dbInsert($insert, 'bills'); $affected = dbInsert($insert, 'bills');
$message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!"; $message .= $message_break . "Bill ".mres($_POST['bill_name'])." added!";
$message_break .= "<br />"; $message_break .= "<br />";
} }
echo("<meta http-equiv='refresh' content='10000'>"); echo("<meta http-equiv='refresh' content='10000'>");
if ($_GET['opta'] == "add") if ($_GET['opta'] == "add")
{ {
?> ?>
<div style='padding:10px;font-size:20px; font-weight: bold;'>Add Bill</div> <div style='padding:10px;font-size:20px; font-weight: bold;'>Add Bill</div>
<form name="form1" method="post" action="bills/"> <form name="form1" method="post" action="bills/">
<input type=hidden name=addbill value=yes> <input type=hidden name=addbill value=yes>
<div style="padding: 10px; background: #f0f0f0;"> <div style="padding: 10px; background: #f0f0f0;">
<table cellpadding=2px width=400px> <table cellpadding=2px width=400px>
<tr> <tr>
<td><strong>Description</strong></td> <td><strong>Description</strong></td>
<td><input type="text" name="bill_name" size="32"></td> <td><input type="text" name="bill_name" size="32"></td>
</tr> </tr>
<tr> <tr>
<td><strong>Billing Type</strong></td> <td><strong>Billing Type</strong></td>
<td> <td>
<input type="radio" name="bill_type" value="cdr" checked /> CDR 95th: <input type="text" name="bill_cdr" size="10">KBps <input type="radio" name="bill_type" value="cdr" checked /> CDR 95th: <input type="text" name="bill_cdr" size="10">KBps
<br /> <br />
<input type="radio" name="bill_type" value="quota" /> Quota: <input type="text" name="bill_quota" size="10">GB <input type="radio" name="bill_type" value="quota" /> Quota: <input type="text" name="bill_quota" size="10">GB
</tr> </tr>
<tr> <tr>
<td><strong>Billing Day</strong></td> <td><strong>Billing Day</strong></td>
<td><input type="text" name="bill_day" size="5" value="1"></td> <td><input type="text" name="bill_day" size="5" value="1"></td>
</tr> </tr>
<tr><td colspan=4><h3>Optional Information</h3></td></tr> <tr><td colspan=4><h3>Optional Information</h3></td></tr>
<tr> <tr>
<td><strong>Customer Reference</strong></td> <td><strong>Customer Reference</strong></td>
<td><input type="text" name="bill_custid" size="32"></td> <td><input type="text" name="bill_custid" size="32"></td>
</tr> </tr>
<tr> <tr>
<td><strong>Billing Reference</strong></td> <td><strong>Billing Reference</strong></td>
<td><input type="text" name="bill_ref" size="32"></td> <td><input type="text" name="bill_ref" size="32"></td>
</tr> </tr>
<tr> <tr>
<td><strong>Notes</strong></td> <td><strong>Notes</strong></td>
<td><input type="textarea" name="bill_notes" size="32"></td> <td><input type="textarea" name="bill_notes" size="32"></td>
</tr> </tr>
<tr> <tr>
<td></td><td><input type="submit" class="submit" name="Submit" value=" Add Bill "></td> <td></td><td><input type="submit" class="submit" name="Submit" value=" Add Bill "></td>
</tr> </tr>
</table> </table>
</div> </div>
</form> </form>
<?php <?php
} else { } else {
print_optionbar_start('40'); print_optionbar_start('40');
?> ?>
<table cellpadding=7 cellspacing=0 class=devicetable width=100%> <table cellpadding=7 cellspacing=0 class=devicetable width=100%>
<form method='post' action=''> <form method='post' action=''>
<tr> <tr>
<td width='40' align=center valign=middle><div style='font-weight: bold; font-size: 16px;'>Bills</div></td> <td width='40' align=center valign=middle><div style='font-weight: bold; font-size: 16px;'>Bills</div></td>
<td width='240'><span style='font-weight: bold; font-size: 14px;'></span> <td width='240'><span style='font-weight: bold; font-size: 14px;'></span>
<input type="text" name="hostname" id="hostname" size=40 value="<?php echo($_POST['hostname']); ?>" /> <input type="text" name="hostname" id="hostname" size=40 value="<?php echo($_POST['hostname']); ?>" />
</td> </td>
<td width='100'> <td width='100'>
<select name='os' id='os'> <select name='os' id='os'>
<option value=''>All Types</option> <option value=''>All Types</option>
<option value=''>CDR</option> <option value=''>CDR</option>
<option value=''>95th</option> <option value=''>95th</option>
<option value=''>Quota</option> <option value=''>Quota</option>
</select> </select>
</td> </td>
<td width='100'> <td width='100'>
<select name='hardware' id='hardware'> <select name='hardware' id='hardware'>
<option value=''>All States</option> <option value=''>All States</option>
<option value=''>Under Quota</option> <option value=''>Under Quota</option>
<option value=''>Over Quota</option> <option value=''>Over Quota</option>
</select> </select>
</td> </td>
<td width='100'> <td width='100'>
<select name='location' id='location'> <select name='location' id='location'>
<option value=''>All Customers</option> <option value=''>All Customers</option>
</select> </select>
</td> </td>
<td> <td>
<input type=submit class=submit value=Search> <input type=submit class=submit value=Search>
</td> </td>
<td width='80' style='font-weight:bold; font-size: 12px;'> <td width='80' style='font-weight:bold; font-size: 12px;'>
<a href='bills/add/'><img src="images/16/add.png" align=absmiddle alt="Add"> Add Bill</a> <a href='bills/add/'><img src="images/16/add.png" align=absmiddle alt="Add"> Add Bill</a>
</td> </td>
</tr> </tr>
</form> </form>
</table> </table>
<?php <?php
print_optionbar_end(); print_optionbar_end();
echo("<table border=0 cellspacing=0 cellpadding=5 class=devicetable width=100%>"); echo("<table border=0 cellspacing=0 cellpadding=5 class=devicetable width=100%>");
$i=1; $i=1;
foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill) foreach (dbFetchRows("SELECT * FROM `bills` ORDER BY `bill_name`") as $bill)
{ {
if (bill_permitted($bill['bill_id'])) if (bill_permitted($bill['bill_id']))
{ {
unset($class); unset($class);
$day_data = getDates($bill['bill_day']); $day_data = getDates($bill['bill_day']);
$datefrom = $day_data['0']; $datefrom = $day_data['0'];
$dateto = $day_data['1']; $dateto = $day_data['1'];
$rate_data = getRates($bill['bill_id'],$datefrom,$dateto); $rate_data = getRates($bill['bill_id'],$datefrom,$dateto);
$rate_95th = $rate_data['rate_95th']; $rate_95th = $rate_data['rate_95th'];
$dir_95th = $rate_data['dir_95th']; $dir_95th = $rate_data['dir_95th'];
$total_data = $rate_data['total_data']; $total_data = $rate_data['total_data'];
$rate_average = $rate_data['rate_average']; $rate_average = $rate_data['rate_average'];
if ($bill['bill_type'] == "cdr") if ($bill['bill_type'] == "cdr")
{ {
$type = "CDR"; $type = "CDR";
$allowed = formatRates($bill['bill_cdr'] * 1000); $allowed = formatRates($bill['bill_cdr'] * 1000);
$used = formatRates($rate_data['rate_95th'] * 1000); $used = formatRates($rate_data['rate_95th'] * 1000);
$percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2); $percent = round(($rate_data['rate_95th'] / $bill['bill_cdr']) * 100,2);
} elseif ($bill['bill_type'] == "quota") { } elseif ($bill['bill_type'] == "quota") {
$type = "Quota"; $type = "Quota";
$allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024); $allowed = formatStorage($bill['bill_gb']* 1024 * 1024 * 1024);
$used = formatStorage($rate_data['total_data'] * 1024 * 1024); $used = formatStorage($rate_data['total_data'] * 1024 * 1024);
$percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2); $percent = round(($rate_data['total_data'] / ($bill['bill_gb'] * 1024)) * 100,2);
} }
$background = get_percentage_colours($percent); $background = get_percentage_colours($percent);
$right_background = $background['right']; $right_background = $background['right'];
$left_background = $background['left']; $left_background = $background['left'];
if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; } if (!is_integer($i/2)) { $row_colour = $list_colour_a; } else { $row_colour = $list_colour_b; }
echo(" echo("
<tr bgcolor='$row_colour'> <tr bgcolor='$row_colour'>
<td width='7'></td> <td width='7'></td>
<td width='250'><a href='bill/".$bill['bill_id']."/'><span style='font-weight: bold;' class=interface>".$bill['bill_name']."</span></a></td> <td width='250'><a href='bill/".$bill['bill_id']."/'><span style='font-weight: bold;' class=interface>".$bill['bill_name']."</span></a></td>
<td>$notes</td> <td>$notes</td>
<td>$type</td> <td>$type</td>
<td>$allowed</td> <td>$allowed</td>
<td>$used</td> <td>$used</td>
<td width=370>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</td> <td width=370>".print_percentage_bar (350, 20, $perc, NULL, "ffffff", $background['left'], $percent . "%", "ffffff", $background['right'])."</td>
<td width=60><a href='bill/".$bill['bill_id']."/edit/'><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td> <td width=60><a href='bill/".$bill['bill_id']."/edit/'><img src='images/16/wrench.png' align=absmiddle alt='Edit'> Edit</a></td>
</tr> </tr>
"); ");
$i++; $i++;
} ### PERMITTED } ### PERMITTED
} }
echo("</table>"); echo("</table>");
} }
echo("</td></tr></table>"); echo("</td></tr></table>");
?> ?>
+118 -119
View File
@@ -1,119 +1,118 @@
<?php <?php
if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs') if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs')
{ {
if (isset($vars['graph'])) { $graph_type = "port_" . $vars['graph']; } else { $graph_type = "port_bits"; } if (isset($vars['graph'])) { $graph_type = "port_" . $vars['graph']; } else { $graph_type = "port_bits"; }
} }
if (!$vars['view']) { $vars['view'] = "basic"; } if (!$vars['view']) { $vars['view'] = "basic"; }
$link_array = array('page' => 'device', $link_array = array('page' => 'device',
'device' => $device['device_id'], 'device' => $device['device_id'],
'tab' => 'ports'); 'tab' => 'ports');
print_optionbar_start(); print_optionbar_start();
$menu_options['basic'] = 'Basic'; $menu_options['basic'] = 'Basic';
$menu_options['details'] = 'Details'; $menu_options['details'] = 'Details';
$menu_options['arp'] = 'ARP Table'; $menu_options['arp'] = 'ARP Table';
if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id")) if(dbFetchCell("SELECT * FROM links AS L, ports AS I WHERE I.device_id = '".$device['device_id']."' AND I.interface_id = L.local_interface_id"))
{ {
$menu_options['neighbours'] = 'Neighbours'; $menu_options['neighbours'] = 'Neighbours';
} }
if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'")) if(dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE `ifType` = 'adsl'"))
{ {
$menu_options['adsl'] = 'ADSL'; $menu_options['adsl'] = 'ADSL';
} }
$sep = ""; $sep = "";
foreach ($menu_options as $option => $text) foreach ($menu_options as $option => $text)
{ {
echo($sep); echo($sep);
if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); } if ($vars['view'] == $option) { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($text,$link_array,array('view'=>$option))); echo(generate_link($text,$link_array,array('view'=>$option)));
if ($vars['view'] == $option) { echo("</span>"); } if ($vars['view'] == $option) { echo("</span>"); }
$sep = " | "; $sep = " | ";
} }
unset($sep); unset($sep);
echo(' | Graphs: '); echo(' | Graphs: ');
$graph_types = array("bits" => "Bits", $graph_types = array("bits" => "Bits",
"upkts" => "Unicast Packets", "upkts" => "Unicast Packets",
"nupkts" => "Non-Unicast Packets", "nupkts" => "Non-Unicast Packets",
"errors" => "Errors", "errors" => "Errors",
"etherlike" => "Etherlike"); "etherlike" => "Etherlike");
foreach ($graph_types as $type => $descr) foreach ($graph_types as $type => $descr)
{ {
echo("$type_sep"); echo("$type_sep");
if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo("<span class='pagemenu-selected'>"); } if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type))); echo(generate_link($descr,$link_array,array('view'=>'graphs','graph'=>$type)));
if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo("</span>"); } if ($vars['graph'] == $type && $vars['view'] == "graphs") { echo("</span>"); }
echo(' ('); echo(' (');
if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo("<span class='pagemenu-selected'>"); } if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo("<span class='pagemenu-selected'>"); }
echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type))); echo(generate_link('Mini',$link_array,array('view'=>'minigraphs','graph'=>$type)));
if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo("</span>"); } if ($vars['graph'] == $type && $vars['view'] == "minigraphs") { echo("</span>"); }
echo(')'); echo(')');
$type_sep = " | "; $type_sep = " | ";
} }
print_optionbar_end(); print_optionbar_end();
if ($vars['view'] == 'minigraphs') if ($vars['view'] == 'minigraphs')
{ {
$timeperiods = array('-1day','-1week','-1month','-1year'); $timeperiods = array('-1day','-1week','-1month','-1year');
$from = '-1day'; $from = '-1day';
echo("<div style='display: block; clear: both; margin: auto; min-height: 500px;'>"); echo("<div style='display: block; clear: both; margin: auto; min-height: 500px;'>");
unset ($seperator); unset ($seperator);
## FIX THIS. UGLY. ## FIX THIS. UGLY.
foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port) foreach (dbFetchRows("select * from ports WHERE device_id = ? ORDER BY ifIndex", array($device['device_id'])) as $port)
{ {
echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 183px; max-width:183px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e9e9e9;'> echo("<div style='display: block; padding: 3px; margin: 3px; min-width: 183px; max-width:183px; min-height:90px; max-height:90px; text-align: center; float: left; background-color: #e9e9e9;'>
<div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div> <div style='font-weight: bold;'>".makeshortif($port['ifDescr'])."</div>
<a href=\"" . generate_port_url($port) . "\" onmouseover=\"return overlib('\ <a href=\"" . generate_port_url($port) . "\" onmouseover=\"return overlib('\
<div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\ <div style=\'font-size: 16px; padding:5px; font-weight: bold; color: #e5e5e5;\'>".$device['hostname']." - ".$port['ifDescr']."</div>\
".$port['ifAlias']." \ ".$port['ifAlias']." \
<img src=\'graph.php?type=".$graph_type."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=450&amp;height=150\'>\ <img src=\'graph.php?type=".$graph_type."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=450&amp;height=150\'>\
', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >". ', CENTER, LEFT, FGCOLOR, '#e5e5e5', BGCOLOR, '#e5e5e5', WIDTH, 400, HEIGHT, 150);\" onmouseout=\"return nd();\" >".
"<img src='graph.php?type=".$graph_type."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=180&amp;height=45&amp;legend=no'> "<img src='graph.php?type=".$graph_type."&amp;id=".$port['interface_id']."&amp;from=".$from."&amp;to=".$now."&amp;width=180&amp;height=45&amp;legend=no'>
</a> </a>
<div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 32, '')."</div> <div style='font-size: 9px;'>".truncate(short_port_descr($port['ifAlias']), 32, '')."</div>
</div>"); </div>");
} }
echo("</div>"); echo("</div>");
} elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") { } elseif ($vars['view'] == "arp" || $vars['view'] == "adsl" || $vars['view'] == "neighbours") {
include("ports/".$vars['view'].".inc.php"); include("ports/".$vars['view'].".inc.php");
} else { } else {
if ($vars['view'] == "details") { $port_details = 1; } if ($vars['view'] == "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";
global $port_cache; global $port_cache, $port_index_cache;
global $port_index_cache;
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id']));
$ports = dbFetchRows("SELECT * FROM `ports` WHERE `device_id` = ? AND `deleted` = '0' ORDER BY `ifIndex` ASC", array($device['device_id'])); ### As we've dragged the whole database, lets pre-populate our caches :)
### As we've dragged the whole database, lets pre-populate our caches :) ### FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries.
### FIXME - we should probably split the fetching of link/stack/etc into functions and cache them here too to cut down on single row queries. foreach($ports as $port)
foreach($ports as $port) {
{ $port_cache[$port['interface_id']] = $port;
$port_cache[$port['interface_id']] = $port; $port_index_cache[$port['device_id']][$port['ifIndex']] = $port;
$port_index_cache[$port['device_id']][$port['ifIndex']] = $port; }
}
foreach ($ports as $port)
foreach ($ports as $port) {
{ include("includes/print-interface.inc.php");
include("includes/print-interface.inc.php"); $i++;
$i++; }
} echo("</table></div>");
echo("</table></div>"); }
}
?>
?>
+1 -1
View File
@@ -14,7 +14,7 @@ if ($vars['view'] == 'graphs' || $vars['view'] == 'minigraphs')
} }
if (!$vars['view']) { $vars['view'] = "basic"; } if (!$vars['view']) { $vars['view'] = "basic"; }
$menu_options['basic'] = 'Basic'; $menu_options['basic'] = 'Basic';
#$menu_options['details'] = 'Details'; #$menu_options['details'] = 'Details';
+2 -2
View File
@@ -199,8 +199,8 @@ foreach ($ports as $port)
$this_port['ifTrunk'] = $this_port['vlanTrunkPortEncapsulationOperType']; $this_port['ifTrunk'] = $this_port['vlanTrunkPortEncapsulationOperType'];
} }
$this_port['ifVlan'] = $this_port['vmVlan']; $this_port['ifVlan'] = $this_port['vmVlan'];
if(isset($this_port['vlanTrunkPortNativeVlan'])) { $this_port['ifVlan'] = $this_port['vlanTrunkPortNativeVlan']; } if (isset($this_port['vlanTrunkPortNativeVlan'])) { $this_port['ifVlan'] = $this_port['vlanTrunkPortNativeVlan']; }
if (isset($this_port['dot1qPvid'])) if (isset($this_port['dot1qPvid']))
{ {
$this_port['ifVlan'] = $this_port['dot1qPvid']; $this_port['ifVlan'] = $this_port['dot1qPvid'];