--- etc/view.php.orig 2003-09-26 15:58:34 UTC +++ etc/view.php @@ -8,154 +8,163 @@ header("Cache-Control: no-cache, must-revalidate"); header("Pragma: no-cache"); - print "\n\n
\n"; + print "\n\n\n"; /* Connect to RTG MySQL Database */ - $dbc=@mysql_connect ($host, $user, $pass) or - $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or + $dbc=@mysqli_connect ($host, $user, $pass, $db) or die ("MySQL Connection Failed, Check Configuration."); - mysql_select_db($db,$dbc); # Global variables off by default in newer versions of PHP - if (!$PHP_SELF) { + if (!isset($PHP_SELF) || ($PHP_SELF == "")) { $PHP_SELF = "view.php"; - $rid = $_GET['rid']; - $iid = $_GET['iid']; + $rid = isset($_GET['rid'])?$_GET['rid']:""; + $iid = isset($_GET['iid'])?$_GET['iid']:""; } # Determine router, interface names as necessary - if ($rid && $iid) { - $selectQuery="SELECT a.name, a.description, a.speed, b.name AS router FROM interface a, router b WHERE a.rid=b.rid AND a.rid=$rid AND a.id=$iid"; - $selectResult=mysql_query($selectQuery, $dbc); - $selectRow=mysql_fetch_object($selectResult); - $interfaces = mysql_num_rows($selectResult); + if (($rid != "") && ($iid != "")) { + $selectQuery="SELECT `a`.`name`, `a`.`description`, `a`.`speed`, `b`.`name` " . + "AS `router` FROM `interface` `a`, `router` `b` WHERE `a`.`rid`=`b`.`rid` " . + "AND `a`.`rid`=" . mysqli_real_escape_string($dbc, $rid) . " AND `a`.`id`=" . + mysqli_real_escape_string($dbc, $iid); + $selectResult=mysqli_query($dbc, $selectQuery); + $selectRow=mysqli_fetch_object($selectResult); + $interfaces = mysqli_num_rows($selectResult); $name = $selectRow->name; $description = $selectRow->description; $speed = ($selectRow->speed)/1000000; $router = $selectRow->router; - } else if ($rid && !$iid) { - $selectQuery="SELECT name AS router from router where rid=$rid"; - $selectResult=mysql_query($selectQuery, $dbc); - $selectRow=mysql_fetch_object($selectResult); + } else if (($rid != "")&& ($iid == "")) { + $selectQuery="SELECT `name` AS `router` FROM `router` WHERE `rid`=" . + mysqli_real_escape_string($dbc, $rid); + $selectResult=mysqli_query($dbc, $selectQuery); + $selectRow=mysqli_fetch_object($selectResult); $router = $selectRow->router; } # Generate Title - echo "