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:
@@ -18,13 +18,15 @@ use App\Models\PortsFdb;
|
||||
use App\Models\Sensor;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Routing\Router;
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Alerting\QueryBuilderParser;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Data\Store\Datastore;
|
||||
use LibreNMS\Exceptions\InvalidIpException;
|
||||
use LibreNMS\Util\IPv4;
|
||||
use LibreNMS\Util\IP;
|
||||
use LibreNMS\Util\IPv4;
|
||||
|
||||
function api_success($result, $result_name, $message = null, $code = 200, $count = null, $extra = null)
|
||||
{
|
||||
@@ -160,7 +162,7 @@ function get_port_stats_by_port_hostname(\Illuminate\Http\Request $request)
|
||||
$ifName = $request->route('ifname');
|
||||
|
||||
// handle %2f in paths and pass to get_graph_by_port_hostname if needed
|
||||
if (str_contains($ifName, '/')) {
|
||||
if (Str::contains($ifName, '/')) {
|
||||
$parts = explode('/', $request->path());
|
||||
|
||||
if (isset($parts[5])) {
|
||||
@@ -211,7 +213,7 @@ function get_graph_generic_by_hostname(\Illuminate\Http\Request $request)
|
||||
$vars['output'] = $request->get('output', 'display');
|
||||
if (isset($sensor_id)) {
|
||||
$vars['id'] = $sensor_id;
|
||||
if (str_contains($vars['type'], '_wireless')) {
|
||||
if (Str::contains($vars['type'], '_wireless')) {
|
||||
$vars['type'] = str_replace('device_', '', $vars['type']);
|
||||
} else {
|
||||
// If this isn't a wireless graph we need to fix the name.
|
||||
@@ -483,7 +485,7 @@ function show_endpoints(\Illuminate\Http\Request $request, Router $router)
|
||||
$base = str_replace('api/v0', '', $request->url());
|
||||
foreach ($router->getRoutes() as $route) {
|
||||
/** @var \Illuminate\Routing\Route $route */
|
||||
if (starts_with($route->getPrefix(), 'api/v0') && $route->getName()) {
|
||||
if (Str::startsWith($route->getPrefix(), 'api/v0') && $route->getName()) {
|
||||
$output[$route->getName()] = $base . $route->uri();
|
||||
}
|
||||
}
|
||||
@@ -633,7 +635,7 @@ function get_graph_by_portgroup(\Illuminate\Http\Request $request)
|
||||
|
||||
if (empty($id)) {
|
||||
$ports = get_ports_from_type(explode(',', $group));
|
||||
$if_list = implode(',', array_pluck($ports, 'port_id'));
|
||||
$if_list = implode(',', Arr::pluck($ports, 'port_id'));
|
||||
} else {
|
||||
$if_list = $id;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@
|
||||
* @author Neil Lathwood <gh+n@laf.io>
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Alerting\QueryBuilderParser;
|
||||
|
||||
header('Content-type: application/json');
|
||||
@@ -159,9 +160,9 @@ if (is_numeric($rule_id) && $rule_id > 0) {
|
||||
$groups = [];
|
||||
$locations = [];
|
||||
foreach ((array)$vars['maps'] as $item) {
|
||||
if (starts_with($item, 'l')) {
|
||||
if (Str::startsWith($item, 'l')) {
|
||||
$locations[] = (int)substr($item, 1);
|
||||
} elseif (starts_with($item, 'g')) {
|
||||
} elseif (Str::startsWith($item, 'g')) {
|
||||
$groups[] = (int)substr($item, 1);
|
||||
} else {
|
||||
$devices[] = (int)$item;
|
||||
@@ -176,7 +177,7 @@ if (is_numeric($rule_id) && $rule_id > 0) {
|
||||
$transports = [];
|
||||
$groups = [];
|
||||
foreach ((array)$vars['transports'] as $item) {
|
||||
if (starts_with($item, 'g')) {
|
||||
if (Str::startsWith($item, 'g')) {
|
||||
$groups[] = (int)substr($item, 1);
|
||||
} else {
|
||||
$transports[] = (int)$item;
|
||||
|
@@ -26,6 +26,8 @@
|
||||
* @author Tony Murray <murraytony@gmail.com>
|
||||
*/
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
header('Content-type: application/json');
|
||||
|
||||
if (!Auth::user()->hasGlobalAdmin()) {
|
||||
@@ -50,7 +52,7 @@ $new_title = convert_template($vars['title']);
|
||||
|
||||
function convert_template($line)
|
||||
{
|
||||
if (str_contains($line, '{calc')) {
|
||||
if (Str::contains($line, '{calc')) {
|
||||
return preg_replace(
|
||||
[
|
||||
'/{calc[ ]*([\w\d\s\%\.\(\)\*\/\-\+\/]+)}/',// Replaces {calc (something*100)}
|
||||
|
@@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
/*
|
||||
* LibreNMS
|
||||
*
|
||||
@@ -126,10 +128,10 @@ if ($sub_type == 'new-maintenance') {
|
||||
|
||||
foreach ($_POST['maps'] as $target) {
|
||||
$type = 'device';
|
||||
if (starts_with($target, 'l')) {
|
||||
if (Str::startsWith($target, 'l')) {
|
||||
$type = 'location';
|
||||
$target = substr($target, 1);
|
||||
} elseif (starts_with($target, 'g')) {
|
||||
} elseif (Str::startsWith($target, 'g')) {
|
||||
$type = 'device_group';
|
||||
$target = substr($target, 1);
|
||||
}
|
||||
|
Reference in New Issue
Block a user