#============================================================ # ViewFileInformation #============================================================ package ViewFileInformation; use Common; @ISA = qw(Common); #公開したいサブルーチン #@EXPORT = qw(erfc tan); @EXPORT_OK = qw(); use strict; use Archive::Zip; use Template; #========================================== # 大域変数 #========================================== #============================================================ # コンストラクタ、デストラクタ #============================================================ sub new { my ($module) = @_; my $this = {}; bless $this; # $this->SUPER::new(@_); return $this; } sub DESTROY { my $this = shift; $this->SUPER::DESTROY(@_); } #============================================================ # メンバー関数 #============================================================ sub ViewSnippetFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); my %type = ( c => 'c', cpp => 'cpp', csharp => 'csharp', flex => 'flex', html => 'html', htm => 'html', java => 'java', js => 'javascript', pl => 'perl', pm => 'perl', py => 'phython', rb => 'ruby', sql => 'sql', mysql => 'sql', xml => 'xml', ); my ($drive, $directory, $filename, $ext, $lastdir, $filebody) = Deps::SplitFilePath($Path); $ext =~ s/^\.//; my $sc = $type{lc $ext}; return 0 if(!$sc); $App->H3("Information for [$Path] ($sc)"); print < EOT my $content = JFile->new()->ReadFile($Path); # if($sc eq 'html' or $sc eq 'xml') { Utils::InvalidateHTMLTags($content); # } print < $content EOT2 return 1; } sub ViewInformation { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); return if($this->ViewSnippetFile($App, $pParams, $Path)); if($Path =~ /\.(jpe?g|gif|bmp|pdf)$/i) { return $this->ViewImageFile($App, $pParams, $Path); } elsif($Path =~ /\.(pm|pl)$/i) { return $this->ViewDetailPerlLibrary($App, $pParams, $Path); } # elsif($Path =~ /\.(html?|mht)$/i) { elsif($Path =~ /\.(html?)$/i) { return $this->ViewHTMLFile($App, $pParams, $Path); } elsif($Path =~ /\.(mht)$/i) { return $this->ViewMHTFile($App, $pParams, $Path); } elsif($Path =~ /\.(alm)$/i) { return $this->ViewALMailMailFile($App, $pParams, $Path); } elsif($Path =~ /\.adr$/i) { return $this->ViewALMailAddressBookByTable($App, $pParams, $Path); # return $this->ViewTextFile($App, $pParams, $Path); } elsif($Path =~ /\.csv$/i) { return $this->ViewCSVFileByTable($App, $pParams, $Path); } elsif($Path =~ /\.zip$/i) { return $this->ViewZIPFileContent($App, $pParams, $Path); } elsif($Path =~ /\.wma$/i) { return $this->ViewDetailWMAFile($App, $pParams, $Path); } elsif($Path =~ /\.mp3$/i) { return $this->ViewDetailMP3File($App, $pParams, $Path); } elsif($Path =~ /\.(ini|cfg|config|te?xt|lst|out|wiki|template|mysql|bat|csh|bsh|sh|pl|pm)$/i) { return $this->ViewTextFile($App, $pParams, $Path); } # $App->H3("Invalid music data: [$Path]"); return 0; } sub ViewZIPFileContent { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); Utils::URLDecode($Path); $Path =~ s/^file:\/\///i; if($Path !~ /\.zip$/i) { $App->H3("Invalid zip file: [$pParams->{Path}]"); return 0; } $App->H2("Details: [$Path]\n"); my $zip = Archive::Zip->new( $Path); return 0 if(!$zip); my $comment = $zip->zipfileComment(); $App->PrintRawHTML("Comment: $comment
\n") if($comment ne ''); my $nMember = $zip->numberOfMembers(); $App->PrintRawHTML("# of files: $nMember
\n"); my @files = $zip->members(); # my @files = $zip->memberNames(); if(@files > 0) { $App->BeginTable(1); $App->BeginTableHeader(); $App->BeginTableRow(); $App->TableCell("File name"); $App->TableCell("Time stamp"); $App->TableCell("File size (kB)"); $App->TableCell("Compressed size (kB)"); $App->EndTableRow(); $App->EndTableHeader(); $App->BeginTableBody(); for(my $i = 0 ; $i < @files ; $i++) { $App->BeginTableRow(); $App->TableCell($files[$i]->fileName() . "\n"); # $App->TableCell($files[$i]->externalFileName() . "\n"); $App->TableCell(Utils::BuildDateString($files[$i]->lastModFileDateTime()) . "\n"); $App->TableCell(sprintf("==>%.2f", $files[$i]->uncompressedSize() /1024) . "\n"); $App->TableCell(sprintf("==>%.2f", $files[$i]->compressedSize() / 1024) . "\n"); $App->EndTableRow(); } $App->EndTableBody(); $App->BeginTable(1); } return 1; } sub ViewDetailPerlLibrary { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); Utils::URLDecode($Path); $Path =~ s/^file:\/\///i; if($Path !~ /\.(pm|pl)$/i) { $App->H3("Invalid pm/pl file: [$pParams->{Path}]"); return 0; } $App->H2("Details: [$Path]\n"); my $s = JFile->new()->ReadFile($Path); $s = Utils::ConvertToHTMLString($s, 1); $s =~ s/(&\w+);/q\($1:semicolon\)/mg; $s =~ s/\t/    /g; $s =~ s/^(sub\s+\w+)/$1<\/font><\/b>/mg; $s =~ s/^(\s*(my|our|local)\s+.+?);/$1;<\/font><\/b>/mg; $s =~ s/q\((&\w+):semicolon\)/$1;/mg; $App->PrintRawHTML($s); return 1; } sub ViewDetailWMAFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); Utils::URLDecode($Path); $Path =~ s/^file:\/\///i; if($Path !~ /\.wma$/i) { $App->H3("Invalid wma file: [$Path]"); return 0; } $App->H3("Information for [$Path] (Windows Media Audio)"); use Audio::WMA; my %inf; my $wma = Audio::WMA->new($Path); my $info = $wma->info(); my $tags = $wma->tags(); my $flags = $info->{flags}; $App->H3("Info\n"); foreach my $key (sort keys %$info) { next if($key =~ /^(flags)$/); #Jcode::convert(\$info->{$key}, $pParams->{WebCharCode}, 'sjis'); $App->PrintRawHTML("$key: $info->{$key}
\n"); } $App->H3("Tags\n"); foreach my $key (sort keys %$tags) { #Jcode::convert(\$info->{$key}, $pParams->{WebCharCode}, 'sjis'); #$info->{$key} .= ' '; $App->PrintRawHTML("$key: $tags->{$key}
\n"); } $App->H3("Flags\n"); foreach my $key (sort keys %$flags) { #Jcode::convert(\$info->{$key}, $pParams->{WebCharCode}, 'sjis'); $App->PrintRawHTML("$key: $flags->{$key}
\n"); } return 1; } sub ViewDetailMP3File { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.mp3/i) { $App->H3("Invalid mp3 file: [$Path]"); return 0; } $App->H3("Information for [$Path] (MP3)"); use MP3::Info; my $tags = get_mp3tag($Path); my $info = get_mp3info($Path); $App->PrintRawHTML("Length: $info->{MM}:$info->{SS}
\n"); $App->H3("Info\n"); foreach my $key (sort keys %$info) { #Jcode::convert(\$info->{$key}, 'sjis');#, 'utf-8'); $App->PrintRawHTML("$key: $info->{$key}
\n"); } $App->H3("Tags\n"); foreach my $key (sort keys %$tags) { #Jcode::convert(\$info->{$key}, 'sjis');#, 'utf-8'); $App->PrintRawHTML("$key: $tags->{$key}
\n"); } return 1; } sub ViewHTMLFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.html?$/i) { $App->H3("Invalid HTML file: [$Path]"); return 0; } $App->H3("Information for [$Path] (HTML)"); my $content = JFile->new()->ReadFile($Path); $content =~ s/^(.*?)\]*\>//si; $content =~ s/\<\/body[^\>]*\>.*$//si; if($content) { # $App->print($content); $App->PrintRawHTML($content); } return 1; } sub ViewMHTFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.(mht)$/i) { $App->H3("Invalid MHT HTML file: [$Path]"); return 0; } my $in = new JFile($Path, 'r'); if(!$in) { $App->H2("Error in ViewFileInformation::ViewALMailMailFile: Can not read [$Path]\n"); return 0; } my $c = 0; while(1) { my $line = $in->ReadLine(); last if(!defined $line); if($c == 0 and $line =~ /^From:/i) { $in->Close(); return $this->ViewMHTFile2($App, $pParams, $Path); } $App->print($line); # $App->PrintRawHTML($line); $c++; } $in->Close(); return 1; } sub ViewMHTFile2 { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.(mht)$/i) { $App->H3("Invalid MHT file: [$Path]"); return 0; } my $mf = new MailFile; my $pTextArray = $mf->Read($Path, 0); if(!$pTextArray) { $App->H2("Error: Can not read [$Path]\n"); return 0; } my $Header = $mf->GetHeader(); # my $Content = $mf->GetContent(); my $Content = $mf->GetMailBoy(); # my $Content = $mf->GetFullContent(); my $psp = $mf->{pSerialPartsInf}; my $nParts = @$psp; my $DecodedContent = $mf->DecodeContent($pParams->{WebCharCode}, 1); #$code, $RemoveHeader); my $From = $mf->GetHeaderFromString("From"); $From = $mf->DecodeSubject($From, $pParams->{WebCharCode}); my ($EMail, $Name) = $mf->SplitEMailAddress($From); my $Name = $EMail if($Name eq ''); my $Date = $mf->GetHeaderFromString("Date"); my ($DayOfWeek, $DayOfMonth, $Month, $Year, $hour, $min, $sec, $TimeDifference) = $mf->SplitDate($Date); $Month = $mf->GetMonthFromName($Month); my $To = $mf->GetHeaderFromString("To"); my $Subject = $mf->GetHeaderFromString("Subject"); $Subject = $mf->DecodeSubject($Subject, $pParams->{WebCharCode}); $Subject = "no title" if($Subject eq ''); $App->H3("Information for [$Path] (ALMail Mail file)"); # $App->PrintRawHTML("

