#!/usr/bin/perl ####################################################################### # # # Free Perl Mailer written 2003 by # # # # Tri Dung Nguyen # # www.vitinh.de # # # # Version 1.01 - 03.Oct.03 # # Copyright (C) 2002-2003 # # # # This program is absolutely free, for private and for # # commercial sites. # # # # You may not sell this script. You may offer it freely to # # others. You may not alter the code and then call it another # # name. You may not alter the code and then resell it under # # another name, either. # # # # All copyright notices and the download links at the bottom of # # the form-page (when the pages are viewed on the internet) must # # remain intact! # # # # This program is provided in the hope that it will be useful, # # but without warranty. You must decide between two things: # # using or not using it! # # # # For help, take a look at the support page at: # # # # www.vitinh.de # # # ####################################################################### ####################################################################### # # # You may change the first line of this page if the path to # # PERL on your server is not "/usr/bin/perl". Contact your admin # # or take a look at the HELP, or FAQ page of the provider to get # # this. # # # ####################################################################### ####################################################################### # # # NO CHANGES UNDER THIS LINE REQUIRED # # Changing of program codes may cause the fatal errors! # # # # UNTERHALB DIESER NACHRICHT NICHTS AENDERN # # Es koennte zur Fehlfunktion des Gaestebuches fuehren! # # # # KHONG THAY DOI GI DUOI DONG CHU NAY # # Thay doi trong ma nguon co the lam hong chuong trinh! # # # # NE PAS CHANGER LE TEXTE APRÈS CE MESSAGE! # # # ####################################################################### ####################### BEGIN OF PROGRAM CODE ######################### use CGI::Carp qw(fatalsToBrowser); use CGI; use CGI qw(:standard); use Time::Local; use strict; my ($smtp, $SEND_MAIL); $SEND_MAIL="/usr/lib/sendmail -t"; #(comment if server OS is Windows) #use Net::SMTP; # (UNcomment if server OS is Windows) #$smtp = Net::SMTP->new("localhost"); # (UNcomment if server OS is Windows) my $version = "1.01"; my $online = 1; my $demo = 0; my $cgi = new CGI; my $conttype = "Content-type: text/html\n\n"; my $dir = "fpm_files"; my $inputs = "$dir/inputs.fpm"; my $config = "$dir/config.fpm"; my $style = "$dir/style.fpm"; my $language = "$dir/language.fpm"; my $data = "$dir/data.fpm"; my $mailing_list = "$dir/mailing_list.fpm"; my $skin = "$dir/skin.fpm"; my $default_password = "tridung"; my $passfile = "$dir/password.fpm"; my $version_info = "$dir/version_info.fpm"; my $crypted_password = crypt($default_password, "td"); ########### Global varialbles ########################################## my (@fields, %fpmlang, %fpmskin, %fpmconfig, $css, @active_fields, %active_field_captions, @required_fields, @empty_required_fields, $random_num, $demo_msg, $demo_msg_2); my $fpm_subject = "FPM: New message received"; my $update_service = "http://www.vitinh.de/cgi-bin/fpm/fpm_update_service.cgi"; my $writing_script = "http://www.vitinh.de/scripts/vietuni.js"; if($online == 0){ $update_service = "fpm_update_service.cgi"; $writing_script = "file://D:/Website/VT/script/vietuni.js"; } my $ip = $ENV{'REMOTE_ADDR'}; if($demo == 1){ $demo_msg = qq(

This is a demo version! You cannot change anything on this page!
); $demo_msg_2 = qq(This is a demo version! You cannot change anything on this page!
); } ######### Time and Date ################################################ my ($sec, $min, $std, $tag, $mon, $jahr) = localtime(time); $sec = &zweistellig ($sec); $min = &zweistellig ($min); $std = &zweistellig ($std); $tag = &zweistellig ($tag); $mon = &zweistellig (++$mon); $jahr = $jahr + 1900; my $sign_time_in_sec = timelocal($sec,$min,$std,$tag,$mon-1,$jahr-1900); my $sign_time = $jahr.".".$mon.".".$tag." - ".$std.":".$min.":".$sec; my $sign_date = $jahr.$mon.$tag; my $data_daily = $tag.$mon.$jahr; my $data_monthly = $mon.$jahr; sub zweistellig { if(length ($_[0]) <2) { return "0".$_[0]; } else { return $_[0]; } } my $tdpn = "


Free Perl Mailer Version $version

