UBB.Dev
Posted By: JoshPet [6.1] AttachFileTypeImage1.0 - 08/23/2002 7:07 AM
Mod Name / Version - AttachFileTypeImage1.0.txt

Created - August 23, 2002

Description - Adds a File Attachment Icon to the Postlist, Show Flat and Threaded View indicating the TYPE of File that is attached. With the new download script.. you don't know what you are clicking on... a small photo... a large video file... a text file... a pdf, a File Attachment Icon will indicate what type of file is attached. In the Postlist view, the icon appears in front of the subject (in place of the standard disk). In Flat and Threaded views, it will appear next to the "Attachment" link, which also helps users find the small "attachment" link. You can edit the file types if you need to add an extension. If the file type isn't in the code, it will default to the disk icon.

Working Under - UBB.threads 6.1

Any pre-requisites - none

Author(s) - Joshua Pettit (JoshPet)

Credits - many have suggested it at ThreadsDev - I think Gardener recently suggested this more specifically

Files Altered - postlist.php, showflat.php, showthreaded.php

Database Altered - no

New Files - fileiconmovie.gif, fileiconpdf.gif, fileiconphoto.gif, fileiconsound.gif, fileicontext.gif, fileiconzip.gif

Any other info - This mod is all set, but my graphics are still lacking.

[:"red"]PLEASE POST SOME BETTER FILE ICONS IF YOU FIND THEM!!![/]

Current included icons are:
[]http://www.pettitfamily.net/josh/fileiconphoto.gif[/] for .GIF, .JPG, .PNG graphic files.

[]http://www.pettitfamily.net/josh/fileiconsound.gif[/] for .WAV, .RA, .AU, .MP3, .AVI sound files.

[]http://www.pettitfamily.net/josh/fileiconmovie.gif[/] for .MPG, .MPEG, .RM, .WMV, .MOV, .ASX, .RAM video files.

[]http://www.pettitfamily.net/josh/fileicontext.gif[/] for .TXT text files.

[]http://www.pettitfamily.net/josh/fileiconzip.gif[/] for .ZIP, .SIT, .SEA compressed files.

[]http://www.pettitfamily.net/josh/fileiconpdf.gif[/] for .PDF Adope Acrobat files.

If the file type isn't specified in the code... it will default to the standard disk icon []https://www.ubbdev.com/threads/php/images/icons/disk.gif[/].

Like I said.... I don't really like the icons.... it's all I could find. Suggestions please. Also let me know if I've left out or mis categorized any file type extension.

Thanks!


Attached File
Posted By: Gardener Re: [6.1] AttachFileTypeImage1.0 - 08/23/2002 9:32 AM
Nice work! I've wanted this before, and as you say it is even more needed in 6.1.

How about also adding the size of the attachment next to the link on showflat and showthreaded?

I'll try to find some better icons, they should all be roughly the same size and style for it to look good.
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/23/2002 3:55 PM
Thank you!
Filesize would be a good idea. I'll have to look at that in a revision.
We have a video forum on our site.. and some of those attachments can get large for the poor folks using dial up .

Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 08/23/2002 4:17 PM
Josh, will this work in 6.0.1 ? I needed this desperately, but want to give 6.1 a bit of time to settle down before I upgrade
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/23/2002 4:24 PM
It could..... there will be slight changes. (because of the new download script in 6.1)

I will look at this and post instructions for 6.x tonight.
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/23/2002 4:43 PM
Version 1.1 is attached to THIS POST.

It's the same.... is't just at the bottom of the instructions I give directions for 6.0.x.

Enjoy!



Attached File
Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 08/24/2002 6:57 AM
Thanks a ton, I am trying this out NOW!

Just bothering you with another question, or rather suggestion. From the description, it seems this iwll work only for attachments. But in my board, though I have the hack installed which displays attached pictures inline in the post, most of my members tend to post pictures using the [image] code -- in your future release, if you could incorporate displaying the gif in postlist even for [image] tagged pics inside a post, that will be gr8!
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/24/2002 7:06 AM
Good suggestion.

