PDA

View Full Version : Download Thread


Logician
07-11-2002, 10:00 PM
This hacks allows you to download a thread into your computer (desktop etc.) as a text file with one click.

The hack adds a "DOWNLOAD THREAD" link next to "Subscribe to this Thread" and when clicked entire thread is downloaded. (See Screenshot (https://vborg.vbsupport.ru/attachment.php?s=&postid=271933))

It's useful when:
a) You want to archive and save the thread,
b) Want to read it offline,
c) It's a long thread and you want to browse it faster as a text file, use better searching features of your text editor. For example wouldnt it be nice to download and search a keyword in the text file in, say, Lesene's Store Hack Thread which has 921 replies? :p

Anyway the hack works with ALL vb versions and very easy to apply (2 steps/ 2 minutes..). If you install it, please click INSTALL (https://vborg.vbsupport.ru/misc.php?s=&action=install&threadid=40981), thank you.

Note : Download function is tested with IE v.6.0 and Netscape v.4.7 and it's working in both browsers. I dont know other browsers or older versions though

Note : For Italian Translation (and instructions) of the hack, see this post (https://vborg.vbsupport.ru/showthread.php?postid=365675#post365675). Thanks to Geminy.


UPDATE AT 13.OCTOBER.2002 : Due to a small bug, I updated the hack code. If you are downloading now, the code you dowload is already updated. If you installed the hack prior to 13.October.2002, you may want to reapply STEP 2, if you encounter problems.

Enjoy the hack. :)
Logician

Logician
07-12-2002, 04:13 PM
Screenshot

Link14716
07-12-2002, 04:15 PM
Looks good. I will probably install this :D

Link14716
07-12-2002, 04:21 PM
Installed and working great. Thanks :)

BigJohnson
07-12-2002, 05:11 PM
Works great. Very nice hack. That would be cool if this hack needed no support hehehe. It works for everyone hehe. Great hack. I love the layout of the TXT file also. Great work indeed.

Xenon
07-12-2002, 09:19 PM
think i will install it, good work pal!!

just a question: does it have any problems on large threads like servertimeouts or something?
do you know anything like that, or that a posters username disappears (as happens sometimes in my archiv hack, and i don't know why ;))

TECK
07-12-2002, 09:36 PM
excellent work logician. :)
congrats on this great idea. i will use it on my tutorials forum.

Logician
07-12-2002, 10:30 PM
Originally posted by Xenon
just a question: does it have any problems on large threads like servertimeouts or something?

I didnt test with very long threads so I dont know what would happen if it is applied to Store Hack thread for instance..
But I really dont think it would be a problem, because even a long thread should not take more than 30 seconds to compile. Depends on your MYSQL performance too of course.

do you know anything like that, or that a posters username disappears (as happens sometimes in my archiv hack, and i don't know why ;))
yeah I know! Same happened to me in this hack. I didnt bother to trace its reason but I applied a LEFT JOIN in my query to get the username from user table, instead of using the username in thread table. Strange but thread table usernames sometimes disappear as you mentioned.. Anyway take a look at my query and you can adopt the same method in your hack too. It obviously works..

Logician
07-12-2002, 10:34 PM
Originally posted by Nakkid
congrats on this great idea.
Thx but I cant say its my idea. I'm highly inspired by Bira's "Download PMs to a file" hack (great hack BTW)..

In fact I requested this hack in that thread months ago, but nobody coded it, so I did.. ;)

Boofo
07-13-2002, 12:46 AM
Another excellent hack, sir. Installed without a hitch and works great! There is one thing, though. Is there a way to parse out the font color codes and other codes like that before it writes the message to a text file? :)

PET
07-13-2002, 06:40 AM
yea ! This is very very cool & usefull !

squawell
07-13-2002, 08:45 AM
what a wonderful hack u did Logician......:D:D:D

* squawell like this one too.... installed.....

ULTIMATESSJ
07-13-2002, 11:26 AM
great hack, nice work

/me clicks install

Logician
07-13-2002, 02:45 PM
Originally posted by Boofo
Is there a way to parse out the font color codes and other codes like that before it writes the message to a text file? :)
it can be possible but it requires some work. I cant promise it done soon, but I can try to add the feature when I'm more available.. :)

