$dir_content_type = "UTF-8"; header("Content-Type: text/html; charset=$dir_content_type"); @include_once $_SERVER['DOCUMENT_ROOT'].'/init.php'; @include_once $_SERVER['DOCUMENT_ROOT'].'/lib.php'; @include_once $_SERVER['DOCUMENT_ROOT'].'/reviews/lib.php'; $is_okey = (int)$_GET['is_okey']; $merr = array(); $vehicle = ""; $init_name_firm = trim(strtolower($_GET['firm'])); if(!$allow_dir[$init_name_firm]) $merr['firm_error'] = "firm not found"; $init_name_model = $_GET['model']; //is correct model name? $init_name_model = trim(preg_replace("/[^0-9a-z_& -]+/sim", "", $init_name_model)); if(strlen($init_name_model)<1) $merr['model_error'] = "model not found"; $vehicle = trim(get_caption($init_name_firm).' '.get_caption($init_name_model)); $vehicle_url = ""; if($init_name_firm) { $vehicle_url = "".get_caption($init_name_firm).""; if($init_name_model) { $vehicle_url .= " ".get_caption($init_name_model).""; } } $syear = (int)trim($_GET['syear']); if($syear<1900||$syear>2100) $syear = ""; if(sizeof($merr)<1) { if(isset($_POST['submit_review'])) { $subject = ex_my_trim($_POST['subject']); $from_and_location = ex_my_trim($_POST['from_and_location']); $contact = ex_my_trim($_POST['contact']); $email = ex_my_trim($_POST['email']); $model = ex_my_trim($_POST['model']); $year = (int)$_POST['year']; $wrong_comment = ex_my_trim($_POST['wrong_comment']); $general_comment = ex_my_trim($_POST['general_comment']); $f3 = ex_my_trim($_POST['f3']); $f4 = ex_my_trim($_POST['f4']); $f5 = ex_my_trim($_POST['f5']); $f6 = ex_my_trim($_POST['f6']); $f7 = ex_my_trim($_POST['f7']); $f8 = ex_my_trim($_POST['f8']); $f9 = ex_my_trim($_POST['f9']); $f10 = ex_my_trim($_POST['f10']); $prev_car = ex_my_trim($_POST['prev_car']); $f12 = ex_my_trim($_POST['f12']); $f13 = ex_my_trim($_POST['f13']); $ra = $_SERVER['REMOTE_ADDR']; $ua = ex_my_trim($_SERVER['HTTP_USER_AGENT']); if($year<1900||$year>(int)date('Y')) $merr['year'] = 1; if(!strlen($subject)) $merr['subject'] = 1; if(!strlen($from_and_location)) $merr['from_and_location'] = 1; //if(!strlen($wrong_comment)) $merr['wrong_comment'] = 1; if(!strlen($general_comment)) $merr['general_comment'] = 1; if(sizeof($merr)==0) { //reviews status -> //0 - not inserted or consist error //1 - inserted //2 - synced $sql = "insert into reviews (`site_id`, `gfirm`, `gmodel`, `year`, `subject`, `from`, `model`, `what_wrong_car`, `general_comments`, `engine_and_transmission`, `Performance`, `Reliability`, `Comfort`, `Dealer`, `Running_costs`, `Distance_when_acquired`, `Most_recent_distance`, `Previous_car`, `First_year_of_ownership`, `Most_recent_year_of_ownership`, `dt`, `ip`, `user_agent`, `status`, `type`, `contact`, `email`) values ('$init_site_id', '$init_name_firm', '$init_name_model', '$year', '$subject', '$from_and_location', '$model', '$wrong_comment', '$general_comment', '$f3', '$f4', '$f5', '$f6','$f7','$f8','$f9','$f10','$prev_car','$f12','$f13', UNIX_TIMESTAMP(), '$ra', '$ua', 0, 0, '{$contact}', '{$email}')"; mysql_query($sql); $real_id = mysql_insert_id(); if($real_id>0) { //put files reset($_FILES); $pics = array(); $thumbnail_is_ok = false; foreach($_FILES as $key=>$file) { if($file['error']==0&&$file['size']>0) { $save_to_path = $_SERVER['DOCUMENT_ROOT']."/$init_reviews_dir/$init_reviews_pic_dir/$real_id/"; $keyword_for_new_file = $init_name_model; list($is_caption_file, $tmp_file) = upload_file($file, $save_to_path, $keyword_for_new_file); if(!$is_caption_file) continue; $pics[] = $is_caption_file; if(!$thumbnail_is_ok) { $result_jpg = $save_to_path."{$real_id}_thumbnail.jpg"; $thumbnail_is_ok = create_thumbnail($tmp_file, $result_jpg); } } } $sql = "update reviews set real_id='{$real_id}', status='1', pic1='{$pics[0]}', pic2='{$pics[1]}', pic3='{$pics[2]}', pic4='{$pics[3]}', pic5='{$pics[4]}' where id='{$real_id}'"; mysql_query($sql); } header("location: ./add.php?firm={$init_name_firm}&model={$init_name_model}&is_okey={$real_id}"); die(); } //mail("info@toyota-supra.info","add review",$str); } else { $subject = ''; $from_and_location = ''; $contact = ''; $email = ''; $model = ''; $wrong_comment = ''; $general_comment = ''; $f3 = ''; $f4 = ''; $f5 = ''; $f6 = ''; $f7 = ''; $f8 = ''; $f9 = ''; $f10 = ''; $prev_car = ''; $f12 = ''; $f13 = ''; $year = $syear; } } $from_reviews = 1; $header_info = ""; $header_info = "