KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.4.62
System : FreeBSD fbsdweb2.web.rcn.net 14.1-RELEASE FreeBSD 14.1-RELEASE releng/14.1-n267679-10e31f0946d8 GENERIC amd64
User : www ( 80)
PHP Version : 8.3.8
Disable Function : NONE
Directory :  /domains/djweb1/cgi-bin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /domains/djweb1/cgi-bin/nph-setra.bak
#!/usr/bin/perl

############################################################
# NPH-SETRA.PL
# Tuesday, 09 March 1999
#
# Pinkerton Computer Consultants, Inc.
# http://www.pcci.com
############################################################

###########################################################
# VARIABLES
###########################################################
# Get the form input
read (STDIN, $input, $ENV{'CONTENT_LENGTH'});

# Create variable arrays/values
@pairs = split(/&/, $input);
foreach $pair (@pairs)  {
	($name, $value) = split (/=/, $pair);
	$name =~ tr/+/ /;
	$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
	$value =~ tr/+/ /;
	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        if (defined($Config{$name})) {
            $Config{$name} = $value;
        }
        else {
			if ($Form{$name} && $value) {
				$Form{$name} = "$Form{$name}, $value";
			}
			elsif ($value) {
				push(@Field_Order,$name);
				$Form{$name} = $value;
			}
		}
}

###########################################################
# Declare required fields [@=arrays; $=variable]
# 
# @Required - required fields as specified in the form
# @imageHeader - Page logo as specified in the form
# $os - operating system
# $debug - debug flag as specified in the form
###########################################################
@Required = split(/,/,$Form{'required'});
@imageHeader = split(/,/,$Form{'image_header'});

# Default variables
$os='UNIX';
$debug=$Form{'debug'};

###########################################################
# PROGRAM FLOW
###########################################################
# Check Required Fields
&validateForm;

# Send Mail
if ($sendEmailFlag eq "1") {
	# E-mail to user
		&send_mail_T0_EMAIL_ADDR;
	# E-mail to organization
		&send_mail_T0_RECIPIENT;
}

###########################################################
# SUBROUTINES
###########################################################

###########################################################
# VALIDATE FORM ENTRIES
###########################################################
sub validateForm {
    # Local variables
    local($require, @error);

    # Validate required fields
    foreach $require (@Required) {
        # EMAIL field (contain)
        if ($require =~ 'email' && !&check_email($Form{$require})) {
			if (!$Form{$require}) {
				push(@error,'<B>' . $require . '</B>: missing field');
	        }
			else {
	            push(@error,'<B>' . $require . '</B>: invalid format');
			}
        }

        # credit_number field (equal)
        elsif ($require eq 'credit_number' && !&check_credit_number($Form{$require})) {
			if (!$Form{$require}) {
				push(@error,'<B>' . $require . '</B>: missing field');
	        }
			else {
	            push(@error,'<B>' . $require . '</B>: invalid format');
			}
        }

        # phone field (equal)
        elsif ($require =~ 'phone' && !&check_number($Form{$require}) ||
				$require =~ 'fax' && !&check_number($Form{$require})) {
			if (!$Form{$require}) {
				push(@error,'<B>' . $require . '</B>: missing field');
	        }
			else {
	            push(@error,'<B>' . $require . '</B>: invalid format');
			}
        }

        # OTHER fields
        elsif (!$Form{$require}) {
            push(@error,'<B>' . $require . '</B>: missing field');
        }
    }

    # If any error fields have been found, send error message to the user.
    if (@error) {
		&error('missing_fields', @error)
	}
	else {
		&success
	}
}

	###########################################################
	# VALIDATE EMAIL ADDRESS
	###########################################################
	sub check_email {
	    # Initialize local email variable with input to subroutine.
	    $email = $_[0];
	
	    # If the e-mail address contains:
	    if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/ ||
		    $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {
	        return 0;
	    }
	
	    else {
	        # E-mail verification passed.
	        return 1;
	    }
	}
	
	###########################################################
	# VALIDATE CREDIT CARD NUMBER
	###########################################################
	sub check_credit_number {
	    # Initialize local credit_number variable with input to subroutine.
	    $credit_number = $_[0];
		$varLength = length($credit_number);
	
		if ($varLength < 15) {
			return 0;
		}
		else {
	    	if ($credit_number =~ /\d{4}([\W])\d{6}\1\d{5}/ ||
				$credit_number =~ /\d{4}([\W])\d{4}\1\d{4}\1\d{4}/ ||
				$credit_number =~ /[0-9]{15,16}/) {
				return 1;
			}
			else {
				return 0;
			}
		}
	}
	
	###########################################################
	# VALIDATE PHONE/FAX NUMBER
	###########################################################
	sub check_number {
	    # Initialize local phone variable with input to subroutine.
	    $number = $_[0];
		$varLength = length($number);
	
		if ($number =~ /([\W])\d{3}([\W])\d{3}([\W])\d{4}/ ||
			$number =~ /\d{3}([\W])\d{3}\1\d{4}/ ||
			$number =~ /([\W])\d{3}([\W])/ ||
			$number =~ /\d{3}([\W])\d{4}/ ||
			$number =~ /[0-9]{$varLength}/) {
			return 1;
		}
		else {
			return 0;
		}
	}