Boofo
07-13-2002, 02:48 PM
Sounds good to me. :) Let me know if and when you need some testing done on it. :)

Originally posted by Logician

it can be possible but it requires some work. I cant promise it done soon, but I can try to add the feature when I'm more available.. :)

Ryangel
07-13-2002, 03:24 PM
hmm not sure if there is something wrong but, the savefile name looks weird.
See attachment.

Logician
07-13-2002, 03:31 PM
Originally posted by Ryangel
hmm not sure if there is something wrong but, the savefile name looks weird.
See attachment.
You should be able to download/save the thread anyway, could you? BTW what was the exact thread name you were trying to DL?

Ryangel
07-13-2002, 03:35 PM
Yup . It viewed fine :)

Threadname was : "[News] 4 Jul: Minister's Speech at ITE East (Macpherson)'s Opening "

So maybe that was a problem .

Logician
07-13-2002, 03:44 PM
I tried parse out special characters from thread title so that file name will be nice but some may be missed. In your example it was : char. It's no big deal but if it bothers you, there are 2 possible solutions:

1- edit line:

$filename=preg_replace("/[.!\\\?\^\'\"\$]/", '', $thread[title]);


and replace it as:

$filename=preg_replace("/[.!:\\\?\^\'\"\$]/", '', $thread[title]);

(This will parse out : char too)

2- If you are not interested in naming the file name after thread title, replace the same line as:

$filename='Thread'.$threadid;

After the change all file names will be like "Thread1244.txt" and no more file name bugs. However I personally prefer to use thread title as file name, it is much better IMO..

Your call :)

Ryangel
07-13-2002, 03:52 PM
I followed your first soloution .

Worked out well :)

Thanks for the hack!

Boofo
07-13-2002, 06:39 PM
The original line in your text file had an extra \ in it (right before the '). You didn't add that to what you told him to replace. Is it supposed to be there? (It isn't showing in here for some reason)

$filename=preg_replace("/[.!:\\\?\^\'\"\$]/", '', $thread[title]);

Originally posted by Logician
I tried parse out special characters from thread title so that file name will be nice but some may be missed. In your example it was : char. It's no big deal but if it bothers you, there are 2 possible solutions:

1- edit line:

$filename=preg_replace("/[.!\\\?\^\'\"\$]/", '', $thread[title]);


and replace it as:

$filename=preg_replace("/[.!:\\\?\^\'\"\$]/", '', $thread[title]);

(This will parse out : char too)

Logician
07-13-2002, 08:10 PM
Originally posted by Boofo
The original line in your text file had an extra \ in it (right before the '). You didn't add that to what you told him to replace. Is it supposed to be there? (It isn't showing in here for some reason)

parsing in board playing tricks on us.. Just add a : in my original code right before ! char

Technical info: This line removes some special chars from thread title when forming file name and by adding : char we make it remove that char too..

Boofo
07-13-2002, 08:14 PM
Ok, I just wanted to make sure in case the extra \ was needed. :)

lordnet
07-13-2002, 08:16 PM
Great hack ;)

my best wish...

LORD :)

Reverend
07-13-2002, 08:57 PM
Nice one Logician.
Works great. :cool:

Ryangel
07-13-2002, 11:43 PM
Originally posted by Boofo
The original line in your text file had an extra \ in it (right before the '). You didn't add that to what you told him to replace. Is it supposed to be there? (It isn't showing in here for some reason)

$filename=preg_replace("/[.!:\\\?\^\'\"\$]/", '', $thread[title]);



Thanks for pointing that out !

*Goes to fix code*

Boofo
07-13-2002, 11:57 PM
No problem. :)

Originally posted by Ryangel


Thanks for pointing that out !

*Goes to fix code*

DWZ
07-15-2002, 03:15 AM
Looks like a great idea, can someone post the format of the .txt file...

i.e. download a thread then paste it (or part of it) here in the [code] tag?

Thanks :)

Logician
07-15-2002, 05:33 AM
Originally posted by DWZ
can someone post the format of the .txt file...

sample downloaded thread.. here you go..

FleaBag
07-16-2002, 11:02 PM
You uploaded the template instructions as a text file and hence vB.org is parsing the replacements. So everyone is leeching sortasc.gif from this site. ;) Besides that, great addition to my forums; working well on 2.2.6. Thanks. :)

