Files
librenms-librenms/app/Http/Controllers/LegacyController.php
Tony Murray 89fae9be1d Move API routing to Laravel (#10457)
* Add more api helper functions
to centralize code more

* Enable cors

* Initial Legacy route in Laravel

* Force api v0 responses to json
Add a couple more routes

* more paths, pretty print the json response
pass parameters to the api function

* devices basic functions

* Port generic graph function
check permissions function accepts callback to avoid lots of if statements

* move vlans

* links

* graphs

* fdb

* health

* wireless

* port graphs

* ip functions
split em up

* port_stack

* components

* compoment add/edit/delete

* get_device_groups

* port stats

* port graphs

* get_devices_by_group

* port_groups

* api_get_graph

* show_endpoints

* get_bill

* get_bill_graph

* get_bill_graphdata

* get_bill_history

* get_bill_history_graph

* remaining bill functions

* list_alerts

* ack/unmute alert

* Some cleanups

* Some cleanups

* list_alert_rules

* alert rule add/edit/delete

* inventory

* list_cbgp

* vrf

* list_ipsec

* list_fdb

* list_links (fix both usages)

* list_locations

* list_locations

* list_vlans

* list_ip_addresses

* list_arp

* list_ip_networks

* cleanup

* services

* list_logs and fix authlog.......

* cleanup

* cleanup 2

* remove slim

* don't load schema more than once

* basic test

* fix style

* downgrade laravel-cors to a version that supports PHP 7.1
2019-07-29 16:32:37 -05:00

82 lines
2.7 KiB
PHP

<?php
namespace App\Http\Controllers;
use App\Checks;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use LibreNMS\Config;
class LegacyController extends Controller
{
public function index(Request $request, Session $session)
{
Checks::postAuth();
// Set variables
$no_refresh = false;
$init_modules = ['web', 'auth'];
require base_path('/includes/init.php');
set_debug(str_contains($request->path(), 'debug'));
\LibreNMS\Plugins::start();
if (str_contains($request->path(), 'widescreen=yes')) {
$session->put('widescreen', 1);
}
if (str_contains($request->path(), 'widescreen=no')) {
$session->forget('widescreen');
}
# Load the settings for Multi-Tenancy.
if (Config::has('branding') && is_array(Config::get('branding'))) {
$branding = Arr::dot(Config::get('branding.' . $request->server('SERVER_NAME'), Config::get('branding.default')));
foreach ($branding as $key => $value) {
Config::set($key, $value);
}
}
# page_title_prefix is displayed, unless page_title is set FIXME: NEEDED?
if (Config::has('page_title')) {
Config::set('page_title_prefix', Config::get('page_title'));
}
// render page
ob_start();
$vars['page'] = basename($vars['page'] ?? '');
if ($vars['page'] && is_file("includes/html/pages/" . $vars['page'] . ".inc.php")) {
require "includes/html/pages/" . $vars['page'] . ".inc.php";
} elseif (Config::has('front_page') && is_file('includes/html/' . Config::get('front_page'))) {
require 'includes/html/' . Config::get('front_page');
} else {
require 'includes/html/pages/front/default.php';
}
$html = ob_get_clean();
ob_end_clean();
if (isset($pagetitle) && is_array($pagetitle)) {
# if prefix is set, put it in front
if (Config::get('page_title_prefix')) {
array_unshift($pagetitle, Config::get('page_title_prefix'));
}
# if suffix is set, put it in the back
if (Config::get('page_title_suffix')) {
$pagetitle[] = Config::get('page_title_suffix');
}
# create and set the title
$title = join(" - ", $pagetitle);
$html .= "<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>";
}
return response()->view('layouts.legacy_page', [
'content' => $html,
'refresh' => $no_refresh ? 0 : Config::get('page_refresh'),
]);
}
}