Page 1 of 1

Help with some perl

Posted: Wed Mar 05, 2008 10:01 am
by QbertsBrother
so i am working on this site and it was written in perl. i dont have much experience with perl so i really have no idea of what is going on in this code. when i look at the code i can see that there is a form in the code. but when i view the page the form is not displayed. could someone please look at it and find the place that tells it to display the form or not?

thanks

Code: Select all

#!/usr/bin/perl
 
require '/srv/www/htdocs/50thandfrance/2007ArtFair/menu.lib';
require '/srv/www/htdocs/50thandfrance/2007ArtFair/navmenu.lib';
 
print "Content-Type:text/html\n\n"; 
 
@pgs = split(/&/,$ENV{'QUERY_STRING'});
$lvar=join("\&",@pgs);
if(length($pgs[0]) != 2){
 $pgs[0]="00";
}#end 0=""
print <<end_html;
 
<html>
<head>
<TITLE>::Edina Art Fair::</TITLE>
<link rel="stylesheet" type="text/css" href="style.css">
<META NAME="Keywords" content="">
<META NAME="Description" CONTENT="">
</head>
<body background="images/separator-bg.jpg" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">
<!page table>
<table width=775 cellpadding=0 cellspacing=0 border=0 align=center>
<tr><td colspan=3><img src="images/banner.jpg" width=775 height=130></td></tr>
<tr><td align=left><img src="images/bar-l.jpg" width=14 height=28></td>
<td background="images/bar-bg.jpg" width=100%>
end_html
&MainMenu;
print <<end_html;
</td>
<td align=right><img src="images/bar-r.jpg" width=14 height=28></td></tr>
<tr><td colspan=3><img src="images/top.jpg" width=775 height=29></td></tr>
</table>
<table width=775 cellpadding=0 cellspacing=0 border=0 align=center>
<tr><td align=left background="images/menu-bg.jpg" valign=top><img src="images/spacer.gif" width=155 height=1><br>
end_html
for($x=0;$x<=3;$x+=1){
 if($pgs[$x] ne ""){
  $pid="$pid$pgs[$x]";
 }
}#end x
#print "pid=$pid<br>\n";
 &Menu;
print <<end_html;
</td>
<td><img src="images/separator-bg.jpg" width=15 height=375></td>
<td background="images/body-bg.jpg"><img src="images/spacer.gif" width=14 height=1></td>
<td background="images/body-bg.jpg" valign=top><img src="images/spacer.jpg" width=477 height=1><br>
$crumb{$pid}<P>
end_html
 
read(STDIN, $over, $ENV{'CONTENT_LENGTH'});
$over=~tr/+/ /;
$over=~s/%09/ /g;
$over=~tr/&/\t/;
$over=~s/  / /g;
#$over=~s/%0D/ /g;
#$over=~s/%0A/ /g;
@pairs=split(/\t/, $over);
foreach $pair (@pairs) {
($name, $value)=split(/=/, $pair);
$value=~s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
#remove leading/trailing spaces
  $value=~s/^\s+//;
  $value=~s/\s+$//;
$sub=substr($name, 1);
$typ=substr($name,0,1);
#print "$typ $sub = $value<br>\n";
 if($typ eq "a"){
  $fi[$sub]=$value;
 }
 if($typ eq "t"){
  $tv[$sub]=$value;
 }
}
 
 
if($tv[99] ne ""){
 
if($fi[1] eq ""){
 $erm=$erm."First Name<br>\n";
 }#end else
 
if($fi[2] eq ""){
 $erm=$erm."Last Name<br>\n";
 }#end else
 
if(length($fi[8]) < 10){
 $erm=$erm."Telephone with area code<br>\n";
 }#end else
 
 
if($fi[7] eq ""){
 $erm=$erm."Email Address<br>\n";
 }
 
if($fi[7] ne ""){
$c=index($fi[7]," ");
if($c > -1){
  $be++;
  }
$c=index($fi[7],";");
if($c > -1){
  $be++;
   }
$c=index($fi[7],",");
if($c > -1){
  $be++;
   }
$c=index($fi[7],'@');
if($c == -1){
  $be++;
   }
$c=index($fi[7],'.');
if($c == -1){
  $be++;
   }
 }#end else email check
 
if($be > 0){
 $erm=$erm."<b>$fi[7]</b> is not a valid email address<BR>";
 }
 
 
if($fi[11] eq ""){
 $erm=$erm."Age<br>\n";
 }#end else
 
if($fi[11] eq ""){
 $erm=$erm."T-Shirt Size<br>\n";
 }#end else
 
$fo=0;
for($x=18;$x<=33;$x+=1){
 if($fi[$x] ne ""){
  $fo++;
  last;
 }#end x
}#end x
 
if($fo == 0){
 $erm=$erm."Select at least one sign-up time<br>\n";
 }#end else
 
 
 if($erm ne ""){
  $erm="<ul><font color=red>The following information is missing or invalid:<ul>$erm</ul>Please make corrections and resubmit</font></ul>";
  $tv[99]="";
 }#end erm<>""
 
}#end 99<>""
 
