]> git.p6c8.net - devedit.git/commitdiff
Allow to execute a HTTP download of a file
authorpcanterino <>
Tue, 29 Dec 2009 12:52:03 +0000 (12:52 +0000)
committerpcanterino <>
Tue, 29 Dec 2009 12:52:03 +0000 (12:52 +0000)
errors.conf
modules/Command.pm
templates/dirlist_file.htm
templates/viewfile.htm

index 535793664594c6086f7e6af0252a4123891a8aee..244501ff0b2b4405f566b5d4bea241bce80b5f97 100644 (file)
@@ -33,6 +33,7 @@ no_copy           = You have not enough permissions to copy this file.
 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_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.
 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.
index cc996ca233c27a5fcf04999034b2aa7c5292ce6c..8fcf6d6f35b575a851bdd90a40edddc4537b7b83 100644 (file)
@@ -6,7 +6,7 @@ package Command;
 # Execute Dev-Editor's commands
 #
 # Author:        Patrick Canterino <patrick@patshaping.de>
 # 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
 #
 # Copyright (C) 1999-2000 Roland Bluethgen, Frank Schoenmann
 # Copyright (C) 2003-2009 Patrick Canterino
@@ -42,6 +42,7 @@ my $users  = eval('getpwuid(0)') && eval('getgrgid(0)');
 my %dispatch = ('show'         => \&exec_show,
                 'beginedit'    => \&exec_beginedit,
                 'endedit'      => \&exec_endedit,
 my %dispatch = ('show'         => \&exec_show,
                 'beginedit'    => \&exec_beginedit,
                 'endedit'      => \&exec_endedit,
+                'download'     => \&exec_download,
                 'mkdir'        => \&exec_mkdir,
                 'mkfile'       => \&exec_mkfile,
                 'upload'       => \&exec_upload,
                 'mkdir'        => \&exec_mkdir,
                 'mkfile'       => \&exec_mkfile,
                 'upload'       => \&exec_upload,
@@ -444,6 +445,32 @@ sub exec_endedit($$)
  return devedit_reload({command => 'beginedit', file => $virtual});
 }
 
  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
 # exec_mkfile()
 #
 # Create a file and return to directory view
index fd342fea3c7df2a5d06460b59f4940843b1bd763..5b9b734b82c4d5de83052f102821de88febb5123 100644 (file)
@@ -3,5 +3,5 @@
 <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 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&amp;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&amp;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&amp;file={FILE_URL}">Copy</a>{ENDIF}{ENDIF}{IF dir_writeable} | <a href="{SCRIPT}?command=rename&amp;file={FILE_URL}">Rename</a> | <a href="{SCRIPT}?command=remove&amp;file={FILE_URL}">Delete</a>{ENDIF} |{IF !link}{IF users} <a href="{SCRIPT}?command=chprop&amp;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&amp;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&amp;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&amp;file={FILE_URL}">Copy</a>{ENDIF}{ENDIF}{IF dir_writeable} | <a href="{SCRIPT}?command=rename&amp;file={FILE_URL}">Rename</a> | <a href="{SCRIPT}?command=remove&amp;file={FILE_URL}">Delete</a>{ENDIF} |{IF !link}{IF users} <a href="{SCRIPT}?command=chprop&amp;file={FILE_URL}">Chmod/Chgrp</a> |{ENDIF}{ENDIF} {ENDIF}<a href="{URL}" target="_blank">View in Browser</a>)</td>
 </tr>
 </tr>
index 4aaf594e4ee3307bfa6bdc058f6faefa809a5dc5..7303f1fe1b7c4627560e2721e5d5a9d286720b27 100644 (file)
 </pre>
 </div>
 
 </pre>
 </div>
 
-{IF editable}<p><a href="{SCRIPT}?command=beginedit&amp;file={FILE_URL}">Edit this file</a></p>{ELSE}<br>{ENDIF}
+<ul>
+<li><a href="{SCRIPT}?command=download&amp;file={FILE_URL}">Download this file</a></li>{IF editable}
+<li><a href="{SCRIPT}?command=beginedit&amp;file={FILE_URL}">Edit this file</a></li>{ENDIF}
+</ul>
 
 <hr>
 
 
 <hr>
 

patrick-canterino.de