Strange Problem ... using Avatars with bridged gallery Strange Problem ... using Avatars with bridged gallery
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Strange Problem ... using Avatars with bridged gallery

Started by Summoner Yuna, April 17, 2007, 01:14:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Summoner Yuna

I'm posting here, because I'm kind of lost and pulling my hair out. Anyways, what I'm trying to do is to use the modpack's avatar system with my forum bridged to vBulletin. I want to do this for two reasons 1) vBulletin's avatars are tricky to bridge because everytime a user changes their's it adds a different number to the file-name; and 2) I want to have small avatars on my gallery comments (50x50) as opposed to the 140x140 size my forum has.

Anyways, more to the point, after successfully bridging the modpack, I achieved this successfully as follows:

Added to vbulletin30.inc.php
'avatar_url' => 'userid'

//mod define Avatar path
define('AVATAR_PATH', 'albums/userpics/'.+1000);
define('AVATAR_PIC', ''.+1000);


Changed avatar section in my themes file to:

if ($CONFIG['enable_avatar']){
($row['avatar_url'] != "") ? $avatar_url= AVATAR_PATH.$row["avatar_url"].'/'.'user_'.AVATAR_PIC.$row["avatar_url"].'_avatar.jpg' : $avatar_url = '';
if (file_exists($avatar_url) == TRUE) {
$avatar_pic = $avatar_url;
}
else $avatar_pic = "albums/userpics/noavatar.jpg"; //added to display default avatar if user doesn't have one
}
else $avatar_url="";


I'm not a PHP expert, I kind of "stumble" my way along here and there using pre-existing code to work things out, so I've no idea if it's the best code to work. But I tested it on my local computer which runs PHP 5.1.4 under IIS. Everything worked 100% perfectly. Even for users other than admin which were only in the forum database and not in the CPG users database ... no errors at all when uploading an avatar and displaying it in a comment.

