function LivelyChatSupport_set_cookies() { if (!isset($_COOKIE["livelychatsupport_convo_open"])) { $_COOKIE["livelychatsupport_convo_open"] = "false"; setcookie("livelychatsupport_convo_open", $_COOKIE["livelychatsupport_convo_open"], mktime(0, 0, 0, 12, 31, date("Y") + 2), "/"); } if (!isset($_COOKIE["livelychatsupport_convo_token"]) || $_COOKIE["livelychatsupport_convo_token"] == "") { $_COOKIE["livelychatsupport_convo_token"] = md5(uniqid(rand(), true)); setcookie("livelychatsupport_convo_token", $_COOKIE["livelychatsupport_convo_token"], mktime(0, 0, 0, 12, 31, date("Y") + 2), "/"); } if (isset($_REQUEST["from_twilio"])) { LivelyChatSupport_receive_sms(); } }
function LivelyChatSupport_frontend_footer() { global $wpdb; $convos_table = $wpdb->prefix . "livelychatsupport_convos"; LivelyChatSupport_set_cookies(); if (isset($_GET["from_twilio"])) { LivelyChatSupport_receive_sms(); } wp_register_style("LivelyChatSupport-chatbox-reset", plugins_url("lively-chat-support/chatbox/css/reset.css")); wp_register_style("LivelyChatSupport-chatbox-style", plugins_url("lively-chat-support/chatbox/css/style.css")); wp_register_script("LivelyChatSupport-chatbox-script", plugins_url("lively-chat-support/chatbox/js/chatbox.js")); wp_enqueue_style(array("LivelyChatSupport-chatbox-reset", "LivelyChatSupport-chatbox-style", "LivelyChatSupport-chatbox-colours")); wp_enqueue_script(array("jquery", "LivelyChatSupport-chatbox-script")); $livelychatsupport = LivelyChatSupport_details(); $convo = LivelyChatSupport_convo($_COOKIE["livelychatsupport_convo_token"]); $agent = LivelyChatSupport_agent(); if (!$agent) { $livelychatsupport_offline = true; } else { } if (isset($_COOKIE["livelychatsupport_convo_open"]) && $_COOKIE["livelychatsupport_convo_open"] == "true" || LIVELYCHATSUPPORT_ADMIN == true) { $livelychatsupport_open = true; } if ($livelychatsupport["online"] == "offline") { $livelychatsupport_offline = true; } else { if ($livelychatsupport["online"] == "hours") { $hour = LivelyChatSupport_hour(); if (!$hour) { $livelychatsupport_offline = true; } } } if (LIVELYCHATSUPPORT_ADMIN == false && isset($_COOKIE["livelychatsupport_convo_token"])) { if ($convo) { $referrers = json_decode($convo->referrers); } if (!is_array($referrers) || !isset($referrers)) { $referrers = array(); } $referrers = array_push($referrers, "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); if ($convo) { $wpdb->update($convos_table, array("referrers" => json_encode($referrers), "updated_at" => date("Y-m-d H:i:s", current_time("timestamp")), "last_seen" => date("Y-m-d H:i:s", current_time("timestamp"))), array("token" => $_COOKIE["livelychatsupport_convo_token"])); } else { if (!is_admin()) { $convo = LivelyChatSupport_create_visitor($referrers); } } if (LivelyChatSupport_is_visible_for_current_page()) { include_once LIVELYCHATSUPPORT_ROOT . "/chatbox/includes/structure.php"; } } }