if($tv[99] ne ""){
 
($sec, $min, $hr, $dom, $min, $year, $wkdy, $doy, $tz) = localtime(time);
$year=$year + 1900;
$mon=$mon+1;
if($day < 10){ $day="0$day" };
if($mon < 10){ $mon="0$mon" };
$fi[40]=$year.$mon.$day.$hr.$min.$sec;
 
#send email
$mailprog = '/usr/sbin/sendmail'; 
$sender='noreply@50thandfrance.com';
open (MAIL, "|$mailprog -t") or &dienice ("mail can not be sent.\n");
print MAIL "From: $sender\n";
print MAIL "To: director\@50thandfrance.com\n";
print MAIL "Cc: $fi[7]\n";
print MAIL "Subject: 2008 Edina Art Fair Volunteer\n\n";
 
print MAIL "   Name: $fi[1] $fi[2]\n";
print MAIL "  Email: $fi[7]\n";
print MAIL "    Age: $fi[11]\n";
print MAIL "T-Shirt: $fi[13]\n";
if($fi[3] ne ""){ print MAIL "Address: $fi[3]\n" };
if($fi[4] ne ""){ print MAIL "   City: $fi[4]\n" };
if($fi[5] ne ""){ print MAIL "  State: $fi[5]\n" };
if($fi[6] ne ""){ print MAIL "    ZIP: $fi[6]\n" };
if($fi[8] ne ""){ print MAIL "  Phone: $fi[8]\n" };
if($fi[9] ne ""){ print MAIL " NPhone: $fi[9]\n" };
if($fi[10] ne ""){ print MAIL " MPhone: $fi[10]\n" };
if($fi[12] ne ""){ print MAIL "  CName: $fi[12]\n" };
if($fi[14] ne ""){ print MAIL "Enter friend\'s name you would like to volunteer with\n$fi[14]\n" }; 
if($fi[15] ne ""){ print MAIL "Any special needs, comments, suggestions\n$fi[15]\n" };
print MAIL "\nSign-up Times\n";
for($x=18;$x<40;$x+=1){
 if($fi[$x] ne ""){
  print MAIL "  $fi[$x]\n";
 }#end if
}#end x
 
close(MAIL);
 
$out=join("\t",@fi);
open(BCOUT, ">>/srv/www/htdocs/50thandfrance/data/artfair/2007volunteer.txt");
 print BCOUT "$out\n";
close(BCOUT);
 
print "Thank you!<p>Your volunteer application has been received. A copy of this application has been sent to $fi[7].<p>\n";
 
}#end 99<>""
 
if($tv[99] eq ""){
 print"<p><img src=\"images/007.jpg\" align=right width=275><p><p>For volunteer opportunities and to become a volunteer.<br/><br/>Please contact:<br/>Rachel Hubbard<br/>952-922-1524<br/><a href=\"mailto:director\@50thandfrance.com\">director\@50thandfrance.com</a>\n";
}
 
