2015-07-21 23:01:57 +01:00
< ? php
/*
* LibreNMS
*
* Copyright ( c ) 2014 Neil Lathwood < https :// github . com / laf / http :// www . lathwood . co . uk / fa >
*
* This program is free software : you can redistribute it and / or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation , either version 3 of the License , or ( at your
* option ) any later version . Please see LICENSE . txt at the top level of
* the source code distribution for details .
*/
require_once '../includes/defaults.inc.php' ;
2015-07-23 17:48:22 +01:00
set_debug ( $_REQUEST [ 'debug' ]);
2015-07-21 23:01:57 +01:00
require_once '../config.php' ;
require_once '../includes/definitions.inc.php' ;
require_once 'includes/functions.inc.php' ;
require_once '../includes/functions.php' ;
require_once 'includes/authenticate.inc.php' ;
if ( ! $_SESSION [ 'authenticated' ]) {
echo 'unauthenticated' ;
exit ;
}
$type = mres ( $_POST [ 'type' ]);
if ( $type == 'placeholder' ) {
2015-10-02 07:21:37 +00:00
$output = " <span style='text-align:left;'><br><h3>Click on Edit-Dashboard to add Widgets</h3><br><h4><strong>Remember:</strong> You can only move & rezise widgets when you're in <strong>Edit-Mode</strong>.</h4><span> " ;
2015-07-21 23:01:57 +01:00
$status = 'ok' ;
2015-09-06 13:18:54 +01:00
$title = 'Placeholder' ;
2015-07-21 23:01:57 +01:00
}
elseif ( is_file ( 'includes/common/' . $type . '.inc.php' )) {
2015-09-05 16:15:11 +01:00
$results_limit = 10 ;
$no_form = true ;
2015-09-06 13:18:54 +01:00
$title = ucfirst ( $type );
$unique_id = str_replace ( array ( " - " , " . " ), " _ " , uniqid ( $type , true ));
2015-09-05 16:15:11 +01:00
$widget_id = mres ( $_POST [ 'id' ]);
$widget_settings = json_decode ( dbFetchCell ( 'select settings from users_widgets where user_widget_id = ?' , array ( $widget_id )), true );
2015-09-06 13:18:54 +01:00
$widget_dimensions = $_POST [ 'dimensions' ];
if ( ! empty ( $_POST [ 'settings' ]) ) {
define ( 'show_settings' , true );
}
2015-07-21 23:01:57 +01:00
include 'includes/common/' . $type . '.inc.php' ;
$output = implode ( '' , $common_output );
$status = 'ok' ;
2015-09-06 13:18:54 +01:00
$title = $widget_settings [ 'title' ] ? : $title ;
2015-07-21 23:01:57 +01:00
}
$response = array (
'status' => $status ,
'html' => $output ,
2015-09-06 13:18:54 +01:00
'title' => $title ,
2015-07-21 23:01:57 +01:00
);
echo _json_encode ( $response );