.html The prime copy of this script lives on vds12 in /clients/common/encore. Please do not make any changes to this script in any other location as they will be overwritten when a new deployment occurs. After updating, use /home/kristin/encore-deploy.sh to deploy the code across all of the servers. When a new server is added, add it to the encore-deploy.sh script. ***********************************************************************************/ $Root = $_SERVER['DOCUMENT_ROOT']; // get the form type from the filename. preg_match('/form\-([a-zA-Z0-9-]*)\.html/',$_SERVER['PHP_SELF'],$matches); $ftype = $matches[1]; $useCaptcha = true; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $ipAction=''; foreach($_POST as $type=>$value) { if (stristr($value, 'first page of Google') || stristr($value, '1st page of Google') || stristr($value, 'We help our clients get') || stristr($value, 'BackPage Ads') || stristr($value, 'Ads Posting') || stristr($value, 'yourmail@gmail.com') || stristr($value, 'POSTING SOFTWARE') || stristr($value, 'top of the search') || stristr($value, 'increase fans') || stristr($value, 'increase likes') || stristr($value, 'increase followers') || stristr($value, 'increase rankings') ) $ipAction = 'thanks'; } if ($ipAction=='') { if (!isset($_POST['g-recaptcha-response']) || $_POST['g-recaptcha-response']=='') { $arBlockedIPs=array('');$arWhiteList=array(''); // pull in any ip block/allow lists if (is_file('ip-arrays.php')) include('ip-arrays.php'); // for client-wide if (is_file('ip-arrays-'.$ftype.'.php')) include('ip-arrays-'.$ftype.'.php'); // for form-specific if (!is_callable('vdsFirstCheckIP')) include('/clients/common/docs/inc/code/ip-checkers.php'); $ipAction = vdsFirstCheckIP($arBlockedIPs,$arWhiteList); } } // for a while, we pretend the form got submitted if ($ipAction == 'thanks') { header('Location: thanks-'.$ftype.'.html'); exit(); } // we can also pretend a denial of service is occurring (specific to that IP) if ($ipAction == 'denial') { header('HTTP/1.0 503 Service Unavailable'); exit(); } } if (!is_callable('vdsRecordIP')) include('/clients/common/docs/inc/code/ip-checkers.php'); $numAttempts = vdsNumAttemptsForIP(); if ($numAttempts>2) $useCaptcha = true; if (!is_callable('vdsImportRequestVariables')) include('/clients/common/docs/inc/code/variable-import.php'); vdsImportRequestVariables(1,'URL_'); // Includes the error functions error_out (email error and exit) and error_msg (email error and continue) for use in the script. if (!is_callable('error_msg')) include('/clients/common/docs/inc/code/error_handler.php'); // Includes the generic curl function for calling Smart Capture if (!is_callable('get_web_page')) include('/clients/common/docs/inc/code/curl-handler.php'); // Sanitize "ref" variable to prevent cross-site scripting if (isset($URL_ref)) $URL_ref = preg_replace('/\W/', '', $URL_ref); else $URL_ref = ''; // we use ref to store the AdTracker code, but sometimes the ref appears to have the URL of the referrer?? if (strlen($URL_ref)>3) {$URL_ref = '';$_REQUEST['ref']='';$_POST['ref']='';$_GET['ref']='';} if (!isset($URL_Email)) $URL_Email=''; if (!isset($URL_message)) $URL_message=''; if (!isset($URL_Name)) $URL_Name=''; if (!isset($URL_UN)) $URL_UN=''; if (!isset($URL_Num)) $URL_Num=''; if (!isset($URL_Avail)) $URL_Avail=''; if (!isset($URL_Stay)) $URL_Stay=''; if (!isset($URL_ET)) $URL_ET=''; if (!isset($URL_FT)) $URL_FT=''; if (!isset($URL_PID)) $URL_PID=''; // initialize variables commonly found in OLconfig.php $TEMPLATEDOCTITLE = 'doctitle'; $TEMPLATEPAGEHEADER = 'PageHeader'; $TEMPLATEHEAD = 'head'; $TEMPLATEMAINCONTENT01 = 'MainContent01'; $TEMPLATEMAINCONTENT02 = 'MainContent02'; // initialize variables which might get overwritten in preprocess- $dontSpamCheck = false; $post_ret = ''; $actionfile = 'http://smart-capture.vdsys.com/services/form-capture.php'; // initialize variables possibly set/overwritten in config- file $thanksurl = ''; $custombuttons = ''; $METATAGS = ''; $gSiteKey = ''; $gSecretKey = ''; $pageTitle = ''; $pageHeader = ''; $introText = ''; $hasupload = false; $template = ''; $formid = 0; $AccountID = 0; $navisdKW = ''; $contactblock = ''; $questionblock = ''; $custombuttons = '

