#!/usr/bin/perl
use CGI;
$query = new CGI;
#You need to modify this script at all parts of Step B
#Script Description
#Unique script ID: yel/coc/f/yel-5b2d
#Created on: 12/19/2001
#Last edited on: 12/19/2001
#Script class: D
#STEP A======
#A1. The following lines get and process data passed
#through the URL, do not modify
$stringpassed=$ENV{'QUERY_STRING'};
#A2. Replace all plusses with spaces for data passed via URL
$stringpassed=~s/\+/ /g;
#STEP B======
######################################################
# START OF CONFIGURATION
######################################################
#B1. REQUIRED: The location of event data file on your server.
$data="/home/mrgforce/public_html/usaent/cgi/ep/eventpublisher.txt";
#B1b. REQUIRED: The location of your TEMPORARY event data file on your server.
$tempdata="/home/mrgforce/public_html/usaent/cgi/ep/eventpublisher.tempdata";
#B1c. OPTIONAL: You can format the opening and closing HTML of your admin mode
$openinghtml="/home/mrgforce/public_html/usaent/ep/icons/template.htm";
#B2. REQUIRED: The URL of this file in your cgi directory. You must
#provide the full URL, beginning with http://
$thisurl="http://www.usaentertainment.com/cgi/eventpublisher_pro.cgi";
#B4. REQUIRED TO ADD, DELETE, OR MODIFY.
$adminpassword="ttt123";
$validationcode1="389afg741X";
#B5. URL to send users to after posting, editing, or getting errors.
#This is usually:
# (1) the admin form (if events are added by you most of the time) OR
# (2) the user submit form (if events are submitted by users most of the time)OR
# (3) this script itself (if you want to show the existing events after posting).
$forwardingURL="http://www.usaentertainment.com/ep/eventpublisher_usersearch-old.htm";
#B16. URL to the base ICON images directory for field:
#The URL should end with a forwardslash.
$baseurltoIcon="http://www.usaentertainment.com/ep/icons/";
#B17. Maximum number of events to display (sorted according to event date - event on
#December 01, 2001 will be displayed on top of event on December 31, 2001).
$maximumpage=150;
#B18. Font settings of the event display
$fontface ="Verdana, Arial"; ### Recommended: "Verdana, Arial"
$fontsize= "1"; ### Used for event title and description only ###
$fonttitlecolor = "#990000";
$fontsubtitlecolor ="#000080"; ### Used for event sub titles such as "Venue", "Date" ....
########################################################
# END OF CONFIGURATION
######################################################
$maximum=50000;
#####&do_diff_check;
@variablenames = $query->param;
foreach $variable (@variablenames){
$value=$query->param($variable);
$tempapprove{$variable}="$value";}
#STEP D================================
#You should not need to modify this section at all
#D1. Check to see if opening html file is on server
if (-e "$openinghtml"){
#D2. If so, open it and write opening and closing text to different strings
#to be used throughout the script
$problem="Can't open template file. Make sure you are referencing the file and not just a directory.";
open(OPENING, "$openinghtml") || &security;
@wholefile=;
close(OPENING);
$fulltemplate=join("\n",@wholefile);
($templatestart,$templateend)=split(/\+\+\+/,$fulltemplate);}
else{
#D3. If template file not found, use this for now
$templatestart="";
$templateend="";}
$delimiter="\t";
#D6. Get Password Entered by User
$checkpassword=$query->param('checkpassword');
#D7. Figure out what action user wants to take.
$actiontotake=$query->param('actiontotake');
$linenumberpass=$query->param('linenumberpass');
#D8. If user wants to delete record, and has already
#verified password, then go to the makechange subroutine
if ($actiontotake eq "Delete Record"){
$recordaction="Deleted";
&makechange;
exit;}
#D9. If user wants to edit record, and has already
#verified password, then go to the makechange subroutine
if ($actiontotake eq "Edit Record"){
$recordaction="Edited";
&makechange;
exit;}
#D10. If user wants to edit record, to go subroutine to verify
if ($actiontotake eq "Edit"){
&edit;
exit;}
#D11. If user wants to delete record, to go subroutine to verify
if ($actiontotake eq "Delete"){
&delete;
exit;}
#D12. If user wants to add record, go to add subroutine
if ($actiontotake eq "Add"){
&addrecord;
exit;}
#D13. If user wants to add record to temporary file
if ($actiontotake eq "Addtemp"){
&addtemp;
exit;}
#D14. If owner wants to evaluate records in temp file
if ($actiontotake eq "Scrolltemp"){
&scrolltemp;
exit;}
#D15. If user wants to update temp file
if ($actiontotake eq "Updatetemp"){
&updatetemp;
exit;}
#STEP E================================
#E1. Get the data passed from user
#PRO
$Icon=$query->param('Icon');
$Iconwork=lc($Icon);
#E1b. The line below chops characters that cause problems in Perl word searches
$Iconwork=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Iconwork eq "select"){
$Iconwork="";
$Icon="";}
$Iconpass="$Icon";
$Event=$query->param('Event');
$Eventwork=lc($Event);
#PRO
$Eventwork=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Eventwork eq "select"){
$Eventwork="";
$Event="";}
$Eventpass="$Event";
$Description=$query->param('Description');
$Descriptionwork=lc($Description);
#PRO
$Descriptionwork=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Descriptionwork eq "select"){
$Descriptionwork="";
$Description="";}
$Descriptionpass="$Description";
#E1. Get the data passed from user
$Venue=$query->param('Venue');
$Venuework=lc($Venue);
#PRO
$Venuework=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Venuework eq "select"){
$Venuework="";
$Venue="";}
$Venuepass="$Venue";
$Month=$query->param('Month');
$Monthwork=lc($Month);
#PRO
$Monthwork=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Monthwork eq "select"){
$Monthwork="";
$Month="";}
$Monthpass="$Month";
$Day=$query->param('Day');
$Daywork=lc($Day);
#PRO
$Daywork=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Daywork eq "select"){
$Daywork="";
$Day="";}
$Daypass="$Day";
$Year=$query->param('Year');
$Yearwork=lc($Year);
#PRO
$Yearwork=~tr/[a-zA-Z0-9 \-\.\,\?]/ /cd;
if ($Yearwork eq "select"){
$Yearwork="";
$Year="";}
$Yearpass="$Year";
#E6. Get number of records already displayed
$startitem=$query->param('startitem');
#E7. Figure the last record to display on this page
$enditem=$startitem+$maximumpage;
#F4a. Support for European characters.
#PRO
($Iconone, $Icontwo, $Iconthree, $Iconfour, $Iconfive, $Iconsix, $Iconseven)=split(/ /, $Iconwork);
#F4a. Support for European characters.
($Eventone, $Eventtwo, $Eventthree, $Eventfour, $Eventfive, $Eventsix, $Eventseven)=split(/ /, $Eventwork);
#F4a. Support for European characters.
$Lo1="P"; $Lo2="is";
($Descriptionone, $Descriptiontwo, $Descriptionthree, $Descriptionfour, $Descriptionfive, $Descriptionsix, $Descriptionseven)=split(/ /, $Descriptionwork);
$Text1="Fr"; $Text2="Ev"; $Text3="her";
#F4a. Support for European characters.
$Hi1="ee"; $Hi2="ent"; $Hi3="ubl";
($Venueone, $Venuetwo, $Venuethree, $Venuefour, $Venuefive, $Venuesix, $Venueseven)=split(/ /, $Venuework);
#F4a. Support for European characters.
($Monthone, $Monthtwo, $Monththree, $Monthfour, $Monthfive, $Monthsix, $Monthseven)=split(/ /, $Monthwork);
($Dayone, $Daytwo, $Daythree, $Dayfour, $Dayfive, $Daysix, $Dayseven)=split(/ /, $Daywork);
#F4a. Support for European characters.
$comp1="INT"; $comp2="O"; $comp3="U"; $lcomp1="int"; $lcomp2="po"; $lcomp3="u";
$and1="b"; $and2="y";
($Yearone, $Yeartwo, $Yearthree, $Yearfour, $Yearfive, $Yearsix, $Yearseven)=split(/ /, $Yearwork);
#STEP G================================
#Do not modify this section
#G1. Open datafile and write contents to an array, if can't open report the problem at the security subroutine
$problem="You do not have a file to search on the server. Please ADD test records before trying to search your test data file.";
open (FILE, "$data") || &security;
@all=;
close (FILE);
#G2. The line below is required, do not modify
print "Content-type: text/html\n\n";
#G3. Display HTML Header
if ($adminpassword eq $checkpassword){
print "$templatestart\n";}
else {
######### Show Top of Page with Graphic, Search & Submit Links
print "
\n";
######### Show Day & Date on Page
@timedisp = localtime;
@months = qw(January February March April May June July August September October November December);
@dayofweek = qw(Sunday Monday Tuesday Wednesday Thursday Friday Saturday);
$monthdisp = $months[$timedisp[4]];
$daydisp = $dayofweek[$timedisp[6]];
print "
It\'s \n"; print "$daydisp $monthdisp $timedisp[3], "; print $timedisp[5] + 1900; print " \n";
}
#print "";}
#STEP H================================
#H1. Read each line of the data file, compare with search words
foreach $line (@all){
$line=~s/\n//g;
$loopsaround++;
$checkleng=length($line);
if ($checkleng<2){next};
$linetemp1=lc($line);
#H1a. Support for European characters.
($Icon,$Event,$Description,$Venue,$Day,$Month,$Year,$Time,$Website,$Email,$Public_Remarks,$Private_Remarks,$Image_Upload,$RecordID,$skipthisfield)=split (/$delimiter/,$linetemp1);
#H9. This line specifies the fields to sort results by
$line="$Year$Month$Day$Event$delimiter$loopsaround$delimiter$line";
#H9.5 This line removes stray leading spaces before sorting your results
$line=~s/^ +//;
$increcount=0;
#PRO
#H12. Look for matches in fields
if (($Icon =~/\b$Iconone/ && $Icon =~/\b$Icontwo/ && $Icon =~/\b$Iconthree/ && $Icon =~/\b$Iconfour/ && $Icon =~/\b$Iconfive/ && $Icon=~/\b$Iconsix/ && $Icon=~/\b$Iconseven/) || !$Iconwork) {
$increcount++;}
if (($Event =~/\b$Eventone/ && $Event =~/\b$Eventtwo/ && $Event =~/\b$Eventthree/ && $Event =~/\b$Eventfour/ && $Event =~/\b$Eventfive/ && $Event=~/\b$Eventsix/ && $Event=~/\b$Eventseven/) || !$Eventwork) {
$increcount++;}
if (($Description =~/\b$Descriptionone/ && $Description =~/\b$Descriptiontwo/ && $Description =~/\b$Descriptionthree/ && $Description =~/\b$Descriptionfour/ && $Description =~/\b$Descriptionfive/ && $Description=~/\b$Descriptionsix/ && $Description=~/\b$Descriptionseven/) || !$Descriptionwork) {
$increcount++;}
if (($Venue =~/\b$Venueone/ && $Venue =~/\b$Venuetwo/ && $Venue =~/\b$Venuethree/ && $Venue =~/\b$Venuefour/ && $Venue =~/\b$Venuefive/ && $Venue=~/\b$Venuesix/ && $Venue=~/\b$Venueseven/) || !$Venuework) {
$increcount++;}
if ($Monthpass == "" && $Daypass == "") {
$increcount++;}
elsif ($Monthpass == $Month && $Daypass == "") {
$increcount++;}
elsif ($Monthpass == "" && $Daypass == $Day) {
$increcount++;}
elsif ($Monthpass == $Month && $Daypass == $Day) {
$increcount++;}
if (($Year =~/\b$Yearone/ && $Year =~/\b$Yeartwo/ && $Year =~/\b$Yearthree/ && $Year =~/\b$Yearfour/ && $Year =~/\b$Yearfive/ && $Year=~/\b$Yearsix/ && $Year=~/\b$Yearseven/) || !$Yearwork) {
$increcount++;}
if ($line=~/markedtoedit/ && $actiontotake eq "markedtoedit"){
$line=~s/markedtoedit//g;
push (@keepers2,$line);}
$line=~s/markedtoedit//g;
if ($increcount==6){
push (@keepers,$line);}}
#STEP J=======
if ($actiontotake eq "markedtoedit"){
@keepers=@keepers2;}
#J1. Sort matches stored in array.
@keepers=sort(@keepers);
#J2. Get and display number of matches found
$length1=@keepers;
#J3. If the number of matches is less than enditem, adjust
if ($length1<$enditem){
$enditem=$length1;
$displaystat="Y";}
#J4. The first field about to display
$disstart=$startitem+1;
##### Show Total Posted
#J5. Show user total number of matches found & display on screen
if ($length1){
print "<\/font>\n";
#print "Total Events Posted ... $length1<\/font>\n";
} else {
print "
No local events found for your search criteria.<\/B> Press your Browsers Back Button and try again.<\/P>\n";}
#STEP K=====
################ FROM NEW PROGRAM ################
#Server time vs. local time adjustment
#Turn it on to show the current date and time. This is to ease
#troubleshooting. Turn it OFF once everything is working fine.
$debug = "0"; #Debug mode 1 = ON 0 = OFF
$offset = 180; #Time offset in minutes. Default is zero for no adjustment.
#Formatting for Today Date
($secstamp,$minstamp,$hourstamp,$mdaystamp,$monthstamp,$yearstamp,$wdaystamp,$dayofyearstamp,$isdst1stamp) = localtime(time+($offset*60));
$monthstamp++;
$yearstamp=1900+$yearstamp;
if (length($monthstamp)==1){
$monthstamp="0$monthstamp";}
if (length($mdaystamp)==1){
$mdaystamp="0$mdaystamp";}
if (length($hourstamp)==1){
$hourstamp="0$hourstamp";}
if (length($minstamp)==1){
$minstamp="0$minstamp";}
if (length($secstamp)==1){
$secstamp="0$secstamp";}
$todaydate="
Current date: $yearstamp/$monthstamp/$mdaystamp Current time: $hourstamp:$minstamp:$secstamp - This date and time are displayed here for server time vs. local time adjustment checking only. Please go to Step K in upevent.cgi and set the \$offset switch until they match your local time. Then turn off this box by setting \$debug to 0.
";
if ($debug){
print "$todaydate";}
############## PARTIAL END OF FROM NEW PROGRAM - MORE BELOW ################
#K1. Do some HTML formatting before showing results
print "
\n";
#K4. Keep track of results processed on this page
foreach $line (@keepers){
#K5. Delete stray hard returns
$line=~s/\n//g;
#K6. Keep track of records displayed
$countline1++;
#K7. Decide whether or not this record goes on this page
if ($countline1>$startitem && $countline1<=$enditem){
#K8. Open each line of sorted array for displaying
($sortfield,$loopsaround,$Icon,$Event,$Description,$Venue,$Day,$Month,$Year,$Time,$Website,$Email,$Public_Remarks,$Private_Remarks,$Image_Upload,$RecordID,$skipthisfield)=split (/$delimiter/,$line);
if ($Month eq "01"){
$Month2 = "January";}
if ($Month eq "02"){
$Month2 = "February";}
if ($Month eq "03"){
$Month2 = "March";}
if ($Month eq "04"){
$Month2 = "April";}
if ($Month eq "05"){
$Month2 = "May";}
if ($Month eq "06"){
$Month2 = "June";}
if ($Month eq "07"){
$Month2 = "July";}
if ($Month eq "08"){
$Month2 = "August";}
if ($Month eq "09"){
$Month2 = "September";}
if ($Month eq "10"){
$Month2 = "October";}
if ($Month eq "11"){
$Month2 = "November";}
if ($Month eq "12"){
$Month2 = "December";}
############# MORE FROM NEW PROGRAM - TO DISPLAY NEW EVENTS ###############
$localdate = "$yearstamp$monthstamp$mdaystamp";
$eventdate = "$Year$Month$Day";
if (($eventdate >= $localdate) or (($eventdate >= $localdate) and ($adminpassword eq $checkpassword))){
############# END OF FROM NEW PROGRAM ##############################
#K15. Formatting for ad separating line.
print "
\n";
#K15. Formatting for field Day. If you add any HTML, make sure you
#put a backslash in front of all quote marks inside print statements
if ($Day){
print "
Date:
$Month2 $Day, $Year
\n";}
#K15. Formatting for field Event. If you add any HTML, make sure you
if ($Public_Remarks eq "YES" && $RecordID ne ""){
print "
\n";}
#K15. Formatting for field Venue.
if ($Venue){
print "
Where:
$Venue
\n";}
#K15. Formatting for field Time. If you add any HTML, make sure you
#put a backslash in front of all quote marks inside print statements
#if ($Time){
#print "
Time:
$Time
\n";}
#K15. Formatting for field Website. If you add any HTML, make sure you
#put a backslash in front of all quote marks inside print statements
if ($Website && $Email){
print "
\n";}
#K15. Formatting for field Public_Remarks.
#if ($Public_Remarks){
#print "
$Public_Remarks
\n";}
#K11. Check passwords before showing edit and delete buttons
if ($adminpassword eq $checkpassword){
print "
\n";}
######### FROM NEW PROGRAM TO END ############
}
else {
$skip1 = $skip1+1;
$countline1 = $countline1-1;}
########## END FROM NEW PROGRAM TO END ########
#STEP L====
#L1. If total displayed equals maximum you set, then exit
if ($countline1 == $maximum && $maximum){
$problem2="Your search was terminated because there were more than $maximum matching records found, please be more specific in your search";
last;}
#L2. If script just got to last match then exit program
if ($length1 == $countline1){
last;}
#L3. If script is at the end of a page then show NEXT button
if ($countline1 == $enditem && $displaystat ne "Y" && $maximum>$countline1){
$stopit="Y";
last;
}
}}
###print "
\n";
$fcc="f"; $fcd="1"; $fce="w"; $fcf="tp"; $fcg="dn"; $fci="e";
$checkfcc="ne"; $checkfcd="t"; $checkfcf="s"; $checkfcg="ef"; $checkfci="ank"; $checkfcj="_bl";
$mer1="";
$mer3=" ";
# Formatting for separating line at bottom above Next Button.
print "
\n";
print "
\n";
#L4. Display NEXT MATCHES button
#if ($stopit eq "Y"){
#print " \n";
######### Copyright
print "Copyright © 1998-$yearstamp ... All Rights Reserved \n";
print "USAENTERTAINMENT.COM \n";
print "TAMPABAYMUSICSCENE.COM
\n";
#}
#L6. Show problems
if ((!$mer1) or (!$mer2) or (!$mer3)){
&low;}
if ($problem2){
print "$problem2";}
else {
print "$mer3";
}
#L8. If opening.htm was found, show its closing html codes
if (!$errormode) {
&low;}
srand();
$checkval=int(rand(30));
if ($checkval==3){
print "";}
if ($adminpassword eq $checkpassword){
print "$templateend\n";}
else {
print "";}
exit;
#STEP M=====
sub security{
#M1. This is the subroutine that reports all problems
print "Content-type: text/html\n\n";
print "$templatestart\n";
print "
Data Error
\n";
print "Please correct the following error:
$problem
\n";
print "$templateend\n";
exit;
}
sub low{
#M1. This is the subroutine that reports all problems
print "$templatestart\n";
print "
Data Error
\n";
print "Error:
Script Corrupted!
\n";
print "$templateend\n";
exit;
}
#STEP N=====
sub edit{
#N1. Open data file and read it
$problem="Can't open data file to read from it at edit subroutine";
open (FILE,"$data") || &security;
@all=;
close (FILE);
#N2. Read each line of the data file
foreach $line (@all){
$line=~s/\n//g;
($copyIcon,$copyEvent,$copyDescription,$copyVenue,$copyDay,$copyMonth,$copyYear,$copyTime,$copyWebsite,$copyEmail,$copyPublic_Remarks,$copyPrivate_Remarks,$copyImage_Upload,$copyRecordID,$skipthisfield)=split (/$delimiter/,$line);
$keepcount++;
#N3. Find the line user wants to modify
if ($keepcount==$linenumberpass){
$linetokeep=$line;
$linetokeep=~s/markedtoedit//g;
last;
}
}
#N4. Check password sent via hidden field
if ($adminpassword ne $checkpassword){
$problem="Your password does not match the master password, please re-enter.";
&security;}
#N6. Split matching line into its respective variables
($Icon,$Event,$Description,$Venue,$Day,$Month,$Year,$Time,$Website,$Email,$Public_Remarks,$Private_Remarks,$Image_Upload,$RecordID,$skipthisfield)=split (/$delimiter/,$linetokeep);
#Required Header, do not delete
print "Content-type: text/html\n\n";
#N8. If can't find opening html, display default header
print "$templatestart\n";
print "
Admin Mode: Edit this Record\n";
print "
\n";
print "$templateend\n";
exit;
}
#STEP O====
sub delete{
#O1. Open data file and read it
$problem="Can't open data file to read from it at delete subroutine";
open (FILE,"$data") || &security;
@all=;
close (FILE);
#O2. Read each line of the file
foreach $line (@all){
$line=~s/\n//g;
($copyIcon,$copyEvent,$copyDescription,$copyVenue,$copyDay,$copyMonth,$copyYear,$copyTime,$copyWebsite,$copyEmail,$copyPublic_Remarks,$copyPrivate_Remarks,$copyImage_Upload,$copyRecordID,$skipthisfield)=split (/$delimiter/,$line);
$keepcount++;
#O3. Find line to delete
if ($keepcount==$linenumberpass){
$linetokeep=$line;
$linetokeep=~s/markedtoedit//g;
last;
}
}
($Icon,$Event,$Description,$Venue,$Day,$Month,$Year,$Time,$Website,$Email,$Public_Remarks,$Private_Remarks,$Image_Upload,$RecordID,$skipthisfield)=split (/$delimiter/,$linetokeep);
#O4. Check password sent via hidden field
if ($adminpassword ne $checkpassword){
$problem="Your password does not match the master password.";
&security;}
#O6. Required Header, do not delete
print "Content-type: text/html\n\n";
print "$templatestart\n";
print "
Admin Mode: Delete this Record?\n";
($Icon,$Event,$Description,$Venue,$Day,$Month,$Year,$Time,$Website,$Email,$Public_Remarks,$Private_Remarks,$Image_Upload,$RecordID,$skipthisfield)=split (/$delimiter/,$linetokeep);
#O7. Show validation HTML
print "
\n";
#If opening.htm was not found, show default closing html codes
print "$templateend\n";
exit;
}
#STEP P======
sub makechange{
#P1. Go to get variable subroutine and make sure add preferences apply
if ($recordaction eq "Edited"){
&getvariables;}
#P2. This step either replaces or empties the existing line
if ($recordaction eq "Deleted"){
$replacementline="";}
else{
$replacementline="$Icon$delimiter$Event$delimiter$Description$delimiter$Venue$delimiter$Day$delimiter$Month$delimiter$Year$delimiter$Time$delimiter$Website$delimiter$Email$delimiter$Public_Remarks$delimiter$Private_Remarks$delimiter$Image_Upload$delimiter$RecordID";}
$problem="Can't open data file to read from it";
open (FILE,"$data") || &security;
@all=;
close (FILE);
$linenumberpass--;
$all[$linenumberpass]=$replacementline;
$problem="Can't open temporary file. You need to chmod 777 the directory your data file is in. See the help files under Permissions for Class B Scripts.";
#P6. Write the entire changed file to a temporary file
open (FILE2,">$data.tmp") || &security;
foreach $line (@all){
$line=~s/\n//g;
print FILE2 "$line\n";}
close(FILE2);
#P7. Rename the temp file to your master data file
$problem="Can't rename file after making change";
rename("$data.tmp", "$data") || &security;
print "Content-type: text/html\n\n";
#P8. If can't find opening html, display default header
print "$templatestart\n";
print "Your record has been $recordaction. Please click here to continue.\n";
close (FILE);
#If opening.htm was not found, show default closing html codes
print "$templateend\n";
exit;
}
#STEP Q===
#This subroutine adds records to your database
sub addrecord{
#Q1. Check password
if ($adminpassword ne $checkpassword && $adminpassword){
$problem="The password you entered does not match your administration password. Please press BACK on your browser to fix this problem.";
&security;}
&getvariables;
$replacementline="$Icon$delimiter$Event$delimiter$Description$delimiter$Venue$delimiter$Day$delimiter$Month$delimiter$Year$delimiter$Time$delimiter$Website$delimiter$Email$delimiter$Public_Remarks$delimiter$Private_Remarks$delimiter$Image_Upload$delimiter$RecordID";
#Q3. Write the new record to the bottom of the data file
$problem="Can't write to the data file. Please verify its location and change its permissions to 777.";
open (FILE2,">>$data") || &security;
print FILE2 "$replacementline\n";
close(FILE2);
print "Content-type: text/html\n\n";
#Q4. If can't find opening html, display default header
print "$templatestart\n";
print "Your record has been added. Please click here to continue.\n";
#If opening.htm was not found, show default closing html codes
print "$templateend\n";
exit;
}
#STEP R===
sub getvariables{
#R1. This step checks your variables before adding/editing them
$Icon=$query->param('Icon');
$Event=$query->param('Event');
$Description=$query->param('Description');
$Private_Remarks=$query->param('Private_Remarks');
$Venue=$query->param('Venue');
if ($Venue eq "Choose From The Many Venues Listed Here ... Or Enter the Info Below"){
$Venue=$Private_Remarks;}
$Day=$query->param('Day');
$Month=$query->param('Month');
$Year=$query->param('Year');
$Time=$query->param('Time');
$Website=$query->param('Website');
$Email=$query->param('Email');
$Public_Remarks=$query->param('Public_Remarks');
$checkcodepass1=$query->param('checkcodepass1');
#R3. Replace hard returns with , cut carriage returns
$Icon=~s/\n/ /g;
$Icon=~s/\r//g;
if ($Icon eq "Select"){
$Icon="";}
#R3. Replace hard returns with , cut carriage returns
$Event=~s/\n/ /g;
$Event=~s/\r//g;
if ($Event eq "Select"){
$Event="";}
#R3. Replace hard returns with , cut carriage returns
$Description=~s/\n/ /g;
$Description=~s/\r//g;
$Description=~s/\t//g;
if ($Description eq "Select"){
$Description="";}
#R3. Replace hard returns with , cut carriage returns
$Venue=~s/\n/ /g;
$Venue=~s/\r//g;
if ($Venue eq "Select"){
$Venue="";}
#R3. Replace hard returns with , cut carriage returns
$Day=~s/\n/ /g;
$Day=~s/\r//g;
if ($Day eq "Select"){
$Day="";}
#R3. Replace hard returns with , cut carriage returns
$Month=~s/\n/ /g;
$Month=~s/\r//g;
if ($Month eq "Select"){
$Month="";}
#R3. Replace hard returns with , cut carriage returns
$Year=~s/\n/ /g;
$Year=~s/\r//g;
if ($Year eq "Select"){
$Year="";}
#R3. Replace hard returns with , cut carriage returns
$Time=~s/\n/ /g;
$Time=~s/\r//g;
if ($Time eq "Select"){
$Time="";}
#R3. Replace hard returns with , cut carriage returns
$Website=~s/\n/ /g;
$Website=~s/\r//g;
if ($Website eq "Select"){
$Website="";}
#R3. Replace hard returns with , cut carriage returns
$Email=~s/\n/ /g;
$Email=~s/\r//g;
if ($Email eq "Select"){
$Email="";}
#R3. Replace hard returns with , cut carriage returns
$Public_Remarks=~s/\n/ /g;
$Public_Remarks=~s/\r//g;
if ($Public_Remarks eq "Select"){
$Public_Remarks="";}
#R3. Replace hard returns with , cut carriage returns
$Private_Remarks=~s/\n/ /g;
$Private_Remarks=~s/\r//g;
if ($Private_Remarks eq "Select"){
$Private_Remarks="";}
#R4. You have marked Event as a field that must contain at least 2
$Eventcheck=$Event;
$Eventcheck=~s/ +/ /g;
$Eventcheck=length($Eventcheck);
if ($Eventcheck<2){
$problem="Please press back on your browser and provide more information for the .. Event .. field.";
&security;}
#R4. You have marked Description as a field that must contain at least 2
$Venuecheck=$Venue;
$Venuecheck=~s/ +/ /g;
$Venuecheck=length($Venuecheck);
if ($Venuecheck<2){
$problem="Please press the Back Button on your browser and provide more information for the .. Venue .. Field. It is either not indicated in the dropdown box or not indicated in the additional field provided";
&security;}
#R4. You have marked Day as a field that must contain at least 1
$Daycheck=$Day;
$Daycheck=~s/ +/ /g;
$Daycheck=length($Daycheck);
if ($Daycheck<1){
$problem="Please press back on your browser and provide more information for the .. Day .. field.";
&security;}
#R4. You have marked Month as a field that must contain at least 1
#non-blank characters before allowing the field to be added. You can change the
#requirement below, or comment out all 6 lines below step to skip validation
$Monthcheck=$Month;
$Monthcheck=~s/ +/ /g;
$Monthcheck=length($Monthcheck);
if ($Monthcheck<1){
$problem="Please press back on your browser and provide more information for the .. Month .. field.";
&security;}
#R4. You have marked Year as a field that must contain at least 2
#non-blank characters before allowing the field to be added. You can change the
#requirement below, or comment out all 6 lines below step to skip validation
$Yearcheck=$Year;
$Yearcheck=~s/ +/ /g;
$Yearcheck=length($Yearcheck);
if ($Yearcheck<2){
$problem="Please press back on your browser and provide more information for the .. Year .. field.";
&security;}
#R4. You have marked Time as a field that must contain at least 2
#$Timecheck=$Time;
#$Timecheck=~s/ +/ /g;
#$Timecheck=length($Timecheck);
#if ($Timecheck<2){
#$problem="Please press back on your browser and provide more information for the .. Time .. field - at least 2 letters or numbers.";
#&security;}
#R10. You have marked Email as a field that must contain a valid e-mail
#Address, OR, be empty. To remove requirement, comment out 9 lines below
$Emailcheck=$Email;
($firstpart,$secondpart)=split(/\@/,$Emailcheck);
if ($Email && (!$firstpart || !$secondpart || $secondpart!~/\./)){
$problem="The information you have provided in the e-mail field does not look like a valid e-mail address. Please press back on your browser and fix this problem.";
&security;}
#R11. Remove characters that could cause security issues in e-mail field
if ($Emailcheck =~/[\!\|\~\^\'\"]/){
$problem="The information you entered into the e-mail field contains illegal characters. This field should contain letters, numbers, the \@ symbol, and periods only. Please press BACK and fix this problem.";
&security;}
#R13. You have marked Website as a field that must contain a valid hyperlink - FROM NEW SCRIPT
#To remove this requirement, comment out all 4 lines below
$Websitecheck=substr($Website,0,7);
if ($Website && $Websitecheck!~/http:\/\//i){
$problem="The information you have provided in the Website field does not look like a valid hyperlink. As stated, the web address MUST BEGIN WITH http:// . Please press the back button in your browser to fix this problem.";
&security;}
#R14. Check validation code
if ($checkcodepass1 ne $validationcode1){
$problem="The validation code you entered does not match. Please press the BACK BUTTON on your browser to fix this problem.";
&security;}
}
#STEP S====
sub addtemp{
#S1. This subroutine adds records to your temporary file for approval
#S2. Check variable sent
&getvariables;
#S3. Randomize in preparation for random generator
srand();
#S4. Get IP address of person posting record
$ipstamp=$ENV{'REMOTE_ADDR'};
#S5. Generate a large random number to serve as key
$randnumb=int(rand(9999999));
$replacementline="$ipstamp&&temp$randnumb(\+\+)$Icon$delimiter$Event$delimiter$Description$delimiter$Venue$delimiter$Day$delimiter$Month$delimiter$Year$delimiter$Time$delimiter$Website$delimiter$Email$delimiter$Public_Remarks$delimiter$Private_Remarks$delimiter$Image_Upload$delimiter$RecordID";
#S6. Write the temp record to the bottom of the
$problem="Can't write to the data file. Please verify its location and change its permissions to 777.";
open (FILE2,">>$tempdata") || &security;
print FILE2 "$replacementline\n";
close(FILE2);
print "Content-type: text/html\n\n";
print "
\n";
print "$templatestart\n";
#S7. Acknowledge that record has been posted
print "Your record has been sent to the WebMaster for approval. Please click here to return to the Events Calendar .. OR ... Use your Browser's Back Button to submit more Events.\n";
print "$templateend\n";
exit;
}
#STEP T====
sub scrolltemp{
#T1. This step is your interface with the temp file
#T2. Check password
if ($adminpassword ne $checkpassword && $adminpassword){
$problem="The password you entered does not match your administration password. Please press BACK on your browser to fix this problem.";
&security;}
#T3. Check to make sure that the data file can be opened.
$problem="Unable to open your temporary data file. It either contains no records, or the path to it is incorrect.";
open (FILE, "$tempdata") || &security;
@all=;
close (FILE);
print "Content-type: text/html\n\n";
#T4. Start showing contents of data file
print "$templatestart\n";
print "\n";}
else{
print "\n";}
print "$templateend\n";
exit;
}
#STEP U=======
sub updatetemp{
#U1. This step makes changes from temp file
#U2. Check password
if ($adminpassword ne $checkpassword && $adminpassword){
$problem="The password you entered does not match your administration password. Please press BACK on your browser to fix this problem.";
&security;}
$problem="Unable to open your temporary data file. It either contains no records, or the path to it is incorrect.";
open (FILE, "$tempdata") || &security;
@all=;
close (FILE);
foreach $line (@all){
$line=~s/\n//g;
$checkleng=length($line);
if ($checkleng<2){next};
($indexvalues,$stringvalues)=split(/\(\+\+\)/,$line);
($ipaddress,$uniqueapproval)=split(/&&/,$indexvalues);
($Icon,$Event,$Description,$Venue,$Day,$Month,$Year,$Time,$Website,$Email,$Public_Remarks,$Private_Remarks,$Image_Upload,$RecordID,$skipthisfield)=split (/$delimiter/,$stringvalues);
if ($tempapprove{$uniqueapproval} eq "A"){
push(@recordstoadd,$stringvalues);}
elsif ($tempapprove{$uniqueapproval} eq "D"){
push(@recordstodelete,$stringvalues);}
elsif ($tempapprove{$uniqueapproval} eq "E"){
push(@recordstoedit,$stringvalues);}
else {
push(@recordstohold,$line);}
}
$problem="Unable to open data file to add records. Check path to it and its permissions.";
open (FILE, ">>$data") || &security;
foreach $line (@recordstoadd){
$line=~s/\n//g;
print FILE "$line\n";}
close(FILE);
$problem="Unable to open data file to records to edit. Check path to it and its permissions.";
open (FILE, ">>$data") || &security;
foreach $line (@recordstoedit){
$line=~s/\n//g;
print FILE "markedtoedit$line\n";}
close(FILE);
$problem="Unable to open temporary file to refresh data. Check path to it and its permissions.";
open (FILE, ">$tempdata") || &security;
foreach $line (@recordstohold){
$line=~s/\n//g;
print FILE "$line\n";}
close(FILE);
$checkhold=@recordstohold;
if ($checkhold){
&scrolltemp;}
print "Content-type: text/html\n\n";
print "$templatestart\n";
print "
Your actions have been taken. Please click here to continue.
\n";
print "$templateend\n";
exit;
}
sub read{
my ($open_file)=@_;
open(DAT, "$open_file") ;
my @data=;
close(DAT);
return @data;
}
sub write{
my ($writeto_file,@write)=@_;
my ($abc,$output);
foreach $abc(@write){
$output="$output\n$abc";
for ($output){
s/^\s+//;
s/\s+$//;
}
}
flock(DAT, 2);
open(DAT,">$writeto_file");
print DAT "$output\n";
close(DAT);
flock(DAT, 8);
}
sub do_diff_check{
my(@today) = localtime(time);
$today[5]=$today[5]+1900;
$today[4]=$today[4]+1;
if($today[4]<10){
$today[4]="0$today[4]";
}
if($today[3]<10){
$today[3]="0$today[3]";
}
my $today_date="$today[5]$today[4]$today[3]";
my @data_temp=&read($data);
foreach my $line(@data_temp){
my(@fields)=split(/\t/,$line);
my $temp_date="$fields[6]$fields[5]$fields[4]";
if($temp_date < $today_date){
$diff_marker=1;
last;
}
}
my (@output);
if($diff_marker){
foreach my $line(@data_temp){
my(@fields)=split(/\t/,$line);
my $temp_date="$fields[6]$fields[5]$fields[4]";
if($temp_date >=$today_date){
push(@output,$line);
}
}
&write($data,@output);
print "$line\n";
}
}