PDA

View Full Version : Attachment Database


rake
11-16-2002, 10:00 PM
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
11-17-2002, 06:19 PM
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
11-17-2002, 06:21 PM
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
11-17-2002, 06:37 PM
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
11-17-2002, 06:46 PM
damn im getting this error
Database error in vBulletin 2.2.8:

Invalid SQL: SELECT attachment.attachmentid,attachment.userid,attachme nt.dateline,attachment.filename,attachment.visible ,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 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
11-17-2002, 06:47 PM
I'm using the attachments as files hack, is this compatabul with it?

!!!
11-17-2002, 06:50 PM
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
11-17-2002, 06:52 PM
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
11-17-2002, 06:58 PM
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
11-17-2002, 07:03 PM
same error :(

rake
11-17-2002, 07:16 PM
check for this line:

$getattach = $DB_site->query("SELECT attachment.attachmentid,attachment.userid,attachme nt.dateline,attachment.filenam e,attachment.visible ".iif($privattach,',attachment.private','').",attachment.counter,post.postid,pos t.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
11-17-2002, 07:17 PM
mine says

$getattach = $DB_site->query("SELECT attachment.attachmentid,attachment.userid,attachme nt.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
11-17-2002, 07:19 PM
replace it with the one i posted above and it will work.

corsacrazy
11-17-2002, 07:19 PM
i replaced my code with the one you said and its working now , thanks alot ;)

Velocd
11-17-2002, 07:31 PM
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 ;)

Dean C
11-17-2002, 07:32 PM
Thats pretty damn cool...

- miSt

corsacrazy
11-17-2002, 07:55 PM
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
11-17-2002, 11:59 PM
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
11-18-2002, 06:28 AM
Very cool Hack, great! thx

Bison
11-18-2002, 10:36 AM
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
11-18-2002, 12:15 PM
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
11-19-2002, 12:17 AM
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
11-19-2002, 04:15 AM
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
11-19-2002, 06:50 AM
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
11-19-2002, 06:56 AM
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
11-19-2002, 01:47 PM
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
11-19-2002, 03:13 PM
Hello..

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

Weird...

thenetbox
11-19-2002, 03:16 PM
ok.. I removed the templates and everything became very fast again..

does VB have a template limit or something?

afterlab
11-19-2002, 08:55 PM
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
11-21-2002, 09:57 PM
i love it rake, but, for some reason, it makes the whole damn server run so slow, especially that page O_o

Mike11212
11-22-2002, 06:49 PM
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

!!!
11-22-2002, 07:10 PM
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
11-22-2002, 07:43 PM
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
11-22-2002, 11:29 PM
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
11-23-2002, 02:37 AM
It loads fine for me o-O

lalo landa
11-23-2002, 06:24 AM
Originally posted by rake
check for this line:

$getattach = $DB_site->query("SELECT attachment.attachmentid,attachment.userid,attachme nt.dateline,attachment.filename,attachment.visible ".iif($privattach,',attachment.private','').",attachment.counter,post.postid,post.threadid,thre ad.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
11-23-2002, 08:39 AM
i've identified the problem. I'll release a patch soon. Sorry for the trouble everyone.

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

- Anthony AKA CS

Erwin
11-25-2002, 08:01 PM
!!!,


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
11-25-2002, 08:03 PM
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
11-25-2002, 08:05 PM
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
02-10-2003, 04:08 PM
This just killed my dedicated server, unfortunately! Too bad, it had a lot of potential. :(

TLfuRy
02-12-2003, 02:20 PM
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
02-12-2003, 06:38 PM
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
02-26-2003, 05:45 AM
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
02-26-2003, 12:12 PM
No doubt ... the code is bad.

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

Tim Wheatley
03-29-2003, 09:25 PM
*bump* :)

mtha
04-18-2003, 06:41 AM
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="https://vborg.vbsupport.ru/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
04-18-2003, 06:47 PM
02-26-03 at 07:45 AM kuska said this in Post #45 (https://vborg.vbsupport.ru/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
04-18-2003, 07:44 PM
Can someone please test it? I have only my liveboard @ the moment but i need this hack! :)

Thanks in advance
Kars

Jitway
04-18-2003, 08:28 PM
Works great! :D version 2.2.9

Kars10
04-19-2003, 12:59 PM
@ Rake, theres a Bug.

Search for:

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

replace it with:

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

Kars :)

rake
04-19-2003, 01:16 PM
Thank Kars. I'll update the file. :)

Kars10
04-19-2003, 01:19 PM
N/P.
I thank you for this Great Hack!

Kars:)

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

Thanx

rake
04-19-2003, 07:43 PM
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.
04-19-2003, 08:18 PM
rake, thanx a million! ;)

TheComputerGuy
04-21-2003, 12:40 PM
Does this work properly without killing the server yet?

Kars10
04-21-2003, 12:43 PM
@ TheComputerGuy, yes it works like a charm. :)

Kars

bandersen
04-26-2003, 11:04 AM
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 (https://vborg.vbsupport.ru/showthread.php?postid=323135#post323135)
Private attachment? Attachment viewer?

rake
04-26-2003, 07:49 PM
what do you want to restrict them to? it could easily be done.

bandersen
04-27-2003, 02:53 PM
what if I wanted to restrict the database to show only .zip files....

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

sajjid
05-12-2003, 11:20 PM
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
05-15-2003, 02:52 PM
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
05-17-2003, 03:14 AM
04-21-03 at 02:40 PM TheComputerGuy said this in Post #58 (https://vborg.vbsupport.ru/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
05-19-2003, 09:37 AM
any news on this great hack?

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

Attachment Usage: 210.04 MB

rake
05-19-2003, 04:02 PM
Are you sure you ran the queries? The index is vital and drastically reduces load.

goyo
05-19-2003, 08:30 PM
Today at 06:02 PM rake said this in Post #68 (https://vborg.vbsupport.ru/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
05-30-2003, 07:01 PM
So if you have a large attachment amount, this will still bring everything to a crawl? :)

Oblivion Knight
05-30-2003, 07:51 PM
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
07-14-2003, 07:54 AM
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
07-31-2003, 10:27 PM
Ive followed all the instructions..

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

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

Steve123
07-31-2003, 10:34 PM
ALTER TABLE `post` DROP INDEX ( `attachmentid` )

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


;)

Oblivion Knight
08-01-2003, 06:34 AM
Today at 12:34 AM Steve123 said this in Post #74 (https://vborg.vbsupport.ru/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
08-02-2003, 12:04 PM
It's good to see it working now.

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

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