PDA

View Full Version : Attachment Database


rake
17 Nov 2002, 18:37
It's self-explanatory and easy to install. You can view a demo here: http://forums.ffdiscovery.com/attach.php


Instalation
===========

Installation is extremely easy. First open the attach.php file and check the configuration. It's designed to work with the private attachments hack and the attachment viewer. After checking the config, upload the file to your forums directory, create a new template called attachment with the contents of the attachment.txt file and a new template called attachmentbit with the contents of the attachmentbit.txt file. That's it.

Feedback is always appreciated. You can get assistance, if needed, either through an e-mail or through my forums.

SpeedStreet
17 Nov 2002, 19:19
Nice Idea!

Is it possible to grant moderators and admins delete privileges? This would be a great addon for managing the amount of attachments you currently have!

EDIT: Listing of file size would be pretty groovy too... :)

KelteN
17 Nov 2002, 19:21
Originally posted by SpeedStreet
Nice Idea!

Is it possible to grant moderators and admins delete privileges? This would be a great addon for managing the amount of attachments you currently have!

EDIT: Listing of file size would be pretty groovy too... :)

Nice ideas :D It would be nice to see them added into this hack ;)

corsacrazy
17 Nov 2002, 19:37
kool ive been lookin for something like this , cheers ... i have the hack thing "attactments : 112" and i was lookin 2 put a link on that to goto all the attatchment and this hack wood b perfect thanks alot.

corsacrazy
17 Nov 2002, 19:46
damn im getting this error
Database error in vBulletin 2.2.8:

Invalid SQL: SELECT attachment.attachmentid,attachment.userid,attachment.dateline,attachment.filenam e,attachment.visible,attachment.private,attachment.counter,post.postid,post.thre adid,thread.title,user.username FROM attachment LEFT JOIN post on attachment.attachmentid=post.attachmentid LEFT JOIN thread USING(threadid) LEFT JOIN user on attachment.userid=user.userid WHERE attachment.visible=1 AND post.attachmentid<>0 LIMIT 0,15
mysql error: Unknown column 'attachment.private' in 'field list'

mysql error number: 1054



this is how i have set up the attatc.php file


//===================== config ===============
$privattach = 0; // set this to 1 if you have the private attachments hack installed. 0 if not.
$ppg = 15; // atttachments to show per page
$maxppg = 100; // maximum attachments per page
$attachviewer = 1; //set this to 1 if you've got the attachment viewer installed. 0 if not.
//============================================


please can you help me out ? thanks

Ninth Dimension
17 Nov 2002, 19:47
I'm using the attachments as files hack, is this compatabul with it?

!!!
17 Nov 2002, 19:50
Originally posted by rake
It's self-explanatory and easy to install. You can view a demo here: http://forums.ffdiscovery.com/attach.php


Instalation
===========

Installation is extremely easy. First open the attach.php file and check the configuration. It's designed to work with the private attachments hack and the attachment viewer. After checking the config, upload the file to your forums directory, create a new template called attachment with the contents of the attachment.txt file and a new template called attachmentbit with the contents of the attachmentbit.txt file. That's it.

Feedback is always appreciated. You can get assistance, if needed, either through an e-mail or through my forums.

Private attachment? Attachment viewer?

corsacrazy
17 Nov 2002, 19:52
they are other hacks


Private attachment : allows u 2 attactch files in a pm
Attachment viewer: shows the attachment within a page looking like your forum, ie includes the header/footer and shows who posted the attactment

rake
17 Nov 2002, 19:58
Originally posted by corsacrazy
damn im getting this error



this is how i have set up the attatc.php file


//===================== config ===============
$privattach = 0; // set this to 1 if you have the private attachments hack installed. 0 if not.
$ppg = 15; // atttachments to show per page
$maxppg = 100; // maximum attachments per page
$attachviewer = 1; //set this to 1 if you've got the attachment viewer installed. 0 if not.
//============================================


