Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
0ad90288
Commit
0ad90288
authored
Feb 11, 2016
by
Ad Schellevis
Committed by
Franco Fichtner
Feb 25, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) add multi select, move and toggle to vpn_openvpn_client.php
(cherry picked from commit
d9c91c3f
)
parent
3ffdac34
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
168 additions
and
81 deletions
+168
-81
vpn_openvpn_client.php
src/www/vpn_openvpn_client.php
+168
-81
No files found.
src/www/vpn_openvpn_client.php
View file @
0ad90288
...
...
@@ -123,6 +123,8 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
}
elseif
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
$pconfig
=
$_POST
;
$input_errors
=
array
();
if
(
isset
(
$_POST
[
'id'
])
&&
isset
(
$a_client
[
$_POST
[
'id'
]]))
{
$id
=
$_POST
[
'id'
];
}
...
...
@@ -132,20 +134,49 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if
(
$act
==
"del"
)
{
// remove client
if
(
!
isset
(
$id
))
{
if
(
isset
(
$id
))
{
openvpn_delete
(
'client'
,
$a_client
[
$id
]);
unset
(
$a_client
[
$id
]);
write_config
();
}
header
(
"Location: vpn_openvpn_client.php"
);
exit
;
}
elseif
(
$act
==
"del_x"
)
{
if
(
!
empty
(
$pconfig
[
'rule'
])
&&
is_array
(
$pconfig
[
'rule'
]))
{
foreach
(
$pconfig
[
'rule'
]
as
$rulei
)
{
if
(
isset
(
$a_client
[
$rulei
]))
{
openvpn_delete
(
'client'
,
$a_client
[
$rulei
]);
unset
(
$a_client
[
$rulei
]);
}
if
(
!
empty
(
$a_client
[
$id
]))
{
openvpn_delete
(
'client'
,
$a_client
[
$id
]);
}
unset
(
$a_client
[
$id
]);
write_config
();
}
header
(
"Location: vpn_openvpn_client.php"
);
exit
;
}
elseif
(
$act
==
"move"
){
// move selected items
if
(
!
isset
(
$id
))
{
// if id not set/found, move to end
$id
=
count
(
$a_client
);
}
$a_client
=
legacy_move_config_list_items
(
$a_client
,
$id
,
$pconfig
[
'rule'
]);
write_config
();
header
(
"Location: vpn_openvpn_client.php"
);
exit
;
}
elseif
(
$act
==
"toggle"
)
{
if
(
isset
(
$id
))
{
if
(
isset
(
$a_client
[
$id
][
'disable'
]))
{
unset
(
$a_client
[
$id
][
'disable'
]);
}
else
{
$a_client
[
$id
][
'disable'
]
=
true
;
}
openvpn_resync
(
'client'
,
$a_client
[
$id
]);
write_config
();
}
header
(
"Location: vpn_openvpn_client.php"
);
exit
;
}
else
{
// update client (after validation)
$pconfig
=
$_POST
;
$input_errors
=
array
();
if
(
isset
(
$id
))
{
$vpnid
=
$a_client
[
$id
][
'vpnid'
];
}
...
...
@@ -342,7 +373,8 @@ $( document ).ready(function() {
// link delete buttons
$
(
"
.act_delete
"
).
click
(
function
(){
var
id
=
$
(
this
).
attr
(
"
id
"
).
split
(
'
_
'
).
pop
(
-
1
);
var
id
=
$
(
this
).
data
(
"
id
"
);
if
(
id
!=
'
x
'
)
{
BootstrapDialog
.
show
({
type
:
BootstrapDialog
.
TYPE_DANGER
,
title
:
"
<?=
gettext
(
"OpenVPN"
);
?>
"
,
...
...
@@ -361,7 +393,43 @@ $( document ).ready(function() {
}
}]
});
}
else
{
// delete selected
BootstrapDialog
.
show
({
type
:
BootstrapDialog
.
TYPE_DANGER
,
title
:
"
<?=
gettext
(
"OpenVPN"
);
?>
"
,
message
:
"
<?=
gettext
(
"Do you really want to delete the selected clients?"
);
?>
"
,
buttons
:
[{
label
:
"
<?=
gettext
(
"No"
);
?>
"
,
action
:
function
(
dialogRef
)
{
dialogRef
.
close
();
}},
{
label
:
"
<?=
gettext
(
"Yes"
);
?>
"
,
action
:
function
(
dialogRef
)
{
$
(
"
#id
"
).
val
(
""
);
$
(
"
#action
"
).
val
(
"
del_x
"
);
$
(
"
#iform2
"
).
submit
()
}
}]
});
}
});
// link toggle buttons
$
(
"
.act_toggle
"
).
click
(
function
(){
$
.
post
(
window
.
location
,
{
act
:
'
toggle
'
,
id
:
$
(
this
).
data
(
"
id
"
)},
function
(
data
)
{
location
.
reload
();
});
});
// link move buttons
$
(
"
.act_move
"
).
click
(
function
(){
$
(
"
#id
"
).
val
(
$
(
this
).
data
(
"
id
"
));
$
(
"
#action
"
).
val
(
"
move
"
);
$
(
"
#iform2
"
).
submit
();
});
});
...
...
@@ -398,18 +466,18 @@ function dev_mode_change() {
}
function
autokey_change
()
{
if
(
document
.
iform
.
autokey_enable
!=
undefined
&&
document
.
iform
.
autokey_enable
.
checked
)
if
(
document
.
iform
.
autokey_enable
!=
undefined
&&
document
.
iform
.
autokey_enable
.
checked
)
{
document
.
getElementById
(
"
autokey_opts
"
).
style
.
display
=
"
none
"
;
else
}
else
{
document
.
getElementById
(
"
autokey_opts
"
).
style
.
display
=
""
;
}
}
function
useproxy_changed
()
{
if
(
jQuery
(
'
#proxy_authtype
'
).
val
()
!=
'
none
'
)
{
jQuery
(
'
#proxy_authtype_opts
'
).
show
();
if
(
$
(
'
#proxy_authtype
'
).
val
()
!=
'
none
'
)
{
$
(
'
#proxy_authtype_opts
'
).
show
();
}
else
{
jQuery
(
'
#proxy_authtype_opts
'
).
hide
();
$
(
'
#proxy_authtype_opts
'
).
hide
();
}
}
...
...
@@ -439,10 +507,11 @@ else :
<?php
endif
;
?>
if
(
document
.
iform
.
tlsauth_enable
.
checked
&&
!
autocheck
)
if
(
document
.
iform
.
tlsauth_enable
.
checked
&&
!
autocheck
)
{
document
.
getElementById
(
"
autotls_opts
"
).
style
.
display
=
""
;
else
}
else
{
document
.
getElementById
(
"
autotls_opts
"
).
style
.
display
=
"
none
"
;
}
}
//]]>
...
...
@@ -1006,10 +1075,13 @@ endif; ?>
</form>
<?php
else
:?>
<
form
method
=
"post"
name
=
"iform2"
id
=
"iform2"
>
<
input
type
=
"hidden"
id
=
"id"
name
=
"id"
value
=
""
/>
<
input
type
=
"hidden"
id
=
"action"
name
=
"act"
value
=
""
/>
<
table
class
="
table
table
-
striped
">
<thead>
<tr>
<td><?=gettext("
Disabled
"); ?
></td>
<td
></td>
<td><?=gettext("
Protocol
"); ?></td>
<td><?=gettext("
Server
"); ?></td>
<td><?=gettext("
Description
"); ?></td>
...
...
@@ -1020,14 +1092,14 @@ endif; ?>
<?php
$i
= 0;
foreach (
$a_client
as
$client
) :
$disabled
= "
NO
";
if (isset(
$client['disable']
)) {
$disabled
= "
YES
";
}
$server
= "
{
$client
[
'server_addr'
]}
:
{
$client
[
'server_port'
]}
";?>
<tr ondblclick="
document
.
location
=
'vpn_openvpn_client.php?act=edit&id=<?=$i;?>'
"
>
<tr
>
<td>
<?=
$disabled
;?>
<input type="
checkbox
" name="
rule
[]
" value="
<?=
$i
;
?>
" />
<a
href=
"#"
class=
"act_toggle"
data-id=
"
<?=
$i
;
?>
"
data-toggle=
"tooltip"
title=
"
<?=
(
empty
(
$client
[
'disable'
]))
?
gettext
(
"disable"
)
:
gettext
(
"enable"
);
?>
"
>
<span
class=
"glyphicon glyphicon-play
<?=
(
empty
(
$client
[
'disable'
]))
?
"text-success"
:
"text-muted"
;
?>
"
></span>
</a>
</td>
<td>
<?=
htmlspecialchars
(
$client
[
'protocol'
]);
?>
...
...
@@ -1039,10 +1111,13 @@ endif; ?>
<?=
htmlspecialchars
(
$client
[
'description'
]);
?>
</td>
<td>
<a
data-id=
"
<?=
$i
;
?>
"
data-toggle=
"tooltip"
title=
"
<?=
gettext
(
"move selected before this item"
);
?>
"
class=
"act_move btn btn-default btn-xs"
>
<span
class=
"glyphicon glyphicon-arrow-left"
></span>
</a>
<a
href=
"vpn_openvpn_client.php?act=edit&id=
<?=
$i
;
?>
"
class=
"btn btn-default btn-xs"
>
<span
class=
"glyphicon glyphicon-pencil"
></span>
</a>
<a
id=
"del_
<?=
$i
;
?>
"
title=
"
<?=
gettext
(
"delete client"
);
?>
"
class=
"act_delete btn btn-default btn-xs"
>
<a
data-id=
"
<?=
$i
;
?>
"
title=
"
<?=
gettext
(
"delete client"
);
?>
"
class=
"act_delete btn btn-default btn-xs"
>
<span
class=
"fa fa-trash text-muted"
></span>
</a>
<a
href=
"vpn_openvpn_client.php?act=new&dup=
<?=
$i
;
?>
"
class=
"btn btn-default btn-xs"
data-toggle=
"tooltip"
title=
"
<?=
gettext
(
"clone rule"
);
?>
"
>
...
...
@@ -1053,8 +1128,20 @@ endif; ?>
<?php
$i
++
;
endforeach
;
?>
<tr>
<td
colspan=
"4"
></td>
<td>
<a
data-id=
"
<?=
$i
;
?>
"
data-toggle=
"tooltip"
title=
"
<?=
gettext
(
"move selected items to end"
);
?>
"
class=
"act_move btn btn-default btn-xs"
>
<span
class=
"glyphicon glyphicon-arrow-down"
></span>
</a>
<a
data-id=
"x"
title=
"
<?=
gettext
(
"delete selected rules"
);
?>
"
data-toggle=
"tooltip"
class=
"act_delete btn btn-default btn-xs"
>
<span
class=
"fa fa-trash text-muted"
></span>
</a>
</td>
</tr>
</tbody>
</table>
<form>
<?php
endif
;
?>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment