<![CDATA[ Support/Comments for FileDownloadPE - My Forums]]> https://forums.modx.com/thread/?thread=38433 <![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218890 where can i find Documentation to FileDownloadPE ?

P.S. here is NO any docs http://scottydelicious.com/blog/2008/06/15/filedownloadpe]]>
Wild Striker Dec 04, 2010, 06:02 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218890
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218889 sottwell Jul 07, 2010, 02:34 AM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218889 <![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218888 Quote from: MediaGuy at Jan 11, 2010, 10:20 AM

Just to let you guys know: I changed "return" to "exit" and now my custom snippet is working, I think the same would work with the original FiledownloadPE!

yes it does. You saved me a lot of heart ache thanks smiley
Copy paste of original code with that simple exit change on download section
<?php
/**
 * @package FileDownloadPE (Pirate Edition)
 * @copyright 2008 MODx CMS/F Community.
 * @license GPL v3 <http://www.gnu.org/licenses/gpl.html>
 * @link http://scottydelicious.com/blog/2008/06/15/filedownloadpe
 * @version 1.1 <2008.18.06 : June 18th 2006>
 * @since 1.0 <2008.15.06 : June 15th 2006>
 * @category PHP 5 Only. Requires PHP5 <http://gophp5.org/>
 * @author Dr. Scotty Delicious, DFPA <[email protected]>
 */

//  Set default snippet parameters.
$_table     = 'downloads';
$filename   = isset($filename)  ? $filename : null;
$dberror    = isset($dberror)   ? $dberror  : 'There was an error processing your download request.';
$nofile     = isset($nofile)    ? $nofile   : 'No file specified.';

// Defaults for Template Variables:
$alias = $_REQUEST['q'];
if (!$alias) $alias = Download::GetAlias($_REQUEST['id']);
$fileMimeTV = isset($fileMimeTV) ? $fileMimeTV : 'FileMime';
$filePathTV = isset($filePathTV) ? $filePathTV : 'File';

// Get download count for requested document.
if ($action == 'count')
{
	$filename = isset($filename) ? $filename : Download::GetAlias($id);
    return Download::Count($filename, $_table, $dberror, $nofile);
}

// Download the requested file.
$mime       = $modx->getTemplateVarOutput($fileMimeTV);
$mime       = $mime[$fileMimeTV];
$file       = $modx->getTemplateVarOutput($filePathTV);
$file       = $modx->config['base_path'] . $file[$filePathTV];

return Download::File($alias, $file, $mime, $_table, $dberror, $nofile);

class Download
{
    private static $error = '';
    private static $nofile = '';
    private static $table = '';
    private static $filename = '';
    
    public static function File($filename, $path, $mime, $table, $dberror, $nofile)
    {
        global $modx;
        self::$table = $modx->getFullTableName($table);
        self::$filename = $filename;
        self::$error = $dberror;
        self::$nofile = $nofile;
        
        $check = self::_tableCheck($table);
        if (!$check) return self::$error;
        
        $info = self::_getInfo();
        if (!$info) return self::$error;
        
        if(is_file($path))  
        {  
            $count = ($info['count'] + 1);
            $update = $modx->db->update("`count`=$count", self::$table, "`name`='$filename'");

            // required for IE  
            if(ini_get('zlib.output_compression')) { ini_set('zlib.output_compression', 'Off'); }

            header('Pragma: public');
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');  
            header('Cache-Control: private',false);  
            header('Content-Type: '.$mime);  
            header('Content-Disposition: attachment; filename="'.basename($path).'"');  
            header('Content-Transfer-Encoding: binary');  
            header('Content-Length: '.filesize($path));
            readfile($path);
            exit;
        }
        else
        {
            return self::$error;
        }
    }
    
    public static function Count($filename, $table, $dberror, $nofile)
    {
        if (!$filename) return $nofile;
        global $modx;
        self::$table = $modx->getFullTableName($table);
        self::$filename = $filename;
        self::$error = $dberror;
        self::$nofile = $nofile;
        
        $check = self::_tableCheck($table);
        if (!$check) return self::$error;
        
        $info = self::_getInfo();
        if (!$info) return self::$error;
        else return $info['count'];
    }

	public static function GetAlias($id = 0)
	{
		global $modx;
		if (!$id) return false;
		$site_content = $modx->getFullTableName('site_content');
		$document = $modx->db->select('alias', $site_content, "`id` = $id");
		$alias = $modx->db->getRow($document);
		return $alias['alias'];
	}
    
    private static function _getInfo()
    {
        global $modx;
        $search = $modx->db->select('*', self::$table, "`name` = '" .self::$filename. "'");

        if ( $modx->db->getRecordCount($search) == 0 )
        {
            $insert = array('name' => self::$filename, 'count' => 0);
            if (!$modx->db->insert($insert, self::$table)) return false;
            $search = $modx->db->select('*', self::$table, "`name` = '" .self::$filename. "'");
        }
        $info = $modx->db->getRow($search);
        return $info;
    }
    
    private static function _tableCheck($tablename)
    {
        global $modx;
        $prefix = $modx->db->config['table_prefix'];
        $check = "SHOW TABLES LIKE '" . $prefix . $tablename . "'";
        $result = $modx->db->query($check);
        $recordCount = $modx->db->getRecordCount($result);
        if ($modx->db->getRecordCount($result) == 0)
        {
            $sql = "CREATE TABLE `" . $prefix . "downloads` (
              `id` int(11) NOT NULL auto_increment,
              `name` varchar(128) NOT NULL default '',
              `count` int(11) NOT NULL default '0',
              PRIMARY KEY  (`id`),
              KEY `name` (`name`)
            )";
            if ( !$modx->db->query($sql) ) return false;
            else $recordCount = 1;
        }
        return $recordCount;
    }
}
?>

