Project

General

Profile

Download (7.47 KB) Statistics
| Branch: | Tag: | Revision:
1 afb07cf1 Scott Ullrich
<?php 
2
/*
3
	vpn_openvpn_ccd.php
4
5
	Copyright (C) 2005 Peter Allgeyer (allgeyer@web.de).
6
	All rights reserved.
7
	
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10
	
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13
	
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17
	
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29
30
require("guiconfig.inc");
31
require_once("openvpn.inc");
32
33
if (!is_array($config['ovpn']))
34
	$config['ovpn'] = array();
35
if (!is_array($config['ovpn']['server'])){
36
	$config['ovpn']['server'] =  array();
37
	$config['ovpn']['server']['tunnel'] =  array();
38
}
39
if (!is_array($config['ovpn']['server']['ccd']))
40
	$config['ovpn']['server']['ccd'] =  array();
41
42
$ovpnccd = &$config['ovpn']['server']['ccd'];
43
44
$id = $_GET['id'];
45
if (isset($_POST['id']))
46
        $id = $_POST['id'];
47
48
49
if ($_POST['apply']) {
50
	$retval = 0;
51
52
	$retval = ovpn_server_ccd_add();
53
54
#
55
#	/* should we send a SIGUSR1 to openvpn daemon? */
56
#	foreach ($config['ovpn']['server']['tunnel'] as $id => $server) {
57
#		/* get tunnel interface */
58
#		$tun = $server['tun_iface'];
59
#
60
#		/* send SIGUSR1 to running openvpn daemon */
61
#		if (isset($server['enable']))
62
#			sigkillbypid($g['varrun_path']."/ovpn_srv_{$tun}.pid", "SIGUSR1");
63
#	}
64
#
65
66
	/* remove dirty flag */
67
	unlink_if_exists($d_ovpnccddirty_path);
68
69
	$savemsg = get_std_save_message($retval);	
70
}
71
72
if ($_GET['act'] == "del") {
73
	if ($ovpnccd[$id]) {
74
		$ovpnent = $ovpnccd[$id];
75
76
		unset($ovpnccd[$id]);
77
		write_config();
78
79
		/* Remove config files */
80
		ovpn_server_ccd_del($ovpnent['cn']);
81
82
		header("Location: vpn_openvpn_ccd.php");
83
		exit;
84
	}
85
86
} else if ($_GET['act'] == "toggle") {
87
	if ($ovpnccd[$_GET['id']]) {
88
		$ovpnccd[$_GET['id']]['enable'] = !isset($ovpnccd[$_GET['id']]['enable']);
89
		write_config();
90
		touch($d_ovpnccddirty_path);
91
		header("Location: vpn_openvpn_ccd.php");
92
		exit;
93
	}
94
}
95
96
$pgtitle = "VPN: OpenVPN";
97
include("head.inc");
98
99
?>
100
<?php include("fbegin.inc"); ?>
101 4f8e387d Scott Ullrich
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
102
<p class="pgtitle"><?=$pgtitle?></p>
103 afb07cf1 Scott Ullrich
<?php if ($input_errors) print_input_errors($input_errors); ?>
104
<?php if (file_exists($d_sysrebootreqd_path) && !file_exists($d_ovpnccddirty_path)) print_info_box(get_std_save_message(0)); ?>
105 4f8e387d Scott Ullrich
106 afb07cf1 Scott Ullrich
<form action="vpn_openvpn_ccd.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
107
<?php if (file_exists($d_ovpnccddirty_path)): ?><p>
108 4f8e387d Scott Ullrich
<?php print_info_box_np("OpenVPN client-specific configuration options have been changed.<br>You must apply the changes in order for them to take effect.");?>
109 afb07cf1 Scott Ullrich
<?php endif; ?>
110
111
<table width="100%" border="0" cellpadding="0" cellspacing="0">
112
  <tr><td>
113 4f8e387d Scott Ullrich
<?php
114
	$tab_array = array();
115
	$tab_array[] = array("Server", false, "vpn_openvpn_srv.php");
116
	$tab_array[] = array("Client", false, "vpn_openvpn_cli.php");
117
	$tab_array[] = array("Client-specific Configuration", true, "vpn_openvpn_ccd.php");
118
	$tab_array[] = array("CRL", false, "vpn_openvpn_crl.php");
