<% require("/var/www/webhosts-script/www.tartanowners.org/private/phpheaders/main.phtml"); # if (!isset($tone)){ # header("HTTP/1.0 404 Not Found"); # exit; # } $kTONESubmitAd = 6; $kTONESubmitAdAdd = 7; $kTONESubmitAdPreview = 8; $kTONESubmitAdPreviewAdd = 9; $kTONESubmitAdPreviewUpdate = 10; $error[code][blank_id] = TONEErrorValue($error[code]); $error[code][blank_type] = TONEErrorValue($error[code]); $error[code][blank_model] = TONEErrorValue($error[code]); $error[code][blank_year] = TONEErrorValue($error[code]); $error[code][bad_year] = TONEErrorValue($error[code]); $error[code][blank_hullnumber] = TONEErrorValue($error[code]); $error[code][blank_boatname] = TONEErrorValue($error[code]); $error[code][blank_homeport] = TONEErrorValue($error[code]); $error[code][blank_ownername] = TONEErrorValue($error[code]); $error[code][blank_phonehome] = TONEErrorValue($error[code]); $error[code][blank_phonework] = TONEErrorValue($error[code]); $error[code][blank_phone] = TONEErrorValue($error[code]); $error[code][blank_email] = TONEErrorValue($error[code]); $error[code][bad_email] = TONEErrorValue($error[code]); $error[code][blank_comments] = TONEErrorValue($error[code]); $error[code][blank_description] = TONEErrorValue($error[code]); $error[code][blank_text] = 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[val]=0; $max_file_size = 2*1024*1024; $min_file_size = 1024; if(!isset($submit)) { $show_ad = true; $show_good = false; $show_preview = false; if(isset($tone)) { 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_model = $the_owner->model_id; $own_image = $the_owner->image_id; $own_image_preview = $the_owner->imagepre_id; $own_isupdate = TONETextDisplay($the_owner->is_update, false, false); $own_type = $the_owner->ownertype; $own_boatyear = TONETextDisplay($the_owner->boatyear, false, false); $own_hullnumber = TONETextDisplay($the_owner->hullnumber, false, false); $own_boatname = TONETextDisplay($the_owner->boatname, false, false); $own_homeport = TONETextDisplay($the_owner->homeport, false, false); $own_ownername = TONETextDisplay($the_owner->ownername, false, false); $own_phone_home = TONETextDisplay($the_owner->phone_home, false, false); $own_phone_work = TONETextDisplay($the_owner->phone_work, false, false); $own_email = TONETextDisplay($the_owner->email, false, false); $own_comments = TONETextDisplay($the_owner->comments, false, false); $ad_email = $own_email; $ad_name = $own_ownername; $ad_phone = (empty($own_phone_home) ? '' : "$own_phone_home (H) ") . (empty($own_phone_work) ? '' : "$own_phone_work (W)"); $ad_model = $own_model; $url_forward[] = 'oid=' . $the_owner->id; } } } } else { $submit_type = key($submit); if(is_array($submit[$submit_type])) $sub_type = key($submit[$submit_type]); switch($submit_type) { ## The preview looked good, make it active case $kTONESubmitAdPreviewAdd: if(empty($aid)) { $error[val] += $error[code][blank_id]; $error[txt][] = "Not enough information to perform an update, please try again."; } else { unset($data); $data[id] = $aid; $data[active] = 'Y'; $error_result = TONEAdUpdate($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 updated, please try again."; } } if($error[val]) { ## Something bad happend, letz reset the vars and start over unset($ad_type); unset($ad_year); unset($ad_model); unset($ad_description); unset($ad_name); unset($ad_phone); unset($ad_email); unset($ad_text); $show_ad = true; $show_good = false; $show_preview = false; } else { ## All is good, lets redirect to the applicable as page $sql_get = "select * from ad where id=$aid"; $result_get=mysql_query($sql_get, $gTONEDBConn); if($result_get) { if(mysql_num_rows($result_get)) { $the_ad = mysql_fetch_object($result_get); } } $ad_type = $the_ad->type; #if($ad_type == $kTONEAdTypeBoat) $page = '4salebody.phtml'; #if($ad_type == $kTONEAdTypeItem) $page = 'itembody.phtml'; #if($ad_type == $kTONEAdTypeCrew) $page = 'crewbody.phtml'; #if($ad_type == $kTONEAdTypeWant) $page = 'wantbody.phtml'; exec("curl 'http://www.tartanowners.org/members/rss/news.php?ad=$aid' > /dev/null &"); TONERedirectBrowser("http://www.tartanowners.org/v6/classifieds.phtml", false); exit; $show_ad = false; $show_good = true; $show_preview = false; } break; ## Something was wrong, letz get the data so the user can update it case $kTONESubmitAdPreviewUpdate: if(empty($aid)) { $error[val] += $error[code][blank_id]; $error[txt][] = "Could not update information, please try again."; } else { $sql_get = "select * from ad where id=$aid"; $result_get=mysql_query($sql_get, $gTONEDBConn); if($result_get) { if(mysql_num_rows($result_get)) { $the_ad = mysql_fetch_object($result_get); } else { $error[val] += $error[code][db_norows]; $error[txt][] = "Could not find the original data, please try again."; } } else { $error[val] += $error[code][db_norows]; $error[txt][] = "Could not find the original data, please try again."; } } if($error[val]) { ## Something bad happned, letz reset the vars and start over. unset($aid); unset($ad_model); unset($ad_image); unset($ad_image_preview); unset($ad_type); unset($ad_year); unset($ad_description); unset($ad_name); unset($ad_phone); unset($ad_email); unset($ad_text); ## Set the display options $show_ad = true; $show_good = false; $show_preview = false; } else { ## Prep the data for display into the fields $ad_model = $the_ad->model_id; $ad_image = $the_ad->image_id; $ad_image_preview = $the_ad->imagepre_id; $ad_type = TONETextDisplay($the_ad->type, false, false); $ad_year = TONETextDisplay($the_ad->itemyear, false, false); $ad_description = TONETextDisplay($the_ad->description, false, false); $ad_name = TONETextDisplay($the_ad->name, false, false); $ad_phone = TONETextDisplay($the_ad->phone, false, false); $ad_email = TONETextDisplay($the_ad->email, false, false); $ad_text = TONETextDisplay($the_ad->itemtext, false, false); ## Set the display options $show_ad = true; $show_good = false; $show_preview = false; $url_forward[] = 'aid=' . $aid; } break; case $kTONESubmitAd: ## Set the display mode $show_owner = false; $show_ad = true; ## Preformat the data $ad_type = TONETextPreformat($ad_type); $ad_year = TONETextPreformat($ad_year); $ad_model = TONETextPreformat($ad_model); $ad_description = TONETextPreformat($ad_description); $ad_name = TONETextPreformat($ad_name); $ad_phone = TONETextPreformat($ad_phone); $ad_email = TONETextPreformat($ad_email); $ad_text = TONETextPreformat($ad_text); ## Validate the inputed data if(empty($ad_type)) { $error[val] += $error[code][blank_type]; $error[txt][] = "You must select an Ad type."; } if(empty($ad_year)) { if($ad_type == $kTONEAdTypeBoat || $ad_type == $kTONEAdTypeCrew) { $error[val] += $error[code][blank_year]; $error[txt][] = "You must enter the year of your Tartan."; } } else { if(!preg_match("/^(\d\d\d\d)$/", $ad_year)) { $error[val] += $error[code][bad_year]; $error[txt][] = "The year must be 4 digits (YYYY)."; } } if(empty($ad_model) && $ad_type==$kTONEAdTypeBoat) { $error[val] += $error[code][blank_model]; $error[txt][] = "You must select a Tartan model for this ad."; } if(empty($ad_description) && $ad_type!=$kTONEAdTypeBoat) { $error[val] += $error[code][blank_description]; $error[txt][] = "You must enter a short description."; } if(empty($ad_name)) { $error[val] += $error[code][blank_ownername]; $error[txt][] = "You must enter your name."; } if(empty($ad_phone)) { $error[val] += $error[code][blank_phone]; $error[txt][] = "You must enter a phone number."; } if(empty($ad_email)) { $error[val] += $error[code][blank_email]; $error[txt][] = "You must enter an email address."; } else { if( !TONEValidateEmailForm($ad_email) ) { $error[val] += $error[code][bad_email]; $error[txt][] = "Your email address is invalid."; } } if(empty($ad_text)) { $error[val] += $error[code][blank_text]; $error[txt][] = "You must enter the Ad text."; } if( !empty($_FILES['ad_photo']['name']) ) { if($_FILES['ad_photo']['size'] > $max_file_size) { $error[val] += $error[code][file_size_lrg]; $error[txt][] = "Images cannot be larger than $max_file_size bytes."; } if($_FILES['ad_photo']['size'] < $min_file_size) { $error[val] += $error[code][file_size_sml]; $error[txt][] = "Images cannot be smaller than $min_file_size bytes."; } if( !($error[val] & $error[code][file_size_sml]) && !($error[val] & $error[code][file_size_lrg]) ) { $image_orig = new TONEImage; $image_orig->dir = $_FILES['ad_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(); } unset($data); $data[id] = $ad_image; $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[val] += $error[code][db_norows]; $error[txt][] = "The image could not be added to the database."; } else { $ad_image = $error_result; $error_result = TONEImageMove($_FILES['ad_photo']['tmp_name'], $ad_image, $image_orig->type); if(TONEIsError($error_result, 'img_nocpy')) { TONEImageDelete($id); $error[val] += $error[code][file_copy]; $error[txt][] = "Could not store the image."; } if(!$error[val] ) { $tmpimg=tempnam("/tmp", "img"); $image_preview = new TONEImage; $image_preview->dir = $tmpimg; if(!empty($debug)) $imig_preview->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_preview->dir); $image_preview->GetInfo(); unset($data); $data[id] = $ad_image_preview; $data[size] = $image_preview->size; $data[type] = $image_preview->type; $data[dim_x] = $image_preview->dim_x; $data[dim_y] = $image_preview->dim_y; $error_result = TONEImageUpdate($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 preview image could not be added to the database."; } else { $ad_image_preview = $error_result; $error_result = TONEImageMove($image_preview->dir, $ad_image_preview, $image_preview->type); } } } } } if(!$error[val]) { unset($data); $data[id] = $aid; $data[model_id] = $ad_model; $data[image_id] = $ad_image; $data[imagepre_id] = $ad_image_preview; $data[type] = $ad_type; $data[itemyear] = $ad_year; $data[description] = $ad_description; $data[name] = $ad_name; $data[phone] = $ad_phone; $data[email] = $ad_email; $data[itemtext] = $ad_text; switch($sub_type) { ## Add the data case $kTONESubmitAdAdd: $data[active] ='Y'; $error_result = TONEAdUpdate($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."; } if($error[val]) { $show_ad = true; $show_preview = false; $show_good = false; } else { ## All is good, lets redirect to the applicable ads page exec("curl 'http://www.tartanowners.org/members/rss/news.php?ad=$error_result' > /dev/null &"); if($ad_type == $kTONEAdTypeBoat) $page = '/v6/classifieds.phtml'; if($ad_type == $kTONEAdTypeItem) $page = '/v6/classifieds.phtml'; if($ad_type == $kTONEAdTypeCrew) $page = '/v6/classifieds.phtml'; if($ad_type == $kTONEAdTypeWant) $page = '/v6/classifieds.phtml'; TONERedirectBrowser($page, false); exit; $show_ad = false; $show_preview = false; $show_good = true; } break; ## Add the data and show a preview case $kTONESubmitAdPreview: $data[active] ='N'; $error_result = TONEAdUpdate($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."; } else { $aid = $error_result; } if($error[val]) { $show_owner = false; $show_ad = true; $show_preview = false; $show_good = false; } else { ## Format the data for display on the screen $ad_model = TONETextDisplay($ad_model); $ad_type = TONETextDisplay($ad_type); $ad_year = TONETextDisplay($ad_year); $ad_description = TONETextDisplay($ad_description); $ad_name = TONETextDisplay($ad_name); $ad_phone = TONETextDisplay($ad_phone); $ad_email = TONETextDisplay($ad_email); $ad_text = TONETextDisplay($ad_text); $show_ad = true; $show_preview = true; $show_good = false; $error_result = TONEModelGet($ad_model); if(is_array($error_result)) $ad_model_name=$error_result[model]; $url_forward[] = 'aid=' . $aid; } break; } } if($error[val]) { ## Format the data for display on the screen $ad_type = TONETextDisplay($ad_type, false, false); $ad_year = TONETextDisplay($ad_year, false, false); $ad_model = TONETextDisplay($ad_model, false, false); $ad_description = TONETextDisplay($ad_description, false, false); $ad_name = TONETextDisplay($ad_name, false, false); $ad_phone = TONETextDisplay($ad_phone, false, false); $ad_email = TONETextDisplay($ad_email, false, false); $ad_text = TONETextDisplay($ad_text, false, false); } break; } } $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 Classified Ad Form
<% include("/var/www/webhosts-script/www.tartanowners.org/private/menu/menu.html"); %>

