Welcome, Guest. Please login or register.

Author Topic: GUI small bug  (Read 2542 times)

richard.lajaunie

  • Newbie
  • *
  • Posts: 26
    • View Profile
GUI small bug
« on: April 17, 2012, 06:59:35 PM »
Hi all,
In my sens there is a small bug in the Devices-Status.php page.

I create a user without 'adm' capabilities.
When this user look at one of our core switch (more than 100 links) in devices status and click on Top... link
he get "you're not authorized".
But in this he cannot view the whole list of links.

this is a very simple solution

Code: [Select]
diff --git a/html/Devices-Status.php b/html/Devices-Status.php
index 511eb98..ae57809 100755
--- a/html/Devices-Status.php
+++ b/html/Devices-Status.php
@@ -502,7 +502,13 @@ flush();
 </td><td class="helper">
 
 <h2>
+<?
+if (preg_match("/adm/",$_SESSION['group'])){
+?>
 <a href="Topology-Linked.php?dv=<?=$ud?>"><img src="img/16/ncon.png" title="Edit Links"></a>
+<? }else{ ?>
+<a href="Topology-Links.php?dv=<?=$ud?>"><img src="img/16/ncon.png" title="View Links"></a>
+<? } ?>
 Top <?=$_SESSION['lim']?> Links</h2>
 
 <?
diff --git a/html/Topology-Links.php b/html/Topology-Links.php
index e69de29..a502ea7 100644
--- a/html/Topology-Links.php
+++ b/html/Topology-Links.php
@@ -0,0 +1,72 @@
+<?
+# Program: Topology-Links.php
+# Programmer: Remo Rickli
+# Modified by: Richard Lajaunie
+
+$printable = 1;
+
+include_once ("inc/header.php");
+
+$_GET = sanitize($_GET);
+$dv = isset($_GET['dv']) ? $_GET['dv'] : "";
+$if = isset($_GET['if']) ? $_GET['if'] : "";
+$nb = isset($_GET['nb']) ? $_GET['nb'] : "";
+$ni = isset($_GET['ni']) ? $_GET['ni'] : "";
+$add = isset($_GET['add']) ? $_GET['add'] : "";
+$del = isset($_GET['del']) ? $_GET['del'] : "";
+$ddu = isset($_GET['ddu']) ? $_GET['ddu'] : "";
+$dvl = isset($_GET['dvl']) ? $_GET['dvl'] : "";
+$ndu = isset($_GET['ndu']) ? $_GET['ndu'] : "";
+$nvl = isset($_GET['nvl']) ? $_GET['nvl'] : "";
+$dbw = isset($_GET['dbw']) ? $_GET['dbw'] : "";
+$nbw = isset($_GET['nbw']) ? $_GET['nbw'] : "";
+$typ = isset($_GET['typ']) ? $_GET['typ'] : "";
+
+$lde = "Added $now by $_SESSION[user]";
+$link  = @DbConnect($dbhost,$dbuser,$dbpass,$dbname);
+?>
+<h2><?=($typ)?$typ:$dv?> - Links</h2>
+<table class="content" ><tr class="<?=$modgroup[$self]?>2">
+<th><img src="img/16/dev.png"><br>Device</th>
+<th><img src="img/16/port.png"><br>Interface</th>
+<th><img src="img/16/abc.png" title="D=Discovery Protocol,O=Oui,V=VoIP,S=static"><br><?=$typlbl?></th>
+<th><img src="img/16/tap.png"><br><?=$bwdlbl?></th>
+<th><img src="img/16/dev.png"><br><?=$neblbl?></th>
+<th><img src="img/16/port.png"><br>Interface</th>
+<th><img src="img/16/say.png"><br><?=$cmtlbl?></th>
+<th width="80"><img src="img/16/cog.png"><br><?=$cmdlbl?></th></tr>
+</tr>
+<?
+       $query  = GenQuery('links','s','*','ifname','',array('device'),array('='),array($dv));
+       $res    = @DbQuery($query,$link);
+       if($res){
+               $nli = 0;
+               $row = 0;
+               while( ($l = @DbFetchRow($res)) ){
+                       $ud = rawurlencode($l[1]);
+                       $un = rawurlencode($l[3]);
+                       if ($row % 2){$bg = "txta"; $bi = "imga";}else{$bg = "txtb"; $bi = "imgb";}
+                       $row++;
+                       echo "<tr class=\"$bg\" onmouseover=\"this.className='imga'\" onmouseout=\"this.className='$bg'\">\n";
+                       echo "<td><a href=\"Devices-Status.php?dev=$ud\"><img src=\"img/16/sys.png\"></a>\n";
+                       echo " <a href=?dv=$ud>$l[1]</a></td><td>$l[2]</td>\n";
+                       echo "<th>$l[6]</th>\n";
+                       echo "<td align=right>" . DecFix($l[5]) . "</td>\n";
+                       echo "<td><a href=\"Devices-Status.php?dev=$un\"><img src=\"img/16/sys.png\"></a>\n";
+                       echo " <a href=?dv=$un>$l[3]</a></td><td>$l[4] (Vlan$l[9] $l[8])</td><td>$l[7]</td>\n";
+                       echo "<th><a href=?del=$l[0]&dv=$ud><img src=\"img/16/bcnl.png\" onclick=\"return confirm('Link $l[0] $dellbl?');\" title=\"$l[0] $dellbl\"></
+                       $nli++;
+               }
+               @DbFreeResult($res);
+       }else{
+               print @DbError($link);
+       }
+       ?>
+</table>
+<table class="content" >
+<tr class="<?=$modgroup[$self]?>2"><td><?=$row?> Links</td></tr>
+</table>
+       <?
+//}
+include_once ("inc/footer.php");
+?>


Bye

rickli

  • Administrator
  • Hero Member
  • *****
  • Posts: 2701
    • View Profile
    • NeDi
Re: GUI small bug
« Reply #1 on: April 17, 2012, 10:27:32 PM »
Thanks for the input!

Community, would it be of general interest to list links like vlans, modules or interfaces? If so, I don't mind adding a Topology-Links module based on richards suggestion...
Please consider Other-Invoices on your NeDi installation for an annual contribution, tx!
-Remo

ntmark

  • Full Member
  • ***
  • Posts: 136
    • View Profile
    • tvnz.co.nz
Re: GUI small bug
« Reply #2 on: April 18, 2012, 06:20:52 AM »
+1 sounds like it could be helpful with reporting.