Files
librenms-librenms/app/Http/Controllers/LegacyController.php
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

89 lines
2.7 KiB
PHP
Raw Normal View History

2018-05-09 08:05:17 -05:00
<?php
namespace App\Http\Controllers;
2018-09-11 07:51:35 -05:00
use App\Checks;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
2020-04-17 17:37:56 -05:00
use Illuminate\Support\Str;
use LibreNMS\Config;
2021-04-29 22:42:18 -05:00
use LibreNMS\Util\Debug;
2018-09-11 07:51:35 -05:00
2018-05-09 08:05:17 -05:00
class LegacyController extends Controller
{
public function index(Request $request, Session $session)
2018-05-09 08:05:17 -05:00
{
2018-09-11 07:51:35 -05:00
Checks::postAuth();
// Set variables
$no_refresh = false;
$init_modules = ['web', 'auth'];
require base_path('/includes/init.php');
2021-04-29 22:42:18 -05:00
Debug::set(Str::contains($request->path(), 'debug'));
ob_start(); // protect against bad plugins that output during start
\LibreNMS\Plugins::start();
ob_end_clean();
2020-04-17 17:37:56 -05:00
if (Str::contains($request->path(), 'widescreen=yes')) {
$session->put('widescreen', 1);
}
2020-04-17 17:37:56 -05:00
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
2018-05-09 08:05:17 -05:00
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';
} else {
abort(404);
}
2020-04-01 06:03:02 +02:00
2018-05-09 08:05:17 -05:00
$html = ob_get_clean();
ob_end_clean();
2018-05-09 08:05:17 -05:00
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'));
}
2018-05-09 08:05:17 -05:00
// 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
2023-05-24 22:21:54 +02:00
$title = implode(' - ', $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'),
]);
2018-05-09 08:05:17 -05:00
}
2020-06-05 11:50:58 -05:00
public function dummy()
{
return 'Dummy page';
}
2018-05-09 08:05:17 -05:00
}