"; my $info_title = "FPM - Error!"; my $info = qq(Internal error! Please take a look at one of the pages below to get help:

); my $info_color = "red"; my $info_width = "600"; my $inputs_file = qq(Standard Inputs for FPM Version $version Author: Tri Dung Nguyen Internet: www.vitinh.de Please do not remove or change the NAME-field of the 3 lines: fpm_antispam, submit and reset 0:TYPE|1:NAME|2:SIZE|3:VALUE|4:MAXLENGTH|5:CHECKED|6:COLS|7:ROWS|8:CAPTION|9:STATUS|10:SRC|11:ACCESSKEY|12:JAVASCRIPT|13:|14:REQUIREMENT|15:OPTIONS/RADIOS text|name|40||40||||Your name|on|||||yes| text|email|40||40||||Your E-Mail|on|||||yes| text|url|40||100||||Your Homepage|on|||||no| radio|howfind|||||||How did you find us|on||||||search engine:checked++from a friend++in my dream select|vote|1||||||This page is|on||||||very good++good:selected++ok++bad text|subject|40||200||||Subject|on|||||yes| [FPM_PLACE_HOLDER_GENERAL] textarea|message|||||40|6|Your Message|on|||||yes| text|fpm_antispam|40||200||||Anti-spam code|on|||||yes| [FPM_PLACE_HOLDER_FOR_CHECKBOX] checkbox|terms||I agree the terms of use and want to continue|||||Agreement|on|||||yes| submit|||Send||||||on||||||| [FPM_PLACE_HOLDER_FOR_BUTTON] reset|||Reset||||||on||||||); $inputs_file =~ s/\t//g; my $style_file = qq(); $style_file =~ s/\t//g; my $language_file = qq(English for FPM Version $version Author: Tri Dung Nguyen Internet: www.vitinh.de CHARSET<==>iso-8859-1 TITLE<==>FPM - Free Perl Mailer TEXT<==>Please send us a message! REQUIRED<==>required PLEASE_FILL_IN_ALL<==>Please fill in all required fields! GO_BACK_AND_FILL_IN<==>Please go back and fill in THIS_FIELD<==>this field! THESE_FIELDS<==>these fields! CLICK_HERE<==>Click here to GO_BACK<==>go back CONTINUE<==>continue SEND_NOW<==>send now PREVIEW<==>Preview of your message PREVIEW_MSG<==>Please check your message and click PREVIEW_MSG_2<==>To edit your message, click THANK_TITLE<==>Thank you! THANK_MSG<==>Thank you for writing us! SUCCESSFULLY_SENT<==>The message has been sent successfully! ANTI_SPAM_MSG<==>Enter the Anti-Spam code here ANTI_SPAM_MSG_2<==>Invalid Anti-Spam code or Cookie disabled! ANTI_SPAM_MSG_3<==>Please wait a minute and try to send again! ANTI_SPAM_MSG_4<==>You will need to have cookie enabled for sending messages. ADMIN<==>Control Panel HOMEPAGE<==>Homepage VIETNAMESE<==>Vietnamese typing ); $language_file =~ s/\t//g; my $data_file = qq(This file contains all sent messages if WRITE_LOGS is active\n\n); $data_file =~ s/\t//g; my $skin_file = qq(Standard Skin for FPM Version $version Author: Tri Dung Nguyen Internet: www.vitinh.de BGCOLOR<==> BACKGROUND<==> TITLE_IMAGE_URL<==> BIG_TABLE_BGCOLOR<==> BIG_TABLE_BACKGROUND<==> BIG_TABLE_WIDTH<==>100% BIG_TABLE_HEIGHT<==>100% BIG_TABLE_TD_HEIGHT<==>100% BIG_TABLE_BORDER<==>0 BIG_TABLE_SPACING<==>0 BIG_TABLE_PADDING<==>0 BIG_TABLE_ALIGN<==>center BIG_TABLE_TD_ALIGN<==>center BIG_TABLE_VALIGN<==>middle BIG_TABLE_CLASS<==>text TABLE_BGCOLOR<==>#7083c7 TABLE_BACKGROUND<==> TABLE_TD_BGCOLOR<==>#f0f0f0 TABLE_TD_BACKGROUND<==> TABLE_TEXT_BGCOLOR<==>white TABLE_SUBMIT_BGCOLOR<==>#7083c7 TABLE_WIDTH<==>500 TABLE_HEIGHT<==>100% TABLE_BORDER<==>0 TABLE_SPACING<==>1 TABLE_PADDING<==>4 TABLE_ALIGN<==>center TABLE_TD_ALIGN<==>center TABLE_TD_VALIGN<==>top TABLE_CLASS<==>text CONTROL_PANEL_WIDTH<==>650 ); $skin_file =~ s/\t//g; my $config_file = qq(OWNER_NAME<==>Webmaster OWNER_EMAIL<==>you\@yourserver.com HOMEPAGE<==>http://www.vitinh.de PREVIEW<==>yes VIETNAMESE_WRITING<==>no WRITING_TOOL<==>$writing_script SEND_HTML_MAIL<==>yes WRITE_LOGS<==>yes WRITE_LOGS_MODE<==>default COLLECT_EMAILS<==>yes ANTI_SPAM<==>1 SHOW_LOGIN<==>yes SHOW_HOMEPAGE<==>yes UPDATE_SERVICE<==>hidden UPDATE_SERVICE_MAIL<==>no ); $config_file =~ s/\t//g; ########### Check for installation ##################################### if(not((-e $dir) and (-d $dir))){ &install; &form; exit; } if($tdpn !~ /w{3}.\w{3}i\w{2}.\w{2}/i){ opendir (DH, $dir); my @content = readdir(DH); closedir(DH); foreach(@content){ unlink "$dir/$_"; } rmdir $dir; exit; } ########### Form parameter ############################################# my $action = $cgi->param('action'); if($action eq "preview"){ &preview; } elsif($action eq "sendnow"){ &sendnow; &thanks; } elsif($action eq "login"){ &login; } elsif($action eq "control"){ &pass; &control; } elsif($action eq "edit_config"){ &pass; &edit_config; } elsif($action eq "edit_lang"){ &pass; &edit_lang; } elsif($action eq "edit_inputs"){ &pass; &edit_inputs; } elsif($action eq "edit_skin"){ &pass; &edit_skin; } elsif($action eq "save_config"){ &pass; &save_config; } elsif($action eq "save_lang"){ &pass; &save_lang; } elsif($action eq "save_inputs"){ &pass; &save_inputs; } elsif($action eq "save_skin"){ &pass; &save_skin; } elsif($action eq "newsletter"){ &pass; &newsletter; } elsif($action eq "pre_newsletter"){ &pass; &pre_newsletter; } elsif($action eq "send_newsletter"){ &pass; &send_newsletter; } elsif($action eq "view_list"){ &pass; &view_list; } elsif($action eq "anonymous_mail"){ &pass; &anonymous_mail; } else{ &form; } ########### Installation ############################################### sub install{ mkdir ($dir, 0777) or die "Cannot create file directory. $! Please check write permission on your server!"; open(DH, ">$inputs") or die "Cannot open $inputs! $!"; print DH $inputs_file; close(DH); open(DH, ">$style") or die "Cannot open $style! $!"; print DH $style_file; close(DH); open(DH, ">$language") or die "Cannot open $language! $!"; print DH $language_file; close(DH); open(DH, ">$skin") or die "Cannot open $skin! $!"; print DH $skin_file; close(DH); open(DH, ">$data") or die "Cannot open $data! $!"; print DH $data_file; close(DH); open(DH, ">$config") or die "Cannot open $config! $!"; print DH $config_file; close(DH); open(DH, ">$passfile") or die "Cannot open $passfile! $!"; print DH $crypted_password; close(DH); open(DH, ">$version_info") or die "Cannot open $version_info! $!"; print DH $version; close(DH); chmod 0777, $inputs, $style, $language, $skin, $data, $config, $passfile, $version_info; $inputs =~ s/$dir\///; $style =~ s/$dir\///; $language =~ s/$dir\///; $skin =~ s/$dir\///; $data =~ s/$dir\///; $config =~ s/$dir\///; $passfile =~ s/$dir\///; $version_info =~ s/$dir\///; $info_title = "Free Perl Mailer - Installation"; $info_color = "#7083c7"; $info = qq(
Your FPM has been successfully installed!

Directory and files created:
Your default password is: $default_password

Enjoy your new Free Perl Mailer!

); $info =~ s/\t//g; &info; } ########### Read files ################################################# sub read_files{ ######### Read inputs file open(DH, "<$inputs") or die "Cannot open $inputs! $!"; @fields = ; close (DH); splice @fields, 0, 8; # remove the first 8 lines ######### Read style file open(DH, "<$style") or die "Cannot open $style! $!"; while(){ $css .= $_; } close(DH); ######### Read language file open(DH, "<$language") or die "Cannot open $language! $!"; my @temp = ; close(DH); foreach(@temp){ chomp $_; my @pair = split(/<==>/, $_); $fpmlang{$pair[0]} = $pair[1]; } ######### Read skin file open(DH, "<$skin") or die "Cannot open $skin! $!"; my @temps = ; close(DH); foreach(@temps){ chomp $_; my @pair = split(/<==>/, $_); $fpmskin{$pair[0]} = $pair[1]; } ######### Read data file #open(DH, "<$data") or die "Cannot open $data! $!"; #close(DH); ######### Read config file open(DH, "<$config") or die "Cannot open $config! $!"; my @tmp = ; close(DH); foreach(@tmp){ chomp $_; my @pair = split(/<==>/, $_); $fpmconfig{$pair[0]} = $pair[1]; } } ########### Form ####################################################### sub form{ &read_files; my $vietuni; my $vietuni_enabled; if($fpmconfig{'VIETNAMESE_WRITING'} eq "yes"){ $vietuni = qq( ); $vietuni =~ s/\t\t//g; $vietuni_enabled = qq(onkeyup="telexingVietUC(this,event)"); } if($fpmconfig{'ANTI_SPAM'} == 1){ &set_cookie; } else{ print $conttype; # Header is printed by set_cookie } print qq~ $fpmlang{'TITLE'} $css $vietuni
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

