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.
Originally posted by pogo The chances that you want to upload a file that has the same hash like a file that is already in the database are 1:340.000.000.000.000.000.000.000.000.000.000.000. 000
That means you have to upload this many files before the "bug" will occur. Theoretically.
Damn! I'm getting close. I better watch this.
By the way, how would you enter that equation on a calculator?
*gg*
my calculator can handle exponental operations, so i can just type in 3.4 exp 38
ok, it's not a MS calculator, but one i bought for scholl long time ago
PHP supports one error control operator: the at sign (@). When prepended to an expression in PHP, any error messages that might be generated by that expression will be ignored.
how would i go about removing this hack
after installing it, my forum has been going very very slow
how do i remove these queries?
-------------------------------------------------------------------------------
ALTER TABLE attachment ADD hash VARCHAR(32) DEFAULT '0' NOT NULL;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
UPDATE attachment SET hash = md5(filedata);
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
ALTER TABLE attachment ADD INDEX(hash);
-------------------------------------------------------------------------------