I'll have to see if that's doable.
I don't think the postlist looks up the body of the message... although it could....
That also might be a first step at a mousover preview of the message.

Hmmmmmmm....
Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 08/24/2002 10:22 AM
Josh, had some problems (v.6.0.1)...

1) showflat -- works fine.

2) showthreaded -- doesnt show the icon beside Attachment -- in fact, doesnt even show th eword "Attachment" any more.

3) Postlist -- absolutely no effect -- it just doesnt show any icons.

Where might I have gone wrong? I do have a hack installed which inlines all attachments and displays the image, but in showflat, both of them works together and is working fine.

Personally, I can live without the icon showing up beside "Attachment" text -- we only allow image attachments, and they are inlined anyway. But the postlist is what I desperately wanted to work.


Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 08/24/2002 11:25 AM
Ok, managed to sort out (2) above. Showthread now works.

In the last but one line were the text for 6.0.1 says "replace with"
code:
$postrow[$i]['filelink'] = "<a href="{$config['fileurl']}/$File">{$ubbt_lang['FILE_ATTACH']} $fileicon</a>";



Should actually be
code:
$filelink = "<a href="{$config['fileurl']}/$File">{$ubbt_lang['FILE_ATTACH']} $fileicon</a>";



That took care of it. Work sfine now.

(3) This still aint working -- I rehacked thrice

If its any clue, I have installed the Sticky hack, and though I can Stick posts, it does not display the word "Sticky:" in front of the Subject like the code says it should. I have checked the code and found nothing wrong.

If you take the two incidences together, then in my board something is stopping anything to be displayed in front of the $subject! Any clues?

Posted By: omegatron Re: [6.1] AttachFileTypeImage1.0 - 08/25/2002 12:09 AM
How come when I take a look at your hack instructions none of the lines you say are in the files are actually in the files?

They do not exist in version 6.1 of files. Is this hack an add-on of another hack I need to do?
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/25/2002 3:25 AM
posted by crescendo:
Josh, had some problems (v.6.0.1)...
3) Postlist -- absolutely no effect -- it just doesnt show any icons.



Sounds like you figured out all the problems except Postlist.

I revised the postlist instructions (for 6.0.x) and will repost below... as version 1.2.

In 6.1 Rick is already checking the database to see if there's a file.. as he does the disk icon thing... but not in 6.0.x.... so we need to add that in.

Download 1.2 and note the 2 new lines to change (Adding $file to the database query) in postlist.php and you should be all set.

Sorry.... didn't test for 6.0.x and have begun to lose track of what were features and what were hacks.
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.2 - 08/25/2002 3:26 AM
Version 1.2 is Attached!

It fixes directions for postlist.php on version 6.0.x

Directions for 6.1 remain unchanged.

:)

Attached File
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/25/2002 3:32 AM
posted by omegatron:
How come when I take a look at your hack instructions none of the lines you say are in the files are actually in the files?

They do not exist in version 6.1 of files. Is this hack an add-on of another hack I need to do?


I just looked at your site.... you're running 6.0.3.

The instructions at the begining of the hack are for the newly created.... 6.1 BR1...came out just a couple of days ago.

If you need instructions for 6.0.1, 6.0.2, and 6.0.3... the instructions come AFTER the 6.1 instructions (as I added them for crescendo). Read past the 6.1 instructions if you're not running 6.1 BR1 yet.
Posted By: yors Re: [6.1] AttachFileTypeImage1.2 - 08/25/2002 9:10 AM
posted by JoshPet:
Version 1.2 is Attached!


Whooooohooo...I got it working finally (6.0.1) -- bless you Josh!!

OK, there was still a 'wee bit' of crease in the text of v1.2 -- confusion between $File and $file (yes, just uppercasing all Fs wherever there is "$file" solved the problem with postlist!!)

I am taking the privilege of uploading the corrected instruction -- please note that this is entirely Joshpets creation, I have merely corrected some minor errors in the UBBT6.0.x instructions

