function errorCheck() { //check for error global $return, $data_contact, $url_curl, $userpwd, $content, $to_error, $headers, $modify, $url_contacts, $entityID; $status = 'default'; $status = get_string_between($return, 'status":"', '"'); $errorMessage = get_string_between($return, 'message":"', '"'); if ($status !== "ok") { if (begins_with($errorMessage, "A duplicate record has been found")) { $modify = 'True'; //if contacts table if ($url_curl == $url_contacts) { $entityID = filter_var($errorMessage, FILTER_SANITIZE_NUMBER_INT); } $url_curl = $url_curl . '/' . $entityID; sendData(); } else { //set email variables $subject = 'Error: Hobson Radius Form'; $message = 'There has been an error on the Hobson Radious Form Submission Status: ' . $status . ' ***Modify: ' . $modify . ' ***Error: ' . $errorMessage . ' ***url:' . $url_curl . ' ***entityID:' . $entityID . ' ***error return:' . $return . ' data send:' . print_r($data_contact, true); //send email mail($to_error, $subject, $message, $headers); } } }
function errorCheck() { /*check for error Hobson returns a string after form submission. We need to parse the string to determine the error. */ global $return, $data_contact, $url_curl, $userpwd, $content, $to_error, $headers, $modify, $url_contacts, $entityID; $status = 'default'; $status = get_string_between($return, 'status":"', '"'); $errorMessage = get_string_between($return, 'message":"', '"'); //if we are ok, then there is not error and we can move on. if ($status !== "ok") { if (begins_with($errorMessage, "A duplicate record has been found")) { //The record already exists in the database, prepare to resubmit using the Modify/Put Method. $modify = 'True'; //if contacts table if ($url_curl == $url_contacts) { $entityID = filter_var($errorMessage, FILTER_SANITIZE_NUMBER_INT); } $url_curl = $url_curl . '/' . $entityID; sendData(); } else { //prepare variables for email $subject = 'Error: Hobson Radius Form'; $message = 'There has been an error on the Hobson Radious Form Submission Status: ' . $status . ' ***Modify: ' . $modify . ' ***Error: ' . $errorMessage . ' ***url:' . $url_curl . ' ***entityID:' . $entityID . ' ***error return:' . $return . ' data send:' . print_r($data_contact, true); //send email mail($to_error, $subject, $message, $headers); } } //send email mail($to_error, $subject, $message, $headers); }
function longest_matching_prefix($str, $arr) { $len = strlen($str); while ($len > 0) { $prefix = substr($str, 0, $len); if (begins_with($prefix, $arr)) { return $prefix; } $len -= 1; } return ''; }
} $sesizare_descriere = trim($_POST['sesizare_descriere']); if (strlen($sesizare_descriere) < 1) { $error['sesizare_descriere'] = 'Obligatoriu.'; $submitOK = false; } $data_ora = trim($_POST['data_ora']); if (strlen($data_ora) < 1) { $error['data_ora'] = 'Obligatoriu.'; $submitOK = false; } //Sesizare Categorii $selected_categs = array(); foreach ($_POST as $key => $value) { //just checkboxes if (begins_with($key, 'cb')) { $selected_categs[] = $value; } } if (!count($selected_categs)) { $error['selected_categs'] = 'Cel putin o categorie.'; $submitOK = false; } //Sesizare Localizare Coordonate $coord_lon = floatval($_POST['coord_lon']); $coord_lat = floatval($_POST['coord_lat']); $location_search = filter_var($_POST['location_search'], FILTER_SANITIZE_STRING); //get location reverse geocode (via Google) $location_reverse = getReverseGeocode($coord_lat, $coord_lon); //Sesizare Linkuri Sursa $linkuri_sursa = $_POST['linkuri_sursa'];
/* spaghetti time, it's nice to analyze crappy apps, isn't it? */ if (isset($_GET['source']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) { highlight_file(__FILE__); die; } include_once 'config.php'; $title = ''; $content = ''; $page = @$_REQUEST['page']; switch ($page) { case 'print': $url = base64_decode($_REQUEST['url']); $title = ''; if (begins_with($url, $config['url'])) { $content = getContentFromUrl($url); } if (isset($_REQUEST['load_template']) && ($_REQUEST['load_template'] == '1' || $_REQUEST['load_template'] == true)) { $content = only_body($content); } break; case 'product': if (isset($_REQUEST['prod'])) { $title = htmlentities(ucfirst($prod), ENT_QUOTES); $content = getProduct($_REQUEST['prod']); } break; case 'contact': if (isset($_POST['url-bad'])) { if (isset($_POST["captcha"]) && $_POST["captcha"] != "" && $_SESSION["code"] == $_POST["captcha"]) {