please can you help me out ? thanks


sorry about that. re-download the file

corsacrazy
17 Nov 2002, 20:03
same error :(

rake
17 Nov 2002, 20:16
check for this line:

$getattach = $DB_site->query("SELECT attachment.attachmentid,attachment.userid,attachment.dateline,attachment.filenam e,attachment.visible ".iif($privattach,',attachment.private','').",attachment.counter,post.postid,post.threadid,thread.title,user.username FROM attachment LEFT JOIN post on attachment.attachmentid=post.attachmentid LEFT JOIN thread USING(threadid) LEFT JOIN user on attachment.userid=user.userid WHERE attachment.visible=1 AND post.attachmentid<>0 ".iif($privattach,'AND private=0','')." LIMIT $min,$perpage");

corsacrazy
17 Nov 2002, 20:17
mine says

$getattach = $DB_site->query("SELECT attachment.attachmentid,attachment.userid,attachment.dateline,attachment.filenam e,attachment.visible,attachment.private,attachment.counter,post.postid,post.thre adid,thread.title,user.username FROM attachment LEFT JOIN post on attachment.attachmentid=post.attachmentid LEFT JOIN thread USING(threadid) LEFT JOIN user on attachment.userid=user.userid WHERE attachment.visible=1 AND post.attachmentid<>0 ".iif($privattach,'AND private=0','')." LIMIT $min,$perpage");

rake
17 Nov 2002, 20:19
replace it with the one i posted above and it will work.

corsacrazy
17 Nov 2002, 20:19
i replaced my code with the one you said and its working now , thanks alot ;)

Velocd
17 Nov 2002, 20:31
Very nice, this is one I will be sure to install, but an even more efficient attachment database is one that categorizes the attachments by the forum they are in. I'll consider revising it with this improvement if you don't want to yourself, and then posting it.

/me clicks install ;)

Dean C
17 Nov 2002, 20:32
Thats pretty damn cool...

- miSt

corsacrazy
17 Nov 2002, 20:55
wood there be a way to order the attactments by a value set in the attach.php file ie, order by filesize, number of times downloaded, or extension. ? ?

Dark_Wizard
18 Nov 2002, 00:59
Does this work with the "Attachments as Files" hack? Otherwise I would have to rewrite it and don't have the time to do it...

dev
18 Nov 2002, 07:28
Very cool Hack, great! thx

Bison
18 Nov 2002, 11:36
Originally posted by Velocd
Very nice, this is one I will be sure to install, but an even more efficient attachment database is one that categorizes the attachments by the forum they are in. I'll consider revising it with this improvement if you don't want to yourself, and then posting it.

* Velocd clicks install ;)

I await your modifications! :)

rake
18 Nov 2002, 13:15
Originally posted by Dark_Wizard
Does this work with the "Attachments as Files" hack? Otherwise I would have to rewrite it and don't have the time to do it...

I don't know if that hack modifies the announcement table or not. I'll have to look into it and create a compatible version, but my time is limited. I have a whole lot of exams this week. :nervous:

Larry@IOG
19 Nov 2002, 01:17
Database error in vBulletin 2.2.8:

Invalid SQL: SELECT COUNT(*) FROM attachment WHERE visible=1 AND private=0
mysql error: Unknown column 'private' in 'where clause'

mysql error number: 1054

Date: Monday 18th of November 2002 08:08:53 PM
Script: http://www.impulseownersgroup.com/vb/vb/attach.php
Referer:


Is what I am getting

Larry

SWFans.net
19 Nov 2002, 05:15
I'm not sure why, but I installed this hack to test it out, and as I tried to load attach.php my server load on a semi dedicated server wen't through the roof and stalled MySQL on my forums. I think something needs some optimization maybe.

