#!/usr/bin/perl #!c:/perl/bin/perl.exe # The above line may need to be changed to reflect the location of # the perl interpreter on your system. Use "which perl" on a Unix system # to make a noble attempt to locate your perl interpreter. If you are # installing this on an NT IIS server then you probably do not need to # modify this line because it will most likely be ignored. Apache under # NT generally DOES require the top line to be configured. We have provided # two common paths above as examples, only the top line will be used, the # second line is just there to provide an example. ############################################################################ # POP3Mail, Standard Edition, version 2.3 # # Copyright (c) 2000, Indian Magic. All rights reserved. ############################################################################ package mailman; # Enable these while you are working on modifications. Make absolutely # certain that 'use strict' is NOT enabled in production installations. # CGI.pm and 'use strict' are not compatible, if you have 'use strict' # enabled then your users will not be able to upload files because CGI.pm # provides uploaded files using a bizarre on-the-fly file handle that will # cause an error if you have 'use strict' enabled. We think that this is # ugly too, but there is no way around it at the moment. #use strict; #$^W = 1; # Warnings. # Version information that might find its way into output. $mailman::strPOP3MailVersion = 'v2.3'; $mailman::strPOP3MailEdition = 'Standard Edition'; # Variable initialization. Clean and neat and all, but very necessary # for mod_perl. InitializeVars(); ############################################################################ # This section contains a few variables that you might need to set in order # to get POP3Mail functioning properly. If your installation is working, # then you don't need to worry about any of these. ############################################################################ # Location Attachments # When a user selects an attachment from a message for downloading, # POP3Mail generates that attachment on-the-fly and sends it through the # HTTP server to the user's browser. POP3Mail includes the necessary # HTTP header information for the user's browser to determine the # file name, but many broswers, most notably Microsoft's Internet # Explorer, either ignore these headers or just don't handle them # very well. The result is that when a user downloads an attachment, # your browser may present the user with a "Save As" box with the # file name filled in as the name of this script, a string or random # characters, or any number of other un-graceful things. We think that # the best solution to this problem would be for browser makers to # pay attention to HTTP headers, but until then we provide a mechanism # for working around the problem. If you set up a directory that is # writable by POP3Mail and readable by your web server, then POP3Mail # will write out the attachment file to that directory temporarily, # and redirect the user's browser to that file. When the user logs # in or out POP3Mail will ensure that the user's files in this # temporary directory are removed. A user that exits POP3Mail without # logging out and never logs back in could potentially leave stale # attachment files on the server, so occasional monitoring of the # temporary directory for stale files would be appropriate. Also note # that this mechanism could be considered a privacy problem since a # user's attachments are deposited temporarily into a world-readable # directory rather than generated on-the-fly the way POP3Mail normally # would do. We have left the decision up to each individual # administrator as to whether or not to use this feature. Most people # seem to prefer allowing POP3Mail to generate attachments on-the-fly # for simplicity, ease of administration, and security/privacy, but # some people think that the attachment file name thing is a critical # issue. The decision is yours. # To use this feature, create a directory that is readable by your # web server and writable by the user that POP3Mail runs as. Set # $mailman::strLocalLocationAttachments to the local path name of # this directory, for instance # $mailman::strLocalLocationAttachments = '/public_html/attachtmp/'; # Then set $mailman::strURLLocationAttachments to the URL location # of this directory, for instance # $mailman::strURLLocationAttachments = '/attachtmp/'; # Note the terminal slashes at the end, those are necessary. Just # set and uncomment the following lines to use this feature: #$mailman::strLocalLocationAttachments = 'c:/www/public_html/pop3mail/tmp/'; #$mailman::strURLLocationAttachments = '/pop3mail/tmp/'; # Local File Permissions # Use this if you want to modify the permissions that files and # directories created by POP3Mail use. This will only make much sense # to Unix and Unix-like operating systems. If this value is not set, # nothing will happen. This should be an octal integer as in the # example below, not a string. # This value will only matter if you set # $mailman::strLocalLocationAttachments and # $mailman::strURLLocationAttachments, of course. $mailman::iLocalFilePermissions = 0666; # Local Directory Permissions # Same as above, used for directories created by POP3Mail. # This value will only matter if you set # $mailman::strLocalLocationAttachments and # $mailman::strURLLocationAttachments, of course. $mailman::iLocalDirectoryPermissions = 0777; # Outgoing Banner Text # This is the banner that is appended to the end of any message that # this POP3Mail installation sends. One reason why this is one of the # first configuration options is because we want to make it very # obvious that you can remove or modify this banner. Indian Magic places # no restrictions at all on this banner, so don't worry about leaving # credit to us in here or anything like that. Please feel free to # change this to whatever you like, or completely remove it. If this # value is not defined then it will simply append no banner. $mailman::strOutgoingBannerText = "Check any POP3 Mail at http://mail.indian-magic.net" ; # Incoming Mail Server: # The way that we originally intended to allow people to 'rig' the server # names for an installation was through simple template modifications, as # mentioned in the FAQ. A lot of people have asked about ways to rig the # server names in the script itself though, so we added this. We aim to # please... If you want to rig your incoming server name so that it makes # no difference at all what an incoming form specifies, just un-comment # this line and specify it. #$mailman::strIncomingServer = 'mail.indian-magic.net'; # Outgoing Mail Server: # Same deal, different server. #$mailman::strOutgoingServer = 'mail.indian-magic.net'; # From Domain Name: # Set this variable to override the domain name that is assumed when a # user logs in. For instance, when the user "abcd" logs into the POP3 # server "mail.indian-magic.net", POP3Mail will assume that his address # is "abcd@mail5.indian-magic.net". If you set this variable to # "indian-magic.net", then it will assume that his address is # "abcd@indian-magic.net" instead. If the mapping between POP3 user names # and email addresses is more complicated then you will need to actually # build your own routines to do the mapping. #$mailman::strFromDomainName = "indian-magic.net"; # From Domain Trim: # If the above option doesn't work for you, you can set this value to # instruct POP3Mail to trim the machine name when it derives the 'from' # email address. The number that you set this to represents the total # number of names to shear off of the left-hand side of the machine # name. For instance, if the user's POP3 server name is # "mail.abcd.indian-magic.net", and you set this value to 0, the default, # then when the user composes a message POP3Mail will guess # "username@mail.abcd.indian-magic.net" as the 'from' address. If you set # this value to 1 then it will guess "username@abcd.indian-magic.net", if # you set it to 2 then it will guess "username@indian-magic.net", etc. This # can be helpful if you have a number of different virtual domains # and you want the email address to be inferred dynamically, rather # than by hard-coding it with the "From Domain Name" configuration value. #$mailman::iFromDomainTrim = 1; # Outgoing Domain Name: # When a user specifies a recipient name without full domain qualification # ("abcd" instead of "abcd@indian-magic.net", for example) then the SMTP server # should provide configuration rules for determining how to deal with this # mail. It should not be the responsibility of the mail client to fill in # a complete address. We have had many requests for a feature to allow # an administrator to specify a default domain name, however, and we aim # to please. This configuration variable is the result. If you want # POP3Mail to assume a default domain name when it is given an incomplete # address, uncomment this line and set it to your domain name. We strongly # recommend against this, however, you should be looking into your SMTP # server's configuration options and not using this feature. #$mailman::strOutgoingDomainName = indian-magic.net'; # Messages Per Page: # This value controls the number of messages returned per page in a # message list. Adjust it if you like. $mailman::iMessagesPerPage = 20; # Local Template Location: # If you have a web server that sets the current directory to something # strange, you can set this to an absolute path to make it easier to # allow POP3Mail to find the templates. Just set this variable to an # absolute path like "C\:\\inetpub\\wwwroot\\pop3mail\\templates\\" # or '/usr/home/indian-magic/pop3mail/' or whatever. Note the final slash, that's # important. If you leave it out then things won't work. If you need # to set this value, then un-comment the following line: #$mailman::strLocalTemplateLocation = "D:/inetpub/wwwroot/indian-magic/products/pop3mail/"; $mailman::strLocalTemplateLocation = "/home/sites/site6/web/pop3mail/"; # Local Script Location: # If your server is one of the ones that causes problems that require the # above value to be set, then you might also need to set this value. In # most cases your script location and your template location will be # identical, but if you move your templates to a different directory than # your script for whatever reason, then you will need to set this. If you # have no idea what I'm talking about, you should probably just leave this. #$mailman::strLocalScriptLocation = $mailman::strLocalTemplateLocation; $mailman::strLocalScriptLocation = "/home/sites/site6/web/"; # URL Image Location: # Use this to rig the URLs that will be used to access the images that # the templates point to. This value will be prepended to any value in # the templates of the form ""i_*.gif"" (including the inner quotes). # If you have customized your templates and your own custom images are # not showing up in POP3Mail's output, it is probably because the custom # images that you are using are not named "i_*.gif". # To use this variable, set it to the exact value that you want prepended # to image names in order to make them into URLs that will point to your # image directory. For instance, if you bury your images in an "images" # directory under the directory where POP3Mail is installed, set this to # 'images/' (with the slash). If you put your images in a completely # different directory, something that is rooted, like '/pop3mail/images/' # might be what you are looking for. In the most extreme cases you can # do away with relative URLs entirely and provide a complete absolute URL # like the one below #$mailman::strURLImageLocation = 'http://www.indian-magic.net/pop3mail/'; # Use Perl 'alarm()' function: # Set this to true if your Perl interpreter supports "alarm". As of this # Writing, NT Perl does not. If this is not set, POP3Mail will not be able # to timeout when a server hangs. The OSSettings() routine will attempt # to set this variable, but you can override it here if you want. # The point of the "alarm" feature as used in POP3Mail is to allow POP3Mail # to detect when a mail server has not responded within a reasonable # amount of time. If your server's Perl interpreter does not support # "alarm", then POP3Mail will still work, but if a mail server ever does # not respond then the user will get no feedback to that effect. #$mailman::bUseAlarm = 1; # Timeout Duration: # The aforementioned timeout delay. Set this to something else to modify # how long POP3Mail will sit around waiting for a mail server to respond. # Only works if $mailman::bUseAlarm is set to something. $mailman::iTimeoutDurationInSeconds = 180; # Use Perl 'crypt()' function: # Some Perl impelentations apparently do not support the crypt() function. # We have never seen one, and there are plenty of implementations out there # that you should be able to find a good one, but we try to accomodate # anyway. Comment out this line if your Perl implementation is breaking # on the crypt() function. Be warned that if you do this your users' # usernames and passwords will be less obfuscated than they were before, # which admittedly wasn't much. This is a good place to repeat the # suggestion that POP3Mail is an excellent candidate for SSL and other # fancy HTTP security mechanisms. #$mailman::bUseCrypt = 1; # Use Hijack Test: # POP3Mail performs a test to determine if the current session has been # hijacked by a different user from a different address. On a few # systems this will not work because of the configuration. If your # POP3Mail installation sits behind a cluster of caching proxy servers # for load balancing, for instance. If you want to disable the hijack # checking functionality, just comment out this line. #$mailman::bUseHijackTest = 1; # Kiosk Mode: # If you are using POP3Mail in a kiosk environment, it will generally # be possible for a user to use a combination of "BACK" and "RELOAD" in # the kiosk web browser to intrude backwards into the mail sessions of # previous users. If you set this value then POP3Mail will operate in # kiosk mode, which means that when a user logs in, POP3Mail will create # a new browser window with that user's session. If the user logs out # then that window will close, and the user's history information will # go with the window so that intrusions with "BACK" and "RELOAD" aren't # possible. We recommend against using this feature for installations # that are not kiosk-based because it relies on Javascript and cookies, # which does not leave users with older browsers with a way in. If you # are in a kiosk environment then you have control over the browser an # that's not a problem. We strongly recommend against using the # Microsoft Internet Explorer for kiosk environments because it does not # properly respect the "Expires:" and "Cache-control:" HTTP headers, so # IE will cache user mail to the hard drive whether you want it to or # not. Microsoft appears to have no interest in fixing this problem. # IE 4 SP1 pretty consistently crashed during our tests of the # full-screen popup window kiosk mode, too, which is likely not exactly # the behavior that you are looking for in your kiosk browser. # The kiosk mode feature primarily activates and deactivates sections # of outbound templates, so if you have customized your templates before # you decided to use kiosk mode then it is entirely possible that you # broke this mode by removing vital Javascript. Consult the # out-of-the-box template set for examples of the Javascript snippets # necessary for this mode. #$mailman::bKioskMode = 1; ############################################################################ # You should not have to configure any values after this line. ############################################################################ use Socket; use FileHandle; my($mma) = new FileHandle(); use CGI; my($mmb) = new CGI; { my(@mmc) = $mmb->param; my($mmd) = 0; for($mmd=0;$mmd<$#mmc+1;$mmd++) { my($mme) = $mmc[$mmd];; if($mme =~ /^(.+)\.[xy]$/) { my($mmf) = $1; if($mme =~ /^([^\#]+)\#(.*)\.[xy]$/) { $mmf = $1; $mmb->param($mmf,mmmd($2)); } else { $mmb->param($mmf,'MAILMANSPECIALTRUE'); } $mmb->delete("${mmf}.x"); $mmb->delete("${mmf}.y"); } else { if($mme =~ /^([^\#]+)\#(.*)$/) { $mmb->param($1,mmmd($2)); } } } } if($mmb->param('INTERFACE')) { my(@mmg) = split(/\&/,$mmb->param('INTERFACE')); my($mmh) = ''; foreach $mmh (@mmg) { if($mmh =~ /^([^\=]+)\=(.*)$/) { $mmb->param($1,mmmd($2)); } } unless($mmb->param('INTERFACE') =~ /ALTERNATE_TEMPLATES/) { $mmb->param('ALTERNATE_TEMPLATES',''); } } { @mailman::mmi = split(/\;/,$ENV{'HTTP_COOKIE'}); my($mmj) = ''; foreach $mailman::mmj (@mailman::mmi) { $mailman::mmk = 1; if($mailman::mmj =~ /POP3MailAuth\=(\S+)/) { my(@mml) = split(/\&/,$1); my($mmm) = ''; foreach $mmm (@mml) { $mmm =~ /^(.+)\#(.+)$/; unless($mmb->param($1)) { $mmb->param($1,$2); } } } } } $mailman::mmn = mmmh($mmb->param('USERNAME')); $mailman::mmn =~ s/^\s*([^\s]+)\s*$/$1/; $mailman::mmo = mmmg($mailman::mmn); $mailman::mmp = mmmh($mmb->param('PASSWORD')); $mailman::mmp =~ s/^\s*([^\s]+)\s*$/$1/; $mailman::mmq = mmmg($mailman::mmp); unless($mailman::strIncomingServer) { $mailman::strIncomingServer = mmmh($mmb->param('SERVER')); $mailman::strIncomingServer =~ s/^\s*([^\s]+)\s*$/$1/; } $mailman::mmr = mmmg($mailman::strIncomingServer); unless($mailman::strOutgoingServer) { $mailman::strOutgoingServer = $mmb->param('OUTGOING'); $mailman::strOutgoingServer =~ s/^\s*([^\s]+)\s*$/$1/; } $mailman::mms = ''; if(defined($mailman::strLocalLocationAttachments) && defined($mailman::strURLLocationAttachments)) { unless($mailman::strLocalLocationAttachments =~ /[\/\\]$/) { $mailman::strLocalLocationAttachments .= '/'; } unless($mailman::strURLLocationAttachments =~ /[\/\\]$/) { $mailman::strURLLocationAttachments .= '/'; } $mailman::mmt = $mailman::strLocalLocationAttachments . mmmc($mailman::mmn . '@' . $mailman::strIncomingServer); $mailman::mmu = $mailman::strURLLocationAttachments . mmmc( mmmc($mailman::mmn . '@' . $mailman::strIncomingServer)); $mailman::mmv = 1; } $mailman::mmw = mmmb($ENV{SERVER_NAME},42); $mailman::mmw .= mmmb($ENV{REMOTE_HOST} . $ENV{REMOTE_ADDR},69); $mailman::mmx = mmmg($mailman::mmw); mmma(); $mailman::mmy = $ENV{SCRIPT_NAME}; unless($mailman::mmy =~ /^\//) { $mailman::mmy = "/$mailman::mmy"; } $mailman::mmz = $mailman::mmy; $mailman::mmz =~ s/^(.*[\\\/])[^\\\/]+$/$1/; if($mailman::mmz eq '/') { $mailman::mmaa = ''; } else { $mailman::mmaa = "path=$mailman::mmz; "; } sub mmkl { if($mmb->param('NOFRAMES')) { $mailman::mmab = 1; } if($mmb->param('NOCACHE')) { $mailman::mmac = 1; } if(defined($mmb->param('ALTERNATE_TEMPLATES'))) { $mailman::mmad = $mmb->param('ALTERNATE_TEMPLATES'); } } sub mmkm { my($mmae) = shift; my(@mmc) = $mmb->param; my($mmd) = 0; for($mmd=0;$mmd<$#mmc+1;$mmd++) { my($mme) = $mmc[$mmd];; if($mme =~ /^$mmae\:(.*)$/) { return $1; } } return; } mmkl(); mmkn(); { my($mmj) = ''; @mailman::mmi = split(/\;/,$ENV{'HTTP_COOKIE'}); foreach $mailman::mmj (@mailman::mmi) { if($mailman::mmj =~ /POP3MailCmds\=(\S+)/) { my($mmaf) = ''; @mailman::mmag = split(/\&/,$1); foreach $mmaf (@mailman::mmag) { $mmaf =~ /^(.+)\#(.+)$/; unless($mmb->param($1)) { $mmb->param($1,$2); } } } } } mmkl(); mmkn(); mmkq(); sub mmkn { my($mmah) = ''; if($mmb->param('BLANK')) { mmlz('t_blank.htm'); } if($mmb->param('MENU')) { mmlz('t_f_menu.htm'); } if($mmb->param('LOGOUT')) { if($mailman::mmv) { mmmo(); } if($mailman::bKioskMode) { print "Set-cookie: POP3MailAuth=;$mailman::mmaa" . "expires=Sun, 03-May-1998 16:00:00 GMT\n"; print "Set-cookie: POP3MailCmds=;$mailman::mmaa" . "expires=Sun, 03-May-1998 16:00:00 GMT\n"; print "Set-cookie: POP3MailDir=;$mailman::mmaa" . "expires=Sun, 03-May-1998 16:00:00 GMT\n"; $mailman::mmn = ''; mmlz('t_closewindow.htm'); } else { mmkq(); } } if($mmb->param('START')) { mmkq(); } if($mmb->param('LOGIN')) { my($mmai) = ''; if($mmai = mmks()) { if(defined($mmai)) { $mmai =~ s/^\-ERR(.*)$/$1/; } $mailman::bKioskMode = 0; $mailman::mmaj{'GREETING'} = "
\n| . qq|\n| . qq|\n| . qq|
\n|; } else { if($mmdz =~ /\.(jpg)|(gif)|(png)\s*$/i) { $mmdg .= qq|\n| . qq|
Attachment 1:\n| . qq|\n| . qq|$mmdz |
\n| .
qq|\n| .
qq| |
Attachment 1:\n| . qq|\n| . qq|$mmdz
\n|; } } } return $mmdg; } my($mmer)=1; if($mmel =~ /multipart\/mixed/i) { if($mmeh[1] =~ /multipart\/alternative/i || $mmeh[1] =~ /multipart\/mixed/i) { $mmdg = mmlc($mmeg[1], $mmdx); } elsif($mmeh[1] =~ /text\/plain/i) { $mmdg = mmlk($mmeg[1], $mmdx); } elsif($mmeh[1] =~ /text\/html/i) { if($mmdx) { $mmdg = mmlk($mmeg[1], $mmdx); } else { $mmdg = mmll($mmeg[1]); } } else { $mmer = 0; } } elsif($mmel eq 'multipart/alternative') { my($mmes) = 1; for(;$mmes<=$mmej;$mmes++) { if($mmeh[$mmes] =~ /text\/html/i && !$mmdx) { $mmdg = mmll($mmeg[$mmes]); return $mmdg; } } $mmes = 1; for(;$mmes<=$mmej;$mmes++) { if($mmeh[$mmes] =~ /text\/plain/i) { $mmdg = mmlk($mmeg[$mmes], $mmdx); return $mmdg; } } } else { $mmdg = mmlk($mmdw, $mmdx); return($mmdg); } if($mmdx) { return($mmdg); } if($mmel eq 'multipart/mixed') { for(;$mmer<$mmej;$mmer++) { my($mmet) = $mmei[$mmer+1]; $mmet = mmmc($mmet); if($mailman::mmab) { $mmdg .= qq|\n| . qq|\n| . qq|\n| . qq|
\n|; } else { if($mmek[$mmer+1] =~ /\.(jpg)|(gif)|(png)\s*$/i) { $mmdg .= qq|\n| . qq|
Attachment #$mmer:\n| . qq|\n| . qq|$mmek[$mmer+1] |
\n| .
qq|\n| .
qq| |
Attachment #$mmer:\n| . qq|\n| . qq|$mmek[$mmer+1]
\n|; } } } } } else { $mmeo=0; plaintextline: foreach $_ (@$mmdw) { if(/^begin \d\d\d (\S+)\s*$/i) { $mmeo++; $mmeb=0; $mmep[$mmeo] = $1; $mmen[$mmeo] = $1 . 'P' . $mmeo; next plaintextline; } elsif($mmeo>0 && /^end\s*$/i) { $mmeo++; $mmeb=0; $mmem[$mmeo] .= "Fake Header\n\n"; next plaintextline; } $mmem[$mmeo][$mmeb++] = $_; } if($mailman::mmam ne '') { my($mmeu) = 0; for(;$mmeu<=$mmeo;$mmeu++) { if($mmen[$mmeu] eq $mailman::mmam) { if($mmep[$mmeu] eq '') { $mmdg = mmlk($mmem[$mmeu], $mmdx); return $mmdg; } else { mmlj($mmem[$mmeu],$mmep[$mmeu]); } } } } else { my($mmeu) = 0; for(;$mmeu<=$mmeo;$mmeu++) { if(!defined($mmep[$mmeu]) || $mmep[$mmeu] eq '') { $mmdg .= mmlk($mmem[$mmeu], $mmdx); } elsif(!$mmdx) { my($mmev) = $mmen[$mmeu]; $mmev = mmmc($mmev); if($mailman::mmab) { $mmdg .= '\n| . qq|
Attachment #$mmeu:\n| . qq|\n| . qq|$mmep[$mmeu] |
\n| .
qq|\n| .
qq| |
Attachment #$mmeu:\n| . qq|\n| . qq|$mmep[$mmeu]
\n|; } } } } } return($mmdg); } return($mmdg); } sub mmld { my($mmew) = shift; $mmew =~ s/([a-fA-F0-9]{2})/pack("C",hex($1))/eg; return $mmew; } sub mmle { my($mmdh) = ''; { my($mmdi,$mmdj,$mmdk,$mmdl,$mmdm,$mmdn,$mmdo,$mmdp,$mmdq) = gmtime(time); my(@mmdr) = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep', 'Oct','Nov','Dec'); $mmdh = "$mmdl $mmdr[$mmdm] " . ($mmdn + 1900) . " $mmdk:$mmdj:$mmdi +0000"; } return (100000000); } sub mmlf { my($mmex) = @_; my($mmey,$mmez) = (0, 0); my($mmec) = 0; my($mmba) = ''; my($mmfa) = ''; my($mmci) = ''; my($mmfb) = ''; my($mmfc) = 'Untitled'; foreach $mmba (@$mmex) { if($mmba =~ /^Content-transfer-encoding\: base64/i) { $mmey = 1; } elsif($mmba =~ /^Content-transfer-encoding\: quoted-printable/i) { $mmez = 1; } else { if($mmec && $mmey) { $mmfa .= $mmba; } elsif($mmec && $mmez) { $mmfa .= $mmba; } elsif($mmec) { $mmfa .= $mmba; } else { $mmci .= $mmba; } } if($mmba =~ /^[\r\n]+$/) { $mmec = 1; $mmci =~ s/[\r\n]+[ \t]+(\S)/ $1/gs; } if(!$mmec && $mmba =~ /name\=\"?([^\"\;]+)\"?\;?\s/si) { $mmfc = $1; } } if($mmey) { $mmfb = mmli($mmfa); } elsif($mmez) { $mmfb = mmlh($mmfa); } else { $mmfb = $mmfa; } print "Expires: Sun, 03 May 1998 16:00:00 GMT\n"; my($mmfd,$mmfe,$mmff) = mmmf(); if($mmfd !~ /MSIE/i) { print "Cache-control: no-cache\n"; } unless($mailman::mmv) { print $mmci; print $mmfb; exit(0); } else { unless(-d $mailman::mmt) { unless(mkdir($mailman::mmt,0755)) { mmko("Could not create temporary directory for " . "storing the attachment file. Make sure that " . "the directory " . "\"$mailman::mmt\" exists " . "and is writable by the web user."); } if(defined($mailman::iLocalDirectoryPermissions)) { mmmi($mailman::mmt, $mailman::iLocalDirectoryPermissions); } } my $mmfg = $mmfc; if($mmfc =~ /^(.+)(\.[^\.]+)$/) { my $mmfh = $1; my $mmfi = $2; $mmfc = mmmc(mmmc($mmfh)) . $mmfi; } else { $mmfc = mmmc(mmmc($mmfc)); } my($mmfj) = new FileHandle(); my($mmfk) = $mailman::mmt . '/' . $mmfc; unless(open($mmfj,">$mmfk")) { mmko("Could not create temporary attachment file in \"" . $mmfk ."\". Make sure that the " . "directory is writable by the web user."); } binmode($mmfj); print {$mmfj} $mmfb; close($mmfj); if ($mmfg =~ /^(.+)(\.[^\.]+)$/) { my($mmfl) = $mailman::mmu . '/' . mmmc(mmmc(mmmc($1))) . $2; print $mmb->redirect($mmfl); } else { my($mmfl) = $mailman::mmu . '/' . $mmfc; print $mmb->redirect($mmfl); } exit(0); } } sub mmlg { my $mmfa = shift; $mmfa =~ tr/\_/\ /; return $mmfa; } sub mmlh { my($mmfa) = @_; my($mmfm); $mmfa =~ s/\s+(\r?\n)/$1/g; $mmfa =~ s/=\r?\n//g; $mmfm = $mmfa; $mmfm =~ s/=([\da-fA-F]{2})/pack("C", hex($1))/ge; return($mmfm); } sub mmli { my($mmfa) = @_; my($mmfm); $mmfa =~ tr|A-Za-z0-9+=/||cd; if(length($mmfa)%4) { return($mmfa); } $mmfa =~ s/=+$//; $mmfa =~ tr|A-Za-z0-9+/| -_|; while($mmfa =~ /(.{1,60})/gs) { my($mmfn) = chr(32+length($1)*3/4); $mmfm .= unpack("u",$mmfn . $1 ); } return($mmfm); } sub mmlj { my($mmfo,$mmfp) = @_; print "Expires: Sun, 03 May 1998 16:00:00 GMT\n"; my($mmfd,$mmfe,$mmff) = mmmf(); if($mmfd !~ /MSIE/i) { print "Cache-control: no-cache\n"; } unless($mailman::mmv) { print qq|Content-Type: application\/octet-stream; name="$mmfp"\n\n|; my($mmdg) = ''; my($mmba) = ''; foreach $mmba (@$mmfo) { $mmdg .= unpack('u',$mmba); } print $mmdg; exit(0); } else { unless(-d $mailman::mmt) { unless(mkdir($mailman::mmt,0755)) { mmko("Could not create temporary directory for " . "storing the attachment file. Make sure that " . "the directory " . "\"$mailman::mmt\" exists " . "and is writable by the web user."); } if(defined($mailman::iLocalDirectoryPermissions)) { mmmi($mailman::mmt, $mailman::iLocalDirectoryPermissions); } } my($mmfj) = new FileHandle(); my($mmfk) = $mailman::mmt . '/' . $mmfp; unless(open($mmfj,">$mmfk")) { mmko("Could not temporary attachment file in \"" . $mmfk ."\". Make sure that the " . "directory is writable by the web user."); } binmode($mmfj); my($mmba) = ''; foreach $mmba (@$mmfo) { print {$mmfj} unpack('u',$mmba); } close($mmfj); my($mmfl) = $mailman::mmu . '/' . $mmfp; print $mmb->redirect($mmfl); exit(0); } } sub mmlk { my($mmdw,$mmdx) = @_; my($mmey,$mmez); my($mmdg) = ''; my($mmbw) = 0; my($mmfa) = ''; if(!$mmdx) { $mmdg = "\n"; } $mmbw=0; foreach $_ (@$mmdw) { if(!$mmbw) { if(/^Content-transfer-encoding\: base64/i) { $mmey = 1; } elsif(/^Content-transfer-encoding\: quoted-printable/i) { $mmez = 1; } } if($mmbw) { my($mmfq) = ''; if($mmez || $mmey) { $mmfa = $_; if($mmey) { $mmfq = mmli($mmfa); } elsif($mmez) { $mmfq = mmlh($mmfa); } } else { $mmfq = $_; } my($mmfr) = length($mmfq); my($mmfs) = ''; if($mmdx) { $mmfs = $mmfq; } else { $mmfs = mmkx($mmfq); } my($mmft) = 90 + (length($mmfs) - $mmfr); $mmfs =~ s/([^\n]{1,$mmft})\s/$1\n/g; $mmfs =~ s/\015//g; if($mmdx) { $mmfs = '> ' . $mmfs; } $mmdg .= $mmfs ; } if(/^[\r\n]+$/){ $mmbw = 1; } } if($mmey) { $mmdg .= mmli($mmfa); } elsif($mmez) { $mmdg .= mmlh($mmfa); } if(!$mmdx) { $mmdg .= "\n"; } return $mmdg; } sub mmll { my($mmdw) = @_; my($mmey,$mmez); my($mmfa) = ''; my($mmdg) = ''; my($mmbw) = 0; foreach $_ (@$mmdw) { if(!$mmbw) { if(/^Content-transfer-encoding\: base64/i) { $mmey = 1; } elsif(/^Content-transfer-encoding\: quoted-printable/i) { $mmez = 1; } } if($mmbw) { if($mmez || $mmey) { $mmfa .= $_; } else { my($mmfs) = $_; $mmfs =~ s/\r//g; $mmdg .= $mmfs; } } if(/^[\r\n]+$/){ $mmbw = 1; } } if($mmey) { $mmdg .= mmli($mmfa); } elsif($mmez) { $mmdg .= mmlh($mmfa); } $mmdg =~ s/\<\/?(html|head|body|title)[^\>]*\>//sig; return $mmdg; } sub mmlm { my($mmal,$mmds) = @_; mmla($mmal,$mmds); my($mmar) = ''; if($mailman::mmab) { $mmar = 't_nf_message.htm'; } else { $mmar = 't_f_message.htm'; } $mailman::mmaj{'USERNAME'} = $mailman::mmn; $mailman::mmaj{'USERNAMEHIDDEN'} = $mailman::mmo; $mailman::mmaj{'SERVER'} = $mailman::strIncomingServer; $mailman::mmaj{'SERVERHIDDEN'} = $mailman::mmr; $mailman::mmaj{'PASSWORDHIDDEN'} = $mailman::mmq; $mailman::mmaj{'CHECKSUM'} = $mailman::mmx; $mailman::mmaj{'NUM'} = $mailman::mmcl; $mailman::mmaj{'ID'} = $mailman::mmbk; $mailman::mmaj{'TO'} = $mailman::mmcd; $mailman::mmaj{'FROM'} = $mailman::mmce; $mailman::mmaj{'DATE'} = $mailman::mmbq; $mailman::mmaj{'SUBJECT'} = $mailman::mmcg; $mailman::mmaj{'MESSAGENUM'} = $mailman::mmbm; $mailman::mmaj{'MESSAGE'} = mmlc(\@mailman::mmdv); $mailman::mmaj{'CC'} = $mailman::mmcf; $mailman::mmfu = mmlx($mmar,'CCLINE'); if($mailman::mmbo eq '') { $mailman::mmfu = ''; } else { $mailman::mmfu = mmlv($mailman::mmfu,\%mailman::mmaj); } $mailman::mmaj{'CCLINE'} = $mailman::mmfu; mmlz($mmar,\%mailman::mmaj); } sub mmln { my($mmal,$mmds) = @_; mmla(mmmc($mmal),$mmds); my($mmar) = ''; if($mailman::mmab) { $mmar = 't_nf_message.htm'; } else { $mmar = 't_f_message.htm'; } $mailman::mmaj{'USERNAME'} = $mailman::mmn; $mailman::mmaj{'USERNAMEHIDDEN'} = $mailman::mmo; $mailman::mmaj{'SERVER'} = $mailman::strIncomingServer; $mailman::mmaj{'SERVERHIDDEN'} = $mailman::mmr; $mailman::mmaj{'PASSWORDHIDDEN'} = $mailman::mmq; $mailman::mmaj{'CHECKSUM'} = $mailman::mmx; $mailman::mmaj{'NUM'} = $mailman::mmcl; $mailman::mmaj{'ID'} = $mailman::mmbk; $mailman::mmaj{'MESSAGENUM'} = $mailman::mmbm; $mailman::mmaj{'TO'} = $mailman::mmcd; $mailman::mmaj{'FROM'} = $mailman::mmce; $mailman::mmaj{'DATE'} = $mailman::mmbq; $mailman::mmaj{'SUBJECT'} = $mailman::mmcg; $mailman::mmaj{'CC'} = $mailman::mmcf; $mailman::mmfu = mmlx($mmar,'CCLINE'); if($mailman::mmbo eq '') { $mailman::mmfu = ''; } else { $mailman::mmfu = mmlv($mailman::mmfu,\%mailman::mmaj); } $mailman::mmaj{'CCLINE'} = $mailman::mmfu; $mailman::mmaj{'MESSAGE'} = "
\n"; my($mmba) = ''; foreach $mmba (@mailman::mmdv) { $mmba =~ s/\015//g; $mmba =~ s/\&/\&\;/g; $mmba =~ s/\\<\;/g; $mmba =~ s/\>/\>\;/g; $mailman::mmaj{'MESSAGE'} .= $mmba; } $mailman::mmaj{'MESSAGE'} .= "\n"; mmlz($mmar,\%mailman::mmaj); } sub mmlo { my($mmal) = @_; $mailman::mmbh = mmkw($mmal); mmkr($mma,"DELE $mailman::mmbh"); my($mmbg) = ''; $mmbg = <$mma>; unless($mmbg =~ /^\+OK/) { mmko($mmbg); } } sub mmlp { my($mmal) = @_; mmlo($mmal); } sub mmlq { my($mmal,$mmfv,$mmfw, $mmbn) = @_; my($mmdg) = ''; my($mmfx) = ''; my($mmfy) = ''; my($mmfz) = ''; $mailman::mmaj{'ATTACH'} = $mmb->param('ATTACH'); my($mmar) = ''; $mmar = 't_messageform.htm'; if($mmal ne 'NEW') { mmla(mmmc($mmal),0); $mmfx = $mailman::mmbn; $mmfy = $mailman::mmbp; $mmfz = $mailman::mmbs; if($mailman::mmbt) { $mailman::mmbn = $mailman::mmbt; } else { $mailman::mmbn = $mailman::mmbp; } if($mmfv) { $mailman::mmbn .= ", $mmfx"; if($mailman::mmbo){ $mailman::mmbn .= ", $mailman::mmbo"; } } if($mmfw) { unless($mailman::mmbs =~ /^fwd\:/i) { $mailman::mmbs = "Fwd: $mailman::mmbs"; } $mailman::mmbn = ""; } else { unless($mailman::mmbs =~ /^re\:/i) { $mailman::mmbs = "Re: $mailman::mmbs"; } } $mailman::mmbo = ''; } $mailman::mmbn =~ s/\"/"/g; $mailman::mmbs =~ s/\"/"/g; if($mmal ne 'NEW') { $mailman::mmeq = 0; $mmdg = mmlc(\@mailman::mmdv,1); if($mmfw) { my($mmga) = mmlx($mmar, 'FORWARDHEADER'); $mailman::mmaj{'ORIGINALTO'} = $mmfx; $mailman::mmaj{'ORIGINALFROM'} = $mmfy; $mailman::mmaj{'ORIGINALSUBJECT'} = $mmfz; $mailman::mmaj{'ORIGINALDATE'} = $mailman::mmbq; $mmdg = mmlv($mmga, \%mailman::mmaj) . $mmdg; if($mailman::mmeq) { $mailman::mmgb = $mmal; $mailman::mmaj{'ERROR'} = 'The original message attachment(s) ' . 'will be included in this message.'; } } } $mailman::mmaj{'USERNAME'} = $mailman::mmn; $mailman::mmaj{'USERNAMEHIDDEN'} = $mailman::mmo; $mailman::mmaj{'SERVER'} = $mailman::strIncomingServer; $mailman::mmaj{'SERVERHIDDEN'} = $mailman::mmr; $mailman::mmaj{'PASSWORDHIDDEN'} = $mailman::mmq; $mailman::mmaj{'CHECKSUM'} = $mailman::mmx; $mailman::mmaj{'NUM'} = $mailman::mmbh; $mailman::mmaj{'MESSAGE'} = $mmdg; $mailman::mmaj{'TO'} = $mailman::mmbn; $mailman::mmaj{'CC'} = $mailman::mmbo; $mailman::mmaj{'SUBJECT'} = $mailman::mmbs; if(defined($mailman::strFromDomainName)) { $mailman::mmaj{'FROM'} = $mailman::mmn . '@' . mmmq($mailman::strFromDomainName); } else { $mailman::mmaj{'FROM'} = $mailman::mmn . '@' . mmmq($mailman::strIncomingServer); } my($mmfd,$mmfe,$mmff) = mmmf(); my($mmgc) = 0; if(($mmfd =~ /MSIE/i && $mmfe >= 4) || ($mmfd =~ /Mozilla/i && $mmfe >= 2)) { if(!$mmfw) { if($mmb->param('ATTACH')) { $mailman::mmaj{'UPLOAD'} = mmlx($mmar, 'UPLOAD'); $mmgc = 1; } else { $mailman::mmaj{'UPLOAD'} = mmlx($mmar, 'BENIGNUPLOAD'); } } else { $mailman::mmaj{'UPLOAD'} = ''; } } else { $mailman::mmaj{'UPLOAD'} = ''; } if($mmgc) { $mailman::mmaj{'MULTIPARTTAG'} = mmlx($mmar,'MULTIPARTTAG'); } mmlz($mmar,\%mailman::mmaj); } sub mmlr { my($mmai,$mmgd) = @_; my($mmfw) = 0; $mailman::mmaj{'ATTACH'} = $mmb->param('ATTACH'); my($mmar) = ''; $mmar = 't_messageform.htm'; $mailman::mmaj{'USERNAME'} = $mailman::mmn; $mailman::mmaj{'USERNAMEHIDDEN'} = $mailman::mmo; $mailman::mmaj{'SERVER'} = $mailman::strIncomingServer; $mailman::mmaj{'SERVERHIDDEN'} = $mailman::mmr; $mailman::mmaj{'PASSWORDHIDDEN'} = $mailman::mmq; $mailman::mmaj{'CHECKSUM'} = $mailman::mmx; $mailman::mmaj{'NUM'} = $mmb->param('NUM'); $mailman::mmaj{'TO'} = $mmb->param('TO'); $mailman::mmaj{'CC'} = $mmb->param('CC'); $mailman::mmaj{'FROM'} = $mmb->param('FROM'); $mailman::mmaj{'SUBJECT'} = $mmb->param('SUBJECT'); $mailman::mmaj{'OUTGOING'} = $mailman::strOutgoingServer; $mailman::mmaj{'ERROR'} = $mmai; unless(defined($mmgd) && length($$mmgd)) { $mailman::mmaj{'MESSAGE'} = $mmb->param('TEXT'); } else { $mailman::mmaj{'MESSAGE'} = $$mmgd; } if(defined($mmb->param('FORWARDATTACHMENTS'))) { $mailman::mmgb = mmmd($mmb->param('FORWARDATTACHMENTS')); $mmfw = 1; } my($mmfd,$mmfe,$mmff) = mmmf(); my($mmgc) = 0; if(($mmfd =~ /MSIE/i && $mmfe >= 4) || ($mmfd =~ /Mozilla/i && $mmfe >= 2)) { if(!$mmfw) { if($mmb->param('ATTACH')) { $mailman::mmaj{'UPLOAD'} = mmlx($mmar, 'UPLOAD'); $mmgc = 1; } else { $mailman::mmaj{'UPLOAD'} = mmlx($mmar, 'BENIGNUPLOAD'); } } else { $mailman::mmaj{'UPLOAD'} = ''; } } else { $mailman::mmaj{'UPLOAD'} = ''; } if($mmgc) { $mailman::mmaj{'MULTIPARTTAG'} = mmlx($mmar,'MULTIPARTTAG'); } mmlz($mmar,\%mailman::mmaj); } sub mmls { my($mmay) = "\015\012"; my($mmaz, $mmba) = @_; my($mmbb) = length($mmba . $mmay); syswrite($mmaz,$mmba . $mmay,$mmbb); } sub mmlt { my($mmay) = "\015\012"; my($mmdg) = ''; my($mmdy) = ''; my($mmge) = ''; my($mmbn) = ''; my($mmai) = ''; if($mmai = mmks()) { if(defined($mmai)) { $mmai =~ s/^\-ERR(.*)$/$1/; } $mailman::bKioskMode = 0; $mailman::mmaj{'GREETING'} = "
The output template "$mmfc" exists and was found by the POP3Mail\n| . qq|script, but the script does not have permission to read it.
\n| . qq|On most Unix systems, you can go to the directory where POP3Mail is\n| . qq|installed and type "chmod 644 $mmfc" to solve this problem. If\n| . qq|your HTTP server is running in a different operating in a different\n| . qq|operating system, consult your HTTP server and operating system \n| . qq|documentation for more information.
\n| . qq|\n|; exit(1); } else { print qq|The output template "$mmfc" could not be found by the POP3Mail \n| . qq|script.
Make sure that this template is located where POP3Mail can \n| . qq|find it (in the same directory as the script itself on most web servers,\n| . qq|but not necessarily) and make sure that the web server process has\n| . qq|permission to read the file. Consult your HTTP server and operating\n| . qq|system documentation for more information.
\n| . qq|\n|; exit(1); } } sub mmlx { my($mmfc,$mmhf) = @_; my($mmew) = ''; my($mmhg) = new FileHandle(); if(defined($mailman::mmad)) { $mmfc = $mailman::mmad . $mmfc; } if(open($mmhg, $mailman::strLocalTemplateLocation . $mmfc)) { my($mmhh) = ''; while(defined($_ = <$mmhg>)) { $mmhh .= $_; } close($mmhg); if($mmhh =~ /POP3MailSnippet\($mmhf\)\s*(.+)\s*EndSnippet\($mmhf\)/si) { $mmew = $1; $mmew =~ s/^\s+(\S.*)$/$1/; $mmew =~ s/^(.*\S)\s+$/$1/; return $mmew; } } $mmew = qq|Template Error: Snippet "$mmhf" not found in | . qq|template "$mmfc"|; return $mmew; } sub mmly { my($mmfc,@mmhi) = @_; my(@mmhj); my($mmhg) = new FileHandle(); if(defined($mailman::mmad)) { $mmfc = $mailman::mmad . $mmfc; } if(open($mmhg, $mailman::strLocalTemplateLocation . $mmfc)) { my($mmhh) = ''; while(defined($_ = <$mmhg>)) { $mmhh .= $_; } close($mmhg); my($mmhf) = ''; foreach $mmhf (@mmhi) { if($mmhh =~ /POP3MailSnippet\($mmhf\)\s*(.+)\s*EndSnippet\($mmhf\)/si) { my($mmew) = $1; $mmew =~ s/^\s+(\S.*)$/$1/; $mmew =~ s/^(.*\S)\s+$/$1/; push(@mmhj,$1); } else { mmko( qq|Template Error: Snippet "$mmhf" not found in | . qq|template "$mmfc"|); } } return @mmhj; } } sub mmlz { my($mmfc,$mmhd,$mmaq) = @_; my($mmhk) = 1; my($mmhg) = new FileHandle(); if(defined($mailman::mmad)) { $mmfc = $mailman::mmad . $mmfc; } unless($mmhd->{'ME'}){ $mmhd->{'ME'} = $mailman::mmy; } my($mmef) = localtime(time); $mmhd->{'UNIQUE'} = mmmg($mmef); $mmhd->{'EDITION'} = $mailman::strPOP3MailEdition; $mmhd->{'VERSION'} = $mailman::strPOP3MailVersion; if(open($mmhg, $mailman::strLocalTemplateLocation . $mmfc)) { print "Content-type: text/html\n"; my($mmm) = ''; if(defined($mailman::mmo)) { $mmm .= 'USERNAME' . '#' . $mailman::mmo . '&'; } if(defined($mailman::mmr)) { $mmm .= 'SERVER' . '#' . $mailman::mmr . '&'; } if(defined($mailman::mmq)) { $mmm .= 'PASSWORD' . '#' . $mailman::mmq . '&'; } if(defined($mailman::mmx)) { $mmm .= 'CHECKSUM' . '#' . $mailman::mmx; } if(defined($mailman::mmn) && $mailman::mmn ne '') { print "Set-cookie: POP3MailAuth=$mmm;" . "$mailman::mmaa\n"; } if(defined($mailman::mmo)) { $mmhd->{'AUTHENTICATION'} = qq||; } if(defined($mailman::mmr)) { $mmhd->{'AUTHENTICATION'} .= qq||; } if(defined($mailman::mmq)) { $mmhd->{'AUTHENTICATION'} .= qq||; } if(defined($mailman::mmx)) { $mmhd->{'AUTHENTICATION'} .= qq||; } $mmhd->{'AUTHENTICATION'} .= $mailman::mms; $mmhd->{'SETTINGS'} = ''; if($mailman::mmab) { $mmhd->{'SETTINGS'} .= qq||; } if($mailman::mmac) { $mmhd->{'SETTINGS'} .= qq||; } if(defined($mailman::mmad)) { $mmhd->{'SETTINGS'} .= qq||; } if($mailman::mmgb) { my($mmhl) = mmmc($mailman::mmgb); $mmhd->{'SETTINGS'} .= qq||; } my(@mmc) = $mmb->param; my($mmd) = 0; my($mmhm) = ''; for($mmd=0;$mmd<$#mmc;$mmd++) { my($mmaf) = $mmc[$mmd];; if($mmaf ne 'USERNAME' && $mmaf ne 'SERVER' && $mmaf ne 'PASSWORD' && $mmaf ne 'CHECKSUM' && $mmaf ne 'SEND' && $mmaf ne 'TEXT' && $mmaf ne 'ATTACH' && $mmaf !~ /USERFILE/) { $mmhm .= $mmaf . '#' . $mmb->param($mmaf) . '&'; } } chop($mmhm); if($mailman::mmab) { print "Set-cookie: POP3MailCmds=$mmhm; " . "path=$mailman::mmz;\n"; } if($mailman::mmac) { print "Expires: Sun, 03 May 1998 16:00:00 GMT\n"; print "Cache-control: no-cache\n"; } print "\n"; if(defined($mailman::strDebug) && ($mmfc !~ /t\_f\_frameset/)) { print qq|\n| . qq|DEBUG OUTPUT |
\n| .
qq|$mailman::strDebug| . qq| |