Author Topic: No Operator Answer Redirect  (Read 35063 times)

0 Members and 1 Guest are viewing this topic.

Sabyre

  • Full Member
  • ***
  • Posts: 6
  • Goober Extraordinaire
No Operator Answer Redirect
« on: March 02, 2013, 03:18:33 PM »
****** UPDATED 9-18-2014 ******

WebIM is written well in my opinion. Thanks guys! Though it looks like support is scarce and spammers have set in on this site.

I wanted to make a change so that unanswered chat requests after 'x' amount of time would be redirected. Who wants to wait on hold forever or potentially loose a customer?
We have it setup so that if an operator doesn't respond to a chat request within a set amount of time the visitor will be directed to a web form that offers an apology and an option for the visitor to contact you.

In the root folder of webim...
Create file: newchattimer.php:
Code: [Select]
<?php 
#///////////////////////////////////////////////////////////////////
#// Version 1.14917a - DSI - MILBEW NO ANSWER REDIRECT            //
#// Author: Dirigo Systems, Inc (DSI)                             //
#// http://itdsi.com - 800.485.4990                               //
#///////////////////////////////////////////////////////////////////

include('libs/config.php');
include(
'libs/common.php');

// --- Get thread ID.
$threadid = ($_SESSION['threadid']);

// --- Query DB, check if an operator has joined thread.
$link connect();
$query mysql_query("SELECT * FROM chatmessage WHERE threadid ='" $threadid "' AND tmessage LIKE '%Operator%%joined the chat%'");

// --- Define OP joined variable.
if(mysql_num_rows($query) == 0) {
  
$opjoined 'n'
 } 
mysql_close($link);

// --- Define thread ajax file.
$threadFile "ajaxfiles/opAnswer_";
$threadFile .= $threadid;
$threadFile .= ".txt";  

// --- Write thread ajax file.
$fh fopen($threadFile'w') or die("can't open file");
$stringData $opjoined;
fwrite($fh$stringData);
fclose($fh);
// --- Make file readable by client JS.
chmod($threadFile0777);

// --- Let's keep the folder tidy and remove old thread references.
$oldthread "ajaxfiles/opAnswer_";
$oldthread .= ($threadid 100);
$oldthread .= ".txt";
if (file_exists($oldthread)) {
unlink($oldthread);
}

?>


Create file: chatnoop.php
Code: [Select]
<?php
#///////////////////////////////////////////////////////////////////
#// Version 1.14917a - DSI - MILBEW NO ANSWER REDIRECT            //
#// Author: Dirigo Systems, Inc (DSI)                             //
#// http://itdsi.com - 800.485.4990                               //
#///////////////////////////////////////////////////////////////////

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');
require_once(
'libs/expand.php');
require_once(
'libs/captcha.php');
$page = array();
setup_logo();
setup_leavemessage($visitor['name'],$email,$firstmessage,$groupid,$groupname,$info,$referrer,can_show_captcha());
expand("styles"getchatstyle(), "leavemessage.tpl");

// --- Courtesy of 'wooshman' updated by DSI.
// --- To clear waiting list of dead threads (unanswered chat requests) uncomment the following.
// --- *** Keep in mind if enabled and visitors do NOT use the contact form you may never know they attempted to chat.


//$dtmcreated = date('Y-m-d H:i:s');
//$threadid = ($_SESSION['threadid']);
//$link = connect();

//$query = "INSERT INTO chatmessage (threadid, ikind, tmessage, dtmcreated) VALUES ('$threadid', '6', 'No OP Answer', '$dtmcreated')";
//$res = mysql_query($query) or die(mysql_error());

//$query2 = "UPDATE chatthread SET istate='3', dtmmodified='$dtmcreated' WHERE threadid=$threadid";
//$res = mysql_query($query2) or die(mysql_error());

//mysql_close($link);

// --- END
?>


Modify: client.php
At the end of the file Just after
Code: [Select]
?>
Add:
Code: [Select]

<script type="text/javascript">
///////////////////////////////////////////////////////////////////
// Version 1.14917a - DSI - MILBEW NO ANSWER REDIRECT            //
// Author: Dirigo Systems, Inc (DSI)                             //
// http://itdsi.com - 800.485.4990                               //
///////////////////////////////////////////////////////////////////