Logician
07-17-2002, 07:51 AM
Originally posted by GamerForums
You uploaded the template instructions as a text file and hence vB.org is parsing the replacements. So everyone is leeching sortasc.gif from this site. ;)
corrected.. thx.. :)

jassim
07-21-2002, 05:58 AM
i like thise hack tankX :glasses:

ripman
07-25-2002, 11:57 AM
Good idea - I've instaled it :)

but there's a problem - i'm using iuso-8559-2 with polish chars and that causes problems in output .txt file (polish characters are printed badly)

Logician
07-25-2002, 02:18 PM
Originally posted by ripman
but there's a problem - i'm using iuso-8559-2 with polish chars and that causes problems in output .txt file (polish characters are printed badly)
Weird.. I also use a non-english ISO in my own board but I dont have any problems with non-english chars. Unfortunately I cant provide you with a solution for this but just give this a chance:

edit hack code, find:
header("Content-disposition: attachment;filename=".$filename.".txt");

After that add:
header("CHARSET=ISO-8559-2");

Actually this header is not for attachments, so I dont think it will work, but your wont lose anything by trying anyway..

ripman
07-25-2002, 02:34 PM
Blah - still there's a bug :(

FleaBag
09-03-2002, 03:32 PM
Works with 2.2.7. ;) Cheers!

chitown
09-12-2002, 12:34 AM
i have installed this hack and when i click on download thread it opens another blank page and no pop up window to save.... what did i do wrong?

Logician
09-12-2002, 05:47 AM
Originally posted by chitown
i have installed this hack and when i click on download thread it opens another blank page and no pop up window to save.... what did i do wrong?
Which browser (and its version too) do you use? If you have any other browser (Netscape, IE, Opera), please check with that one too. Also try this: left click on the download thread link and choose open in new browser window. Does it still happen then?

chitown
09-12-2002, 09:52 AM
<a href="http://www.cardtrix.com/forum/showthread.php3?threadid=321&action=download" target="_blank">http://www.cardtrix.com/forum/showth...ction=download</a>

IE6 that is the browser i am using and above is the link it is attempting to send me to.

chitown
09-14-2002, 01:25 AM
still opening another blank window, can someone please help

alpha2503
09-20-2002, 11:53 AM
hi folks...

i'm also using the IE6 and the board only opens a blank page if i click on the download link ! hopefully someone get's a solution for this :) !

greetz

chitown
09-20-2002, 12:22 PM
hey alpha my problem was a call to a .php extension and i use .php3 extensions. when ever i add a hack i have to make sure that i change the extensions. I hope that may be your problem.

alpha2503
09-20-2002, 07:25 PM
it isn't cause i only use the *.php extension... i run the board locally on a windows webserver but as i know the javascript variables and so on are given over on the browser or client side so this shouldn't be the fault...

i really checked the hacked code many many times, but there's nothing wrong with it :ermm:... it may be a problem of IE6 + service pack 1 which is included in the windows xp version with service pack 1 but i don't know...

Logician
09-20-2002, 08:27 PM
Originally posted by alpha2503
i run the board locally on a windows webserver but as i know the javascript variables and so on are given over on the browser or client side so this shouldn't be the fault...

i really checked the hacked code many many times, but there's nothing wrong with it :ermm:... it may be a problem of IE6 + service pack 1 which is included in the windows xp version with service pack 1 but i don't know...
Some thoughts:
1- It does not matter for the hack whether you are in Windows or unix. My board is on unix server while my localhost is on Windows and the hack works well on both servers..

2- Your post gave me the impression that your problem is related to your file type associations or your browser. Here are some steps to find out:
a) Try to right click on Download Thread Link and choose "Save Target As" from the menu, does it download now?
b) Try to use different browsers like Netscape, Opera or Mozzilla, does it work?
c) Is it only you who have the problem? Can your users download without problems?
d) Cant you download from other boards' download thread link either? Say, try here:
http://www.bimmervibe.com/phorum/showthread.php?s=&threadid=415

If your answer is YES for either of above, it means the problem is not related to the hack but your file type settings/browser.

