Code Search for Developers
 
 
  

view_attachment.html from AlphaMail at Krugle


Show view_attachment.html syntax highlighted

% # vim: set syntax=mason:
<%args>
$file
$type
$subtype
$mode => "normal"
</%args>
<%init>
my $user = Apache::SiteControl->getCurrentUser($r);
my $logger = Log::Log4perl->get_logger('alphamail');
my $sandbox = $config->get("sandbox_util");
my $sandbox_dir = $config->get("sandbox");
my $jpegtopnm = $config->get("jpegtopnm");
my $pnmtojpeg = $config->get("pnmtojpeg");
my $pnmscale = $config->get("pnmscale");
my $giftopnm = $config->get("giftopnm");
my $tifftopnm = $config->get("tifftopnm");
my $pngtopnm = $config->get("pnmtopnm");
my $iconsize = $config->get("iconsize");
my $prefix = $config->get("message_tmpdir", '/tmp') . "/" .  
             $user->getAttribute('imap') .  "_" . $user->getUsername();
my $username = $user->getUsername();

if($file !~ m/^\Q$prefix\E\/msg[-\d]*\/[^\/]*$/i || $file =~ m!/\.\./!) {
   $logger->logcroak("Security Violation! $username attempted to view $file. Prefix was $prefix");
}

#my $name = $file;
#$name =~ s!^.*/([^/]+)$!$1!;
#my $sandbox_loc = "$sandbox_dir/tmp/$name";
# Put it in the sandbox
#link $file, $sandbox_loc or $logger->error("Unable to move file to sandbox");

$subtype = lc($subtype);
$subtype = "tiff" if $subtype eq 'tif';

my $line;
my %converters = ( jpeg => $jpegtopnm,
                   gif => $giftopnm,
                   tiff => $tifftopnm,
                   png => $pngtopnm,
                   pnm => "cat" # FIXME
                 );
my $converter = $converters{$subtype};
$logger->debug("Running in $mode mode with $type/$subtype");
if($mode eq "shrink" && $type eq "image" && $converter) {
   $r->content_type("$type/$subtype");
   $logger->debug("tring to convert using: $sandbox $converter < '$file' | $sandbox $pnmscale -ysize $iconsize | $sandbox $pnmtojpeg|");
   # The redirection happens before sandbox runs. That is OK, since the fds are
   # passed along for the ride...no need to use the tmp dir in sandbox.
   open DATA, "$sandbox $converter < '$file' | $sandbox $pnmscale -ysize $iconsize | $sandbox $pnmtojpeg|" or $logger->error("problem running: $sandbox $converter < $file | $sandbox $pnmscale -ysize $iconsize | $sandbox $pnmtojpeg|");
   while($line = <DATA>) {
      $m->print($line);
   }
   close DATA;
} elsif($type eq "image" && $converter && $subtype =~ m/^(tiff|png)$/) {
   # Convert to better format for browser
   $r->content_type("$type/jpeg");
   open DATA, "$sandbox $converter < $file | $sandbox $pnmtojpeg|" or $logger->error("problem converting file: $sandbox $converter < $file | $sandbox $pnmtojpeg|");
   while($line = <DATA>) {
      $m->print($line);
   }
   close DATA;
} else {
   $r->content_type("$type/$subtype");
   open DATA, "<$file" or $logger->error("No such file: $file");
   while($line = <DATA>) {
      $m->print($line);
   }
   close DATA;
}
</%init>




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_alias.html
    import_complete.html
    import_csv.html
    import_csv_save.html
    import_fname.html
    import_imho.html
    import_lname.html
    index.html
    process_edit.html
    take.html
  settings/
    altfolder_update.html
    edit_folders.html
    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
    word.html
    zip.html
  address_mail.html
  addresslist.mhtml
  autohandler
  check_spelling.html
  compose.html
  filevault.html
  first_login.html
  fix_spelling.html
  folderlist.mhtml
  footer.mhtml
  get_attachment.html
  header.mhtml
  index.html
  logout.html
  menu.mhtml
  other_folders.html
  print.html
  process_compose.html
  process_first_login.html
  process_messages.html
  read.html
  remove_attachment.html
  renew_session.html
  share_options.html
  share_upload.html
  verify_password.html
  view_attachment.html