'; $formOnSubmit = "_gaq.push(['_trackEvent', 'Form', 'submit-form', 'Contact Us - ".$ftype." Form']);ga('send','event','Form','submit-form', 'Contact Us - ".$ftype." Form');"; // do not include the OLconfig.php for Wyndham forms - they are included in the Config.php file which // we have no control over. if (!preg_match('/wyn(.)*\.vdsys\.com/i',$_SERVER['SERVER_NAME']) && $_SERVER['SERVER_NAME']!='www.wyndhamvacationrentals.com' ) { include_once ($Root.'/inc/OLconfig.php'); // check for $clientVDSID to verify the Smart Capture account has been created already if (!isset($clientVDSID) || $clientVDSID=='' || $clientVDSID==0) error_out('Client VDS ID is not set in OLconfig.php? Might need to create new Smart Capture client'); } // If the jquery overlays are available, include them in the form. // The overlays put the "Please Wait" image on the screen after the submit button is pressed. // This keeps the button from being pressed more than once when the form submission is delayed. $addHead=''; $afterbuttons=''; if (is_file("$Root/vdsimages/ajax-loader.gif") && is_file("$Root/vdsimages/ajax-loaderBG.gif") && is_file("$Root/vdsimages/alert-wait.png") && is_file("$Root/vdsimages/modsrchbg.png") && is_file("$Root/javascript/jquery.js") ) { $addHead = ''; $afterbuttons = " "; } if ($_SERVER['REQUEST_METHOD'] == 'POST') { // use preprocess-.php to overwrite variables, add things to the $_REQUEST, etc if (file_exists('preprocess-'.$ftype.'.php')) { include_once('preprocess-'.$ftype.'.php'); } if ( substr($post_ret,0,3) <>'req') { // so the preprocess file can kick back to the form without going through main processor. if ($gSiteKey!='' && $useCaptcha==true) { $arCaptchaFields['response'] = $_POST['g-recaptcha-response']; $arCaptchaFields['secret'] = $gSecretKey; $arCaptchaFields['remoteip'] = $theIP; $gresponse = checkCAPTCHA($arCaptchaFields); $readresponse = json_decode($gresponse,true); if ($readresponse['success']!=true) { if ($preview==true) error_msg('The reCaptcha response is: '.var_export($readresponse['error-codes'],true)); $post_ret = 'req~~
  • Please verify you are not a robot
  • '; } } $URL_Email = get_web_page('http://smart-capture.vdsys.com/services/curl-domain-correct.php?Email='.$URL_Email); $_REQUEST['Email'] = $URL_Email; if (isset($customMessageFieldData) && $customMessageFieldData!='') { $customMessageFieldName = md5('Custom'.$_REQUEST['FormID'].$_REQUEST['Email'].'Message'.$_REQUEST['AID']); $_REQUEST[$customMessageFieldName] = $customMessageFieldData; } if (!$dontSpamCheck) { if (!is_callable('vdsSPAMCheck')) include('/clients/common/docs/inc/code/variable-check.php'); vdsSPAMCheck(); if (!is_callable('isValidEmail')) include_once('/clients/common/docs/inc/code/email-validator.php'); if (!isValidEmail($URL_Email) || stristr($URL_Email, '@test.com')) { $post_ret = 'req~~
  • Invalid Email Address
  • '; } } if ( substr($post_ret,0,3) != 'req') { $post_ret = get_web_page($actionfile); } if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'){ echo $post_ret; exit(); } elseif ( substr($post_ret,0,6)=='thanks') { if (isset($thanksurl) && $thanksurl[0]=='?') { error_msg('thanksurl needs updating: '.$thanksurl); $thanksurl[0] = '&'; } $URLString = substr($post_ret,8); if ( substr($URLString,0,2) != 'FT') { error_msg('Not sure what we are looking for, but don\'t see the FToken...'.$URLString); } header('Location: thanks-'.$ftype.'.html?'.$URLString.$thanksurl); exit(); } } } if (isset($post_ret) && $post_ret != '' && substr($post_ret,0,3) != 'req') { error_msg('post_ret is: ~'.$post_ret.'~'); exit('post_ret is: ~'.$post_ret.'~'); } elseif ( substr($post_ret,0,3) == 'req' ) { $missedRequirements=true; $errorReasons = substr($post_ret, 5); } if (isset($missedRequirements) && $missedRequirements==true) { $reqmessage = '

    Some required fields are not filled in. Please fill them in and re-submit.

    '; if (isset($errorReasons)) { $reqmessage .= ''; } $reqsymbol = "  Required."; } else { $reqmessage = "

    (* indicates required field)

    "; $reqsymbol = "*"; } if ($URL_Name=='' && $URL_UN!='') $URL_Name=$URL_UN; if ($URL_Num!='') $URL_Name = '('.$URL_Num.') '.$URL_Name; if ($URL_message!='') { $altMessage = stripslashes($URL_message); } elseif ($URL_Name!='') { $altMessage = 'I was looking at property: '.stripslashes($URL_Name); if($URL_Avail<>""){ $Avail = strftime("%m/%d/%Y",strtotime("$URL_Avail")); $altMessage .= ", arriving $Avail"; } if($URL_Stay<>""){ $altMessage .= ", staying for $URL_Stay days"; } $altMessage .= " and would like to know..."; } include_once("config-$ftype.php"); include_once("$Root/inc/OpenTemplateParser.class.php"); $page = new TemplateParser($template); if (is_array($addTemplateSection)) { foreach ($addTemplateSection as $section=>$content) { $page->setSection($section, $content); } } // if the OLconfig file contains the captcha information, include it if ($useCaptcha==true && $gSiteKey!='') $addHead .= ""; if ($TEMPLATEHEAD<>"") { if ($METATAGS<>"") $page->appendSection($TEMPLATEHEAD, $METATAGS); if (file_exists('optinform.css')) $page->appendSection($TEMPLATEHEAD,""); if (file_exists($ftype.'.css')) $page->appendSection($TEMPLATEHEAD,""); if ($addHead<>"") $page->appendSection($TEMPLATEHEAD, $addHead); } $contents = ""; $page->setTitle($pageTitle); if ($TEMPLATEPAGEHEADER<>"") $page->setSection($TEMPLATEPAGEHEADER, $pageHeader); else { $contents .= '

    '.$pageHeader.'

    '; } $contents .= "
    ".$introText."
    "; $contents .= "
    ".$reqmessage."
    "; // start the form and make sure to add client-specific identifiers as hiddens so // that our non-client-specific form processor can tell who this is. $contents .= "
    "") $contents .= "onsubmit=\"".$formOnSubmit."\""; $contents .= ">"; $contents .= ""; $contents .= ""; if ($URL_ET<>"") $contents .= ""; if ($URL_FT<>"") $contents .= ""; if ($URL_PID<>"") $URL_Num=$URL_PID; if ($URL_Num<>"") $contents .= ""; // if the form has a Navis export, add the hidden field for the Keyword if ($navisdKW<>"") $contents .= ""; $contents .= ""; $contents .= $contactblock; $contents .= $questionblock; $contents .= "
    "; if ($gSiteKey!='') $contents .= "
    "; $contents .= $custombuttons; $contents .= $afterbuttons; $contents .= "
    "; // if the form has a Navis export, add the JavaScript to pull in the Campaign Keyword if ($navisdKW) $contents .= ''; if ($addTemplateSection[$TEMPLATEMAINCONTENT01]=='') $page->setSection($TEMPLATEMAINCONTENT01, $contents); $page->printPage(); function checkCAPTCHA( $arFields='') { $peer_key = version_compare(PHP_VERSION, '5.6.0', '<') ? 'CN_name' : 'peer_name'; $options = array( 'http' => array( 'header' => "Content-type: application/x-www-form-urlencoded\r\n", 'method' => 'POST', 'content' => http_build_query($arFields), // Force the peer to validate (not needed in 5.6.0+, but still works 'verify_peer' => true, // Force the peer validation to use www.google.com $peer_key => 'www.google.com', ), ); $context = stream_context_create($options); return file_get_contents('https://www.google.com/recaptcha/api/siteverify', false, $context); }