mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Use PDO for MySQL queries (#8935)
Gut dbFacile mres() now does nothing... could have some vulnerable queries, but most are ok TODO - [x] IRC client broke - [x] Install broke DO NOT DELETE THIS TEXT #### Please note > Please read this information carefully. You can run `./scripts/pre-commit.php` to check your code before submitting. - [x] Have you followed our [code guidelines?](http://docs.librenms.org/Developing/Code-Guidelines/) #### Testers If you would like to test this pull request then please run: `./scripts/github-apply <pr_id>`, i.e `./scripts/github-apply 5926`
This commit is contained in:
committed by
Neil Lathwood
parent
86c097574b
commit
a2e33efba8
@@ -18,18 +18,10 @@ use LibreNMS\Exceptions\LockException;
|
||||
use LibreNMS\Util\FileLock;
|
||||
use LibreNMS\Util\MemcacheLock;
|
||||
|
||||
global $database_link;
|
||||
|
||||
if (!isset($init_modules) && php_sapi_name() == 'cli') {
|
||||
// Not called from within discovery, let's load up the necessary stuff.
|
||||
$init_modules = array('nodb');
|
||||
$init_modules = [];
|
||||
require realpath(__DIR__ . '/../..') . '/includes/init.php';
|
||||
try {
|
||||
dbConnect();
|
||||
} catch (DatabaseConnectException $e) {
|
||||
echo $e->getMessage() . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
$return = 0;
|
||||
@@ -60,9 +52,7 @@ try {
|
||||
echo 'Step #' . $step++ . ' ...' . PHP_EOL;
|
||||
|
||||
if (!empty($line)) {
|
||||
$creation = dbQuery($line);
|
||||
if (!$creation) {
|
||||
echo 'WARNING: Cannot execute query (' . $line . '): ' . mysqli_error($database_link) . "\n";
|
||||
if (!dbQuery($line)) {
|
||||
$return = 1;
|
||||
}
|
||||
}
|
||||
@@ -99,10 +89,9 @@ try {
|
||||
d_echo("$line \n");
|
||||
|
||||
if ($line[0] != '#') {
|
||||
if (!mysqli_query($database_link, $line)) {
|
||||
if (!dbQuery($line)) {
|
||||
$return = 2;
|
||||
$err++;
|
||||
d_echo(mysqli_error($database_link) . PHP_EOL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user