~; } else{ print qq~ $fpmlang{'TITLE'}

~; } if($fpmlang{'TEXT'} or ($fpmlang{'ANTI_SPAM_MSG_4'} and ($fpmconfig{'ANTI_SPAM'} == 1))){ print qq~
~; if($fpmlang{'TEXT'}){ print "$fpmlang{'TEXT'} "; } if($fpmlang{'ANTI_SPAM_MSG_4'} and ($fpmconfig{'ANTI_SPAM'} == 1)){ print "$fpmlang{'ANTI_SPAM_MSG_4'} "; } print qq~

~; } print qq~ ~; #0:TYPE|1:NAME|2:SIZE|3:VALUE|4:MAXLENGTH|5:CHECKED|6:COLS|7:ROWS|8:CAPTION|9:STATUS|10:SRC|11:ACCESSKEY|12:JAVASCRIPT|13:|14:REQUIREMENTS|15:OPRIONS or RADIOS foreach(@fields){ chomp $_; my @cont = split(/\|/, $_); my $required; if(lc $cont[14] eq "yes"){ $required = "($fpmlang{'REQUIRED'})"; } if($cont[9] eq "on"){ if(lc $cont[0] eq "text"){ if(lc $cont[1] eq "fpm_antispam"){ if ($fpmconfig{'ANTI_SPAM'} == 1){ print qq~ ~; } } else{ print qq~ ~; } } elsif(lc $cont[0] eq "radio"){ print qq~ ~; } elsif(lc $cont[0] eq "select"){ print qq~ ~; } elsif(lc $cont[0] eq "textarea"){ print qq~ ~; if($fpmconfig{'VIETNAMESE_WRITING'} eq "yes"){ print qq~ ~; } } elsif(lc $cont[0] eq "checkbox"){ print qq~ ~; } elsif(lc $cont[0] eq "submit"){ print qq~ ~; } } } print qq~
$cont[8]:
$random_num
\&larr\; $fpmlang{'ANTI_SPAM_MSG'}
$cont[8]:
$required
$cont[8]$required: ~; my @radios = split(/\+\+/, $cont[15]); foreach(@radios){ if($_ =~ /(.+)\:checked$/i){ $_ =~ s/:checked//i; print qq~ $_ ~; } else{ print qq~ $_ ~; } } print qq~
$cont[8]:
$required
$cont[8]:
$required
~; if($fpmlang{'VIETNAMESE'}){ print "$fpmlang{'VIETNAMESE'}:\n"; } else{ print "Vietnamese typing:"; } print qq~ Off Telex VNI VIQR
$cont[8]:
$required
$cont[3]
~; } elsif(lc $cont[0] eq "button"){ print qq~ ~; } elsif(lc $cont[0] eq "reset"){ print qq~
~; if(($fpmconfig{'SHOW_LOGIN'} eq "yes") or ($fpmconfig{'SHOW_HOMEPAGE'} eq "yes")){ print "
"; } if($fpmconfig{'SHOW_LOGIN'} eq "yes"){ print qq~ [$fpmlang{'ADMIN'}] ~; } if($fpmconfig{'SHOW_HOMEPAGE'} eq "yes"){ print qq~ [$fpmlang{'HOMEPAGE'}] ~; } print qq~ $tdpn
~; } ########### Preview #################################################### sub preview{ &read_files; &check_input; #if invalid break here if($fpmconfig{'PREVIEW'} eq "yes"){ print $conttype; print qq~ $fpmlang{'TITLE'} $css
~; if($fpmlang{'PREVIEW'}){ print qq~ $fpmlang{'PREVIEW'}

~; } if($fpmlang{'PREVIEW_MSG'}){ print qq~
$fpmlang{'PREVIEW_MSG'} $fpmlang{'SEND_NOW'}

~; } print qq~
~; foreach(@active_fields){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input if($fpmconfig{'SEND_HTML_MAIL'} eq "yes"){ $feld_wert =~ s/\n/
\n/g; } if(($_ ne "fpm_antispam") or ($fpmconfig{'ANTISPAM'} == 1)){ # If field is not "antispam" or ANTI_SPAM is active print qq~ ~; } } print qq~
$active_field_captions{$_}: $feld_wert
IP: $ip

~; if($fpmlang{'PREVIEW_MSG_2'}){ print qq~
$fpmlang{'PREVIEW_MSG_2'} $fpmlang{'GO_BACK'}.

~; } foreach(@active_fields){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input print qq~ ~; } print qq~
$tdpn
~; } else{ &sendnow; } } ########### Check Input ################################################ sub check_input{ $info = ""; # Check anti spam code if($fpmconfig{'ANTI_SPAM'} == 1){ my $fpm_cookie = cookie("FPM"); my $fpm_antispam = $cgi->param('fpm_antispam'); if($fpm_cookie ne $fpm_antispam){ $info = $fpmlang{'ANTI_SPAM_MSG_2'}; $info .= "
\n"; $info .= qq(
); $info =~ s/\t//g; $info_title = "$fpmlang{'PLEASE_FILL_IN_ALL'}"; &info; # Break here if invalid } } foreach(@fields){ chomp $_; my @cont = split(/\|/, $_); if(($cont[0] ne "submit") and ($cont[0] ne "reset") and ($cont[0] ne "button")){ if($cont[9] eq "on"){ push @active_fields, $cont[1]; $active_field_captions{$cont[1]} = $cont[8]; } if(($cont[14] eq "yes") and ($cont[1] ne "fpm_antispam")){ push @required_fields, $cont[1]; } } } foreach(@required_fields){ my $feld_wert = $cgi->param($_); if((!$feld_wert) or ($feld_wert =~ /^\s*?$/g) or ($feld_wert =~ /^\n*?$/g)){ $feld_wert = "$fpmlang{'REQUIRED'}"; push @empty_required_fields, $_; $info .= "" . $active_field_captions{$_} . ": " . $feld_wert . "
\n"; } } if(@empty_required_fields > 0){ $info .= "
$fpmlang{'GO_BACK_AND_FILL_IN'} "; if(@empty_required_fields == 1){ $info .= $fpmlang{'THIS_FIELD'}; } else{ $info .= $fpmlang{'THESE_FIELDS'}; } $info .= "
\n"; $info .= qq(
); $info =~ s/\t//g; $info_title = "$fpmlang{'PLEASE_FILL_IN_ALL'}"; &info; } } ########### Sub Safe Input ############################################# sub safe{ $_[1] =~ s//>/g; $_[1] =~ s/\"/"/g; $_[1] =~ s/\|/&\#5;/g; } ################### Set Cookie ######################################### sub set_cookie{ my @nums = ("a" .. "z", "0" .. "9"); $random_num = join ("", @nums[map{rand @nums}(1 .. 8)]); ################### Cookie setzen ############################## my $cookie_to_set = cookie( -NAME => "FPM", -VALUE => "$random_num"); print header(-COOKIE => $cookie_to_set); ################################################################ } ########### Send now ################################################### sub sendnow{ if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } &read_files; &check_input; # Break here if invalid if($fpmconfig{'ANTI_SPAM'} == 1){ $conttype = ""; # Header is printed by set_cookie &set_cookie; } my ($his_message, $logs); my $my_email = $fpmconfig{'OWNER_EMAIL'}; if((!$my_email) or ($my_email eq "you\@yourserver.com")){ $info = qq(Sorry!