function opCheck() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else {
alert("Your browser does not support XMLHTTP!");
}
xmlhttp.onreadystatechange=function() {
if(xmlhttp.readyState==4) {
opCheck();
}
}
opjoined = "newchattimer.php";
xmlhttp.open("GET",opjoined,true);
xmlhttp.send(null);
}


function opResult() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
else {
alert("Your browser does not support XMLHTTP!");
}
xmlhttp.onreadystatechange=function() {
if(xmlhttp.readyState==4) {
if (xmlhttp.responseText == 'n') window.location.replace("chatnoop.php");
}
}
ajaxurl = "ajaxfiles/opAnswer_<?php echo $threadid;?>.txt";
xmlhttp.open("GET",ajaxurl,true);
xmlhttp.send(null);
}

// --- Set number to desired timeout length (1000 = 1 second).
setTimeout(function() { opCheck(); }, 148000); // --- Create thread file
setTimeout(function() { opResult(); }, 150000); // --- Check status of thread

</script>


Create folder '/ajaxfiles' CHMOD 755 or 777.

I have tested this with the latest browsers as of this update and all works. Please note the optional addition to 'chatnoop.php'.
« Last Edit: September 18, 2014, 09:03:42 PM by Sabyre »

dremhmrk2

  • Jr. Member
  • **
  • Posts: 2
Re: No Operator Answer Redirect
« Reply #1 on: October 29, 2013, 07:28:03 PM »
I feel that I must be missing something here. And I'd like to preface by saying I am at advanced beginner level when it comes to PHP but have been making sites a long time and I have a firm grasp of file structures, codes, blah blah blah, but not really the inner workings of java or php. That being said I can normally reverse engineer most things.

Problem: No visible effect at all.
Mibew version 1.6.5.

I have created the two files (newchattimer.php & chatnoop.php) and have placed them in my root webim folder, I have also created the specified folder (ajaxfiles) and CHMOD'd it to 777. Additionally I have added the javascript to the end of client.php.

I am able to see the javascript when i view source on the chat page, I have had a file created inside the ajaxfiles folder, but it doesn't seem to redirect! I tried chrome and firefox.

I assume the numbers at the end of the client.php file is the actual "x" number of milliseconds to wait. I lowered this down to 20 seconds worth of milliseconds, no change. I'm at a loss on this one as no errors are being thrown, the java comes through to the viewsource and the ajaxfiles folder is gaining files but no redirection is happening.

All I can imagine is that I've made a directory mistake or perhaps your code was not meant for my version of Mibew.

I appreciate any help you guys can offer, this is exactly the mod I need because my staff tends to walk off with the chat on far too often. I have included the files in question below.

root/webim/newchattime.php:
Code: [Select]
<?php 
include('libs/config.php');
include(
'libs/common.php');

$threadid = ($_SESSION['threadid']);

$link connect();
$query mysql_query("SELECT * FROM chatmessage WHERE threadid ='" $threadid "' AND tmessage LIKE '%Operator%%joined the chat%'");

if(
mysql_num_rows($query) == 0) {
  
$opjoined 'n'
 } 
mysql_close($link);

$myFile "ajaxfiles/opAnswer_";
$myFile .= $threadid;
//$myFile .= "12";
$myFile .= ".txt";  

$fh fopen($myFile'w') or die("can't open file");
$stringData $opjoined;
fwrite($fh$stringData);
fclose($fh);
chmod($myFile0777);

$oldthread "ajaxfiles/opAnswer_";
$oldthread .= ($threadid 1);
$oldthread .= ".txt";
unlink($oldthread);
?>

root/webim/chatnoop.php:
Code: [Select]
<?php

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');
require_once(
'libs/expand.php');
require_once(
'libs/captcha.php');
$page = array();
setup_logo();
setup_leavemessage($visitor['name'],$email,$firstmessage,$groupid,$groupname,$info,$referrer,can_show_captcha());
expand("styles"getchatstyle(), "leavemessage.tpl");

?>