\n"); # $App->print("$Header\n"); # $App->PrintRawHTML("

\n"); my $text; #$App->print("nParts=$nParts\n"); for(my $i = 0 ; $i < $nParts ; $i++) { my $p = $psp->[$i]; $text = ''; if(defined $p->{Subject}) { $text = $p->{Subject}; $text = $mf->DecodeSubject($text); } elsif($p->{ContentType} =~ /text\//i) { $p->ReadHeader("sjis", 0, $p->{Content}); # $p->GetMultipartInfoFromString("sjis", $p->{Content}); my $s = ($p->{Subject})? $p->{Subject} : $this->{pMail}->{Subject}; $s = $mf->DecodeSubject($s); my $f = ($p->{From})? $p->{From} : $this->{pMail}->{From}; $f = $mf->DecodeSubject($f); my $CT = $p->{ContentType}; $CT = (defined $CT)? $CT : ''; $text = "$s: $f [$CT]"; } elsif(defined $p->{ContentType}) { $text = $p->{ContentType}; $text =~ s/\s*;\s*name=.*$//i; $text =~ s/\s*;\s*file=.*$//i; if(defined $p->{FileName}) { my $f = $p->{FileName}; Jcode::convert(\$f, "sjis"); $text = "$text [$f]"; } if(defined $p->{ContentTransferEncoding}) { $text = "$text [$p->{ContentTransferEncoding}]"; } } #$App->print("$i: [$text]\n"); my ($pHeader, $pContent) = $mf->SplitHeaderFromString($p->{Content}); my $Header = join('', @$pHeader); my $content = join('', @$pContent); my $ContentTransferEncoding = $p->GetHeaderFromString("Content-Transfer-Encoding", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); if($ContentTransferEncoding) { $content = $mf->DecodeContent($pParams->{WebCharCode}, 1, undef, $content, $ContentTransferEncoding); } my $From = $p->GetHeaderFromString("From", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); $From = $mf->DecodeSubject($From, $pParams->{WebCharCode}); my $To = $p->GetHeaderFromString("To", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); $To = $mf->DecodeSubject($To, $pParams->{WebCharCode}); my $Date = $p->GetHeaderFromString("Date", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); my $Subject = $p->GetHeaderFromString("Subject", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); $Subject = $mf->DecodeSubject($Subject, $pParams->{WebCharCode}); my $ContentType = $p->GetHeaderFromString("Content-Type", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); my $ContentDisposition = $p->GetHeaderFromString("Content-Disposition", $pParams->{WebCharCode}, 0, $pHeader); if($ContentType =~ /(application|stream)/i) { # $App->PrintRawHTML("