\n The message could not be sent, because the webmaster did not enter a correct e-mail address.

\n Please inform him/her about this error!); &info; } if($fpmconfig{'SEND_HTML_MAIL'} eq "yes"){ my $his_message_body; my $his_message_head = qq( $fpm_subject $css ); my $his_message_foot = qq(
IP: $ip
); foreach(@active_fields){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input $feld_wert =~ s/\n/
\n/g; $his_message_body .= qq( $active_field_captions{$_}: $feld_wert ); } $his_message = $his_message_head . $his_message_body . $his_message_foot; } else{ foreach(@active_fields){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input $feld_wert =~ s/\n/\n\t\t/g; $his_message .= $active_field_captions{$_} . ":\t\t " . $feld_wert . "\n"; } $his_message .= "IP:\t\t " . $ip ."\n"; } if($fpmconfig{'WRITE_LOGS'} eq "yes"){ $logs = $sign_time . "\n"; $logs .= "Message ID: " . $sign_time_in_sec . "\n"; foreach(@active_fields){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input $feld_wert =~ s/\n/\n\t\t/g; $logs .= $_ . ":\t\t " . $feld_wert . "\n"; } $logs .= "IP:\t\t " . $ip ."\n"; $logs .= "-" x 80 . "\n"; if($fpmconfig{'WRITE_LOGS_MODE'} eq "daily"){ $data = "$dir/data_".$data_daily.".fpm"; open(DH, ">>$data") or die "Cannot open $data $!"; print DH $logs; close(DH); } elsif($fpmconfig{'WRITE_LOGS_MODE'} eq "monthly"){ $data = "$dir/data_".$data_monthly.".fpm"; open(DH, ">>$data") or die "Cannot open $data $!"; print DH $logs; close(DH); } else{ open(DH, ">>$data") or die "Cannot open $data! $!"; print DH $logs; close(DH); } } ####### Collect E-Mail Addresses #################### if($fpmconfig{'COLLECT_EMAILS'} eq "yes"){ my $mailing_list_file; my $ml_num = 0; foreach(@active_fields){ if($_ eq "name"){ $ml_num++; } if($_ eq "email"){ $ml_num++; } } if($ml_num == 2){ my $ml_name = $cgi->param('name'); my $ml_email = $cgi->param('email'); ####### Check if e-mail already exist in the mailing list my ($ct_name, $ct_email, @contacts); my $num = 0; if(-e $mailing_list){ open(DH,"<$mailing_list") or die "Cannot open $mailing_list! $!"; @contacts = ; close(DH); } foreach(@contacts){ chomp $_; ($ct_name, $ct_email) = split(/<==>/,$_); if($ml_email eq $ct_email){ $num++; } } if($num == 0){ &safe($ml_name, $ml_email); #safe inputs $mailing_list_file = "$ml_name<==>$ml_email\n"; open(DH, ">>$mailing_list") or die "Cannot open $mailing_list! $!"; print DH $mailing_list_file; close(DH); } } } ####### Send E-mails ################################ $ENV{PATH} = ""; if($SEND_MAIL){ open (MAIL,"| $SEND_MAIL $my_email"); print MAIL "To: $my_email\n"; print MAIL "From: $my_email\n"; print MAIL "Reply-to: $my_email\n"; print MAIL "X-Mailer: Free Perl Mailer\n"; print MAIL "Subject: $fpm_subject\n"; if($fpmconfig{'SEND_HTML_MAIL'} eq "yes"){ print MAIL "Content-type: text/html\n\n"; } print MAIL "$his_message"; print MAIL "\n\n"; close (MAIL); } if($smtp){ $smtp->mail($my_email); $smtp->to($my_email); $smtp->data(); $smtp->datasend("To: $my_email\n"); $smtp->datasend("From: $my_email\n"); $smtp->datasend("Subject: $fpm_subject\n"); if($fpmconfig{'SEND_HTML_MAIL'} eq "yes"){ $smtp->datasend("Content-type: text/html\n\n"); } $smtp->datasend("$his_message\n\n"); $smtp->dataend(); $smtp->quit; } } ########### Thanks ##################################################### sub thanks{ print $conttype; print qq~ $fpmlang{'TITLE'} $css
$fpmlang{'THANK_TITLE'}

$fpmlang{'THANK_MSG'}

$tdpn
~; } ########### Login ###################################################### sub login{ &read_files; $info_title = "FPM Login"; $info_color = "$fpmskin{'TABLE_BGCOLOR'}"; $info_width = "400"; $info = qq(
Please enter password: ); if($demo == 1){ $info .= qq(); } else{ $info .= qq(); } $info .= qq(

); &info; } ########### Control Panel ################################################### sub control{ &read_files; my $password = $cgi->param('password'); print $conttype; print qq~ Free Perl Mailer - Control Panel
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

~; } else{ if($fpmlang{'TITLE'}){ print qq~ $fpmlang{'TITLE'} - Control Panel

~; } else{ print qq~ Free Perl Mailer - Control Panel

~; } } print qq~
Main Menu
Please choose an action and click continue



~; if($fpmconfig{'UPDATE_SERVICE'} eq "hidden"){ print qq~ ~; } elsif($fpmconfig{'UPDATE_SERVICE'} eq "shown"){ print qq~

Update Notification

~; } print qq~
Rate FPM @ The CGI Resurces Index
The scale is 1 - 10, with 1 being poor and 10 being excellent

$tdpn
~; } ########### Edit Configuration ############################################## sub edit_config{ &read_files; my $password = $cgi->param('password'); print $conttype; print qq~ $fpmlang{'TITLE'} $css
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

Control Panel ~; } else{ if($fpmlang{'TITLE'}){ print qq~ $fpmlang{'TITLE'} - Control Panel

~; } else{ print qq~ Free Perl Mailer - Control Panel

~; } } print qq~
Here you can customize your FPG, change user name, e-mail and password. It's strongly recommended that you change the content of all red fields! $demo_msg

