AnnoyingTeen
Programmer
I'm writing a program for a civic association's website. I've already made a news update page, but I'm stuck now on the events page. All I need this page to do is list the upcoming events, but I need the events to be in order.
It comes from a form with a lot of drop down boxes, I'll give you the script for the form, and for the processor, all I need now is to make it show (in date order) on the page.
Here's the form:
#!C:\Perl\bin\perl
print "Content-type:text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>New news</title>\n";
print "<!--\n";
print "<BODY>\n";
print "-->\n";
print "</head>\n";
print "<body>\n";
print "<form method=\"post\" action=\"UpEventRead.pl\">\n";
print "Event Type:";
print "<SELECT name=\"type\">\n";
print "<OPTION value=\"cshca\">CSHCA Event\n";
print "<OPTION value=\"other\">Other Event\n";
print "</SELECT><BR>\n";
print "Date:\n";
print "<SELECT Name=\"month\"><OPTION value=\"0\">January<OPTION value=\"1\">February<OPTION value=\"2\">March<OPTION value=\"3\">April<OPTION value=\"4\">May<OPTION value=\"5\">June<OPTION value=\"6\">July<OPTION value=\"7\">August<OPTION value=\"8\">September<OPTION value=\"9\">October<OPTION value=\"10\">November<OPTION value=\"11\">December</SELECT>\n";
print "<SELECT name=\"day\"><OPTION value=\"1\">1<OPTION value=\"2\">2<OPTION value=\"3\">3<OPTION value=\"4\">4<OPTION value=\"5\">5<OPTION value=\"6\">6<OPTION value=\"7\">7<OPTION value=\"8\">8<OPTION value=\"9\">9<OPTION value=\"10\">10<OPTION value=\"11\">11<OPTION value=\"12\">12<OPTION value=\"13\">13<OPTION value=\"14\">14<OPTION value=\"15\">15<OPTION value=\"16\">16<OPTION value=\"17\">17<OPTION value=\"18\">18<OPTION value=\"19\">19<OPTION value=\"20\">20<OPTION value=\"21\">21<OPTION value=\"22\">22<OPTION value=\"23\">23<OPTION value=\"24\">24<OPTION value=\"25\">25<OPTION value=\"26\">26<OPTION value=\"27\">27<OPTION value=\"28\">28<OPTION value=\"29\">29<OPTION value=\"30\">30<OPTION value=\"31\">31</SELECT>\n";
print ", <SELECT Name=\"year\"><OPTION value=\"2006\">2006<OPTION value=\"2007\">2007<OPTION value=\"2008\">2008<OPTION value=\"2009\">2009<OPTION value=\"2010\">2010</select>\n";
print "<BR>\n";
print "Event: <textarea name=\"event\" cols=\"50\" rows=\"10\"></textarea><br>\n";
print "Password: <input type=\"password\" name=\"pass\"></input><br>\n";
print "<input name=\"button\" type=\"submit\" value=\"Submit\">\n";
print "</FORM>\n";
print "<!--\n";
print "</BODY>\n";
print "-->\n";
print "</body>\n";
print "</html>\n";
And here's the script that puts the data into a file:
#!C:\Perl\bin\perl
print "Content-type:text/html\n\n";
$pass = 0;
if( $ENV{'REQUEST_METHOD'} eq 'POST')
{read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'})};
@pairs = split(/&/, $buffer);
print "<html><head>\n";
print "<div name=\"Ad\" style=\"display:none\">\n";
print "<textarea><body></textarea> \n";
print "</div>\n";
print "<META HTTP-EQUIV=Refresh CONTENT=\"10; URL=\"Newnews.pl\">\n";
($key, $password) = split(/=/, $pairs[5]);
if($password eq "password")
{
foreach $pair( @pairs )
{
($key, $value) = split( /=/, $pair);
$value =~ tr/+/ /;
$key =~ s/%(..)/pack("c", hex($1))/eg;
$key =~ tr/+/ /;
$value =~ s/%(..)/pack("c", hex($1))/eg;
$value =~ s/fuck/****/;
$value =~ s/shit/****/;
$value =~ s/damn/****/;
$value =~ s/<!--(.|\n)*-->//g;
if( $formdata{$key} ){formdata{$key} .= ", $value"; }
else{ $formdata{$key} = $value; }
}
if($formdata{type} eq 'cshca') { open(Event,">>cshcaevent.txt"); }
else { open(Event, ">>cshcaotherevent.txt"); }
print Event "$formdata{'month'}&$formdata{'day'}&$formdata{'year'}&$formdata{'event'}\n";
close(Event);
$pass = 1;
print "<HEAD>\n";
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "<!-- Hide from older browsers\n";
print "alert('Your change has been made');\n";
print "// end hiding -->\n";
print "</SCRIPT>\n";
print "</HEAD>\n";
}
else {
print "<HEAD>\n";
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "<!-- Hide from older browsers\n";
print "alert('Incorrect Password'}');\n";
print "// end hiding -->\n";
print "</SCRIPT>\n";
print "</HEAD>\n";
}
print "</head><body background=\"print "<CENTER><TABLE height=\"100\%\"><TR><TD valign=\"middle\"><TABLE valign=\"center\" \"\#000000\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\"><TR><TD bgcolor=\"\#AAAAFF\"><CENTER><BR><BR>Please wait while we forward you back to the news update screen.<BR><BR></TD></TR><TR><TD bgcolor=\"\#0000FF\"><A HREF=\"Newevent.pl\"><CENTER>Or click here if you do not wish to wait.</A></TD></TR></TABLE></TD></TR></TABLE></CENTER>\n";
print "<!-- </body> --></body></html>\n";
print "</HTML>\n";
I dont think it should be that hard to make this, the data for the news page, to put it in order (I've already started to make changes):
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<head>\n";
print "<title></title>\n";
print "<div name=\"Ad\" style=\"display:none\">\n";
print "<textarea><body></textarea> \n";
print "</div>\n";
print "</HEAD>\n";
print "<body background=\"print "<BR><HR><BR><H1>CSHCA Events</H1></CENTER>\n";
open(events, "<cshcaevent.txt");
@events = <psts>;
close (psts);
foreach $line (@posts)
{
$post =~ s/fuck/****/;
$post =~ s/shit/****/;
$post =~ s/damn/****/;
print "<TABLE border=\"0\" width=\"100%\">\n";
print "<TR><TD bgcolor=\"666600\"><FONT color=\"FFFFFF\">Post By $name <div align=\"right\">$time</div></TD></TR>\n";
print "<TR><TD>$post</TD></TR>\n";
print "</TABLE>\n";
print "<BR>\n";
}
print "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100\%\">\n";
print "<tr>\n";
print "<td bgcolor=\"\#666600\"><font color=\"\#ffffff\">Post by Richard Balsano<div align=\"right\">12:02:00 Sunday, September 25</td></tr>\n";
print " <TR><TD><P>The SHUFSD voted to cancel their contract to buy Mohlenhoff property. We are on the Task Force to find an alternate bus depot site. Phase 2 now starts -- getting the town and county to buy the land for use in an environment and community friendly way.</P></TD></TR>\n";
print "</table>\n";
print "<CENTER><BR><HR><BR><H1>Site News</H1></CENTER>\n";
print "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100\%\">\n";
print "<tr>\n";
print "<td bgcolor=\"\#666600\"><font color=\"\#ffffff\">Post by Jonathan Balsano<div align=\"right\">07:21:00 Sunday, August 7</td></tr>\n";
print " <TR><TD><P>The website is ready, although we don't have many links yet...I hope this site will really help the CSHCA with communications between the members and getting their message out.</P></TD></TR>\n";
print "</table>\n";
print "<!--\n";
print "</Body>\n";
print "-->\n";
print "</Body>\n";
print "</html>\n";
So if you haven't figured out what I'm trying to do yet, because I'm really horrible at explaining my problems, I need to know the most effective way to arrange the events in date order when displayed
It comes from a form with a lot of drop down boxes, I'll give you the script for the form, and for the processor, all I need now is to make it show (in date order) on the page.
Here's the form:
#!C:\Perl\bin\perl
print "Content-type:text/html\n\n";
print "<html>\n";
print "<head>\n";
print "<title>New news</title>\n";
print "<!--\n";
print "<BODY>\n";
print "-->\n";
print "</head>\n";
print "<body>\n";
print "<form method=\"post\" action=\"UpEventRead.pl\">\n";
print "Event Type:";
print "<SELECT name=\"type\">\n";
print "<OPTION value=\"cshca\">CSHCA Event\n";
print "<OPTION value=\"other\">Other Event\n";
print "</SELECT><BR>\n";
print "Date:\n";
print "<SELECT Name=\"month\"><OPTION value=\"0\">January<OPTION value=\"1\">February<OPTION value=\"2\">March<OPTION value=\"3\">April<OPTION value=\"4\">May<OPTION value=\"5\">June<OPTION value=\"6\">July<OPTION value=\"7\">August<OPTION value=\"8\">September<OPTION value=\"9\">October<OPTION value=\"10\">November<OPTION value=\"11\">December</SELECT>\n";
print "<SELECT name=\"day\"><OPTION value=\"1\">1<OPTION value=\"2\">2<OPTION value=\"3\">3<OPTION value=\"4\">4<OPTION value=\"5\">5<OPTION value=\"6\">6<OPTION value=\"7\">7<OPTION value=\"8\">8<OPTION value=\"9\">9<OPTION value=\"10\">10<OPTION value=\"11\">11<OPTION value=\"12\">12<OPTION value=\"13\">13<OPTION value=\"14\">14<OPTION value=\"15\">15<OPTION value=\"16\">16<OPTION value=\"17\">17<OPTION value=\"18\">18<OPTION value=\"19\">19<OPTION value=\"20\">20<OPTION value=\"21\">21<OPTION value=\"22\">22<OPTION value=\"23\">23<OPTION value=\"24\">24<OPTION value=\"25\">25<OPTION value=\"26\">26<OPTION value=\"27\">27<OPTION value=\"28\">28<OPTION value=\"29\">29<OPTION value=\"30\">30<OPTION value=\"31\">31</SELECT>\n";
print ", <SELECT Name=\"year\"><OPTION value=\"2006\">2006<OPTION value=\"2007\">2007<OPTION value=\"2008\">2008<OPTION value=\"2009\">2009<OPTION value=\"2010\">2010</select>\n";
print "<BR>\n";
print "Event: <textarea name=\"event\" cols=\"50\" rows=\"10\"></textarea><br>\n";
print "Password: <input type=\"password\" name=\"pass\"></input><br>\n";
print "<input name=\"button\" type=\"submit\" value=\"Submit\">\n";
print "</FORM>\n";
print "<!--\n";
print "</BODY>\n";
print "-->\n";
print "</body>\n";
print "</html>\n";
And here's the script that puts the data into a file:
#!C:\Perl\bin\perl
print "Content-type:text/html\n\n";
$pass = 0;
if( $ENV{'REQUEST_METHOD'} eq 'POST')
{read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'})};
@pairs = split(/&/, $buffer);
print "<html><head>\n";
print "<div name=\"Ad\" style=\"display:none\">\n";
print "<textarea><body></textarea> \n";
print "</div>\n";
print "<META HTTP-EQUIV=Refresh CONTENT=\"10; URL=\"Newnews.pl\">\n";
($key, $password) = split(/=/, $pairs[5]);
if($password eq "password")
{
foreach $pair( @pairs )
{
($key, $value) = split( /=/, $pair);
$value =~ tr/+/ /;
$key =~ s/%(..)/pack("c", hex($1))/eg;
$key =~ tr/+/ /;
$value =~ s/%(..)/pack("c", hex($1))/eg;
$value =~ s/fuck/****/;
$value =~ s/shit/****/;
$value =~ s/damn/****/;
$value =~ s/<!--(.|\n)*-->//g;
if( $formdata{$key} ){formdata{$key} .= ", $value"; }
else{ $formdata{$key} = $value; }
}
if($formdata{type} eq 'cshca') { open(Event,">>cshcaevent.txt"); }
else { open(Event, ">>cshcaotherevent.txt"); }
print Event "$formdata{'month'}&$formdata{'day'}&$formdata{'year'}&$formdata{'event'}\n";
close(Event);
$pass = 1;
print "<HEAD>\n";
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "<!-- Hide from older browsers\n";
print "alert('Your change has been made');\n";
print "// end hiding -->\n";
print "</SCRIPT>\n";
print "</HEAD>\n";
}
else {
print "<HEAD>\n";
print "<SCRIPT LANGUAGE=\"JavaScript\">\n";
print "<!-- Hide from older browsers\n";
print "alert('Incorrect Password'}');\n";
print "// end hiding -->\n";
print "</SCRIPT>\n";
print "</HEAD>\n";
}
print "</head><body background=\"print "<CENTER><TABLE height=\"100\%\"><TR><TD valign=\"middle\"><TABLE valign=\"center\" \"\#000000\" cellpadding=\"0\" cellspacing=\"1\" border=\"0\"><TR><TD bgcolor=\"\#AAAAFF\"><CENTER><BR><BR>Please wait while we forward you back to the news update screen.<BR><BR></TD></TR><TR><TD bgcolor=\"\#0000FF\"><A HREF=\"Newevent.pl\"><CENTER>Or click here if you do not wish to wait.</A></TD></TR></TABLE></TD></TR></TABLE></CENTER>\n";
print "<!-- </body> --></body></html>\n";
print "</HTML>\n";
I dont think it should be that hard to make this, the data for the news page, to put it in order (I've already started to make changes):
#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<head>\n";
print "<title></title>\n";
print "<div name=\"Ad\" style=\"display:none\">\n";
print "<textarea><body></textarea> \n";
print "</div>\n";
print "</HEAD>\n";
print "<body background=\"print "<BR><HR><BR><H1>CSHCA Events</H1></CENTER>\n";
open(events, "<cshcaevent.txt");
@events = <psts>;
close (psts);
foreach $line (@posts)
{
$post =~ s/fuck/****/;
$post =~ s/shit/****/;
$post =~ s/damn/****/;
print "<TABLE border=\"0\" width=\"100%\">\n";
print "<TR><TD bgcolor=\"666600\"><FONT color=\"FFFFFF\">Post By $name <div align=\"right\">$time</div></TD></TR>\n";
print "<TR><TD>$post</TD></TR>\n";
print "</TABLE>\n";
print "<BR>\n";
}
print "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100\%\">\n";
print "<tr>\n";
print "<td bgcolor=\"\#666600\"><font color=\"\#ffffff\">Post by Richard Balsano<div align=\"right\">12:02:00 Sunday, September 25</td></tr>\n";
print " <TR><TD><P>The SHUFSD voted to cancel their contract to buy Mohlenhoff property. We are on the Task Force to find an alternate bus depot site. Phase 2 now starts -- getting the town and county to buy the land for use in an environment and community friendly way.</P></TD></TR>\n";
print "</table>\n";
print "<CENTER><BR><HR><BR><H1>Site News</H1></CENTER>\n";
print "<table cellpadding=\"0\" cellspacing=\"0\" width=\"100\%\">\n";
print "<tr>\n";
print "<td bgcolor=\"\#666600\"><font color=\"\#ffffff\">Post by Jonathan Balsano<div align=\"right\">07:21:00 Sunday, August 7</td></tr>\n";
print " <TR><TD><P>The website is ready, although we don't have many links yet...I hope this site will really help the CSHCA with communications between the members and getting their message out.</P></TD></TR>\n";
print "</table>\n";
print "<!--\n";
print "</Body>\n";
print "-->\n";
print "</Body>\n";
print "</html>\n";
So if you haven't figured out what I'm trying to do yet, because I'm really horrible at explaining my problems, I need to know the most effective way to arrange the events in date order when displayed