no_delete         = You have not enough permissions to delete this file.
 no_dir_access     = You have not enough permissions to access this directory.
 no_directory      = '{FILE}' is not a directory.
+no_download       = You are not allowed to download '{FILE}'.
 no_edit           = You have not enough permissions to edit this file.
 no_rename         = You have not enough permissions to move/rename this file.
 no_root_access    = You have not enough permissions to access the root directory.
 
 # Execute Dev-Editor's commands
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
-# Last modified: 2005-05-11
+# Last modified: 2009-12-29
 #
 # Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann
 # Copyright (C) 2003-2009 Patrick Canterino
 my %dispatch = ('show'         => \&exec_show,
                 'beginedit'    => \&exec_beginedit,
                 'endedit'      => \&exec_endedit,
+                'download'     => \&exec_download,
                 'mkdir'        => \&exec_mkdir,
                 'mkfile'       => \&exec_mkfile,
                 'upload'       => \&exec_upload,
  return devedit_reload({command => 'beginedit', file => $virtual});
 }
 
+# exec_download()
+#
+# Execute a HTTP download of a file
+#
+# Params: 1. Reference to user input hash
+#         2. Reference to config hash
+#
+# Return: Output of the command (Scalar Reference)
+
+sub exec_download($$)
+{
+ my ($data,$config) = @_;
+ my $physical       = $data->{'physical'};
+ my $virtual        = $data->{'virtual'};
+ my $dir            = upper_path($virtual);
+
+ return return error($config->{'errors'}->{'no_download'},$dir,{FILE => $virtual}) if(-d $physical || -l $physical);
+
+ my $filename = file_name($virtual);
+
+ my $output = header(-type => 'application/octet-stream', -attachment => $filename);
+ $output   .= ${ file_read($physical,1) };
+
+ return \$output;
+}
+
 # exec_mkfile()
 #
 # Create a file and return to directory view
 
 <td align="right" style="white-space:nowrap">{SIZE}</td>
 <td style="padding-left:15pt;white-space:nowrap;">{DATE}{IF gmt} (GMT){ENDIF}</td>
 <td style="padding-left:15pt;white-space:nowrap;">{IF forbidden}<span style="color:#C0C0C0" title="File access forbidden by Dev-Editor's configuration">{FILE_NAME}</span>{ELSE}{FILE_NAME}{ENDIF}</td>
-<td style="padding-left:15pt;white-space:nowrap;">({IF !forbidden}{IF viewable}<a href="{SCRIPT}?command=show&file={FILE_URL}">View</a>{ELSE}<span style="color:#C0C0C0" title="{IF !readable}Not readable{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{ENDIF}{ENDIF}">View</span>{ENDIF} | {IF editable}<a href="{SCRIPT}?command=beginedit&file={FILE_URL}">Edit</a>{ELSE}<span style="color:#C0C0C0" title="{IF link}Symbolic link{ELSE}{IF !readable}Not readable{ELSE}{IF !writeable}Read only{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{ENDIF}{ENDIF}{ENDIF}{ENDIF}">Edit</span>{ENDIF}{IF !link}{IF readable} | <a href="{SCRIPT}?command=copy&file={FILE_URL}">Copy</a>{ENDIF}{ENDIF}{IF dir_writeable} | <a href="{SCRIPT}?command=rename&file={FILE_URL}">Rename</a> | <a href="{SCRIPT}?command=remove&file={FILE_URL}">Delete</a>{ENDIF} |{IF !link}{IF users} <a href="{SCRIPT}?command=chprop&file={FILE_URL}">Chmod/Chgrp</a> |{ENDIF}{ENDIF} {ENDIF}<a href="{URL}" target="_blank">View in Browser</a>)</td>
+<td style="padding-left:15pt;white-space:nowrap;">({IF !forbidden}{IF viewable}<a href="{SCRIPT}?command=show&file={FILE_URL}">View</a>{ELSE}<span style="color:#C0C0C0" title="{IF !readable}Not readable{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{ENDIF}{ENDIF}">View</span>{ENDIF} | {IF editable}<a href="{SCRIPT}?command=beginedit&file={FILE_URL}">Edit</a>{ELSE}<span style="color:#C0C0C0" title="{IF link}Symbolic link{ELSE}{IF !readable}Not readable{ELSE}{IF !writeable}Read only{ELSE}{IF binary}Binary file{ELSE}{IF too_large}File too large{ENDIF}{ENDIF}{ENDIF}{ENDIF}{ENDIF}">Edit</span>{ENDIF}{IF !link}{IF readable}| <a href="{SCRIPT}?command=download&file={FILE_URL}">Download</a> | <a href="{SCRIPT}?command=copy&file={FILE_URL}">Copy</a>{ENDIF}{ENDIF}{IF dir_writeable} | <a href="{SCRIPT}?command=rename&file={FILE_URL}">Rename</a> | <a href="{SCRIPT}?command=remove&file={FILE_URL}">Delete</a>{ENDIF} |{IF !link}{IF users} <a href="{SCRIPT}?command=chprop&file={FILE_URL}">Chmod/Chgrp</a> |{ENDIF}{ENDIF} {ENDIF}<a href="{URL}" target="_blank">View in Browser</a>)</td>
 </tr>