discourse-legacysite-perl/site/racecalendar/edit.php

449 lines
18 KiB
PHP
Raw Normal View History

2024-06-17 12:42:14 +00:00
<?PHP
if(!isset($_GET[uid]) AND !$_POST) {
header('Location:https://slowtwitch.com/calendar/');
exit();
}
include("config.php");
// 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
$state_list = array('AL'=>"Alabama",
'AK'=>"Alaska",
'AB'=>'Alberta',
'AZ'=>"Arizona",
'AR'=>"Arkansas",
'BC'=>'British Columbia',
'CB'=>"Caribbean",
'CA'=>"California",
'CM'=>"Central America",
'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",
'MB'=>'Manitoba',
'MD'=>"Maryland",
'MA'=>"Massachusetts",
'MX'=>"Mexico",
'MI'=>"Michigan",
'MN'=>"Minnesota",
'MS'=>"Mississippi",
'MO'=>"Missouri",
'MT'=>"Montana",
'NE'=>"Nebraska",
'NV'=>"Nevada",
'NB'=>'New Brunswick',
'NL'=>'Newfoundland',
'NH'=>"New Hampshire",
'NJ'=>"New Jersey",
'NM'=>"New Mexico",
'NY'=>"New York",
'NC'=>"North Carolina",
'ND'=>"North Dakota",
'NS'=>'Nova Scotia',
'OH'=>"Ohio",
'OK'=>"Oklahoma",
'ON'=>'Ontario',
'OR'=>"Oregon",
'PA'=>"Pennsylvania",
'PE'=>'Prince Edward Island',
'QC'=>'Quebec',
'RI'=>"Rhode Island",
'SK'=>'Saskatchewan',
'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");
// Populate with post data or populate with edit return data
if (isset($_POST[edit_return])) {
$row = $_POST;
$row[racedate] = strtotime($row[racedate]);
} else {
$uid = intval(mysql_escape_string($_GET[uid]));
$results = mysql_query("SELECT onetype, twotype, threetype, oneunit, twounit, threeunit, results, pic1, pic2, pic3, uid, name, nametag, type, indivfee, teamfee, swim, bike, run, state, statetag, city, address, phone, email, courseinfo, moreinfo, directions, register, website, submitted_by, valid, UNIX_TIMESTAMP(date) AS racedate, uid AS uid FROM gforum_Triathlons WHERE uid='".$uid."'");
$row = mysql_fetch_array($results);
}
if(is_logged_in($user)){
//Get user's uid
$username = base64_decode($_SESSION['user']);
$testresults = mysql_query("SELECT user_id FROM ".$prefix."User WHERE user_username='$username'") or die(mysql_error());
$testrow = mysql_fetch_array($testresults);
$useruid = $testrow[user_id];
$race_owner = FALSE;
// is the current user the owner of the race?
if($useruid == $row[submitted_by] && $row[valid] == 1){
$race_owner = TRUE;
}
if(!is_admin() && $race_owner != TRUE) {
header('Location:https://slowtwitch.com/calendar/');
exit();
}
} else {
header('Location:https://slowtwitch.com/calendar/');
exit();
}
?>
<!-- BODY -->
<div class="content">
<!-- LEFT COLUMN -->
<!-- End left column -->
<!-- Content col -->
<h1 class="content-title"><strong>Edit a Race</strong></h1>
<p class="cont">To edit a race, simply change the data you wish. If you make a mistake, just hit the reset button. To save the changes to a NEW race, hit the "CREATE NEW RACE" button. To save changes to the existing race, hit the "SAVE CHANGES" button. You will have a chance to review the data before confirming.</p>
<form enctype="multipart/form-data" action="edit_Confirm.php" method="post">
<p class="cont"><font color="red"><? echo $errmsg; ?></font></p>
<table border="0" cellspacing="0" cellpadding="3">
<? /**<tr>
we need to make a delete box similar to within the GLinks article pages. There is some code that exists currently from the current submit form that allows pics to be changed, so take a look at that first.
<td align="right">Pictures: </td>
<td><input type="file" name="imagefile[]" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right"></td>
<td><input type="file" name="imagefile[]" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right"></td>
<td><input type="file" name="imagefile[]" size="30" maxlength="100"></td>
</tr>
**/?>
<tr>
<td align="right">Race Name: </td>
<td><input value="<? echo $row[name]; ?>" type="text" name="name" size="30" maxlength="80"></td>
</tr>
<tr>
<td align="right">Race Date: </td>
<td>
<? // we need to convert the UNIX timestamp to individual parts //
$month = date("m", $row[racedate]);
$day = date("d", $row[racedate]);
$year = date("Y", $row[racedate]);
$hour = date("h", $row[racedate]);
$minute = date("i", $row[racedate]);
$ampm = date("A", $row[racedate]);
//echo $row[racedate];
?>
<select name="month">
<option value="0">Month
<option <? if(strcmp($month, "01") == 0){ echo ("selected"); } ?> value="01">January</option>
<option <? if(strcmp($month, "02") == 0){ echo ("selected"); } ?> value="02">February</option>
<option <? if(strcmp($month, "03") == 0){ echo ("selected"); } ?> value="03">March</option>
<option <? if(strcmp($month, "04") == 0){ echo ("selected"); } ?> value="04">April</option>
<option <? if(strcmp($month, "05") == 0){ echo ("selected"); } ?> value="05">May</option>
<option <? if(strcmp($month, "06") == 0){ echo ("selected"); } ?> value="06">June</option>
<option <? if(strcmp($month, "07") == 0){ echo ("selected"); } ?> value="07">July</option>
<option <? if(strcmp($month, "08") == 0){ echo ("selected"); } ?> value="08">August</option>
<option <? if(strcmp($month, "09") == 0){ echo ("selected"); } ?> value="09">September</option>
<option <? if(strcmp($month, "10") == 0){ echo ("selected"); } ?> value="10">October</option>
<option <? if(strcmp($month, "11") == 0){ echo ("selected"); } ?> value="11">November</option>
<option <? if(strcmp($month, "12") == 0){ echo ("selected"); } ?> value="12">December</option>
</select>
<select name="day">
<option value="0">Day
<option value="01" <? if(strcmp($day, "01") == 0){ echo ("selected"); } ?>>1
<option value="02" <? if(strcmp($day, "02") == 0){ echo ("selected"); } ?>>2
<option value="03" <? if(strcmp($day, "03") == 0){ echo ("selected"); } ?>>3
<option value="04" <? if(strcmp($day, "04") == 0){ echo ("selected"); } ?>>4
<option value="05" <? if(strcmp($day, "05") == 0){ echo ("selected"); } ?>>5
<option value="06" <? if(strcmp($day, "06") == 0){ echo ("selected"); } ?>>6
<option value="07" <? if(strcmp($day, "07") == 0){ echo ("selected"); } ?>>7
<option value="08" <? if(strcmp($day, "08") == 0){ echo ("selected"); } ?>>8
<option value="09" <? if(strcmp($day, "09") == 0){ echo ("selected"); } ?>>9
<option value="10" <? if(strcmp($day, "10") == 0){ echo ("selected"); } ?>>10
<option value="11" <? if(strcmp($day, "11") == 0){ echo ("selected"); } ?>>11
<option value="12" <? if(strcmp($day, "12") == 0){ echo ("selected"); } ?>>12
<option value="13" <? if(strcmp($day, "13") == 0){ echo ("selected"); } ?>>13
<option value="14" <? if(strcmp($day, "14") == 0){ echo ("selected"); } ?>>14
<option value="15" <? if(strcmp($day, "15") == 0){ echo ("selected"); } ?>>15
<option value="16" <? if(strcmp($day, "16") == 0){ echo ("selected"); } ?>>16
<option value="17" <? if(strcmp($day, "17") == 0){ echo ("selected"); } ?>>17
<option value="18" <? if(strcmp($day, "18") == 0){ echo ("selected"); } ?>>18
<option value="19" <? if(strcmp($day, "19") == 0){ echo ("selected"); } ?>>19
<option value="20" <? if(strcmp($day, "20") == 0){ echo ("selected"); } ?>>20
<option value="21" <? if(strcmp($day, "21") == 0){ echo ("selected"); } ?>>21
<option value="22" <? if(strcmp($day, "22") == 0){ echo ("selected"); } ?>>22
<option value="23" <? if(strcmp($day, "23") == 0){ echo ("selected"); } ?>>23
<option value="24" <? if(strcmp($day, "24") == 0){ echo ("selected"); } ?>>24
<option value="25" <? if(strcmp($day, "25") == 0){ echo ("selected"); } ?>>25
<option value="26" <? if(strcmp($day, "26") == 0){ echo ("selected"); } ?>>26
<option value="27" <? if(strcmp($day, "27") == 0){ echo ("selected"); } ?>>27
<option value="28" <? if(strcmp($day, "28") == 0){ echo ("selected"); } ?>>28
<option value="29" <? if(strcmp($day, "29") == 0){ echo ("selected"); } ?>>29
<option value="30" <? if(strcmp($day, "30") == 0){ echo ("selected"); } ?>>30
<option value="31" <? if(strcmp($day, "31") == 0){ echo ("selected"); } ?>>31
</select>
<select name="year">
<option value="2008" <? if(strcmp($year, "2008") == 0){ echo ("selected"); } ?>>2008
<option value="2007" <? if(strcmp($year, "2007") == 0){ echo ("selected"); } ?>>2007
<option value="2006" <? if(strcmp($year, "2006") == 0){ echo ("selected"); } ?>>2006
</select>
</td>
</tr>
<tr>
<td align="right">Start Time: </td>
<td>
<select name="hour">
<option value="01" <? if(strcmp($hour, "01") == 0){ echo ("selected"); } ?>>1
<option value="02" <? if(strcmp($hour, "02") == 0){ echo ("selected"); } ?>>2
<option value="03" <? if(strcmp($hour, "03") == 0){ echo ("selected"); } ?>>3
<option value="04" <? if(strcmp($hour, "04") == 0){ echo ("selected"); } ?>>4
<option value="05" <? if(strcmp($hour, "05") == 0){ echo ("selected"); } ?>>5
<option value="06" <? if(strcmp($hour, "06") == 0){ echo ("selected"); } ?>>6
<option value="07" <? if(strcmp($hour, "07") == 0){ echo ("selected"); } ?>>7
<option value="08" <? if(strcmp($hour, "08") == 0){ echo ("selected"); } ?>>8
<option value="09" <? if(strcmp($hour, "09") == 0){ echo ("selected"); } ?>>9
<option value="10" <? if(strcmp($hour, "10") == 0){ echo ("selected"); } ?>>10
<option value="11" <? if(strcmp($hour, "11") == 0){ echo ("selected"); } ?>>11
<option value="12" <? if(strcmp($hour, "12") == 0){ echo ("selected"); } ?>>12
</select>
:
<select name="minute">
<option value="00" <? if(strcmp($minute, "00") == 0){ echo ("selected"); } ?>>00
<option value="05" <? if(strcmp($minute, "05") == 0){ echo ("selected"); } ?>>05
<option value="10" <? if(strcmp($minute, "10") == 0){ echo ("selected"); } ?>>10
<option value="15" <? if(strcmp($minute, "15") == 0){ echo ("selected"); } ?>>15
<option value="20" <? if(strcmp($minute, "20") == 0){ echo ("selected"); } ?>>20
<option value="25" <? if(strcmp($minute, "25") == 0){ echo ("selected"); } ?>>25
<option value="30" <? if(strcmp($minute, "30") == 0){ echo ("selected"); } ?>>30
<option value="35" <? if(strcmp($minute, "35") == 0){ echo ("selected"); } ?>>35
<option value="40" <? if(strcmp($minute, "40") == 0){ echo ("selected"); } ?>>40
<option value="45" <? if(strcmp($minute, "45") == 0){ echo ("selected"); } ?>>45
<option value="50" <? if(strcmp($minute, "50") == 0){ echo ("selected"); } ?>>50
<option value="55" <? if(strcmp($minute, "55") == 0){ echo ("selected"); } ?>>55
</select>
<select name="daypart">
<option value="0" <? if(strcmp($ampm, "AM") == 0){ echo ("selected"); } ?>>AM
<option value="1" <? if(strcmp($ampm, "PM") == 0){ echo ("selected"); } ?>>PM
</select>
</td>
</tr>
<tr>
<td align="right">Race Type: </td>
<td>
<select name="type">
<option value="1" <? if($row[type] == 1){ echo ("selected"); } ?>>Triathlon
<option value="2" <? if($row[type] == 2){ echo ("selected"); } ?>>Duathlon
<option value="3" <? if($row[type] == 3){ echo ("selected"); } ?>>Other
</select>
</td>
</tr>
<tr>
<td align="right">Individual entry fee: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[indivfee])); ?>" type="text" name="indivfee" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Team entry fee: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[teamfee])); ?>" type="text" name="teamfee" size="30" maxlength="100"></td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
******************************************************************************
<br />
IMPORTANT: Fractional lengths must be entered as a decimal number<br />
Examples: 0.25, 1.2, 0.1, 13.2.<EFBFBD>If your race contains only two legs, simply
leave the third leg blank."<br />
</div>
</td>
</tr>
<tr>
<td align="right">1st distance: </td>
<td><input value="<? echo stripslashes($row[swim]); ?>" type="text" name="swim" size="5" maxlength="5">
<select name="oneunit">
<option value="1" <? if($row[oneunit] == 1){ echo ("selected"); } ?>>miles</option>
<option value="4" <? if($row[oneunit] == 4){ echo ("selected"); } ?>>kilometers</option>
<option value="3" <? if($row[oneunit] == 3){ echo ("selected"); } ?>>yards</option>
<option value="2" <? if($row[oneunit] == 2){ echo ("selected"); } ?>>meters</option>
</select>
<select name="onetype">
<option value="1" <? if($row[onetype] == 1){ echo ("selected"); } ?>>Swim</option>
<option value="2" <? if($row[onetype] == 2){ echo ("selected"); } ?>>Bike</option>
<option value="3" <? if($row[onetype] == 3){ echo ("selected"); } ?>>Run</option>
<option value="4" <? if($row[onetype] == 4){ echo ("selected"); } ?>>Paddle</option>
<option value="5" <? if($row[onetype] == 5){ echo ("selected"); } ?>>Ski</option>
</select>
</td>
</tr>
<tr>
<td align="right">2nd distance: </td>
<td><input value="<? echo stripslashes($row[bike]); ?>" type="text" name="bike" size="5" maxlength="5">
<select name="twounit">
<option value="1" <? if($row[twounit] == 1){ echo ("selected"); } ?>>miles</option>
<option value="4" <? if($row[twounit] == 4){ echo ("selected"); } ?>>kilometers</option>
<option value="3" <? if($row[twounit] == 3){ echo ("selected"); } ?>>yards</option>
<option value="2" <? if($row[twounit] == 2){ echo ("selected"); } ?>>meters</option>
</select>
<select name="twotype">
<option value="2" <? if($row[twotype] == 2){ echo ("selected"); } ?>>Bike</option>
<option value="1" <? if($row[twotype] == 1){ echo ("selected"); } ?>>Swim</option>
<option value="3" <? if($row[twotype] == 3){ echo ("selected"); } ?>>Run</option>
<option value="4" <? if($row[twotype] == 4){ echo ("selected"); } ?>>Paddle</option>
<option value="5" <? if($row[twotype] == 5){ echo ("selected"); } ?>>Ski</option>
</select>
</td>
</tr>
<tr>
<td align="right">3rd distance: </td>
<td><input value="<? echo stripslashes($row[run]); ?>" type="text" name="run" size="5" maxlength="5">
<select name="threeunit">
<option value="1" <? if($row[threeunit] == 1){ echo ("selected"); } ?>>miles</option>
<option value="4" <? if($row[threeunit] == 4){ echo ("selected"); } ?>>kilometers</option>
<option value="3" <? if($row[threeunit] == 3){ echo ("selected"); } ?>>yards</option>
<option value="2" <? if($row[threeunit] == 2){ echo ("selected"); } ?>>meters</option>
</select>
<select name="threetype">
<option value="3" <? if($row[threetype] == 3){ echo ("selected"); } ?>>Run</option>
<option value="2" <? if($row[threetype] == 2){ echo ("selected"); } ?>>Bike</option>
<option value="1" <? if($row[threetype] == 1){ echo ("selected"); } ?>>Swim</option>
<option value="4" <? if($row[threetype] == 4){ echo ("selected"); } ?>>Paddle</option>
<option value="5" <? if($row[threetype] == 5){ echo ("selected"); } ?>>Ski</option>
</select>
</td>
</tr>
<tr>
<td colspan="2">
<div class="indentlarge">
******************************************************************************
</div></td>
</tr>
<tr>
<tr>
<td align="right">State: </td>
<td>
<SELECT name="state">
<OPTION value="0">Choose a State/Province</OPTION>
<? //use loop for dropdown box
foreach($state_list as $key=>$value){
if(strcmp($row[state], $value) == 0){
$str = " selected=\"selected\"";
}
echo "<option value=\"$value\"$str>$value</option>";
$str = "";
}
?>
</SELECT>
</td>
</tr>
<tr>
<td align="right">City: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[city])); ?>" type="text" name="city" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Address: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[address])); ?>" type="text" name="address" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">Phone Contact: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[phone])); ?>" type="text" name="phone" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right">E-mail Contact: </td>
<td><input value="<? echo stripslashes(htmlspecialchars($row[email])); ?>" type="text" name="email" size="30" maxlength="100"></td>
</tr>
<tr>
<td align="right" valign="top">Course Info: </td>
<td><textarea name="courseinfo" rows="7" cols="45">
<? if($row[courseinfo]){ echo strip_tags(stripslashes($row[courseinfo])); }else{ ?>
Please insert a short paragraph describing the course.
<? } ?>
</textarea></td>
</tr>
<tr>
<td align="right" valign="top">More Info: </td>
<td><textarea name="moreinfo" rows="7" cols="45">
<? if($row[moreinfo]){ echo strip_tags(stripslashes($row[moreinfo])); }else{ ?>
Please insert a short paragraph describing information such as prizes, age groups, drafting rule, etc.
<? } ?>
</textarea></td>
</tr>
<tr>
<td align="right" valign="top">Directions: </td>
<td><textarea name="directions" rows="7" cols="45">
<? if($row[directions]){ echo strip_tags(stripslashes($row[directions])); }else{ ?>
Please describe how to get to your race from your surrounding area.
<? } ?>
</textarea></td>
</tr>
<tr>
<td align="right">Registration link: </td>
<td><input value="<? echo $row[register]; ?>" type="text" name="register" size="30" maxlength="200">
(include http:// )
</td>
</tr>
<tr>
<td align="right">Website: </td>
<td><input value="<? echo $row[website]; ?>" type="text" name="website" size="30" maxlength="200">
(include http:// )
</td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="save_changes" value="Save Changes" onclick="" /><input type="reset" value="Reset" /><input type="submit" name="add_race" value="Add New Race" />
<input type="hidden" name="uid" value="<? echo $row[uid]; ?>" />
<input type="hidden" name="script_action" value="0" />
<input type="hidden" name="submitted_by" value="<? echo $useruid; ?>" />
</td>
</tr>
</table>
</form>
<!-- End content col -->
</div>
<!-- End BODY -->
</div>
<!-- End Outer -->
<? include("include_common_footer.php"); ?>