1
|
#!/usr/local/bin/php
|
2
|
<?php
|
3
|
/*
|
4
|
services_snmp.php
|
5
|
part of m0n0wall (http://m0n0.ch/wall)
|
6
|
|
7
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
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
|
require("guiconfig.inc");
|
33
|
|
34
|
if (!is_array($config['snmpd'])) {
|
35
|
$config['snmpd'] = array();
|
36
|
$config['snmpd']['rocommunity'] = "public";
|
37
|
}
|
38
|
|
39
|
$pconfig['syslocation'] = $config['snmpd']['syslocation'];
|
40
|
$pconfig['syscontact'] = $config['snmpd']['syscontact'];
|
41
|
$pconfig['rocommunity'] = $config['snmpd']['rocommunity'];
|
42
|
$pconfig['enable'] = isset($config['snmpd']['enable']);
|
43
|
|
44
|
if ($_POST) {
|
45
|
|
46
|
unset($input_errors);
|
47
|
$pconfig = $_POST;
|
48
|
|
49
|
/* input validation */
|
50
|
if ($_POST['enable']) {
|
51
|
$reqdfields = explode(" ", "rocommunity");
|
52
|
$reqdfieldsn = explode(",", "Community");
|
53
|
|
54
|
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
|
55
|
}
|
56
|
|
57
|
if (!$input_errors) {
|
58
|
$config['snmpd']['syslocation'] = $_POST['syslocation'];
|
59
|
$config['snmpd']['syscontact'] = $_POST['syscontact'];
|
60
|
$config['snmpd']['rocommunity'] = $_POST['rocommunity'];
|
61
|
$config['snmpd']['enable'] = $_POST['enable'] ? true : false;
|
62
|
|
63
|
write_config();
|
64
|
|
65
|
$retval = 0;
|
66
|
if (!file_exists($d_sysrebootreqd_path)) {
|
67
|
config_lock();
|
68
|
$retval = services_snmpd_configure();
|
69
|
config_unlock();
|
70
|
}
|
71
|
$savemsg = get_std_save_message($retval);
|
72
|
}
|
73
|
}
|
74
|
?>
|
75
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
76
|
<html>
|
77
|
<head>
|
78
|
<title><?=gentitle("Services: SNMP");?></title>
|
79
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
80
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
81
|
<script language="JavaScript">
|
82
|
<!--
|
83
|
function enable_change(enable_change) {
|
84
|
var endis;
|
85
|
endis = !(document.iform.enable.checked || enable_change);
|
86
|
document.iform.syslocation.disabled = endis;
|
87
|
document.iform.syscontact.disabled = endis;
|
88
|
document.iform.rocommunity.disabled = endis;
|
89
|
}
|
90
|
//-->
|
91
|
</script>
|
92
|
</head>
|
93
|
|
94
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
95
|
<?php include("fbegin.inc"); ?>
|
96
|
<p class="pgtitle">Services: SNMP</p>
|
97
|
<?php if ($input_errors) print_input_errors($input_errors); ?>
|
98
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
99
|
<form action="services_snmp.php" method="post" name="iform" id="iform">
|
100
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
101
|
<tr>
|
102
|
<td width="22%" valign="top" class="vtable"> </td>
|
103
|
<td width="78%" class="vtable">
|
104
|
<input name="enable" type="checkbox" value="yes" <?php if ($pconfig['enable']) echo "checked"; ?> onClick="enable_change(false)">
|
105
|
<strong>Enable SNMP agent</strong></td>
|
106
|
</tr>
|
107
|
<tr>
|
108
|
<td width="22%" valign="top" class="vncell">System location</td>
|
109
|
<td width="78%" class="vtable">
|
110
|
<input name="syslocation" type="text" class="formfld" id="syslocation" size="40" value="<?=htmlspecialchars($pconfig['syslocation']);?>">
|
111
|
</td>
|
112
|
</tr>
|
113
|
<tr>
|
114
|
<td width="22%" valign="top" class="vncell">System contact</td>
|
115
|
<td width="78%" class="vtable">
|
116
|
<input name="syscontact" type="text" class="formfld" id="syscontact" size="40" value="<?=htmlspecialchars($pconfig['syscontact']);?>">
|
117
|
</td>
|
118
|
</tr>
|
119
|
<tr>
|
120
|
<td width="22%" valign="top" class="vncellreq">Community</td>
|
121
|
<td width="78%" class="vtable">
|
122
|
<input name="rocommunity" type="text" class="formfld" id="rocommunity" size="40" value="<?=htmlspecialchars($pconfig['rocommunity']);?>">
|
123
|
<br>
|
124
|
In most cases, "public" is used here</td>
|
125
|
</tr>
|
126
|
<tr>
|
127
|
<td width="22%" valign="top"> </td>
|
128
|
<td width="78%">
|
129
|
<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">
|
130
|
</td>
|
131
|
</tr>
|
132
|
</table>
|
133
|
</form>
|
134
|
<script language="JavaScript">
|
135
|
<!--
|
136
|
enable_change(false);
|
137
|
//-->
|
138
|
</script>
|
139
|
<?php include("fend.inc"); ?>
|
140
|
</body>
|
141
|
</html>
|