Jul 05, 2009, 09:15 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1] 2 3 4   Go Down
  Print  
Author Topic: Support/Comments for FileDownloadPE  (Read 8658 times)
0 Members and 1 Guest are viewing this topic.
Dr. Scotty Delicious
Coding Team
*
Posts: 1,183


D.F.P.A.


WWW
« on: Jun 15, 2008, 11:10 PM »

This is an auto-generated support/comment thread for FileDownloadPE.

Use this forum to post any comments about this addition or any questions you have regarding its use.

Brief Description:
A secure file download snippet for MODx with download counting and access control.

For installation, usage, parameters, and examples see:
http://scottydelicious.com/blog/2008/06/15/filedownloadpe
« Last Edit: Jun 15, 2008, 11:13 PM by Dr. Scotty Delicious » Logged

davidm
MODx evangelist
Marketing & Design Team
*
Posts: 7,026


Software is like sex, it's better when it's free !


WWW
« Reply #1 on: Jun 16, 2008, 09:00 AM »

Wow great news, an improved version of FileDownload, secured at that... glad I run PHP5 to test this one out Grin

Thanks !
Logged

.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez ŕ l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accčs pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net
therebechips
Sr. Member
****
Posts: 305


« Reply #2 on: Jun 17, 2008, 04:14 AM »

This looks very elegant - I love the clean class structure -  but I have a few questions. Wouldn't it be better to use the document pagetitle as the filename? Having to repeat this in both the pagetitle, alias and FileName tv introduces redundancy, in my view. Also could the mimetype be determined automatically (ok I know this can be tricky)? Or alternatively you could use your snippet in the file template to redirect to the actual file thus obviating the need to send the Content-Type header.

Finally, I had been planning to rewrite FileDetails to provide the option of secure file storage in the database itself (the only way to get true security I reckon, since /assets/files/[filename] is going to be guessable) - but since you already have that extra table, would you consider doing this?

Cheers

Mark
Logged
Dr. Scotty Delicious
Coding Team
*
Posts: 1,183


D.F.P.A.


WWW
« Reply #3 on: Jun 17, 2008, 06:28 AM »

This looks very elegant - I love the clean class structure -  but I have a few questions. Wouldn't it be better to use the document pagetitle as the filename?
Brilliant! I love it. I will work on your other suggestions too, but this particular one seems so devastatingly obvious that I can't believe I didn't think of it.
<?php
$i 
0;
while( 
$i <= 1000 )
{
    echo 
'Thank You';
    
$i++;
}

// A thousand thank yous.
?>

Finally, I had been planning to rewrite FileDetails to provide the option of secure file storage in the database itself (the only way to get true security I reckon, since /assets/files/[filename] is going to be guessable) - but since you already have that extra table, would you consider doing this?

Cheers

Mark
That's a good Idea. I suppose it could be stored as a BLOB.

-sD-
Dr. Scotty Delicious, DFPA.
Logged

therebechips
Sr. Member
****
Posts: 305


« Reply #4 on: Jun 17, 2008, 06:59 AM »

You're very welcome!

For file upload/download BLOB can actually be problematic, but I worked out a way to do this reliably (on typical shared hosting) for large files a while ago, and explained it here (see therebechips):
http://uk.php.net/features.file-upload

Basically you split the file into chunks and encode them with base 64 (slight increase in file size but you get much better reliability from your db).

Mark
Logged
Dr. Scotty Delicious
Coding Team
*
Posts: 1,183


D.F.P.A.


WWW
« Reply #5 on: Jun 18, 2008, 08:20 AM »

UPDATED TO 1.1

FileName TV no longer required. Uses document's "alias" instead.
If FURLs are not enabled, this snippet will grab the alias from the "site_content" table using $_REQUEST['id']

Parameter &filename replaced with &id. For getting the number of downloads, simply specify document's id in this parameter.
For example: [!FileDownloadPE? &action=`count` &id=`36`!]

Auto-detecting mime type just won't work yet without a depreciated function "mime_content_type()" which is not installed on either of my servers, or the PECL "finfo" extension. Neither are reliably available on servers. I am looking forward to PHP 6.

Finally, I had been planning to rewrite FileDetails to provide the option of secure file storage in the database itself (the only way to get true security I reckon, since /assets/files/[filename] is going to be guessable) - but since you already have that extra table, would you consider doing this?

