/[webmail]/cgi-bin/inbox.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /cgi-bin/inbox.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by dpavlin, Tue Feb 22 13:28:20 2000 UTC revision 1.4 by dpavlin, Wed Apr 19 10:57:07 2000 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/perl  #!/usr/local/bin/perl
2    
3  BEGIN { $APP_PATH="foo/bar"; }  BEGIN { $APP_PATH="/home/httpd/html/webmail/cgi-bin/"; }
4    
5  # @ ----------------------------------------------------------------------------------------------------------  # @ ----------------------------------------------------------------------------------------------------------
6  # @ This code is (c) 1999 Alexandre Aufrere and NikoSoft.  # @ This code is (c) 1999 Alexandre Aufrere and NikoSoft.
# Line 89  $pop = new Mail::POP3Client($loginname, Line 89  $pop = new Mail::POP3Client($loginname,
89  #How many messages are there in the inbox provided by the $pop object?  #How many messages are there in the inbox provided by the $pop object?
90  $MessageCount = $pop->Count;  $MessageCount = $pop->Count;
91    
92    #gather additional size info
93    @MessageSize = $pop->ListArray;
94    
95  print "<table><tr><td>";  print "<table><tr><td>";
96  #if $pop->count is -1, then the POP connection failed.  #if $pop->count is -1, then the POP connection failed.
# Line 104  elsif ($MessageCount == 0) { Line 106  elsif ($MessageCount == 0) {
106  #if $pop->count is >0, then that is the number of messages in the  #if $pop->count is >0, then that is the number of messages in the
107  #POP account inbox.  #POP account inbox.
108  else {  print "<img src=$MAIL_IMG valign=middle>&nbsp;&nbsp;";  else {  print "<img src=$MAIL_IMG valign=middle>&nbsp;&nbsp;";
109          print "<b>$MessageCount $messagesininbox.</b>\n";          print "<b>$MessageCount $messagesininbox (",$pop->Size," $bytestotaltext).</b>\n";
110                  }                  }
111    
112  #print "</td><td width=300 align=center>\n";  #print "</td><td width=300 align=center>\n";
# Line 138  print "</td></tr></table><br>\n"; Line 140  print "</td></tr></table><br>\n";
140                                    
141          if ($MessageCount > 0) {          if ($MessageCount > 0) {
142                  print "<table border=0 cellpadding=2 cellspacing=0 width=90% align=center>";                  print "<table border=0 cellpadding=2 cellspacing=0 width=90% align=center>";
143                  print "<tr bgcolor=darkblue><td><b><font color=white>$fromtext</b></td><td><b><font color=white>$subjecttext</b></td><td><b><font color=white>$datetext</b></td><td>&nbsp;</td>";                  print "<tr bgcolor=darkblue><td><b><font color=white>$fromtext</b></td><td><b><font color=white>$subjecttext</b></td><td><b><font color=white>$datetext</b></td><td colspan=2><font color=white><b>$sizetext&nbsp;</b></td>";
144          &ParseHeaders();                  &ParseHeaders();
145                  print "</table>";                  print "</table>";
146                  }                  }
147                    
# Line 178  exit; Line 180  exit;
180    
181  #----------------------------------SUBROUTINES-------------------------  #----------------------------------SUBROUTINES-------------------------
182    
183    # Decode quoted strings (in From: and Subject)
184    
185    sub DecodeQuoted {
186            my $tmp = $_[0];
187            if ($tmp =~ /=?ISO-8859-[1-2]?(.)?/i) {
188                    $tmp =~ s/=([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
189                    $tmp =~ s/=\?ISO-8859-[1-2]\?.\?(.*)\?=/$1/i;
190            }
191            return $tmp;
192    }
193    
194  #-----------------------------Sub ParseHeaders-----------------------------  #-----------------------------Sub ParseHeaders-----------------------------
195  #Subroutine to parse the headers on each message to exctract the TO:, FROM:,  #Subroutine to parse the headers on each message to exctract the TO:, FROM:,
# Line 228  for ($i=$lastMsg; $i >= 1 && $i> $lastMs Line 240  for ($i=$lastMsg; $i >= 1 && $i> $lastMs
240                  #of each line                  #of each line
241          if (/^From:/ ){          if (/^From:/ ){
242                  $from = $';                     #Get string following the succesful match.                  $from = $';                     #Get string following the succesful match.
243                $from = DecodeQuoted($from);
244              $from =~ s/</&lt\;/;                #Strip out angled brackets to prevent browsers              $from =~ s/</&lt\;/;                #Strip out angled brackets to prevent browsers
245              $from =~ s/>/&gt\;/;                #from interpreting them as unknown HTML codes.              $from =~ s/>/&gt\;/;                #from interpreting them as unknown HTML codes.
246              }              }
# Line 236  for ($i=$lastMsg; $i >= 1 && $i> $lastMs Line 249  for ($i=$lastMsg; $i >= 1 && $i> $lastMs
249              }              }
250          elsif (/^Subject:/) {          elsif (/^Subject:/) {
251                  $sub = $';                  $sub = $';
252                    $sub = DecodeQuoted($sub);
253              }              }
254          elsif (/^Date:/) {          elsif (/^Date:/) {
255                  $date = $';                  $date = $';
256                          }                          }
257          }          }
258          $date=~ s/.*\,(.*)\+.*/$1/;          $date=~ s/.*\,(.*)\+.*/$1/;
259          print "<td><a href='.' OnClick='document.lire$i.submit();return false;'>$from&nbsp;</a></td><td><b>$sub&nbsp;</b></td><td>$date&nbsp;</td>";          $date="<small>$date</small>";
260    
261            $size=$MessageSize[$i];
262            $size="<small>".int(($size+512)/1024)."k</small>";
263    
264            print "<td><a href='.' OnClick='document.lire$i.submit();return false;'>$from&nbsp;</a></td><td><b>$sub&nbsp;</b></td><td>$date&nbsp;</td><td align=right>$size</td>";
265    
266          #for each message header, also provide a FORM button to          #for each message header, also provide a FORM button to
267          #delete using inbox.pl As above, pass in the needed vars          #delete using inbox.pl As above, pass in the needed vars

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.26