mirror of
https://gitlab.com/ruany/litebans-php.git
synced 2025-05-23 08:29:06 +00:00
Use PDO instead of MySQLi
This commit is contained in:
parent
1041830c20
commit
c18750007d
4
bans.php
4
bans.php
@ -36,7 +36,7 @@
|
||||
<?php
|
||||
global $table_bans, $conn;
|
||||
$result = run_query($table_bans);
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
date_default_timezone_set("UTC");
|
||||
$timeResult = date('F j, Y, g:i a', $row['time'] / 1000);
|
||||
$expiresResult = date('F j, Y, g:i a', $row['until'] / 1000);
|
||||
@ -58,8 +58,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
$result->free();
|
||||
$conn->close();
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -13,8 +13,10 @@ function get_query($table) {
|
||||
|
||||
function run_query($table) {
|
||||
global $conn;
|
||||
if (!$result = $conn->query(get_query($table))) {
|
||||
die('Query error: "' . $conn->error . '"');
|
||||
try {
|
||||
$result = $conn->query(get_query($table));
|
||||
} catch (PDOException $ex) {
|
||||
die($ex->getMessage());
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
@ -32,10 +32,12 @@ function litebans_connect() {
|
||||
global $conn, $active_query;
|
||||
global $table_bans, $table_mutes, $table_warnings, $table_history;
|
||||
|
||||
$conn = new mysqli($dbhost, $username, $password, $database);
|
||||
$dsn = 'mysql:dbname=' . $database . ';host=' . $dbhost . ';charset=utf8';
|
||||
|
||||
if ($conn->connect_errno > 0) {
|
||||
die('Unable to connect to database: ' . $conn->connect_error);
|
||||
try {
|
||||
$conn = new PDO($dsn, $username, $password);
|
||||
} catch (PDOException $e) {
|
||||
echo 'Connection failed: ' . $e->getMessage();
|
||||
}
|
||||
|
||||
$table_bans = $table_prefix . "bans";
|
||||
|
@ -26,7 +26,7 @@
|
||||
<?php
|
||||
global $table_mutes, $conn;
|
||||
$result = run_query($table_mutes);
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
date_default_timezone_set("UTC");
|
||||
$timeResult = date('F j, Y, g:i a', $row['time'] / 1000);
|
||||
$expiresResult = date('F j, Y, g:i a', $row['until'] / 1000);
|
||||
@ -48,8 +48,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
$result->free();
|
||||
$conn->close();
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
@ -33,7 +33,7 @@
|
||||
<?php
|
||||
global $table_warnings, $conn;
|
||||
$result = run_query($table_warnings);
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
date_default_timezone_set("UTC");
|
||||
$expiresResult = date('F j, Y, g:i a', $row['until'] / 1000);
|
||||
?>
|
||||
@ -53,8 +53,6 @@
|
||||
</td>
|
||||
</tr>
|
||||
<?php }
|
||||
$result->free();
|
||||
$conn->close();
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
Loading…
x
Reference in New Issue
Block a user