add_error("No advert has been supplied"); elseif(!eregi("^[0-9]*$", $advert_id)) $page->add_error("No advert has been supplied"); if(!$page->check_for_errors()){ require(SITE_INCLUDES."/classes/business_advert.class.php"); $advert = new Business_advert($page); $advert->set_advert_id($advert_id); $advert->load_advert("'1', '8'"); if(!$page->check_for_errors()){ $reject_form_class = "hide"; $status = $advert->get_status(); $userid = $advert->get_userid(); $type = $advert->get_advert_type(); $type_string = $type == 1 ? "Business for sale" : "Business looking for investment"; $username = $advert->get_username(); $title = $advert->get_title(); $description = $advert->get_description(); $years_trading = $advert->get_years_trading(); $asking_price = number_format($advert->get_asking_price()); $turnover = number_format($advert->get_turnover()); $profit_string = $advert->get_profit_display(); $profit_loss_string = $advert->get_profit_loss_text(); $ownership = $advert->get_ownership_text(); $has_employees = $advert->get_has_employees(); $has_employees_text = $has_employees == "1" ? 'Yes' : "No"; if($has_employees == "1") { $fulltime_staff = $advert->get_fulltime_staff (); $parttime_staff = $advert->get_parttime_staff (); } $audited_accounts = $advert->get_audited_accounts() == 1 ? 'Yes' : 'No'; $management_accounts = $advert->get_management_accounts() == 1 ? 'Yes' : 'No'; $category = $advert->get_category(); $category_id = $advert->get_category_id(); $sub_category_id = $advert->get_sub_category_id(); $sub_category = $advert->get_sub_category(); $country_id = $advert->get_country_id(); $country = $advert->get_country(); $area_id = $advert->get_area_id(); $area = $advert->get_area(); $county_id = $advert->get_county_id(); $county = $advert->get_county(); $town_id = $advert->get_town_id(); $town = $advert->get_town(); if( $type == 2 ) { //investment $share = $advert->get_share(); $eis_registered = $advert->get_eis_registered(); $eis_registered_text = $eis_registered == 1 ? "Yes" : "No"; } $advert_photos = $advert->get_advert_photos(); $termid = isset($_GET['termid']) ? $_GET['termid'] : ""; if(!empty($termid)) $advert->log_referer($termid); //do page keywords $page->add_page_keywords($category); $page->add_page_keywords($country); if(!empty($sub_category)) $page->add_page_keywords($sub_category); if(!empty($area)) $page->add_page_keywords($area); if(!empty($area)) $page->add_page_keywords($county); if(!empty($town)) $page->add_page_keywords($town); //work out category display for meta description $cat_display = $category; if(!empty($sub_category)) $cat_display = $sub_category." / ".$cat_display; //work out loc display for titles if(!empty($county)) $loc_display = $county; if(!empty($town)) $loc_display .= ", ".$town; if(empty($loc_display) && !empty($area)) $loc_display = $area; elseif(empty($loc_display)) $loc_display = $country; //Set meta data $page->set_page_title($title." in ".$loc_display); if(count(explode(" ", $description)) < 20) $page->set_page_description($cat_display." business for sale in ".$loc_display." for ".$asking_price.". Contact ".$username." for more info"); else{ $words = explode(" ", $description); $words = array_slice($words, 0, 15); $page->set_page_description(substr(implode(" ", $words), 0, -1)."..."); } //are they are buyer client? Check their looking fors if(isset($_SESSION['s_login']) && $_SESSION['s_account_type'] == 2){ $preset_array = array(); $temp = q(sprintf("SELECT id, name FROM buyer_lookingfor WHERE userid = %u", intval($_SESSION['s_userid'])), SITE_DB); while($row = mysql_fetch_assoc($temp)){ $lookingfor_id = $row['id']; $name = $row['name']; $array_pos = count($preset_array); $preset_array[$array_pos]['preset_id'] = $lookingfor_id; $preset_array[$array_pos]['preset_name'] = $name; } Require(SITE_INCLUDES."/classes/matcher.class.php"); $match_percentage = 0; if(isset($_POST['go_preset']) && !empty($_POST['select_preset'])){ //they have selected a specific preset to compare with $matcher = New Matcher($page, $_SESSION['s_userid'], $advert, $_POST['select_preset']); $matcher->calculate_match_percentage(); $match_percentage = $matcher->get_match_percentage(); $preset_id = $_POST['select_preset']; $preset_name = $matcher->get_preset_name();; $preset_match_details = $matcher->get_matched_items(); } else{ for($x=0; $x < count($preset_array); $x++){ $lookingfor_id = $preset_array[$x]['preset_id']; $name = $preset_array[$x]['preset_name']; $matcher = New Matcher($page, $_SESSION['s_userid'], $advert, $lookingfor_id); $matcher->calculate_match_percentage(); $temp_percentage = $matcher->get_match_percentage(); if($temp_percentage >= $match_percentage){ $match_percentage = $temp_percentage; $preset_id = $lookingfor_id; $preset_name = $name; $preset_match_details = $matcher->get_matched_items(); } } } } } } if($page->check_for_errors()){ $page->set_block_bots(true); $page->include_content("error.inc.php"); } //page actions //book marks if(isset($_GET['bookmark']) && isset($_SESSION['s_login']) && $_SESSION['s_account_type'] == 2){ $temp = q(sprintf("INSERT INTO buyer_bookmarks (userid, advert_id, dateadded) VALUES (%u, %u, ".time().")", intval($_SESSION['s_userid']), intval($advert_id)), SITE_DB); } elseif(isset($_GET['bookmark']) && !isset($_SESSION['s_login'])){ $page->set_block_bots(true); $page->include_content("signupinc.php"); } //send to a friend $mail_form_display = "hide"; if(isset($_POST['go_email_friend'])){ $to_email = $_POST['email_to']; $to_name = $_POST['name_to']; if( !isset( $_SESSION['s_login'] ) ) $from_user_name = $_POST['name_from']; else $from_user_name = $load_user->get_user_data('contact_name'); if( empty( $from_user_name ) ) $page->add_error("Please enter your name"); if(empty($to_email)) $page->add_error("Please enter an email to send to."); if(empty($to_name)) $page->add_error("Please enter the name of the person you are sending to."); require(SITE_INCLUDES."/classes/php-captcha.php"); if(!PhpCaptcha::Validate($_POST['confirmCode'])) $page->add_error("The code does not match, please try again"); if(!$page->check_for_errors()){ //get the send to a friend template $temp = q("SELECT * FROM support_email_templates WHERE id = 3", SITE_DB); $row = mysql_fetch_assoc($temp); if(is_array($row)){ //get email data $from_name = $row['from_name']; $from_email = $row['from_email']; $from = $from_name."<".$from_email.">"; $subject = $row['subject']; $email_body = $row['email']; //make relevant replaces $subject = str_replace("%from_name", $from_user_name, $subject); $email_body = str_replace("%from_name", $from_user_name, $email_body); $email_body = str_replace("%to_name", $to_name, $email_body); $email_body = str_replace("%linkvar", SITE_LINKS, $email_body); $email_body = str_replace("%advert_link", "advert-".$advert_id.".html", $email_body); $email_body = str_replace("%support_link", "support-centre/", $email_body); //send email send_email($to_email, $subject, $email_body, $from, true, false); $page->add_error("We have sent the mail to your friend."); $page->set_error_type(1); } } else $mail_form_display = "block"; } if(isset($_SESSION['s_login']) && $_SESSION['s_account_type'] == 2){ //register a view $result = q ( sprintf("INSERT INTO advert_views VALUES (%u, %u, 1, %u, ".time().") ON DUPLICATE KEY UPDATE percentage_match = %u, amount = amount + 1, dateadded = ".time(), intval($advert_id), intval($_SESSION['s_userid']), intval ( $match_percentage ), intval ( $match_percentage ) ), SITE_DB); } else { //register a general view $temp = q ( sprintf("INSERT DELAYED INTO advert_general_views VALUES (%u)", intval( $advert_id) ) , SITE_DB ); } $page->include_header_file(); require(SITE_INCLUDES."/content/advert.inc.php"); $page->include_footer_file(); ?>