discourse-legacysite-perl/site/racecalendar/edit_Confirm.php
2024-06-17 22:42:14 +10:00

392 lines
16 KiB
PHP

<?PHP
if (!$_POST){ header('Location: https://slowtwitch.com/calendar/'); }
include("config.php");
/**if(is_logged_in($user)){
$username = base64_decode($_SESSION['user']);
if($username != "Slowman" && $username != "Rappstar") {
header('Location:https://slowtwitch.com/calendar/');
exit();
}
} else {
header('Location:https://slowtwitch.com/calendar/');
exit();
}**/
// set the page title
$pagetitle = "Edit A Race";
// set meta tags
$meta_keywords = "edit race";
$meta_description = "edit screen for race information";
?>
<? include("include_common_head.php"); ?>
<? include("include_common_content.php"); ?>
<!-- Start outer -->
<div id="outer">
<?
//Array of states for use in the form
//Array of states for use in the form
$state_list = array('AL'=>"Alabama",
'AK'=>"Alaska",
'AZ'=>"Arizona",
'AR'=>"Arkansas",
'CA'=>"California",
'CO'=>"Colorado",
'CT'=>"Connecticut",
'DE'=>"Delaware",
'DC'=>"District of Columbia",
'FL'=>"Florida",
'GA'=>"Georgia",
'HI'=>"Hawaii",
'ID'=>"Idaho",
'IL'=>"Illinois",
'IN'=>"Indiana",
'IA'=>"Iowa",
'KS'=>"Kansas",
'KY'=>"Kentucky",
'LA'=>"Louisiana",
'ME'=>"Maine",
'MD'=>"Maryland",
'MA'=>"Massachusetts",
'MI'=>"Michigan",
'MN'=>"Minnesota",
'MS'=>"Mississippi",
'MO'=>"Missouri",
'MT'=>"Montana",
'NE'=>"Nebraska",
'NV'=>"Nevada",
'NH'=>"New Hampshire",
'NJ'=>"New Jersey",
'NM'=>"New Mexico",
'NY'=>"New York",
'NC'=>"North Carolina",
'ND'=>"North Dakota",
'OH'=>"Ohio",
'OK'=>"Oklahoma",
'OR'=>"Oregon",
'PA'=>"Pennsylvania",
'RI'=>"Rhode Island",
'SC'=>"South Carolina",
'SD'=>"South Dakota",
'TN'=>"Tennessee",
'TX'=>"Texas",
'UT'=>"Utah",
'VT'=>"Vermont",
'VA'=>"Virginia",
'WA'=>"Washington",
'WV'=>"West Virginia",
'WI'=>"Wisconsin",
'WY'=>"Wyoming");
/** THIS SECTION DISPLAYS THE DATA FOR CONFIRMATION **/
// Need to interlace this with the edit / upload / copy screen from above.
/**if($deletepics == 1){
//delete pictures uploaded
$file1 = $picname1;
$file2 = $picname2;
$file3 = $picname3;
$file1 = stripslashes(str_replace("\"", "", $file1));
$file2 = stripslashes(str_replace("\"", "", $file2));
$file3 = stripslashes(str_replace("\"", "", $file3));
$file1 = "/srv/www/htdocs/trifind/racepics/$file1.img";
$file2 = "/srv/www/htdocs/trifind/racepics/$file2.img";
$file3 = "/srv/www/htdocs/trifind/racepics/$file3.img";
if(file_exists($file1)){ unlink($file1); }
if(file_exists($file2)){ unlink($file2); }
if(file_exists($file3)){ unlink($file3); }
}**/
$errmsg = NULL;
//Check for blank fields
if ((!$_POST[name])) $errmsg = $errmsg.'Race name, ';
if ($_POST[month]==0) $errmsg = $errmsg.'Race month, ';
if ($_POST[day]==0) $errmsg = $errmsg.'Race day, ';
if ($_POST[type]==0) $errmsg = $errmsg.'Race type, ';
if (!$_POST[indivfee]) $errmsg = $errmsg.'Individual entry fee, ';
if (!$_POST[swim]) $errmsg = $errmsg.'1st event distance, ';
if (!$_POST[bike]) $errmsg = $errmsg.'2nd event distance, ';
//if (!$_POST[run]) $errmsg = $errmsg.'3rd event distance, ';
if (!$_POST[state]) $errmsg = $errmsg.'State, ';
if (!$_POST[city]) $errmsg = $errmsg.'City, ';
if (!$_POST[address]) $errmsg = $errmsg.'Address, ';
if (!$_POST[phone]) $errmsg = $errmsg.'Phone, ';
if (!$_POST[email]) $errmsg = $errmsg.'Email, ';
if (strlen($_POST[courseinfo]) < 4) $errmsg = $errmsg.'Course info, ';
if (strlen($_POST[moreinfo]) < 4) $errmsg = $errmsg.'More info, ';
if (strlen($_POST[directions]) < 4) $errmsg = $errmsg.'Directions, ';
if (!$_POST[website]) $errmsg = $errmsg.'Website, ';
if (isset($errmsg)) {
$errmsg = 'The following fields cannot be left blank: '.$errmsg;
$errmsg = rtrim($errmsg, ', ');
}
if( preg_match('/[^a-zA-Z0-9\. ]/', $_POST[name]) ) {
// Contains invalid characters.
$errmsg = "Please use only letters and numbers in the name";
}
$name = trim($_POST[name]);
$nametag = strtolower(str_replace(" ","", $name));
if(strlen($nametag) > 12){ //Shorten it
$nametag = substr($nametag, 0, 12);
}
$hour = $_POST[hour];
if($_POST[daypart] == 1){ $hour = $hour + 12; }
$state = $_POST[state];
$statetag = strtolower(str_replace(" ","", $state));
$type = $_POST[type];
$indivfee = trim($_POST[indivfee]);
$teamfee = trim($_POST[teamfee]);
$swim = $_POST[swim];
$oneunit = $_POST[oneunit];
$twounit = $_POST[twounit];
$threeunit = $_POST[threeunit];
$onetype = $_POST[onetype];
$twotype = $_POST[twotype];
$threetype = $_POST[threetype];
$bike = $_POST[bike];
$run = $_POST[run];
$city = trim($_POST[city]);
$address = trim($_POST[address]);
$phone = trim($_POST[phone]);
$email = trim($_POST[email]);
$courseinfo = nl2br(substr(trim($_POST[courseinfo]), 0, 4096));
$moreinfo = nl2br(substr(trim($_POST[moreinfo]), 0, 4096));
$directions = nl2br(substr(trim($_POST[directions]), 0, 4096));
$register = trim($_POST[register]);
$website = trim($_POST[website]);
$results = trim($_POST[results]);
$sixresults = trim($_POST[sixresults]);
$minute = $_POST[minute];
$year = $_POST[year];
$month = $_POST[month];
$day = $_POST[day];
$date = "$year-$month-$day $hour:$minute:00";
$uid = $_POST[uid];
if($type == 1){ $typename = 'Triathlon'; }
if($type == 2){ $typename = 'Duathlon'; }
if($type == 3){ $typename = 'Other'; }
?>
<!-- BODY -->
<div class="content">
<!-- LEFT COLUMN -->
<!-- End left column -->
<!-- Content col -->
<h1 class="content-title"><strong>Edit a Race</strong></h1>
<p class="cont">
<? if(!$errmsg){ ?>Please confirm your race information. If everything is correct, click the submit button. Otherwise, you may click the edit button to change your race information before submitting.<? } else { echo $errmsg; } ?>
</p>
<h1 class="content-title"><strong><? echo stripslashes($name); ?></strong></h1>
<div class="indent">
<?
$nametagmod = trim(strtolower(str_replace(" ","",$name)));
$nametagmod1 = $nametagmod . '1';
$nametagmod2 = $nametagmod . '2';
$nametagmod3 = $nametagmod . '3';
?>
</div>
<table border="0" cellspacing="0" cellpadding="2">
<tr>
<td align="right"><strong>Date:</strong> </td><td><? echo "$month/$day/$year"; ?></td>
</tr>
<tr>
<td align="right"><strong>Race Type:</strong> </td><td><? echo $typename; ?></td>
</tr>
<tr>
<?
if($oneunit == 1){ $oneunitword = "mile"; }
if($oneunit == 2){ $oneunitword = "meter"; }
if($oneunit == 3){ $oneunitword = "yard"; }
if($oneunit == 4){ $oneunitword = "kilometers"; }
if($twounit == 1){ $twounitword = "mile"; }
if($twounit == 2){ $twounitword = "meter"; }
if($twounit == 3){ $twounitword = "yard"; }
if($twounit == 4){ $twounitword = "kilometers"; }
if($threeunit == 1){ $threeunitword = "mile"; }
if($threeunit == 2){ $threeunitword = "meter"; }
if($threeunit == 3){ $threeunitword = "yard"; }
if($threeunit == 4){ $threeunitword = "kilometers"; }
if($onetype == 1){ $onetypeword = "swim"; }
if($onetype == 2){ $onetypeword = "bike"; }
if($onetype == 3){ $onetypeword = "run"; }
if($onetype == 4){ $onetypeword = "paddle"; }
if($onetype == 5){ $onetypeword = "ski"; }
if($twotype == 1){ $twotypeword = "swim"; }
if($twotype == 2){ $twotypeword = "bike"; }
if($twotype == 3){ $twotypeword = "run"; }
if($twotype == 4){ $twotypeword = "paddle"; }
if($twotype == 5){ $twotypeword = "paddle"; }
if($threetype == 1){ $threetypeword = "swim"; }
if($threetype == 2){ $threetypeword = "bike"; }
if($threetype == 3){ $threetypeword = "run"; }
if($threetype == 4){ $threetypeword = "paddle"; }
if($threetype == 5){ $threetypeword = "ski"; }
?>
<td align="right"><strong>Course:</strong> </td><td><? echo "$swim $oneunitword $onetypeword, $bike $twounitword $twotypeword";
if ($run != 0) { echo ", $run $threeunitword $threetypeword"; }
?></td>
</tr>
<tr>
<td align="right"><strong>Start:</strong> </td><td><? echo "$hour:$minute"; ?></td>
</tr>
<tr>
<td align="right"><strong>Location:</strong> </td><td><? echo stripslashes($city); echo ", $state"; ?></td>
</tr>
<tr>
<td align="right"><strong>Address:</strong> </td><td><? echo stripslashes($address); ?></td>
</tr>
<tr>
<td align="right" valign="top"><strong>Contact:</strong> </td><td><? echo stripslashes($phone); echo "<br />"; echo stripslashes($email); ?></td>
</tr>
<tr>
<td align="right"><strong>Individual Price:</strong> </td><td valign="bottom"><? echo stripslashes($indivfee); ?></td>
</tr>
<tr>
<td align="right"><strong>Team Price:</strong> </td><td valign="bottom"><? echo stripslashes($teamfee); ?></td>
</tr>
<tr>
<td valign="top" align="right"><strong>Course Info:</strong> </td><td><? echo stripslashes($courseinfo); ?></td>
</tr>
<tr>
<td valign="top" align="right"><strong>More:</strong> </td><td><? echo stripslashes($moreinfo); ?></td>
</tr>
<tr>
<td valign="top" align="right"><strong>Directions:</strong> </td><td><? echo stripslashes($directions); ?></td>
</tr>
<tr>
<td align="right"><strong>Register:</strong> </td><td><? echo "<a target=\"_blank\" href=\"$register\">Click here</a>"; ?></td>
</tr>
<tr>
<td align="right"><strong>Website:</strong> </td><td><? echo "<a target=\"_blank\" href=\"$website\">$name</a>"; ?></td>
</tr>
</table>
<br />
<div class="indent">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td colspan="2">
<? // Confirm //?>
<form enctype="multipart/form-data" action="edit_X.php" method="post">
<input type="hidden" name="picname1" value="<? echo $nametagmod1; ?>">
<input type="hidden" name="picname2" value="<? echo $nametagmod2; ?>">
<input type="hidden" name="picname3" value="<? echo $nametagmod3; ?>">
<input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($name)); ?>">
<input type="hidden" name="password" value="<? echo $password; ?>">
<input type="hidden" name="month" value="<? echo $month; ?>">
<input type="hidden" name="day" value="<? echo $day; ?>">
<input type="hidden" name="daypart" value="<? echo $daypart; ?>">
<input type="hidden" name="hour" value="<? echo $hour; ?>">
<input type="hidden" name="minute" value="<? echo $minute; ?>">
<input type="hidden" name="year" value="<? echo $year; ?>">
<input type="hidden" name="type" value="<? echo $type; ?>">
<input type="hidden" name="indivfee" value="<? echo stripslashes(htmlspecialchars($indivfee)); ?>">
<input type="hidden" name="teamfee" value="<? echo stripslashes(htmlspecialchars($teamfee)); ?>">
<input type="hidden" name="swim" value="<? echo stripslashes(htmlspecialchars($swim)); ?>">
<input type="hidden" name="bike" value="<? echo stripslashes(htmlspecialchars($bike)); ?>">
<input type="hidden" name="run" value="<? echo stripslashes(htmlspecialchars($run)); ?>">
<input type="hidden" name="oneunit" value="<? echo $oneunit; ?>">
<input type="hidden" name="twounit" value="<? echo $twounit; ?>">
<input type="hidden" name="threeunit" value="<? echo $threeunit; ?>">
<input type="hidden" name="onetype" value="<? echo $onetype; ?>">
<input type="hidden" name="twotype" value="<? echo $twotype; ?>">
<input type="hidden" name="threetype" value="<? echo $threetype; ?>">
<input type="hidden" name="state" value="<? echo $state; ?>">
<input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($city)); ?>">
<input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($address)); ?>">
<input type="hidden" name="phone" value="<? echo stripslashes(htmlspecialchars($phone)); ?>">
<input type="hidden" name="email" value="<? echo stripslashes(htmlspecialchars($email)); ?>">
<input type="hidden" name="courseinfo" value="<? echo stripslashes(htmlspecialchars($courseinfo)); ?>">
<input type="hidden" name="moreinfo" value="<? echo stripslashes(htmlspecialchars($moreinfo)); ?>">
<input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($directions)); ?>">
<input type="hidden" name="register" value="<? echo $register; ?>">
<input type="hidden" name="website" value="<? echo $website; ?>">
<!--input type="hidden" name="results" value="<? echo $results; ?>"-->
<? if(!$errmsg){
if(isset($_POST[add_race])){ ?>
This data will be saved as a NEW RACE.
<input type="hidden" name="add_race" value="1" />
<input type="hidden" name="submitted_by" value="<? echo $_POST[submitted_by]; ?>" />
<? } else { ?>
This data will be saved as a modification to the EXISTING RACE.
<input type="hidden" name="save_changes" value="1" />
<input type="hidden" name="uid" value="<? echo $uid; ?>" />
<? } ?>
<br /><br />
<input type="submit" name="submit" value="Confirm">&nbsp;&nbsp;&nbsp;
</form>
<? } ?>
<form action="edit.php" method="post" enctype="multipart/form-data" >
<input type="hidden" name="name" value="<? echo stripslashes(htmlspecialchars($name)); ?>">
<input type="hidden" name="month" value="<? echo $month; ?>">
<input type="hidden" name="day" value="<? echo $day; ?>">
<input type="hidden" name="daypart" value="<? echo $daypart; ?>">
<input type="hidden" name="hour" value="<? echo $hour; ?>">
<input type="hidden" name="minute" value="<? echo $minute; ?>">
<input type="hidden" name="year" value="<? echo $year; ?>">
<input type="hidden" name="racedate" value="<? echo $date; ?>">
<input type="hidden" name="type" value="<? echo $type; ?>">
<input type="hidden" name="indivfee" value="<? echo stripslashes(htmlspecialchars($indivfee)); ?>">
<input type="hidden" name="teamfee" value="<? echo stripslashes(htmlspecialchars($teamfee)); ?>">
<input type="hidden" name="swim" value="<? echo stripslashes(htmlspecialchars($swim)); ?>">
<input type="hidden" name="bike" value="<? echo stripslashes(htmlspecialchars($bike)); ?>">
<input type="hidden" name="run" value="<? echo stripslashes(htmlspecialchars($run)); ?>">
<input type="hidden" name="oneunit" value="<? echo $oneunit; ?>">
<input type="hidden" name="twounit" value="<? echo $twounit; ?>">
<input type="hidden" name="threeunit" value="<? echo $threeunit; ?>">
<input type="hidden" name="onetype" value="<? echo $onetype; ?>">
<input type="hidden" name="twotype" value="<? echo $twotype; ?>">
<input type="hidden" name="threetype" value="<? echo $threetype; ?>">
<input type="hidden" name="state" value="<? echo $state; ?>">
<input type="hidden" name="city" value="<? echo stripslashes(htmlspecialchars($city)); ?>">
<input type="hidden" name="address" value="<? echo stripslashes(htmlspecialchars($address)); ?>">
<input type="hidden" name="phone" value="<? echo stripslashes(htmlspecialchars($phone)); ?>">
<input type="hidden" name="email" value="<? echo stripslashes(htmlspecialchars($email)); ?>">
<input type="hidden" name="courseinfo" value="<? echo stripslashes(htmlspecialchars($courseinfo)); ?>">
<input type="hidden" name="moreinfo" value="<? echo stripslashes(htmlspecialchars($moreinfo)); ?>">
<input type="hidden" name="directions" value="<? echo stripslashes(htmlspecialchars($directions)); ?>">
<input type="hidden" name="register" value="<? echo $register; ?>">
<input type="hidden" name="website" value="<? echo $website; ?>">
<!--input type="hidden" name="results" value="<? echo $results; ?>"-->
<input type="hidden" name="edit_return" value="1" />
<input type="hidden" name="uid" value="<? echo $uid; ?>" />
<input type="hidden" name="edit_return" value="1" />
<input type="hidden" name="submitted_by" value="<? echo $_POST[submitted_by]; ?>" />
<input type="hidden" name="valid" value="1">
<input type="submit" name="submit" value="Return To Edit Screen">
<!--input type="hidden" name="picname1" value="<? echo $nametagmod1; ?>">
<input type="hidden" name="picname2" value="<? echo $nametagmod2; ?>">
<input type="hidden" name="picname3" value="<? echo $nametagmod3; ?>">
<input type="hidden" name="deletepics" value="1"-->
</form>
</td></tr>
</table></div>
<!-- End content col -->
</div>
<!-- End BODY -->
</div>
<!-- End Outer -->
<? include("include_common_footer.php"); ?>