#!/usr/bin/perl -w
#use strict; # conflict with CGI hash
use CGI qw/:standard/;
use Data::FormValidator::Constraints (qw/valid_email/);
use Data::FormValidator::Constraints (qw/valid_american_phone/);
$CGI::POST_MAX=1024 * 100; # max 100K posts
$CGI::DISABLE_UPLOADS = 1; # no uploads
# Location of e-mail program
$mailprog = "/usr/sbin/sendmail";
my $toemail;
my $fromemail = "<webmaster\@rockwareit.net>";
my $test = 'test';
my $lnameprint;
my $fnameprint;
my $emailprint;
my $phoneprint;
my $previewflag = escapeHTML(param('previewflag'));
my $formflag = escapeHTML(param('formflag'));
my $prevbtn = escapeHTML(param('prevbutton'));
my $prevcancel = escapeHTML(param('prevcanbutton'));
my $firstname;
my $lastname;
my $email;
my $phone;
my $carrier;
my $product_title;
my $description;
my $image_url;
my $text_mail;
print "Content-type: text/html\n\n";
if ($formflag eq 'sent') {
#print $formflag . "is sent.\n";
#skip the form
if (param()) {
$firstname = escapeHTML(param('firstName'));
$lastname = escapeHTML(param('lastName'));
$email = escapeHTML(param('email'));
$phone = escapeHTML(param('phone'));
$carrier = escapeHTML(param('phoneCarriers'));
&email_validate;
&phone_validate;
if (($firstname ne "") && ($lastname ne "") && ($email ne "invalid
+") && ($phone ne "invalid")) {
# print preview page
&print_head();
&print_preview_page();
}else{
# set some variables to echo back user selections
&error_fname();
&error_lname();
&error_email();
&error_phone();
&print_head();
&print_error_page();
&print_tail();
} # end if
}else {
#error page
&print_error_page();
} # end if (param()) {
}elsif ($previewflag eq 'go') {
print "Name is $firstname\n";
$firstname = escapeHTML(param('firstName'));
print "First name is $firstname\n";
$lastname = escapeHTML(param('lastName'));
print "Last name is $lastname\n";
$email = escapeHTML(param('email'));
print "Email is $email\n";
$phone = escapeHTML(param('phone'));
print "Phone is $phone\n";
$carrier = escapeHTML(param('phoneCarriers'));
print "Carrier is $carrier\n";
&email_replace();
&email_to_text();
&mail_form_data();
&number_replace();
&text_form_data();
&print_head();
&print_thank_you_page();
&print_tail();
}else{
&print_head;
&print_form;
}
# =========================================================== subrouti
+nes =================================================================
+======================== #
sub number_replace {
$phone =~ s/ //;
$phone =~ s/\)//;
$phone =~ s/ \) //;
$phone =~ s/ \)//;
$phone =~ s/\) //;
} # end sub ==========================================================
+========
sub phone_validate {
if (valid_american_phone($phone)) {
# Phone number is valid
print "Phone - Input is valid.\n";
}else{
$phone = 'invalid';
print "Phone - Input is invalid.\n";
}
$phone;
} # end sub phone_validateb ==========================================
+=========
sub email_validate {
if (valid_email($email)) {
# email is valid
print "Email - Input is valid.\n";
} else {
$email = 'invalid';
print "Email - Input is invalid.\n";
} # end if
} # end sub email_validateb ==========================================
+=========
sub email_replace {
$email =~ s/\@/\@/;
print "After replacement, email is now $email\n";
} # end sub ==========================================================
+=========
sub email_to_text {
if ($carrier =~ /att/i) {
$text_mail = "$phone\@txt.att.net";
}elsif($carrier =~ /cricket/i) {
$text_mail = "$phone\@sms.mycricket.com";
}elsif ($carrier =~ /metro/i) {
$text_mail = "$phone\@mymetropcs.com";
}elsif ($carrier =~ /sprint/i) {
$text_mail = "$phone\@messaging.sprintpcs.com";
}elsif($carrier =~ /tmobile/i) {
$text_mail = "$phone\@tmomail.net";
}elsif($carrier =~ /uscellular/i) {
$text_mail = "$phone\@email.uscc.net";
}elsif($carrier =~ /verizon/i) {
$text_mail = "$phone\@vtext.com";
}elsif($carrier =~ /virgin/i) {
$text_mail = "$phone\@vmobl.com";
} # end if
print "Carrier email is $text_mail\n";
} # end sub ==========================================================
+========
sub mail_form_data {
# emails the form data
my(@values,$key);
# Open the sendmail program and pipe the data
open(MAIL, "| $mailprog -t") || die "I can't open $mailprog\n";
print MAIL "To: <$email>\n";
print MAIL "From: <webmaster\@skibeestore.com>\n";
print MAIL "Subject: Price Request\n";
print MAIL "\n";
foreach $key (param) {
print MAIL "$key: ";
@values = param($key);
print MAIL join(", ",@values),"\n";
}
print MAIL "\n";
close(MAIL)
} # end sub mail_form_data ===========================================
+=======
sub text_form_data {
# emails the form data
my(@values,$key);
# Open the sendmail program and pipe the data
open(MAIL, "| $mailprog -t") || die "I can't open $mailprog\n";
print MAIL "From: <webmaster\@skibeestore.com>\n";
print MAIL "To: <$text_mail>\n";
print MAIL "Subject: Price Request\n";
print MAIL "\n";
foreach $key (param) {
print MAIL "$key: ";
@values = param($key);
print MAIL join(", ",@values),"\n";
}
print MAIL "\n";
close(MAIL)
} # end sub text_form_data ===========================================
+=======
sub form_field_values {
my(@values,$key);
print "<h2>Here are the current settings in this form</h2>";
foreach $key (param) {
print "<strong>$key</strong> -> ";
@values = param($key);
print join(", ",@values),"<br>\n";
}
} #end sub form_field_values =========================================
+=======
sub error_fname {
if($firstname eq "") {
$fnameprint = '<label id="firstNameLabel" class="formLabel" fo
+r="firstName">First name:</label><div class="errortext">This Field Is
+ Required ---></div>';
}else{
$fnameprint = '<label id="firstNameLabel" class="formLabel" fo
+r="firstName">First name:</label>';
}
} # end sub error_fname ===========================================
+==========
sub error_lname {
if($lastname eq "") {
$lnameprint = '<label id="lastNameLabel" class="formLabel" for
+="lastName">Last name:</label><div class="errortext">This Field Is Re
+quired ---></div>';
}else{
$lnameprint = '<label id="lastNameLabel" class="formLabel" for
+="lastName">Last name:</label>';
}
} # end sub error_lname ===========================================
+==========
sub error_email {
if($email eq "" || "invalid") {
$emailprint = '<label id="emailLabel" class="formLabel" for="e
+Mail">Email:</label><div class="errortext">This Field Is Required ---
+></div>';
}else{
$emailprint = '<label id="emailLabel" class="formLabel" for="e
+Mail">Email:</label>';
}
} # end sub error_email ===========================================
+==========
sub error_phone {
if($phone eq "invalid" || "") {
$phoneprint = '<label id="phoneNumberLabel" class="formLabel"
+for="phoneNumber">Phone Number:</label><div class="errortext">This Fi
+eld Is Required ---></div>';
}else{
$phoneprint = '<label id="phoneNumberLabel" class="formLabel"
+for="phoneNumber">Phone Number:</label>';
}
} # end sub error_phone ===========================================
+==========
sub print_tail {
print <<TAIL;
<tr align="left" valign="top">
</table>
</td>
<!-- borderbox bottom -->
</td>
</table>
<!-- end content -->
</td>
</table>
<!-- end main -->
</td></tr>
<tr align="left" valign="top" bgcolor="#999999"><td>
<!-- footer rule -->
<tr align="left" valign="top" bgcolor="#FFFFFF"><td>
<!-- footer -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr align="left" valign="top"><td></td><td class="footer">© 2013
+SkiBee Stores. All rights reserved
<tr align="left" valign="top"><td colspan="2"></td></tr></table>
<!-- end footer -->
</td></tr></table></div>
</BODY>
</HTML>
TAIL
} # end sub print_tail ===============================================
+=====
sub print_head {
print <<HEAD;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html dir="ltr" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="resource-type" content="document">
<meta name="revisit-after" content="20 days">
<meta name="classification" content="Equipment Wholeseller">
<meta name="robots" content="ALL">
<meta name="distribution" content="Global">
<meta name="rating" content="Safe For Kids">
<meta name="doc-type" content="Web Page">
<meta name="doc-class" content="Completed">
<meta name="author" content="Created by Rockware Interactive Technolog
+ies.">
<meta http-equiv="reply-to" content="webmaster@rockwareit.net">
<TITLE>SkiBee Stores, inc.</TITLE>
<!-- OWNER NAME="Copyright (C) 2013 - 2006 SkiBee Stores, Incorporated
+. All Rights Reserved" -->
<!-- OWNER INFO="" -->
<!-- OWNER INFO="" -->
<!-- OWNER INFO="Email: webmaster@skibeestore.com" -->
<!-- global /styles -->
<style type="text/css" media="all">
\@import "/css/EmailForPriceStyleSheet.css";
</style>
</head>
HEAD
} # end sub print_head ===============================================
+=====
sub print_thank_you_page {
print <<THANKYOU_PAGE;
<body>
<div id="container">
Thank you! Please check your email and/or phone for the price!<br />
</div>
</body>
</HTML>
THANKYOU_PAGE
} # end print_check_page =============================================
+===========
sub print_preview_page {
print <<PREVIEW_PAGE;
<body>
<div id="container">
<form name="emailForPriceForm" action="/skibeeapp.pl" method="post">
<div id="leftDiv">
<!-- product details -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Product Item Details</legend>
<dl>
<dt>Product Title : </dt>
<dd><a href="#">Product Title</a></dd>
<dt class="dtDescription">Description : </dt>
<dd class="ddDescription"></dd>
<dt>Product Image:</dt>
<dd><a href="#"><img id="productImage" src="$image_url" /></a></dd>
<dt>Item # : </dt>
<dd></dd>
<dt>Manufacturer Name: </dt>
<dd></dd>
<dt>Manufacturer # : </dt>
<dd></dd>
<dt>Free Shipping : </dt>
<dd>Yes</dd>
<dt>MSRP Price : </dt>
<dd></dd>
<dt>Private Club Price : </dt>
<dd>After form submission, check computer or phone for message reveali
+ng price</dd>
</dl>
</fieldset>
</div>
<div id="rightDiv">
<!-- email for price -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Request Email for Price</legend>
<table>
<tr>
<td>
<label id="firstNameLabel" class="formLabel" for="firstName">First nam
+e:</label>
</td>
<td>
<input type="text" name="firstName" id="firstName" class="formField" v
+alue="$firstname" />
</td>
</tr>
<tr>
<td>
<label id="lastNameLabel" class="formLabel" for="lastName">Last name:<
+/label>
</td>
<td>
<input type="text" name="lastName" id="lastName" class="formField" val
+ue="$lastname" />
</td>
</tr>
<tr>
<td>
<label id="emailLabel" class="formLabel" for="eMail">Email:</label>
</td>
<td>
<input type="text" name="email" id="email" class="formField" value="$e
+mail" />
</td>
</tr>
</table>
</fieldset>
<!-- text for price -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Request Text for Price</legend>
<table>
<tr>
<td>
<label id="phoneNumberLabel" class="formLabel" for="phoneNumber">Phone
+ Number:</label>
</td>
<td>
<input type="text" name="phone" id="phoneNumber" class="formField" val
+ue="$phone" />
</td>
</tr>
<tr>
<td>
<label id="phoneCarrierLabel" class="formLabel" for="phoneCarriers">Se
+lect Phone Carrier:</label>
</td>
<td>
<input type="text" name="phoneCarriers" id="phoneCarriers" class="form
+Field" value="$carrier" />
</select>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="email" value="$email" />
<input type="hidden" name="lastName" value="$lastname" />
<input type="hidden" name="phoneCarriers" value="$carrier" />
<input type="hidden" name="previewflag" value="go" />
<input type="submit" name="submitBtn" class="submitBtn" value="Submit"
+ />
</td>
</tr>
</table>
</fieldset>
</div>
</form>
</div>
</body>
</HTML>
PREVIEW_PAGE
} # end print_preview_page ===========================================
+=============
sub print_error_page {
print<<ERROR_PAGE;
<body>
<div id="container">
<form name="emailForPriceForm" action="#" method="post">
<div id="rightDiv">
<!-- email for price -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Request Email for Price</legend>
<table>
<tr>
<td>
$fnameprint
</td>
<td>
<input type="text" name="firstName" id="firstName" class="formField" v
+alue="" />
</td>
</tr>
<tr>
<td>
$lnameprint
</td>
<td>
<input type="text" name="lastName" id="lastName" class="formField" val
+ue="" />
</td>
</tr>
<tr>
<td>
$emailprint
</td>
<td>
<input type="text" name="eMail" id="eMail" class="formField" value=""
+/>
<input type="hidden" name="formflag" value="sent" >
</td>
</tr>
</table>
</fieldset>
<!-- text for price -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Request Text for Price</legend>
<table>
<tr>
<td>
$phoneprint
</td>
<td>
<input type="text" name="phoneNumber" id="phoneNumber" class="formFiel
+d" value="" />
</td>
</tr>
<tr>
<td>
<label id="phoneCarrierLabel" class="formLabel" for="phoneCarriers">Se
+lect Phone Carrier:</label>
</td>
<td>
<select name="phoneCarriers" id="phoneCarriers" class="formField">
<option value="">-- Select Below --</option>
<option value="att">ATT</option>
<option value="cricket">Cricket</option>
<option value="metro">MetroPCS</option>
<option value="sprint">Sprint</option>
<option value="tmobile">T-Mobile</option>
<option value="uscellular">US Cellular</option>
<option value="verizon">Verizon</option>
<option value="virgin">Virgin Mobile</option>
</select>
</td>
</tr>
</table>
</fieldset>
<!-- terms & conditions -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Terms & Conditions</legend>
<table>
<tr>
<td colspan="2">
<textarea rows="5" cols="46">The following Terms and Conditions apply
+to the use of this Web site as well as all transactions conducted thr
+ough the site.Upon submission of this form I agree to join SKI-BEE DI
+STRIBUTING, INC.'s membership club named SkiBee's Downhill Club and c
+onsent to receive email and/or text messages sent to the email and/or
+ telephone number I have provided wherein. I understand I may remove
+ my name out of SkiBee's Downhill Club at any time by click notifying
+ us, the service provider at any time.
</textarea>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="termsAccepted" id="termsAccepted" value="
+on" />
<label for="termsAccepted">I have read and accept the terms and condit
+ions. </label>
<span class="required">*</span>
</td>
</tr>
<tr>
<td>
<input type="submit" class="submitBtn" value="Submit" />
<input type="submit" class="submitBtn" value="Cancel" />
</td>
</tr>
</table>
</fieldset>
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Other Options</legend>
<table>
<tr class="otherOptionsTr">
<td class="alginRightTd">
<a href="https://skibeestore.com/register.sc" class="linkButton">Regis
+ter</a>
</td>
<td>
<a href="https://skibeestore.com/register.sc">Register to see private
+club price now!</a>
</td>
</tr>
<tr class="otherOptionsTr">
<td class="alginRightTd">
<a href="https://skibeestore.com/login.sc" class="linkButton">Login</a
+>
</td>
<td>
<a href="https://skibeestore.com/register.sc">Login to see private clu
+b price now!</a>
</td>
</tr>
</table>
</fieldset>
</div>
</form>
</div>
</body>
</HTML>
ERROR_PAGE
} # end print_error_page =============================================
+=============
sub print_form {
#displays the first form
#print "Content-type: text/html\n\n";
print <<HTML;
<HTML>
<body>
<div id="container">
<form name="emailForPriceForm" action="/skibeeapp.pl" method="post">
<div id="rightDiv">
<!-- email for price -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Request Email for Price</legend>
<table>
<tr>
<td>
<label id="firstNameLabel" class="formLabel" for="firstName">First nam
+e:</label>
</td>
<td>
<input type="text" name="firstName" id="firstName" class="formField" v
+alue="" />
</td>
</tr>
<tr>
<td>
<label id="lastNameLabel" class="formLabel" for="lastName">Last name:<
+/label>
</td>
<td>
<input type="text" name="lastName" id="lastName" class="formField" val
+ue="" />
</td>
</tr>
<tr>
<td>
<label id="emailLabel" class="formLabel" for="eMail">Email:</label>
</td>
<td>
<input type="text" name="email" id="email" class="formField" value=""
+/>
</td>
</tr>
</table>
</fieldset>
<!-- text for price -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Request Text for Price</legend>
<table>
<tr>
<td>
<label id="phoneNumberLabel" class="formLabel" for="phoneNumber">Phone
+ Number:</label>
</td>
<td>
<input type="text" name="phone" id="phoneNumber" class="formField" val
+ue="" />
</td>
</tr>
<tr>
<td>
<label id="phoneCarrierLabel" class="formLabel" for="phoneCarriers">Se
+lect Phone Carrier:</label>
</td>
<td>
<select name="phoneCarriers" id="phoneCarriers" class="formField">
<option value="">-- Select Below --</option>
<option value="att">ATT</option>
<option value="cricket">Cricket</option>
<option value="metro">MetroPCS</option>
<option value="sprint">Sprint</option>
<option value="tmobile">T-Mobile</option>
<option value="uscellular">US Cellular</option>
<option value="verizon">Verizon</option>
<option value="virgin">Virgin Mobile</option>
</select>
</td>
</tr>
</table>
</fieldset>
<!-- terms & conditions -->
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Terms & Conditions</legend>
<table>
<tr>
<td colspan="2">
<textarea rows="5" cols="46">The following Terms and Conditions apply
+to the use of this Web site as well as all transactions conducted thr
+ough the site.Upon submission of this form I agree to join SKI-BEE DI
+STRIBUTING, INC.'s membership club named SkiBee's Downhill Club and c
+onsent to receive email and/or text messages sent to the email and/or
+ telephone number I have provided wherein. I understand I may remove
+ my name out of SkiBee's Downhill Club at any time by click notifying
+ us, the service provider at any time.
</textarea>
</td>
</tr>
<tr>
<td>
<input type="checkbox" name="termsAccepted" id="termsAccepted" value="
+on" />
<label for="termsAccepted">I have read and accept the terms and condit
+ions. </label>
<span class="required">*</span>
</td>
</tr>
<tr>
<td>
<input type="hidden" name="formflag" value="sent" />
<input type="submit" class="submitBtn" value="Submit" />
<input type="submit" class="submitBtn" value="Cancel" />
</td>
</tr>
</table>
</fieldset>
<fieldset class="fieldSet">
<legend><img src="https://developers.google.com/_static/images/silhoue
+tte36.png?sz=30" />Other Options</legend>
<table>
<tr class="otherOptionsTr">
<td class="alginRightTd">
<a href="https://skibeestore.com/register.sc" class="linkButton">Regis
+ter</a>
</td>
<td>
<a href="https://skibeestore.com/register.sc">Register to see private
+club price now!</a>
</td>
</tr>
<tr class="otherOptionsTr">
<td class="alginRightTd">
<a href="https://skibeestore.com/login.sc" class="linkButton">Login</a
+>
</td>
<td>
<a href="https://skibeestore.com/register.sc">Login to see private clu
+b price now!</a>
</td>
</tr>
</table>
</fieldset>
</div>
</form>
</div>
</body>
</HTML>
HTML
} # end sub print_form ===============================================
+========
|