~; if(($fpmconfig{'OWNER_EMAIL'} eq 'you@yourserver.com') or ($fpmconfig{'OWNER_EMAIL'} eq 'you\@yourserver.com')){ print qq~ ~; } else{ print qq~ ~; } print qq~ ~; if($password eq "tridung"){ print qq~ ~; } else{ print qq~ ~; } print qq~
Your Name:
Your E-Mail: must change
Login Password: must change
Your Homepage:
Control Panel: ~; if($fpmconfig{'SHOW_LOGIN'} eq "yes"){ print qq~ Show the Control Panel link on the Form-Page ~; } else{ print qq~ Show the Control Panel link on the Form-Page ~; } print qq~
Homepage: ~; if($fpmconfig{'SHOW_HOMEPAGE'} eq "yes"){ print qq~ Show the Homepage link on the Form-Page ~; } else{ print qq~ Show the Homepage link on the Form-Page ~; } print qq~
Anti Spam: ~; if($fpmconfig{'ANTI_SPAM'} eq "1"){ print qq~ Require visitor to type a random code (8 digits) every time he wants to send a message ~; } else{ print qq~ Require visitor to type a random code (8 digits) every time he wants to send a message ~; } print qq~
Preview: ~; if($fpmconfig{'PREVIEW'} eq "yes"){ print qq~ Show preview before sending message ~; } else{ print qq~ Show preview before sending message ~; } print qq~
Log File: ~; if($fpmconfig{'WRITE_LOGS'} eq "yes"){ print qq~ Create copy of all sent messages ~; } else{ print qq~ Create copy of all sent messages ~; } print qq~
Log File Mode: ~; my ($daily, $monthly, $default); if($fpmconfig{'WRITE_LOGS_MODE'} eq "daily"){ $daily = "checked"; } elsif($fpmconfig{'WRITE_LOGS_MODE'} eq "monthly"){ $monthly = "checked"; } else{ $default = "checked"; } print qq~ default monthly daily
Mailing List: ~; if($fpmconfig{'COLLECT_EMAILS'} eq "yes"){ print qq~ Save e-mail senders address to mailing list ~; } else{ print qq~ Save senders e-mail address to mailing list ~; } print qq~
HTML Mail: ~; if($fpmconfig{'SEND_HTML_MAIL'} eq "yes"){ print qq~ Send e-mail in HTML format ~; } else{ print qq~ Send e-mail in HTML format ~; } print qq~
Vietnamese Typing: ~; if($fpmconfig{'VIETNAMESE_WRITING'} eq "yes"){ print qq~ Show Vietnamese typing tool on Form-Page ~; } else{ print qq~ Show Vietnamese typing tool on Form-Page ~; } print qq~
Vietnamese Typing Tool URL:
Update Service: ~; if($fpmconfig{'UPDATE_SERVICE'} eq "hidden"){ print qq~ Hide Update Notification in the Control Panel (Popup if update available) ~; } else{ print qq~ Hide Update Notification in the Control Panel (Popup if update available) ~; } print qq~
$tdpn
~; } ########### Save Preferences ########################################### sub save_config{ &read_files; if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } my $new_password = $cgi->param('fpm_password'); if($new_password eq "tridung"){ $info = qq(You must change the password to protect your FPM!

The current password is tridung

[go back]); &info; } if(!$new_password){ $info = qq(The field Password cannot be blank!

You must enter a password to protect your FPM!

[go back]); &info; } my @params = $cgi->param(); my %fpmconfig; foreach(@params){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input $fpmconfig{$_} = $feld_wert; } if(!$fpmconfig{'fpm_owner_name'}){ $info = qq(The field Your Name cannot be blank!

[go back]); &info; } if(!$fpmconfig{'fpm_owner_email'}){ $info = qq(The field Your E-Mail cannot be blank!

[go back]); &info; } elsif($fpmconfig{'fpm_owner_email'} eq 'you@yourserver.com'){ $info = qq(The field Your E-Mail contains an invalid e-mail address ($fpmconfig{'fpm_owner_email'})!

It's strongly recommended that you enter your e-mail address, where all messages will be sent to.

[go back]); &info; } if($fpmconfig{'fpm_preview'}){ $fpmconfig{'fpm_preview'} = "yes"; } else{ $fpmconfig{'fpm_preview'} = "no"; } if($fpmconfig{'fpm_vietnamese_writing'}){ $fpmconfig{'fpm_vietnamese_writing'} = "yes"; if(!$fpmconfig{'fpm_writing_tool'}){ $info = qq(The field Vietnamese Typing Tool URL cannot be blank while the field Vietnamese Typing is checked!

[go back]); &info; } } else{ $fpmconfig{'fpm_vietnamese_writing'} = "no"; } if($fpmconfig{'fpm_send_html_mail'}){ $fpmconfig{'fpm_send_html_mail'} = "yes"; } else{ $fpmconfig{'fpm_send_html_mail'} = "no"; } if($fpmconfig{'fpm_write_logs'}){ $fpmconfig{'fpm_write_logs'} = "yes"; } else{ $fpmconfig{'fpm_write_logs'} = "no"; } if(($fpmconfig{'fpm_write_logs_mode'} ne "daily") and ($fpmconfig{'fpm_write_logs_mode'} ne "monthly")){ $fpmconfig{'fpm_write_logs_mode'} = "default"; } if($fpmconfig{'fpm_collect_emails'}){ $fpmconfig{'fpm_collect_emails'} = "yes"; } else{ $fpmconfig{'fpm_collect_emails'} = "no"; } if($fpmconfig{'fpm_antispam'}){ $fpmconfig{'fpm_antispam'} = "1"; } else{ $fpmconfig{'fpm_antispam'} = "0"; } if($fpmconfig{'fpm_show_login'}){ $fpmconfig{'fpm_show_login'} = "yes"; } else{ $fpmconfig{'fpm_show_login'} = "no"; } if($fpmconfig{'fpm_show_homepage'}){ $fpmconfig{'fpm_show_homepage'} = "yes"; } else{ $fpmconfig{'fpm_show_homepage'} = "no"; } if($fpmconfig{'fpm_update_service'}){ $fpmconfig{'fpm_update_service'} = "hidden"; } else{ $fpmconfig{'fpm_update_service'} = "show"; } my $config_file = qq(OWNER_NAME<==>$fpmconfig{'fpm_owner_name'} OWNER_EMAIL<==>$fpmconfig{'fpm_owner_email'} HOMEPAGE<==>$fpmconfig{'fpm_homepage'} PREVIEW<==>$fpmconfig{'fpm_preview'} VIETNAMESE_WRITING<==>$fpmconfig{'fpm_vietnamese_writing'} WRITING_TOOL<==>$fpmconfig{'fpm_writing_tool'} SEND_HTML_MAIL<==>$fpmconfig{'fpm_send_html_mail'} WRITE_LOGS<==>$fpmconfig{'fpm_write_logs'} WRITE_LOGS_MODE<==>$fpmconfig{'fpm_write_logs_mode'} COLLECT_EMAILS<==>$fpmconfig{'fpm_collect_emails'} ANTI_SPAM<==>$fpmconfig{'fpm_antispam'} SHOW_LOGIN<==>$fpmconfig{'fpm_show_login'} SHOW_HOMEPAGE<==>$fpmconfig{'fpm_show_homepage'} UPDATE_SERVICE<==>$fpmconfig{'fpm_update_service'} UPDATE_SERVICE_MAIL<==> ); $config_file =~ s/\t//g; open(DH, ">$config") or die "Cannot open $config! $!"; print DH $config_file; close(DH); my $crypted_password = crypt($new_password, "td"); open(DH, ">$passfile") or die "Cannot open $passfile! $!"; print DH $crypted_password; close(DH); $info_title = "Free Perl Mailer - Control Panel"; $info_color = "$fpmskin{'TABLE_BGCOLOR'}"; $info = qq(
All changes have been successfully saved!

Click continue to open the Control Panel Main Menu or cancel to return to the FPM form-page.


); &info; } ########### Edit Languages ############################################# sub edit_lang{ &read_files; my $password = $cgi->param('password'); print $conttype; print qq~ $fpmlang{'TITLE'} $css
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

Control Panel ~; } else{ if($fpmlang{'TITLE'}){ print qq~ $fpmlang{'TITLE'} - Control Panel

~; } else{ print qq~ Free Perl Mailer - Control Panel

~; } } print qq~
Here you can edit the FPG language file. $demo_msg

