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
96dfff26
Commit
96dfff26
authored
Aug 12, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) refactor vpn_ipsec_keys.php
parent
575c202e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
131 additions
and
136 deletions
+131
-136
vpn_ipsec_keys.php
src/www/vpn_ipsec_keys.php
+131
-136
No files found.
src/www/vpn_ipsec_keys.php
View file @
96dfff26
...
...
@@ -39,19 +39,22 @@ if (!is_array($config['ipsec'])) {
if
(
!
is_array
(
$config
[
'ipsec'
][
'mobilekey'
]))
{
$config
[
'ipsec'
][
'mobilekey'
]
=
array
();
}
else
{
ipsec_mobilekey_sort
();
}
ipsec_mobilekey_sort
();
$a_secret
=
&
$config
[
'ipsec'
][
'mobilekey'
];
$userkeys
=
array
();
foreach
(
$config
[
'system'
][
'user'
]
as
$id
=>
$user
)
{
if
(
!
empty
(
$user
[
'ipsecpsk'
]))
{
$userkeys
[]
=
array
(
'ident'
=>
$user
[
'name'
],
'pre-shared-key'
=>
$user
[
'ipsecpsk'
],
'id'
=>
$id
);
;
if
(
$_SERVER
[
'REQUEST_METHOD'
]
===
'POST'
)
{
if
(
isset
(
$_POST
[
'act'
])
&&
isset
(
$_POST
[
'id'
])
&&
is_numericint
(
$_POST
[
'id'
])
&&
$_POST
[
'act'
]
==
"del"
)
{
// delete entry
if
(
isset
(
$config
[
'ipsec'
][
'mobilekey'
][
$_POST
[
'id'
]]))
{
unset
(
$config
[
'ipsec'
][
'mobilekey'
][
$_POST
[
'id'
]]);
write_config
(
gettext
(
"Deleted IPsec Pre-Shared Key"
));
mark_subsystem_dirty
(
'ipsec'
);
header
(
"Location: vpn_ipsec_keys.php"
);
exit
;
}
}
if
(
isset
(
$_POST
[
'apply'
]))
{
}
elseif
(
isset
(
$_POST
[
'apply'
]))
{
// apply changes
$retval
=
vpn_ipsec_configure
();
/* reload the filter in the background */
filter_configure
();
...
...
@@ -59,13 +62,8 @@ if (isset($_POST['apply'])) {
if
(
is_subsystem_dirty
(
'ipsec'
))
{
clear_subsystem_dirty
(
'ipsec'
);
}
}
if
(
$_GET
[
'act'
]
==
"del"
)
{
if
(
$a_secret
[
$_GET
[
'id'
]])
{
unset
(
$a_secret
[
$_GET
[
'id'
]]);
write_config
(
gettext
(
"Deleted IPsec Pre-Shared Key"
));
mark_subsystem_dirty
(
'ipsec'
);
}
else
{
// nothing to post, redirect
header
(
"Location: vpn_ipsec_keys.php"
);
exit
;
}
...
...
@@ -75,18 +73,43 @@ $pgtitle = gettext("VPN: IPsec: Keys");
$shortcut_section
=
"ipsec"
;
include
(
"head.inc"
);
?>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
// link delete buttons
$
(
"
.act_delete
"
).
click
(
function
(){
var
id
=
$
(
this
).
attr
(
"
id
"
).
split
(
'
_
'
).
pop
(
-
1
);
BootstrapDialog
.
show
({
type
:
BootstrapDialog
.
TYPE_INFO
,
title
:
"
<?=
gettext
(
"IPsec"
);
?>
"
,
message
:
"
<?=
gettext
(
"Do you really want to delete this Pre-Shared Key?"
);
?>
"
,
buttons
:
[{
label
:
"
<?=
gettext
(
"No"
);
?>
"
,
action
:
function
(
dialogRef
)
{
dialogRef
.
close
();
}},
{
label
:
"
<?=
gettext
(
"Yes"
);
?>
"
,
action
:
function
(
dialogRef
)
{
$
.
post
(
window
.
location
,
{
act
:
'
del
'
,
id
:
id
},
function
(
data
)
{
location
.
reload
();
});
dialogRef
.
close
();
}
}]
});
});
});
</script>
<body>
<?php
include
(
"fbegin.inc"
);
?>
<section
class=
"page-content-main"
>
<div
class=
"container-fluid"
>
<div
class=
"row"
>
<?php
<?php
if
(
isset
(
$savemsg
))
{
print_info_box
(
$savemsg
);
}
...
...
@@ -94,106 +117,78 @@ include("head.inc");
print_info_box_np
(
gettext
(
"The IPsec tunnel configuration has been changed"
)
.
".<br />"
.
gettext
(
"You must apply the changes in order for them to take effect."
));
}
?>
?>
<section
class=
"col-xs-12"
>
<?
$active_tab
=
"/vpn_ipsec_settings.php"
;
include
(
'vpn_ipsec_tabs.inc'
);
?>
<?php
$active_tab
=
"/vpn_ipsec_settings.php"
;
include
(
'vpn_ipsec_tabs.inc'
);
?>
<div
class=
"tab-content content-box col-xs-12"
>
<form
action=
"vpn_ipsec_keys.php"
method=
"post"
>
<div
class=
"table-responsive"
>
<table
class=
"table table-striped table-sort"
>
<table
class=
"table table-striped"
>
<tr>
<td
class=
"listhdrr"
>
<?=
gettext
(
"Identifier"
);
?>
</td>
<td
class=
"listhdr"
>
<?=
gettext
(
"Pre-Shared Key"
);
?>
</td>
<td
class=
"list"
>
<table
border=
"0"
cellspacing=
"0"
cellpadding=
"1"
summary=
"add key"
>
<tr>
<td
width=
"20"
height=
"17"
></td>
<td><a
href=
"vpn_ipsec_keys_edit.php"
class=
"btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-plus"
></span></a></td>
</tr>
</table>
<td>
<?=
gettext
(
"Identifier"
);
?>
</td>
<td>
<?=
gettext
(
"Pre-Shared Key"
);
?>
</td>
<td>
<a
href=
"vpn_ipsec_keys_edit.php"
class=
"btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-plus"
></span></a>
</td>
</tr>
<?php
$i
=
0
;
foreach
(
$userkeys
as
$secretent
)
:
<?php
$i
=
0
;
$userkeys
=
array
();
foreach
(
$config
[
'system'
][
'user'
]
as
$id
=>
$user
)
{
if
(
!
empty
(
$user
[
'ipsecpsk'
]))
{
$userkeys
[]
=
array
(
'ident'
=>
$user
[
'name'
],
'pre-shared-key'
=>
$user
[
'ipsecpsk'
],
'id'
=>
$id
);
;
}
}
foreach
(
$userkeys
as
$secretent
)
:
?>
<tr>
<td
class=
"listlr gray"
>
<?php
if
(
$secretent
[
'ident'
]
==
'allusers'
)
{
echo
gettext
(
"ANY USER"
);
}
else
{
echo
htmlspecialchars
(
$secretent
[
'ident'
]);
}
?>
<td>
<?=
$secretent
[
'ident'
]
==
'allusers'
?
gettext
(
"ANY USER"
)
:
htmlspecialchars
(
$secretent
[
'ident'
])
;
?>
</td>
<td
class=
"listr gray"
>
<td
>
<?=
htmlspecialchars
(
$secretent
[
'pre-shared-key'
]);
?>
</td>
<td
class=
"list nowrap"
>
<form
action=
"system_usermanager.php"
method=
"post"
name=
"form_edit_key"
>
<input
type=
"hidden"
name=
"act"
value=
"edit"
/>
<input
type=
"hidden"
name=
"userid"
value=
"
<?=
$secretent
[
'id'
];
?>
"
/>
<input
type=
"image"
name=
"edituser[]"
width=
"17"
height=
"17"
border=
"0"
src=
"/themes/
<?=
$g
[
'theme'
];
?>
/images/icons/icon_e.gif"
title=
"
<?=
gettext
(
"edit"
);
?>
"
/>
</form>
</td>
<td>
<a
href=
"system_usermanager.php?userid=
<?=
$secretent
[
'id'
];
?>
&act=edit"
title=
"
<?=
gettext
(
"edit"
);
?>
"
class=
"btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-pencil"
></span></a>
</td>
</tr>
<?php
$i
++
;
endforeach
;
?>
<?php
$i
=
0
;
foreach
(
$a_secret
as
$secretent
)
:
<?php
$i
++
;
endforeach
;
?>
<?php
$i
=
0
;
foreach
(
$config
[
'ipsec'
][
'mobilekey'
]
as
$secretent
)
:
?>
<tr>
<td
class=
"listlr"
>
<td
>
<?=
htmlspecialchars
(
$secretent
[
'ident'
]);
?>
</td>
<td
class=
"listr"
>
<td
>
<?=
htmlspecialchars
(
$secretent
[
'pre-shared-key'
]);
?>
</td>
<td
class=
"list nowrap"
><a
href=
"vpn_ipsec_keys_edit.php?id=
<?=
$i
;
?>
"
><img
src=
"./themes/
<?=
$g
[
'theme'
];
?>
/images/icons/icon_e.gif"
title=
"
<?=
gettext
(
"edit key"
);
?>
"
width=
"17"
height=
"17"
border=
"0"
alt=
"edit"
/></a>
<a
href=
"vpn_ipsec_keys.php?act=del&id=
<?=
$i
;
?>
"
onclick=
"return confirm('
<?=
gettext
(
"Do you really want to delete this Pre-Shared Key?"
);
?>
')"
><img
src=
"./themes/
<?=
$g
[
'theme'
];
?>
/images/icons/icon_x.gif"
title=
"
<?=
gettext
(
"delete key"
);
?>
"
width=
"17"
height=
"17"
border=
"0"
alt=
"delete"
/></a></td>
<td>
<a
href=
"vpn_ipsec_keys_edit.php?id=
<?=
$i
;
?>
"
title=
"
<?=
gettext
(
"edit key"
);
?>
"
class=
"btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-pencil"
></span></a>
<a
id=
"del_
<?=
$i
;
?>
"
title=
"
<?=
gettext
(
"delete key"
);
?>
"
class=
"act_delete btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-remove"
></span></a>
</td>
</tr>
<?php
$i
++
;
endforeach
;
?>
<tr>
<td
class=
"list"
colspan=
"2"
></td>
<td
class=
"list"
>
<table
border=
"0"
cellspacing=
"0"
cellpadding=
"1"
summary=
"add key"
>
<?php
$i
++
;
endforeach
;
?>
<tr>
<td
width=
"20"
height=
"17"
></td>
<td><a
href=
"vpn_ipsec_keys_edit.php"
class=
"btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-plus"
></span></a></td>
</tr>
</table>
<td
colspan=
"2"
></td>
<td>
<a
href=
"vpn_ipsec_keys_edit.php"
class=
"btn btn-default btn-xs"
><span
class=
"glyphicon glyphicon-plus"
></span></a>
</td>
</tr>
</table>
</div>
</form>
<div
class=
"container-fluid"
>
<p>
<span
class=
"vexpl"
>
<span
class=
"text-danger"
>
<strong>
<?=
gettext
(
"Note"
);
?>
:
<br
/></strong>
</span>
<?=
gettext
(
"PSK for any user can be set by using an identifier of any/ANY"
);
?>
</span>
</p>
</div>
</div>
</section>
...
...
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