johnsamir
Advanced OT User
Hi
I'm improving my website which is based in ZnoteAAC code. don't know if it's just me but i noticed that self hosted forums was displaying lots of errors
like:
tested with clean ZnoteAAC and faced the same issues
so i've fixed them. don't know how directly post if since i don't have my website linked to my github or anything similar
here is the fixed/ edited code.
enjoy
I'm improving my website which is based in ZnoteAAC code. don't know if it's just me but i noticed that self hosted forums was displaying lots of errors
like:
Code:
Deprecated: Automatic conversion of false to array is deprecated in C:\xampp\htdocs\forum.php on line 928
Deprecated: Automatic conversion of false to array is deprecated in C:\xampp\htdocs\forum.php on line 67
Warning: Undefined array key "admin_thread_delete" in C:\xampp\htdocs\forum.php on line 95
Warning: Undefined array key "admin_thread_close" in C:\xampp\htdocs\forum.php on line 96
Warning: Undefined array key "admin_thread_open" in C:\xampp\htdocs\forum.php on line 97
Warning: Undefined array key "admin_thread_sticky" in C:\xampp\htdocs\forum.php on line 98
Warning: Undefined array key "admin_thread_unstick" in C:\xampp\htdocs\forum.php on line 99
Warning: Undefined array key "admin_thread_id" in C:\xampp\htdocs\forum.php on line 100
Warning: Undefined array key "admin_post_id" in C:\xampp\htdocs\forum.php on line 186
Warning: Undefined array key "admin_post_delete" in C:\xampp\htdocs\forum.php on line 187
Warning: Undefined array key "admin_category_delete" in C:\xampp\htdocs\forum.php on line 189
Warning: Undefined array key "admin_update_category" in C:\xampp\htdocs\forum.php on line 193
Warning: Undefined array key "admin_category_name" in C:\xampp\htdocs\forum.php on line 194
Warning: Undefined array key "admin_category_access" in C:\xampp\htdocs\forum.php on line 196
Warning: Undefined array key "admin_category_closed" in C:\xampp\htdocs\forum.php on line 197
Warning: Undefined array key "admin_category_hidden" in C:\xampp\htdocs\forum.php on line 198
Warning: Undefined array key "admin_category_guild_id" in C:\xampp\htdocs\forum.php on line 199
Warning: Undefined array key "admin_board_create_name" in C:\xampp\htdocs\forum.php on line 206
Warning: Undefined array key "admin_board_create_access" in C:\xampp\htdocs\forum.php on line 207
Warning: Undefined array key "admin_board_create_closed" in C:\xampp\htdocs\forum.php on line 208
Warning: Undefined array key "admin_board_create_hidden" in C:\xampp\htdocs\forum.php on line 209
Warning: Undefined array key "admin_board_create_guild_id" in C:\xampp\htdocs\forum.php on line 210
so i've fixed them. don't know how directly post if since i don't have my website linked to my github or anything similar
here is the fixed/ edited code.
Code:
//////////////////////
// No category specified, show list of available categories
if (!$admin) {
$categories = mysql_select_multi(
"SELECT `id`, `name`, `access`, `closed`, `hidden`, `guild_id` FROM `znote_forum` WHERE `access`<='$yourAccess' ORDER BY `name`;"
);
} else {
$categories = mysql_select_multi(
"SELECT `id`, `name`, `access`, `closed`, `hidden`, `guild_id` FROM `znote_forum` ORDER BY `name`;"
);
}
$guildboard = false;
?>
<table class="znoteTable table table-striped table-hover" id="forumCategoryTable">
<tr class="yellow">
<th>Forum Boards</th>
<?php
$guild = false;
foreach ($charData as $char) {
if ($char['guild'] > 0) {
$guild = true;
}
}
if ($admin || $guild) {
if (!isset($guilds)) {
$guilds = mysql_select_multi("SELECT `id`, `name` FROM `guilds` ORDER BY `name`;");
if ($guilds === false) {
$guilds = array(); // Ensure $guilds is an array even if the query fails
}
$guilds[] = array('id' => '0', 'name' => 'No guild');
}
$guildName = array();
foreach ($guilds as $guild) {
$guildName[$guild['id']] = $guild['name'];
}
if ($admin) {
?>
<th>Edit</th>
<th>Delete</th>
<?php
}
}
?>
</tr>
<?php
if ($categories !== false) {
foreach ($categories as $category) {
$access = true;
if ($category['guild_id'] > 0) {
$guildboard[] = $category;
$access = false;
}
if ($access) {
$url = url("forum.php?cat=" . $category['id']);
echo '<tr class="special">';
echo '<td onclick="javascript:window.location.href=\'' . $url . '\'">';
if ($category['closed'] == 1) echo $config['forum']['closed'], ' ';
if ($category['hidden'] == 1) echo $config['forum']['hidden'], ' ';
if ($category['guild_id'] > 0) {
echo "[" . $guildName[$category['guild_id']] . "] ";
}
echo $category['name'] . "</td>";
// Admin columns
if ($admin) {
?>
<td style="margin: 0px; padding: 0px; width: 100px;">
<form action="" method="post">
<input type="hidden" name="admin_category_id" value="<?php echo $category['id']; ?>">
<input type="submit" name="admin_category_edit" value="Edit" style="margin: 0px; padding: 0px; width: 50px; height: 22px;" class="btn btn-warning">
</form>
</td>
<td style="margin: 0px; padding: 0px; width: 100px;">
<form action="" method="post">
<input type="hidden" name="admin_category_id" value="<?php echo $category['id']; ?>">
<input type="submit" name="admin_category_delete" value="Delete" style="margin: 0px; padding: 0px; width: 75px; height: 22px;" class="btn btn-danger">
</form>
</td>
<?php
}
echo '</tr>';
}
}
}
?>
</table>
<hr class="bighr">
<?php
if ($guildboard !== false && $guild || $guildboard !== false && $admin) {
?>
<table class="table table-striped table-hover znoteTable" id="forumCategoryTable">
<tr class="yellow">
<th>Guild Boards</th>
<?php
foreach ($charData as $char) {
if ($char['guild'] > 0) {
$guild = true;
}
}
if ($admin || $guild) {
if (!isset($guilds)) {
$guilds = mysql_select_multi("SELECT `id`, `name` FROM `guilds` ORDER BY `name`;");
$guilds[] = array('id' => '0', 'name' => 'No guild');
}
$guildName = array();
foreach ($guilds as $guild) {
$guildName[$guild['id']] = $guild['name'];
}
if ($admin) {
?>
<th width="100">Edit</th>
<th width="100">Delete</th>
<?php
}
}
?>
</tr>
<?php
$count = 0;
foreach ($guildboard as $board) {
$access = false;
foreach ($charData as $char) {
if ($board['guild_id'] == $char['guild']) {
$access = true;
$count++;
}
}
if ($access || $admin) {
$url = url("forum.php?cat=" . $board['id']);
echo '<tr class="special">';
echo '<td onclick="javascript:window.location.href=\'' . $url . '\'">';
if ($board['closed'] == 1) echo $config['forum']['closed'], ' ';
if ($board['hidden'] == 1) echo $config['forum']['hidden'], ' ';
if ($board['guild_id'] > 0) {
echo "[" . $guildName[$board['guild_id']] . "] ";
}
echo $board['name'] . "</td>";
// Admin columns
if ($admin) {
?>
<td style="margin: 0px; padding: 0px; width: 100px;">
<form action="" method="post">
<input type="hidden" name="admin_category_id" value="<?php echo $board['id']; ?>">
<input type="submit" name="admin_category_edit" value="Edit" style="margin: 0px; padding: 0px; width: 50px; height: 22px;" class="btn btn-warning">
</form>
</td>
<td style="margin: 0px; padding: 0px; width: 100px;">
<form action="" method="post">
<input type="hidden" name="admin_category_id" value="<?php echo $board['id']; ?>">
<input type="submit" name="admin_category_delete" value="Delete" style="margin: 0px; padding: 0px; width: 75px; height: 22px;" class="btn btn-danger">
</form>
</td>
<?php
}
echo '</tr>';
}
}
if ($count == 0 && !$admin) {
echo '<tr><td>You don\'t have access to any guildboards.</td></tr>';
}
?>
</table>
<?php
}
if ($admin) {
?>
<h2>Create board:</h2>
<form action="" method="post">
<input type="text" name="admin_board_create_name" placeholder="Board name"><br><br>
Required access: <select name="admin_board_create_access">
<?php
foreach ($config['ingame_positions'] as $access => $name) {
echo "<option value='$access'>$name</option>";
}
?>
</select><br><br>
Board closed: <select name="admin_board_create_closed">
<option value="0">No</option>
<option value="1">Yes</option>
</select><br>
Board hidden: <select name="admin_board_create_hidden">
<option value="0">No</option>
<option value="1">Yes</option>
</select><br><br>
Guild board: <select name="admin_board_create_guild_id">
<?php
foreach ($guilds as $guild) {
if ($guild['id'] == 0) {
echo "<option value='" . $guild['id'] . "' selected>" . $guild['name'] . "</option>";
} else {
echo "<option value='" . $guild['id'] . "'>" . $guild['name'] . "</option>";
}
}
?>
</select><br><br>
<input type="submit" value="Create Board" class="btn btn-primary">
</form>
<?php
}
} // This closing brace is added for the opening brace at the beginning
include 'layout/overall/footer.php';
?>