Attached File
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.2 - 08/25/2002 4:04 PM
Cool. Thank you!
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.3 - 08/25/2002 8:07 PM
OK

I've added the ability for it to display in showflat and showthreaded the size of the Attachment in Bytes, KB or MB (whichever is the most logical). Thus users can not initiate the download of a large attachment if they have a slow connection.

Version 1.3 is Attached to THIS POST

Attached File
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/26/2002 9:12 AM
posted by crescendo:
Just bothering you with another question, or rather suggestion. From the description, it seems this iwll work only for attachments. But in my board, though I have the hack installed which displays attached pictures inline in the post, most of my members tend to post pictures using the [image] code -- in your future release, if you could incorporate displaying the gif in postlist even for [image] tagged pics inside a post, that will be gr8!


Just re-read this thread and was reminded of this request... I think this has merit too, to allow for inline photos.

I'm not sure if it's do-able (at my level)... I'm new to this but learning fast... but I surprised myself today in figuring out the filesize thing..... so I will look and see if i can make this work.

I think mod has some great potential...I am especially liking the addition of the filesize.... you should be able to see what lines were new in the instructions if you wish to add that in.

If anyone finds some better images (or feels creative) that would better fit with the size and theme of threads....please post them.
Posted By: omegatron Re: [6.1] AttachFileTypeImage1.0 - 08/26/2002 11:57 AM
Well it is actually very doable. I have both hacks installed together fine. Here is the code below. You will see I did not delete the initial hacks code so the pics are still displayed inline.

Josh's hack in red the inline image in blue.

[:"red"]
if ($File) {
$fileicon = "";
if (eregi("\.GIF|\.JPG|\.PNG", $File)) {
$fileicon = "<img src="{$config['images']}/fileiconphoto.gif" alt="Photo" border="0" $imagestyle />";
}
elseif (eregi("\.TXT", $File)) {
$fileicon = "<img src="{$config['images']}/fileicontext.gif" alt="Text Document" border="0" $imagestyle />";
}
elseif (eregi("\.ZIP|\.SIT|\.SEA", $File)) {
$fileicon = "<img src="{$config['images']}/fileiconzip.gif" alt="Compressed File" border="0" $imagestyle />";
}
elseif (eregi("\.PDF", $File)) {
$fileicon = "<img src="{$config['images']}/fileiconpdf.gif" alt="PDF File" border="0" $imagestyle />";
}
elseif (eregi("\.WAV|\.RA|\.AU|\.MP3|\.AVI", $File)) {
$fileicon = "<img src="{$config['images']}/fileiconsound.gif" alt="Sound File" border="0" $imagestyle />";
}
elseif (eregi("\.MPG|\.MPEG|\.RM|\.WMV|\.MOV|\.ASX|\.RAM", $File)) {
$fileicon = "<img src="{$config['images']}/fileiconmovie.gif" alt="Movie File" border="0" $imagestyle />";
}
else {
$fileicon = "<img src="{$config['images']}/file.gif" alt="{$ubbt_lang['FILE_ATTACH']}" border="0" $imagestyle />";
}
$File = rawurlencode($File);
$postrow[$i]['filelink'] = "<a href="{$config['fileurl']}/$File">{$ubbt_lang['FILE_ATTACH']} $fileicon</a>";[/][:"blue"]
if ($user['U_Username']) {
if (eregi("\.GIF|\.JPG|\.PNG", $File)) {
$TempBod = $Body;
$TempBod .= "<br /><br /><IMG SRC="$config[fileurl]/$File" Border="0">";
$Body = $TempBod;
}
}
}
[/]

Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 08/26/2002 4:43 PM
Yes, cool.

He wants the "photo" icon to appear if someone has used the image tag in their post and linked to an off site photo in their post as well.

I need to look at that. It's probably doable as well.

