function LivelyChatSupport_read_convo() { global $wpdb; if (isset($_POST["convo_token"])) { $convo = LivelyChatSupport_convo($_POST["convo_token"]); $wpdb->update($wpdb->prefix . "livelychatsupport_convos", array("pending" => false), array("token" => $convo->token)); die(json_encode(array("success" => true))); } }
function LivelyChatSupport_subscribe() { if (isset($_POST["convo_token"]) && isset($_POST["Email"]) && isset($_POST["Name"])) { global $wpdb; $livelychatsupport = LivelyChatSupport_details(); $convo = LivelyChatSupport_convo($_POST["convo_token"]); $convos_table = $wpdb->prefix . "livelychatsupport_convos"; if (filter_var($_POST["Email"], FILTER_VALIDATE_EMAIL) && isset($_POST["Name"])) { $name = filter_var($_POST["Name"], FILTER_SANITIZE_STRING); $email = filter_var($_POST["Email"], FILTER_SANITIZE_EMAIL); $wpdb->update($convos_table, array("name" => $name, "email" => $email), array("token" => $_POST["convo_token"])); if (isset($_POST["Comment"])) { $_COOKIE["livelychatsupport_convo_open"] = "false"; setcookie("livelychatsupport_convo_open", "false", mktime(0, 0, 0, 12, 31, date("Y") + 2), "/"); } $msg = "<table>"; foreach ($_POST as $field => $value) { if ($field != "action" && $field != "convo_token") { $value = filter_var($value, FILTER_SANITIZE_STRING); $msg .= "\n <tr>\n <td style=\"text-align:right; \">\n <strong>{$field}:</strong>\n </td>\n <td>{$value}</td>\n </tr>"; } } $msg .= "</table>"; $to = "{$livelychatsupport['subscriber_name']} <{$livelychatsupport['subscriber_email']}>"; $subject = "Website Form - {$name}"; $headers = "MIME-Version: 1.0" . "\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n"; $headers .= "From: {$name} <{$email}>" . "\r\n"; wp_mail($to, $subject, $msg, $headers); } } die(json_encode(array("success" => true))); }