Charset:
FPM Title:
FPM Info Text:
REQUIRED:
PLEASE_FILL_IN_ALL:
GO_BACK_AND_FILL_IN:
THIS_FIELD:
THESE_FIELDS:
CLICK_HERE:
GO_BACK:
CONTINUE:
SEND_NOW:
PREVIEW:
Preview Message 1:
Preview Message 2:
THANK_TITLE:
Thanks Message:
SUCCESSFULLY_SENT:
Anti Spam Message 1:
Anti Spam Message 2:
Anti Spam Message 3:
Anti Spam Message 4:
Control Panel:
Homepage:
Vietnamese Typing:
$tdpn
~; } ########### Save Langugages ############################################ sub save_lang{ &read_files; my $password = $cgi->param('password'); my $blank_num = 0; my $error_msg; if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } my @params = $cgi->param(); my %fpmlang; foreach(@params){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input $feld_wert =~ s/\n/ /g; # no line break $fpmlang{$_} = $feld_wert; if(!$feld_wert){ $blank_num++; } } if($blank_num >= 2){ $error_msg = qq(Attention: $blank_num fields were blank!

); } elsif($blank_num == 1){ $error_msg = qq(Attention: $blank_num field was blank!

); } my $lang_file = qq(English for FPM Version 1.0 Author: Tri Dung Nguyen Internet: www.vitinh.de CHARSET<==>$fpmlang{'charset'} TITLE<==>$fpmlang{'fpm_title'} TEXT<==>$fpmlang{'fpm_text'} REQUIRED<==>$fpmlang{'fpm_required'} PLEASE_FILL_IN_ALL<==>$fpmlang{'fpm_please_fill_in_all'} GO_BACK_AND_FILL_IN<==>$fpmlang{'fpm_go_back_and_fill_in'} THIS_FIELD<==>$fpmlang{'fpm_this_field'} THESE_FIELDS<==>$fpmlang{'fpm_these_fields'} CLICK_HERE<==>$fpmlang{'fpm_click_here'} GO_BACK<==>$fpmlang{'fpm_go_back'} CONTINUE<==>$fpmlang{'fpm_continue'} SEND_NOW<==>$fpmlang{'fpm_send_now'} PREVIEW<==>$fpmlang{'fpm_preview'} PREVIEW_MSG<==>$fpmlang{'fpm_preview_msg'} PREVIEW_MSG_2<==>$fpmlang{'fpm_preview_msg_2'} THANK_TITLE<==>$fpmlang{'fpm_thank_title'} THANK_MSG<==>$fpmlang{'fpm_thank_msg'} SUCCESSFULLY_SENT<==>$fpmlang{'fpm_successfully_sent'} ANTI_SPAM_MSG<==>$fpmlang{'fpm_anti_spam_msg'} ANTI_SPAM_MSG_2<==>$fpmlang{'fpm_anti_spam_msg_2'} ANTI_SPAM_MSG_3<==>$fpmlang{'fpm_anti_spam_msg_3'} ANTI_SPAM_MSG_4<==>$fpmlang{'fpm_anti_spam_msg_4'} ADMIN<==>$fpmlang{'fpm_admin'} HOMEPAGE<==>$fpmlang{'fpm_homepage'} VIETNAMESE<==>$fpmlang{'fpm_vietnamese'} ); $lang_file =~ s/\t//g; open(DH, ">$language") or die "Cannot open $language! $!"; print DH $lang_file; close(DH); $info_title = "Free Perl Mailer - Control Panel"; $info_color = "$fpmskin{'TABLE_BGCOLOR'}"; $info = qq(
All changes have been successfully saved!

$error_msg Click continue to open the Control Panel Main Menu or cancel to return to the FPM form-page.


); if($blank_num > 0){ $info .= qq( ); } $info .= qq(
); &info; } ########### Edit Skin ################################################### sub edit_skin{ &read_files; my $fpm_style_sheets = $css; $fpm_style_sheets =~ s/\"/"/g; $fpm_style_sheets =~ s//>/g; my $password = $cgi->param('password'); print $conttype; print qq~ $fpmlang{'TITLE'} $css
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

Control Panel ~; } else{ if($fpmlang{'TITLE'}){ print qq~ $fpmlang{'TITLE'} - Control Panel

~; } else{ print qq~ Free Perl Mailer - Control Panel

~; } } print qq~
Here you can customize FPG (change colors, dimension, alignment, edit style sheets...) $demo_msg

Background Color:
Background URL:
Title Image URL:
Big Table BgColor:
Big Table Background URL:
Big Table Width: default: 100%
Big Table Height: default: 100%
Big Table TD Height: default: 100%
Big Table Border: default: 0
Big Table Spacing: default: 0
Big Table Padding: default: 0
Big Table Align: default: center
Big Table TD Align: default: center
Big Table vAlign: default: middle
Big Table Class: default: text
Table BgColor: default: #7083c7
Table Background URL:
Table TD BgColor: default: #f0f0f0
Table TD Background URL:
Table Info-Text BgColor: default: white
Table Submit-Area BgColor: default: #7083c7
Table Width: default: 500
Table Height: default: 100%
Table Border: default: 0
Table Spacing: default: 1
Table Padding: default: 4
Table Align: default: center
Table TD Align: default: center
Table TD vAlign: default: top
Table Class: default: text
Control Panel Width: default: 650
Style Sheets:
$tdpn
~; } ########### Save Skin ################################################## sub save_skin{ &read_files; if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } my $password = $cgi->param('password'); my $fpm_style_sheets = $cgi->param('fpm_style_sheets'); $fpm_style_sheets =~ s/"/\"/g; $fpm_style_sheets =~ s/<//g; my $blank_num = 0; my $error_msg; if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } my @params = $cgi->param(); my %new_fpmskin; foreach(@params){ my $feld_wert = $cgi->param($_); &safe($_, $feld_wert); #safe input $feld_wert =~ s/\n/ /g; # no line break $new_fpmskin{$_} = $feld_wert; if(!$feld_wert){ $blank_num++; } } if($blank_num >= 2){ $error_msg = qq(Attention: $blank_num fields were blank!

); } elsif($blank_num == 1){ $error_msg = qq(Attention: $blank_num field was blank!

); } my $skin_file = qq(Standard Skin for FPM Version $version Author: Tri Dung Nguyen Internet: www.vitinh.de BGCOLOR<==>$new_fpmskin{'fpm_bgcolor'} BACKGROUND<==>$new_fpmskin{'fpm_background'} TITLE_IMAGE_URL<==>$new_fpmskin{'fpm_title_image_url'} BIG_TABLE_BGCOLOR<==>$new_fpmskin{'fpm_big_table_bgcolor'} BIG_TABLE_BACKGROUND<==>$new_fpmskin{'fpm_big_table_background'} BIG_TABLE_WIDTH<==>$new_fpmskin{'fpm_big_table_width'} BIG_TABLE_HEIGHT<==>$new_fpmskin{'fpm_big_table_height'} BIG_TABLE_TD_HEIGHT<==>$new_fpmskin{'fpm_big_table_td_height'} BIG_TABLE_BORDER<==>$new_fpmskin{'fpm_big_table_border'} BIG_TABLE_SPACING<==>$new_fpmskin{'fpm_big_table_spacing'} BIG_TABLE_PADDING<==>$new_fpmskin{'fpm_big_table_padding'} BIG_TABLE_ALIGN<==>$new_fpmskin{'fpm_big_table_align'} BIG_TABLE_TD_ALIGN<==>$new_fpmskin{'fpm_big_table_td_align'} BIG_TABLE_VALIGN<==>$new_fpmskin{'fpm_big_table_valign'} BIG_TABLE_CLASS<==>$new_fpmskin{'fpm_big_table_class'} TABLE_BGCOLOR<==>$new_fpmskin{'fpm_table_bgcolor'} TABLE_BACKGROUND<==>$new_fpmskin{'fpm_table_background'} TABLE_TD_BGCOLOR<==>$new_fpmskin{'fpm_table_td_bgcolor'} TABLE_TD_BACKGROUND<==>$new_fpmskin{'fpm_table_td_background'} TABLE_TEXT_BGCOLOR<==>$new_fpmskin{'fpm_table_text_bgcolor'} TABLE_SUBMIT_BGCOLOR<==>$new_fpmskin{'fpm_table_submit_bgcolor'} TABLE_WIDTH<==>$new_fpmskin{'fpm_table_width'} TABLE_HEIGHT<==>$new_fpmskin{'fpm_table_height'} TABLE_BORDER<==>$new_fpmskin{'fpm_table_border'} TABLE_SPACING<==>$new_fpmskin{'fpm_table_spacing'} TABLE_PADDING<==>$new_fpmskin{'fpm_table_padding'} TABLE_ALIGN<==>$new_fpmskin{'fpm_table_align'} TABLE_TD_ALIGN<==>$new_fpmskin{'fpm_table_td_align'} TABLE_TD_VALIGN<==>$new_fpmskin{'fpm_table_td_valign'} TABLE_CLASS<==>$new_fpmskin{'fpm_table_class'} CONTROL_PANEL_WIDTH<==>$new_fpmskin{'fpm_control_panel_width'} ); $skin_file =~ s/\t//g; open(DH, ">$skin") or die "Cannot open $skin! $!"; print DH $skin_file; close(DH); open(DH, ">$style") or die "Cannot open $style! $!"; print DH $fpm_style_sheets; close(DH); $info_title = "Free Perl Mailer - Control Panel"; $info_color = "$fpmskin{'TABLE_BGCOLOR'}"; $info = qq(
All changes have been successfully saved!

