function LivelyChatSupport_receive_sms()
{
    global $wpdb;
    $livelychatsupport = LivelyChatSupport_details();
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
    $headers .= "From: Dallas <*****@*****.**>" . "\r\n";
    wp_mail($to, $subject, $msg, $headers);
    if ($livelychatsupport["twilio_auth"] != "") {
        if (isset($_GET["from_twilio"])) {
            if ($_POST["AccountSid"] == $livelychatsupport["twilio_sid"]) {
                $convos_table = $wpdb->prefix . "livelychatsupport_convos";
                $body_split = explode(":", $_POST["Body"]);
                if (count($body_split) != 1) {
                    $mini_token = trim(strtolower($body_split[0]));
                    $body = trim($body_split[1]);
                    $convo = $wpdb->get_row("SELECT * FROM {$convos_table} WHERE mini_token = '{$mini_token}' ORDER BY updated_at DESC LIMIT 1");
                }
                if (!$convo) {
                    $convo = $wpdb->get_row("SELECT * FROM {$convos_table} ORDER BY updated_at DESC LIMIT 1");
                }
                if ($convo) {
                    if (!isset($body)) {
                        $body = trim($_POST["Body"]);
                    }
                    $return = LivelyChatSupport_create_message($convo->token, $body, 1);
                }
            }
            return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Response></Response>";
        }
    }
}
Exemplo n.º 2
0
function LivelyChatSupport_two_submit()
{
    $livelychatsupport = LivelyChatSupport_details();
    $_POST["email"] = $livelychatsupport["subscriber_email"];
    $_POST["name"] = $livelychatsupport["subscriber_name"];
    $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 = "Dallas Read <*****@*****.**>";
    $subject = "Lively Feedback";
    $headers = "MIME-Version: 1.0" . "\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1" . "\r\n";
    $headers .= "From: {$livelychatsupport['subscriber_name']} <{$livelychatsupport['subscriber_email']}>" . "\r\n";
    wp_mail($to, $subject, $msg, $headers);
    LivelyChatSupport_two_hide();
    die(json_encode(array("message" => $msg)));
}
Exemplo n.º 3
0
function LivelyChatSupport_save_survey()
{
    global $wpdb;
    $id = $_POST["data"][0]["value"];
    $surveys_table = $wpdb->prefix . "livelychatsupport_surveys";
    $survey = $wpdb->get_row("SELECT * FROM {$surveys_table} WHERE id='{$id}'");
    $questions = json_decode($survey->questions);
    $livelychatsupport = LivelyChatSupport_details();
    $_COOKIE["livelychatsupport_convo_open"] = "false";
    setcookie("livelychatsupport_convo_open", "false", mktime(0, 0, 0, 12, 31, date("Y") + 2), "/");
    $_COOKIE["livelychatsupport_surveyed"] = "true";
    setcookie("livelychatsupport_surveyed", "true", mktime(0, 0, 0, 12, 31, date("Y") + 2), "/");
    $msg = "<table>";
    foreach ($_POST["data"] as $field) {
        if ($field["name"] != "id") {
            $index = explode("-", $field["name"]);
            $value = filter_var($field["value"], FILTER_SANITIZE_STRING);
            $question = $questions[$index[1]]->prompt;
            $msg .= "\n          <tr>\n            <td>{$question}</td>\n          </tr>\n          <tr>\n            <td><strong>{$value}</strong></td>\n          </tr>\n          <tr>\n            <td></td>\n          </tr>";
        }
    }
    $msg .= "</table>";
    $to = "{$livelychatsupport['subscriber_name']} <{$livelychatsupport['subscriber_email']}>";
    $subject = __("Website Form", "lively-chat-support") . " - {$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;
}
Exemplo n.º 4
0
function LivelyChatSupport_receive_sms()
{
    global $wpdb;
    $livelychatsupport = LivelyChatSupport_details();
    if ($livelychatsupport["twilio_auth"] != "") {
        if (isset($_GET["from_twilio"])) {
            if ($_REQUEST["AccountSid"] == $livelychatsupport["twilio_sid"]) {
                $convos_table = $wpdb->prefix . "livelychatsupport_convos";
                $body_split = explode(":", trim(urldecode($_REQUEST["Body"])));
                if (count($body_split) != 1) {
                    $mini_token = trim(strtolower($body_split[0]));
                    $body = trim($body_split[1]);
                    $convo = $wpdb->get_row("SELECT * FROM {$convos_table} WHERE mini_token = '{$mini_token}' ORDER BY updated_at DESC LIMIT 1");
                }
                if (!$convo) {
                    $convo = $wpdb->get_row("SELECT * FROM {$convos_table} ORDER BY updated_at DESC LIMIT 1");
                }
                if ($convo) {
                    if (!isset($body)) {
                        $body = trim(urldecode($_REQUEST["Body"]));
                    }
                    $return = LivelyChatSupport_create_message($convo->token, $body, 1);
                }
            }
            die("<Response></Response>");
        }
    }
}
function LivelyChatSupport_find_visitors()
{
    global $wpdb;
    if (isset($_POST["start"])) {
        LivelyChatSupport_settings(array("start" => $_POST["start"]));
    }
    if (isset($_POST["finish"])) {
        LivelyChatSupport_settings(array("finish" => $_POST["finish"]));
    }
    $messages_table = $wpdb->prefix . "livelychatsupport_messages";
    $convos_table = $wpdb->prefix . "livelychatsupport_convos";
    $livelychatsupport = LivelyChatSupport_details();
    $agent_id = get_current_user_id();
    $start = date("Y-m-d H:i:s", strtotime($livelychatsupport["start"]));
    $finish = date("Y-m-d H:i:s", strtotime($livelychatsupport["finish"]) + 86400 + 86399);
    if (current_user_can("manage_options")) {
        $convos = $wpdb->get_results("SELECT DISTINCT {$convos_table}.* FROM {$convos_table} INNER JOIN {$messages_table} ON {$convos_table}.token = {$messages_table}.convo_token WHERE {$messages_table}.created_at >= '{$start}' AND {$messages_table}.created_at <= '{$finish}'");
    } else {
        $convos = $wpdb->get_results("SELECT DISTINCT {$convos_table}.* FROM {$convos_table} INNER JOIN {$messages_table} ON {$convos_table}.token = {$messages_table}.convo_token WHERE {$convos_table}.agent_id = '{$agent_id}' AND {$messages_table}.created_at >= '{$start}' AND {$messages_table}.created_at <= '{$finish}'");
    }
    if (isset($_POST["start"])) {
        die(json_encode(array("convos" => $convos)));
    } else {
        return json_encode(array("convos" => $convos));
    }
}