View | Details | Raw Unified | Return to bug 191276 | Differences between
and this patch

Collapse All | Expand All

(-)net/rtg/Makefile (-2 / +19 lines)
Lines 3-9 Link Here
3
3
4
PORTNAME=	rtg
4
PORTNAME=	rtg
5
PORTVERSION=	0.7.4
5
PORTVERSION=	0.7.4
6
PORTREVISION=	10
6
PORTREVISION=	11
7
CATEGORIES=	net
7
CATEGORIES=	net
8
MASTER_SITES=	SF \
8
MASTER_SITES=	SF \
9
		ftp://ftpmirror.uk/freebsd-ports/rtg/
9
		ftp://ftpmirror.uk/freebsd-ports/rtg/
Lines 14-22 Link Here
14
LICENSE=	GPLv2
14
LICENSE=	GPLv2
15
15
16
LIB_DEPENDS=	libnetsnmp.so:${PORTSDIR}/net-mgmt/net-snmp
16
LIB_DEPENDS=	libnetsnmp.so:${PORTSDIR}/net-mgmt/net-snmp
17
RUN_DEPENDS=	p5-DBI>=0:${PORTSDIR}/databases/p5-DBI \
18
		p5-DBD-mysql>=0:${PORTSDIR}/databases/p5-DBD-mysql
17
19
18
USE_RC_SUBR=	rtgpoll
20
USE_RC_SUBR=	rtgpoll
19
USE_MYSQL=	yes
21
USE_MYSQL=	client
20
WANT_PERL=	yes
22
WANT_PERL=	yes
21
USES=		shebangfix
23
USES=		shebangfix
22
SHEBANG_FILES=	etc/95.pl etc/report.pl
24
SHEBANG_FILES=	etc/95.pl etc/report.pl
Lines 25-30 Link Here
25
CONFIGURE_ARGS+=	--sysconfdir=${PREFIX}/etc/${PORTNAME} \
27
CONFIGURE_ARGS+=	--sysconfdir=${PREFIX}/etc/${PORTNAME} \
26
			--with-mysql=${LOCALBASE} \
28
			--with-mysql=${LOCALBASE} \
27
			--with-snmp=${LOCALBASE}
29
			--with-snmp=${LOCALBASE}
30
OPTIONS_DEFINE=	WEB MYSQL
31
OPTIONS_DEFAULT=WEB
32
MYSQL_DESC=	Pull MySQL server in as a dependancy for local setups
33
WEB_DESC=	Include PHP-based web client interface pre-requisites
34
35
.include <bsd.port.options.mk>
36
37
.if ${PORT_OPTIONS:MMYSQL}
38
USE_MYSQL=	yes
39
.endif
40
41
.if ${PORT_OPTIONS:MWEB}
42
WANT_PHP_WEB=	yes
43
USE_PHP=	mysqli spl
44
.endif
28
45
29
.include <bsd.port.pre.mk>
46
.include <bsd.port.pre.mk>
30
47
(-)net/rtg/files/patch-etc-95.php (+72 lines)
Line 0 Link Here
1
--- etc/95.php.orig	2014-06-22 15:27:55.587467922 +0100
2
+++ etc/95.php	2014-06-22 15:28:47.947474934 +0100
3
@@ -4,10 +4,8 @@
4
   print "<HTML>\n<!-- RTG Version $VERSION -->\n<HEAD>\n";
5
 
6
   /* Connect to RTG MySQL Database */
7
-  $dbc=@mysql_connect ($host, $user, $pass) or
8
-  $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or 
9
+  $dbc=@mysqli_connect ($host, $user, $pass, $db) or
10
      die ("MySQL Connection Failed, Check Configuration.");
11
-  mysql_select_db($db,$dbc);
12
 