Thanks.
Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 08/27/2002 7:13 AM
Thats right Josh. Omegatron: this hack works perfectly with inlined "Attached" images, as you say...even I have both installed and working together. All you have to do is correctly identify where to replace or insert the codes keeping the inlining code intact. I was specifically looking for this to work with [image] tagged pictures too.

Just stating so that there is no confusion
Posted By: omegatron Re: [6.1] AttachFileTypeImage1.0 - 08/27/2002 11:48 AM
okay yes thats cool. Thats always a good thing to pay proper attention to hacking and merging
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.4 - 09/08/2002 8:50 PM
Version 1.4 is attached to this post.

It offers 2 alternative icons for Zip and Movie files.

It fixes a bug in the filesize calculation that wasn't working correctly if the file name had spaces or special characters. Thanks to Dave_L for helping me with this.

It fixes a bug where .RAM files (video) were showing as a sound file because .RA came first in my list.

Enjoy!
Seems to be working well on my 6.1 br1 board which has now gone live.

Attached File
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 09/08/2002 9:05 PM
[]most of my members tend to post pictures using the [image] code -- in your future release, if you could incorporate displaying the gif in postlist even for [image] tagged pics inside a post, that will be gr8!


I haven't forgotten this..... but I don't think it's possible.

The post is stored with the <img src tag in the database. If you were to say "if the body contains img src tag...then display the photo image in the subject... it would do so for graemlins as well.

Don't know of a way around that. They are images too.

If I had a photo icon in each post when graemlins were used.... every post would have one.. and it would be worthless. <SHRUG>
Posted By: Gardener Re: [6.1] AttachFileTypeImage1.0 - 09/09/2002 12:00 AM
One way could be to add a field in the table which can be 1 or 0 and is set when the post is made. If there is an image-tag in the post, the value of the field is set to 1. Then you would only have to check this variable in the postlist.
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 09/09/2002 4:46 AM
That's a good idea... you could look for the "image" tag when the post is made.
Posted By: Aglavalin Re: [6.1] AttachFileTypeImage1.0 - 09/09/2002 9:06 AM
Or you could add the html of each graemlin on your site into the code, to ignore them. This way would not alter the database at least.
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 09/09/2002 9:55 AM
I wonder. Either way...this one might be about 3 feet over my head.
Posted By: Aglavalin Re: [6.1] AttachFileTypeImage1.0 - 09/09/2002 10:01 AM
I'm kinda bored, might start farting around with this one. I would do it with no database alterations though. More code to add in, but less intrusive if you remove it later on.
Posted By: JoshPet Re: [6.1] AttachFileTypeImage1.0 - 09/09/2002 10:09 AM
I agree. I use database alterations sparingly.

I've been debating about the "last post" hack for months. Might give that one a go.
Posted By: Aglavalin Re: [6.1] AttachFileTypeImage1.0 - 09/10/2002 7:36 AM
I got this working, but it's only searching the first post for the <img> tag so far. I need to have it ignore graemlins and see if I can get it to look at the other post bodies as well. May just let it look at the first, since that seems more doable and far less strain on the server.
Posted By: Aglavalin Re: [6.1] AttachFileTypeImage1.0 - 09/10/2002 8:55 AM
I just finished a hack to show an image in the supject on the postlist.php page for posts that have an image inserted in the body on the initial post. It is located here.

It just seemed like too much server load to have it hunt down every reply and search through them...
Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 09/13/2002 4:05 PM
[]

The post is stored with the <img src tag in the database. If you were to say "if the body contains img src tag...then display the photo image in the subject... it would do so for graemlins as well.

Don't know of a way around that. They are images too.



Josh, thee graemlins are stored in a specific directory, isnt it? Cant we make the script ignore any img src tag pointing to that directory?

I mean, when I thought of this, I too was exactly foxed by "what to do with graemlins?", but this seems to be the simplest way, if its possible.
Posted By: yors Re: [6.1] AttachFileTypeImage1.0 - 09/13/2002 4:06 PM
oops, sorry, I was on page 2 when I replied

Going over to check your hack aglavalin!
© UBB.Developers