What can be your problem then? When you download a program with .xxx extension for the first time, Windows asks you what to do: Open it or Save it. And there is a small box there, Always ask before opening this type of file". If you accidently clear that for ".txt" files and choose to "OPEN" it once, then your IE will be associated with txt files and whenever you click one, IE will automatically open it, instead of save it (or ask what to do). If this is your problem you have to cancel .txt file associations with your IE. To do this either choose a .txt file SHIFT-Right mouse Click/Open With and choose notepad or My computer/View/Tools/Folder Options/File Types and cancel IE's relation with txt files..

I hope this will help..

alpha2503
09-20-2002, 08:35 PM
hi logician !

a) it will download the showthread.htm
b) this ++++in' nutscrape and the other ones have all the same problem
c) i don't like other users on my local pc :D
d) it work's on this board so i think it's the hack itself

if you're good in php i can send you the files which are involved in this hack so that you can look at them, but i think i'm not bad in this by myself so that you wouldn't find any errors ;) but if you want you can try :)

greetz

Logician
09-20-2002, 09:04 PM
Originally posted by alpha2503
if you're good in php i can send you the files which are involved in this hack so that you can look at them, but i think i'm not bad in this by myself so that you wouldn't find any errors ;) but if you want you can try :)

If it would help, yes I could check by myself but I believe it wouldnt. The hack is very simple with 1 step only and since you are not a newbie it's certain that you didnt apply the code incorrectly. My checking it would not do any good, since the same code already works in my system. Your problem should be related to PHP/Server settings or maybe the server program itself. (BTW. are you using Apache?) May I suggest applying the hack to your real board? If its your local host settings that cause the problem, the hack should work in your real board. There are hundreds of users installed the hack and using it without any problems anyway..

marocnl
10-12-2002, 07:48 PM
Hi there!

This is a great hack, but i just have one problem. When i try to download a thread it sends me to the nopermission_error template. I'm an Admin. How the hell is that possible?;)

this is what checks the perms:

// Check Permissions so that a smartass wouldnt download a thread he doesnt allowed to see
$getperms=getpermissions($thread['forumid'],-1,-1,$forum['parentlist']);
if (!$getperms['canview'] or !$thread['visible'])
{show_nopermission();}
if (!$getperms['canviewothers'] and ($thread['postuserid']!=$bbuserinfo['userid'] or $bbuserinfo['userid']==0))
{show_nopermission();}

What is going wrong here?

Logician
10-13-2002, 08:40 AM
Originally posted by marocnl
Hi there!

This is a great hack, but i just have one problem. When i try to download a thread it sends me to the nopermission_error template. I'm an Admin. How the hell is that possible?;)

Can you please apply this (as STEP 2) and tell me if your problem is cured? Thanks..

marocnl
10-13-2002, 09:07 AM
Works great. Thnx man! :knockedout:

One question which has nothing to do with ur hack. :)

Does the amount of tables in a (MySql) database has any effect on the speed of that database?

Logician
10-13-2002, 09:31 AM
Originally posted by marocnl
One question which has nothing to do with ur hack. :)
Does the amount of tables in a (MySql) database has any effect on the speed of that database?
The answer is no for you.. If you are asking for a bank database or smt., I keep my right to change the answer.. ;)

marocnl
10-13-2002, 10:40 AM
Originally posted by Logician

The answer is no for you.. If you are asking for a bank database or smt., I keep my right to change the answer.. ;)
I thought so......thnx 4 the confirmation. :knockedout:

ukbill69
10-23-2002, 08:08 PM
I would like to say that to add this txt to the showthread becuase i have found that there was no space and divider. So here it is: |
<!-- Download Thread Hack Start -->
<img src="{imagesfolder}/sortasc.gif" alt="" border="0" align="absmiddle"> <a href="showthread.php?s=$session[sessionhash]&threadid=$threadid&action=download">Download Thread</a></table>
<!-- Download Thread Hack Finnish -->

kreatiV
10-27-2002, 07:08 AM
This seems like a great hack to me I am close to installing it. Is there a chance that Usergroup Permissions can be applied to this in a new version?

I would like only certain Usergroups to be able to download threads and not everybody that is registered on my board.

Logician
10-27-2002, 08:08 AM
I would like only certain Usergroups to be able to download threads and not
yep possible..

Find:

if (!$threadid OR $threadid<1) {show_nopermission();}

After that add:


if ($bbuserinfo[usergroupid]!=X AND $bbuserinfo[usergroupid]!=y AND $bbuserinfo[usergroupid]!=z) {show_nopermission();}

This will allow only usergroup X, Y, Z to download the thread..

kreatiV
10-27-2002, 08:52 AM
Cool! I gotta grab that hack now and install it later on.

FleaBag
10-28-2002, 10:53 PM
Works with 2.2.8. Cheers. :D

N9ne
10-29-2002, 12:03 AM
Excellent hack, working flawlessly on 2.2.8. Just one thing though, you should add a space after the img code in the showthread template, so the Download this thread link isn't right next to the image :).

filburt1
11-04-2002, 11:09 PM
Logician, I hope you don't mind: http://www.vbulletintemplates.com/mods/showthread.php?s=&threadid=1845 :)

SRozhon
11-06-2002, 10:05 PM
This looks awesome, but I have a quick question. In step 1 it says
Edit Template SHOW THREAD TEMPLATES/showthread
I feel like an idiot but what file is this that I should edit? Thank you!

Logician
11-06-2002, 10:13 PM
Originally posted by SRozhon
This looks awesome, but I have a quick question. In step 1 it says

I feel like an idiot but what file is this that I should edit? Thank you!
it's not a file, it's a template editing.. You have to login to your Admin CP, choose Modify Template, then find the template mentioned and edit it.. ;)

SRozhon
11-06-2002, 10:41 PM
Oh geesh thank you...guess I'm more tired than I thought..lol Thanks again!

Dynamic One
11-11-2002, 09:16 AM
Thanks Logician. Great hack you made m8.

geniuscrew
11-20-2002, 11:02 PM
Works like a charm! *installs*

Boofo
01-15-2003, 05:15 PM
I just installed this on 2.2.9 and I have a thread title with quotes in it. When I go to download the thread it shows it as the following:
Do you believe in & quot
(NOTE: I had to put a space bewteen the & and the quot. The disable code hack doesn't work here now for some reason.)

when the actual name of the thread is:
Do you believe in "signs"?
How can I parse out the quotes in the title?

MalaK_3araby
01-18-2003, 10:37 AM
Thanks for this hack.

- Installs

N9ne
01-18-2003, 02:40 PM
I noticed the same bug as Boofo did, when there is a html character in the thread title, it will screw up the file name, something somewhere needs to be unhtmlcharacter'd

Boofo
01-19-2003, 10:51 PM
N9ne, I found a fix for our problem. I tried it and it works on my end. Test it out and let me know if it fixes it for you. You have to change it in 3 places so the file will have the html characters in the thread title and any post title you have those characters in also.

Replace:

$filename=preg_replace("/[.!:\\\?\^\'\"\$]/", '', $thread[title]);

With:

$filename=preg_replace("/[.!:\\\?\^\'\"\$]/", '', unhtmlspecialchars($thread[title]));

Replace:

print ("THREAD : $thread_db[title]\r\n");

With:

print ("THREAD : ".unhtmlspecialchars($thread_db[title])."\r\n");

Replace:

if ($post[title]) {print ("Title : ".$post[title]."\r\n");}

With:

if ($post[title]) {print ("Title : ".unhtmlspecialchars($post[title])."\r\n");}

Logician
01-20-2003, 08:10 AM
Originally posted by Boofo
N9ne, I found a fix for our problem.
Looks good and should work.. Well done..

Boofo
01-20-2003, 08:16 AM
Originally posted by Logician

Looks good and should work.. Well done..

Coming from you, Sinan, that means more than you will ever know. I mean that. ;)

And thank you for not running to bail me out when I first ran into this problem and posted it in the thread here. I never would have figured it out myself, if you had given me the code. You forced me to learn something (as little as it was). :)

Logician
01-20-2003, 08:47 AM
Originally posted by Boofo

And thank you for not running to bail me out when I first ran into this problem and posted it in the thread here. I never would have figured it out myself, if you had given me the code. You forced me to learn something (as little as it was). :)
It was not my intention.. I just cant always find time to answer promptly but I'm glad it did some good.. :)

Boofo
01-20-2003, 09:02 AM
I'm sorry. I didn't mean for that to sound in a negative way. I meant that by you being busy, it helped me to force myself to try and figure it out on my own, which is always better for learning. Sorry, if it sounded like something else. :)

