Migrate to PostgreSQL & small changes
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
<li><a href="/rules">Rules</a></li>
|
||||
<li><a href="https://store.limework.net" style="color:lightgreen;">🛒 Store</a></li>
|
||||
<li><div class="dropdown">
|
||||
<button class="dropbtn">𝄘</button>
|
||||
<button class="dropbtn">More</button>
|
||||
<div class="dropdown-content">
|
||||
<a href="https://git.limework.net" style="color:lightgreen;">🏗 Gitea</a>
|
||||
<a href="https://video.govindas.net" style="color:lightgreen;">📺 PeerTube</a>
|
||||
@@ -32,7 +32,6 @@
|
||||
</ul>
|
||||
<div class='content'>
|
||||
<?php
|
||||
|
||||
$banid=htmlspecialchars($_POST['banid']);
|
||||
$banreason=htmlspecialchars($_POST['banreason']);
|
||||
$whyunban=htmlspecialchars($_POST['whyunban']);
|
||||
@@ -56,27 +55,36 @@ if (strlen($banid) > 16) {
|
||||
$error=true;
|
||||
|
||||
} if (!$error) {
|
||||
ini_set('display_errors',1);
|
||||
error_reporting(E_ALL | E_STRICT);
|
||||
//ini_set('display_errors',1);
|
||||
//error_reporting(E_ALL | E_STRICT);
|
||||
// webbanappeal has read-only access to bans table, nothing else. It can only be accessed in localhost. Publishing password to git is fine.
|
||||
$con = mysqli_connect("localhost","webbanappeal","UpUOZhRf5WLAy920wbDqyAKLySHl677juGgL","friends");
|
||||
if (!$con) {
|
||||
echo "<p style='color:red;'>Failed to connect to database: " . mysqli_connect_error();
|
||||
echo "</p>";
|
||||
$error=true;
|
||||
}
|
||||
$con = pg_connect("host=localhost port=5432 dbname=limework user=webbanappeal password=UpUOZhRf5WLAy920wbDqyAKLySHl677juGgL");
|
||||
|
||||
$sanitized_banid = mysqli_real_escape_string($con, $banid);
|
||||
if ($result = mysqli_query($con, "SELECT `banid` FROM `bans` WHERE `banid` = '$sanitized_banid'")) {
|
||||
if (mysqli_num_rows($result) == 0) {
|
||||
echo "<p style='color:red;'>Error: There is no ban with the specified ban ID. Did you enter it correctly?</p><br>";
|
||||
$error=true;
|
||||
} else {
|
||||
// Free result set
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
if (!$con) {
|
||||
echo "<p style='color:red;'>Failed to connect to database.";
|
||||
echo "</p>";
|
||||
$error=true;
|
||||
}
|
||||
mysqli_close($con);
|
||||
$query = "SELECT banid FROM bans WHERE banid = $1";
|
||||
$stmt = pg_prepare($con, "bancheck", $query);
|
||||
$result = pg_execute($con, "bancheck", array($banid));
|
||||
|
||||
$banidfound=false;
|
||||
if (!$result) {
|
||||
echo "<p style='color:red;'>An database error occurred, report this to staff.";
|
||||
echo "</p>";
|
||||
$error=true;
|
||||
} else {
|
||||
while ($row = pg_fetch_assoc($result)) {
|
||||
$banidfound=true;
|
||||
}
|
||||
}
|
||||
if (!$banidfound) {
|
||||
echo "<p style='color:red;'>There is no ban with the specified ban ID.";
|
||||
echo "</p>";
|
||||
$error=true;
|
||||
}
|
||||
pg_free_result($result);
|
||||
}
|
||||
//must not be else if, as error variable may be set above
|
||||
if ($error) {
|
||||
|
||||
Reference in New Issue
Block a user