FWC
19 Nov 2002, 07:50
Originally posted by SWFans.net
I'm not sure why, but I installed this hack to test it out, and as I tried to load attach.php my server load on a semi dedicated server wen't through the roof and stalled MySQL on my forums. I think something needs some optimization maybe. I saw it driving the loads through the roof on two servers today. It locks multiple queries in the mysql server for huge amounts of time. I restarted mysql on both of them to get them back to normal.

lalo landa
19 Nov 2002, 07:56
Originally posted by Larry@IOG
Database error in vBulletin 2.2.8:

Invalid SQL: SELECT COUNT(*) FROM attachment WHERE visible=1 AND private=0
mysql error: Unknown column 'private' in 'where clause'

mysql error number: 1054

Date: Monday 18th of November 2002 08:08:53 PM
Script: http://www.impulseownersgroup.com/vb/vb/attach.php
Referer:


Is what I am getting

Larry

The same to me.. :(
I need the another two hacks to make work this one?

I set to 0 the options, and use all te posibble combinations.. but don't work

Help please .. this hack looks SO Cool!

rake
19 Nov 2002, 14:47
Originally posted by Larry@IOG
Database error in vBulletin 2.2.8:

Invalid SQL: SELECT COUNT(*) FROM attachment WHERE visible=1 AND private=0
mysql error: Unknown column 'private' in 'where clause'

mysql error number: 1054

Date: Monday 18th of November 2002 08:08:53 PM
Script: http://www.impulseownersgroup.com/vb/vb/attach.php
Referer:


Is what I am getting

Larry
the answer is on the first page. A query needs to be replaced.
And FWC, would you mind running the script with explain=1 and posting the results? It might help finding the cause.

thenetbox
19 Nov 2002, 16:13
Hello..

I added the templates but as soon as I did that it got very very very slow...

Weird...

thenetbox
19 Nov 2002, 16:16
ok.. I removed the templates and everything became very fast again..

does VB have a template limit or something?

afterlab
19 Nov 2002, 21:55
You showed me this hack earlier, and I was amazed. Now, when releasing it, it will soon become a part of my own community. Thanks for the contribution.

joeboo
21 Nov 2002, 22:57
i love it rake, but, for some reason, it makes the whole damn server run so slow, especially that page O_o

Mike11212
22 Nov 2002, 19:49
beware if installing this hack
it works fine but causes your database to overload mines simply shutdown because of this and the server had to be restarted

!!!
22 Nov 2002, 20:10
Originally posted by Mike11212
beware if installing this hack
it works fine but causes your database to overload mines simply shutdown because of this and the server had to be restarted

Interesting...why would this hack do that?

SWFans.net
22 Nov 2002, 20:43
Originally posted by SWFans.net
I'm not sure why, but I installed this hack to test it out, and as I tried to load attach.php my server load on a semi dedicated server wen't through the roof and stalled MySQL on my forums. I think something needs some optimization maybe. Originally posted by FWC
I saw it driving the loads through the roof on two servers today. It locks multiple queries in the mysql server for huge amounts of time. I restarted mysql on both of them to get them back to normal. Originally posted by thenetbox
Hello..

I added the templates but as soon as I did that it got very very very slow...

Weird... Originally posted by Mike11212
beware if installing this hack
it works fine but causes your database to overload mines simply shutdown because of this and the server had to be restarted Don't know why, but I'm not alone in seeing it do that.

Mike11212
23 Nov 2002, 00:29
the server im on is dedicated p3 1ghz 1gb of ram
and when i executed attach.php
it worked but took about 3 minutes to load
hit the arrow for the next page and it wouldnt load server went down

LOD-squa
23 Nov 2002, 03:37
It loads fine for me o-O

lalo landa
23 Nov 2002, 07:24
Originally posted by rake
check for this line:

$getattach = $DB_site->query("SELECT attachment.attachmentid,attachment.userid,attachment.dateline,attachment.filenam e,attachment.visible ".iif($privattach,',attachment.private','').",attachment.counter,post.postid,post.threadid,thread.title,user.username FROM attachment LEFT JOIN post on attachment.attachmentid=post.attachmentid LEFT JOIN thread USING(threadid) LEFT JOIN user on attachment.userid=user.userid WHERE attachment.visible=1 AND post.attachmentid<>0 ".iif($privattach,'AND private=0','')." LIMIT $min,$perpage");


Please update the attached file... (still wrong)

rake
23 Nov 2002, 09:39
i've identified the problem. I'll release a patch soon. Sorry for the trouble everyone.

shovel
25 Nov 2002, 13:36
Great job Alex. It's great how you can both wow myself aswell as Eric. Lol.

- Anthony AKA CS

Erwin
25 Nov 2002, 21:01
!!!,


You are appearing as unlicensed.

To download hacks you will need to go to this (http://www.vbulletin.com/members/forums.php) page and enter your email address, to show you are licensed. (you will need to use your customer number and password to access that page)
Thank you.

Erwin
25 Nov 2002, 21:03
rake,

You are appearing as unlicensed. Get your admin to do the following:

To download hacks you will need to go to this (http://www.vbulletin.com/members/forums.php) page and enter your email address, to show you are licensed. (you will need to use your customer number and password to access that page)
Thank you.

corsacrazy
25 Nov 2002, 21:05
Originally posted by corsacrazy
wood there be a way to order the attactments by a value set in the attach.php file ie, order by filesize, number of times downloaded, or extension. ? ?


i would still like there to be an option to order the attactments by date or number of downloads etc , :cry: wood this b possible ? cheers

LanciaStratos
10 Feb 2003, 17:08
This just killed my dedicated server, unfortunately! Too bad, it had a lot of potential. :(

TLfuRy
12 Feb 2003, 15:20
I guess nothing ever got done as far as fixing the load issue. I just installed it, and it loaded a few times....30+ seconds processing time for each pageload. Now my server is down. :(

This is a great idea, and I think this functionality should be part of vB. It would be great to also have the ability to see if the thread still exists, and let you delete selected attachments. Viewing size would be great too.

Martin64
12 Feb 2003, 19:38
I tried this one as well, I had to shut down mysql because it was killing it. Perhaps it's selecting too many attachments? I have an attachment database of 400 MB so maybe that's what caused it, because when installing it locally it worked.

Good idea with the hack though. :)

kuska
26 Feb 2003, 06:45
Well im sure you had good intentions but i had to remowe this hack from my shared server and as ive been told all the people running this hack had to remove it.
I highly dont recommend installing this hack due to the server kill it creates. This is two emails i just recieved from my host http://www.f5hosting.com:


David,

You are running a hack file in your public_html folder called attach.php. That is horribly written code, complete garbage. It's got three JOIN's in it!! It's a total server killer. It could choke a dedicated server, much less a shared server. Please remove it. We can't allow it. It locks up mySQL for more than a minute at a time and drives the server load up by a factor of 5 or more. I had to get several sites to remove it, as did many other hosts, when it first came out. Thank you.

Michael


And after i removed the file this is the second email i recieved:





Thanks, David. It's not your fault. We all have to be careful what hacks we put on our vB's. Some of them are great, but a lot of them are really bad. This one may be the all time champion server killer, the piece of crap. Some kid wrote it, and didn't know what he was doing.

Michael


lol , not to be mean, i dont know nothing about writing hacks, but Michael totally burned you !!!! :)

Bison
26 Feb 2003, 13:12
No doubt ... the code is bad.

Better let someone revise this hack. It has great potential! :)

Tim Wheatley
29 Mar 2003, 22:25
*bump* :)

mtha
18 Apr 2003, 07:41
Cool hack

I would link thread to the post which has the attachment, using
showthread.php?s=$session[sessionhash]&postid=$att[postid]#post$att[postid]" , and open them in new window:



Template name: attachmentbit
Template:

<tr align="center">
<td bgcolor="#F1F1F1"><normalfont><img src="http://www.vbulletin.org/forum/vbimages/attach/$extension.gif" width="16" height="16" border="0" alt=""></normalfont></td>
<td bgcolor="#DFDFDF"><normalfont><a href="$link" target="_blank">$att[filename]</a></normalfont></td>
<td bgcolor="#F1F1F1"><normalfont><a href="member.php?s=$session[sessionhash]&action=getinfo&userid=$att[userid]" target="_blank">$att[username]</a></normalfont></td>
<td bgcolor="#DFDFDF"><normalfont>$att[counter]</normalfont></td>
<td bgcolor="#DFDFDF"><normalfont>$date</normalfont></td>
<td bgcolor="#DFDFDF" align="left"><normalfont><a href="showthread.php?s=$session[sessionhash]&postid=$att[postid]#post$att[postid] " target="_blank">$att[title]</a></normalfont></td>
</tr>



for big forum with many attachments, the script takes too long :((

rake
18 Apr 2003, 19:47
02-26-03 at 07:45 AM kuska said this in Post #45 (http://www.vbulletin.org/forum/showthread.php?postid=358553#post358553)
Well im sure you had good intentions but i had to remowe this hack from my shared server and as ive been told all the people running this hack had to remove it.
I highly dont recommend installing this hack due to the server kill it creates. This is two emails i just recieved from my host http://www.f5hosting.com:

And after i removed the file this is the second email i recieved:

lol , not to be mean, i dont know nothing about writing hacks, but Michael totally burned you !!!! :)

Well, at least he's right about my age, but you don't measure the speed of a query by the number of joins. I mean, wow! It's got three joins in it, it must be bad. Oh well, i shouldn't complain. It was my fault.

Here's the fix:
Run the following query:
ALTER TABLE `post` ADD INDEX ( `attachmentid` )

and replace attach.php with the attached file. Be sure to TEST IT.

Kars10
18 Apr 2003, 20:44
Can someone please test it? I have only my liveboard @ the moment but i need this hack! :)

Thanks in advance
Kars

Jitway
18 Apr 2003, 21:28
Works great! :D version 2.2.9

Kars10
19 Apr 2003, 13:59
@ Rake, theres a Bug.

Search for:

".iif($privattach,'AND priv=0','')."

replace it with:

".iif($privattach,'AND private=0','')."

Kars :)

