Projet

Général

Profil

Télécharger (4,04 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / status_upnp.php @ 93caffc0

1
<?php
2
/* $Id$ */
3
/*
4
	status_upnp.php
5
	part of pfSense (https://www.pfsense.org/)
6

    
7
	Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31
/*
32
	pfSense_BUILDER_BINARIES:	/sbin/pfctl
33
	pfSense_MODULE:	upnp
34
*/
35

    
36
##|+PRIV
37
##|*IDENT=page-status-upnpstatus
38
##|*NAME=Status: UPnP Status page
39
##|*DESCR=Allow access to the 'Status: UPnP Status' page.
40
##|*MATCH=status_upnp.php*
41
##|-PRIV
42

    
43
require("guiconfig.inc");
44

    
45
if ($_POST) {
46
	if ($_POST['clear'] == "Clear") {
47
		upnp_action('restart');
48
		$savemsg = gettext("Rules have been cleared and the daemon restarted");
49
	}
50
}
51

    
52
$rdr_entries = array();
53
exec("/sbin/pfctl -aminiupnpd -sn", $rdr_entries, $pf_ret);
54

    
55
$now = time();
56
$year = date("Y");
57

    
58
$pgtitle = array(gettext("Status"),gettext("UPnP &amp; NAT-PMP Status"));
59
$shortcut_section = "upnp";
60
include("head.inc");
61
?>
62
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
63
<?php include("fbegin.inc"); ?>
64
<?php if ($savemsg) print_info_box($savemsg); ?>
65
<?php
66
if(!$config['installedpackages'] || !$config['installedpackages']['miniupnpd']['config'][0]['iface_array'] ||
67
	!$config['installedpackages']['miniupnpd']['config'][0]['enable']) {
68
	echo gettext("UPnP is currently disabled.");
69
	include("fend.inc");
70
	exit;
71
}
72
?>
73
<div id="mainlevel">
74
<table width="100%" border="0" cellpadding="0" cellspacing="0">
75
   <tr>
76
     <td class="tabcont" >
77
      <form action="status_upnp.php" method="post">
78
      <input type="submit" name="clear" id="clear" value="<?=gettext("Clear");?>" /> <?=gettext("all currently connected sessions");?>.
79
    </form>
80
    </td>
81
   </tr>
82
   <tr>
83
    <td class="tabcont" >
84
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="tabcont">
85
    	<tr>
86
          <td width="10%" class="listhdrr"><?=gettext("Port");?></td>
87
          <td width="10%" class="listhdrr"><?=gettext("Protocol");?></td>
88
          <td width="20%" class="listhdrr"><?=gettext("Internal IP");?></td>
89
          <td width="10%" class="listhdrr"><?=gettext("Int. Port");?></td>
90
          <td width="50%" class="listhdr"><?=gettext("Description");?></td>
91
		</tr>
92
		<?php $i = 0; foreach ($rdr_entries as $rdr_entry) {
93
			if (preg_match("/on (.*) inet proto (.*) from any to any port = (.*) keep state label \"(.*)\" rtable [0-9] -> (.*) port (.*)/", $rdr_entry, $matches))
94
			$rdr_proto = $matches[2];
95
			$rdr_port = $matches[3];
96
			$rdr_label =$matches[4];
97
			$rdr_ip = $matches[5];
98
			$rdr_iport = $matches[6];
99
		?>
100
        <tr>
101
          <td class="listlr">
102
		<?php print $rdr_port;?>
103
          </td>
104
          <td class="listlr">
105
		<?php print $rdr_proto;?>
106
          </td>
107
          <td class="listlr">
108
		<?php print $rdr_ip;?>
109
          </td>
110
          <td class="listlr">
111
		<?php print $rdr_iport;?>
112
          </td>
113
          <td class="listlr">
114
		<?php print $rdr_label;?>
115
          </td>
116
        </tr>
117
        <?php $i++; }?>
118
      </table>
119
     </td>
120
    </tr>
121
</table>
122
</div>
123
<?php include("fend.inc"); ?>
124
</body>
125
</html>
(200-200/254)