13
   if ($PHP_SELF == "") {
14
     $PHP_SELF = "95.php";
15
@@ -50,8 +48,8 @@
16
   $max = $avg = $nintyfifth = 0;
17
   $rate = array();
18
 
19
-  $selectResult=mysql_query($statement, $dbc);
20
-  while ($selectRow=mysql_fetch_object($selectResult)){
21
+  $selectResult=mysqli_query($dbc, $statement);
22
+  while ($selectRow=mysqli_fetch_object($selectResult)){
23
     $counter = $selectRow->counter;
24
     $sample_secs = $selectRow->unixtime;
25
     $total += $counter;
26
@@ -89,9 +87,8 @@
27
 <?php
28
   echo "<FORM ACTION=\"$PHP_SELF\" METHOD=\"GET\">\n";
29
   if (($bt || $smonth)) { 
30
-    $dbc=@mysql_connect ($host, $user, $pass) or
31
-    $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or die ("MySQL Connection Failed, Check Configuration.");
32
-    mysql_select_db($db,$dbc);
33
+    $dbc=@mysqli_connect ($host, $user, $pass, $db) or
34
+      die ("MySQL Connection Failed, Check Configuration.");
35
     /* Format into GNU date syntax */
36
     if ($bt == "") {
37
       $bt = strtotime("$syear-$smonth-$sday $shour:$smin:00");
38
@@ -104,11 +101,11 @@
39
     $range="dtime>FROM_UNIXTIME($bt) AND dtime<=FROM_UNIXTIME($et)";
40
 
41
     $selectQuery="SELECT id, name, description, rid FROM interface WHERE description LIKE \"%$customer%\"";
42
-    $selectResult=mysql_query($selectQuery, $dbc);
43
-    if (mysql_num_rows($selectResult) <= 0) 
44
+    $selectResult=mysqli_query($dbc, $selectQuery);
45
+    if (mysqli_num_rows($selectResult) <= 0) 
46
       print "<BR>No Such Customer Found.<BR>\n";
47
     else {
48
-      while ($selectRow=mysql_fetch_object($selectResult)){
49
+      while ($selectRow=mysqli_fetch_object($selectResult)){
50
         $ids[$selectRow->id] = $selectRow->name; 
51
         $rids[$selectRow->id] = $selectRow->rid; 
52
 	$desc[$selectRow->id] = $selectRow->description;
53
@@ -127,8 +124,8 @@
54
       foreach($ids as $iid=>$name) {
55
 
56
         $selectQuery="SELECT name FROM router WHERE rid=$rids[$iid]";
57
-        $selectResult=mysql_query($selectQuery, $dbc);
58
-        $selectRow=mysql_fetch_object($selectResult);
59
+        $selectResult=mysqli_query($dbc, $selectQuery);
60
+        $selectRow=mysqli_fetch_object($selectResult);
61
 	$router = $selectRow->name;
62
 
63
         if ($yellow) $yellow = 0;
64
@@ -201,7 +198,7 @@
65
     echo "<P><INPUT TYPE=\"SUBMIT\" VALUE=\"Ok\">";
66
   }
67
 
68
-  if ($dbc) mysql_close($dbc);
69
+  if ($dbc) mysqli_close($dbc);
70
   echo "</FORM>\n";
71
 ?>
72
 <BR>
(-)net/rtg/files/patch-etc-rtg.php (-5 / +86 lines)
Lines 1-6 Link Here
1
--- etc/rtg.php.orig	2010-07-04 03:49:22.836351752 +0100
1
--- etc/rtg.php.orig	2003-09-24 21:42:03.000000000 +0100
2
+++ etc/rtg.php	2010-07-04 03:54:55.955519331 +0100
2
+++ etc/rtg.php	2014-06-22 15:25:22.471477252 +0100
3
@@ -171,6 +171,9 @@
3
@@ -4,10 +4,8 @@
4
   print "<HTML>\n<!-- RTG Version $VERSION -->\n<HEAD>\n";
5
 
6
   /* Connect to RTG MySQL Database */
7
-  $dbc=@mysql_connect ($host, $user, $pass) or
8
-  $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or 
9
+  $dbc=@mysqli_connect ($host, $user, $pass, $db) or
10
      die ("MySQL Connection Failed, Check Configuration.");
11
-  mysql_select_db($db,$dbc);
12
 
13
  if ($PHP_SELF == "") {
14
    $PHP_SELF = "rtg.php";
15
@@ -37,17 +35,17 @@
16
   # Determine router, interface names as necessary
17
   if ($rid && $iid) {
18
     $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[0]";
19
-    $selectResult=mysql_query($selectQuery, $dbc);
20
-    $selectRow=mysql_fetch_object($selectResult);
21
-    $interfaces = mysql_num_rows($selectResult);
22
+    $selectResult=mysqli_query($dbc, $selectQuery);
23
+    $selectRow=mysqli_fetch_object($selectResult);
24
+    $interfaces = mysqli_num_rows($selectResult);
25
     $name = $selectRow->name;
26
     $description = $selectRow->description;
27
     $speed = ($selectRow->speed)/1000000;
28
     $router = $selectRow->router;
29
   } else if ($rid && !$iid) {
30
     $selectQuery="SELECT name AS router from router where rid=$rid";
31
-    $selectResult=mysql_query($selectQuery, $dbc);
32
-    $selectRow=mysql_fetch_object($selectResult);
33
+    $selectResult=mysqli_query($dbc, $selectQuery);
34
+    $selectRow=mysqli_fetch_object($selectResult);
35
     $router = $selectRow->router;
36
   }
37
 
38
@@ -71,8 +69,8 @@
39
 if (!$rid && !$iid) {
40
  echo "<SELECT NAME=\"rid\" SIZE=10>\n";
41
  $selectQuery="SELECT DISTINCT name, rid FROM router ORDER BY name";
42
- $selectResult=mysql_query($selectQuery, $dbc);
43
- while ($selectRow=mysql_fetch_object($selectResult)){
44
+ $selectResult=mysqli_query($dbc, $selectQuery);
45
+ while ($selectRow=mysqli_fetch_object($selectResult)){
46
     echo "<OPTION VALUE=\"$selectRow->rid\">$selectRow->name\n";
47
  }
48
  echo "</SELECT>\n";
49
@@ -91,8 +89,8 @@
50
 
51
   echo "<SELECT MULTIPLE NAME=\"iid[]\" SIZE=10>\n"; 
52
   $selectQuery="SELECT id, name, description FROM interface WHERE rid=$rid ORDER BY name";
53
-  $selectResult=mysql_query($selectQuery, $dbc);
54
-  while ($selectRow=mysql_fetch_object($selectResult)){
55
+  $selectResult=mysqli_query($dbc, $selectQuery);
56
+  while ($selectRow=mysqli_fetch_object($selectResult)){
57
      echo "<OPTION VALUE=\"$selectRow->id\">$selectRow->name ($selectRow->description)\n";
58
   }
59
   echo "</SELECT>\n";
60
@@ -152,8 +150,8 @@
61
   $range="$range AND id=$iid[0]";
62
 
63
   $selectQuery="SELECT description, name, speed FROM interface WHERE rid=$rid AND id=$iid[0]";
64
-  $selectResult=mysql_query($selectQuery, $dbc);
65
-  $selectRow=mysql_fetch_object($selectResult);
66
+  $selectResult=mysqli_query($dbc, $selectQuery);
67
+  $selectRow=mysqli_fetch_object($selectResult);
68
   echo "<TABLE BORDER=0>\n";
69
   echo "<TD><I>Device</I>:</TD><TD>$router ($rid)</TD><TR>\n";
70
   echo "<TD><I>Interface</I>:</TD><TD>$selectRow->name ($iid[0])</TD><TR>\n";
71
@@ -165,12 +163,15 @@
72
   echo "<P>\n";
73
  
74
   #$selectQuery="SELECT DISTINCT id FROM ifInOctets_$rid WHERE $range";
75
-  #$selectResult=mysql_query($selectQuery, $dbc);
76
-  #if (mysql_num_rows($selectResult) <= 0) {
77
+  #$selectResult=mysqli_query($dbc, $selectQuery);
78
+  #if (mysqli_num_rows($selectResult) <= 0) {
79
   #   print "<BR>No Data Found on Interface for Given Range.<BR>\n";
4
   #}
80
   #}
5
   #else {
81
   #else {
6
     $args = "t1=ifInOctets_$rid&t2=ifOutOctets_$rid&begin=$bt&end=$et&units=bits/s&factor=8";
82
     $args = "t1=ifInOctets_$rid&t2=ifOutOctets_$rid&begin=$bt&end=$et&units=bits/s&factor=8";
Lines 10-16 Link Here
10
     foreach ($iid as $value) {
86
     foreach ($iid as $value) {
11
       $args="$args&iid=$value";
87
       $args="$args&iid=$value";
12
     }
88
     }
13
@@ -181,8 +184,11 @@
89
@@ -181,8 +182,11 @@
14
     if ($borderb) $args = "$args&borderb=$borderb";
90
     if ($borderb) $args = "$args&borderb=$borderb";
15
     if ($aggr) $args = "$args&aggr=yes";
91
     if ($aggr) $args = "$args&aggr=yes";
16
     if ($percentile) $args = "$args&percentile=$nth";
92
     if ($percentile) $args = "$args&percentile=$nth";
Lines 23-29 Link Here
23
     foreach ($iid as $value) {
99
     foreach ($iid as $value) {
24
       $args="$args&iid=$value";
100
       $args="$args&iid=$value";
25
     }
101
     }
26
@@ -192,9 +198,13 @@
102
@@ -192,13 +196,17 @@
27
     if ($borderb) $args = "$args&borderb=$borderb";
103
     if ($borderb) $args = "$args&borderb=$borderb";
28
     if ($aggr) $args = "$args&aggr=yes";
104
     if ($aggr) $args = "$args&aggr=yes";
29
     if ($percentile) $args = "$args&percentile=$nth";
105
     if ($percentile) $args = "$args&percentile=$nth";
Lines 39-41 Link Here
39
 #  }
115
 #  }
40
 } 
116
 } 
41
 
117
 
118
-mysql_close($dbc);
119
+mysqli_close($dbc);
120
 ?>
121
 
122
 <P>
(-)net/rtg/files/patch-etc-view.php (-4 / +81 lines)
Lines 1-6 Link Here
1
--- etc/view.php.orig	2010-07-04 03:55:12.757175355 +0100
1
--- etc/view.php.orig	2003-09-26 16:58:34.000000000 +0100
2
+++ etc/view.php	2010-07-04 03:59:40.479683639 +0100
2
+++ etc/view.php	2014-06-22 15:24:14.720483023 +0100
3
@@ -95,19 +95,22 @@
3
@@ -11,10 +11,8 @@
4
   print "<HTML>\n<!-- RTG Version $VERSION -->\n<HEAD>\n";
5
 
6
   /* Connect to RTG MySQL Database */
7
-  $dbc=@mysql_connect ($host, $user, $pass) or
8
-  $dbc=@mysql_connect ("$host:/var/lib/mysql/mysql.sock", $user, $pass) or 
9
+  $dbc=@mysqli_connect ($host, $user, $pass, $db) or
10
      die ("MySQL Connection Failed, Check Configuration.");
11
-  mysql_select_db($db,$dbc);
12
 
13
   # Global variables off by default in newer versions of PHP
14
   if (!$PHP_SELF) {
15
@@ -26,17 +24,17 @@
16
   # Determine router, interface names as necessary
17
   if ($rid && $iid) {
18
     $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";
19
-    $selectResult=mysql_query($selectQuery, $dbc);
20
-    $selectRow=mysql_fetch_object($selectResult);
21
-    $interfaces = mysql_num_rows($selectResult);
22
+    $selectResult=mysqli_query($dbc, $selectQuery);
23
+    $selectRow=mysqli_fetch_object($selectResult);
24
+    $interfaces = mysqli_num_rows($selectResult);
25
     $name = $selectRow->name;
26
     $description = $selectRow->description;
27
     $speed = ($selectRow->speed)/1000000;
28
     $router = $selectRow->router;
29
   } else if ($rid && !$iid) {
30
     $selectQuery="SELECT name AS router from router where rid=$rid";
31
-    $selectResult=mysql_query($selectQuery, $dbc);
32
-    $selectRow=mysql_fetch_object($selectResult);
33
+    $selectResult=mysqli_query($dbc, $selectQuery);
34
+    $selectRow=mysqli_fetch_object($selectResult);
35
     $router = $selectRow->router;
36
   }
37
 
38
@@ -68,12 +66,12 @@
39
  if (!$rid) {
40
     print "Monitored Devices: <P>\n";
41
     $selectQuery="SELECT rid, name FROM router";
42
-    $selectResult=mysql_query($selectQuery, $dbc);
43
-    if (mysql_num_rows($selectResult) <= 0) 
44
+    $selectResult=mysqli_query($dbc, $selectQuery);
45
+    if (mysqli_num_rows($selectResult) <= 0) 
46
       print "<BR>No Routers Found.<BR>\n";
47
     else {
48
       print "<UL>\n";
49
-      while ($selectRow=mysql_fetch_object($selectResult)){
50
+      while ($selectRow=mysqli_fetch_object($selectResult)){
51
         print "<LI><A HREF=\"$PHP_SELF?rid=$selectRow->rid\">";
52
         print "$selectRow->name</A><BR>\n";
53
       }
54
@@ -95,19 +93,22 @@
4
 
55
 
5
       $bt = $et - (60*60*24);
56
       $bt = $et - (60*60*24);
6
       print "<B>Day View:</B><BR>\n";
57
       print "<B>Day View:</B><BR>\n";
Lines 26-32 Link Here
26
       print "<BR><B>$router: $name ($description)</B>\n";
77
       print "<BR><B>$router: $name ($description)</B>\n";
27
       print "<BR><BR>\n";
78
       print "<BR><BR>\n";
28
     }
79
     }
29
@@ -134,7 +137,10 @@
80
@@ -116,8 +117,8 @@
81
 
82
  if ($rid && !$iid) {
83
     $selectQuery="SELECT id, name, description FROM interface WHERE rid=$rid";
84
-    $selectResult=mysql_query($selectQuery, $dbc);
85
-    $interfaces = mysql_num_rows($selectResult);
86
+    $selectResult=mysqli_query($dbc, $selectQuery);
87
+    $interfaces = mysqli_num_rows($selectResult);
88
     if ($interfaces <= 0) 
89
       print "<BR>No Interfaces Found for Router $router (ID: $rid).<BR>\n";
90
     else {
91
@@ -129,12 +130,15 @@
92
       print gmdate('D, d M Y H:i:s \G\M\T', time())."\n";
93
       print "</TABLE><HR>\n";
94
       print "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"10\">\n";
95
-      while ($selectRow=mysql_fetch_object($selectResult)){
96
+      while ($selectRow=mysqli_fetch_object($selectResult)){
97
         $ids[$selectRow->id] = $selectRow->name; 
30
 	$desc[$selectRow->id] = $selectRow->description;
98
 	$desc[$selectRow->id] = $selectRow->description;
31
 	$iid = $selectRow->id;
99
 	$iid = $selectRow->id;
32
 	print "<TD><A HREF=\"$PHP_SELF?rid=$rid&iid=$iid\">\n";
100
 	print "<TD><A HREF=\"$PHP_SELF?rid=$rid&iid=$iid\">\n";
Lines 38-40 Link Here
38
 	print "</A><BR>\n";
106
 	print "</A><BR>\n";
39
         print "<B>$selectRow->name ($selectRow->description)</B>\n";
107
         print "<B>$selectRow->name ($selectRow->description)</B>\n";
40
         if ($even) {
108
         if ($even) {
109
@@ -148,7 +152,7 @@
110
     print "<INPUT TYPE=\"SUBMIT\" VALUE=\"Back to Main\">\n";
111
   }
112
 
113
-  if ($dbc) mysql_close($dbc);
114
+  if ($dbc) mysqli_close($dbc);
115
   echo "</FORM>\n";
116
 ?>
117
 

Return to bug 191276