rake
19 Apr 2003, 14:16
Thank Kars. I'll update the file. :)

Kars10
19 Apr 2003, 14:19
N/P.
I thank you for this Great Hack!

Kars:)

M.C.
19 Apr 2003, 15:57
Hi! is it possible to sort by date, username, thread and etc. (not only by downloads)?

Thanx

rake
19 Apr 2003, 20:43
Yes. Replace the attachment template with the one attached, and the re-updated attach.php file a couple of posts above and you'll get that extra functionality.

M.C.
19 Apr 2003, 21:18
rake, thanx a million! ;)

TheComputerGuy
21 Apr 2003, 13:40
Does this work properly without killing the server yet?

Kars10
21 Apr 2003, 13:43
@ TheComputerGuy, yes it works like a charm. :)

Kars

bandersen
26 Apr 2003, 12:04
Nice hack!

I am looking for a hack that will show only a certain type of files in the database (not the .jpg's). Can I use this hack then - and which one of the other hacks below do you recommend I use?


11-17-02 at 10:50 PM !!! said this in Post #7 (http://www.vbulletin.org/forum/showthread.php?postid=323135#post323135)
Private attachment? Attachment viewer?

rake
26 Apr 2003, 20:49
what do you want to restrict them to? it could easily be done.

bandersen
27 Apr 2003, 15:53
what if I wanted to restrict the database to show only .zip files....

rake
27 Apr 2003, 16:02
Under
===============
$extension = substr(strrchr($att[filename],"."),1);
Add
===============
if($extension!="zip") {
continue;
}

sajjid
13 May 2003, 00:20
i know this might be a newbie question but it will help me a lot i need the following info
i run forums with a host and have 10 Gig Transfer and 1 Gig space i also have access to mysql and space with my isp i like to link my images and attachments on that server to save bandwith i would be graet full if anyone can direct me in the right direction
many thanks in Advance

TLfuRy
15 May 2003, 15:52
Great job rake. With that added index it works great! I would love to have it show file size on the view page, but other than that it's great! :D

goyo
17 May 2003, 04:14
04-21-03 at 02:40 PM TheComputerGuy said this in Post #58 (http://www.vbulletin.org/forum/showthread.php?postid=385095#post385095)
Does this work properly without killing the server yet?
Nope it's kills my dedicated server.
I'm using only the updated files.
It took more than a minute to load the page

By the way my attachment database size is 2.6 GB...

Maybe attach.php don't like that fact ?

agfisdn
19 May 2003, 10:37
any news on this great hack?

it still has problems on my mysql server... load's too high ! :(

Attachment Usage: 210.04 MB

rake
19 May 2003, 17:02
Are you sure you ran the queries? The index is vital and drastically reduces load.

goyo
19 May 2003, 21:30
Today at 06:02 PM rake said this in Post #68 (http://www.vbulletin.org/forum/showthread.php?postid=397186#post397186)
Are you sure you ran the queries? The index is vital and drastically reduces load.

Yes I run them. In case you need it I can give you access to my server, but I think it's because the 2,6 GB attachment table...

Alien
30 May 2003, 20:01
So if you have a large attachment amount, this will still bring everything to a crawl? :)