Geminy
03-13-2003, 05:18 PM
This is the Italian translate of the hack

Questa ? la traduzione in Italiano dell'Hack.

Thanks to LOGICIAN to have I date the licence to translate this Hack :) .

Grazie a LOGICIAN per aver dato il permesso di tradurre questo Hack.

cirisme
03-14-2003, 04:19 PM
Excellent hack!

(thumbs up)

tmapm
06-15-2003, 12:19 PM
You should ass Boofo's update to the hack :p ANyways this hack works great. Thanks!

Giveit2u43
07-27-2003, 06:14 PM
Well, I love this hack it`s a great idea but the users where complaining about the different tags showing up in the downloaded messages, I added the following to remove them.. (don`t know if this is the best way of doing this, but it works and for the users that`s all that counts)

add:

$dlt = $post[pagetext];
$dlt = htmlspecialchars($dlt);
$dlt = preg_replace("/(\[quote])/siU", "\r\n********************************************** ********************************\r\n", $dlt);
$dlt = preg_replace("/(\[\/quote])/siU", "\r\n********************************************** ********************************", $dlt);
$dlt = preg_replace("/(\[)(.*)(\])/siU", "", $dlt);
$dlt = preg_replace("/(\[\/)(.*)(\])/siU", "", $dlt);
$dlt = preg_replace("/(\[\*\])/siU", "", $dlt);


after:

while ($post=$DB_site->fetch_array($post_db))
{


and change:

print ("\r\n$post[pagetext]\r\n\r\n");


to:

print ("\r\n$dlt\r\n\r\n");

Logician
07-27-2003, 06:36 PM
thx for sharing.. not the best way to handle it as bbcode can change from board to board but still very useful for boards which are in English language and using default bbcodes.

Giveit2u43
07-27-2003, 06:56 PM
Yep, you where right.. actually, after I thought about this a little more I realised that if I stripped everything between the [ ]'s that`ll work too.. So I`ve updated the original post with a much simpilier way of doing this that should be more suitable for those not using standard bbcodes or english ones ;)

Logician
07-27-2003, 07:15 PM
Today at 10:56 PM Giveit2u43 said this in Post #77 (https://vborg.vbsupport.ru/showthread.php?postid=421039#post421039)
Yep, you where right.. actually, after I thought about this a little more I realised that if I stripped everything between the [ ]'s that`ll work too.. So I`ve updated the original post with a much simpilier way of doing this that should be more suitable for those not using standard bbcodes or english ones ;)
As a matter of fact I believe that the other code was better and more flexible for customization. :) Arent this code not only removing bbcode but also any texts that appears in [ ] but not a bbcode? :)

Giveit2u43
07-27-2003, 08:48 PM
Well the other code was more flexible for customization as it removed each code seperately, but I found it did add quite a bit to the creation time for the download page, doing it with less preg_replaces is quicker (at least in my tests)

And yes that code will remove EVERYTHING in [ ]'s BBCode or Otherwise, and I`ve made a point of adding a notice to the post pages informing all users that text in [ ]'s is stripped from the downloaded thread's so they shouldn`t be used... (not that they have ever been used for anything but bbcodes, but well now people know *g*)

I`m really just a beginner and wanted something effective that would stop users from complaining, this worked and in my test the only ill effect is that URL`s are stripped so if a URL is posted in a thread it`ll just display the name that was used not the URL, and I haven`t quite found a workaround for that which looks okay.. I can get it to display:

http://www.domain.com]Link Name

but can`t replace that ] with a space or a : to make the layout nicer.. maybe a better answer will come as I continue to investigate the PHP stripping, trimming, replacing functions..

Thanks for your comments..

MindTrix
09-27-2003, 02:02 PM
Cudnt get the hack to work, kept gettin sent bck to the same page, then realised i hadnt re-uploaded the php file **dumbass** works brilliant thanks a bunch :>

wolfgang2
10-11-2003, 10:20 PM
just installed!
works great on 2.3.0!
Thx

brendonm
10-22-2003, 10:29 AM
nice work :) installed 2 minutes, no problems - works very well. *Clicked Install*

Agent XY
12-15-2003, 02:33 PM
very nice, short hack :D

thx!

(Works on vB 2.3.3 german)