Code Search for Developers
 
 
  

get_attachment.html from AlphaMail at Krugle


Show get_attachment.html syntax highlighted

% # vim: set syntax=mason:
<%args>
$file => -1
$type => -1
$subtype => -1
$suggested_name => -1
</%args>
<%init>
my $user;
my $prefix;
my $username;

eval {
   $user = Apache2::SiteControl->getCurrentUser($r);
   $prefix = $config->getScratchDir($user);
   $username = $user->getUsername();
};
if($@) {
   $logger->error("Unable to get attachment: $@");
   $m->redirect(build_url("$base/mail/index.html", { message => "Request failed" }));
}

$file =~ s/\\/\\\\/g; # Un-escape escapes

if($file == -1) {
   $m->redirect(build_url("$base/mail/index.html", { message => "No filename for attachment." }));
} elsif($file =~ m!(^|/)\.\./!) {
   $logger->error("Security Violation! $username attempted to view $file. Prefix was $prefix");
   $m->redirect(build_url("$base/mail/index.html", { message => "Security violation on filename $file" }));
}

$file = "$prefix/$file"; # Full path to tmp file.

$logger->debug("Getting attachment $file ($type/$subtype)");

$r->content_type("$type/$subtype");
$r->headers_out()->set('Content-Disposition' => qq(attachment; filename="$suggested_name"));

$file =~ s!//!/!g; # get rid of double /
if(!open(DATA, "<$file")) {
   # We probably renewed an old session (see bug 425)...force them to re-click
   # on the message.
   $m->redirect(build_url("$base/mail/index.html", { message => "Please try again (decoded attachment was cleaned up due to session inactivity). If it fails again then contact support." }));
}
my $line;
while($line = <DATA>) {
   $m->print($line);
}
close DATA;

# Just in case a timeout occured...we don't want renew_session causing another
# download. [Bug 412]
$user->setAttribute($r, 'intended_dest', "$base/mail/index.html");
$user->setAttribute($r, 'intended_args', [ ]);
</%init>
<%once>
use AlphaMail::HTMLHelper qw(build_url);
our $logger = Log::Log4perl->get_logger('alphamail');
our $base = $config->get('base_uri');
</%once>




See more files for this project here

AlphaMail

AlphaMail is an accelerated web mail interface with a C++ middleware layer that is more effective than an IMAP proxy which is a highly scalable (10k+ users). The interface includes modern features, Section 508 compliance, and universal browser support.

Project homepage: http://sourceforge.net/projects/alphamail
Programming language(s): C++,Java,JavaScript,Perl
License: other

  addressbook/
    edit.mhtml
    import.mhtml
    import_complete.html
    import_csv.html
    import_csv_save.html
    import_fname.html
    import_imho.html
    import_lname.html
    index.html
    lists.mhtml
    process_edit.html
    process_lists.html
    process_take.html
    take.html
  admin/
    autohandler
    index.html
    show_stats.mhtml
    test.mhtml
  docs/
    faq/
      colors.gif
      dates1.gif
      drafts.gif
      filter.gif
      general.html
      index.html
      notrash1.gif
      notrash2.gif
      notrash3.gif
      other.html
      sort.gif
      timeout.gif
    new_features.html
  settings/
    add_filter.html
    altfolder_update.html
    altprefix_update.html
    edit_folders.html
    export.mhtml
    export_mail.html
    filters.mhtml
    folders.mhtml
    general.mhtml
    index.html
    share.mhtml
    sharing_agree.html
    signatures.mhtml
    update_folderlist.html
    update_general.html
    update_signatures.html
  viewers/
    excel.html
    html.html
    targz.html
    text.html
    word.html
    zip.html
  address_mail.html
  addresslist.html
  autohandler
  check_spelling.html
  compose.html
  feedback.html
  first_login.html
  fix_spelling.html
  folderlist.mhtml
  footer.mhtml
  get_attachment.html
  header.mhtml
  help.html
  index.html
  logout.html
  menu.mhtml
  other_folders.html
  process_compose.html
  process_first_login.html
  process_messages.html
  process_read_message.html
  process_search.html
  quota.html
  quota_graph.html
  raw.html
  read.html
  remove_attachment.html
  renew_session.html
  resume_compose.html
  sanitized.html
  share_options.html
  share_upload.html
  verify_password.html
  view_attachment.html