I don't have anything against storage in the database, but I totally disagree that the file path is going to be guessable.
First of all, there is no reason to set the alias to the name of the file. Secondly, If you use the MODx resource browser, you are slightly limited to /assets/files/, but you can use any number or name of sub folders. Upload your file to "/assets/downloads/current/projects/2008/" through the MODx resources browser and it is cleanly organized AND They can guess all day. If you want, obscure the folders a bit. Third, You are not limited to using the MODx Resource browser. Instead, FTP your files to "/home/your-username/public_html/private_files/" and put "private_files/myfile.zip" in the File TV.

-sD-
Dr. Scotty Delicious, DFPA.
Logged

therebechips
Sr. Member
****
Posts: 305


« Reply #6 on: Jun 19, 2008, 04:52 AM »

Hi Scotty,

looks good!

Fair point about the clean filepath - but at the end of the day security by obscurity is going to be a problem, if, say, you're doing stuff like selling software downloads. And most the the CMS admins I know could not be trusted to obscure the filename.

But in any case, this is an extremely well coded snippet and I will certainly be making use of it. Good work mate!
Logged
Dr. Scotty Delicious
Coding Team
*
Posts: 1,183


D.F.P.A.


WWW
« Reply #7 on: Jun 19, 2008, 08:33 AM »

Well, I like the challenge. It appeals to the pirate in me, so I am going to give db file storage a go.

-sD-
Dr. Scotty Delicious, DFPA.
Logged

rossco
Committed to MODx
*****
Posts: 849



WWW
« Reply #8 on: Jun 19, 2008, 10:10 AM »

Scotty, long time no see.

I have installed and have your snippet working... It's super duper! 

I have one problem...  I run a gaming site and would like to have the latest patches of games available to my members and so this means large zip files.  My host limits zip file sizes to 100mb if uploading to your webspace which I think is bs and I've just messaged them to say I think it's crazy since I'm paying for the service.  Anyway, I don't suppose there's a way to allow external links yet have the counter still work?

BTW I like your new site, looks excellent.  You nearly have as many tattoos as me  Tongue 

Ross
Logged

Dr. Scotty Delicious
Coding Team
*
Posts: 1,183


D.F.P.A.


WWW
« Reply #9 on: Jun 19, 2008, 05:43 PM »

Anyway, I don't suppose there's a way to allow external links yet have the counter still work?

Not with the way the code is currently written. Right now, it expects a path, but I suppose I could add a preg_match in there to check if the "File" TV contents starts with "http://". If it does, then use some logic to fopen and fread a remote file.

-sD-
Dr. Scotty Delicious, DFPA.
Logged

rossco
Committed to MODx
*****
Posts: 849



WWW
« Reply #10 on: Jun 20, 2008, 12:34 AM »

That would be cool for those who have files stored else where that would like to use the counter... 

I like the snippet how it's meant to work... works great.

Ross
Logged

Pikachu
Full Member
***
Posts: 137



WWW
« Reply #11 on: Jun 20, 2008, 04:25 AM »

I'm just curious about something (not directly related to the snippet). What does the "self::" bring compared to "this->" ?
Logged
Soshite
Committed to MODx
*****
Posts: 923



WWW
« Reply #12 on: Jun 20, 2008, 06:40 AM »

This requires to set up each download individually, right (unlike FileDownload, which grabs all of the files in a folder)?
Logged

My Snippets
-> PopUpChunk v1.0

Dr. Scotty Delicious
Coding Team
*
Posts: 1,183


D.F.P.A.


WWW
« Reply #13 on: Jun 20, 2008, 08:44 AM »

I'm just curious about something (not directly related to the snippet). What does the "self::" bring compared to "this->" ?
The class is static (it is never instantiated). When a class is static, "self::" is the way to access members, but more specifically, for static methods to access other static methods and properties.

This requires to set up each download individually, right (unlike FileDownload, which grabs all of the files in a folder)?
That is correct Soshite.

-sD-
Dr. Scotty Delicious, DFPA.
« Last Edit: Jun 20, 2008, 08:46 AM by Dr. Scotty Delicious » Logged

chinesedream
Sr. Member
****
Posts: 305


« Reply #14 on: Jul 13, 2008, 08:47 AM »

I followed every step, but when I tried to upload a file, it gives me this error:

Error, "Failed to upload file, internal error..."

What would be the possible cause?  The file upload browser is FCKEditor, I don't have it installed, and had turned the tinyMCE off. Does this matter?

Thanks!
« Last Edit: Jul 13, 2008, 08:53 AM by chinesedream » Logged
Pages: [1] 2 3 4   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!