mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-18 02:25:05 +00:00
(dashboard) the weirdness around stats.inc, getstats.php and ajax.js needs to be replaced with a more structural solution.
Because all current widgets depend on legacy code and we don't want to pollute new style mvc code with it, we choose to build a new broker in the old structure. This commit only includes the basic setup for the broken and an empty gateway_api() function
This commit is contained in:
parent
44b4ee49a7
commit
8e7bc1f679
75
src/www/widgets/api/get.php
Normal file
75
src/www/widgets/api/get.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2016 Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/*
|
||||
Simple wrapper to retrieve data for widgets using legacy code.
|
||||
Returns a json object containing a list of available plugins and for all requested plugins (parameter load) the
|
||||
collected data.
|
||||
*/
|
||||
|
||||
header("Last-Modified: " . gmdate( "D, j M Y H:i:s" ) . " GMT" );
|
||||
header("Expires: " . gmdate( "D, j M Y H:i:s", time() ) . " GMT" );
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate" );
|
||||
header("Cache-Control: post-check=0, pre-check=0", FALSE);
|
||||
header("Pragma: no-cache");
|
||||
|
||||
require_once("guiconfig.inc");
|
||||
// require legacy scripts, so plugins don't have to load them
|
||||
require_once("system.inc");
|
||||
require_once("config.inc");
|
||||
require_once("filter.inc");
|
||||
require_once("pfsense-utils.inc");
|
||||
require_once("interfaces.inc");
|
||||
|
||||
// parse request, load parameter contains all plugins that should be loaded for this request
|
||||
if (!empty($_REQUEST['load'])) {
|
||||
$loadPluginsList = explode(',', $_REQUEST['load']);
|
||||
} else {
|
||||
$loadPluginsList = array();
|
||||
}
|
||||
|
||||
// add metadata
|
||||
$result['system'] = $g['product_name'];
|
||||
// available plugins
|
||||
$result['plugins'] = array();
|
||||
// collected data
|
||||
$result['data'] = array();
|
||||
|
||||
// probe plugins
|
||||
foreach (glob(__DIR__."/plugins/*.php") as $filename) {
|
||||
$pluginName = basename($filename, '.php');
|
||||
$result['plugins'][] = $pluginName;
|
||||
if (in_array($pluginName, $loadPluginsList)) {
|
||||
require $filename;
|
||||
$pluginFunctionName = $pluginName."_api";
|
||||
if (function_exists($pluginName."_api")) {
|
||||
$result['data'][$pluginName] = $pluginFunctionName();
|
||||
}
|
||||
}
|
||||
}
|
||||
// output result
|
||||
echo json_encode($result);
|
||||
31
src/www/widgets/api/plugins/gateway.php
Normal file
31
src/www/widgets/api/plugins/gateway.php
Normal file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
/*
|
||||
Copyright (C) 2016 Deciso B.V.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
function gateway_api()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user