Project

General

Profile

« Previous | Next » 

Revision db7d66e7

Added by Phil Davis over 10 years ago

Cleanup code logic status_upnp

1) Variable $i is was set, incremented and not used.
2) "if preg_match" at line 94 had no curlies after it, so it was only applying to the first line after it ($rdr_proto = ...) It really looks like "if preg_match"should apply to the whole code chunk - settings the various "rdr*" vars and then spitting out the "tr" with the various matches values in the row.
Somebody with some various UPnP enabled and running should test this to see if the status page still works with this change.
I think it only makes a difference if $rdr_entries has some lines in it that do not match the regex - in that case the old code might have displayed some rubbish or (almost?) duplicated rows.

View differences:

usr/local/www/status_upnp.php
90 90
          <td width="10%" class="listhdrr"><?=gettext("Int. Port");?></td>
91 91
          <td width="50%" class="listhdr"><?=gettext("Description");?></td>
92 92
		</tr>
93
		<?php $i = 0; foreach ($rdr_entries as $rdr_entry) {
94
			if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches))
93
<?php
94
	foreach ($rdr_entries as $rdr_entry) {
95
		if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches)) {
95 96
			$rdr_proto = $matches[2];
96 97
			$rdr_port = $matches[3];
97 98
			$rdr_label =$matches[4];
98 99
			$rdr_ip = $matches[5];
99 100
			$rdr_iport = $matches[6];
100
		?>
101
?>
101 102
        <tr>
102 103
          <td class="listlr">
103 104
		<?php print $rdr_port;?>
......
115 116
		<?php print $rdr_label;?>
116 117
          </td>
117 118
        </tr>
118
        <?php $i++; }?>
119
<?php
120
		}
121
	}
122
?>
119 123
      </table>
120 124
     </td>
121 125
    </tr>

Also available in: Unified diff