Skip to content

Commit

Permalink
Fixed thumbnail bugs in forum posts.
Browse files Browse the repository at this point in the history
  • Loading branch information
MariusTBjercke committed Sep 22, 2019
1 parent 5feceaf commit 25bf60c
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion armory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
$title = 'Armory: ';
include 'includes/config.php';
include 'includes/functions.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/players_lib.php';
include 'includes/classes/armory_lib.php';
include 'includes/classes/forum_lib.php';
include 'includes/classes/events_lib.php';
include 'includes/classes/accounts_lib.php';
include 'header.php';
include 'footer.php';
?>
2 changes: 1 addition & 1 deletion forum.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
$title = 'Forum: ';
include 'includes/config.php';
include 'includes/functions.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/forum_lib.php';
include 'includes/classes/events_lib.php';
include 'includes/classes/accounts_lib.php';
include 'header.php';
include 'footer.php';
?>
Expand Down
1 change: 1 addition & 0 deletions gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$title = 'Gallery: ';
include 'includes/config.php';
include 'includes/functions.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/site_lib.php';
include 'includes/classes/forum_lib.php';
include 'includes/classes/events_lib.php';
Expand Down
1 change: 1 addition & 0 deletions howto.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$title = 'How to connect: ';
include 'includes/config.php';
include 'includes/functions.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/forum_lib.php';
include 'includes/classes/events_lib.php';
include 'header.php';
Expand Down
29 changes: 26 additions & 3 deletions includes/classes/forum_lib.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
require_once('accounts_lib.php');

class Forum {
class Forum extends Account {

public $forumActive;

Expand Down Expand Up @@ -177,6 +178,26 @@ public function listTopics($postID) {
}
}

public function fileExists($userID) {
global $mysqli_auth;
global $mysqli_cms;

$query = "SELECT * FROM account WHERE id='$userID'";
$result = $mysqli_auth->query($query);
$fetch = $result->fetch_assoc();
$poster = new Account($userID);
$poster->retrieveAccount();

$realPath = $_SERVER['DOCUMENT_ROOT'] . '/img/avatars/' . $poster->getAvatarID() . '.png';
$imgURL = '/img/avatars/' . $poster->getAvatarID() . '.png';

if (!file_exists($realPath)) {
return '/img/avatars/no-avatar.png';
} else {
return $imgURL;
}
}

public function displayTopic($topicID)
{
global $mysqli_auth;
Expand All @@ -186,6 +207,7 @@ public function displayTopic($topicID)
$result = $mysqli_cms->query($query);
$fetch = $result->fetch_assoc();
$poster = new Account($fetch['user_id']);
$posterID = $fetch['user_id'];
$poster->retrieveAccount();
$poster_name = $poster->getName();
?>
Expand All @@ -205,7 +227,7 @@ public function displayTopic($topicID)
<tbody>
<tr>
<td class="forum-post-avatar">
<img src="img/avatars/<?= $poster->getAvatarID(); ?>.png" width="180">
<img src="<?php echo $this->fileExists($posterID); ?>" width="180">
<div class="role">Rank: <?= $poster->getRole(); ?></div>
<div class="role">Highest level: <?= $poster->getHighestLevel(); ?></div>
</td>
Expand Down Expand Up @@ -238,6 +260,7 @@ public function displayReplies($topicID) {
foreach ($array as $reply) {
$poster = new Account($reply['user_id']);
$poster->retrieveAccount();
$posterID = $reply['user_id'];
$poster_name = $poster->getName();
$thumbs = $this->displayThumbs($reply['id']);
?>
Expand Down Expand Up @@ -266,7 +289,7 @@ public function displayReplies($topicID) {
<tbody>
<tr>
<td class="forum-post-avatar">
<img src="img/avatars/<?= $poster->getAvatarID(); ?>.png" width="180">
<img src="<?php echo $this->fileExists($posterID); ?>" width="180">
<div class="role">Rank: <?= $poster->getRole(); ?></div>
<div class="role">Highest level: <?= $poster->getHighestLevel(); ?></div>
</td>
Expand Down
4 changes: 2 additions & 2 deletions includes/classes/site_lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ public function getCurrentURL() {
$link .= "://";

$link .= $_SERVER['HTTP_HOST'];
$validURL = str_replace("&", "&amp", $url);
return $validURL;
$link .= $_SERVER['REQUEST_URI'];
return $link;
}

}
1 change: 1 addition & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

include 'includes/functions.php';
include 'includes/classes/site_lib.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/forum_lib.php';
include 'includes/classes/events_lib.php';
include 'includes/classes/polls_lib.php';
Expand Down
1 change: 1 addition & 0 deletions onlineplayers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$title = 'Online players: ';
include 'includes/config.php';
include 'includes/functions.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/players_lib.php';
include 'includes/classes/events_lib.php';
include 'includes/classes/forum_lib.php';
Expand Down
4 changes: 2 additions & 2 deletions pages/legion/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@
<?php
if (empty($account->getAvatarID())) {
?>
<img src="<?php echo $site->getCurrentURL(); ?>/img/avatars/no-avatar.png" title="Avatar" alt="Avatar">
<img src="../../img/avatars/no-avatar.png" title="Avatar" alt="Avatar">
<?php
} else {
echo '<img src="' . $site->getCurrentURL() . '/img/thumbnails/'.$account->getAvatarID().'.png" title="Avatar" alt="Avatar">';
echo '<img src="../../img/thumbnails/'.$account->getAvatarID().'.png" title="Avatar" alt="Avatar">';
}
?>
</div>
Expand Down
1 change: 1 addition & 0 deletions register.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
$title = 'Register: ';
include 'includes/config.php';
include 'includes/functions.php';
include 'includes/classes/accounts_lib.php';
include 'includes/classes/forum_lib.php';
include 'includes/classes/events_lib.php';
include 'header.php';
Expand Down

0 comments on commit 25bf60c

Please sign in to comment.