<% require("/var/www/webhosts-script/www.tartanowners.org/private/phpheaders/main.phtml"); $error[code][blank_own_id] = TONEErrorValue($error[code]); $error[code][blank_boatname] = TONEErrorValue($error[code]); $error[code][blank_harbor] = TONEErrorValue($error[code]); $error[code][blank_lat] = TONEErrorValue($error[code]); $error[code][bad_lat] = TONEErrorValue($error[code]); $error[code][oor_lat] = TONEErrorValue($error[code]); $error[code][blank_lon] = TONEErrorValue($error[code]); $error[code][bad_lon] = TONEErrorValue($error[code]); $error[code][oor_lon] = TONEErrorValue($error[code]); $error[code][bad_category] = TONEErrorValue($error[code]); $error[code][bad_activity] = TONEErrorValue($error[code]); $error[code][bad_experience] = TONEErrorValue($error[code]); $error[code][blank_comment] = TONEErrorValue($error[code]); $error[code][blank_description] = TONEErrorValue($error[code]); $error[code][blank_location] = TONEErrorValue($error[code]); $error[code][blank_photo] = TONEErrorValue($error[code]); $error[code][file_copy] = TONEErrorValue($error[code]); $error[code][file_size_lrg] = TONEErrorValue($error[code]); $error[code][file_size_sml] = TONEErrorValue($error[code]); $error[code][reload_photo] = TONEErrorValue($error[code]); $error[val]=0; $max_file_size = 2*1024*1024; $min_file_size = 1024; if(!isset($tone)) { $new_owner = true; $own_id = ''; $own_boatname = ''; } else { $new_owner = false; unset($data); $where[]['owner.hash'] = array( 'op' => '=', 'val' => $tone ); $error_result = TONEOwnerGetResult('', $order, $where); if( !($error_result < 0) ) { if(mysql_num_rows($error_result) == 1) { $the_owner = mysql_fetch_object($error_result); $own_id = $the_owner->id; $own_boatname = $the_owner->boatname; } } } if(isset($submit)) { ## Preformat the data $own_boatname = TONETextPreformat($own_boatname); $hbr_harbor = TONETextPreformat($hbr_harbor); $hbr_lat = TONETextPreformat($hbr_lat); $hbr_lon = TONETextPreformat($hbr_lon); $hbr_category = TONETextPreformat($hbr_category); $hbr_activity = TONETextPreformat($hbr_activity); $hbr_experience = TONETextPreformat($hbr_experience); $hbr_comment = TONETextPreformat($hbr_comment); ## Validate the data if(empty($own_id)) { $error[val] += $error[code][blank_own_id]; $error[txt][] = "You do not have an active profile."; } if(empty($own_boatname)) { $error[val] += $error[code][blank_boatname]; $error[txt][] = "You must enter your Boat Name."; } if(empty($hbr_harbor)) { $error[val] += $error[code][blank_harbor]; $error[txt][] = "You must enter a Harbor."; } if(empty($hbr_lat)) { $error[val] += $error[code][blank_lat]; $error[txt][] = "You must enter a Latitude."; } else { if(!preg_match("/^(-?\d+.\d+)$/", $hbr_lat)) { $error[val] += $error[code][bad_lat]; $error[txt][] = "Latitude must be in decimal degrees (dd.ddd)."; } elseif($hbr_lat <= 0 || $hbr_lat >= 90) { $error[val] += $error[code][oor_lat]; $error[txt][] = "Latitude must be between 0 and 90 degrees."; } } if(empty($hbr_lon)) { $error[val] += $error[code][blank_lon]; $error[txt][] = "You must enter a Longitude."; } else { if(!preg_match("/^(-?\d+.\d+)$/", $hbr_lon)) { $error[val] += $error[code][bad_lon]; $error[txt][] = "Longitude must be in decimal degrees (dd.ddd)."; } elseif($hbr_lon >= 0 || $hbr_lon <= -180) { $error[val] += $error[code][oor_lon]; $error[txt][] = "Longitude must be between 0 and -180 degrees."; } } if($hbr_category == '- Category -') { $error[val] += $error[code][bad_category]; $error[txt][] = "You must select a Category."; } if($hbr_activity == '- Activity -') { $error[val] += $error[code][bad_activity]; $error[txt][] = "You must select an Activity."; } if($hbr_experience == '- Experience -') { $error[val] += $error[code][bad_experience]; $error[txt][] = "You must select your Experience."; } if(empty($hbr_comment)) { $error[val] += $error[code][blank_comment]; $error[txt][] = "You must enter a Comment."; } if( !empty($_FILES['photo']['name']) && !$error[val] ) { $image_orig = new TONEImage; $image_orig->dir = $_FILES['photo']['tmp_name']; if(!empty($debug)) $imig_orig->debug=true; $image_orig->GetInfo(); if($image_orig->dim_x > 600 || $image_orig->dim_y > 600) { $new = TONEImageConstrainDimensions($image_orig->dim_x, $image_orig->dim_y, 600); $image_orig->ConvertResized($new[dim_x], $new[dim_y], 75, 'JPEG'); clearstatcache(); $image_orig->GetInfo(); $dim_x = $image_orig->dim_x; $dim_y = $image_orig->dim_y; $type = $image_orig->type; } TONEImageFileDelete($image); TONEImageDelete($image); unset($data); $data[size] = $image_orig->size; $data[type] = $image_orig->type; $data[dim_x] = $image_orig->dim_x; $data[dim_y] = $image_orig->dim_y; $error_result = TONEImageUpdate($data, false); if($error_result < 0 && (TONEIsError($error_result, 'db_norows') || TONEIsError($error_result, 'db_badsql') ) ) { $error[txt][] = "The image could not be added to the database."; } else { $image = $error_result; $error_result = TONEImageMove($_FILES['photo']['tmp_name'], $image, $image_orig->type); if(TONEIsError($error_result, 'img_nocpy')) { TONEImageDelete($id); $error[txt][] = "Could not store the image."; } if( !$error[val] ) { $tmpimg=tempnam("/tmp", "img"); $image_pre = new TONEImage; $image_pre->dir = $tmpimg; if(!empty($debug)) $image_pre->debug=true; $new = TONEImageConstrainDimensions($image_orig->dim_x, $image_orig->dim_y, 120); $image_orig->ConvertResized($new[dim_x], $new[dim_y], 75, 'JPEG', $image_pre->dir); $image_pre->GetInfo(); TONEImageFileDelete($image_preview); TONEImageDelete($image_preview); unset($data); $data[size] = $image_pre->size; $data[type] = $image_pre->type; $data[dim_x] = $image_pre->dim_x; $data[dim_y] = $image_pre->dim_y; $error_result = TONEImageUpdate($data, false); if($error_result < 0 && (TONEIsError($error_result, 'db_norows') || TONEIsError($error_result, 'db_badsql') ) ) { $error[txt][] = "The preview image could not be added to the database."; } else { $image_preview = $error_result; $error_result = TONEImageMove($image_pre->dir, $image_preview, $image_pre->type); } } } } if( !empty($_FILES['photo']['name']) && $error[val] ) { $error[val] += $error[code][reload_photo]; $error[txt][] = "Please reselect your photo if you still want to upload it."; } if(!$error[val]) { unset($data); $data[owner_id] = $own_id; $data[boat_name] = $own_boatname; $data[harbor] = $hbr_harbor; $data[lat] = $hbr_lat; $data[lon] = $hbr_lon; $data[category] = $hbr_category; $data[activity] = $hbr_activity; $data[experience] = $hbr_experience; $data[comment] = $hbr_comment; $data[image_id] = $image; $data[imagepre_id] = $image_preview; $error_result = TONEHarborInfoUpdate($data, false); if($error_result < 0 && ( TONEIsError($error_result, 'db_norows') || TONEIsError($error_result, 'db_badsql') ) ) { $error[val] += $error[code][db_norows]; $error[txt][] = "The information was not inserted into the database, please try again later."; } else { $hid = $error_result; } } if($error[val]) { ## Format the data for display on the screen $own_boatname = TONETextDisplay($own_boatname, false, false); $hbr_harbor = TONETextDisplay($hbr_harbor, false, false); $hbr_lat = TONETextDisplay($hbr_lat, false, false); $hbr_lon = TONETextDisplay($hbr_lon, false, false); $hbr_category = TONETextDisplay($hbr_category, false, false); $hbr_activity = TONETextDisplay($hbr_activity, false, false); $hbr_experience = TONETextDisplay($hbr_experience, false, false); $hbr_comment = TONETextDisplay($hbr_comment, false, false); } else { exec("curl 'http://www.tartanowners.org/members/rss/news.php?harbor=$hid' > /dev/null &"); TONERedirectBrowser('/members/harbornotes.php', true); exit; } } $rnd = rand(100000, 999999); $url_forward[] = 'rnd=' . $rnd; if($debug) $url_forward[] = 'debug=' . $debug; if(count($url_forward)) $forward = TONETextMakeFromList($url_forward, '', '&', false, '', false); %> Tartan Owners Harbor Info Form

Tartan Owners Harbor Info Form

Please use this form to provide a tip based on your local knowledge or experience. You may submit tips about a harbor, cove or anchorage, navigation, anchoring, local features and shoreside activities, transit notes, etc.

<%if($error[val]):%>

Errors:

<%endif;%>
*Boat Name:
Harbor Name:
*Coordinates:
(dd.ddd) 
Lat:  Lon:
Enter exact Lat/Lon, or Choose from Map
Category/Activity:  
Experience:
Comments:
Optional Photo: <%if($image && $image_preview):%>Your current photo is shown below. To change it, use the "Browse" button to select another:

<%=TONEImageGetTagIMG($image_preview);%>

<%endif;%>
All Fields are Required 

Using the Form: