Project

General

Profile

Download (6.25 KB) Statistics
| Branch: | Tag: | Revision:
1
<?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

    
101
<?php include("fbegin.inc"); ?>
102
<?php if ($input_errors) print_input_errors($input_errors); ?>
103
<?php if (file_exists($d_sysrebootreqd_path) && !file_exists($d_ovpnccddirty_path)) print_info_box(get_std_save_message(0)); ?>
104
<form action="vpn_openvpn_ccd.php" method="post" enctype="multipart/form-data" name="iform" id="iform">
105
<?php if (file_exists($d_ovpnccddirty_path)): ?><p>
106
<?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.");?><br>
107
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
108
<?php endif; ?>
109

    
110
<table width="100%" border="0" cellpadding="0" cellspacing="0">
111
  <tr><td>
112
  <ul id="tabnav">	        
113
	<li class="tabinact"><a href="vpn_openvpn_srv.php">Server</a></li>
114
	<li class="tabinact"><a href="vpn_openvpn_cli.php">Client</a></li>
115
	<li class="tabact">Client-specific Configuration</li>
116
	<li class="tabinact"><a href="vpn_openvpn_crl.php">CRL</a></li>
117
  </ul>
118
  </td></tr>
119
  <tr>
120
  <td class="tabcont">
121
  <strong><span class="red">WARNING: This feature is experimental and modifies your optional interface configuration.
122
  Backup your configuration before using OpenVPN, and restore it before upgrading.<br>
123
&nbsp;  <br>
124
    </span></strong>
125
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
126
	<tr>
127
	  <td width="5%" class="list">&nbsp;</td>
128
	  <td width="38%" class="listhdrr">Common Name</td>
129
	  <td width="47%" class="listhdr">Description</td>
130
	  <td width="10%" class="list"></td>
131
	</tr>
132
	<?php $i = 0; foreach ($ovpnccd as $ccd):
133

    
134
		if (isset($ccd['disable']))
135
			$iconfn = "block";
136
		else
137
			$iconfn = "pass";
138

    
139
		if (!isset($ccd['enable'])) {
140
			$spans = "<span class=\"gray\">";
141
			$spane = "</span>";
142
			$iconfn .= "_d";
143
		} else {
144
			$spans = $spane = "";
145
		}
146
	?>
147
	
148
	<tr>
149
	  <td class="listt" align="center">
150
	  	<a href="?act=toggle&id=<?=$i;?>"><img src="<?=$iconfn;?>.gif"
151
		width="11" height="11" border="0" title="click to toggle enabled/disabled status"></a>
152
	  </td>
153
	  <td class="listlr"><?=$spans;?>
154
		<?= $ccd['cn'];?>
155
	  <?=$spane;?></td>
156
	  <td class="listbg"><?=$spans;?>
157
		<?= htmlspecialchars($ccd['descr']);?>&nbsp;
158
	  <?=$spane;?></td>
159
	  <td valign="middle" nowrap class="list"><a href="vpn_openvpn_ccd_edit.php?id=<?=$i;?>"><img src="e.gif" title="edit client-specific configuration" width="17" height="17" border="0"></a>
160
		&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="x.gif" title="delete client-specific configuration" width="17" height="17" border="0"></a></td>
161
	</tr>
162
  	<?php $i++; endforeach; ?>
163
	<tr> 
164
	  <td class="list" colspan="3">&nbsp;</td>
165
	  <td class="list"><a href="vpn_openvpn_ccd_edit.php"><img src="plus.gif" title="add client-specific configuration" width="17" height="17" border="0"></a></td>
166
	</tr>
167
    </table>
168
    <table border="0" cellspacing="0" cellpadding="0">
169
      <tr> 
170
	<td width="16"><img src="pass.gif" width="11" height="11"></td>
171
	  <td>pass</td>
172
	  <td width="14"></td>
173
	  <td width="16"><img src="block.gif" width="11" height="11"></td>
174
	  <td>block</td>
175
	</tr>
176
	<tr>
177
	  <td colspan="5" height="4"></td>
178
	</tr>
179
	<tr> 
180
	  <td><img src="pass_d.gif" width="11" height="11"></td>
181
	  <td>pass (disabled)</td>
182
	  <td></td>
183
	  <td><img src="block_d.gif" width="11" height="11"></td>
184
	  <td>block (disabled)</td>
185
	</tr>
186
    </table>
187
  </td>
188
</tr>
189
</table>
190
</form>
191
<?php include("fend.inc"); ?>
(139-139/155)