Oblivion Knight
30 May 2003, 20:51
I love the concept of the hack, but I had no idea where to place a link to it..
It's an awkward thing to place since it's only really an archive and doesn't add any kind of functionality to the forums..

I placed it below my $logincode in the welcome panel for now.. ;)

Excellent work though!


[Edit]
There still seems to be an issue with the amount of MySQL load this requires.
I'm using the latest file and ran the query, but I came to the server this morning and it was running at snails pace. Also on the Microstats, the MySQL % had shot up from around an average of 50% to a whopping 95%+. Upon removal, both the speed and MySQL load statistic returned back to normal.

Anyone wanting to remove the query can use this:
ALTER TABLE `post` DROP INDEX ( `attachmentid` )

tkeil69575
14 Jul 2003, 08:54
hi rake,
nice hack. :)

however, there seems to be a small problem with the page link. if you klick on "last page" you come to e.g. page 55. the listing is blank. the previous 5 or 6 page also. any ideas?

tina

Steve123
31 Jul 2003, 23:27
Ive followed all the instructions..

It makes me server load jump to 100%...

gota have to uninstall.. o well it looked good :S

Steve123
31 Jul 2003, 23:34
ALTER TABLE `post` DROP INDEX ( `attachmentid` )

ERROR 1064: You have an error in your SQL syntax near '( `attachmentid` )' at line 1


;)

Oblivion Knight
01 Aug 2003, 07:34
Today at 12:34 AM Steve123 said this in Post #74 (http://www.vbulletin.org/forum/showthread.php?postid=422246#post422246)
ALTER TABLE `post` DROP INDEX ( `attachmentid` )

ERROR 1064: You have an error in your SQL syntax near '( `attachmentid` )' at line 1


;) There's nothing wrong with the syntax.. All it's doing is reversing the original query that was run.

Did the original query run successfully?
ALTER TABLE `post` ADD INDEX ( `attachmentid` )

gmarik
02 Aug 2003, 13:04
It's good to see it working now.

Johnny
07 Feb 2004, 14:37
can someone tell me how I can limit this so it displays attatcments from certain forums instead of all of them

350Chevy
22 Mar 2004, 18:11
Any updates on this that wont crash my server and have the options to manage the attachments (ie. delete...prun)?