function unsubscribe($param) { global $sender; $html_email = htmlentities($param["em"]); $info = get_sub_info($param["em"], true); if (isset($info["status"]) && $info["status"] == "unsubscribed") { $html = <<<EOD <div class="alert alert-warning"> <strong>{$html_email}</strong> is already removed from the email subscription list. </div> EOD; echo $html; return false; } if (!$info) { form($param, "Sorry, <strong>{$html_email}</strong> is\nnot currently subscribed."); } if (sql_unsub($param["em"]) === false) { $html = <<<EOD <div class="alert alert-danger"> <h4>Database Error</h4> Sorry, a database error occurred on our servers. Please try again later. </div> EOD; echo $html; return false; } $html = <<<EOD <div class="alert alert-success"> <h4>Unsubscribed</h4> <strong>{$html_email}</strong> has been removed from the email subscription list. </div> EOD; echo $html; return true; }
$val = array("id" => $id, "status" => $status, "em" => $address, "m" => $havdalah, "upd" => $optin_announce, "zip" => $zip, "city" => $city, "geonameid" => $geonameid, "t" => $created); mysqli_free_result($result); return $val; } header("Cache-Control: private"); $param = array(); foreach ($_REQUEST as $key => $value) { $param[$key] = trim($value); } if (isset($param["k"])) { if (!preg_match('/^[0-9a-f]{24}$/', $param["k"])) { bad_request("Invalid confirmation key"); } $info = get_sub_info($param["k"]); } elseif (isset($_SERVER["QUERY_STRING"]) && preg_match('/^[0-9a-f]{24}$/', $_SERVER["QUERY_STRING"])) { $info = get_sub_info($_SERVER["QUERY_STRING"]); } else { bad_request("No confirmation key"); exit(0); } if (!isset($info["em"])) { header("HTTP/1.0 404 Not Found"); echo "Can't find {$_SERVER['QUERY_STRING']} in DB"; exit(0); } if (isset($param["commit"]) && $param["commit"] == "1") { $ip = $_SERVER["REMOTE_ADDR"]; $sql = <<<EOD UPDATE hebcal_shabbat_email SET email_status='active', email_ip='{$ip}'