set_file(array("home"=>"upload_photo.html")); $tpl->set_block("home","USERFORM","USERFORMS"); $tpl->set_block("home","MESG","MESGS"); //client requested to insert data directly into the database. emailing the data is not neccessary. //client also requested not to resize the image automatically. they will resize it themselves #define(GALLERY_ADMIN,"nicole@centerline.com"); $source = $_FILES["photo"]["tmp_name"]; $photo_file = basename($_FILES["photo"]["name"]); $dest = "images/gallery/$photo_file"; if ($state) { $affected_rows = addPhoto($vehicle_make,$vehicle_model,$vehicle_year,$wheel_style,$wheel_size,$lifted,$lifted_how_much,$lowered,$lowered_how_much,$carType,$comment,$source,$dest,$photo_file,$email); if ($affected_rows == 0) { $err_mesg ="Database Error: Information about your vehicle cannot be sent to Center Line. Please contact Center Line admin and report this error."; } else { $err_mesg="Your information has been submitted succesfully to Center Line. Thank you."; } $tpl->set_var("message",$err_mesg); $tpl->set_var("USERFORMS",""); $tpl->parse("MESGS","MESG",true); } else{ cleanAll(); $tpl->set_var("error",""); $tpl->set_var("MESGS",""); $tpl->parse("USERFORMS","USERFORM",true); } $tpl->set_var("gallery_footer",GALLERY_FOOTER); $tpl->pparse(DefaultPage,"home"); function addPhoto($vehicle_make,$vehicle_model,$vehicle_year,$wheel_style,$wheel_size,$lifted,$lifted_how_much,$lowered,$lowered_how_much,$carType,$comment,$source,$dest,$photo_file,$email){ global $tpl; if (!copy($source, $dest)) $photo_file = ""; $date_today = date("YmdHis"); switch ($carType){ case "Car": $date_created = "car_date_created"; break; case "Truck": $date_created = "truck_date_created"; break; case "SUV": $date_created = "suv_date_created"; break; } $display = "No"; //dont display to photo gallery the photos submitted by user $display_website = "No"; // initially the photo uploaded by the user should not be displayed $sql = "INSERT INTO cline_auto_info(vehicle_make,vehicle_model,vehicle_year,wheel_style,wheel_size,lifted,lifted_how_much,lowered,lowered_how_much,display,display_website,comment,type,$date_created,date_created,full_photo,email) VALUES ('$vehicle_make','$vehicle_model','$vehicle_year','$wheel_style','$wheel_size','$lifted','$lifted_how_much','$lowered','$lowered_how_much','$display','$display_website','$comment','$carType','$date_today',NOW(),'$photo_file','$email');"; //echo $sql; $result = mysql_query($sql); return mysql_affected_rows(); } //client requested to stop emailing the customer's photo and data to her email //instead just insert it directly into the database and she will just check the //backend page for new photos. /*function emailData($dest){ global $tpl,$vehicle_make,$vehicle_model,$vehicle_year, $wheel_style,$wheel_size,$lifted,$lifted_how_much, $lowered,$lowered_how_much,$comment; if ($lowered == 'Yes') { $myVar = "Lowered $lowered_how_much"; } else if ($lifted=='Yes') { $myVar = "Lifted $lifted_how_much"; } $from_name = "Centerline Wheels Customer"; $from_email = "customer@centerlinewheels.com"; $to_name = "Centerline Wheels Admin"; $to_email = GALLERY_ADMIN; $subject = "Customer Submission of Photo and Auto Info"; if ($comment == "") { $comment = "No Comment."; } $message = $vehicle_year." ".$vehicle_make." ".$vehicle_model."
". $wheel_size." ".$wheel_style."
". $myVar."

Comment: ".$comment; $mime = sendMIME($to_name,$to_email,$from_name,$from_email,$subject,$message,$dest); return $mime; } function sendMIME($to_name,$to_email,$from_name,$from_email,$subject,$message,$dest){ $headers['From'] = $from_email; $headers['Subject'] = $subject; $mime = new Mail_mime; $mime->setTXTBody($message); $mime->setHTMLBody($message); $mime->addAttachment($dest, 'application/octet-stream'); $body = $mime->get(); $headers = $mime->headers($headers); $params['sendmail_path'] = '/usr/sbin/sendmail'; $params['sendmail_args'] = '-oi -t'; // Create the mail object using the Mail::factory method $mail =& Mail::factory('sendmail', $params); if (!$mail->send($to_email, $headers, $body)) { return false; } else return true; }*/ function cleanAll(){ global $tpl; $values = array("vehicle_make"=>"","vehicle_model"=>"","vehicle_year"=>"","wheel_style"=>"","wheel_size"=>"", "lifted_how_much"=>"","lowered_how_much"=>"","comment"=>$comment,"email"=>""); $tpl->set_var($values); } ?>