%#============================================================================ %# ePortal - WEB Based daily organizer %# Author - S.Rusakov %# %# Copyright (c) 2001 Sergey Rusakov. All rights reserved. %# This program is free software; you can redistribute it %# and/or modify it under the same terms as Perl itself. %# %# $Revision: 3.1 $ %# $Date: 2003/04/24 05:36:52 $ %# $Header: /home/cvsroot/ePortal/comp_root/catalog/download.htm,v 3.1 2003/04/24 05:36:52 ras Exp $ %# %#---------------------------------------------------------------------------- %# Parameters: %# link - ID of ePortal::Catalog object to download %# todisk - true to force "Save as" dialog %#---------------------------------------------------------------------------- <& /message.mc &> %#=== @metags onStartRequest ==================================================== <%method onStartRequest><%perl> my $link = $ARGS{link}; if ( $link ) { my $c = new ePortal::Catalog; if ( $c->restore($link) ) { # Determine mime type my $subr = $r->lookup_uri('/' . escape_uri($c->filename)); my $content_type = $subr ? $subr->content_type : undef; $content_type = "application/octet-stream" unless $content_type; logline('notice', "Downloading file ", $c->Filename, " as ", $content_type); # Take the file $m->clear_buffer; $r->content_type($content_type); $r->header_out("Content-Disposition" => "attachment; filename=".$c->Filename) if ( $ARGS{todisk} ); $r->header_out( "Content-Length" => length($c->Text) ); $r->send_http_header; $m->print($c->Text); $m->abort; return; } else { $session{ErrorMessage} = pick_lang( rus => "Óêàçàííûé ðåñóðñ íå íàéäåí", eng => "Resource not found"); } }