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:
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Config;
|
||||
use LibreNMS\Authentication\LegacyAuth;
|
||||
|
||||
@@ -33,7 +34,7 @@ echo "Authentication Method: " . Config::get('auth_mechanism') . PHP_EOL;
|
||||
// if ldap like, check selinux
|
||||
if (Config::get('auth_mechanism') == 'ldap' || Config::get('auth_mechanism') == "active_directory") {
|
||||
$enforce = shell_exec('getenforce 2>/dev/null');
|
||||
if (str_contains($enforce, 'Enforcing')) {
|
||||
if (Str::contains($enforce, 'Enforcing')) {
|
||||
// has selinux
|
||||
$output = shell_exec('getsebool httpd_can_connect_ldap');
|
||||
if ($output != "httpd_can_connect_ldap --> on\n") {
|
||||
|
@@ -2,6 +2,7 @@
|
||||
<?php
|
||||
|
||||
use LibreNMS\Config;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
$install_dir = realpath(__DIR__ . '/..');
|
||||
chdir($install_dir);
|
||||
@@ -36,7 +37,7 @@ if (isset($options['h'])) {
|
||||
if (is_numeric($options['h'])) {
|
||||
$where = "AND `device_id` = ?";
|
||||
$params = array($options['h']);
|
||||
} elseif (str_contains($options['h'], ',')) {
|
||||
} elseif (Str::contains($options['h'], ',')) {
|
||||
$device_ids = array_map('trim', explode(',', $options['h']));
|
||||
$device_ids = array_filter($device_ids, 'is_numeric');
|
||||
$where = 'AND `device_id` in ' . dbGenPlaceholders(count($device_ids));
|
||||
|
@@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
use LibreNMS\Exceptions\InvalidModuleException;
|
||||
use LibreNMS\Util\ModuleTestHelper;
|
||||
use LibreNMS\Util\Snmpsim;
|
||||
@@ -98,7 +99,7 @@ if (isset($options['v'])) {
|
||||
$variant = $options['variant'];
|
||||
}
|
||||
|
||||
if (str_contains($variant, '_')) {
|
||||
if (Str::contains($variant, '_')) {
|
||||
exit("Variant name cannot contain an underscore (_).\n");
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
$filename = basename(__FILE__);
|
||||
$install_dir = realpath(__DIR__ . '/..');
|
||||
chdir($install_dir);
|
||||
@@ -25,13 +27,13 @@ $map = [
|
||||
];
|
||||
|
||||
foreach ($changed_files as $file) {
|
||||
if (starts_with($file, 'doc/')) {
|
||||
if (Str::startsWith($file, 'doc/')) {
|
||||
$map['docs']++;
|
||||
}
|
||||
if (ends_with($file, '.py')) {
|
||||
if (Str::endsWith($file, '.py')) {
|
||||
$map['python']++;
|
||||
}
|
||||
if (ends_with($file, '.sh')) {
|
||||
if (Str::endsWith($file, '.sh')) {
|
||||
$map['bash']++;
|
||||
}
|
||||
|
||||
@@ -43,10 +45,10 @@ foreach ($changed_files as $file) {
|
||||
// check if os owned file or generic php file
|
||||
if (!empty($os_name = os_from_file($file))) {
|
||||
$map['os'][] = $os_name;
|
||||
if (ends_with($file, '.php')) {
|
||||
if (Str::endsWith($file, '.php')) {
|
||||
$map['os-php']++;
|
||||
}
|
||||
} elseif (ends_with($file, '.php')) {
|
||||
} elseif (Str::endsWith($file, '.php')) {
|
||||
$map['php']++;
|
||||
}
|
||||
}
|
||||
@@ -178,11 +180,11 @@ exit($return); //return the combined/single return value of tests
|
||||
|
||||
function os_from_file($file)
|
||||
{
|
||||
if (starts_with($file, 'includes/definitions/')) {
|
||||
if (Str::startsWith($file, 'includes/definitions/')) {
|
||||
return basename($file, '.yaml');
|
||||
} elseif (starts_with($file, ['includes/polling', 'includes/discovery'])) {
|
||||
} elseif (Str::startsWith($file, ['includes/polling', 'includes/discovery'])) {
|
||||
return os_from_php($file);
|
||||
} elseif (starts_with($file, 'LibreNMS/OS/')) {
|
||||
} elseif (Str::startsWith($file, 'LibreNMS/OS/')) {
|
||||
if (preg_match('#LibreNMS/OS/[^/]+.php#', $file)) {
|
||||
// convert class name to os name
|
||||
preg_match_all("/[A-Z][a-z]*/", basename($file, '.php'), $segments);
|
||||
@@ -193,7 +195,7 @@ function os_from_file($file)
|
||||
}
|
||||
return os_from_php(str_replace('-', '_', $osname));
|
||||
}
|
||||
} elseif (starts_with($file, ['tests/snmpsim/', 'tests/data/'])) {
|
||||
} elseif (Str::startsWith($file, ['tests/snmpsim/', 'tests/data/'])) {
|
||||
list($os,) = explode('_', basename(basename($file, '.json'), '.snmprec'), 2);
|
||||
return $os;
|
||||
}
|
||||
|
Reference in New Issue
Block a user