WP Live Chat Support - Version 4.1.1

Version Description

It is highly recommended that you upgrade to version 4.1.1

=

Download this release

Release Info

Developer WP-LiveChat
Plugin Icon 128x128 WP Live Chat Support
Version 4.1.1
Comparing to
See all releases

Code changes from version 4.1.0 to 4.1.1

ajax.php CHANGED
@@ -6,7 +6,7 @@ header('Access-Control-Max-Age: 604800');
6
  header('Access-Control-Allow-Headers: x-requested-with');
7
 
8
  ini_set('html_errors', 0);
9
- define('SHORTINIT', true);
10
 
11
 
12
  //$absolute_path = __FILE__;
@@ -26,6 +26,12 @@ require_once( '../../../wp-load.php' );
26
 
27
  define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
28
 
 
 
 
 
 
 
29
 
30
 
31
 
@@ -42,7 +48,7 @@ require_once( ABSPATH . WPINC . '/kses.php' );
42
  $plugin_dir = basename(dirname(__FILE__))."/languages/";
43
  load_plugin_textdomain( 'wplivechat', false, $plugin_dir );
44
 
45
-
46
 
47
 
48
  global $wpdb;
@@ -65,13 +71,15 @@ require_once("functions.php");
65
  // stuff goes here
66
 
67
 
 
 
68
 
69
  $check = 1;
70
 
