Use mysqli instead of deprecated mysql module

This commit is contained in:
Ruan 2015-02-21 07:55:15 +02:00
parent 152d1de79a
commit 7780ec2ff6
5 changed files with 18 additions and 19 deletions

View File

@ -9,10 +9,10 @@ require 'includes/data/database.php';
$sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_bans . ' INNER JOIN ' . $table_history . ' on ' . $table_bans . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20'; $sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_bans . ' INNER JOIN ' . $table_history . ' on ' . $table_bans . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20';
$retval = mysql_query($sql, $conn); if(!$result = $conn->query($sql)) {
if (!$retval) { die('Query error [' . $conn->error . ']');
die('Could not get data: ' . mysql_error($conn));
} }
?> ?>
<body> <body>
<div class="container"> <div class="container">
@ -51,7 +51,7 @@ if (!$retval) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php while ($row = mysql_fetch_assoc($retval)) { <?php while($row = $result->fetch_assoc()){
// <<-----------------Ban Date Converter------------>> // // <<-----------------Ban Date Converter------------>> //
$timeEpoch = $row['time']; $timeEpoch = $row['time'];
$timeConvert = $timeEpoch / 1000; $timeConvert = $timeEpoch / 1000;
@ -75,7 +75,7 @@ if (!$retval) {
} ?></td> } ?></td>
</tr> </tr>
<?php } <?php }
mysql_close($conn); $result->free();
echo "</tbody></table>"; echo "</tbody></table>";
?> ?>
</div> </div>

View File

@ -2,7 +2,7 @@
$dbhost = 'localhost'; $dbhost = 'localhost';
$dbuser = 'root'; $dbuser = 'root';
$dbpass = 'password'; $dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass); $conn = new mysqli($dbhost, $dbuser, $dbpass, 'litebans');
$table_prefix = ""; $table_prefix = "";
$table_bans = $table_prefix . "bans"; $table_bans = $table_prefix . "bans";
@ -10,9 +10,8 @@ $table_mutes = $table_prefix . "mutes";
$table_warnings = $table_prefix . "warnings"; $table_warnings = $table_prefix . "warnings";
$table_history = $table_prefix . "history"; $table_history = $table_prefix . "history";
if (!$conn) { if($conn->connect_errno > 0){
die('Could not connect: ' . mysql_error()); die('Unable to connect to database [' . $conn->connect_error . ']');
} }
mysql_select_db('litebans');
?> ?>

View File

@ -4,5 +4,6 @@
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$" /> <content url="file://$MODULE_DIR$" />
<orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="jquery-1.10.2" level="application" />
</component> </component>
</module> </module>

View File

@ -9,9 +9,8 @@ require 'includes/data/database.php';
$sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_mutes . ' INNER JOIN ' . $table_history . ' on ' . $table_mutes . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20'; $sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_mutes . ' INNER JOIN ' . $table_history . ' on ' . $table_mutes . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20';
$retval = mysql_query($sql, $conn); if(!$result = $conn->query($sql)) {
if (!$retval) { die('Query error [' . $conn->error . ']');
die('Could not get data: ' . mysql_error());
} }
?> ?>
<body> <body>
@ -41,7 +40,7 @@ if (!$retval) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php while ($row = mysql_fetch_assoc($retval)) { <?php while($row = $result->fetch_assoc()){
// <<-----------------Ban Date Converter------------>> // // <<-----------------Ban Date Converter------------>> //
$timeEpoch = $row['time']; $timeEpoch = $row['time'];
$timeConvert = $timeEpoch / 1000; $timeConvert = $timeEpoch / 1000;
@ -63,7 +62,7 @@ if (!$retval) {
} ?></td> } ?></td>
</tr> </tr>
<?php } <?php }
mysql_close($conn); $result->close();
echo "</tbody></table>"; echo "</tbody></table>";
?> ?>
</div> </div>

View File

@ -9,10 +9,10 @@ require 'includes/data/database.php';
$sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_warnings . ' INNER JOIN ' . $table_history . ' on ' . $table_warnings . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20'; $sql = 'SELECT time,until,reason,name,banned_by_name FROM ' . $table_warnings . ' INNER JOIN ' . $table_history . ' on ' . $table_warnings . '.uuid=' . $table_history . '.uuid WHERE active=1 GROUP BY name ORDER BY time DESC LIMIT 20';
$retval = mysql_query($sql, $conn); if(!$result = $conn->query($sql)) {
if (!$retval) { die('Query error [' . $conn->error . ']');
die('Could not get data: ' . mysql_error($conn));
} }
?> ?>
<body> <body>
<div class="container"> <div class="container">
@ -48,7 +48,7 @@ if (!$retval) {
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php while ($row = mysql_fetch_assoc($retval)) { <?php while($row = $result->fetch_assoc()){
// <<-----------------Expiration Time Converter------------>> // // <<-----------------Expiration Time Converter------------>> //
$expiresEpoch = $row['until']; $expiresEpoch = $row['until'];
$expiresConvert = $expiresEpoch / 1000; $expiresConvert = $expiresEpoch / 1000;
@ -65,7 +65,7 @@ if (!$retval) {
} ?></td> } ?></td>
</tr> </tr>
<?php } <?php }
mysql_close($conn); $result->close();
echo "</tbody></table>"; echo "</tbody></table>";
?> ?>
</div> </div>