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
b7adcb6c
Commit
b7adcb6c
authored
Oct 12, 2015
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(captiveportal, new) add api call for fetching web template
parent
7c0204bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
ServiceController.php
...trollers/OPNsense/CaptivePortal/Api/ServiceController.php
+36
-1
No files found.
src/opnsense/mvc/app/controllers/OPNsense/CaptivePortal/Api/ServiceController.php
View file @
b7adcb6c
...
...
@@ -31,6 +31,7 @@ namespace OPNsense\CaptivePortal\Api;
use
\OPNsense\Base\ApiControllerBase
;
use
\OPNsense\Core\Backend
;
use
\OPNsense\CaptivePortal\CaptivePortal
;
use
\Phalcon\Filter
;
/**
* Class ServiceController
...
...
@@ -72,7 +73,7 @@ class ServiceController extends ApiControllerBase
$status
=
"error reloading captive portal template"
;
}
}
else
{
$status
=
"error reloading captive portal rules ("
.
$bckresult
.
")"
;
$status
=
"error reloading captive portal rules ("
.
$bckresult
.
")"
;
}
return
array
(
"status"
=>
$status
);
...
...
@@ -80,4 +81,38 @@ class ServiceController extends ApiControllerBase
return
array
(
"status"
=>
"failed"
);
}
}
/**
* @param null $name template name
* @return mixed
* @throws \Exception
*/
public
function
getTemplateAction
(
$name
=
null
)
{
// get template name
$paramfilter
=
new
Filter
();
if
(
$name
!=
null
)
{
$templatename
=
$paramfilter
->
sanitize
(
$name
,
'alphanum'
);
}
else
{
$templatename
=
'default'
;
}
// request template data and output result (zipfile)
$backend
=
new
Backend
();
$response
=
$backend
->
configdpRun
(
"captiveportal fetch_template"
,
array
(
$templatename
));
$result
=
json_decode
(
$response
,
true
);
if
(
$result
!=
null
)
{
$response
=
$result
[
'payload'
];
$this
->
response
->
setContentType
(
'application/octet-stream'
,
'UTF-8'
);
$this
->
response
->
setHeader
(
"Content-disposition:"
,
"attachment; filename=template_"
.
$templatename
.
".zip"
);
return
base64_decode
(
$response
);
}
else
{
// return empty response on error
return
""
;
}
}
}
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