#!/usr/bin/perl # CsWebMAIL - Webmail Application for Perl # ------------------------------------------- # Author: Martin Boeck # Created: Vienna, 15. June 1998 # Last: Vienna, 17. 04 2001 # # ------------------------------------------- # ComneX - Commercial Internet Business # http://www.comnex.net # mailto:office@comnex.net # ------------------------------------------- # The "USES" - dont want to invent the wheel use CGI qw(:cgi :multidata); use Net::POP3; use Net::SMTP; use MIME::Base64; use MIME::QuotedPrint; use Data::Dumper; # ------------------ BEGIN of Configuration Area # strict security (1 .. on, 0 .. off) $|=1; $strictsecure = 0; # defaults %DEFAULTuser = ( 'name' => 'unknown', 'address' => 'unknown', 'lang' => 'gr', 'smtp' => '!return "smtp." . ( split ( /\./, $currentInfo{BOX}, 2 ) ) [1]', 'email' => '!return $currentInfo{USER} . "@" . ( split ( /\./, $currentInfo{BOX}, 2 ) ) [1]' ); # allowed Mailhosts $POPallow = "(.*)"; # default WebMail directory (no web access !) $storedir = "/var/www/webmail"; # default WebMail Attachment directory (web access !) $storeweb = "/var/www/webmail/webout"; # default CGI link for WebMail $CGILink = "http://webmail.comnex.net/webmail.pl"; # default ATTACHMENT link for Webmail $ATTACHLink = "http://webmail.comnex.net/wmout/"; # local Webmail TEXT configuration for use in HTML pages %localWebMail = ( Company => 'ComneX - Commercial Internet Business', email => 'mjb@comnex.net', version => '0.97', vdate => '19. April 2001' ); # Data for message reply : $replySubject = "Re: "; $replyQuote = "> "; $replyText = "Answer to your message: \n"; # Time a Secure KEY is valid ( in seconds ) $timevalid = 1800; # A list of short names for month (we only compare the first # three letters) - Perhapes I forgot something %monthlist =( jan => '1', feb => '2', mar => '3', apr => '4', mai => '5', jun => '6', jul => '7', aug => '8', sep => '9', oct => '10', okt => '10', nov => '11', dec => '12', dez => '12', ); # A Hash of all Configuration files in $storeweb/cfg[/lang] %cfgfiles =( errors => 'errors.msg', # Error Messages gen_err => 'gen_err.t', # General Error Template sec_err => 'sec_err.t', # Security Violation Template logon => 'logon.t', # Logon Template logon_err => 'logon_err.t', # Logon Error Template list_head => 'listhead.t', # Head of List list_foot => 'listfoot.t', # Foot of List list_entry => 'listentry.t', # One Entry of list msg_head => 'msghead.t', # Message Head msg_foot => 'msgfoot.t', # Message Foot msg_sus_start => 'msgsusstart.t', # Message Attachment Suspicious msg_sus_stop => 'msgsusstop.t', # Message Attachment Suspicious msg_print_start => 'msgprintstart.t', # Message Print Start msg_print_stop => 'msgprintstop.t', # Message Print Stop msg_showpart_start => 'msgshowstart.t', # Message IMAGE show start msg_showpart_stop => 'msgshowstop.t', # Message IMAGE show stop msg_file_start => 'msgfilestart.t', # Message ATTACHMENT start msg_file_stop => 'msgfilestop.t', # Message ATTACHMENT stop ucfg => 'ucfg.t', # User Configuration ucfgproc => 'ucfgproc.t', # Process of User Configuration sendmail => 'sendmail.t', # Sendmail mailsent => 'mailsent.t', # Send a mail done mailsent_start => 'mailsentstart.t', # Send a mail done mailsent_stop => 'mailsentstop.t', # Send a mail done mailsent_err => 'mailsenterr.t', # Send a mail done logout => 'logout.t', # message after logging out logok => 'logok.msg', list_EN => 'listnew.t', ); # ------------------ END of Configuration Area ## ------------------ Error Messages ## 1 Security Key ## 2 SMTP host not good ## 3 SMTP not enough arguments ## 4 cannot get POP list or cannot save to disk ## 5 ucfg file not possible ## 6 not enough parameters ## 7 directory for UCFG error ## 8 BOX cannot be opened ## 9 Mailhost not allowed ## 10 datasend Error (SMTP) ## 11 cannot save head.cur ## 12 cannot open head.cur ## 13 a secure key exists ! ## 14 logout error ## 15 error getting msg ## ------------------ Logfile Keys ## 1 User logs out ## 2 mail sent ## 3 configuration has been changed ## 4 delete multiple messages ## 5 delete one message ## 6 user logged on # ------------------ BEGIN of MAIN Area # Capture variables and initialize arrays and lists &Do_CGI_Work; # Handle Parameters from QUERY STRING if (($CGIARG{'KEY'}) and ($CGIARG{'USER'}) and ($CGIARG{'BOX'})) { # is it a secure connection ?! if (&check_secure) { # get the Userdata from his directory if ((my $tmperrRead=&readUser) eq 0) { # lets see what the user wants $_ = $CGIARG{'ACTION'}; GETSWITCH: { /^msg/ && do { &CGIGetMsg ( $CGIARG{'NUM'} ); last GETSWITCH; }; /^listmsg/ && do { &CGIListMsg; last GETSWITCH; }; /^relistmsg/ && do { &CGIReListMsg; last GETSWITCH; }; /^deletemsg/ && do { &CGIdelMsg ( $CGIARG{'NUM'} ); last GETSWITCH; }; /^usercfgp/ && do { &CGIUserCFGpr; last GETSWITCH; }; /^usercfg/ && do { &CGIUserCFG; last GETSWITCH; }; /^sendmail/ && do { &CGISendmail; last GETSWITCH; }; /^dosend/ && do { &CGIDoSendmail; last GETSWITCH; }; /^reply/ && do { &CGIReply ( $CGIARG{'NUM'} ); last GETSWITCH; }; /^deletemult/ && do { &CGIdelMult; last GETSWITCH; }; /^logout/ && do { &CGILogout; last GETSWITCH; }; # default case &CGILogon; } # user not defined, so he cannot go on without login } else { &doError ( $cfgfiles{'gen_err'}, $tmperrRead); # ERROR FROM "READUSER" } # Sorry, the user is using an invalid Security LINK } else { &doError ( $cfgfiles{'sec_err'}, 1 ); # ERROR / NO KEY GOOD } # The QUERY String doesnt seem to be valid, lets try a POST case } else { # lets see what the user wants $_ = $CGIDAT::action; POSTSWITCH: { /^logon/ && do { &CGILogonProc; last POSTSWITCH; }; # default case &CGILogon; } } # Closing POP is needed to delete messages, and to please the POP server &closePOP; # not realy important, but do it ! exit 0; # ------------------ END of MAIN Area # ------------------ BEGIN of SUB - Area: CGI* # SUB: CGILogout # PARAMETERS: nothing # GLOBALS: %currentInfo # INITWORK: nothing # DESC: deletes the slink file and display accurate message # ERRORS: 14 # RETURN: nothing # VERSION: 1 sub CGILogout { # if there is an slinkfile, and we can delete it &removePassword; if ( &OSdelete( "$storedir/$CGIARG{'USER'}.$CGIARG{'BOX'}/slinks" ) ) { # do a log message, and display the logout message &logOutOk ( 1, "" ); &htmlSubst($cfgfiles{'logout'}, \%currentInfo); } else { # else do an error log &logOutError ( 14 ); # and display error message &doError ( $cfgfiles{'gen_err'}, 14 ); # ERROR / LOGOUT } } # SUB: CGIReply # PARAMETERS: num to reply # GLOBALS: %currentInfo # INITWORK: nothing # DESC: print the sendmail screen with the current User Info, # including the old message # ERRORS: nothing # RETURN: nothing # VERSION: 1 sub CGIReply { my $msgnum = shift; my %replydata = %currentInfo; # try to read the head of the messages if ((my $tmperr=&FileToHead) eq 0) { # whom to reply to ? if ($POPHead{$msgnum}{'RETURN-PATH'}) { $replydata{'TO'} = &emailAdress( $POPHead{$msgnum}{'RETURN-PATH'} ); } else { $replydata{'TO'} = &emailAdress( $POPHead{$msgnum}{'FROM'} ); } # What subject ? $replydata{'SUBJECT'} = &mydecode( $replySubject . $POPHead{$msgnum}{'SUBJECT'} ); # do we have reply data left ? if ( open ( REPLY, "$currentInfo{'DIRECTORY'}/reply" ) ) { # ok. init message $replydata{'MESSAGE'} = ""; while () { $replydata{'MESSAGE'} .= $_; } close REPLY; } else { $replydata{'MESSAGE'} = $replyText; } } else { # Cannot find the correct head ! $replydata{'TO'} = ""; $replydata{'SUBJECT'} = ""; $replydata{'MESSAGE'} = ""; } # now display the sendmail template using the data found &htmlSubst( $cfgfiles{'sendmail'}, \%replydata ); } # SUB: CGISendmail # PARAMETERS: nothing # GLOBALS: %currentInfo # INITWORK: nothing # DESC: print the sendmail screen with the current User Info # ERRORS: nothing # RETURN: nothing # VERSION: 1 sub CGISendmail { &htmlSubst( $cfgfiles{'sendmail'}, \%currentInfo ); } # SUB: GIDoSendmail # PARAMETERS: nothing # GLOBALS: %currentInfo, $CGIDAT # INITWORK: nothing # DESC: sends a mail # ERRORS: 1,2 # RETURN: nothing # VERSION: 1 sub CGIDoSendmail { # Can we send to someone at somewhere ? if (($CGIDAT::to) and ($currentInfo{'SMTP'}) and ($currentInfo{'EMAIL'})) { &htmlSubst($cfgfiles{'mailsent_start'}, \%currentInfo ); $CGIDAT::to=~s/^\s*//; $CGIDAT::to=~s/\s*$//; $CGIDAT::to=~s/\s+/ /; $CGIDAT::cc=~s/^\s*//; $CGIDAT::cc=~s/\s*$//; $CGIDAT::cc=~s/\s+/ /; $CGIDAT::bcc=~s/^\s*//; $CGIDAT::bcc=~s/\s*$//; $CGIDAT::bcc=~s/\s+/ /m; if ($CGIDAT::to=~/[,;\s]/) { my @alladdr=split /[,;\s]+/, $CGIDAT::to; foreach (@alladdr) { my $tonow=&emailAdress($_); &DoOneSend ($tonow); } } else { my $tonow=emailAdress($CGIDAT::to); &DoOneSend($tonow); } if ( $CGIDAT::bcc ) { if ($CGIDAT::bcc=~/[,;\s]/) { my @alladdr=split /[,;\s]+/, $CGIDAT::bcc; foreach (@alladdr) { my $tonow=&emailAdress($_); &DoOneSend ($tonow); } } else { my $tonow=emailAdress($CGIDAT::bcc); &DoOneSend($tonow); } } if ( $CGIDAT::cc ) { if ($CGIDAT::cc=~/[,;\s]/) {print "YEP"; my @alladdr=split /[,;\s]+/, $CGIDAT::cc; foreach (@alladdr) { my $tonow=&emailAdress($_); &DoOneSend ($tonow); } } else { my $tonow=emailAdress($CGIDAT::cc); &DoOneSend($tonow); } } &htmlSubst($cfgfiles{'mailsent_stop'}, \%currentInfo ); } else { &logOutError ( 3 ); &doError($cfgfiles{'gen_err'}, 3); } } sub DoOneSend { my $tmpto = &emailAdress( shift ); my ($tsubject,$tmessage)=($CGIDAT::subject,$CGIDAT::message); # Try to create SMTP session my $smtp = Net::SMTP->new( $currentInfo{'SMTP'} ); # Session open if ($smtp) { # do some safty work $currentInfo{'EMAIL'} = &emailAdress( $currentInfo{'EMAIL'} ); $tsubject = &encodeLine ( $tsubject ); # Tell the server whom to send to $smtp->mail( $currentInfo{'EMAIL'} ); $smtp->to($tmpto); # send header Data $smtp->data(); $smtp->datasend("From: $currentInfo{'EMAIL'}\n"); $smtp->datasend("To: $CGIDAT::to\n"); if ( $CGIDAT::cc ) { $smtp->datasend("Cc: $CGIDAT::cc\n"); } if ( $CGIDAT::bcc ) { $smtp->datasend("Bcc: $CGIDAT::bcc\n"); } $smtp->datasend("Subject: $tsubject\n"); # some fun my $bound="xxmartinlovesdanilaandhisbabies"; # do we have an attachment if ($CGIDAT::attach) { # we need an content-Type $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-Type: multipart/mixed; boundary=$bound"); $smtp->datasend("\n"); $smtp->datasend("Mail created by cWebmail need a browser, which supports MIME Version 1.0\n"); $smtp->datasend("\n"); $smtp->datasend("--$bound\n"); # assume text/plain for normal message $smtp->datasend("Content-Type: text/plain\n"); } # check if it is a special character code unless ($tmessage =~ /([\x00-\x20] | [\x7F-\xFF])/) { $smtp->datasend("\n"); } else { $smtp->datasend("MIME-Version: 1.0\n"); $smtp->datasend("Content-Transfer-Encoding: quoted-printable\n"); $smtp->datasend("Content-Type: text/plain\n"); $smtp->datasend("\n"); # Encode it using QP $tmessage = encode_qp ($tmessage); } $smtp->datasend("\n"); # for safty; # now the normal message $smtp->datasend("$tmessage\n"); # now an attachment if ($CGIDAT::attach) { my $attachdata = $CGIDAT::attach; my $atfile = $cgih->param('attach'); my @tmpfilename = split(/[\\\\\/]/, $atfile); $tmpfilename[$#tmpfilename] =~ s/[ \t]/_/g; my $cttmp = &findMIME($tmpfilename[$#tmpfilename]); $tmpfilename[$#tmpfilename] = &encodeLine ( $tmpfilename[$#tmpfilename] ); unless ($cttmp) { $cttmp = $cgih->uploadInfo($atfile)->{'Content-Type'}; } $smtp->datasend("--$bound\n"); $smtp->datasend("Content-Transfer-Encoding: base64\n"); $smtp->datasend("Content-Type: $cttmp; name=\"$tmpfilename[$#tmpfilename]\"\n"); $smtp->datasend("Content-Disposition: attachment; filename=\"$tmpfilename[$#tmpfilename]\"\n"); $smtp->datasend("\n"); my $MIMEfiletmp = ""; while (<$atfile>) { $MIMEfiletmp .= $_; } # encode it $MIMEfiletmp = encode_base64($MIMEfiletmp); $smtp->datasend("$MIMEfiletmp\n"); # close $atfile; seek $atfile,0,0; $smtp->datasend("\n"); $smtp->datasend("--$bound--\n"); } # end session unless ($smtp->dataend()) { $smtp->quit; &logOutError ( 10 ); my %htmlout = %currentInfo; $htmlout{TO} = $tmpto; &htmlSubst($cfgfiles{'mailsent_err'}, \%htmlout ); } else { $smtp->quit; &logOutOk ( 2, "$tmpto" ); my %htmlout = %currentInfo; $htmlout{TO} = $tmpto; &htmlSubst($cfgfiles{'mailsent'}, \%htmlout ); } } else { &logOutError ( 2 ); my %htmlout = %currentInfo; $htmlout{TO} = $tmpto; &htmlSubst($cfgfiles{'mailsent_err'}, \%htmlout ); } } # SUB: CGIUserCFG # PARAMETERS: nothing # GLOBALS: %currentInfo # INITWORK: nothing # DESC: let the User configure his account # ERRORS: nothing # RETURN: nothing # VERSION: 1 sub CGIUserCFG { &htmlSubst($cfgfiles{'ucfg'}, \%currentInfo); } # SUB: CGIUserCFGpr # PARAMETERS: nothing # GLOBALS: %currentInfo, %CGIDAT # INITWORK: nothing # DESC: let the User configure his account # ERRORS: from saveconfig # RETURN: nothing # VERSION: 1 sub CGIUserCFGpr { # Get It ! $currentInfo{'REALNAME'} = $CGIDAT::RealName; $currentInfo{'EMAIL'} = $CGIDAT::email; $currentInfo{'ADRESS'} = $CGIDAT::Adress; $currentInfo{'LANG'} = $CGIDAT::lang; $currentInfo{'SMTP'} = $CGIDAT::SMTP; # Save IT! if ((my $tmperrorSave = &saveConfig) eq 0) { &logOutOk ( 3, "" ); &htmlSubst ($cfgfiles{'ucfgproc'}, \%currentInfo); } else { &logOutError ( $tmperrorSave ); &doError($cfgfiles{'gen_err'}, $tmperrorSave); } } # SUB: CGIdelMult # PARAMETERS: msgnum # GLOBALS: %currentInfo, $pop # INITWORK: nothing # DESC: deletes mult message # ERRORS: cannot log in # RETURN: nothing # VERSION: 1 sub CGIdelMult { # We have to relogon my $msgident; if ((my $tmpErrorLog=&LoginUser( $currentInfo{'USER'}, $currentInfo{'BOX'}, $currentInfo{'PASS'})) eq 0) { foreach $msgident (@{$CGIARG{'MULT'}}) { $pop->delete( $msgident ); } $pop->quit; &logOutOk ( 4, "" ); &CGIReListMsg; } else { &logOutError ( $tmpErrorLog ); &doError($cfgfiles{'gen_err'}, $tmpErrorLog); } } # SUB: CGIdelMsg # PARAMETERS: msgnum # GLOBALS: %currentInfo, $pop # INITWORK: nothing # DESC: deletes a message # ERRORS: cannot log in # RETURN: nothing # VERSION: 1 sub CGIdelMsg { my $msgident = shift; # We have to relogon if ((my $tmpErrorLog=&LoginUser( $currentInfo{'USER'}, $currentInfo{'BOX'}, $currentInfo{'PASS'})) eq 0) { $pop->delete( $msgident ); $pop->quit; &logOutOk ( 5, "" ); &CGIReListMsg; } else { &logOutError ( $tmpErrorLog ); &doError($cfgfiles{'gen_err'}, $tmpErrorLog); } } # SUB: CGILogon # PARAMETERS: nothing # GLOBALS: nothing # INITWORK: nothing # DESC: print the logon screen, no massiv work # ERRORS: nothing # RETURN: nothing # VERSION: 1 sub CGILogon { # we just need to display the logon screen, no other work to be done &htmlSubst($cfgfiles{'logon'}, \%localWebMail); } # SUB: CGILogonProc # PARAMETERS: nothing # GLOBALS: %CGIDAT # INITWORK: %currentInfo, $pop, %POPHead # DESC: Does the first login work and displays the list of POP # or print the logon Error # ERRORS: 3, from logon # RETURN: nothing # VERSION: 1 sub CGILogonProc { # lets see if the user can be logged on if ((my $returnstat = &LoginUser( $CGIDAT::user, $CGIDAT::box, $CGIDAT::pass )) eq 0) { # YES !, get his messages, and save it if ((&getPOPlist eq 0) && (&HeadToFile eq 0)) { &addPassword; # and display all messages ! &logOutOk ( 6, "$CGIDAT::user - $CGIDAT::box" ); &CGIListMsg; } else { &logOutError ( 4 ); &doError($cfgfiles{'logon_err'}, 4); } # Sorry, the user cant be logged on ! } else { # Print error using the message number of the Login Result ! &logOutError ( $returnstat ); &doError($cfgfiles{'logon_err'}, $returnstat); } } # SUB: CGIReListMsg # PARAMETERS: nothing # GLOBALS: %currentInfo # INITWORK: $pop, %POPHead # DESC: Reloads the list of Messages from the POP account # ERRORS: 3, from logon # RETURN: nothing # VERSION: 1 sub CGIReListMsg { # Logon the user and see, whats happening if ((my $tmpErrorLog=&LoginUser( $currentInfo{'USER'}, $currentInfo{'BOX'}, $currentInfo{'PASS'})) eq 0) { # YES !, get his messages, and save it if ((&getPOPlist eq 0) && (&HeadToFile eq 0)) { # and display all messages ! &CGIListMsg; } else { &doError($cfgfiles{'logon_err'}, 4); } } else { # Print error using the message number of the Login Result ! &doError($cfgfiles{'logon_err'}, $tmpErrorLog); } } # SUB: CGIListMsg # PARAMETERS: nothing # GLOBALS: %currentInfo # INITWORK: %POPHead # DESC: Reloads the list of Messages from the POP account # ERRORS: from filetohead # RETURN: nothing # VERSION: 1 sub CGIListMsg { my $headmsg; # Read the POP messages from the file if ((my $tmpErrorfile=&FileToHead) eq 0) { # turn sort direction if ($CGIARG{'SORTDIR'}) { if ($CGIARG{'SORTDIR'} eq 1) { $currentInfo{'NEWSORT'} = 2; } else { $currentInfo{'NEWSORT'} = 1; } } else { $currentInfo{'NEWSORT'} = 1; } # print the Header with User Information htmlSubst($cfgfiles{'list_head'}, \%currentInfo); # print each POP Header line with the Header Data foreach $headmsg ( sort sortList keys %POPHead ) { if ((not ($POPHead{$headmsg}{"STATUS"})) or (not $POPHead{$headmsg}{"STATUS"} =~ /r/i)) { htmlSubst($cfgfiles{'list_EN'}, $POPHead{$headmsg}); } else { htmlSubst($cfgfiles{'list_entry'}, $POPHead{$headmsg}); } } # print the footer with the local configuration Hash htmlSubst( $cfgfiles{'list_foot'}, \%localWebMail); # Cant get Header } else { &doError($cfgfiles{'gen_err'}, $tmpErrorfile); } } # SUB: CGIGetMsg # PARAMETERS: [message ID] # GLOBALS: %currentInfo # INITWORK: %POPHead, %POPmsg # DESC: display the message selected # ERRORS: from LoginUser, or FileToHead # RETURN: nothing # VERSION: 1 sub CGIGetMsg { # Check if its a number passed my $msgident = shift; # We have to relogon if ((my $tmpErrorlog=&LoginUser( $currentInfo{'USER'}, $currentInfo{'BOX'}, $currentInfo{'PASS'})) eq 0) { # check if we can get the header if ((my $tmpErrorFile=&FileToHead) eq 0) { # get the list from our POP if (@POPmsg = @{ $pop->get( $msgident ) }) {; # first, display the msg - head &htmlSubst($cfgfiles{'msg_head'}, $POPHead{$msgident} ); &workmsg ( @POPmsg ); &htmlSubst($cfgfiles{'msg_foot'}, $POPHead{$msgident} ); $POPHead{$msgident}{"STATUS"}="RO"; &HeadToFile; } else { &doError( $cfgfiles{'gen_err'}, 15 ); } # Sorry, header problem } else { &doError($cfgfiles{'gen_err'}, $tmpErrorFile); } # no logon possible ! } else { &doError($cfgfiles{'gen_err'}, $tmpErrorlog); } } # ------------------ END of SUB - Area: CGI* # ------------------ BEGIN of SUB - Area: helping routinges sub findMIME { my $filename = shift; my $mimefound = ""; if (open (MIMECONF, "$storedir/cfg/mime.conf")) { while (($_ = ) and (not $mimefound)) { chomp($_); @mimemap = split(/[\ \t]+/, $_); if ($filename =~ /$mimemap[0]/) { $mimefound = $mimemap[1]; } } close MIMECONF; } return $mimefound; } # SUB: sortList # PARAMETERS: - # GLOBALS: %CGIARG, %POPHead # INITWORK: - # DESC: sorting routine # ERRORS: - # RETURN: nothing # VERSION: 1 sub sortList { if (($CGIARG{'SORT'}) and ($CGIARG{'SORTDIR'})) { if ($CGIARG{'SORTNUM'} eq "1") { if ($CGIARG{'SORTDIR'} eq "1") { lc($POPHead{$a}{uc($CGIARG{'SORT'})}) <=> lc($POPHead{$b}{uc($CGIARG{'SORT'})}); } else { lc($POPHead{$b}{uc($CGIARG{'SORT'})}) <=> lc($POPHead{$a}{uc($CGIARG{'SORT'})}); } } else { if ($CGIARG{'SORTDIR'} eq "1") { lc($POPHead{$a}{uc($CGIARG{'SORT'})}) cmp lc($POPHead{$b}{uc($CGIARG{'SORT'})}); } else { lc($POPHead{$b}{uc($CGIARG{'SORT'})}) cmp lc($POPHead{$a}{uc($CGIARG{'SORT'})}); } } } else { $b <=> $a; } } # SUB: prepareHTML # PARAMETERS: one line # GLOBALS: - # INITWORK: - # DESC: substitutes the html "bad" tags # ERRORS: - # RETURN: clean line # VERSION: 1 sub text2htmlprep { my $workstring = shift; $workstring =~ s/\>/\>\;/g; $workstring =~ s/\quit; } } # SUB: logOutOK # PARAMETERS: num, text # GLOBALS: - # INITWORK: - # DESC: logs out OK # ERRORS: - # RETURN: - # VERSION: 1 sub logOutOk { my $id = shift; my $logtext = shift; my $gettext = &getOneLine ( $cfgfiles {'logok'}, $id ); if (open (LOGOK, ">>$currentInfo{'DIRECTORY'}/log")) { my $gtime = gmtime ( time ); print LOGOK "+ $gtime: $gettext $logtext\n"; close LOGOK; } } # SUB: logOutError # PARAMETERS: num # GLOBALS: - # INITWORK: - # DESC: logs out Error # ERRORS: - # RETURN: - # VERSION: 1 sub logOutError { my $id = shift; my $gettext = &getOneLine ( $cfgfiles {'errors'}, $id ); if (open (LOGER, ">>$currentInfo{'DIRECTORY'}/log")) { my $gtime = gmtime ( time ); print LOGER "- $gtime: $gettext\n"; close LOGER; } } # SUB: getOneLine # PARAMETERS: [File], [Num] # GLOBALS: $currentInfo ( if possible ) # INITWORK: nothing # DESC: Reads line x from file # ERRORS: nothing # RETURN: The specific line # VERSION: 1 sub getOneLine { my $msgfile = shift; my $msgnum = shift; my $tmpline = "not defined\n"; my $i; if (open ( MSGFILE, "$storedir/cfg/$currentInfo{'LANG'}/$msgfile") or open (MSGFILE, "$storedir/cfg/$msgfile")) { for ($i=1; $i <= $msgnum; $i++) { $tmpline = ; } close MSGFILE; # cant open one of the errorfiles } else { $tmpline="Cannot open messagebase ! PANIC !\n"; } # prepare for html output ! chomp($tmpline); return($tmpline); } # SUB: doError # PARAMETERS: [Errortemplate], [Errornumber] # GLOBALS: $currentInfo ( if possible ) # INITWORK: nothing # DESC: what to have an Error # ERRORS: nothing # RETURN: nothing # VERSION: 1 sub doError { my $errorfile = shift; my $errno = shift; # try to open first the language specific errorfile, then try to open the # general errorfile my $tmpline = &getOneLine ( "$cfgfiles{'errors'}", $errno ); # prepare hash for output my %tmperr = ( ERROR => "$tmpline", ); # display it ! &htmlSubst($errorfile, \%tmperr); # sorry, but after an error, we dont want to produce more CPU overhead exit 0; } # SUB: htmlSubst # PARAMETERS: [htmltemplate], [parameterhash] # GLOBALS: $currentInfo ( if possible - for secure links ) # INITWORK: nothing # DESC: displays the html give by template and substitutes # ERRORS: selfproducing # VERION: 1 sub nohtml { my $inhash=shift; } sub htmlSubst { my $file = shift; my %substhash = %{ shift() }; my $correct = shift || 1; if ($correct) { foreach my $substpart ( keys %substhash ) { $substhash{$substpart}=~s/\&/\&/g; $substhash{$substpart}=~s/\/\>/g; } } # Get the Session Key for the user my $tmplink = $currentInfo{'SESSIONKEY'}; my $partone = ""; my $parttwo = ""; my $tmphash = ""; if ((open (TEMPLATE, "$storedir/cfg/$currentInfo{'LANG'}/$file")) or (open (TEMPLATE, "$storedir/cfg/$file"))) { # read each line while (