So I upload my files up to my server [development folder, not public as I haven't got everything running the way I want it] and it's not working at all. It basically cannot find the image in the folder [it does exist as I've checked] and instead changes the URL to that of the referring page.

The only thing that I think must be causing a problem is because the server is either running a different version of PHP or is running Apache instead of IIS. [Server: PHP 4.4.3/Apache 1.3/CentOS; Local PC PHP 5.1.4/IIS/Win2000].

In case my method might not have been correct, I tried the one suggested in this thread for another bridging problem, but the same results ... works perfectly on local PC, doesn't on server.

To make this all even more confusing, I use a similar method [using file_exists to check to see if a file exists and to then display the link to it] to check the existance of wallpaper files that I manually upload by using a hack I found in this thread. But this works perfectly on the server and always has.

I'm sure it's a setting on the server, or my versions need upgrading, but what I'm really after is just a confirmation of whether I need to ask my server provider to upgrade my software, or whether there's some configuration setting somewhere that is out of whack that I need to change.

Sorry for the long and detailed post ... I can't seem to explain things simply sometimes.  :-[

Summoner Yuna...

Stramm

as you can't provide a link it's hard to give you an advice. Most likely it's permission problems. Check file and group permissions.

However, I'm not really sure if I understood to 100% what you mean
QuoteSo I upload my files up to my server [development folder, not public as I haven't got everything running the way I want it] and it's not working at all. It basically cannot find the image in the folder [it does exist as I've checked] and instead changes the URL to that of the referring page.

What URL gets changed? Is the right URL in the db, what URL can you see in the html output... if these are OK, then the above said applies. If not, then you need to find out what changed the URL in the html output

Summoner Yuna

Hi Stramm...

Thank you for the reply. I've checked permissions and all seem to be in order.

Regarding the confusion. The URL of the avatar image appears to be the same as the actual page that I am viewing. For example:

Local PC - http://seph/gallery/albums/userpics/10001/user_10001_avatar.jpg
Server - http://www.adventchildren.net/development/testvb/gallery/displayimage.php?album=lastcom&cat=0&pos=0

On my local PC, it is as it should be. But on the server, the URL is as above, which isn't an image URL at all. I've even tried re-uploading files again in case something went astray, but no change.

I could PM you the username/password the development directory on my server if it will be of any assistance.

Regards,
Summoner Yuna...

Stramm

looks to me like you use cpg <= 1.4.8
especially for bridge support there has been made some improvements in 1.4.10. So you should upgrade cpg and the modpack  and you should apply all the two modpack fixes as well.

of course you would need to do your modifications again too (code has changed)

Summoner Yuna

Hi Stramm...

Thanks again for the reply. I was running the latest version of both the gallery and modpack, but I tried a fresh install with the default skin and the patches you recommended and still the same problem existed.

I did however do some digging and found that on the server there appeared to be some difficulty with the tables joining, but on my local PC, that wasn't occurring, which seemed to account for the problem. As I had just worked on the premises that the tables would join as it worked locally, I had removed the if statement determining that, assuming I didn't need it.

I managed to therefore get it working on the server by further modifying using your code for tables that don't join as a base and to accomodate for the three different extensions, but found that it would add an extra query for every comment left, which could ultimately clog up my gallery seeing we are a fairly large site. So on some further messing with the code, I came up with this viable solution.

$avatar_url= preg_replace('/\/\//','/',AVATAR_PATH.$row["author_id"]);

if ( file_exists(AVATAR_PATH.$row['author_id'].'/~avatar.jpg' ) ){
($row['author_id'] != "") ? $avatar_url= $avatar_url."/~avatar.jpg" : $avatar_url = '';
}
else if ( file_exists(AVATAR_PATH.$row['author_id'].'/~avatar.gif' ) ){
($row['author_id'] != "") ? $avatar_url= $avatar_url."/~avatar.gif" : $avatar_url = '';
}
else if ( file_exists(AVATAR_PATH.$row['author_id'].'/~avatar.png' ) ){
($row['author_id'] != "") ? $avatar_url= $avatar_url."/~avatar.png" : $avatar_url = '';
}
else $avatar_url='images/no-avatar.gif';


Basically just using a combination of your code and the code in the thread I found on here for the multiple extensions, but changing avatar_url to author_id accordingly. Not sure if it's the best solution, as I mentioned, I'm no code expert ... but it appears to work for me and testing with all three file extensions as well as multiple comments by different users, both with and without avatars.

Summoner Yuna...

Summoner Yuna

Sorry for double post, as I can't find an edit button. I forgot to mention, that seeing I posted a solution, and it might confuse anyone with a similar problem if they wander onto this thread, as I made a couple of additional changes to help make things easier for myself.

1. Minor change in avatar_manage.php so that the user's avatar is just named ~avatar.jpg [or similar] instead of using the filename in the modpack [I'm sure there's a way to do it, but I guess I opted an easier alternative, as uploaded files must be approved for my gallery, so I can basically rename anything with that name if it were to occur].
2. I don't have the full image path in my code due to my template's alteration, so it should be something like the following for each of the if statements if you are following the modpack's format:

if ( file_exists(AVATAR_PATH.$row['author_id'].'/~avatar.jpg' ) ){
($row['author_id'] != "") ? $avatar_url= "<img src='".$avatar_url."/~avatar.jpg' border='0' />" : $avatar_url = '';


Summoner Yuna...

Stramm

some annotations

The avatar only got assigned the mini thumb filename if the user has chosen it from his already uploaded files (eg. mini_DSCF1003487.jpg). If he uploads a file within avatar_manage.php to use as avatar it got named eg. user_10001_avatar.jpg (where 10001 is the user id + 10000). The mime ype depends on the uploaded file type.

This has ben changed with the latest fix to always use: user_USER_ID + FIRST_USER_CAT_avatar.mime. The avatar is stored within the users dir (albums/USER_ID + FIRST_USER_CAT/). If PHP is running in safe mode, then in albums/ (that's why the user id is part of the avatars file name)
http://forum.coppermine-gallery.net/index.php?topic=43410.0

Thanks for your work :)