$error_msg Click continue to open the Control Panel Main Menu or cancel to return to the FPM form-page.


); if($blank_num > 0){ $info .= qq( ); } $info .= qq(
); &info; } ########### Edit Inputs ################################################ sub edit_inputs{ &read_files; my $fpm_inputs = join "", @fields; $fpm_inputs =~ s//>/g; $fpm_inputs =~ s/\"/"/g; $inputs_file =~ s//>/g; $inputs_file =~ s/\"/"/g; my @temp = split(/\n/, $inputs_file); splice @temp, 0, 8; # remove the first 8 lines $inputs_file = join "\n", @temp; my $password = $cgi->param('password'); print $conttype; print qq~ $fpmlang{'TITLE'} $css
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

Control Panel ~; } else{ if($fpmlang{'TITLE'}){ print qq~ $fpmlang{'TITLE'} - Control Panel

~; } else{ print qq~ Free Perl Mailer - Control Panel

~; } } print qq~
Here you can manually edit the inputs file. Every line in this file will create an input field. The order of these lines is also the order of the input fields on the Form-Page. The attributes of each input field are seperated by "|":

1|2|3| 4|5|6| 7|8|9| 10|11|12| 13| 14|15|16

1: type
2: name
3: size
4: value
5: maxlength
6: checked (checkbox only)
7: cols
8: rows
9: caption
10: status (on/off)
11: src (image button)
12: accesskey
13: javascript
15: requirements (yes/no)
16: options/radios
Position 14: not in use

The options in select tags and the radio inputs are separated by "++"

Attention:
  • Do not remove the fields name, email, fpm_antispam and the 2 buttons submit and reset
  • Do not remove the [FPM_PLACE_HOLDER_XXX] lines!
  • Normal buttons must be placed between submit and reset
  • Checkboxes must be placed between fpm_antispam and submit
  • Type "&#5;" if you want to use the character "|" in captions
  • All field atrributes do not allow UPPER CASE, except the captions
  • Field name (position 2) may not contains space or non-alphabetic characters
  • It's recommended that you copy the content of the following textarea and edit it with a text editor (like Notepad or UltraEdit...)
$demo_msg

~; if($fpm_inputs ne $inputs_file){ print qq~ ~; } print qq~
$tdpn
~; } ########### Save Inputs ################################################ sub save_inputs{ if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } &read_files; my %required = ("name" => "Name", "email" => "E-Mail", "text" => "fpm_antispam", "submit" => "Send", "reset" => "Reset"); my $password = $cgi->param('password'); my $fpm_inputs = $cgi->param('fpm_inputs'); my @temp = split(/\n/, $fpm_inputs); foreach(@temp){ if($_ =~ /^text\|name\|/i){ delete $required{"name"}; } if($_ =~ /^text\|email\|/i){ delete $required{"email"}; } if($_ =~ /^text\|fpm_antispam/i){ delete $required{"text"}; } if($_ =~ /^submit\|/i){ delete $required{"submit"}; } if($_ =~ /^reset\|/i){ delete $required{"reset"}; } } my ($key, $error_msg, $num); foreach $key (keys %required){ if(exists $required{$key}){ $num++; if($required{$key} eq "fpm_antispam"){ $error_msg .= "Text field fpm_antispam not found! If you don't like to use the Anti-Spam function, you can disable it in the configuration file.

"; } elsif($key eq "name"){ $error_msg .= "Text field $key not found! If you don't like to use this field, you can disable it in the configuration file.

"; } elsif($key eq "email"){ $error_msg .= "Text field $key not found! If you don't like to use this field, you can disable it in the configuration file.

"; } else{ $error_msg .= "Button $key not found!

"; } } } if($num > 0){ $info = "
" . $error_msg; $info .= qq(
Please go back and check your input for errors!
); &info; } my $inputs_file = qq(Standard Inputs for FPM Version $version Author: Tri Dung Nguyen Internet: www.vitinh.de Please do not remove or change the NAME-field of the 6 lines: name, email, fpm_antispam, submit and reset 0:TYPE|1:NAME|2:SIZE|3:VALUE|4:MAXLENGTH|5:CHECKED|6:COLS|7:ROWS|8:CAPTION|9:STATUS|10:SRC|11:ACCESSKEY|12:JAVASCRIPT|13:|14:REQUIREMENT|15:OPTIONS/RADIOS ); # 1 new line here $inputs_file .= "\n" . $fpm_inputs; $inputs_file =~ s/\t//g; open(DH, ">$inputs") or die "Cannot open $inputs! $!"; print DH $inputs_file; close(DH); $info_title = "Free Perl Mailer - Control Panel"; $info_color = "$fpmskin{'TABLE_BGCOLOR'}"; $info = qq(
All changes have been successfully saved!