71
  if ($check == 1) {
72
 
73
  if($_POST['action'] == 'wplc_admin_long_poll'){
74
- set_time_limit(120);
75
  //sleep(6);
76
  $i = 1;
77
  while($i <= 28){
@@ -106,12 +114,12 @@ if ($check == 1) {
106
  echo json_encode($array);
107
  break;
108
  }
109
- sleep(1);
110
  $i++;
111
  }
112
  }
113
  if($_POST['action'] == "wplc_admin_long_poll_chat"){
114
- set_time_limit(120);
115
  $i = 1;
116
  $array = array();
117
  while($i <= 28){
@@ -137,7 +145,7 @@ if ($check == 1) {
137
  echo json_encode($array);
138
  break;
139
  }
140
- sleep(1);
141
  $i++;
142
  }
143
  }
@@ -166,16 +174,16 @@ if ($check == 1) {
166
  //User Ajax
167
 
168
  if($_POST['action'] == 'wplc_call_to_server_visitor'){
169
- set_time_limit(120);
170
  $i = 1;
171
  $array = array("check" => false);
172
 
173
  while($i <= 28){
174
 
175
- if($_POST['cid'] == null){
176
  $user = "user".time();
177
  $email = "no email set";
178
- $cid = wplc_log_user_on_page($user,$email);
179
  $array['cid'] = $cid;
180
  $array['status'] = wplc_return_chat_status($cid);
181
  $array['wplc_name'] = $user;
@@ -189,10 +197,28 @@ if ($check == 1) {
189
  $array['cid'] = $_POST['cid'];
190
  if($new_status == $_POST['status']){ // if status matches do the following
191
  if($_POST['status'] != 2){
192
- wplc_update_user_on_page($_POST['cid'], $_POST['status']);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
193
  }
194
  if ($_POST['status'] == 0){ // browsing - user tried to chat but admin didn't answer so turn back to browsing
195
- wplc_update_user_on_page($_POST['cid'], 5);
196
  $array['status'] = 5;
197
  $array['check'] = true;
198
  } else if($_POST['status'] == 3){
@@ -209,7 +235,7 @@ if ($check == 1) {
209
  } else { // statuses do not match
210
  $array['status'] = $new_status;
211
  if($new_status == 1){ // completed
212
- wplc_update_user_on_page($_POST['cid'], 8);
213
  $array['check'] = true;
214
  $array['status'] = 8;
215
  $array['data'] = __("Admin has closed and ended the chat","wplivechat");
@@ -230,7 +256,7 @@ if ($check == 1) {
230
  }
231
  }
232
  else if($new_status == 7){ // timed out
233
- wplc_update_user_on_page($_POST['cid'], 5);
234
  }
235
  else if($new_status == 9){ // user closed chat without inputting or starting a chat
236
  $array['check'] = true;
@@ -255,7 +281,7 @@ if ($check == 1) {
255
  echo json_encode($array);
256
  break;
257
  }
258
- sleep(1);
259
  $i++;
260
  }
261
  }
@@ -291,13 +317,13 @@ if ($check == 1) {
291
  if ($_POST['action'] == "wplc_start_chat") {
292
  if (isset($_POST['cid'])) {
293
  if ($_POST['name'] && $_POST['email']) {
294
- echo wplc_user_initiate_chat(sanitize_text_field($_POST['name']),sanitize_email($_POST['email']),sanitize_text_field($_POST['cid'])); // echo the chat session id
295
  } else {
296
  echo "error2";
297
  }
298
  } else {
299
  if ($_POST['name'] && $_POST['email']) {
300
- echo wplc_user_initiate_chat(sanitize_text_field($_POST['name']),sanitize_email($_POST['email'])); // echo the chat session id
301
  } else {
302
  echo "error2";
303
  }
@@ -305,3 +331,4 @@ if ($check == 1) {
305
  }
306
  }
307
 
 
6
  header('Access-Control-Allow-Headers: x-requested-with');
7
 
8
  ini_set('html_errors', 0);
9
+ define('SHORTINIT', true);
10
 
11
 
12
  //$absolute_path = __FILE__;
26
 
27
  define( 'WP_PLUGIN_DIR', WP_CONTENT_DIR . '/plugins' ); // full path, no trailing slash
28
 
29
+ /* time in seconds between updating the user on the page within the DB (lower number = higher resource usage) */
30
+ define('WPLC_DELAY_BETWEEN_UPDATES',3);
31
+ /* time in seconds between long poll loop (lower number = higher resource usage) */
32
+ define('WPLC_DELAY_BETWEEN_LOOPS',1);
33
+ /* this needs to take into account the previous constants so that we dont run out of time, which in turn returns a 503 error */
34
+ define('WPLC_TIMEOUT',((WPLC_DELAY_BETWEEN_UPDATES + WPLC_DELAY_BETWEEN_LOOPS + 30))*28);
35
 
36
 
37
 
48
  $plugin_dir = basename(dirname(__FILE__))."/languages/";
49
  load_plugin_textdomain( 'wplivechat', false, $plugin_dir );
50
 
51
+
52
 
53
 
54
  global $wpdb;
71
  // stuff goes here
72
 
73
 
74
+ /* we're using PHP 'sleep' which may lock other requests until our script wakes up. Call this function to ensure that other requests can run without waiting for us to finish */
75
+ session_write_close();
76
 
77
  $check = 1;
78
 
79
  if ($check == 1) {
80
 
81
  if($_POST['action'] == 'wplc_admin_long_poll'){
82
+ if (defined('WPLC_TIMEOUT')) { set_time_limit(WPLC_TIMEOUT); } else { set_time_limit(120); }
83
  //sleep(6);
84
  $i = 1;
85
  while($i <= 28){
114
  echo json_encode($array);
115
  break;
116
  }
117
+ if (defined('WPLC_DELAY_BETWEEN_LOOPS')) { sleep(WPLC_DELAY_BETWEEN_LOOPS); } else { sleep(1); }
118
  $i++;
119
  }
120
  }
121
  if($_POST['action'] == "wplc_admin_long_poll_chat"){
122
+ if (defined('WPLC_TIMEOUT')) { set_time_limit(WPLC_TIMEOUT); } else { set_time_limit(120); }
123
  $i = 1;
124
  $array = array();
125
  while($i <= 28){
145
  echo json_encode($array);
146
  break;
147
  }
148
+ if (defined('WPLC_DELAY_BETWEEN_LOOPS')) { sleep(WPLC_DELAY_BETWEEN_LOOPS); } else { sleep(1); }
149
  $i++;
150
  }
151
  }
174
  //User Ajax
175
 
176
  if($_POST['action'] == 'wplc_call_to_server_visitor'){
177
+ if (defined('WPLC_TIMEOUT')) { set_time_limit(WPLC_TIMEOUT); } else { set_time_limit(120); }
178
  $i = 1;
179
  $array = array("check" => false);
180
 
181
  while($i <= 28){
182
 
183
+ if($_POST['cid'] == null || $_POST['cid'] == "" || $_POST['cid'] == "null"){
184
  $user = "user".time();
185
  $email = "no email set";
186
+ $cid = wplc_log_user_on_page($user,$email,$_POST['wplcsession']);
187
  $array['cid'] = $cid;
188
  $array['status'] = wplc_return_chat_status($cid);
189
  $array['wplc_name'] = $user;
197
  $array['cid'] = $_POST['cid'];
198
  if($new_status == $_POST['status']){ // if status matches do the following
199
  if($_POST['status'] != 2){
200
+ //wplc_error_log("[".$_POST['wplcsession']."] [".__LINE__."] [*$i] Updating user on page ".$_SERVER['HTTP_REFERER']);
201
+
202
+ /* check if session_variable is different? if yes then stop this script completely. */
203
+ if (isset($_POST['wplcsession']) && $_POST['wplcsession'] != '' && $i > 1) {
204
+ $wplc_session_variable = $_POST['wplcsession'];
205
+ $current_session_variable = wplc_return_chat_session_variable($_POST['cid']);
206
+ //wplc_error_log("[".$_POST['wplcsession']."] [".__LINE__."] Checking against session variable ".$current_session_variable);
207
+ if ($current_session_variable != "" && $current_session_variable != $wplc_session_variable) {
208
+ /* stop this script */
209
+ //wplc_error_log("[".$_POST['wplcsession']."] [".__LINE__."] [*$i] TERMINATING");
210
+ $array['status'] = 11;
211
+ echo json_encode($array);
212
+ die();
213
+ }
214
+ }
215
+
216
+
217
+ wplc_update_user_on_page($_POST['cid'], $_POST['status'],$_POST['wplcsession']);
218
+ if (defined('WPLC_DELAY_BETWEEN_UPDATES')) { sleep(WPLC_DELAY_BETWEEN_UPDATES); } else { sleep(3); }
219
  }
220
  if ($_POST['status'] == 0){ // browsing - user tried to chat but admin didn't answer so turn back to browsing
221
+ wplc_update_user_on_page($_POST['cid'], 5,$_POST['wplcsession']);
222
  $array['status'] = 5;
223
  $array['check'] = true;
224
  } else if($_POST['status'] == 3){
235
  } else { // statuses do not match
236
  $array['status'] = $new_status;
237
  if($new_status == 1){ // completed
238
+ wplc_update_user_on_page($_POST['cid'], 8,$_POST['wplcsession']);
239
  $array['check'] = true;
240
  $array['status'] = 8;
241
  $array['data'] = __("Admin has closed and ended the chat","wplivechat");
256
  }
257
  }
258
  else if($new_status == 7){ // timed out
259
+ wplc_update_user_on_page($_POST['cid'], 5,$_POST['wplcsession']);
260
  }
261
  else if($new_status == 9){ // user closed chat without inputting or starting a chat
262
  $array['check'] = true;
281
  echo json_encode($array);
282
  break;
283
  }
284
+ if (defined('WPLC_DELAY_BETWEEN_LOOPS')) { sleep(WPLC_DELAY_BETWEEN_LOOPS); } else { sleep(1); }
285
  $i++;
286
  }
287
  }
317
  if ($_POST['action'] == "wplc_start_chat") {
318
  if (isset($_POST['cid'])) {
319
  if ($_POST['name'] && $_POST['email']) {
320
+ echo wplc_user_initiate_chat(sanitize_text_field($_POST['name']),sanitize_email($_POST['email']),sanitize_text_field($_POST['cid']),$_POST['wplcsession']); // echo the chat session id
321
  } else {
322
  echo "error2";
323
  }
324
  } else {
325
  if ($_POST['name'] && $_POST['email']) {
326
+ echo wplc_user_initiate_chat(sanitize_text_field($_POST['name']),sanitize_email($_POST['email']),null,$_POST['wplcsession']); // echo the chat session id
327
  } else {
328
  echo "error2";
329
  }
331
  }
332
  }
333
 
334
+ die();
functions.php CHANGED
@@ -1,15 +1,23 @@
1
  <?php
2
-
3
- function wplc_log_user_on_page($name,$email) {
4
  global $wpdb;
5
  global $wplc_tblname_chats;
6
 
 
 
 
 
 
 
 
7
  $ins_array = array(
8
  'status' => '5',
9
  'timestamp' => date("Y-m-d H:i:s"),
10
  'name' => $name,
11
  'email' => $email,
12
- 'ip' => $_SERVER['REMOTE_ADDR'],
 
13
  'url' => $_SERVER['HTTP_REFERER'],
14
  'last_active_timestamp' => date("Y-m-d H:i:s")
15
  );
@@ -22,18 +30,26 @@ function wplc_log_user_on_page($name,$email) {
22
  return $lastid;
23
 
24
  }
25
- function wplc_update_user_on_page($cid, $status = 5) {
26
  global $wpdb;
27
  global $wplc_tblname_chats;
28
 
 
 
 
 
 
 
 
29
  $query =
30
  "
31
  UPDATE $wplc_tblname_chats
32
  SET
33
  `url` = '".$_SERVER['HTTP_REFERER']."',
34
  `last_active_timestamp` = '".date("Y-m-d H:i:s")."',
35
- `ip` = '".$_SERVER['REMOTE_ADDR']."',
36
- `status` = '$status'
 
37
 
38
  WHERE `id` = '$cid'
39
  LIMIT 1
@@ -142,12 +158,12 @@ function wplc_list_chats() {
142
  $table = "<table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">"
143
  . "<thead>"
144
  . "<tr>"
145
- . "<th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><span>".__("IP","wplivechat")."</span></th>"
146
- . "<th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><span>".__("Name","wplivechat")."</span></th>"
147
- . "<th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\">".__("Email","wplivechat")."</th>"
148
- . "<th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\">".__("URL","wplivechat")."</th>"
149
- . "<th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\">".__("Status","wplivechat")."</th>"
150
- . "<th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><span>".__("Action","wplivechat")."</span></th>"
151
  . "</tr>"
152
  . "</thead>"
153
  . "<tbody id=\"the-list\" class='list:wp_list_text_link'>";
@@ -162,19 +178,26 @@ function wplc_list_chats() {
162
  unset($actions);
163
  $wplc_c++;
164
 
 
 
 
 
 
 
 
165
  if ($result->status == 2) {
166
  $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
167
- $actions = "<a href=\"".$url."\" class=\"wplc_open_chat\" window-title=\"WP_Live_Chat_".$result->id."\">Accept Chat</a>";
168
  $trstyle = "style='background-color:#FFFBE4; height:30px;'";
169
  }
170
  if ($result->status == 3) {
171
  $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
172
- $actions = "<a href=\"".$url."\" class=\"wplc_open_chat\" window-title=\"WP_Live_Chat_".$result->id."\">Open Chat Window</a>";
173
  $trstyle = "style='background-color:#F7FCFE; height:30px;'";
174
  }
175
  if ($wplc_c>1) { $actions = wplc_get_msg(); }
176
  $table .= "<tr id=\"record_".$result->id."\" $trstyle>"
177
- . "<td class='chat_id column-chat_d'>".$result->ip."</td>"
178
  . "<td class='chat_name column_chat_name' id='chat_name_".$result->id."'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."?s=40\" /> ".$result->name."</td>"
179
  . "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>"
180
  . "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>"
@@ -370,6 +393,21 @@ function wplc_mark_as_read_admin_chat_messages($mid) {
370
 
371
 
372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
 
374
 
375
  function wplc_return_chat_status($cid) {
@@ -416,7 +454,7 @@ function wplc_return_status($status) {
416
 
417
  }
418
 
419
- function wplc_user_initiate_chat($name,$email,$cid = null) {
420
  global $wpdb;
421
  global $wplc_tblname_chats;
422
 
@@ -425,6 +463,12 @@ function wplc_user_initiate_chat($name,$email,$cid = null) {
425
  }
426
 
427
  if ($cid != null) { /* change from a visitor to a chat */
 
 
 
 
 
 
428
  $query =
429
  "
430
  UPDATE $wplc_tblname_chats
@@ -433,7 +477,8 @@ function wplc_user_initiate_chat($name,$email,$cid = null) {
433
  `timestamp` = '".date("Y-m-d H:i:s")."',
434
  `name` = '$name',
435
  `email` = '$email',
436
- `ip` = '".$_SERVER['REMOTE_ADDR']."',
 
437
  `url` = '".$_SERVER['HTTP_REFERER']."',
438
  `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
439
 
@@ -444,12 +489,17 @@ function wplc_user_initiate_chat($name,$email,$cid = null) {
444
  return $cid;
445
  }
446
  else { // create new ID for the chat
 
 
 
 
447
  $ins_array = array(
448
  'status' => '2',
449
  'timestamp' => date("Y-m-d H:i:s"),
450
  'name' => $name,
451
  'email' => $email,
452
- 'ip' => $_SERVER['REMOTE_ADDR'],
 
453
  'url' => $_SERVER['HTTP_REFERER'],
454
  'last_active_timestamp' => date("Y-m-d H:i:s")
455
  );
@@ -536,4 +586,133 @@ function wplc_convert_array_to_string($array){
536
  $string = false;
537
  }
538
  return $string;
539
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ $wplc_basic_plugin_url = get_option('siteurl')."/wp-content/plugins/wp-live-chat-support/";
3
+ function wplc_log_user_on_page($name,$email,$session) {
4
  global $wpdb;
5
  global $wplc_tblname_chats;
6
 
7
+
8
+ $user_data = array(
9
+ 'ip' => $_SERVER['REMOTE_ADDR'],
10
+ 'user_agent' => $_SERVER['HTTP_USER_AGENT']
11
+ );
12
+
13
+
14
  $ins_array = array(
15
  'status' => '5',
16
  'timestamp' => date("Y-m-d H:i:s"),
17
  'name' => $name,
18
  'email' => $email,
19
+ 'session' => $session,
20
+ 'ip' => maybe_serialize($user_data),
21
  'url' => $_SERVER['HTTP_REFERER'],
22
  'last_active_timestamp' => date("Y-m-d H:i:s")
23
  );
30
  return $lastid;
31
 
32
  }
33
+ function wplc_update_user_on_page($cid, $status = 5,$session) {
34
  global $wpdb;
35
  global $wplc_tblname_chats;
36
 
37
+
38
+
39
+ $user_data = array(
40
+ 'ip' => $_SERVER['REMOTE_ADDR'],
41
+ 'user_agent' => $_SERVER['HTTP_USER_AGENT']
42
+ );
43
+
44
  $query =
45
  "
46
  UPDATE $wplc_tblname_chats
47
  SET
48
  `url` = '".$_SERVER['HTTP_REFERER']."',
49
  `last_active_timestamp` = '".date("Y-m-d H:i:s")."',
50
+ `ip` = '".maybe_serialize($user_data)."',
51
+ `status` = '$status',
52
+ `session` = '$session'
53
 
54
  WHERE `id` = '$cid'
55
  LIMIT 1
158
  $table = "<table class=\"wp-list-table widefat fixed \" cellspacing=\"0\">"
159
  . "<thead>"
160
  . "<tr>"
161
+ . "<th scope='col' id='wplc_id_colum' class='manage-column column-id sortable desc' style=''><i class=\"fa fa-globe\"> </i> <span>".__("User Data","wplivechat")."</span></th>"
162
+ . "<th scope='col' id='wplc_name_colum' class='manage-column column-name_title sortable desc' style=''><i class=\"fa fa-user\"> </i> <span>".__("Name","wplivechat")."</span></th>"
163
+ . "<th scope='col' id='wplc_email_colum' class='manage-column column-email' style=\"\"><i class=\"fa fa-envelope\"> </i> ".__("Email","wplivechat")."</th>"
164
+ . "<th scope='col' id='wplc_url_colum' class='manage-column column-url' style=\"\"><i class=\"fa fa-link\"> </i> ".__("URL","wplivechat")."</th>"
165
+ . "<th scope='col' id='wplc_status_colum' class='manage-column column-status' style=\"\"><i class=\"fa fa-cog\"> </i> ".__("Status","wplivechat")."</th>"
166
+ . "<th scope='col' id='wplc_action_colum' class='manage-column column-action sortable desc' style=\"\"><i class=\"fa fa-rocket\"> </i> <span>".__("Action","wplivechat")."</span></th>"
167
  . "</tr>"
168
  . "</thead>"
169
  . "<tbody id=\"the-list\" class='list:wp_list_text_link'>";
178
  unset($actions);
179
  $wplc_c++;
180
 
181
+
182
+ global $wplc_basic_plugin_url;
183
+ $user_data = maybe_unserialize($result->ip);
184
+ $user_ip = $user_data['ip'];
185
+ $browser = wplc_return_browser_string($user_data['user_agent']);
186
+ $browser_image = wplc_return_browser_image($browser,"16");
187
+
188
  if ($result->status == 2) {
189
  $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
190
+ $actions = "<a href=\"".$url."\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_".$result->id."\">".__("Accept Chat","wplivechat")."</a>";
191
  $trstyle = "style='background-color:#FFFBE4; height:30px;'";
192
  }
193
  if ($result->status == 3) {
194
  $url = admin_url( 'admin.php?page=wplivechat-menu&action=ac&cid='.$result->id);
195
+ $actions = "<a href=\"".$url."\" class=\"wplc_open_chat button button-primary\" window-title=\"WP_Live_Chat_".$result->id."\">".__("Open Chat Window","wplivechat")."</a>";
196
  $trstyle = "style='background-color:#F7FCFE; height:30px;'";
197
  }
198
  if ($wplc_c>1) { $actions = wplc_get_msg(); }
199
  $table .= "<tr id=\"record_".$result->id."\" $trstyle>"
200
+ . "<td class='chat_id column-chat_d'><img src='".$wplc_basic_plugin_url."/images/$browser_image' alt='$browser' title='$browser' /> ".$user_ip."</td>"
201
  . "<td class='chat_name column_chat_name' id='chat_name_".$result->id."'><img src=\"http://www.gravatar.com/avatar/".md5($result->email)."?s=40\" /> ".$result->name."</td>"
202
  . "<td class='chat_email column_chat_email' id='chat_email_".$result->id."'>".$result->email."</td>"
203
  . "<td class='chat_name column_chat_url' id='chat_url_".$result->id."'>".$result->url."</td>"
393
 
394
 
395
 
396
+ function wplc_return_chat_session_variable($cid) {
397
+ global $wpdb;
398
+ global $wplc_tblname_chats;
399
+ $results = $wpdb->get_results(
400
+ "
401
+ SELECT *
402
+ FROM $wplc_tblname_chats
403
+ WHERE `id` = '$cid'
404
+ "
405
+ );
406
+ foreach ($results as $result) {
407
+ return $result->session;
408
+ }
409
+ }
410
+
411
 
412
 
413
  function wplc_return_chat_status($cid) {
454
 
455
  }
456
 
457
+ function wplc_user_initiate_chat($name,$email,$cid = null,$session) {
458
  global $wpdb;
459
  global $wplc_tblname_chats;
460
 
463
  }
464
 
465
  if ($cid != null) { /* change from a visitor to a chat */
466
+
467
+ $user_data = array(
468
+ 'ip' => $_SERVER['REMOTE_ADDR'],
469
+ 'user_agent' => $_SERVER['HTTP_USER_AGENT']
470
+ );
471
+
472
  $query =
473
  "
474
  UPDATE $wplc_tblname_chats
477
  `timestamp` = '".date("Y-m-d H:i:s")."',
478
  `name` = '$name',
479
  `email` = '$email',
480
+ `session` = '$session',
481
+ `ip` = '".maybe_serialize($user_data)."',
482
  `url` = '".$_SERVER['HTTP_REFERER']."',
483
  `last_active_timestamp` = '".date("Y-m-d H:i:s")."'
484
 
489
  return $cid;
490
  }
491
  else { // create new ID for the chat
492
+ $user_data = array(
493
+ 'ip' => $_SERVER['REMOTE_ADDR'],
494
+ 'user_agent' => $_SERVER['HTTP_USER_AGENT']
495
+ );
496
  $ins_array = array(
497
  'status' => '2',
498
  'timestamp' => date("Y-m-d H:i:s"),
499
  'name' => $name,
500
  'email' => $email,
501
+ 'session' => $session,
502
+ 'ip' => maybe_serialize($user_data),
503
  'url' => $_SERVER['HTTP_REFERER'],
504
  'last_active_timestamp' => date("Y-m-d H:i:s")
505
  );
586
  $string = false;
587
  }
588
  return $string;
589
+ }
590
+
591
+ function wplc_return_browser_image($string,$size) {
592
+ switch($string) {
593
+
594
+ case "Internet Explorer":
595
+ return "web_".$size."x".$size.".png";
596
+ break;
597
+ case "Mozilla Firefox":
598
+ return "firefox_".$size."x".$size.".png";
599
+ break;
600
+ case "Opera":
601
+ return "opera_".$size."x".$size.".png";
602
+ break;
603
+ case "Google Chrome":
604
+ return "chrome_".$size."x".$size.".png";
605
+ break;
606
+ case "Safari":
607
+ return "safari_".$size."x".$size.".png";
608
+ break;
609
+ case "Other browser":
610
+ return "web_".$size."x".$size.".png";
611
+ break;
612
+ default:
613
+ return "web_".$size."x".$size.".png";
614
+ break;
615
+ }
616
+
617
+
618
+ }
619
+ function wplc_return_browser_string($user_agent) {
620
+ if(strpos($user_agent, 'MSIE') !== FALSE)
621
+ return 'Internet explorer';
622
+ elseif(strpos($user_agent, 'Trident') !== FALSE) //For Supporting IE 11
623
+ return 'Internet explorer';
624
+ elseif(strpos($user_agent, 'Firefox') !== FALSE)
625
+ return 'Mozilla Firefox';
626
+ elseif(strpos($user_agent, 'Chrome') !== FALSE)
627
+ return 'Google Chrome';
628
+ elseif(strpos($user_agent, 'Opera Mini') !== FALSE)
629
+ return "Opera";
630
+ elseif(strpos($user_agent, 'Opera') !== FALSE)
631
+ return "Opera";
632
+ elseif(strpos($user_agent, 'Safari') !== FALSE)
633
+ return "Safari";
634
+ else
635
+ return 'Other browser';
636
+ }
637
+
638
+ function wplc_error_directory() {
639
+ $upload_dir = wp_upload_dir();
640
+
641
+ if (is_multisite()) {
642
+ if (!file_exists($upload_dir['basedir'].'/wp-live-chat-support')) {
643
+ wp_mkdir_p($upload_dir['basedir'].'/wp-live-chat-support');
644
+ $content = "Error log created";
645
+ $fp = @fopen($upload_dir['basedir'].'/wp-live-chat-support'."/error_log.txt","w+");
646
+ fwrite($fp,$content);
647
+ }
648
+ } else {
649
+ if (!file_exists(ABSPATH.'wp-content/uploads/wp-live-chat-support')) {
650
+ wp_mkdir_p(ABSPATH.'wp-content/uploads/wp-live-chat-support');
651
+ $content = "Error log created";
652
+ $fp = @fopen(ABSPATH.'wp-content/uploads/wp-live-chat-support'."/error_log.txt","w+");
653
+ fwrite($fp,$content);
654
+ }
655
+
656
+ }
657
+ return true;
658
+
659
+ }
660
+
661
+ function wplc_error_log($error) {
662
+ $content = "\r\n[".date("Y-m-d")."] [".date("H:i:s")."]".$error;
663
+ $fp = @fopen(ABSPATH.'/wp-content/uploads/wp-live-chat-support'."/error_log.txt","a+");
664
+ fwrite($fp,$content);
665
+ fclose($fp);
666
+
667
+
668
+ }
669
+ function Memory_Usage($decimals = 2)
670
+ {
671
+ $result = 0;
672
+
673
+ if (function_exists('memory_get_usage'))
674
+ {
675
+ $result = memory_get_usage() / 1024;
676
+ }
677
+
678
+ else
679
+ {
680
+ if (function_exists('exec'))
681
+ {
682
+ $output = array();
683
+
684
+ if (substr(strtoupper(PHP_OS), 0, 3) == 'WIN')
685
+ {
686
+ exec('tasklist /FI "PID eq ' . getmypid() . '" /FO LIST', $output);
687
+
688
+ $result = preg_replace('/[\D]/', '', $output[5]);
689
+ }
690
+
691
+ else
692
+ {
693
+ exec('ps -eo%mem,rss,pid | grep ' . getmypid(), $output);
694
+
695
+ $output = explode(' ', $output[0]);
696
+
697
+ $result = $output[1];
698
+ }
699
+ }
700
+ }
701
+
702
+ return number_format(intval($result) / 1024, $decimals, '.', '')." mb";
703
+ }
704
+ function wplc_get_memory_usage() {
705
+ $size = memory_get_usage(true);
706
+ $unit=array('b','kb','mb','gb','tb','pb');
707
+ return @round($size/pow(1024,($i=floor(log($size,1024)))),2).' '.$unit[$i];
708
+
709
+ }
710
+ function wplc_record_mem() {
711
+ $data = array(
712
+ 'date' => date('Y-m-d H:i:s'),
713
+ 'php_mem' => wplc_get_memory_usage()
714
+ );
715
+ $fp = @fopen(ABSPATH.'/wp-content/uploads/wp-live-chat-support'."/mem_usag.csv","a+");
716
+ fputcsv($fp, $data);
717
+ fclose($fp);
718
+ }
images/chrome_16x16.png ADDED
Binary file
images/chrome_32x32.png ADDED
Binary file
images/firefox_16x16.png ADDED
Binary file
images/firefox_32x32.png ADDED
Binary file
images/internet-explorer_16x16.png ADDED
Binary file
images/internet-explorer_32x32.png ADDED
Binary file
images/opera_16x16.png ADDED
Binary file
images/opera_32x32.png ADDED
Binary file
images/safari_16x16.png ADDED
Binary file
images/safari_32x32.png ADDED
Binary file
images/web_16x16.png ADDED
Binary file
images/web_32x32.png ADDED
Binary file
js/wplc_u.js CHANGED
@@ -11,12 +11,13 @@
11
  * 8 - complete but now browsing again
12
  * 9 - user closed chat before starting chat
13
  * 10 - user minimized active chat
 
14
  *
15
  */
16
 
17
  jQuery(document).ready(function() {
18
 
19
-
20
  var wplc_cid;
21
  var wplc_check_hide_cookie;
22
  var wplc_chat_status = "";
@@ -38,14 +39,14 @@ jQuery(document).ready(function() {
38
  wplc_chat_status = 5;
39
 
40
 
41
-
42
  var data = {
43
  action: 'wplc_call_to_server_visitor',
44
  security: wplc_nonce,
45
  cid:wplc_cid,
46
  wplc_name: wplc_cookie_name,
47
  wplc_email: wplc_cookie_email,
48
- status:wplc_chat_status
 
49
  };
50
  // ajax long polling function
51
  wplc_call_to_server_chat(data);
@@ -75,8 +76,12 @@ jQuery(document).ready(function() {
75
  jQuery.cookie('wplc_email', response['wplc_email'], { expires: 1, path: '/' });
76
  wplc_cid = jQuery.trim(response['cid']);
77
  wplc_chat_status = response['status'];
78
- //console.log(data);
79
-
 
 
 
 
80
  // handle response
81
  if(data['status'] == response['status']){
82
  if(data['status'] == 5 && wplc_init_chat_box_check == true){ // open chat box on load
@@ -104,6 +109,10 @@ jQuery(document).ready(function() {
104
  document.getElementById('wplc_chatmsg').disabled = true;
105
  jQuery("#wplc_chatbox").append("<em>"+response['data']+"</em><br />");
106
  }
 
 
 
 
107
  else if(response['status'] == 3 || response['status'] == 10){ // re-initialize chat
108
  jQuery("#wplc_cid").val(wplc_cid);
109
  if(response['status'] == 3){ // only if not minimized open aswell
@@ -145,7 +154,8 @@ jQuery(document).ready(function() {
145
  complete: function(response){
146
  //console.log(wplc_run);
147
  if (wplc_run) {
148
- wplc_call_to_server_chat(data);
 
149
  }
150
  },
151
  timeout: 120000
@@ -282,7 +292,6 @@ jQuery(document).ready(function() {
282
  });
283
 
284
  wplc_chat_status = jQuery.cookie('wplc_chat_status');
285
-
286
  if (wplc_chat_status == 3 || wplc_chat_status == 10) {
287
  jQuery("#wp-live-chat-4").show();
288
  jQuery("#wplc_chatmsg").focus();
@@ -359,14 +368,16 @@ jQuery(document).ready(function() {
359
  security: wplc_nonce,
360
  name: wplc_name,
361
  email: wplc_email,
362
- cid: wplc_cid
 
363
  };
364
  } else { // no cookie recorded yet for this visitor
365
  var data = {
366
  action: 'wplc_start_chat',
367
  security: wplc_nonce,
368
  name: wplc_name,
369
- email: wplc_email
 
370
  };
371
  }
372
  //changed ajax url so wp_mail function will work and not stop plugin from alerting admin there is a pending chat
11
  * 8 - complete but now browsing again
12
  * 9 - user closed chat before starting chat
13
  * 10 - user minimized active chat
14
+ * 11 - user moved on to another page (session variable is different)
15
  *
16
  */
17
 
18
  jQuery(document).ready(function() {
19
 
20
+ var wplc_session_variable = new Date().getTime();
21
  var wplc_cid;
22
  var wplc_check_hide_cookie;
23
  var wplc_chat_status = "";
39
  wplc_chat_status = 5;
40
 
41
 
 
42
  var data = {
43
  action: 'wplc_call_to_server_visitor',
44
  security: wplc_nonce,
45
  cid:wplc_cid,
46
  wplc_name: wplc_cookie_name,
47
  wplc_email: wplc_cookie_email,
48
+ status:wplc_chat_status,
49
+ wplcsession:wplc_session_variable
50
  };
51
  // ajax long polling function
52
  wplc_call_to_server_chat(data);
76
  jQuery.cookie('wplc_email', response['wplc_email'], { expires: 1, path: '/' });
77
  wplc_cid = jQuery.trim(response['cid']);
78
  wplc_chat_status = response['status'];
79
+ //console.log(jQuery.cookie('wplc_chat_status'));
80
+ //console.log('1 setting wplc_chat_stauts to '+wplc_chat_status);
81
+ jQuery.cookie('wplc_chat_status', null, { path: '/' });
82
+ //console.log(jQuery.cookie('wplc_chat_status'));
83
+ jQuery.cookie('wplc_chat_status', wplc_chat_status, { expires: 1, path: '/' });
84
+ //console.log(jQuery.cookie('wplc_chat_status'));
85
  // handle response
86
  if(data['status'] == response['status']){
87
  if(data['status'] == 5 && wplc_init_chat_box_check == true){ // open chat box on load
109
  document.getElementById('wplc_chatmsg').disabled = true;
110
  jQuery("#wplc_chatbox").append("<em>"+response['data']+"</em><br />");
111
  }
112
+ else if(parseInt(response['status']) == 11){ /* use moved on to another page (perhaps in another tab so close this instance */
113
+ jQuery("#wp-live-chat").css({ "display" : "none" });
114
+ wplc_run = false;
115
+ }
116
  else if(response['status'] == 3 || response['status'] == 10){ // re-initialize chat
117
  jQuery("#wplc_cid").val(wplc_cid);
118
  if(response['status'] == 3){ // only if not minimized open aswell
154
  complete: function(response){
155
  //console.log(wplc_run);
156
  if (wplc_run) {
157
+ setTimeout(wplc_call_to_server_chat(data), 1500);
158
+
159
  }
160
  },
161
  timeout: 120000
292
  });
293
 
294
  wplc_chat_status = jQuery.cookie('wplc_chat_status');
 
295
  if (wplc_chat_status == 3 || wplc_chat_status == 10) {
296
  jQuery("#wp-live-chat-4").show();
297
  jQuery("#wplc_chatmsg").focus();
368
  security: wplc_nonce,
369
  name: wplc_name,
370
  email: wplc_email,
371
+ cid: wplc_cid,
372
+ wplcsession: wplc_session_variable
373
  };
374
  } else { // no cookie recorded yet for this visitor
375
  var data = {
376
  action: 'wplc_start_chat',
377
  security: wplc_nonce,
378
  name: wplc_name,
379
+ email: wplc_email,
380
+ wplcsession: wplc_session_variable
381
  };
382
  }
383
  //changed ajax url so wp_mail function will work and not stop plugin from alerting admin there is a pending chat
readme.txt CHANGED
@@ -7,7 +7,7 @@ Tested up to: 4.0
7
  Stable tag: trunk
8
  License: GPLv2
9
 
10
- The most cost effective Live Chat plugin. Chat with your visitors for free!
11
 
12
  == Description ==
13
 
@@ -26,6 +26,7 @@ The most cost effective Live Chat plugin. Chat with your visitors for free! WP L
26
 
27
  = Pro Version Features =
28
 
 
29
  * Initiate live chats with online visitors
30
  * Chat to more than one visitor at a time
31
  * Access historical live chat records
@@ -66,10 +67,21 @@ Once the live chat plugin is activated, click on "Live Chat" in the left menu na
66
 
67
  Once installed and activated, a link should appear in your left navigation panel within your WP-ADMIN section. Click on the "Live Chat" link and follow the on screen instructions.
68
 
69
- = The live chat box is not showing up =
70
 
71
  Please review the live chat documentation on [our website](http://wp-livechat.com/documentation/).
72
 
 
 
 
 
 
 
 
 
 
 
 
73
  == Screenshots ==
74
 
75
  1. Front-end of WP Live Chat Support
@@ -79,18 +91,25 @@ Please review the live chat documentation on [our website](http://wp-livechat.co
79
 
80
  == Upgrade Notice ==
81
 
82
- = 4.1.0 =
83
- It is highly recommended that you upgrade to version 4.1.0.
84
 
85
  == Changelog ==
86
 
 
 
 
 
 
 
 
87
  = 4.1.0 2014-07-20 =
88
- * New feature: You can now show the chat box on the left or right
89
  * Vulnerability fix (JS injections). Thank you Patrik @ www.it-securityguard.com
90
  * Fixed 403 bug when saving settings
91
  * Fixed Ajax Time out error (Lowered From 90 to 28)
92
  * Fixed IE8 bug
93
- * Added option to auto pop up chat window
94
  * Added Italian language files. Thanks to Davide
95
 
96
  = 4.0.2 =
7
  Stable tag: trunk
8
  License: GPLv2
9
 
10
+ Fully functional Live Chat plugin. Chat with your visitors for free! No need for third party connections or monthly payments.
11
 
12
  == Description ==
13
 
26
 
27
  = Pro Version Features =
28
 
29
+ * Unlimited live chat agents
30
  * Initiate live chats with online visitors
31
  * Chat to more than one visitor at a time
32
  * Access historical live chat records
67
 
68
  Once installed and activated, a link should appear in your left navigation panel within your WP-ADMIN section. Click on the "Live Chat" link and follow the on screen instructions.
69
 
70
+ = Where can I find documentation for WP Live Chat Support? =
71
 
72
  Please review the live chat documentation on [our website](http://wp-livechat.com/documentation/).
73
 
74
+ = Troubleshooting =
75
+ If you're experiencing issues running WP Live Chat Support, please take note of the following:
76
+
77
+ - The live chat box will only show up on the front end if you are logged in to your wp-admin section.
78
+ - The default delay before the live chat box appears is 10 seconds. You can change this on the settings page.
79
+ - If you press the "X" within the live chat window on the front end, a cookie will be set that will stop the chat box from showing for another 24 hours.
80
+ - If the live chat box still does not appear on your website, please go through the following steps:
81
+ - - Please ensure your theme�s footer.php file has the following line before the closing body tag: <?php wp_footer(); ?>
82
+ - - Ensure that no other plugins are causing JavaScript errors on your website. This could interfere with the execution of our plugin's JavaScript.
83
+ - - If you need more help, please use the [WP Live Chat Support support forum](http://wp-livechat.com/forums/forum/support/) or contact us and we'll get to the bottom of the problem as soon as possible!
84
+
85
  == Screenshots ==
86
 
87
  1. Front-end of WP Live Chat Support
91
 
92
  == Upgrade Notice ==
93
 
94
+ = 4.1.1 =
95
+ It is highly recommended that you upgrade to version 4.1.1
96
 
97
  == Changelog ==
98
 
99
+ = 4.1.1 2014-07-29 =
100
+ * Significant performance improvements
101
+ * Live chat window will now only show in one window (if user has multiple tabs open on your site)
102
+ * You can now see the browser of the live chat user
103
+ * Improved the UI of the backend
104
+ * Bug fixes
105
+
106
  = 4.1.0 2014-07-20 =
107
+ * New feature: You can now show the live chat box on the left or right
108
  * Vulnerability fix (JS injections). Thank you Patrik @ www.it-securityguard.com
109
  * Fixed 403 bug when saving settings
110
  * Fixed Ajax Time out error (Lowered From 90 to 28)
111
  * Fixed IE8 bug
112
+ * Added option to auto pop up live chat window
113
  * Added Italian language files. Thanks to Davide
114
 
115
  = 4.0.2 =
wp-live-chat-support.php CHANGED
@@ -3,14 +3,20 @@
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support. No third party connection required!
6
- Version: 4.1.0
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  */
10
 
11
 
12
- /* 4.1.0
 
 
 
 
 
13
  *
 
14
  * New feature: You can now show the chat box on the left or right
15
  * Vulnerability fix (JS injections). Thank you Patrik @ www.it-securityguard.com
16
  * Fixed 403 bug when saving settings
@@ -21,7 +27,7 @@ Author URI: http://www.wp-livechat.com
21
  *
22
  */
23
 
24
- error_reporting(E_ERROR);
25
  global $wplc_version;
26
  global $wplc_p_version;
27
  global $wplc_tblname;
@@ -30,14 +36,15 @@ global $wplc_tblname_chats;
30
  global $wplc_tblname_msgs;
31
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
32
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
33
- $wplc_version = "4.1.0";
34
-
35
-
36
-
37
 
 
 
 
 
38
  require_once (plugin_dir_path( __FILE__ )."functions.php");
39
  add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');
40
-
41
  add_action('wp_footer', 'wplc_display_box');
42
 
43
  add_action('init','wplc_init');
@@ -69,6 +76,19 @@ function wplc_init() {
69
  }
70
 
71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
72
  function wplc_action_callback() {
73
  global $wpdb;
74
  global $wplc_tblname_chats;
@@ -234,7 +254,7 @@ function wplc_display_box() {
234
  global $wplc_pro_version;
235
  if (isset($wplc_pro_version)) {
236
  $float_version = floatval($wplc_pro_version);
237
- if ($float_version < 4) { return; }
238
  }
239
 
240
  if (function_exists("wplc_register_pro_version")) { wplc_pro_draw_user_box(); } else { wplc_draw_user_box(); }
@@ -364,13 +384,17 @@ function wplc_admin_javascript() {
364
  if (response['pending'] === true) {
365
 
366
  var orig_title = document.getElementsByTagName("title")[0].innerHTML;
 
367
  wplc_pending_refresh = setInterval(function (){
368
- console.log("chat request");
369
-
 
 
 
 
 
370
  document.title = "** CHAT REQUEST **";
371
- wplc_title_alerts1 = setTimeout(function (){ document.title = "__ CHAT Request __"; }, 1000);
372
  wplc_title_alerts2 = setTimeout(function (){ document.title = "** CHAT REQUEST **"; }, 2000);
373
- wplc_title_alerts3 = setTimeout(function (){ document.title = "__ CHAT Request __"; }, 3000);
374
  wplc_title_alerts4 = setTimeout(function (){ document.title = orig_title; }, 4000);
375
 
376
  document.getElementById("wplc_sound").innerHTML="<embed src='<?php echo plugins_url('/ring.wav', __FILE__); ?>' hidden=true autostart=true loop=false>";
@@ -404,7 +428,7 @@ function wplc_admin_javascript() {
404
  complete: function(response){
405
  //console.log(wplc_run);
406
  if (wplc_run) {
407
- wplc_call_to_server(data);
408
  }
409
  },
410
  timeout: 120000
@@ -439,13 +463,14 @@ function wplc_admin_javascript() {
439
  function wplc_admin_menu_layout() {
440
  if (function_exists("wplc_register_pro_version")) {
441
  global $wplc_pro_version;
442
- if (floatval($wplc_pro_version) < 4) {
443
  ?>
444
  <div class='error below-h1'>
445
 
446
  <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
447
- <p><?php _e("You are using an outdated version of WP Live Chat Support Pro. Please" , "wplivechat")?> <a href="http://wp-livechat.com/get-updated-version/" target=\"_BLANK\"><?php _e("update to at least version", "wplivechat") ?> 4.0</a> <?php _e("to ensure all functionality is in working order", "wplivechat" ) ?>.</p>
448
- <p>&nbsp;</p>
 
449
  <p><?php _e("If you are having difficulty updating the plugin, please contact","wplivechat") ?> nick@wp-livechat.com</p>
450
 
451
  </div>
@@ -555,8 +580,13 @@ function wplc_draw_chat_area($cid) {
555
  </style>
556
  <?php
557
 
558
-
559
  foreach ($results as $result) {
 
 
 
 
 
560
  if ($result->status == 1) { $status = __("Previous", "wplivechat"); } else { $status = __("Active", "wplivechat"); }
561
 
562
  echo "<h2>$status Chat with ".$result->name."</h2>";
@@ -566,24 +596,27 @@ function wplc_draw_chat_area($cid) {
566
  echo "<div id=\"wplc_sound_update\"></div>";
567
  echo "<div style='float:left; width:350px;'>";
568
  echo "<table>";
569
- echo "<tr><td>Email address</td><td><a href='mailto:".$result->email."' title='".$result->email."'>".$result->email."</a></td></tr>";
570
- echo "<tr><td>IP Address</td><td><a href='http://www.ip-adress.com/ip_tracer/".$result->ip."' title='Whois for ".$result->ip."'>".$result->ip."</a></td></tr>";
571
- echo "<tr><td>From URL</td><td>".$result->url. " (<a href='".$result->url."' target='_BLANK'>open</a>)"."</td></tr>";
572
- echo "<tr><td>Date</td><td>".$result->timestamp."</td></tr>";
 
 
 
573
  echo "</table><br />";
574
  echo "</div>";
575
  echo "</div>";
576
 
577
  echo "
578
- <p style=\"display:block; width:290px; text-align:right; font-size:10px;\"><a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat\" id=\"wplc_admin_close_chat\">".__("End chat","wplivechat")."</a></p>
579
  <div id='admin_chat_box'>
580
- <div id='admin_chat_box_area_".$result->id."' style='height:200px; width:290px; border:1px solid #ccc; overflow:auto; padding: 5px;'>".wplc_return_chat_messages($cid)."</div>
581
  <p>
582
  ";
583
  if ($result->status != 1) {
584
  echo "
585
  <p style=\"text-align:left; font-size:11px;\">Press ENTER to send your message</p>
586
- <input type='text' name='wplc_admin_chatmsg' id='wplc_admin_chatmsg' value='' style=\"border:1px solid #666; width:290px;\" />
587
  <input id='wplc_admin_cid' type='hidden' value='".$_GET['cid']."' />
588
  <input id='wplc_admin_send_msg' type='button' value='".__("Send","wplivechat")."' style=\"display:none;\" />
589
  </p>
@@ -841,6 +874,7 @@ function wplc_handle_db() {
841
  email varchar(700) NOT NULL,
842
  ip varchar(700) NOT NULL,
843
  status int(11) NOT NULL,
 
844
  url varchar(700) NOT NULL,
845
  last_active_timestamp datetime NOT NULL,
846
  PRIMARY KEY (id)
@@ -878,9 +912,12 @@ function wplc_add_user_stylesheet() {
878
 
879
  }
880
  function wplc_add_admin_stylesheet() {
881
- wp_register_style( 'wplc-admin-style', 'http://code.jquery.com/ui/1.8.24/themes/smoothness/jquery-ui.css' );
882
- wp_enqueue_style( 'wplc-admin-style' );
883
-
 
 
 
884
  }
885
 
886
  if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
@@ -998,5 +1035,4 @@ function wplc_get_home_path() {
998
  }
999
 
1000
  return str_replace( '\\', '/', $home_path );
1001
- }
1002
-
3
  Plugin Name: WP Live Chat Support
4
  Plugin URI: http://www.wp-livechat.com
5
  Description: The easiest to use website live chat plugin. Let your visitors chat with you and increase sales conversion rates with WP Live Chat Support. No third party connection required!
6
+ Version: 4.1.1
7
  Author: WP-LiveChat
8
  Author URI: http://www.wp-livechat.com
9
  */
10
 
11
 
12
+ /* 4.1.1
13
+ * Significant performance improvements
14
+ * Live chat window will now only show in one window (if user has multiple tabs open on your site)
15
+ * You can now see the browser of the live chat user
16
+ * Improved the UI of the backend
17
+ * Bug fixes
18
  *
19
+ * 4.1.0
20
  * New feature: You can now show the chat box on the left or right
21
  * Vulnerability fix (JS injections). Thank you Patrik @ www.it-securityguard.com
22
  * Fixed 403 bug when saving settings
27
  *
28
  */
29
 
30
+ //error_reporting(E_ERROR);
31
  global $wplc_version;
32
  global $wplc_p_version;
33
  global $wplc_tblname;
36
  global $wplc_tblname_msgs;
37
  $wplc_tblname_chats = $wpdb->prefix . "wplc_chat_sessions";
38
  $wplc_tblname_msgs = $wpdb->prefix . "wplc_chat_msgs";
39
+ $wplc_version = "4.1.1";
 
 
 
40
 
41
+ define('WPLC_BASIC_PLUGIN_DIR',dirname(__FILE__));
42
+ define('WPLC_BASIC_PLUGIN_URL',plugins_url()."/wp-live-chat-support/");
43
+ global $wplc_basic_plugin_url;
44
+ $wplc_basic_plugin_url = get_option('siteurl')."/wp-content/plugins/wp-live-chat-support/";
45
  require_once (plugin_dir_path( __FILE__ )."functions.php");
46
  add_action('wp_ajax_wplc_admin_set_transient', 'wplc_action_callback');
47
+ add_action('init','wplc_version_control');
48
  add_action('wp_footer', 'wplc_display_box');
49
 
50
  add_action('init','wplc_init');
76
  }
77
 
78
 
79
+ function wplc_version_control() {
80
+ global $wplc_version;
81
+
82
+
83
+ $current_version = get_option("wplc_current_version");
84
+ if (!isset($current_version) || $current_version != $wplc_version) {
85
+ wplc_handle_db();
86
+ update_option("wplc_current_version",$wplc_version);
87
+
88
+ }
89
+
90
+
91
+ }
92
  function wplc_action_callback() {
93
  global $wpdb;
94
  global $wplc_tblname_chats;
254
  global $wplc_pro_version;
255
  if (isset($wplc_pro_version)) {
256
  $float_version = floatval($wplc_pro_version);
257
+ if ($float_version < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") { return; }
258
  }
259
 
260
  if (function_exists("wplc_register_pro_version")) { wplc_pro_draw_user_box(); } else { wplc_draw_user_box(); }
384
  if (response['pending'] === true) {
385
 
386
  var orig_title = document.getElementsByTagName("title")[0].innerHTML;
387
+ var ringer_cnt = 0;
388
  wplc_pending_refresh = setInterval(function (){
389
+ //console.log("chat request");
390
+ ringer_cnt++;
391
+ if (ringer_cnt > 1) {
392
+ clearInterval(wplc_pending_refresh);
393
+ wplc_title_alerts4 = setTimeout(function (){ document.title = orig_title; }, 4000);
394
+ return;
395
+ }
396
  document.title = "** CHAT REQUEST **";
 
397
  wplc_title_alerts2 = setTimeout(function (){ document.title = "** CHAT REQUEST **"; }, 2000);
 
398
  wplc_title_alerts4 = setTimeout(function (){ document.title = orig_title; }, 4000);
399
 
400
  document.getElementById("wplc_sound").innerHTML="<embed src='<?php echo plugins_url('/ring.wav', __FILE__); ?>' hidden=true autostart=true loop=false>";
428
  complete: function(response){
429
  //console.log(wplc_run);
430
  if (wplc_run) {
431
+ setTimeout(wplc_call_to_server(data), 1500);
432
  }
433
  },
434
  timeout: 120000
463
  function wplc_admin_menu_layout() {
464
  if (function_exists("wplc_register_pro_version")) {
465
  global $wplc_pro_version;
466
+ if (floatval($wplc_pro_version) < 4 || $wplc_pro_version == "4.1.0" || $wplc_pro_version == "4.1.1") {
467
  ?>
468
  <div class='error below-h1'>
469
 
470
  <p><?php _e("Dear Pro User", "wplivechat") ?><br /></p>
471
+ <p><?php _e("You are using an outdated version of <strong>WP Live Chat Support Pro</strong>. Please" , "wplivechat")?> <a href="http://wp-livechat.com/get-updated-version/" target=\"_BLANK\"><?php _e("update to at least version", "wplivechat") ?> 4.0</a> <?php _e("to ensure all functionality is in working order", "wplivechat" ) ?>.</p>
472
+ <p><strong><?php _e("You're live chat box on your website has been temporarily disabled until the Pro plugin has been updated. This is to ensure a smooth and hassle-free user experience for both yourself and your visitors.","wplivechat") ?></strong></p>
473
+ <p><?php _e("You can update your plugin <a href='./update-core.php'>here</a>, <a href='./plugins.php'>here</a> or <a href='http://wp-livechat.com/get-updated-version/' target='_BLANK'>here</a>.","wplivechat") ?></strong></p>
474
  <p><?php _e("If you are having difficulty updating the plugin, please contact","wplivechat") ?> nick@wp-livechat.com</p>
475
 
476
  </div>
580
  </style>
581
  <?php
582
 
583
+
584
  foreach ($results as $result) {
585
+ $user_data = maybe_unserialize($result->ip);
586
+ $user_ip = $user_data['ip'];
587
+ $browser = wplc_return_browser_string($user_data['user_agent']);
588
+ $browser_image = wplc_return_browser_image($browser,"16");
589
+ global $wplc_basic_plugin_url;
590
  if ($result->status == 1) { $status = __("Previous", "wplivechat"); } else { $status = __("Active", "wplivechat"); }
591
 
592
  echo "<h2>$status Chat with ".$result->name."</h2>";
596
  echo "<div id=\"wplc_sound_update\"></div>";
597
  echo "<div style='float:left; width:350px;'>";
598
  echo "<table>";
599
+ echo "<tr><td><i class=\"fa fa-envelope\"> </i></td><td><a href='mailto:".$result->email."' title='".$result->email."'>".$result->email."</a></td></tr>";
600
+ echo "<tr><td valign='top'><i class=\"fa fa-user\"> </i></td><td>";
601
+ echo "<img src='".$wplc_basic_plugin_url."/images/$browser_image' alt='$browser' title='$browser' /> ";
602
+ echo "<a href='http://www.ip-adress.com/ip_tracer/".$user_ip."' title='Whois for ".$user_ip."'>".$user_ip."</a>";
603
+ echo "</td></tr>";
604
+ echo "<tr><td><i class=\"fa fa-link\"> </i></td><td>".$result->url. " (<a href='".$result->url."' target='_BLANK'>open</a>)"."</td></tr>";
605
+ echo "<tr><td><i class=\"fa fa-clock-o\"> </i></td><td>".$result->timestamp."</td></tr>";
606
  echo "</table><br />";
607
  echo "</div>";
608
  echo "</div>";
609
 
610
  echo "
611
+ <div style=\"display:block; clear:both; width:99%; text-align:right; font-size:10px;\"><a href=\"javascript:void(0);\" class=\"wplc_admin_close_chat button\" id=\"wplc_admin_close_chat\">".__("End chat","wplivechat")."</a></div>
612
  <div id='admin_chat_box'>
613
+ <div id='admin_chat_box_area_".$result->id."' style='height:200px; width:95%; border:1px solid #ccc; overflow:auto; background-color:#FFF; padding:2%;'>".wplc_return_chat_messages($cid)."</div>
614
  <p>
615
  ";
616
  if ($result->status != 1) {
617
  echo "
618
  <p style=\"text-align:left; font-size:11px;\">Press ENTER to send your message</p>
619
+ <input type='text' name='wplc_admin_chatmsg' id='wplc_admin_chatmsg' value='' style=\"border:1px solid #666; width:98%;\" />
620
  <input id='wplc_admin_cid' type='hidden' value='".$_GET['cid']."' />
621
  <input id='wplc_admin_send_msg' type='button' value='".__("Send","wplivechat")."' style=\"display:none;\" />
622
  </p>
874
  email varchar(700) NOT NULL,
875
  ip varchar(700) NOT NULL,
876
  status int(11) NOT NULL,
877
+ session bigint NOT NULL,
878
  url varchar(700) NOT NULL,
879
  last_active_timestamp datetime NOT NULL,
880
  PRIMARY KEY (id)
912
 
913
  }
914
  function wplc_add_admin_stylesheet() {
915
+ if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu' || $_GET['page'] == 'wplivechat-menu-settings') {
916
+ wp_register_style( 'wplc-admin-style', 'http://code.jquery.com/ui/1.8.24/themes/smoothness/jquery-ui.css' );
917
+ wp_enqueue_style( 'wplc-admin-style' );
918
+ wp_register_style( 'wplc-font-awesome', plugins_url('/css/font-awesome.min.css', __FILE__) );
919
+ wp_enqueue_style( 'wplc-font-awesome' );
920
+ }
921
  }
922
 
923
  if (isset($_GET['page']) && $_GET['page'] == 'wplivechat-menu-settings') {
1035
  }
1036
 
1037
  return str_replace( '\\', '/', $home_path );
1038
+ }