###########################################################
# REDIRECT TO  SUCCESS HTML
###########################################################
sub success {
    if ($Form{'confirm_url'}) {
        print "HTTP/1.0 302 Found\n";
	    print "Window-target: $Form{'target'}\n" if ($Form{'target'});
        print "Location: $Form{'confirm_url'}\n\n";
    } else {
        print "HTTP/1.0 200 OK\n";
        print "Window-target: $Form{'target'}\n" if ($Form{'target'});
        print "Content-type: text/html\n\n";
        print "<HTML><HEAD><TITLE>Error!</TITLE></HEAD><BODY BGCOLOR=\"\#FFFFFF\">\n";
        print "<H1>Error!</H1>\n";
        print "<P>You didn't supply information for the destination...\n";
        print "</BODY></HTML>\n";
    }
	# Process Email
	$sendEmailFlag='1';
}

###########################################################
# RETURN ERROR HTML
###########################################################
sub error { 
    # Localize variables and assign subroutine input.
    local($error,@error_fields) = @_;
    local($host,$missing_field,$missing_field_list);
    if ($error eq 'missing_fields') {
        if ($Config{'missing_fields_redirect'}) {
            print("Location: $Config{'missing_fields_redirect'}\n\n");
        }
        else {
            foreach $missing_field (@error_fields) {
                $missing_field_list .= "<LI>$missing_field\n";
            }
	        print "HTTP/1.0 200 OK\n";
	        print "Window-target: $Form{'target'}\n" if ($Form{'target'});
			print("Content-type: text/html\n\n");
			print("<HTML>\n");
			print("<HEAD>\n");
			print("<TITLE>Errors Encountered</TITLE>\n");
			print("</HEAD>\n");
			print("<BODY BGCOLOR=FFFFFF>\n");
		
			# image_header
				print("<CENTER>\n");
				print("<TABLE>\n");
				print("<TR>\n");
				$scalar = @imageHeader;
				$count = 1;
					while ($count <= $scalar) {
						print("<TD><IMG SRC=$imageHeader[$count-1]></TD>\n");
						$count++;
					}
				print("</TR>\n");
				print("</TABLE>\n");
				print("</CENTER>\n");

			print("<P>\n");
			print("<CENTER>\n");
			print("<TABLE BORDER=0 WIDTH=480 BGCOLOR=#9C9C9C>\n");
			print("<TR><TH><FONT SIZE=+2>Errors Encountered</FONT></TH></TR>\n");
			print("</TABLE>\n");
			print("<TABLE BORDER=0 WIDTH=480 BGCOLOR=#CFCFCF>\n");
			print("<TR><TD>\n");
			print("The following fields contain errors or inappropriate \n");
			print("data in your submission form:<P>\n");
			print("<UL>\n");
			print("$missing_field_list\n");
			print("</UL>\n");
			print("These fields must be filled in before you can successfully submit the form.  \n");
			print("<BR>Please use your browser's back button to return to the form and try again. \n");
			print("</TD></TR>\n");
			print("</TABLE>\n");
			print("</CENTER>\n");
			print("</BODY>\n");
			print("</HTML>\n");
        }
    }

	# Do not process email due to errors
	$sendEmailFlag='0';
    exit;
}

###########################################################
# send_mail_T0_EMAIL_ADDR
###########################################################
sub send_mail_T0_EMAIL_ADDR {
	open(MAIL, "| /usr/lib/sendmail -t '$Form{'EmailAdress'}'")  ||  die "Cannot open $!\n";
	print MAIL "To: $Form{'EmailAddress'}\n";
	print MAIL "From: $Form{'recipient'}\n";
	print MAIL "Subject: $Form{'subject'}\n";
	print MAIL "\n";

	# Dynamic reply
	print MAIL "Dear $Form{'Name'}:\n";
	print MAIL "\n";
	print MAIL "The information you have provided will help expedite your request. \n";
	print MAIL "Again, thank you for your interest in Setra.\n";
	print MAIL "\n";
	print MAIL "We will respond as soon as possible.\n";
}

###########################################################
# send_mail_T0_RECIPIENT
###########################################################
sub send_mail_T0_RECIPIENT {
	open(MAIL, "| /usr/lib/sendmail -t '$Form{'recipient'}'")  ||  die "Cannot open $!\n";
	print MAIL "To: $Form{'recipient'}\n";
	print MAIL "From: $Form{'EmailAddress'} ($Form{'Name'})\n";
	print MAIL "Subject: $Form{'subject'}\n";
	print MAIL "\n";

	foreach $field (@Field_Order) {
		if ($Form{'application'} !~ /$field/g) {
			print MAIL "$field: $Form{$field}\n";
		}
	}
}


Anon7 - 2021