root/webim/client.php:
Code: [Select]
<?php
/*
 * Copyright 2005-2013 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');
require_once(
'libs/expand.php');
require_once(
'libs/captcha.php');
require_once(
'libs/notify.php');

loadsettings();
if(
$settings['enablessl'] == "1" && $settings['forcessl'] == "1") {
if(!is_secure_request()) {
$requested $_SERVER['PHP_SELF'];
if($_SERVER['REQUEST_METHOD'] == 'GET' && $_SERVER['QUERY_STRING']) {
header("Location: ".get_app_location(true,true)."/client.php?".$_SERVER['QUERY_STRING']);
} else {
die("only https connections are handled");

exit;
}
}

if( !isset(
$_GET['token']) || !isset($_GET['thread']) ) {

$thread NULL;
if( isset($_SESSION['threadid']) ) {
$thread reopen_thread($_SESSION['threadid']);
}

if( !$thread ) {
$groupid "";
$groupname "";
if($settings['enablegroups'] == '1') {
$groupid verifyparam"group""/^\d{1,8}$/""");
if($groupid) {
$group group_by_id($groupid);
if(!$group) {
$groupid "";
} else {
$groupname get_group_name($group);
}
}
}

$visitor visitor_from_request();

if(isset($_POST['survey']) && $_POST['survey'] == 'on') {
$firstmessage getparam("message");
$info getparam("info");
$email getparam("email");
$referrer urldecode(getparam("referrer"));

if($settings['usercanchangename'] == "1" && isset($_POST['name'])) {
$newname getparam("name");
if($newname != $visitor['name']) {
$data strtr(base64_encode(myiconv($webim_encoding,"utf-8",$newname)), '+/=''-_,');
setcookie($namecookie$datatime()+60*60*24*365);
$visitor['name'] = $newname;
}
}
} else {
$firstmessage NULL;
$info getgetparam('info');
$email getgetparam('email');
$referrer = isset($_GET['url']) ? $_GET['url'] :
(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "");
if(isset($_GET['referrer']) && $_GET['referrer']) {
$referrer .= "\n".$_GET['referrer'];
}
}

if(!has_online_operators($groupid)) {
$page = array();
setup_logo();
setup_leavemessage($visitor['name'],$email,$firstmessage,$groupid,$groupname,$info,$referrer,can_show_captcha());
expand("styles"getchatstyle(), "leavemessage.tpl");
exit;
}

if($settings['enablepresurvey'] == '1' && !(isset($_POST['survey']) && $_POST['survey'] == 'on')) {
$page = array();
setup_logo();
setup_survey($visitor['name'], $email$groupid$info$referrer);
expand("styles"getchatstyle(), "survey.tpl");
exit;
}

$remoteHost get_remote_host();
$userbrowser $_SERVER['HTTP_USER_AGENT'];

$link connect();
if(!check_connections_from_remote($remoteHost$link)) {
mysql_close($link);
die("number of connections from your IP is exceeded, try again later");
}
$thread create_thread($groupid,$visitor['name'], $remoteHost$referrer,$current_locale,$visitor['id'], $userbrowser,$state_loading,$link);
$_SESSION['threadid'] = $thread['threadid'];

if( $referrer ) {
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referrer)),$link);
}
post_message_($thread['threadid'],$kind_info,getstring('chat.wait'),$link);
if($email) {
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.visitor.email',array($email)),$link);
}
if($info) {
post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.visitor.info',array($info)),$link);
}
if($firstmessage) {
$postedid post_message_($thread['threadid'],$kind_user,$firstmessage,$link,$visitor['name']);
commit_thread$thread['threadid'], array('shownmessageid' => $postedid), $link);
}
notify_operators($thread$firstmessage$link);
mysql_close($link);
}
$threadid $thread['threadid'];
$token $thread['ltoken'];
$level get_remote_level($_SERVER['HTTP_USER_AGENT']);
$chatstyle verifyparam"style""/^\w+$/""");
header("Location: $webimroot/client.php?thread=$threadid&token=$token&level=$level".($chatstyle "&style=$chatstyle""));
exit;
}

$token verifyparam"token""/^\d{1,8}$/");
$threadid verifyparam"thread""/^\d{1,8}$/");
$level verifyparam"level""/^(ajaxed|simple|old)$/");

$thread thread_by_id($threadid);
if( !
$thread || !isset($thread['ltoken']) || $token != $thread['ltoken'] ) {
die("wrong thread");
}

setup_chatview_for_user($thread$level);

$pparam verifyparam"act""/^(mailthread)$/""default");
if( 
$pparam == "mailthread" ) {
expand("styles"getchatstyle(), "mail.tpl");
} else if( 
$level == "ajaxed" ) {
expand("styles"getchatstyle(), "chat.tpl");
} else if( 
$level == "simple" ) {
expand("styles"getchatstyle(), "chatsimple.tpl");
} else if( 
$level == "old" ) {
expand("styles"getchatstyle(), "nochat.tpl");
}

?>


<script>
function opCheck()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
       
   opCheck();                         
            //  alert('working2');                     
  }
}
opjoined = "newchattimer.php";
xmlhttp.open("GET",opjoined,true);
xmlhttp.send(null);
}

function opResult()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
   
   if (xmlhttp.responseText == 'n') window.location.replace("chatnoop.php");

 }
}
ajaxurl = "ajaxfiles/opAnswer_<?php echo $threadid;?>.txt";
xmlhttp.open("GET",ajaxurl,true);
xmlhttp.send(null);
}

setTimeout(function() {
opCheck();
opResult();
//alert(op);

}, 150000);
clearTimeout();
</script>
« Last Edit: October 29, 2013, 07:30:01 PM by dremhmrk2 »

Sabyre

  • Full Member
  • ***
  • Posts: 6
  • Goober Extraordinaire
Re: No Operator Answer Redirect
« Reply #2 on: October 31, 2013, 08:39:17 PM »
I'd be happy to take a look for you. What is the domain you have WebIM installed on?

falcon

  • Sr. Member
  • ****
  • Posts: 44
Re: No Operator Answer Redirect
« Reply #3 on: November 01, 2013, 06:24:38 AM »
I can report

Code: [Select]
Warning: unlink(ajaxfiles/opAnswer_7371.txt) [function.unlink]: No such file or directory in /usr/home/livejet/public_html/newchattimer.php on line 29

And then flooding with

Code: [Select]
<br />
<b>Warning</b>:  unlink(ajaxfiles/opAnswer_7371.txt) [<a href='function.unlink'>function.unlink</a>]: No such file or directory in <b>/usr/home/livejet/public_html/newchattimer.php</b> on line <b>29</b><br />

And it's flooding ;/
Can look here
No, sorry, can't. Disabled to the usability for clients :)

Set to 30 sec.

Script creating file of [thead-1], not current thread. After CTRL+F5 (maybe f5) all works fine ;/
« Last Edit: November 01, 2013, 06:30:15 AM by falcon »

Sabyre

  • Full Member
  • ***
  • Posts: 6
  • Goober Extraordinaire
Re: No Operator Answer Redirect
« Reply #4 on: November 01, 2013, 01:05:03 PM »
Unlink of $threadid - 1 is all about removing old files so the ajaxfiles folder doesn't become cluttered. If you do a lot of chat support and/or have a lot of staff for chat support you could change it to $threadid - 10 or more.

I think it seems like you have it figured out. Let me know if I can be of anymore help.

falcon

  • Sr. Member
  • ****
  • Posts: 44
Re: No Operator Answer Redirect
« Reply #5 on: November 01, 2013, 01:08:56 PM »
The problem is that file not found. Current thread. I tryed to comment deleting of old.. make timeout to queries.. I think wrong order of responces. it send request to file and get 404 and THEN creates it.. ;/ so after update chat redirects..

all rights is normal. simply get to thread file as I see in firebug is firstly that get to php file with file creation. from tablet now. dont remember fname.
« Last Edit: November 01, 2013, 01:11:50 PM by falcon »

Sabyre

  • Full Member
  • ***
  • Posts: 6
  • Goober Extraordinaire
Re: No Operator Answer Redirect
« Reply #6 on: November 01, 2013, 01:18:31 PM »
This creates a file for the current session....

Code: [Select]
$threadid = ($_SESSION['threadid']);

$link = connect();
$query = mysql_query("SELECT * FROM chatmessage WHERE threadid ='" . $threadid . "' AND tmessage LIKE '%Operator%%joined the chat%'");

if(mysql_num_rows($query) == 0) {
  $opjoined = 'n';
 }
mysql_close($link);

$myFile = "ajaxfiles/opAnswer_";
$myFile .= $threadid;
//$myFile .= "12";
$myFile .= ".txt"; 

$fh = fopen($myFile, 'w') or die("can't open file");
$stringData = $opjoined;
fwrite($fh, $stringData);
fclose($fh);
chmod($myFile, 0777);



This deletes the old file (sessions past):

Code: [Select]
$oldthread = "ajaxfiles/opAnswer_";
$oldthread .= ($threadid - 1);
$oldthread .= ".txt";
unlink($oldthread);


falcon

  • Sr. Member
  • ****
  • Posts: 44
Re: No Operator Answer Redirect
« Reply #7 on: November 01, 2013, 01:21:55 PM »
I will make a test dir for you. i will see.
today near night or tomorrow.

i m very interested in this  ;)

wooshman

  • Full Member
  • ***
  • Posts: 8
Re: No Operator Answer Redirect
« Reply #8 on: April 17, 2014, 08:13:08 AM »
Did this ever get resolved?  I have tried the above and cannot get it to work.

Any help would be great.

Thanks.

Sabyre

  • Full Member
  • ***
  • Posts: 6
  • Goober Extraordinaire
Re: No Operator Answer Redirect
« Reply #9 on: April 17, 2014, 02:21:28 PM »
I just verified that it is no longer working on our end either. We will release an update to fix the issue. I am not sure off the top of my head if it is an issue with newer browsers or perhaps a MIBEW update.

Stay tuned!

wooshman

  • Full Member
  • ***
  • Posts: 8
Re: No Operator Answer Redirect
« Reply #10 on: April 17, 2014, 03:19:18 PM »
Hi Sabyre and thanks for posting after so long.

That is some great news that this mod is still alive so to speak.  It does try to do something, but being so new to Mibew I am a bit lost as to what, where and why.

I look forwards to an update.


wooshman

  • Full Member
  • ***
  • Posts: 8
Re: No Operator Answer Redirect [Solved] Now WORKING
« Reply #11 on: April 19, 2014, 12:57:45 PM »
FULL credit to Sabyre for original coding and idea.

OK fixed it.  It was all to do with the creation of the opAnswer_xxx.txt file.  It was not being created upon the client chat window being opened.

In chatnoop.php I have also added  a mysql line which clears the operators screen of the visit.  Without this the operator has to open the conversation to close it.  I have also made it add "y" to txt file in newchattimer.php upon operator entering chat to prevent the script going to leave message even when chatting.

Please remove existing files and code and use new code for ease:

Create: newchattimer.php - paste the following and save to root of Mibew
Code: [Select]
<?php 
include('libs/config.php');
include(
'libs/common.php');

$threadid = ($_SESSION['threadid']);
$link connect();
$query mysql_query("SELECT * FROM chatmessage WHERE threadid ='" $threadid "' AND tmessage LIKE '%Operator%%joined the chat%'");


if(
mysql_num_rows($query) == 0) {
  
$opjoined 'n'
 } else {
  
$opjoined 'y'// added this so that the script does not send to leave message page after an operator has answered.
 
}
mysql_close($link);

$myFile "ajaxfiles/opAnswer_";
$myFile .= $threadid;
//$myFile .= "12";
$myFile .= ".txt";  

$fh fopen($myFile'w') or die("can't open file");
$stringData $opjoined;
fwrite($fh$stringData);
fclose($fh);
chmod($myFile0777);

$oldthread "ajaxfiles/opAnswer_";
$oldthread .= ($threadid 1);
$oldthread .= ".txt";
unlink($oldthread);
?>

Create: chatnoop.php - paste the following code and save to root of Mibew
Code: [Select]
<?php

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');
require_once(
'libs/expand.php');
require_once(
'libs/captcha.php');

$dtmcreated date('Y-m-d H:i:s');
$page = array();
setup_logo();

// added to clear Operator screen of waiting chat after timeout.
$link connect();
$query mysql_query("INSERT INTO chatmessage (threadid, ikind, tmessage, dtmcreated) VALUES ('$threadid', '6', 'Visitor left the chat', '$dtmcreated')") or die(mysql_error());
mysql_close($link);
//

setup_leavemessage($visitor['name'],$email,$firstmessage,$groupid,$groupname,$info,$referrer,can_show_captcha());
expand("styles"getchatstyle(), "leavemessage.tpl");
?>

Now open client.php and at the very end ( after the closing ?> ) add the following and save
Code: [Select]
<script>
function opCheck()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
{
       
   opCheck();
           
}
}
opjoined = "newchattimer.php";

xmlhttp.open("GET",opjoined,true);
xmlhttp.send(null);
}

opCheck(); // This has been added to run newchattimer.php upon the client chat window opening

function opResult()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
   
   if (xmlhttp.responseText == 'n') window.location.replace("chatnoop.php");

 }
}
ajaxurl = "ajaxfiles/opAnswer_<?php echo $threadid;?>.txt";
xmlhttp.open("GET",ajaxurl,true);
xmlhttp.send(null);
}

setTimeout(function() {
opCheck();
opResult();

}, 30000); // This is how long you have to wait until it redirects to leave message page (chatnoop.php)  30000 = 30 seconds
clearTimeout();
</script>

create folder called ajaxfiles in the root of Mibew and chmod to 777 or 755.

Upload your new files / folders and also client.php and test.

The first time you run it you may see an error message in your logs about a missing file.  This will not happen after the first run.  It is trying to delete the old chat thread txt file.

yaisel

  • Full Member
  • ***
  • Posts: 5
    • GoldenStar de Mexico
Re: No Operator Answer Redirect
« Reply #12 on: May 16, 2014, 02:38:18 PM »
there is some errors in the file chatnoop.php in the version 1.6.11.

Notice: Undefined variable: visitor in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 15

Notice: Undefined variable: threadid in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 17

Notice: Undefined variable: visitor in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21

Notice: Undefined variable: email in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21

Notice: Undefined variable: firstmessage in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21

Notice: Undefined variable: groupid in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21

Notice: Undefined variable: groupname in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21

Notice: Undefined variable: info in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21

Notice: Undefined variable: referrer in C:\xampp\htdocs\roltec-css\webim\chatnoop.php on line 21


add this code line before setup_logo(); and this errors are gone but the visitors continued on visitors waiting list until an operator opens and closes a chat with him.

Code: [Select]
$threadid = ($_SESSION['threadid']);
$visitor = visitor_from_request();
$firstmessage = NULL;
$info = getgetparam('info');
$email = getgetparam('email');
$groupid = "";
$groupname = "";
if($settings['enablegroups'] == '1') {
$groupid = verifyparam( "group", "/^\d{1,10}$/", "");
if($groupid) {
$group = group_by_id($groupid);
if(!$group) {
$groupid = "";
} else {
$groupname = get_group_name($group);
}
}
}
$referrer = isset($_GET['url']) ? $_GET['url'] :
(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "");
if(isset($_GET['referrer']) && $_GET['referrer']) {
$referrer .= "\n".$_GET['referrer'];
}

yaisel

  • Full Member
  • ***
  • Posts: 5
    • GoldenStar de Mexico
Re: No Operator Answer Redirect
« Reply #13 on: May 16, 2014, 03:16:53 PM »
with these changes in the file chatnoop.php works quite stable in 1.6.11, eliminating vistante list of visitors is expected to pass the time and be redirected to the sending message window.

Code: [Select]
<?php

require_once('libs/common.php');
require_once(
'libs/chat.php');
require_once(
'libs/operator.php');
require_once(
'libs/groups.php');
require_once(
'libs/expand.php');
require_once(
'libs/captcha.php');

$dtmcreated date('Y-m-d H:i:s');
$page = array();
setup_logo();
//added to obtain the values ​​of these varibles
$threadid = ($_SESSION['threadid']);
$visitor visitor_from_request();
$firstmessage NULL;
$info getgetparam('info');
$email getgetparam('email');
$groupid "";
$groupname "";
if($settings['enablegroups'] == '1') {
$groupid verifyparam"group""/^\d{1,10}$/""");
if($groupid) {
$group group_by_id($groupid);
if(!$group) {
$groupid "";
} else {
$groupname get_group_name($group);
}
}
}
$referrer = isset($_GET['url']) ? $_GET['url'] :
(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "");
if(isset($_GET['referrer']) && $_GET['referrer']) {
$referrer .= "\n".$_GET['referrer'];
}
// added to clear Operator screen of waiting chat after timeout.
$thread reopen_thread($_SESSION['threadid']);
close_thread($thread,true);
//

setup_leavemessage($visitor['name'],$email,$firstmessage,$groupid,$groupname,$info,$referrer,can_show_captcha());
expand("styles"getchatstyle(), "leavemessage.tpl");
?>


Sabyre

  • Full Member
  • ***
  • Posts: 6
  • Goober Extraordinaire
Re: No Operator Answer Redirect
« Reply #14 on: September 18, 2014, 08:58:48 PM »
Thanks folks for all the feedback, I am sorry for the delays. I have modified the script. It is now functional. Please see the first post in this thread for the updated version.