Classified Ads Form

Use this form to submit a personal advertisement.

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

Errors:

<%endif;%><%if($show_preview):%>

Ad Preview:

<%if($ad_image && $ad_image_preview): echo TONEImageGetTagIMG($ad_image_preview); else: %>No Photo.<%endif;%> <%=$gTONEAdType[$ad_type][name];%>: <%if($ad_year):%><%=$ad_year;%><%endif;%> <%if($ad_model_name):%>Tartan: <%=$ad_model_name;%><%endif;%> Description: <%=$ad_description;%>
Contact: <%=$ad_name;%>; <%=$ad_phone;%>; <%=$ad_email;%>

<%=$ad_text;%>
  

Ad Status:

This preview shows how your ad will appear.  Press Change to edit or Submit to activate it as-is.
<%else:%>
Ad Type:  <%=TONEAdTypePopUp('ad_type', $ad_type);%>
Year: 
Tartan Model:  <%=TONEModelPopUp('ad_model', $ad_model);%>
Short Description: 
Name: 
Phone: 
Email: 
Text: 
Photo:  <%if($ad_image && $ad_image_preview):%>Your Ad photo is shown below. To change it, use the "Browse" button to select another:

<%=TONEImageGetTagIMG($ad_image_preview);%>

<%endif;%>
    
<%endif;%>

Note: