Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: jpg, png and gif check  (Read 6628 times)

0 Members and 1 Guest are viewing this topic.

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
jpg, png and gif check
« on: November 14, 2006, 09:09:27 pm »

Hey

So one last thing ;)

So I would like to get the avatars to work in punbb, in you initial post when you just made the bridge you said:

Quote
Avatars... prepared but not implemented. You shouldn't enable avatars in CPG. However you can eg modify the function theme_html_comments... and check for jpg, gif, png, and if found, display the avatar. You only need to do this check, the avatar path and the name is already available

so I would like to do this:  here is the relevant part of theme_html_comments:

Code: [Select]
if($cpg_udb->can_join()){
if ($CONFIG['enable_avatar']){
        ($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"]."' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}
else $avatar_url="";
} else { // only used when tables can't be joined... then we need to query for the avatar URL -> function get_avatar
if ($CONFIG['enable_avatar']){
$result2 = $cpg_udb->get_avatar($row['author_id']);
$avatar_url= preg_replace('/\/\//','/',AVATAR_PATH.$result2["avatar_url"]);
        ($result2['avatar_url'] != "") ? $avatar_url= "<img src='".$avatar_url."' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}
else $avatar_url="";
}

So I need to add the jpg, png and gif file extension check to this code somewhere right?

Which section is used by punbb, the if or else part?

Cheers

Nick
« Last Edit: November 15, 2006, 12:35:04 pm by Stramm »
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: jpg, png and gif check
« Reply #1 on: November 14, 2006, 09:26:08 pm »

are I find it is the first if statement.

If i stick .jpg after the avatar url bit all the avatars that are jpegs show up.

So i need to somehow put something that checks file extensions here....I'll search around google a bit for a way of doing this.

Cheers

Nick
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: jpg, png and gif check
« Reply #2 on: November 15, 2006, 04:17:13 am »

so i have done it and tested it...(i had a little help from the guys over on www.dreamincode.net)

so if anyone else wants to get avatars working with coppermine bridged to punbb you will need to replace this code:

Code: [Select]
if ($CONFIG['enable_avatar']){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].'.gif'"' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
}

with this code:
Code: [Select]
   if ($CONFIG['enable_avatar']){
if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.jpg' ) ){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".jpg' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.png' ) ){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".png' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.gif' ) ){
($row['avatar_url'] != "") ? $avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".gif' class='image' style='float: left; margin-right: 5px;' alt='' />" : $avatar_url = '';
            }
}


In the file... themes.inc.php (of course you will need stramm's modpack)


for an example of it working now that has comments with avatars that are both gif and jpg:

http://amateurillustrator.com.s2734.gridserver.com/galleries/displayimage.php?pos=-1033

i can't guarantee that this example will stay here. but I will soon be updating my main gallery (see my signature for link) to have this feature.


thanks for all your help stramm and hope this helps some people...maybe you could add it to your modpack?

cheers

Nick
Logged

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: jpg, png and gif check
« Reply #3 on: November 15, 2006, 05:27:22 am »

after a bit more testing i found a little bug

if someone comments who has an avatar then somone comments who doesn't have an avatar the avatar from the fist poster will be used.

This problem isn't visible if everyone has avatars or if the person without the avatar comments first.

I will fix this and post my changed code here.
Logged

Stramm

  • Moderator
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: jpg, png and gif check
« Reply #4 on: November 15, 2006, 08:34:38 am »

not tested...

Code: [Select]
   if ($CONFIG['enable_avatar'] && $row['avatar_url'] != ""){
if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.jpg' ) ){
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".jpg' class='image' style='float: left; margin-right: 5px;' alt='' />";
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.png' ) ){
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".png' class='image' style='float: left; margin-right: 5px;' alt='' />";
            }
else if ( file_exists(AVATAR_PATH . $row['avatar_url'] . '.gif' ) ){
$avatar_url= "<img src='".AVATAR_PATH.$row["avatar_url"].".gif' class='image' style='float: left; margin-right: 5px;' alt='' />";
            }
else $avatar_url="";
}
else $avatar_url="";

nickfzx

  • Contributor
  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Gender: Male
  • Posts: 285
Re: jpg, png and gif check
« Reply #5 on: November 15, 2006, 12:04:30 pm »

yep that's done it...seems to work now in all cases i can see.

 
here is an example:
http://amateurillustrator.com.s2734.gridserver.com/galleries/displayimage.php?album=lastcom&cat=1&pos=90

anyone reading this ignore my code, stramm's is the correct one :)

cheers

Nick
Logged
Pages: [1]   Go Up
 

Page created in 0.05 seconds with 19 queries.