Not Solved [How To?] Broken Avatar in custom page
#1
Not Solved
Hello I have a problem with a custom page. I created a custom directory "X" in my forum root and inside the directory I created a custom page "Y.php" that includes global.php:

require_once "../global.php";

How is that users avatar appear broken when I browse the page?
In particular, the URL being outputted is the following:

src="./uploads/avatars/avatar_1.gif?dateline=1534416144"

Am I missing something or did something wrong?
Reply
#2
Not Solved
what is the code used for getting user avatar ?

if custom php file is in a sub-folder then avatar link should be like
src="../uploads/avatars/avatar_1.gif?dateline=1534416144"
Reply
#3
Not Solved
(2020-04-11, 02:59 AM).m. Wrote: what is the code used for getting user avatar ?

if custom php file is in a sub-folder then avatar link should be like
src="../uploads/avatars/avatar_1.gif?dateline=1534416144"

I'm using this piece of code inside the custom page:

<?php 
add_breadcrumb("Custom Page", "custom.php");
eval("\$html = \"".$templates->get("_custom.php")."\";");
output_page($html);
?>

The global template mentioned contains just this:

<head>
 <title>Site</title>
 {$headerinclude}
 {$extraheaderinclude}
</head>
<body>
 {$header}



Guess I should alter the avatar variable like this:

$mybb->user['avatar'] = '.'.$mybb->user['avatar'];

But I cannot understand where this should be placed
Reply
#4
Not Solved
You can put that before the eval line
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM or Discord
Reply
#5
Not Solved
(2020-04-14, 06:23 AM)Crazycat Wrote: You can put that before the eval line

Just did so, but it didn't work Sad
Reply
#6
Not Solved
Peharps with the full content of your php file I can help you. But working with 4 lines is impossible.
[MyBB 1.8 mods] - Offer me a coffee
Do not ask me help through PM or Discord
Reply
#7
Not Solved
(2020-04-14, 10:58 AM)Crazycat Wrote: Peharps with the full content of your php file I can help you. But working with 4 lines is impossible.

I believe the problem originates from the theme I'm using, but looks so strange as I'm trying to change a MyBB variable by hardcoding it into the page.

About full content, the only other thing I have in that page is the one below. I use it to understand if user has permission to read it depending on usergroups:

<?php 
define("IN_MYBB", 1);
require_once "../global.php";
$groups = $mybb->user['usergroup'];
if($mybb->user['additionalgroups'])
{
$groups.= "," . $mybb->user['additionalgroups'];
}
$explodedgroups = explode(",", $groups);
$canview  = 0;
$allowedgroups = array(4);
foreach($explodedgroups as $group)
{
if(in_array($group, $allowedgroups))
{
$canview = 1;
break;
echo'{$headerinclude}{$header}';
}
}
if(!$canview)
{
echo'<meta http-equiv="refresh" content="0;url=https://boardurl.com" />';
error_no_permission();
}
?>
Reply
#8
Not Solved
Please past your theme details, as it seems to me your theme is outputting an avatar the MyBB core doesn't by default.

Also attach an image where the avatar is displayed correct please.
Reply
#9
Not Solved
(2020-04-14, 07:10 PM)Omar G. Wrote: Please past your theme details, as it seems to me your theme is outputting an avatar the MyBB core doesn't by default.

Also attach an image where the avatar is displayed correct please.

This is the theme I'm using: https://community.mybb.com/thread-224006.html
What kind of details should I post?

EDIT: Just realized that it only happens with MY avatar.. in fact as Admin I've placed a default avatar to all users and removed the ability to upload other ones. The avatar I set as default to all users doesn't get broken (it has its own full image url ending in .png which loads correctly) while my own avatar is a .gif I uploaded via usercp.
Reply
#10
Not Solved
But is your avatar broken only in the new created page or it is broken in any page?

Users have reported issues with GIF images before.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)