if($tv[99] eq "bypass"){
 
$chk11[$fi[11]]="SELECTED";
$chk13{$fi[13]}="SELECTED";
for($x=18;$x<40;$x+=1){
 if($fi[$x] ne ""){
  $chk[$x]="CHECKED";
 }
}#end x
 
print <<end_html;
$erm<p>Thank you for your interest in volunteering at the 2008 Edina Art Fair!</p>
<p>Festival volunteers are needed in a variety of areas including but limited to set up, take down, registration, volunteer headquarters, booth sitter, patio, block ambassador and stage coordinator.
<p><strong><em>You must be at least 16 years of age to volunteer.</em></strong></p>
<p>We will be communicating through email.</p>
<form name="form" method="post" action="volunteer.cgi?$lvar">
<p align="center"><strong>Bold</strong> fields are required.<br>
 <table border="0" cellpadding="2" cellspacing="3" width="450">
  <tr>
   <td valign="top" align="left" colspan="2"><strong>Volunteer Registration</strong></td>
  <tr>
  
  <tr>
   <td valign="top" align="right"><strong>First Name</strong></td>
   <td valign="top" align="left"><input type="text" name="a1" value="$fi[1]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right"><strong>Last Name</strong></td>
   <td valign="top" align="left"><input type="text" name="a2" value="$fi[2]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Address</td>
   <td valign="top" align="left"><input type="text" name="a3" value="$fi[3]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">City</td>
   <td valign="top" align="left"><input type="text" name="a4" value="$fi[4]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">State</td>
   <td valign="top" align="left"><input type="text" name="a5" value="$fi[5]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">ZIP Code</td>
   <td valign="top" align="left"><input type="text" name="a6" value="$fi[6]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right"><strong>Email</strong></td>
   <td valign="top" align="left"><input type="text" name="a7" value="$fi[7]"></td>
  </tr>
 
  <tr>
   <td valign="top" align="right">Telephone</td>
   <td valign="top" align="left"><input type="text" name="a8" value="$fi[8]"></td>
  </tr>  
 
  <tr>
   <td valign="top" align="right"><strong>Age</strong></td>
   <td valign="top" align="left"><select name="a11"><option value="">Select</option>
   <option value="16" $chk11[16]>16 - 20</option>
   <option value="21" $chk11[21]>21 +</option>
   </select></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Company or Organization Name</td>
   <td valign="top" align="left"><input type="text" name="a12" value="$fi[12]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right"><strong>T-Shirt Size</strong></td>
   <td valign="top" align="left"><select name="a13"><option value="">Select</option>
   <option value="S" $chk13{S}>S</option>
   <option value="M" $chk13{M}>M</option>
   <option value="L" $chk13{L}>L</option>
   <option value="XL" $chk13{XL}>XL</option>
   <option value="XXL" $chk13{XXL}>XXL</option>
   </select></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Enter friend's name you<br>would like to volunteer with</td>
   <td valign="top" align="left"><input type="text" name="a14" value="$fi[14]"></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Any special needs, comments, suggestions</td>
   <td valign="top" align="left"><textarea name="a15" style="width: 200px; height: 90px">$fi[15]</textarea></td>
  </tr>
  
  <tr>
   <td valign="top" align="left" colspan="2"><strong>Sign-up Times</strong></td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Thursday (May 30)</td>
   <td valign="top" align="left">
   <input type="checkbox" name="a18" value="Th1530" $chk[18]> 3:30pm – 7:30pm<br>
   <input type="checkbox" name="a19" value="Th1730" $chk[19]> 5:30pm – 9:30pm
   </td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Friday (May 31)</td>
   <td valign="top" align="left">
   <input type="checkbox" name="a20" value="Fr1700" $chk[20]> 5:00am – 9:00am<br>
   <input type="checkbox" name="a21" value="Fr0800" $chk[21]> 8:00am – 12:00pm<br>
   <input type="checkbox" name="a22" value="Fr1100" $chk[22]> 11:00am – 3:00pm<br>
   <input type="checkbox" name="a23" value="Fr1400" $chk[23]> 2:00pm – 6:00pm<br>
   <input type="checkbox" name="a24" value="Fr1700" $chk[24]> 5:00pm – 9:00pm<br>
   </td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Saturday (June 1)</td>
   <td valign="top" align="left">
   <input type="checkbox" name="a25" value="Sa0800" $chk[25]> 8:00am – 12:00pm<br>
   <input type="checkbox" name="a26" value="Sa1100" $chk[26]> 11:00am – 3:00pm<br>
   <input type="checkbox" name="a27" value="Sa1400" $chk[27]> 2:00pm – 6:00pm<br>
   <input type="checkbox" name="a28" value="Sa1700" $chk[28]> 5:00pm – 9:00pm<br>
   <input type="checkbox" name="a29" value="Sa1900" $chk[29]> 7:00pm – 10:00pm<br>
   </td>
  </tr>
  
  <tr>
   <td valign="top" align="right">Sunday (June 2)</td>
   <td valign="top" align="left">
   <input type="checkbox" name="a30" value="Su0800" $chk[30]> 8:00am – 12:00pm<br>
   <input type="checkbox" name="a31" value="Su1100" $chk[31]> 11:00am – 4:00pm<br>
   <input type="checkbox" name="a32" value="Su1500" $chk[32]> 3:00pm – 7:00pm<br>
   <input type="checkbox" name="a33" value="Su1700" $chk[33]> 5:00pm – 9:00pm<br>
   </td>
  </tr>
  
  <tr>
   <td valign="top" align="left" colspan="2"><small><strong>Waiver of Liability:</strong> By submitting the Volunteer Registration Form, volunteer agrees to release and discharge the Edina Art Fair and 50th & France Business & Professional Association, the City of Minneapolis, the City of Edina and Hennepin County, all sponsoring organizations and their directors, officers, employees, agents, members and volunteers from any responsibliity, personal liability, claims, loss or damage arising out of or in conjunction with my participation at the Edina Art Fair.</small></td>
  </tr>
  
  <tr>
   <td valign="top" align="center" colspan="2"><input type="submit" value="Submit" name="t99"></td>
  </tr>
 </table>
</p>
</form>
end_html
 
}#end 99=""
 
 
print <<end_html;
</td>
<td background="images/body-bg.jpg" valign=top align=center><img src="images/spacer.gif" width=100 height=1><br>
end_html
 &Sponsors;
print <<end_html;
</td>
<td background="images/body-bg.jpg"><img src="images/spacer.gif" width=14 height=1></td></tr>
<tr><td colspan=6><img src="images/bottom.jpg" width=775 height=16></td></tr>
<tr><td colspan=6 align=center>
end_html
 &footer;
print <<end_html;
</td></tr>
</table>
</table>
<!end page table>
</body>
</html>
 
end_html
 
exit;
 

Re: Help with some perl

Posted: Sun Mar 09, 2008 1:43 pm
by Skara
Ok, so I just started learning perl a few days ago, but I'll tell you what I can.
So, thinking as I type...
Assuming you mean the <form> on line 223, it's controlled by $tv[99] = 'bypass';
I'm pretty sure this is set on line 74 by $tv[$sub]=$value;
$sub is created on 67, $name & $value on 63, $pair comes from @pairs, @pairs from $over.
I'm not familiar with read(), but I'm thinking $over comes from STDIN.

So... maybe 'bypass' needs to come through STDIN, I'm thinking.

Like I said, I just started learning perl the other day. :|

Re: Help with some perl

Posted: Mon Mar 31, 2008 12:23 pm
by QbertsBrother
thanks

i will look at that and see if i can figure it out.