From 27a7fbe45ddba7ad2fa05e23cba12fa4754ae0b8 Mon Sep 17 00:00:00 2001 From: Bartek Fabiszewski Date: Sun, 16 Apr 2017 21:31:41 +0200 Subject: [PATCH] Remove unused references to mysqli object --- auth.php | 4 ---- client/index.php | 4 +--- index.php | 3 +-- utils/changepass.php | 3 +-- utils/download.php | 5 +---- utils/getpositions.php | 3 +-- utils/gettracks.php | 3 +-- utils/handletrack.php | 9 +++------ utils/handleuser.php | 16 +++++----------- 9 files changed, 14 insertions(+), 36 deletions(-) diff --git a/auth.php b/auth.php index af8a503..ef7a39a 100755 --- a/auth.php +++ b/auth.php @@ -22,8 +22,6 @@ require_once(ROOT_DIR . "/helpers/config.php"); $config = new uConfig(); require_once(ROOT_DIR . "/lang.php"); -require_once(ROOT_DIR . "/helpers/db.php"); -$mysqli = uDb::getInstance(); require_once(ROOT_DIR . "/helpers/user.php"); session_name('ulogger'); @@ -92,7 +90,6 @@ if (!$user->isValid && ($config::$require_authentication || defined('headless')) '; } - $mysqli->close(); exit(); } else { // username submited @@ -126,7 +123,6 @@ if (!$user->isValid && ($config::$require_authentication || defined('headless')) header("Location: $ssl://$url$error"); } } - $mysqli->close(); exit(); } /* end of authentication */ diff --git a/client/index.php b/client/index.php index ea2a73c..342a7ce 100644 --- a/client/index.php +++ b/client/index.php @@ -29,7 +29,7 @@ function setError(&$response, $message) { } define("headless", true); -require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user +require_once(dirname(__DIR__) . "/auth.php"); // sets $user $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : null; $response = [ 'error' => false ]; @@ -105,8 +105,6 @@ switch ($action) { break; } -$mysqli->close(); - header('Content-Type: application/json'); echo json_encode($response); exit(); diff --git a/index.php b/index.php index b259bab..d4e9115 100755 --- a/index.php +++ b/index.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ - require_once(__DIR__ . "/auth.php"); // sets $mysqli, $user + require_once(__DIR__ . "/auth.php"); // sets $user require_once(ROOT_DIR . "/helpers/position.php"); require_once(ROOT_DIR . "/helpers/track.php"); @@ -49,7 +49,6 @@ $displayTrackId = NULL; } - $mysqli->close(); ?> diff --git a/utils/changepass.php b/utils/changepass.php index 475ab0f..abaf343 100644 --- a/utils/changepass.php +++ b/utils/changepass.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ - require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user + require_once(dirname(__DIR__) . "/auth.php"); // sets $user /** * Exit with error message @@ -47,7 +47,6 @@ $xml->endElement(); $xml->endDocument(); $xml->flush(); - $mysqli->close(); exit; } diff --git a/utils/download.php b/utils/download.php index a82112b..43be4ad 100755 --- a/utils/download.php +++ b/utils/download.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ -require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user, $config +require_once(dirname(__DIR__) . "/auth.php"); // sets $user, $config require_once(ROOT_DIR . "/helpers/position.php"); /** @@ -59,7 +59,6 @@ $trackId = (isset($_REQUEST["trackid"]) && is_numeric($_REQUEST["trackid"])) ? ( if (!$config::$public_tracks && !$user->isAdmin && $user->id !== $userId) { // unauthorized - $mysqli->close(); exit(); } @@ -84,7 +83,6 @@ if ($trackId && $userId) { $positionsArr = []; $positionsArr = $position->getAll($userId, $trackId); if (empty($positionsArr)) { - $mysqli->close(); exit(); } @@ -227,5 +225,4 @@ if ($trackId && $userId) { } } -$mysqli->close(); ?> diff --git a/utils/getpositions.php b/utils/getpositions.php index 86b6f99..47875e9 100755 --- a/utils/getpositions.php +++ b/utils/getpositions.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ -require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user, $config +require_once(dirname(__DIR__) . "/auth.php"); // sets $user, $config require_once(ROOT_DIR . "/helpers/position.php"); $userId = (isset($_REQUEST["userid"]) && is_numeric($_REQUEST["userid"])) ? (int) $_REQUEST["userid"] : NULL; @@ -74,5 +74,4 @@ if ($userId) { $xml->flush(); } -$mysqli->close(); ?> diff --git a/utils/gettracks.php b/utils/gettracks.php index d803908..fb1c902 100755 --- a/utils/gettracks.php +++ b/utils/gettracks.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ -require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user, $config +require_once(dirname(__DIR__) . "/auth.php"); // sets $user, $config require_once(ROOT_DIR . "/helpers/track.php"); $userId = (isset($_REQUEST["userid"]) && is_numeric($_REQUEST["userid"])) ? (int) $_REQUEST["userid"] : NULL; @@ -51,5 +51,4 @@ if ($userId) { $xml->flush(); } -$mysqli->close(); ?> diff --git a/utils/handletrack.php b/utils/handletrack.php index 1795495..ad7bdd1 100644 --- a/utils/handletrack.php +++ b/utils/handletrack.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ - require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user + require_once(dirname(__DIR__) . "/auth.php"); // sets $user require_once(ROOT_DIR . "/helpers/track.php"); /** @@ -56,17 +56,14 @@ switch ($action) { case 'update': - if (empty($trackName)) { + if (empty($trackName) || $track->update($trackName) === false) { exitWithStatus(true, $lang["servererror"]); } - if ($track->update($trackName) === false) { - exitWithStatus(true, $mysqli->error); - } break; case 'delete': if ($track->delete() === false) { - exitWithStatus(true, $mysqli->error); + exitWithStatus(true, $lang["servererror"]); } break; diff --git a/utils/handleuser.php b/utils/handleuser.php index 6848a28..f2796c3 100644 --- a/utils/handleuser.php +++ b/utils/handleuser.php @@ -17,7 +17,7 @@ * along with this program; if not, see . */ - require_once(dirname(__DIR__) . "/auth.php"); // sets $mysqli, $user + require_once(dirname(__DIR__) . "/auth.php"); // sets $user /** * Exit with xml response @@ -52,30 +52,24 @@ switch ($action) { case 'add': - if (empty($pass)) { - exitWithStatus(true, $lang["servererror"]); - } if ($aUser->isValid) { exitWithStatus(true, $lang["userexists"]); } - if ($aUser->add($login, $pass) === false) { - exitWithStatus(true, $mysqli->error); + if (empty($pass) || $aUser->add($login, $pass) === false) { + exitWithStatus(true, $lang["servererror"]); } break; case 'update': // update password - if (empty($pass)) { + if (empty($pass) || $aUser->setPass($pass) === false) { exitWithStatus(true, $lang["servererror"]); } - if ($aUser->setPass($pass) === false) { - exitWithStatus(true, $mysqli->error); - } break; case 'delete': if ($aUser->delete() === false) { - exitWithStatus(true, $mysqli->error); + exitWithStatus(true, $lang["servererror"]); } break;