...

View Full Version : Sendmail Fault in Checkout Perl - PLZ HELP!



vanadium
11-04-2011, 10:12 PM
I downloaded this Free Shopping Cart (http://www.nopdesign.com/freecart/) in Java Script some months ago,

I've been struggling for weeks to get it to work 100% - without success
the support forum linked to the homepage has been inactive for years
and seems to be dead.

This script is totally perfect for our webshop, clean and simple
and not a burden on the server, everything seems to work perfectly
except for 1 problem...

The sendmail function will not work! :confused:

We desperately need to find a solution to this problem as soon as possible
since we're losing orders everyday our webshop is offline.

Any help in finding the source of the problem would be very much appreciated!


The problem must be in either the checkout.pl file


#!/usr/bin/perl

require 5.001;


$header = "/cgi-bin/header.html";
$footer = "cgi-bin/footer.html";
$mailprogram = "/usr/lib/sendmail";
$returnpage = "/";
$youremail = "myname\@mydomain.com";
$csvfilename = "/cgi-bin/orders.csv";
$csvquote = "\"\"";
$mode = "FILE";


#These are required fields. I recommend enforcing these by javascript,
#but let's just make sure here as well.
@required = (
'b_first',
'b_last',
'b_addr',
'b_city',
'b_state',
'b_zip',
'b_phone',
'b_email'
);

sub urlDecode {
my ($string) = @_;
$string =~ tr/+/ /;
$string =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex($1))/eg;
$string =~ s/['"]/\'/g;
return ($string);
}


sub processCGI {
local ($cgiData, $key, $value, $pair, @pairs);

if ($ENV{'REQUEST_METHOD'} eq 'GET') { $cgiData = $ENV{'QUERY_STRING'}; }
else { $cgiData = <STDIN>; }
@pairs = split (/&/, $cgiData);
foreach $pair (@pairs) {
($key, $value) = split (/\=/, $pair);
$key = &urlDecode($key);
$value = &urlDecode($value);
if(defined ${$key}){
${$key} .= ", ".$value;
}else{
${$key} = $value;
}
}
}


sub doFormError {
my ($errString) = @_;

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;

print "Content-type: text/html\n\n";

print @LINES;

print "<FONT SIZE=+2>The form you submitted was not complete.<BR><BR></FONT>";
print "$errString<BR><BR>\n";
print "<INPUT TYPE=BUTTON ONCLICK='history.back()' VALUE=' Return to the checkout page '><HR>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;
print @LINES;

exit;
}


sub doError {
my ($errString) = @_;
print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;

print @LINES;

print "$errString<BR><BR>\n";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;
print @LINES;

exit;
}

sub invalidE {
my ($szEmail) = @_;
my ($user, $host);

$szEmail =~ tr/A-Z/a-z/;
if ($szEmail =~ /\s/) { return 1; }
($user, $host) = split (/\@/, $szEmail);
if ($host =~ /compuserve/i) { ; }
else {
if (! $user =~ /\D/) { return 1; }
if (! $host =~ /\D/) { return 1; }
if (substr ($user,0,1) !~ /[a-z]/) { return 1; }
}
if ($szEmail =~ /\w+\@[\w|\.]/) { return 0; }
else { return 1; }
}


sub populateDateVar {
@months = ();
push(@months,"January");
push(@months,"February");
push(@months,"March");
push(@months,"April");
push(@months,"May");
push(@months,"June");
push(@months,"July");
push(@months,"August");
push(@months,"September");
push(@months,"October");
push(@months,"November");
push(@months,"December");
@days = ();
push(@days,"Sunday");
push(@days,"Monday");
push(@days,"Tuesday");
push(@days,"Wednesday");
push(@days,"Thursday");
push(@days,"Friday");
push(@days,"Saturday");
($sec,$min,$hour,$day,$month,$year,$day2) =
(localtime(time))[0,1,2,3,4,5,6];
if ($sec < 10) { $sec = "0$sec"; }
if ($min < 10) { $min = "0$min"; }
if ($hour < 10) { $hour = "0$hour"; }
if ($day < 10) { $day = "0$day"; }
$year += "1900";

#$todaysdate = "$months[$month] $day, $year $hour:$min:$sec";
}




# process the form input.
&processCGI;
&populateDateVar;

foreach $check(@required) {
unless ($check) {
doFormError("It appears that you forgot to fill in the <strong>$check</strong> field.");
exit;
}
}

# checks for valid email address
if( &invalidE($b_email) ){
doFormError('You submitted an invalid email address.');
}


if( $mode eq "BOTH" || $mode eq "EMAIL") {
# Send email order to you...
open (MAIL,"|$mailprogram");
print MAIL "To: $youremail\n";
print MAIL "From: $b_email\n";
print MAIL "Subject: New Online Order\n";
print MAIL "\n\n";
print MAIL "A new order has been received. A summary of this order appears below.\n";
print MAIL "\n";
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
print MAIL " \n";
print MAIL "Bill To: \n";
print MAIL "-------- \n";
print MAIL " $b_first $b_last \n";
print MAIL " $b_addr \n";
print MAIL " $b_addr2 \n";
print MAIL " $b_city, $b_state $b_zip \n";
print MAIL " $b_phone \n";
print MAIL " $b_fax \n";
print MAIL " $b_email \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Ship To: \n";
print MAIL "-------- \n";
print MAIL " $s_first $s_last \n";
print MAIL " $s_addr \n";
print MAIL " $s_addr2 \n";
print MAIL " $s_city, $s_state $s_zip \n";
print MAIL " $s_phone \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Qty Price(\$) Product ID - Product Name\n";
print MAIL "===================================================================== \n";
print MAIL "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n";
if( $NAME_2 ) {print MAIL "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $NAME_3 ) {print MAIL "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";}
if( $NAME_4 ) {print MAIL "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";}
if( $NAME_5 ) {print MAIL "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";}
if( $NAME_6 ) {print MAIL "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";}
if( $NAME_7 ) {print MAIL "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";}
if( $NAME_8 ) {print MAIL "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";}
if( $NAME_9 ) {print MAIL "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";}
if( $NAME_10 ){print MAIL "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";}
if( $NAME_11 ){print MAIL "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";}
if( $NAME_12 ){print MAIL "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";}
if( $NAME_13 ){print MAIL "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";}
print MAIL "===================================================================== \n";
print MAIL "SUBTOTAL: $SUBTOTAL \n";
print MAIL "TOTAL: $TOTAL \n";
print MAIL "\n";
print MAIL "FREIGHT: $SHIPPING \n";
print MAIL "\n\n";
print MAIL "Comments: \n";
print MAIL "--------- \n";
print MAIL "$comment \n";
print MAIL " \n";
close MAIL;
}


if( $mode eq "BOTH" || $mode eq "FILE") {

$csvcomments = $comment;
#$csvcomments =~ s/\"/$csvquote/ig;

open (CSVF,">>$csvfilename");
print CSVF "\"";
print CSVF "$months[$month] $day, $year $hour:$min:$sec";
print CSVF "\",\"";
print CSVF "$b_first";
print CSVF "\",\"";
print CSVF "$b_last";
print CSVF "\",\"";
print CSVF "$b_addr";
print CSVF "\",\"";
print CSVF "$b_addr2";
print CSVF "\",\"";
print CSVF "$b_city";
print CSVF "\",\"";
print CSVF "$b_state";
print CSVF "\",\"";
print CSVF "$b_zip";
print CSVF "\",\"";
print CSVF "$b_phone";
print CSVF "\",\"";
print CSVF "$b_fax";
print CSVF "\",\"";
print CSVF "$b_email";
print CSVF "\",\"";
print CSVF "$s_first";
print CSVF "\",\"";
print CSVF "$s_last";
print CSVF "\",\"";
print CSVF "$s_addr";
print CSVF "\",\"";
print CSVF "$s_addr2";
print CSVF "\",\"";
print CSVF "$s_city";
print CSVF "\",\"";
print CSVF "$s_state";
print CSVF "\",\"";
print CSVF "$s_zip";
print CSVF "\",\"";
print CSVF "$s_phone";
print CSVF "\",\"";
print CSVF "$QUANTITY_1";
print CSVF "\",\"";
print CSVF "\$$PRICE_1";
print CSVF "\",\"";
print CSVF "$ID_1";
print CSVF "\",\"";
print CSVF "$NAME_1";
print CSVF "\",\"";
print CSVF "$ADDTLINFO_1";
print CSVF "\",\"";

}



# Send email conformation to the customer.....
open (MAIL,"|$mailprogram");
print MAIL "To: $b_email\n";
print MAIL "From: $youremail\n";
print MAIL "Subject: Order Confirmation\n";
print MAIL "\n\n";
print MAIL "A new order has been received. A summary of this order appears below.\n";
print MAIL "\n";
print MAIL "Order Date: $months[$month] $day, $year $hour:$min:$sec \n";
print MAIL " \n";
print MAIL "Bill To: \n";
print MAIL "-------- \n";
print MAIL " $b_first $b_last \n";
print MAIL " $b_addr \n";
print MAIL " $b_addr2 \n";
print MAIL " $b_city, $b_state $b_zip \n";
print MAIL " $b_phone \n";
print MAIL " $b_fax \n";
print MAIL " $b_email \n";
print MAIL " \n";
print MAIL " \n";
print MAIL "Ship To: \n";
print MAIL "-------- \n";

if ( $s_addr eq "" ) {
print MAIL " Use Billing Address\n";
} else {
print MAIL " $s_first $s_last \n";
print MAIL " $s_addr \n";
print MAIL " $s_addr2 \n";
print MAIL " $s_city, $s_state $s_zip \n";
print MAIL " $s_phone \n";
}

print MAIL " \n";
print MAIL " \n";
print MAIL "Qty Price(\$) Product ID - Product Name\n";
print MAIL "===================================================================== \n";
print MAIL "$QUANTITY_1 \$$PRICE_1 $ID_1 - $NAME_1 $ADDTLINFO_1 \n";
if( $NAME_2 ) {print MAIL "$QUANTITY_2 \$$PRICE_2 $ID_2 - $NAME_2 $ADDTLINFO_2 \n";}
if( $NAME_3 ) {print MAIL "$QUANTITY_3 \$$PRICE_3 $ID_3 - $NAME_3 $ADDTLINFO_3 \n";}
if( $NAME_4 ) {print MAIL "$QUANTITY_4 \$$PRICE_4 $ID_4 - $NAME_4 $ADDTLINFO_4 \n";}
if( $NAME_5 ) {print MAIL "$QUANTITY_5 \$$PRICE_5 $ID_5 - $NAME_5 $ADDTLINFO_5 \n";}
if( $NAME_6 ) {print MAIL "$QUANTITY_6 \$$PRICE_6 $ID_6 - $NAME_6 $ADDTLINFO_6 \n";}
if( $NAME_7 ) {print MAIL "$QUANTITY_7 \$$PRICE_7 $ID_7 - $NAME_7 $ADDTLINFO_7 \n";}
if( $NAME_8 ) {print MAIL "$QUANTITY_8 \$$PRICE_8 $ID_8 - $NAME_8 $ADDTLINFO_8 \n";}
if( $NAME_9 ) {print MAIL "$QUANTITY_9 \$$PRICE_9 $ID_9 - $NAME_9 $ADDTLINFO_9 \n";}
if( $NAME_10 ){print MAIL "$QUANTITY_10 \$$PRICE_10 $ID_10 - $NAME_10 $ADDTLINFO_10 \n";}
if( $NAME_11 ){print MAIL "$QUANTITY_11 \$$PRICE_11 $ID_11 - $NAME_11 $ADDTLINFO_11 \n";}
if( $NAME_12 ){print MAIL "$QUANTITY_12 \$$PRICE_12 $ID_12 - $NAME_12 $ADDTLINFO_12 \n";}
if( $NAME_13 ){print MAIL "$QUANTITY_13 \$$PRICE_13 $ID_13 - $NAME_13 $ADDTLINFO_13 \n";}
print MAIL "===================================================================== \n";
print MAIL "SUBTOTAL: $SUBTOTAL \n";
print MAIL "TOTAL: $TOTAL \n";
print MAIL "\n";
print MAIL "FREIGHT: $SHIPPING \n";
print MAIL "\n\n";
print MAIL "Comments: \n";
print MAIL "--------- \n";
print MAIL "$comment \n";
print MAIL " \n";
close MAIL;


print "Content-type: text/html\n\n";

open (HEAD, $header);
@LINES = <HEAD>;
close HEAD;
print @LINES;

print "<h2>Thank you</h2>";
print "Thank you for your order from our online store. You will receive a confirmation email of your order ";
print "momentarily. Please contact us at $youremail if you have any questions or concerns.";
print "<P>";
print "<A HREF=\"$returnpage\" target=_top>Return Home</A>";
print "<P>";

open (FOOT, $footer);
@LINES = <FOOT>;
close FOOT;

print @LINES;

exit;




or in the checkout.html file..



<HTML>
<HEAD>
<TITLE>
CHECKOUT -- Title Here
</TITLE>
<STYLE>
.greetext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;color: #006600;}
.blacktext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px;color: #000000;}
.checkout {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.checkoutinput {font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.nopcart {background: #464444;border: 1px;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #ffffff;}
.nopheader {background: #464444;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #FFFFFF;}
.nopentry {background: #FFFFFF;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.noptotal {background: #FFFFFF;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
.nopbutton {background: #FFFFFF;font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000;}
</STYLE>
<SCRIPT SRC="http://www.mydomain.com/language-en.js"></SCRIPT>
<SCRIPT SRC="http://www.mydomain.com/nopcart.js">

</SCRIPT>
<SCRIPT>
function CheckForm( theform )
{
var bMissingFields = false;
var strFields = "";

if( theform.b_first.value == '' ){
bMissingFields = true;
strFields += " Billing: First Name\n";
}
if( theform.b_last.value == '' ){
bMissingFields = true;
strFields += " Billing: Last Name\n";
}
if( theform.b_addr.value == '' ){
bMissingFields = true;
strFields += " Billing: Address\n";
}
if( theform.b_city.value == '' ){
bMissingFields = true;
strFields += " Billing: City\n";
}
if( theform.b_state.value == '' ){
bMissingFields = true;
strFields += " Billing: State\n";
}
if( theform.b_zip.value == '' ){
bMissingFields = true;
strFields += " Billing: Zipcode\n";
}
if( theform.b_phone.value == '' ){
bMissingFields = true;
strFields += " Billing: Phone\n";
}
if( theform.b_email.value == '' ){
bMissingFields = true;
strFields += " Billing: Email\n";
}

if( bMissingFields ) {
alert( "I'm sorry, but you must provide the following field(s) before continuing:\n" + strFields );
return false;
}

return true;
}
</SCRIPT>
</head>
</HEAD>
<BODY BGCOLOR="White" TEXT="Black">
<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
<TD VALIGN=TOP BGCOLOR=#663333>
<IMG SRC="http://www.aescher.eu/null//images/one.gif" WIDTH=2 HEIGHT=20 ALT="">
<IMG SRC="http://www.aescher.eu/null//images/text.gif" WIDTH=391 HEIGHT=20 ALT="The Ultimate Delicacy">
</TD>
</TR>
</TABLE>

<blockquote>

<NOSCRIPT>
Whoops, we detected that your browser does not have JavaScript, or it is disabled. Our product catalog requires that you
have JavaScript enabled to order products. <a href="http://www.netscape.com">Netscape</a> and <a href="http://www.microsoft.com/ie">Microsoft</a>
offer free browsers which support JavaScript. If you are using a JavaScript compliant browser and still have problems, make sure you
have JavaScript enabled in your browser's preferences.
</NOSCRIPT>
<FONT CLASS="checkout">
<form action="http://www.aescher.eu/null/cgi-bin/checkout.pl" method="POST" onSubmit="return CheckForm(this)">
<NOBR>
<SCRIPT>
CheckoutCart();
</SCRIPT>
</NOBR>
<br>
<P>
<font class="blacktext">
<b>Please fill out the following information below to complete your order.</b>
</font>

<p>
<b><font class="greetext">Billing Information:</font></b><P>

<TABLE class="blacktext">
<TR><TD>Name: </TD><TD><input type="text" size="18" name="b_first"> <input type="text" size="15" name="b_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="b_addr2"></TD></TR>
<TR><TD>City: </TD><TD><input type="text" size="21" name="b_city"> </TD></TR>
<TR><TD>State: </TD><TD><input type="text" size="1" name="b_state"> </TD></TR>
<TR><TD>Zip: </TD><TD><input type="text" size="5" name="b_zip"></TD></TR>
<TR><TD>Phone: </TD><TD><input type="text" size="37" name="b_phone"></TD></TR>
<TR><TD>Fax: </TD><TD><input type="text" size="37" name="b_fax"></TD></TR>
<TR><TD>Email: </TD><TD><input type="text" size="37" name="b_email"> </TD></TR>
</TABLE>
<p>
<b><font class="greetext">Shipping Information (if different than billing):</font></b><P>
<TABLE class="blacktext">
<TR><TD>Name: </TD><TD><input type="text" size="18" name="s_first"> <input type="text" size="15" name="s_last"></TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="s_addr"> </TD></TR>
<TR><TD>Address: </TD><TD><input type="text" size="37" name="s_addr2"></TD></TR>
<TR><TD>City: </TD><TD><input type="text" size="21" name="s_city"> </TD></TR>
<TR><TD>State: </TD><TD><input type="text" size="1" name="s_state"> </TD></TR>
<TR><TD>Zip: </TD><TD><input type="text" size="5" name="s_zip"></TD></TR>
<TR><TD>Phone: </TD><TD><input type="text" size="37" name="s_phone"></TD></TR>
<TR><TD>Fax: </TD><TD><input type="text" size="37" name="s_fax"></TD></TR>
<TR><TD>Email: </TD><TD><input type="text" size="37" name="s_email"> </TD></TR>
</TABLE>
<p>
<FONT class="blacktext">
<b><font class="greetext">Comments/Special Instructions:</font></b><P>
<TEXTAREA NAME="comment" ROWS=6 COLS=40>
</TEXTAREA>
</font>
<p>
<b><font color="#660000">This is a DEMO SITE! No real orders will be taken, and no products
will be shipped. Please use a real email address to view the checkout confirmation. Your email
address will NOT be stored on the server, or used for ANYTHING, EVER!</font></b><P>
<input type=submit Value="Submit Order"> <INPUT type=RESET value=" Clear Form ">
</p>
</center>
</FORM>
</blockquote>
</body>
</html>






The server is Linux based - All our PCs are Windows


I checked with my host - here are the path parametres :
----------------------------------------------------------------------------------
PATHS
----------------------------------------------------------------------------------
my $sendmail = "/usr/sbin/sendmail-t-f name\ @domain.com";


# / Usr / bin / perl

Perl is currently in version v5.8.8 built for i486-linux-gnu-thread-multi install.

the correct path to PERL: / usr / bin / perl .

Sendmail is located in / usr / sbin / sendmail .

PHP can be found in / usr / bin / php or / usr / bin / local / php (the latter is a symlink,
which points to the path above). "normal" PHP scripts are running mod_php.

ruby is in / usr / bin / ruby , python under / usr / bin / python

Python is currently in version 2.2.3
----------------------------------------------------------------------------------

btw... the only directories for the webshop are cgi-bin and images
all ht files are in the root directory

the relevant file permissions have been set to CHMOD 755

blnukem
11-07-2011, 01:59 PM
Your code is fine but it seems the the path to sendmail does not look rite

my $sendmail = "/usr/sbin/sendmail-t-f name\ @domain.com";

should be something like:
my $sendmail = "/usr/sbin/sendmail-t-f";

Try running this script and it will output the correct path to sendmail

Perl Sript:


#!/usr/bin/perl -w

# Place this in any cgi-bin CHMOD it to 755 (if UNIX) then call
# it from your browser. Eg. http://www.you.com/cgi-bin/myserver.cgi

$of = qq~<font size="2" face="arial,verdana,helvetica">~;
$cf = qq~</font>~;

my @slocs = qw~
/usr/sbin/sendmail
/usr/bin/sendmail
/sbin/sendmail
/usr/slib/sendmail
/usr/lib/sendmail
/bin/sendmail
/lib/sendmail
/slib/sendmail
/usr/sendmail
/sendmail
sendmail
~;

print qq~Content-type: text/html


<html>
<head><title>Enviromental Variables Report. PerlScriptsJavaScripts.com</title></head>
<body bgcolor="#ffffff" alink="#ff0000" link="#ff0000" vlink="#ff0000">

<center>
$of<b>Enviromental Variables returned by this server. <a href="http://www.perlscriptsjavascripts.com/?evs">A PerlScriptsJavaScripts Product</a></b>$cf
</center>
<br>
<table align="center" border="1" cellpadding="5" cellspacing="0" width="600">
<tr>
<td>$of<b>Variable</b>$cf</td>
<td>$of<b>Value</b>$cf</td>
</tr>
~;

my @vars = sort(keys(%ENV));
foreach(@vars) {
$ENV{$_} ||= qq~&nbsp;~;
print qq~
<tr>
<td>$of\$ENV{$_}$cf</td>
<td>$of$ENV{$_}$cf</td>
</tr>
~;
}

print qq~
<tr>
<td>$of\$ENV{DOCUMENT_NAME}$cf</td>
<td>$of$ENV{DOCUMENT_NAME} &nbsp;$cf</td>
</tr>
<tr>
<td>$of\$ENV{DOCUMENT_URI}$cf</td>
<td>$of$ENV{DOCUMENT_URI} &nbsp;$cf</td>
</tr>
<tr>
<td>$of\$ENV{LAST_MODIFIED}$cf</td>
<td>$of$ENV{LAST_MODIFIED} &nbsp;$cf</td>
</tr>
<tr>
<td>$of\$ENV{DATE_GMT}$cf</td>
<td>$of$ENV{DATE_GMT} &nbsp;$cf</td>
</tr>
<tr>
<td>$of\$ENV{DATE_LOCAL}$cf</td>
<td>$of$ENV{DATE_LOCAL} &nbsp;$cf</td>
</tr>
<tr>
<td>$of\$ENV{REMOTE_USER}$cf</td>
<td>$of$ENV{REMOTE_USER} This var returns the value of a .ht username$cf</td>
</tr>
</table>
<br>

<center>
$of<b>Path(s) to Sendmail</b>$cf
</center>
<br>

<table align="center" border="1" cellpadding="5" cellspacing="0" width="600">
~;

foreach(@slocs) {
if(-e $_){
print qq~
<tr>
<td>$of$_$cf</td>
</tr>
~;
}
}

print qq~
</table>
<br>

<center>
$of<b>Additional Information</b>$cf
</center>
<br>
<table align="center" border="1" cellpadding="5" cellspacing="0" width="600">
<tr>
<td>$of<b>Variable</b>$cf</td>
<td>$of<b>Value</b>$cf</td>
<td>$of<b>Description</b>$cf</td>
</tr>
<tr>
<td>$of\$] $cf</td>
<td>$of$]$cf&nbsp;</td>
<td>$of Version of Perl$cf</td>
</tr>
<tr>
<td>$of\$0 $cf</td>
<td>$of$0$cf&nbsp;</td>
<td>$of Script name$cf</td>
</tr>
<tr>
<td>$of\$\$ $cf</td>
<td>$of$$ $cf&nbsp;</td>
<td>$of Process ID$cf</td>
</tr>
<tr>
<td>$of\$^O $cf</td>
<td>$of$^O $cf&nbsp;</td>
<td>$of Operating System$cf</td>
</tr>
<tr>
<td>$of\$! $cf</td>
<td>$of$!$cf&nbsp;</td>
<td>$of<a href="javascript:alert('If the error says No such file or directory, it is because this script tries to guess the location of sendmail.')">Error returned by server</a>$cf</td>
</tr>
</table>
<br>

<center>
$of<a href="javascript:alert('This is the complete list of standard modules contained in \@INC. \\n\\nClick on the module name to search for it\\'s documentation in the Cpan.org website')"><b>List of Modules Installed on this server</b></a>$cf
</center>
<br>
<table align="center" border="1" cellpadding="5" cellspacing="0" width="600">
<tr>
<td>$of<b>Name</b>$cf</td>
<td>$of<b>Name</b>$cf</td>
</tr>
<tr>
<td>
~;

find(\&wanted, @INC);

@found = sort { uc($a) cmp uc($b) } @found;

for($c = 0; $c < int(@found / 2); $c++){
$search = $found[$c];
$search =~ s/\.pm$//i;
print qq~$of <a href="http://search.cpan.org/search?mode=module&query=$search">$found[$c]</a> <br>\n~;
}

print qq~$cf</td><td>~;

for($d = $c; $d < @found; $d++){
$search = $found[$d];
$search =~ s/\.pm$//i;
print qq~$of <a href="http://search.cpan.org/search?mode=module&query=$search">$found[$d]</a><br>\n~;
}

($sec, $min, $hour, $day, $mon, $year, $weekday, $dayofyear, $dst) = localtime(time);

$year += 1900;

print qq~$cf</td></tr>
</table>
<br>
<center>
$of <a href="http://www.perlscriptsjavascripts.com/?evs"><b>Copyright $year PerlScriptsJavaScripts.com</b></a>$cf
</center>
<br>
</body>
</html>
~;

sub wanted {
use File::Find;
$num = 0;
if ($File::Find::name =~ /\.pm$/){
if(open(M,$File::Find::name)){
while(<M>){
if (/^ *package +(\S+);/){
push (@found, $1);
last;
}
}
chomp(@found);
}
}
}

Budreaux
11-09-2011, 04:57 PM
I wanted to post this for those future searches which may happen across this forum post.

blnukem - i love to impose the KISS method anytime I do anything. While your code was both beautiful and functional, it may be a bit over the top for someone who appears to not have that much experience with perl/CGI. add to that the fact that your code relies on sendmail residing in one of the default directories and that their server admin isn't a maniacal, non-conformist who thinks he has a better directory structure and decides to put sendmail in some obscure directory.

the simpler method is just to telnet into the server and type "which sendmail". This will give the exact location of the sendmail program.

Still, kudos to you blnukem for your scripting efforts

FishMonger
11-09-2011, 06:14 PM
A better KISS method would have been to use one of the many email modules on cpan.

And, there's way too much OLD/OUTDATED code in that example. For example, the urlDecode() and processCGI() subs could be replaced with this:


use CGI;

my $cgi = CGI->new;
my %form = $cgi->Vars();

And the populateDateVar() sub would be replaced with:

use POSIX;

my $todaysdate = strftime("%B %d, %Y %H:%M:%S", localtime);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum