Files
librenms-librenms/app/Http/Controllers/LegacyController.php
Tony Murray 9ede688d13 Replace legacy menu with new Blade generated one (#10173)
* Remove legacy index php file

* fix routing page missing data

* WIP

* fix $navbar global usage

* remove global use of $locations

* ObjectCache again...

* move vars.inc.php to init.php for legacy ajax

* navbar is more local than I thought before.  Fix it.

* Fix some sensors tables escaping

* restore custom menu functionality, but with blade
and docs

* cleanup

* tidy menu @if checks

* Fix up the rest of the global variables and remove print-menubar.php

* consolidate some counting in the menu

* filter out empty custom port descr types

* Fix up custom port groups

* Fix up apps menu

* Fix services menu when all are ok

* Limit cached data to the user it is for

* Fix style

* A few clean ups

* fix pseudowire bug
2019-05-10 11:02:39 -05:00

87 lines
2.8 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'),
]);
}
public function api($path = '')
{
include base_path('includes/html/legacy_api_v0.php');
}
}