\n"); # $App->print("$Header\n"); # $App->PrintRawHTML("

\n"); # my $filename = $mf->GetAttachedFileName($pHeader, $pParams->{WebCharCode}); # my $header = "Attached file [$filename]"; # $App->PrintRawHTML("

\n"); # $header .= " ({DownloadFileLink}&iAttachedFile=$i&Path=$Path\" target=\"_blank\">download)\n"; # $App->PrintRawHTML("$header\n"); } elsif($ContentType =~ /(image)/i) { } elsif($ContentType =~ /(text\/css)/i) { } else { # $App->PrintRawHTML("

\n"); # $App->print("$Header\n"); # $App->PrintRawHTML("

\n"); $content =~ s/^.*?\]*\>//sig; $content =~ s/\<\/body[^\>]*\>.*?$//sig; if($ContentType =~ /html/i) { $App->PrintRawHTML("

\n"); $App->PrintRawHTML("$content\n"); # $App->print("$content\n"); } elsif($ContentType =~ /text/i) { $App->PrintRawHTML("

\n"); $App->print("$content\n"); } else { $App->print("$content\n"); } } $App->PrintRawHTML("

\n"); } } sub ViewALMailMailFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.(alm)$/i) { $App->H3("Invalid ALMail Mail file: [$Path]"); return 0; } my $mf = new MailFile; my $pTextArray = $mf->Read($Path, 0); if(!$pTextArray) { $App->H2("Error: Can not read [$Path]\n"); return 0; } my $Header = $mf->GetHeader(); # my $Content = $mf->GetContent(); my $Content = $mf->GetMailBoy(); # my $Content = $mf->GetFullContent(); my $psp = $mf->{pSerialPartsInf}; my $nParts = @$psp; my $ShowLine = ($nParts <= 1)? 1 : 2; print < .ui-accordion { font-family: times; width: 100%; } .ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 0px; zoom: 1; } .ui-accordion .ui-accordion-li-fix { display: inline; } .ui-accordion .ui-accordion-header { font-family: times; font-size: 50%; border-bottom: 0 !important; } .ui-accordion .ui-accordion-header-active { font-family: times; font-size: 50%; border-bottom: 0 !important; } .ui-accordion .ui-accordion-header a { display: block; font-family: times; font-size: 50%; padding: 0em 0em 0em 0em; } .ui-accordion-icons .ui-accordion-header a { padding-left: 0.5em; } .ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } .ui-accordion .ui-accordion-content { font-family: times; font-size: 50%; padding: 1em 1em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; } .ui-accordion .ui-accordion-content-active { display: block; } EOT my $DecodedContent = $mf->DecodeContent($pParams->{WebCharCode}, 1); #$code, $RemoveHeader); my $From = $mf->GetHeaderFromString("From"); $From = $mf->DecodeSubject($From, $pParams->{WebCharCode}); my ($EMail, $Name) = $mf->SplitEMailAddress($From); my $Name = $EMail if($Name eq ''); my $Date = $mf->GetHeaderFromString("Date"); my ($DayOfWeek, $DayOfMonth, $Month, $Year, $hour, $min, $sec, $TimeDifference) = $mf->SplitDate($Date); $Month = $mf->GetMonthFromName($Month); my $To = $mf->GetHeaderFromString("To"); my $Subject = $mf->GetHeaderFromString("Subject"); $Subject = $mf->DecodeSubject($Subject, $pParams->{WebCharCode}); $Subject = "no title" if($Subject eq ''); $App->H3("Information for [$Path] (ALMail Mail file)"); $App->PrintRawHTML("
\n"); $App->PrintRawHTML("

From: $From
Date: $Date
Subject: $Subject

\n"); $App->PrintRawHTML("

\n"); $App->print("$Header\n"); $App->PrintRawHTML("

\n"); my $text; #$App->print("nParts=$nParts\n"); if($nParts <= 1) { my $header = substr($DecodedContent, 0, 100); $header =~ s/[\s\r\n]+/ /sg; Utils::DelSpace($header); $header = 'Content' if($header eq ''); $App->PrintRawHTML("

$header

\n"); $App->PrintRawHTML("

\n"); $App->print("$DecodedContent\n"); $App->PrintRawHTML("

\n"); } else { for(my $i = 0 ; $i < $nParts ; $i++) { my $p = $psp->[$i]; $text = ''; if(defined $p->{Subject}) { $text = $p->{Subject}; $text = $mf->DecodeSubject($text); } elsif($p->{ContentType} =~ /text\//i) { $p->ReadHeader("sjis", 0, $p->{Content}); # $p->GetMultipartInfoFromString("sjis", $p->{Content}); my $s = ($p->{Subject})? $p->{Subject} : $this->{pMail}->{Subject}; $s = $mf->DecodeSubject($s); my $f = ($p->{From})? $p->{From} : $this->{pMail}->{From}; $f = $mf->DecodeSubject($f); my $CT = $p->{ContentType}; $CT = (defined $CT)? $CT : ''; $text = "$s: $f [$CT]"; } elsif(defined $p->{ContentType}) { $text = $p->{ContentType}; $text =~ s/\s*;\s*name=.*$//i; $text =~ s/\s*;\s*file=.*$//i; if(defined $p->{FileName}) { my $f = $p->{FileName}; Jcode::convert(\$f, "sjis"); $text = "$text [$f]"; } if(defined $p->{ContentTransferEncoding}) { $text = "$text [$p->{ContentTransferEncoding}]"; } } #$App->print("$i: [$text]\n"); my ($pHeader, $pContent) = $mf->SplitHeaderFromString($p->{Content}); my $Header = join('', @$pHeader); my $content = join('', @$pContent); my $ContentTransferEncoding = $p->GetHeaderFromString("Content-Transfer-Encoding", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); if($ContentTransferEncoding) { $content = $mf->DecodeContent($pParams->{WebCharCode}, 1, undef, $content, $ContentTransferEncoding); } my $From = $p->GetHeaderFromString("From", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); $From = $mf->DecodeSubject($From, $pParams->{WebCharCode}); my $To = $p->GetHeaderFromString("To", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); $To = $mf->DecodeSubject($To, $pParams->{WebCharCode}); my $Date = $p->GetHeaderFromString("Date", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); my $Subject = $p->GetHeaderFromString("Subject", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); $Subject = $mf->DecodeSubject($Subject, $pParams->{WebCharCode}); my $ContentType = $p->GetHeaderFromString("Content-Type", $pParams->{WebCharCode}, 0, $pHeader); #, $p->{Content}); my $ContentDisposition = $p->GetHeaderFromString("Content-Disposition", $pParams->{WebCharCode}, 0, $pHeader); $App->PrintRawHTML("

"); if($ContentType =~ /application/i or $ContentType =~ /stream/i) { $App->PrintRawHTML("[$i] Content-Type: $ContentType [$ContentTransferEncoding]"); $App->PrintRawHTML("
Content-Disposition: $ContentDisposition") if($ContentDisposition ne ''); } else { # $Subject =~ /\<[^\>]*\>.*?\<\/[^\>]*\>/sig; # $Subject =~ /\]*\>.*?\<\/img[^\>]*\>/sig; $App->PrintRawHTML("[$i] Subject: $Subject"); $App->PrintRawHTML("
From: $From") if($From ne ''); $App->PrintRawHTML("
Date: $Date") if($Date ne ''); $App->PrintRawHTML("
Content-Type: $ContentType [$ContentTransferEncoding]") if($ContentType ne ''); } $App->PrintRawHTML("

\n"); $App->PrintRawHTML("

\n"); $App->print("$Header\n"); $App->PrintRawHTML("

\n"); if($ContentType =~ /application/i or $ContentType =~ /stream/i) { my $filename = $mf->GetAttachedFileName($pHeader, $pParams->{WebCharCode}); my $header = "Attached file [$filename]"; $App->PrintRawHTML("

$header

\n"); $App->PrintRawHTML("

\n"); $header .= " ({DownloadFileLink}&iAttachedFile=$i&Path=$Path\" target=\"_blank\">download)\n"; $App->PrintRawHTML("$header\n"); } else { if($ContentType =~ /html/i) { my $header = $content; $header =~ s/\<[^\>]+\>//sg; $header = substr($header, 0, 100); $header =~ s/ / /sig; Utils::DelSpace($header); $header = 'Content' if($header eq ''); #$App->print("h[$header]\n"); $App->PrintRawHTML("

$header

\n"); $App->PrintRawHTML("

\n"); # $content =~ /\<[^\>]*\>.*?\<\/[^\>]*\>/sig; # $content =~ /\]*\>.*?\<\/img[^\>]*\>/sig; if($pParams->{Mode} eq 'HTML') { $App->PrintRawHTML("$content\n"); } else { $App->PrintRawHTML("{ViewHTMLBaseLink}&iAttachedFile=$i&Path=$Path\" target=\"_blank\">View HTML
\n"); $App->print("$content\n"); } } elsif($ContentType =~ /text/i) { my $header = substr($content, 0, 100); $header =~ s/[\s\r\n]+/ /sg; Utils::DelSpace($header); $header = 'Content' if($header eq ''); #$App->print("h[$header]\n"); $App->PrintRawHTML("

$header

\n"); $App->PrintRawHTML("

\n"); $App->print("$content\n"); } else { # $App->print("$content\n"); } } $App->PrintRawHTML("

\n"); # Content => $Parts[$i], # From => $From, # To => $To, # Cc => $Cc, # Bcc => $Bcc, # ContentType => $ContentType, # ContentTransferEncoding => $ContentTransferEncoding, # ContentDisposition => $ContentDisposition, # CharSet => $CharSet, # Boundary => $Boundary2, # FileName => $AttachFileName, } } $App->PrintRawHTML("
\n"); } sub ViewTextFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); $App->H3("Information for [$Path] (TEXT)"); my $content = JFile->new()->ReadFile($Path); if($content) { $App->print($content); } return 1; } sub ViewALMailAddressBookByTable { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.adr$/i) { $App->H3("Invalid ALMail AddressBook file: [$Path]"); return 0; } $App->H3("Information for [$Path] (CSV)"); my $MultiFunctionTableJScript = JSParams->new()->GetMultiFunctionalTableString('.TableTest3'); #, sortList => '[[1,1]]', excludeColumns => '[2,3]'); my %MultiFunctionTableConfigByClass = ( class => 'tablesorter' ); # $App->print($MultiFunctionTableJScript); $App->PrintRawHTML($MultiFunctionTableJScript); my $in = new JFile; if(!$in->Open($Path, 'r')) { $App->H2("Error: Can not read [$Path]: $!.\n"); return 0; } $App->BeginTable(1, undef, %MultiFunctionTableConfigByClass); $App->BeginTableHeader(); $App->BeginTableRow(); $App->TableCell('Group', undef, undef, undef, undef, 0); $App->TableCell('Name', undef, undef, undef, undef, 0); $App->TableCell('EMailName', undef, undef, undef, undef, 0); $App->EndTableRow(); $App->EndTableHeader(); $App->BeginTableBody(); my $Group = ''; while(1) { my $line = $in->ReadLine(); last if(!defined $line); Utils::DelSpace($line); #$App->print("l[$line]\n"); if($line =~ /^Group\s+(.*)$/i) { $Group = $1; next; } elsif($line =~ /^End\s+Group/i) { next; } elsif($line eq '') { next; } my ($name, $addr) = ($line =~ /^(.*?)\s*:\s*(.*)$/); # next if(!defined $addr); $App->BeginTableRow(); $App->TableCell($Group, undef, undef, undef, undef, 1); $App->TableCell($name, undef, undef, undef, undef, 1); $App->TableCell($addr, undef, undef, undef, undef, 1); $App->EndTableRow(); } $App->EndTableBody(); $App->EndTable(); return 1; } sub ViewCSVFileByTable { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); if($Path !~ /\.csv$/i) { $App->H3("Invalid CSV file: [$Path]"); return 0; } $App->H3("Information for [$Path] (CSV)"); my $MultiFunctionTableJScript = JSParams->new()->GetMultiFunctionalTableString('.TableTest3'); #, sortList => '[[1,1]]', excludeColumns => '[2,3]'); my %MultiFunctionTableConfigByClass = ( class => 'tablesorter' ); # $App->print($MultiFunctionTableJScript); $App->PrintRawHTML($MultiFunctionTableJScript); my $csv = new CSV; $csv->Read($Path, 0); my $pLabelArray = $csv->LabelArray(); my $nData = $csv->nData(); my $pDataArray = $csv->DataArray(); $App->BeginTable(1, undef, %MultiFunctionTableConfigByClass); $App->BeginTableHeader(); $App->BeginTableRow(); for(my $i = 0 ; ; $i++) { last if(!defined $pDataArray->[$i]); $App->TableCell("Data $i", undef, undef, undef, undef, 0); } $App->EndTableRow(); $App->EndTableHeader(); $App->BeginTableBody(); for(my $i = 0 ; ; $i++) { last if(!defined $pDataArray->[$i]); $App->TableCell($pLabelArray->[$i], undef, undef, undef, undef, 1); } for(my $il = 0 ; ; $il++) { last if(!defined $pDataArray->[0]->[$il]); $App->BeginTableRow(); for(my $i = 0 ; ; $i++) { #$App->print("$il: i=$i\n"); last if(!defined $pDataArray->[$i]->[$il]); last if(!defined $pDataArray->[$i]); $App->TableCell($pDataArray->[$i]->[$il], undef, undef, undef, undef, $il+1); } $App->EndTableRow(); } $App->EndTableBody(); $App->EndTable(); return 1; } sub ViewImageFile { my ($this, $App, $pParams, $Path) = @_; $Path = $pParams->{Path} if($Path eq ''); $App->H3("Information for [$Path] (IMAGE)"); if($Path =~ /\.pdf$/i) { my ($drive, $directory, $filename, $ext1, $lastdir, $filebody) = Deps::SplitFilePath($Path); $directory =~ s/\\/\//g; $App->MakePDFFirstPageImage($pParams, $Path); # $this->MakePDFFirstPageImage( $App, $pParams, $Path, %args, pFiles => \@files); my $PDFPath = $Path; $PDFPath =~ s/\.pdf$/\.jpg/i; #$App->print("path[$Path]\n"); return if(!-f $PDFPath); $Path = $PDFPath; } my ($url, $label) = $App->MakeInlineImageLinkURL($pParams, $Path, undef, $this->{ModuleName}); my $link = $App->MakeImageLinkString($pParams, $url, 0, 300); # $App->print("$link\n"); $App->PrintRawHTML("$link\n"); return 1; } 1;