Version: 1.00, by s.molinari
Developer Last Online: Sep 2018
Version: 2.3.x
Rating:
Released: 02-23-2003
Last Update: Never
Installs: 12
No support by the author.
Hi vB Troopers,
*****************
* Hack Idea:
*****************
This hack is designed to improve 2 things:
1. Prevent duplicate attachments altogether.
2. Speed up the query for duplicates and avoid errors.
What does vB do now?
---------------------------------
If you have "Allow Duplicate Images" set to "No" in your attachments options and your database has a very large amount of attachments, at worst, the server will timeout or the query to check for duplicate attachments takes an extreme amount of time. The duplicates query also checks only for duplicates from a particular user so actually it is possible to have duplicate attachments in the database.
What does vB do differently after the hack?
------------------------
With the hack installed, each attachment receives a hash which is stored in the attachment table. This hash is then used to find duplicate attachments regardless of whether or not the attachment is from the same user or not. So duplicate attachments are not possible.
Why vB works faster with this hack?
------------------------------------
Since the hash field and not the actual file content is being compared, then much less server resources are needed for MySql to run the query. Also the hash field is indexed. This in turn speeds up the saving of the attachments when checking for duplicates.
Please be aware that this hack alters the database and when carried out incorrectly, could cause data loss. Installation is at your own risk.
That said, enjoy!
Scott
This hack was written by pogo.
Also note, a system similiar to this will be part of vB3, so no need to ask if it will be added.
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
After you last message, I tested mine to make sure it works. It works fine here, although I did notice something with it. If you have 2 messages with the same attachment in it, once you delete one of the messages, the other message no longer has an attachment hooked to it.
I hope this is the last bug
Scott will update the hackfile when he is online but you can do this:
In admin/functions.php find
PHP Code:
AND threadid<>'$postinfo[threadid]'
in function deletepost().
Delete it or copy it in a comment line.
Then open editpost.php and find
PHP Code:
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
updatethreadcount($threadinfo[threadid]);
replace it with
PHP Code:
$otherattachs=$DB_site->query("SELECT attachmentid FROM post WHERE attachmentid=$postinfo[attachmentid]");
if ($DB_site->num_rows($otherattachs)==1) {
$DB_site->query("DELETE FROM attachment WHERE attachmentid=$postinfo[attachmentid]");
updatethreadcount($threadinfo[threadid]);
}
If you find other inconsistencies, please tell me.
Thanks for the fix. I will test it out. Also, can you please put the English version in the first post after Scott updates it? The German version is there now.
seem to be having a new problem
god i suck at doing this
sorry guys
anyway hope u can help
what it is now is, the site is running fine, speed is ok, queries ran ok(i think) but when i try 2 attach something my message appers
but no attachment appears and no error message
any ideas?