This works! laugh]]>
shazzed Jul 06, 2010, 10:30 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218888
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218887 Quote from: OnTarget600 at May 27, 2010, 06:21 AM

I am still having a major issue however of all large files getting corrupted on download.

Anybody? I still cannot resolve this issue.

Thanks.]]>
OnTarget600 Jun 16, 2010, 06:07 AM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218887
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218886
I am still having a major issue however of all large files getting corrupted on download. All the files that I will be serving are over 50MB so this is a major issue for me.

Unlike the standard FiledownloadPE the file is the correct size just broken.

Any ideas??

Thanks.]]>
OnTarget600 May 27, 2010, 01:21 AM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218886
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218885 Server issue not snippit issue

Hello,

I have setup the snippet as posted by mediaguy as the original script doesn’t play well with large files.
Unfortunately I am getting the following error:

Fatal error: Class ’Download’ not found in /srv/www/htdocs/mysitename/manager/includes/document.parser.class.inc.php(770) : eval()’d code on line 6.

I assume it is related to these lines (6&7) of the snippet.
$alias = $_REQUEST['q'];
if (!$alias) $alias = Download::GetAlias($_REQUEST['id']);


I am running modx v. 1.0.3

Any help would be greatly appreciated.]]>
OnTarget600 May 25, 2010, 09:51 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=10#dis-post-218885
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218884
i make this change:
Quote from: abyssalplain at Nov 11, 2008, 11:05 AM

Another issue I noticed is that the download counter only works properly if the download link page is placed in the root, and it won’t count properly downloads of the same file from different pages, and doesn’t work with friendly alias paths too well.

I fixed it, replace this part which starts on line 25:

// Get download count for requested document.
if ($action == 'count')
{
	$filename = isset($filename) ? $filename : Download::GetAlias($id);
	
	if ($modx->config['friendly_urls'] && $modx->config['friendly_alias_urls']) 
	{
		$_pIds = $modx->getParentIds($id);

		foreach($_pIds as $pId) 
		{
			$_alias = Download::GetAlias($pId);
			$_aliaspath[] = (!$_alias) ? $pId : $_alias;
		}
		$filename = implode("/",$_aliaspath)."/".$filename;
	}
	
    return Download::Count($filename, $_table, $dberror, $nofile);
}


Not sure if this project / thread is dead, if not then I can fix all the issues and submit it as the next version.

cheers

Jonny


and i get:
« MODx Parse Error »

MODx encountered the following error while attempting to parse the requested resource:
« PHP Parse Error »
 
PHP error debug
  Error:	implode() [function.implode]: Bad arguments.	 
  Error type/ Nr.:	Warning - 2	 
  File:	/var/www/vhosts/domain.net/httpdocs/manager/includes/document.parser.class.inc.php(773) : eval()'d code	 
  Line:	38	 
 
Parser timing
  MySQL:	0.0889 s	(35 Requests)
  PHP:	0.1053 s	 
  Total:	0.1942 s	 


have you time to fix errors and make next release?]]>
lastoftheromans Apr 17, 2010, 06:34 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218884
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218883
Onto expiring links. Looks like there’s something called dp4tc that’s been submitted ...
MattC]]>
mconsidine Mar 08, 2010, 05:26 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218883
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218882
What I get downloaded instead of the file is a bit of next, specifically, the call to the snippet from the "Downloads" template. I.e. [ !FileDownloadPE! ]

I am assuming I’ve done something boneheaded. To try to rectify this myself I replaced the snippet code as per messages #83 and #85 but again, no luck.

Can anyone point out what I am likely doing wrong?

Also, does anyone know of any mods to the snippet to make the download link expire after a certain amount of time? If there are other solutions to all this (namely providing an ability to download a file, which I hope to tie into a Shopkeeper-like solution) I’d be grateful.

TIA,
MattC]]>
mconsidine Mar 08, 2010, 04:38 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218882
<![CDATA[Re: Support/Comments for FileDownloadPE]]> https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218881
I’d like to report that so far, it seems I am not experiencing the issues that I expressed in earlier posts of mine. I tried out what Media Guy suggested in post #83 and #85 (being the most important). I made a duplicate of my FileDownloadPE snippet as to not disturb the original. I completely replaced the existing PHP code with what Media Guy listed in post #83. I then made the change on the third to last line, as he explained in post #85.

I’ve been testing out my existing download link documents and the ones that have been showing problems before making the code change seem to be operating now as they should. I am no longer getting errors when downloading and opening PDF documents.

Additionally, I’d like to mention that in the original installation instructions written by Scotty Delicious, he tells you to select "text/plain" for ’Internet Media Type’ under ’Settings’ when creating/editing your download document. I noticed that while using version Evolution 1.0.2 (I was previously using Evolution 0.9.6.3), if you select "application/pdf" instead of "text/plain", the tree will display an Acrobat-like icon for the document. If you offer different file formats for download, it would be nice to quickly see what format each document is. I was worried this would affect the operation. In testing, it hasn’t seem to change the operation any. Try it out for yourself.]]>
thomasgrant Jan 29, 2010, 12:15 PM https://forums.modx.com/thread/38433/support-comments-for-filedownloadpe?page=9#dis-post-218881