prepare($query); $stmt->bind_param('s', $siteurl); $stmt->execute(); $result = $stmt->get_result(); if ($result->num_rows == 0) { echo 'Site is not available
'; exit; } $site = $result->fetch_assoc(); // HTML Template //$tpfile = "templates/new.html"; $tpfile = $site['html']; $tph = fopen( $tpfile, "r" ) or die( "Unable to open file!" ); $templatestr = fread( $tph,filesize($tpfile) ); $images = explode('|',$site['before_after_images']); $sliderstr = ''; /* // BEFORE AFTER // Original for( $i = 1; $i <= count($images)-1 ; $i++ ){ if ($site['before_after_imgfolder'] == '') { $baimgfolder = '/sites/'.$site['folder'].'/'; } else { $baimgfolder = '/'.$site['before_after_imgfolder'].'/'; } $sliderstr .= "
  • \n"; } $site['footer_title'] = $site['location_name'] ? $site['practice_name'].'
    '.$site['location_name'] : $site['practice_name']; */ // NEW BEFORE/AFTER $baimgfolder = '/'.$site['before_after_imgfolder'].'/'; $sliderstr = "
  • \n "; for( $i = 1; $i <= count($images) - 1; $i++ ){ $sliderstr .= "
  • \n "; } // HTML Placeholders $placeholders = array( '{footer_title}' => $site['footer_title'], '{title}' => $site['practice_name'], '{css}' => $site['css'], '{js}' => $site['js'], '{modal}' => $site['modal'], '{address1}' => $site['address'], '{address1_top}' => $site['address'], '{address2_top}' => ', '.$site['city'].', '.$site['state'].' '.$site['zip'], '{address2}' => $site['city'].', '.$site['state'].' '.$site['zip'], '{phone_url}' => $site['phone_url'], '{phone}' => $site['phone'], '{business hours}' => $site['office_hours'], '{business hours top}' => $site['office_hours'] ? ''.$site['location_name'].' '.$site['office_hours'] : '', '{lat}' => $site['lat'], '{lng}' => $site['lng'], '{emailto}' => $site['contact_email'], '{bcc}' => $site['bcc'], '{logo}' => $site['logo'], '{bottom_img}' => $site['bottom_image'], '{header-background}' => $site['header_background'], '{banner}' => $site['banner'], '{banner_mobile}' => $site['banner_mobile'], '{content2-bg}' => $site['content2-bg'], '{content3-bg}' => $site['content3-bg'], '{content4-bg}' => $site['content4-bg'], '{content5-bg}' => $site['content5-bg'], '{content6-bg}' => $site['content6-bg'], '{content7-bg}' => $site['content7-bg'], '{promoHTML}' => $site['promoHTML'], '{content2_custom}' => $site['content2_custom'], '{objection1_custom}' => $site['objection1_custom'], '{objection2_custom}' => $site['objection2_custom'], '{objection3_custom}' => $site['objection3_custom'], '{footer-custom}' => $site['footer-custom'], '{footer-bg}' => $site['footer-bg'], '{headline}' => $site['headline'], '{siteurl}' => $site['domain'], '{googletag_head}' => $site['googletag_head'], '{googletag_body}' => $site['googletag_body'], '{form_captcha}' => $site['form_captcha'], '{ba_image1}' => $baimgfolder.$images[0], '{before_after_title}' => $site['before_after_title'], '{before_after_slider}' => $sliderstr, '{reviews}' => $site['reviews'], '{promo}' => $site['promo'], '{topbtn_text}' => $site['topbtn_text'], '{home_website}' => $site['home_website'], '{map_extra}' => $site['map_extra'], ); // Additional locations $query = "select * from additional_locations where site_id=".$site['id']; $result = $mysqli->query($query); if ($result->num_rows > 0) { if ($site['id']=='170') { $mapfh = fopen('templates/map2.html', "r") or die("Unable to open file!"); $mapc = fread($mapfh, filesize('templates/map2.html')); } else{ $mapfh = fopen('templates/map.html', "r") or die("Unable to open file!"); $mapc = fread($mapfh, filesize('templates/map.html')); } } $addl_locations_top = ''; $addl_locations_map = ''; $addl_locations_mapcall = ''; // First city was not displaying, but makes city display even if no extra locations //$addl_locations_top = $site['city']; $counter = 0; while( $addl_loc = $result->fetch_assoc() ){ $counter++; if( $counter == 1 ){ $addl_locations_top .= $site['city']; } $mapplaceholders = [ '{title}' => $addl_loc['location_name'] ? ''.$addl_loc['location_name'].'
    ' : '', '{address1}' => $addl_loc['address'], '{address2}' => $addl_loc['city'].', '.$addl_loc['state'].' '.$addl_loc['zip'], '{phone_url}' => $addl_loc['phone_url'], '{phone}' => $addl_loc['phone'], '{business hours}' => $addl_loc['office_hours'], '{lat}' => $addl_loc['lat'], '{lng}' => $addl_loc['lng'], ]; $addl_locations_map .= $mapc; foreach ($mapplaceholders as $key => $value) { $addl_locations_map = str_replace($key, $value, $addl_locations_map); } $addl_locations_map = str_replace('{map}', "map-".$site['id'].'-'.$addl_loc['location_id'], $addl_locations_map); $addl_locations_map = str_replace('{siteid}', $site['id'], $addl_locations_map); $addl_locations_map = str_replace('{locid}', $addl_loc['location_id'], $addl_locations_map); $addl_locations_mapcall .= 'initMap_'.$site['id'].'_'.$addl_loc['location_id'].'();'; //$addl_locations_top .= ' //
    '.$addl_loc['address'].', '.$addl_loc['city'].', '.$addl_loc['state'].' '.$addl_loc['zip']. // ' // '.$addl_loc['phone'].' //'; //$addl_locations_top .= ''.$addl_loc['city'].' '.$addl_loc['phone'].' '; //$addl_locations_top .= ''.$addl_loc['phone'].' '.$addl_loc['city'].''; //$addl_locations_top .= ' | '.$addl_loc['phone'].' '.$addl_loc['city'].''; //$addl_locations_top .= ' | '.$addl_loc['phone'].' '.$addl_loc['city'].''; //$addl_locations_top .= ' | '.$addl_loc['phone'].' '.$addl_loc['city'].''; //$addl_locations_top .= ''; //$addl_locations_top .= ' | '.$addl_loc['phone'].' '.$addl_loc['city'].''; //$addl_locations_top .= ''; //$addl_locations_top .= ' | '.$addl_loc['phone'].' '.$addl_loc['city'].''; //$addl_locations_top .= ''; $addl_locations_top .= ' | '.$addl_loc['phone'].' '.$addl_loc['city'].''; $addl_locations_top .= ''; //$addl_locations_top .= ' | '.$addl_loc['city'].''; //$addl_locations_top .= ''; } $placeholders['{addl_loc_top}'] = $addl_locations_top; $placeholders['{addl_loc_map}'] = $addl_locations_map; $placeholders['{addl_map_call}'] = $addl_locations_mapcall; // CUSTOM FORM if( $site['form'] != '' ){ $formfile = $site['form']; $formtph = fopen($formfile, "r") or die("Unable to open file!"); $formtemplatestr = fread( $formtph, filesize($formfile) ); $formtemplatestr = str_replace('{emailto}', $site['contact_email'], $formtemplatestr); $formtemplatestr = str_replace('{bcc}', $site['bcc'], $formtemplatestr); $formtemplatestr = str_replace('{siteurl}', $site['domain'], $formtemplatestr); $formtemplatestr = str_replace('{topbtn_text}', $site['topbtn_text'], $formtemplatestr); $formtemplatestr = str_replace('{form_captcha}', $site['form_captcha'], $formtemplatestr); $placeholders['{contact_form}'] = $formtemplatestr; } // MODAL CONTENT if( $site['modal'] != '' ){ $modalfile = $site['modal']; $modal = fopen( $modalfile, "r") or die("Unable to open file!"); $formtemplatestr = fread( $modal,filesize($modalfile) ); $placeholders['{modal}'] = $formtemplatestr; } // REVIEWS if( $site['reviews'] != '' ){ $reviews_file = $site['reviews']; $reviews = fopen( $reviews_file, "r") or die("Unable to open file!"); $reviews_templatestr = fread( $reviews,filesize($reviews_file) ); $placeholders['{reviews}'] = $reviews_templatestr; } // Title, logo, phone and text icons if( !is_null($site['top_title']) && $site['top_title'] != '' ){ $placeholders['{top_title}'] = $site['top_title']; } else{ $placeholders['{top_title}'] = 'CoolSculpting '.$site['city'].', '.$site['state'].' | '.$site['practice_name']; } $placeholders['{folder}'] = $site['folder']; // REPLACE placeholders in HTML foreach ($placeholders as $key => $value) { $templatestr = str_replace($key, $value, $templatestr); } // RENDER landing page from HTML echo $templatestr; // VISITOR TRACKING // Database parameters, set if GET not null $firstname = ''; $lastname = ''; $email = ''; $phone = ''; $siteurl = ''; $utm_source = ''; $utm_medium = ''; $utm_campaign = ''; $utm_term = ''; $utm_content = ''; if( isset($_GET['utm_source'])) $utm_source = $_GET['utm_source']; if( isset($_GET['utm_medium'])) $utm_medium = $_GET['utm_medium']; if( isset($_GET['utm_campaign'])) $utm_campaign = $_GET['utm_campaign']; if( isset($_GET['utm_content'])) $utm_content = $_GET['utm_content']; if( isset($_GET['utm_term'])) $utm_term = $_GET['utm_term']; // Copy all site data to SESSION for company_id foreach( $site as $key => $value ){ $_SESSION[$key] = $value; } $siteurl = $_SERVER['HTTP_HOST']; $company_id = $_SESSION['company_id']; $contents .= "index.php: company_id = $company_id\n"; // IP AND VISITOR TRACKING and save to consultation_submissions table $sql = "INSERT INTO visitors (ip, date, siteurl, utm_source, utm_medium, utm_campaign, utm_term, utm_content, company_id) VALUES (?,now(),?,?,?,?,?,?,?)"; if( $stmt = $mysqli->prepare($sql) ){ $stmt->bind_param( "ssssssss", $_SERVER['REMOTE_ADDR'], $siteurl, $utm_source, $utm_medium, $utm_campaign, $utm_term, $utm_content, $company_id); if( $stmt->execute() ){ //$debug_contents .= "\nindex.php: executed()"; error_log("executed"); } else{ error_log("didnt execute"); } } // SELECT id $sql = "SELECT LAST_INSERT_ID()"; $stmt = $mysqli->prepare($sql); $result = $mysqli->query($sql); $row = $result->fetch_assoc(); foreach( $row as $key => $row_ ){ $id = $row_; $get_contents .= "\nindex.php: id = $id"; } // Pass visitor id to form submission $_SESSION['visitors_id'] = $id; $get_contents .= "\nindex.php: _SESSION[id] = ".$_SESSION['visitors_id']."\n"; fwrite( $debug, $debug_contents."\n" ); fclose( $debug ); fwrite( $get_file, $get_contents."\n" ); fclose( $get_file ); ?>