Hi
Our website has a PHP script which was initially designed a long time ago for SMF:
We're now using MyBB - what changes need to be made to reflect MyBB rather than SMF?
Thanks.
Our website has a PHP script which was initially designed a long time ago for SMF:
/**
* Determine the URL of this user's avatar. The algorithm has been ported from Simple Machine
* Forum's Subs.php, so it should work more or less equal to the forum.
*
* @param userId Id of the user to retrieve the avatar url from
* @return string The user's avatar.
*/
public static function determineUserAvatar($userId = false) {
if ($userId == false) {
if (!isset ($_SESSION ['user_info']['user_id']))
return 'https://domain.com/images/no_avatar.jpg';
$userId = $_SESSION ['user_info']['user_id'];
}
$avatar = $_SERVER ['abc_cache'] -> get ('avatar_' . $userId);
if ($avatar !== false && !defined('abc_CLEAR_CACHE'))
return $avatar;
$database = Database::getInstance();
$result = $database -> query('
SELECT
smf_members.id_member,
smf_members.avatar,
smf_attachments.id_attach
FROM
abc_website.users_links
LEFT JOIN
abc_forum.smf_members ON smf_members.id_member = users_links.forum_id
LEFT JOIN
abc_forum.smf_attachments ON smf_attachments.id_member = users_links.forum_id
WHERE
users_links.user_id = ' . (int)($userId));
if ($result === false || $result -> num_rows == 0) {
$_SERVER ['abc_cache'] -> set ('avatar_' . $userId, 'https://domain.com/images/no_avatar.jpg', 3600);
return 'https://domain.com/images/no_avatar.jpg';
}
$avatarInfo = $result -> fetch_assoc();
$avatarImage = '';
if (strlen($avatarInfo['avatar']) > 0)
$avatarImage = $avatarInfo['avatar'];
else if (is_numeric ($avatarInfo ['id_attach']) && $avatarInfo ['id_member'] != 0)
$avatarImage = 'https://forum.domain.com/index.php?action=dlattach;attach=' . $avatarInfo['id_attach'] . ';type=avatar';
else
$avatarImage = 'https://domain.com/images/no_avatar.jpg';
$_SERVER ['abc_cache'] -> set ('avatar_' . $userId, $avatarImage, 3600);
return $avatarImage;
}
We're now using MyBB - what changes need to be made to reflect MyBB rather than SMF?
Thanks.