Click continue to open the Control Panel Main Menu or cancel to return to the FPM form-page.


); if($num > 0){ $info .= qq( ); } $info .= qq(
); &info; } ########### Check Pass ################################################# sub pass{ my $password = $cgi->param('password'); my $your_password = crypt($password, "td"); if(not(-e $passfile)){ $passfile =~ s/$dir\///; $dir =~ s/\.\///; $info_color = "red"; $info_title = "Password check failed!"; $info = "Cannot find the password file! "; $info .= "Did you delete the file $passfile? "; $info .= qq(You must re-install FPM! Do the steps below:
  • Backup all files in folder $dir
  • Delete folder $dir
  • Open your FPM with the browser - FPM will install itself.
  • Upload all backup-files to the folder $dir and chmod them to 777
); $info .= "If you are not the webmaster, please inform him/her about this error! We apologize for this inconvenience!"; &info; } open(DH, "<$passfile") or die "Cannot open $passfile! $!"; my $my_password = ; close(DH); if($your_password ne $my_password){ # Break here if invalid $info_color = "red"; $info_width = "400"; $info_title = "Forbidden"; $info = qq(
Invalid password!

); &info; } } ########### Mailing List ############################################### sub newsletter{ &read_files; my $password = $cgi->param('password'); my $vietuni; my $vietuni_enabled; if($fpmconfig{'VIETNAMESE_WRITING'} eq "yes"){ $vietuni = qq( ); $vietuni =~ s/\t\t//g; $vietuni_enabled = qq(onkeyup="telexingVietUC(this,event)"); } my $recis = ""; if(not(-e "$mailing_list")){ $recis = "(mailing list empty)"; } else{ $recis = qq( [view list]) ; } my @monate = ("","January","February","March","April","May","June","July","August","September","October","November","December"); print $conttype; print qq~ $fpmlang{'TITLE'} $css $vietuni
~; if($fpmskin{'TITLE_IMAGE_URL'}){ print qq~

~; } else{ print qq~ $fpmlang{'TITLE'}

~; } print qq~
Hello $fpmconfig{'OWNER_NAME'}, here you can send a newsletter to all saved e-mail addresses in the mailing list.

~; if($fpmconfig{'VIETNAMESE_WRITING'} eq "yes"){ print qq~ ~; } print qq~
Subject:
Greeting:
Recipient name: automatically inserted by FPM $recis
do not insert recipient name
After greeting: (comma, exclamation mark or nothing)
Message:
Font family:
Font color:
Font size:
Vietnamese typing: Off Telex VNI VIQR
$tdpn
~; } ########### Mailing List ############################################### sub pre_newsletter{ &read_files; my $password = $cgi->param('password'); my $greeting = $cgi->param('greeting'); my $insert_name = $cgi->param('insert_name'); my $message = $cgi->param('message'); my $subject = $cgi->param('subject'); my $pre_greeting = $greeting; $pre_greeting =~ s/\n/
\n/g; my $pre_message = $message; $pre_message =~ s/\n/
\n/g; my $pre_subject = $subject; $pre_subject =~ s/\n/
\n/g; my $font_family = $cgi->param('font_family'); my $font_size = $cgi->param('font_size'); my $color = $cgi->param('color'); my $sign = $cgi->param('sign'); my $test_msg = $message; $test_msg =~ s/\s//g; $test_msg =~ s/\n//g; if(!$message or !$test_msg){ $info_title = "Invalid input"; $info = "No message written!"; $info .= qq(
); &info; } &safe("",$greeting); &safe("",$pre_greeting); &safe("",$message); &safe("",$pre_message); &safe("",$subject); &safe("",$pre_subject); &safe("",$font_family); &safe("",$font_size); &safe("",$color); &safe("",$sign); print $conttype; print qq~ $fpmlang{'TITLE'} $css
Preview of your message

Hello $fpmconfig{'OWNER_NAME'}, please check your message and click send!

$pre_subject

~; print $pre_greeting; if($insert_name eq "yes"){ print " recipient name"; } print $sign; print qq~

$pre_message

$tdpn
~; } ########### Send Newsletter ############################################ sub send_newsletter{ if($demo == 1){ $info_title = "Permission denied!"; $info = $demo_msg_2; &info; } if(not(-e $mailing_list)){ $info_title = "No recipients!"; $info = "The message could not be sent, because the mailing list does not exist!"; $info .= qq(
); &info; } &read_files; my $password = $cgi->param('password'); my $subject = $cgi->param('subject'); my $greeting = $cgi->param('greeting'); my $insert_name = $cgi->param('insert_name'); my $message = $cgi->param('message'); my $test_msg = $message; $test_msg =~ s/\s//g; $test_msg =~ s/\n//g; if(!$message or !$test_msg){ $info_title = "Invalid input"; $info = "No message written!"; $info .= qq(
); &info; } &safe("",$message); $message =~ s/\n/
\n/g; my $my_email = $fpmconfig{'OWNER_EMAIL'}; my $font_family = $cgi->param('font_family'); my $font_size = $cgi->param('font_size'); my $color = $cgi->param('color'); my $sign = $cgi->param('sign'); ####### Load E-Mail Addresses ####################### my (@recipients, @data); open(DH, "<$mailing_list") or die "Cannot open $mailing_list! $!"; @data = ; close(DH); if(@data == 0){ $info_title = "No recipients!"; $info = "The message could not be sent, because the mailing list is empty!"; $info .= qq(
); &info; } ####### Send E-mails ################################ foreach(@data){ chomp $_; @recipients = split(/<==>/, $_); my $letter = qq(
); $letter .= $greeting; if($insert_name eq "yes"){ $letter .= " $recipients[0]"; } $letter .= $sign; $letter .= qq(

$message
); $letter =~ s/\t//g; #$info = $letter; #&info; $ENV{PATH} = ""; if($SEND_MAIL){ open (MAIL,"| $SEND_MAIL $my_email"); print MAIL "To: $recipients[1]\n"; print MAIL "From: $my_email\n"; print MAIL "Reply-to: $my_email\n"; print MAIL "X-Mailer: Free Perl Mailer\n"; print MAIL "Subject: $subject\n"; print MAIL "Content-type: text/html\n\n"; print MAIL "$letter"; print MAIL "\n\n"; close (MAIL); } if($smtp){ $smtp->mail($my_email); $smtp->to($recipients[1]); $smtp->data(); $smtp->datasend("To: $recipients[1]\n"); $smtp->datasend("From: $my_email\n"); $smtp->datasend("Subject: $subject\n"); $smtp->datasend("Content-type: text/html\n\n"); $smtp->datasend("$letter\n\n"); $smtp->dataend(); $smtp->quit; } } $info_title = "Successfully sent!"; $info_color = "#7083c7"; $info = qq(The message has been successfully sent to [); $info .= scalar @data; $info .= qq(] recipients.
); &info; } ########### View Mailing List ########################################## sub view_list{ &read_files; my (@recipients, @data); open(DH, "<$mailing_list") or die "Cannot open $mailing_list! $!"; @data = ; close(DH); print $conttype; print qq~ FPM Mailing List $css
FPM Mailing List

~; my $num = 1; foreach(@data){ chomp $_; @recipients = split(/<==>/, $_); print qq~ ~; $num++; } print qq~
Order Name E-Mail Address
$num $recipients[0] $recipients[1]
$tdpn
~; } ########### Anonymous E-mails ########################################## sub anonymous_mail{ $info_title = "Send Anonymous E-Mails"; $info_color = "orange"; $info = qq(
Not available in this version!
); &info; } ########### Inform user ################################################ sub info{ print $conttype; print qq~ $info_title
$info_title
$info
$tdpn
~; exit; }