Firefox PHP

mod: upload attachments in directory, not db

Posted by dissurion 
Re: The Hack
March 03, 2006 09:19AM
Quote
miles
Sure, here it is. Modified code starts at line 2502, and is bracketed by an if ($USE_FS_ATTACHMENTS=true) {} statement. I left the original code in the else{} branch mainly for reference.

Also, I warn you that I ripped bunch of client-specific stuff out and haven't tested the hack since, which is why I'm posting it informally here and not in the hacks forum.

Thanks a lot! I will look at your alternative approach :-)

P.



Edited 1 time(s). Last edit at 03/05/2006 05:52AM by pcoud.
Re: The Hack
March 05, 2006 05:17PM
Works very fine :-)
Just some minor points: in phorum_db_file_save, the generation of a temporary filename (in case $dest would be empty?) seems strange (but I may miss something in the understanding). I replaced:

file_put_contents($dest = tempnam('/tmp', 'db_file_save'), base64_decode($buffer));

by:

file_put_contents($dest, base64_decode($buffer));

Also, when the attachments are stored in fs, there are useless base64 encoding/decoding which are taking place. They could be removed (at the cost of not being completely transparent to the code depending on the database layer).

It is nice in your approach to be able to upgrade phorum 3 attachments to phorum 5, keeping them in FS storage.

By the way, there is minor copy&paste typo in the comment of mysql.php (both in the original phorum code and your modified version):

/**
* This function saves a file to the db
*/

should be "deletes" instead of "saves"

P.



Edited 1 time(s). Last edit at 03/05/2006 05:18PM by pcoud.
Re: The Hack
March 05, 2006 05:32PM
Quote
pcoud
Just some minor points: in phorum_db_file_save, the generation of a temporary filename (in case $dest would be empty?) seems strange (but I may miss something in the understanding).

You were right to replace it. In my original code, I was assuming the upload to be an image, generating multiple resized versions of it, and throwing away the original. The temporary filename is a leftover from that.
Re: mod: upload attachments in directory, not db
April 20, 2006 05:44PM
Could we have a conclusion on this mod? latest version? Any instruction to support thumbnails and display the first attachment thumbnails with each message title?
Thanks
Re: mod: upload attachments in directory, not db
August 15, 2006 06:29PM
Two issues mainly:

A) When I delete the file from the forum this module does not delete accordingly the file which is stored in the attachments directory.

B) This module could have been comfortable to me if it allowed a larger file size then the one pre-fixed in the forum's settings.

Any way to overcome to this issue?

Thanks...
Re: mod: upload attachments in directory, not db
August 16, 2006 04:21AM
Just make the limit bigger in Phorum admin?

---
-=[ Panu ]=-
Re: mod: upload attachments in directory, not db
August 16, 2006 09:13AM
Sorry it says 613.8KB even if I put raise the limit to 2000000. I did that in the General Settings and on the Forum Settings. Did I miss something perhaps?



Edited 1 time(s). Last edit at 08/16/2006 09:17AM by nicola.
Re: mod: upload attachments in directory, not db
August 16, 2006 09:32AM
That is the limit that is imposed by either the PHP max upload configuration or the database's maximum package size configuration. Looking at the limit, I think it's the database package size limit.

I do not know the internals of this mod. If it stores the file in the database, prior to storing it on the system, then this limit should be honoured. If this is not the case, the limit could be ignored. Ignoring it is no core feature however. You'd need to hack the Phorum code a bit for that. I think that all you need to do is edit your database layer file (include/db/<layername>.php) and let the function phorum_db_maxpacketsize() return NULL at all cases.

If after this, you run into another limiting problem, it's the configuration of PHP which limits the upload size.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: mod: upload attachments in directory, not db
October 18, 2006 04:07AM
What's the status of this module?

To me it seems that the best thing would be to build this functionality into the main phorum code, but that's what you want to do, is it?

f



Edited 1 time(s). Last edit at 10/18/2006 04:08AM by feffemannen.
Re: mod: upload attachments in directory, not db
October 18, 2006 05:34AM
We do not want to build it in the main Phorum code, but there are plans for facilitating implementation of different storage backends. Maybe through hooks or maybe through having a storage layer. At this moment, there are so many development tasks to do, that I do not think plans have fully settled on this.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Sorry, only registered users may post in this forum.

Click here to login