mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Remove Laravel helpers (#11428)
* Remove Laravel helpers * Replace qualifier with import
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
namespace App\Http\Controllers\Ajax;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Str;
|
||||
use \LibreNMS\Config;
|
||||
use Illuminate\Http\Request;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
@@ -71,7 +72,7 @@ class NetCommand extends Controller
|
||||
function () use ($proc, $request) {
|
||||
// a bit dirty, bust browser initial cache
|
||||
$ua = $request->header('User-Agent');
|
||||
if (str_contains($ua, ['Chrome', 'Trident'])) {
|
||||
if (Str::contains($ua, ['Chrome', 'Trident'])) {
|
||||
$char = "\f"; // line feed
|
||||
} else {
|
||||
$char = "";
|
||||
|
@@ -6,6 +6,7 @@ use App\Checks;
|
||||
use Illuminate\Contracts\Session\Session;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Config;
|
||||
|
||||
class LegacyController extends Controller
|
||||
@@ -19,16 +20,16 @@ class LegacyController extends Controller
|
||||
$init_modules = ['web', 'auth'];
|
||||
require base_path('/includes/init.php');
|
||||
|
||||
set_debug(str_contains($request->path(), 'debug'));
|
||||
set_debug(Str::contains($request->path(), 'debug'));
|
||||
|
||||
ob_start(); // protect against bad plugins that output during start
|
||||
\LibreNMS\Plugins::start();
|
||||
ob_end_clean();
|
||||
|
||||
if (str_contains($request->path(), 'widescreen=yes')) {
|
||||
if (Str::contains($request->path(), 'widescreen=yes')) {
|
||||
$session->put('widescreen', 1);
|
||||
}
|
||||
if (str_contains($request->path(), 'widescreen=no')) {
|
||||
if (Str::contains($request->path(), 'widescreen=no')) {
|
||||
$session->forget('widescreen');
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ namespace App\Http\Controllers\Select;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Config;
|
||||
|
||||
class GraphAggregateController extends Controller
|
||||
@@ -56,7 +57,7 @@ class GraphAggregateController extends Controller
|
||||
// handle search
|
||||
if ($search = strtolower($request->get('term'))) {
|
||||
$types = array_filter($types, function ($type) use ($search) {
|
||||
return !str_contains(strtolower($type), $search);
|
||||
return !Str::contains(strtolower($type), $search);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -29,6 +29,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\Device;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Util\Graph;
|
||||
use LibreNMS\Util\StringHelpers;
|
||||
|
||||
@@ -100,7 +101,7 @@ class GraphController extends Controller
|
||||
private function formatGraph($top, $graph)
|
||||
{
|
||||
$text = $graph;
|
||||
if (str_contains('_', $graph)) {
|
||||
if (Str::contains('_', $graph)) {
|
||||
list($type, $subtype) = explode('_', $graph, 2);
|
||||
} else {
|
||||
$type = $graph;
|
||||
@@ -131,18 +132,18 @@ class GraphController extends Controller
|
||||
$terms = preg_split('/[ _-]/', $search, 2);
|
||||
$first = array_shift($terms);
|
||||
|
||||
if (str_contains($type, $first)) {
|
||||
if (Str::contains($type, $first)) {
|
||||
// search matches type, show all unless there are more terms.
|
||||
if (!empty($terms)) {
|
||||
$sub_search = array_shift($terms);
|
||||
$graphs = $graphs->filter(function ($graph) use ($sub_search) {
|
||||
return str_contains(strtolower($graph), $sub_search);
|
||||
return Str::contains(strtolower($graph), $sub_search);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// if the type matches, don't filter the sub values
|
||||
$graphs = $graphs->filter(function ($graph) use ($search) {
|
||||
return str_contains(strtolower($graph), $search);
|
||||
return Str::contains(strtolower($graph), $search);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,7 @@ namespace App\Http\Controllers\Select;
|
||||
use App\ApiClients\GraylogApi;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
|
||||
class GraylogStreamsController extends Controller
|
||||
@@ -50,7 +51,7 @@ class GraylogStreamsController extends Controller
|
||||
$streams = [];
|
||||
try {
|
||||
$streams = collect($api->getStreams()['streams'])->filter(function ($stream) use ($search) {
|
||||
return !$search || str_contains(strtolower($stream['title']), $search) || str_contains(strtolower($stream['description']), $search);
|
||||
return !$search || Str::contains(strtolower($stream['title']), $search) || Str::contains(strtolower($stream['description']), $search);
|
||||
})->map(function ($stream) {
|
||||
$text = $stream['title'];
|
||||
if ($stream['description']) {
|
||||
|
@@ -26,6 +26,7 @@
|
||||
namespace App\Http\Controllers\Table;
|
||||
|
||||
use App\Models\Port;
|
||||
use Illuminate\Support\Arr;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Util\Html;
|
||||
use LibreNMS\Util\Url;
|
||||
@@ -128,6 +129,6 @@ class CustomersController extends TableController
|
||||
|
||||
private function getTypeStrings()
|
||||
{
|
||||
return array_wrap(Config::get('customers_descr', ['cust']));
|
||||
return Arr::wrap(Config::get('customers_descr', ['cust']));
|
||||
}
|
||||
}
|
||||
|
@@ -31,6 +31,7 @@ use App\Models\AuthLog;
|
||||
use App\Models\Dashboard;
|
||||
use App\Models\User;
|
||||
use App\Models\UserPref;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
use LibreNMS\Config;
|
||||
use Toastr;
|
||||
@@ -177,7 +178,7 @@ class UserController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
return redirect(route(str_contains(URL::previous(), 'preferences') ? 'preferences.index' : 'users.index'));
|
||||
return redirect(route(Str::contains(URL::previous(), 'preferences') ? 'preferences.index' : 'users.index'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -26,6 +26,7 @@
|
||||
namespace App\Http\Controllers\Widgets;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ImageController extends WidgetController
|
||||
{
|
||||
@@ -51,7 +52,7 @@ class ImageController extends WidgetController
|
||||
$data['image_url'] = str_replace(['@AUTO_HEIGHT@', '@AUTO_WIDTH@'], [$dimensions['y'], $dimensions['x']], $data['image_url']);
|
||||
|
||||
// bust cache
|
||||
if (str_contains($data['image_url'], '?')) {
|
||||
if (Str::contains($data['image_url'], '?')) {
|
||||
$data['image_url'] .= '&' . mt_rand();
|
||||
} else {
|
||||
$data['image_url'] .= '?' . mt_rand();
|
||||
|
@@ -29,6 +29,7 @@ use App\Http\Controllers\Controller;
|
||||
use App\Models\DeviceGroup;
|
||||
use App\Models\UserWidget;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
abstract class WidgetController extends Controller
|
||||
@@ -115,7 +116,7 @@ abstract class WidgetController extends Controller
|
||||
{
|
||||
if ($view instanceof View) {
|
||||
$html = $view->__toString();
|
||||
$show_settings = (int)starts_with($view->getName(), 'widgets.settings.');
|
||||
$show_settings = (int)Str::startsWith($view->getName(), 'widgets.settings.');
|
||||
} else {
|
||||
$html = (string)$view;
|
||||
$show_settings = (int)$this->show_settings;
|
||||
|
@@ -4,6 +4,7 @@ namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\UserPref;
|
||||
use Closure;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Config;
|
||||
|
||||
class VerifyTwoFactor
|
||||
@@ -20,7 +21,7 @@ class VerifyTwoFactor
|
||||
// check twofactor
|
||||
if (Config::get('twofactor') === true) {
|
||||
// don't apply on 2fa checking routes
|
||||
if (starts_with($request->route()->getName(), '2fa.')) {
|
||||
if (Str::startsWith($request->route()->getName(), '2fa.')) {
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user