119
	display_top_tabs($tab_array);
120
?>
121 afb07cf1 Scott Ullrich
  </td></tr>
122 4f8e387d Scott Ullrich
123
  <tr> 
124
    <td>
125
	<div id="mainarea">
126
        <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
127
                <tr> 
128
                  <td class="vtable">
129
				    <strong><span class="red">WARNING: This feature is experimental and modifies your optional interface configuration.
130
					Backup your configuration before using OpenVPN, and restore it before upgrading.
131
				    </span></strong>
132
				  </td>
133
				</tr>
134
        </table>
135
136
    <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
137 afb07cf1 Scott Ullrich
	<tr>
138
	  <td width="5%" class="list">&nbsp;</td>
139
	  <td width="38%" class="listhdrr">Common Name</td>
140
	  <td width="47%" class="listhdr">Description</td>
141
	  <td width="10%" class="list"></td>
142
	</tr>
143
	<?php $i = 0; foreach ($ovpnccd as $ccd):
144
145
		if (isset($ccd['disable']))
146
			$iconfn = "block";
147
		else
148
			$iconfn = "pass";
149
150
		if (!isset($ccd['enable'])) {
151
			$spans = "<span class=\"gray\">";
152
			$spane = "</span>";
153
			$iconfn .= "_d";
154
		} else {
155
			$spans = $spane = "";
156
		}
157
	?>
158
	
159
	<tr>
160
	  <td class="listt" align="center">
161
	  	<a href="?act=toggle&id=<?=$i;?>"><img src="<?=$iconfn;?>.gif"
162
		width="11" height="11" border="0" title="click to toggle enabled/disabled status"></a>
163
	  </td>
164
	  <td class="listlr"><?=$spans;?>
165
		<?= $ccd['cn'];?>
166
	  <?=$spane;?></td>
167
	  <td class="listbg"><?=$spans;?>
168
		<?= htmlspecialchars($ccd['descr']);?>&nbsp;
169
	  <?=$spane;?></td>
170 4f8e387d Scott Ullrich
	  <td valign="middle" nowrap class="list"><a href="vpn_openvpn_ccd_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit client-specific configuration" width="17" height="17" border="0"></a>
171
		&nbsp;<a href="vpn_openvpn_ccd.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this client-specific configuration?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete client-specific configuration" width="17" height="17" border="0"></a></td>
172 afb07cf1 Scott Ullrich
	</tr>
173
  	<?php $i++; endforeach; ?>
174
	<tr> 
175
	  <td class="list" colspan="3">&nbsp;</td>
176 4f8e387d Scott Ullrich
	  <td class="list"><a href="vpn_openvpn_ccd_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add client-specific configuration" width="17" height="17" border="0"></a></td>
177 afb07cf1 Scott Ullrich
	</tr>
178
    </table>
179 4f8e387d Scott Ullrich
    <table class="tabcont" width="100%" border="0" cellspacing="0" cellpadding="0">
180
                <tr>
181
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass.gif" width="11" height="11"></td>
182
                  <td>pass</td>
183
                  <td width="14"></td>
184
                  <td width="16"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block.gif" width="11" height="11"></td>
185
                  <td>block</td>
186
                  <td width="14"></td>
187
                  <td width="16">&nbsp;</td>
188
                  <td>&nbsp;</td>
189
                  <td width="14"></td>
190
                  <td width="16">&nbsp;</td>
191
                  <td>&nbsp;</td>
192
                </tr>
193
                <tr>
194
                  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_pass_d.gif" width="11" height="11"></td>
195
                  <td nowrap>pass (disabled)</td>
196
                  <td>&nbsp;</td>
197
                  <td><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_block_d.gif" width="11" height="11"></td>
198
                  <td nowrap>block (disabled)</td>
199
                  <td>&nbsp;</td>
200
                  <td>&nbsp;</td>
201
                  <td nowrap>&nbsp;</td>
202
                  <td>&nbsp;</td>
203
                  <td width="16">&nbsp;</td>
204
                  <td nowrap>&nbsp;</td>
205
                </tr>
206 afb07cf1 Scott Ullrich
    </table>
207
  </td>
208
</tr>
209
</table>
210
</form>
211
<?php include("fend.inc"); ?>