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
4918a819
Commit
4918a819
authored
Apr 15, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(legacy) $_GET should be $_POST, like in the rest of our code... last one, needs a bit of polishing
parent
8336e27b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
36 deletions
+42
-36
services.inc
src/etc/inc/services.inc
+32
-19
status_services.php
src/www/status_services.php
+10
-17
No files found.
src/etc/inc/services.inc
View file @
4918a819
...
...
@@ -2785,32 +2785,45 @@ function get_service_status_icon($service, $withtext = true, $smallicon = false)
function
get_service_control_links
(
$service
,
$addname
=
false
)
{
$stitle
=
$addname
?
$service
[
'name'
]
.
' '
:
''
;
$output
=
''
;
$output
=
"
<script type='text/javascript'>
$( document ).ready(function() {
$('.srv_status_act').click(function(event){
event.preventDefault();
params = {};
params['action'] = $(this).data('service_action');
params['service'] = $(this).data('service');
params['id'] = $(this).data('service_id');
$.post('/status_services.php',params, function(data) {
// refresh page after service action
location.reload();
});
});
});
</script>
"
;
if
(
get_service_status
(
$service
))
{
/* restart service button */
$output
.=
"<a href='status_services.php?action=restart&service=
{
$service
[
'name'
]
}
"
;
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
$service_id
=
$service
[
'id'
];
}
else
{
$service_id
=
""
;
}
$output
.=
"' class=
\"
btn btn-default
\"
>"
;
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Restart %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-refresh
\"
></span></a>
\n
"
;
$output
.=
"<span data-service_id=
\"
{
$service_id
}
\"
data-service_action=
\"
restart
\"
data-service=
\"
{
$service
[
'name'
]
}
\"
"
;
$output
.=
" data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title=
\"
"
;
$output
.=
sprintf
(
gettext
(
"Restart %sService"
),
$stitle
)
;
$output
.=
"
\"
class=
\"
btn btn-default srv_status_act glyphicon glyphicon-refresh
\"
></span></i>
\n
"
;
/* stop service button */
$output
.=
"<a href='status_services.php?action=stop&service=
{
$service
[
'name'
]
}
"
;
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
}
$output
.=
"' class=
\"
btn btn-default
\"
>"
;
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Stop %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-stop
\"
></span></a>"
;
$output
.=
"<span data-service_id=
\"
{
$service_id
}
\"
data-service_action=
\"
stop
\"
data-service=
\"
{
$service
[
'name'
]
}
\"
"
;
$output
.=
" data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title=
\"
"
;
$output
.=
sprintf
(
gettext
(
"Stop %sService"
),
$stitle
)
;
$output
.=
"
\"
class=
\"
btn btn-default srv_status_act glyphicon glyphicon-stop
\"
></span></i>
\n
"
;
}
else
{
/* start service button */
$output
.=
"<a href='status_services.php?action=start&service=
{
$service
[
'name'
]
}
"
;
if
(
isset
(
$service
[
'id'
]))
{
$output
.=
"&id=
{
$service
[
'id'
]
}
"
;
}
$output
.=
"' class=
\"
btn btn-default
\"
>"
;
$output
.=
"<span data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title='"
.
sprintf
(
gettext
(
"Start %sService"
),
$stitle
)
.
"' class=
\"
glyphicon glyphicon-play
\"
/></a>
\n
"
;
$output
.=
"<span data-service_id=
\"
{
$service_id
}
\"
data-service_action=
\"
start
\"
data-service=
\"
{
$service
[
'name'
]
}
\"
"
;
$output
.=
" data-toggle=
\"
tooltip
\"
data-placement=
\"
bottom
\"
title=
\"
"
;
$output
.=
sprintf
(
gettext
(
"Start %sService"
),
$stitle
)
;
$output
.=
"
\"
class=
\"
btn btn-default srv_status_act glyphicon glyphicon-play
\"
></span></i>
\n
"
;
}
return
$output
;
...
...
src/www/status_services.php
View file @
4918a819
...
...
@@ -41,34 +41,27 @@ require_once("ipsec.inc");
require_once
(
"interfaces.inc"
);
require_once
(
"rrd.inc"
);
if
(
!
empty
(
$_
GE
T
[
'service'
]))
{
$service_name
=
$_
GE
T
[
'service'
];
switch
(
$_
GE
T
[
'action'
])
{
if
(
!
empty
(
$_
POS
T
[
'service'
]))
{
$service_name
=
$_
POS
T
[
'service'
];
switch
(
$_
POS
T
[
'action'
])
{
case
'restart'
:
$savemsg
=
service_control_restart
(
$service_name
,
$_GE
T
);
service_control_restart
(
$service_name
,
$_POS
T
);
break
;
case
'start'
:
$savemsg
=
service_control_start
(
$service_name
,
$_GE
T
);
service_control_start
(
$service_name
,
$_POS
T
);
break
;
case
'stop'
:
$savemsg
=
service_control_stop
(
$service_name
,
$_GE
T
);
service_control_stop
(
$service_name
,
$_POS
T
);
break
;
}
if
(
isset
(
$_SERVER
[
'HTTP_REFERER'
]))
{
$referer
=
$_SERVER
[
'HTTP_REFERER'
];
if
(
strpos
(
$referer
,
$_SERVER
[
'PHP_SELF'
])
===
false
)
{
/* redirect only if launched from somewhere else */
header
(
'Location: '
.
$referer
);
exit
;
}
}
exit
;
}
function
service_control_start
(
$name
,
$extras
)
{
$msg
=
sprintf
(
gettext
(
'%s has been started.'
),
htmlspecialchars
(
$name
));
if
(
isset
(
$extras
[
'id'
]))
{
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
...
...
@@ -107,7 +100,7 @@ function service_control_stop($name, $extras)
$msg
=
sprintf
(
gettext
(
"%s has been stopped."
),
htmlspecialchars
(
$name
));
$filter
=
array
();
if
(
isset
(
$extras
[
'id'
]))
{
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
...
...
@@ -142,7 +135,7 @@ function service_control_restart($name, $extras)
{
$msg
=
sprintf
(
gettext
(
"%s has been restarted."
),
htmlspecialchars
(
$name
));
if
(
isset
(
$extras
[
'id'
]))
{
if
(
!
empty
(
$extras
[
'id'
]))
{
$filter
[
'id'
]
=
$extras
[
'id'
];
}
...
...
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