function GetReturnLink($s_this_script, $i_form_index) { if (!CheckValidURL($s_this_script)) { Error("not_valid_url", GetMessage(MSG_RETURN_URL_INVALID, array("URL" => $s_this_script)), false, false); } $a_params = array(); $a_params[] = "return={$i_form_index}"; if (isset($aServerVars["QUERY_STRING"])) { $a_params[] = $aServerVars["QUERY_STRING"]; } $a_params[] = session_name() . "=" . session_id(); return AddURLParams($s_this_script, $a_params); }
function SendToCRM($s_url, &$a_data) { global $php_errormsg; if (!CheckValidURL($s_url)) { SendAlert(GetMessage(MSG_URL_INVALID, array("URL" => $s_url))); return false; } @($fp = fopen($s_url, "r")); if ($fp === false) { SendAlert(GetMessage(MSG_URL_OPEN, array("URL" => $s_url, "ERROR" => CheckString($php_errormsg)))); return false; } $s_mesg = ""; while (!feof($fp)) { $s_line = fgets($fp, 4096); $s_mesg .= $s_line; } fclose($fp); $s_mesg = StripHTML($s_mesg); $s_result = preg_match('/__OK__=(.*)/', $s_mesg, $a_matches); if (count($a_matches) < 2 || $a_matches[1] === "") { // // no agreed __OK__ value returned - assume system error // SendAlert(GetMessage(MSG_CRM_FAILED, array("URL" => $s_url, "MSG" => $s_mesg))); return false; } // // look for fields to return // $a_data = FindCRMFields($s_mesg); // // check for success or user error // switch (strtolower($a_matches[1])) { case "true": break; case "false": // // user error // $s_error_code = "crm_error"; $s_error_mesg = GetMessage(MSG_CRM_FORM_ERROR); if (isset($a_data["USERERRORCODE"])) { $s_error_code .= $a_data["USERERRORCODE"]; } if (isset($a_data["USERERRORMESG"])) { $s_error_mesg = $a_data["USERERRORMESG"]; } UserError($s_error_code, $s_error_mesg); // no return break; } return true; }
function GetFormLink(&$s_url) { global $aGetVars, $sThisScript, $sQueryString; $s_url = $s_link = ""; if (isset($aGetVars) && isset($aGetVars["this_form"]) && isset($sThisScript) && !empty($sThisScript) && CheckValidURL($aGetVars["this_form"])) { // // Provide a link back to this script that provides // all the same information *and* sets bad_state=1 // see below for what happens.... // // We can only do this sensibly if the form has supplied // "this_form" and PHP is working within the webserver. // This probably won't work if PHP is being called as // a CGI script. // $b_quest = strpos($sThisScript, '?') !== false; $s_url = $sThisScript . ($b_quest ? "&" : "?") . "bad_state=1&{$sQueryString}"; $s_link = "<p>You can <a href=\"{$s_url}\">return to the form</a> to fix the errors.</p>"; } return $s_link; }
function SendToCRM($s_url, &$a_data) { if (!CheckValidURL($s_url)) { SendAlert("CRM URL '{$s_url}' is not valid (see TARGET_URLS in formmail.php)"); return false; } @($fp = fopen($s_url, "r")); if ($fp === false) { SendAlert("Failed to open CRM URL '{$s_url}'"); return false; } $s_mesg = ""; while (!feof($fp)) { $s_line = fgets($fp, 4096); $s_mesg .= $s_line; } fclose($fp); $s_mesg = StripHTML($s_mesg); $s_result = preg_match('/__OK__=(.*)/', $s_mesg, $a_matches); if (count($a_matches) < 2 || $a_matches[1] === "") { // // no agreed __OK__ value returned - assume system error // SendAlert("SendToCRM failed (url='{$s_url}'): '{$s_mesg}'"); return false; } // // look for fields to return // $a_data = FindCRMFields($s_mesg); // // check for success or user error // switch (strtolower($a_matches[1])) { case "true": break; case "false": // // user error // $s_error_code = "crm_error"; $s_error_mesg = "Your form submission was not accepted"; if (isset($a_data["USERERRORCODE"])) { $s_error_code .= $a_data["USERERRORCODE"]; } if (isset($a_data["USERERRORMESG"])) { $s_error_mesg = $a_data["USERERRORMESG"]; } UserError($s_error_code, $s_error_mesg, "", array()); // no return break; } return true; }