Remove unused references to mysqli object

This commit is contained in:
Bartek Fabiszewski 2017-04-16 21:31:41 +02:00
parent 8dd1dba649
commit 27a7fbe45d
9 changed files with 14 additions and 36 deletions

View File

@ -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'))
</body>
</html>';
}
$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 */

View File

@ -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();

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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();
?>
<!DOCTYPE html>
<html>

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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;
}

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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();
?>

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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();
?>

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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();
?>

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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;

View File

@ -17,7 +17,7 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
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;