From 84f37eb14cc7d170f6777c93061913226b29270f Mon Sep 17 00:00:00 2001 From: Evgeny Gryaznov Date: Thu, 7 Apr 2011 10:34:04 +0200 Subject: [PATCH] invitation patch by Fedor Fetisov --- src/messenger/webim/client.php | 10 +- src/messenger/webim/default.css | 14 ++ src/messenger/webim/images/ajax-loader.gif | Bin 0 -> 6820 bytes src/messenger/webim/images/tblictrack.gif | Bin 0 -> 291 bytes src/messenger/webim/install/dbinfo.php | 20 +- src/messenger/webim/install/dbperform.php | 5 + src/messenger/webim/invite.css | 65 +++++++ src/messenger/webim/invite.php | 68 +++++++ src/messenger/webim/js/164/chat.js | 2 +- src/messenger/webim/js/164/common.js | 6 +- src/messenger/webim/js/164/invite_op.js | 12 ++ src/messenger/webim/js/164/users.js | 38 ++-- src/messenger/webim/js/invite.js | 6 + src/messenger/webim/js/source/build.xml | 13 ++ src/messenger/webim/js/source/invite.js | 94 ++++++++++ src/messenger/webim/js/source/invite_op.js | 95 ++++++++++ src/messenger/webim/js/source/users.js | 177 +++++++++++++++++- src/messenger/webim/libs/chat.php | 11 +- src/messenger/webim/libs/common.php | 7 + src/messenger/webim/libs/getcode.php | 10 + src/messenger/webim/libs/invitation.php | 77 ++++++++ src/messenger/webim/libs/track.php | 121 ++++++++++++ src/messenger/webim/locales/en/properties | 36 ++++ src/messenger/webim/locales/names/level1 | 2 + src/messenger/webim/locales/names/level2 | 24 +++ src/messenger/webim/locales/ru/properties | 37 ++++ src/messenger/webim/operator/features.php | 2 +- .../webim/operator/invitationstate.php | 45 +++++ src/messenger/webim/operator/invite.php | 44 +++++ src/messenger/webim/operator/performance.php | 40 +++- src/messenger/webim/operator/tracked.php | 69 +++++++ src/messenger/webim/operator/update.php | 92 +++++++++ src/messenger/webim/operator/users.php | 1 + .../styles/default/images/buttons/tracked.gif | Bin 0 -> 1232 bytes .../webim/styles/default/templates/chat.tpl | 14 +- .../original/images/buttons/tracked.gif | Bin 0 -> 1268 bytes .../webim/styles/original/templates/chat.tpl | 12 +- .../simplicity/images/buttons/tracked.gif | Bin 0 -> 708 bytes .../styles/simplicity/templates/chat.tpl | 7 +- src/messenger/webim/view/features.php | 9 + src/messenger/webim/view/invite.php | 48 +++++ src/messenger/webim/view/pending_users.php | 38 +++- src/messenger/webim/view/performance.php | 38 ++++ src/messenger/webim/view/tracked.php | 89 +++++++++ 44 files changed, 1463 insertions(+), 35 deletions(-) create mode 100644 src/messenger/webim/images/ajax-loader.gif create mode 100644 src/messenger/webim/images/tblictrack.gif create mode 100644 src/messenger/webim/invite.css create mode 100644 src/messenger/webim/invite.php create mode 100644 src/messenger/webim/js/164/invite_op.js create mode 100644 src/messenger/webim/js/invite.js create mode 100644 src/messenger/webim/js/source/invite.js create mode 100644 src/messenger/webim/js/source/invite_op.js create mode 100644 src/messenger/webim/libs/invitation.php create mode 100644 src/messenger/webim/libs/track.php create mode 100644 src/messenger/webim/operator/invitationstate.php create mode 100644 src/messenger/webim/operator/invite.php create mode 100644 src/messenger/webim/operator/tracked.php create mode 100644 src/messenger/webim/styles/default/images/buttons/tracked.gif create mode 100644 src/messenger/webim/styles/original/images/buttons/tracked.gif create mode 100644 src/messenger/webim/styles/simplicity/images/buttons/tracked.gif create mode 100644 src/messenger/webim/view/invite.php create mode 100644 src/messenger/webim/view/tracked.php diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php index 612030bb..936a09f4 100644 --- a/src/messenger/webim/client.php +++ b/src/messenger/webim/client.php @@ -25,6 +25,7 @@ require_once('libs/operator.php'); require_once('libs/groups.php'); require_once('libs/expand.php'); require_once('libs/captcha.php'); +require_once('libs/invitation.php'); loadsettings(); if($settings['enablessl'] == "1" && $settings['forcessl'] == "1") { @@ -114,7 +115,14 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) { } $thread = create_thread($groupid,$visitor['name'], $remoteHost, $referrer,$current_locale,$visitor['id'], $userbrowser,$state_loading,$link); $_SESSION['threadid'] = $thread['threadid']; - + + $operator = invitation_accept($_SESSION['visitorid'], $thread['threadid'], $link); + if ($operator) { + $operator = operator_by_id_($operator, $link); + $operatorName = ($current_locale == $home_locale) ? $operator['vclocalename'] : $operator['vccommonname']; + post_message_($thread['threadid'], $kind_for_agent, getstring2('chat.visitor.invitation.accepted', array($operatorName)), $link); + } + if( $referrer ) { post_message_($thread['threadid'],$kind_for_agent,getstring2('chat.came.from',array($referrer)),$link); } diff --git a/src/messenger/webim/default.css b/src/messenger/webim/default.css index da66fc0a..2625fea5 100644 --- a/src/messenger/webim/default.css +++ b/src/messenger/webim/default.css @@ -899,3 +899,17 @@ table.awaiting td.visitor { float:left; padding-left:10px; } + +/* invitation wait */ + +.ajaxWait { + z-index: -1; + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 100%; + background-image: url(images/ajax-loader.gif); + background-repeat: no-repeat; + background-position: center; +} diff --git a/src/messenger/webim/images/ajax-loader.gif b/src/messenger/webim/images/ajax-loader.gif new file mode 100644 index 0000000000000000000000000000000000000000..2f6eff25e7d46b1d453a3995449b6d6b349a3da3 GIT binary patch literal 6820 zcma)>cRbba-^Y)$95RmM;5Z#RD0|PNq+{=OI6AUt_TE&--q~A5R*B54BqMu7gpi1= zC<)PWtKawj@BV!s_x1Pn_+0-yAJ5nO_5P@7sN!U;6#X5>8XfcuIs&)wC17r zANT4<=1#u

C!Xd%F(!zYfRgIb9VaLnQ@$6>(uv5XIRYj^Ah{Z+mNBdpm4^ldmJz z+SxkL)x+9O*vZ|&1Hf?trlLN(CHUuSe;x&ZPvL_akDeJ}MxUNCc_C-&iG9{&SFJc6 z`z*?prDE%OZ^3SX0=OuOBw1!*?+GWtx;fMW@WpwVCJsho@IZpDCL99DWaLLJM@3(O zCe`1(=XfdhX_@(L(|swVwg!U4sO=MCd5ZuBC3+)aKtEJ^rmH2hMdAf*JB};Xq2`t@ zf?hh65v6%ZH+S5_Vkg)=A!u7|MT;yNSb4iV!K3k69~f5OhtBD7dLhgQNwj#0YVYkv z@ac@t3R?^>TtinauM7N0y%o- zY$4C{Xh?(l4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cEBj3f*Uymoy|>WF}xv#b;sztcz4q zoYe3CrwQRM_T<2PfZ;%#k35oG#zR9C^`L$o*idoSgwh)rZln`qZh?YtP~}M!MaB}V z^v%>oGjt0i0tsu`)4IB1X31!yct^{p?j=iwvHZmkp53DVP!TtnzSE~q#nj9=;4`V! zWhJ{;6N3D#M8oh){@erc539`J`}4bLCgQa{!Cn(Rtn(K($xVo?$NJ76vtCzgR2&to z9v~?^qIsRA&-*L)vIh2y>)YvUk6pT|Hb#r}X}hI`6uTq+GaTpN!o}p3x~Jwv{)#H) zjG=aPC>|qz`*Aga6CJ-)Kf4ucrv6dteMN5(K}Hq)$ literal 0 HcmV?d00001 diff --git a/src/messenger/webim/images/tblictrack.gif b/src/messenger/webim/images/tblictrack.gif new file mode 100644 index 0000000000000000000000000000000000000000..c0bf7f1ffff8c5cba58b3d4523cf7b3b937467cf GIT binary patch literal 291 zcmcJ~ze+*@7>D6k38AxCAT5F5?r!FglJsYAZH=auhOn){A#yLvGARo>Wo2faYCqs| zmO{FN#+DYR==WiH5k7bDEG{q1q}QTExk_Lj_Ka%i6kT8)RL7pM7CONmuv>J9-Jwh5 zqJ7jr$Eb;put)3$yGMKI8f&97>;)a5Dym?w3`QyOGZun5lKdN+vP%z%pc++ BwEh49 literal 0 HcmV?d00001 diff --git a/src/messenger/webim/install/dbinfo.php b/src/messenger/webim/install/dbinfo.php index 502cf682..919effb9 100644 --- a/src/messenger/webim/install/dbinfo.php +++ b/src/messenger/webim/install/dbinfo.php @@ -109,7 +109,24 @@ $dbtables = array( "locale" => "varchar(8)", "groupid" => "int references ${mysqlprefix}chatgroup(groupid)", "vcvalue" => "varchar(1024) NOT NULL", - ) + ), + + "${mysqlprefix}chatsitevisitor" => array( + "visitorid" => "INT NOT NULL auto_increment PRIMARY KEY", + "userid" => "varchar(64) NOT NULL", + "username" => "varchar(255)", + "firsttime" => "datetime NOT NULL DEFAULT 0", + "lasttime" => "datetime NOT NULL DEFAULT 0", + "entry" => "text NOT NULL", + "path" => "text NOT NULL", + "details" => "text NOT NULL", + "invited" => "tinyint(1) NOT NULL DEFAULT 0", + "invitationtime" => "datetime", + "invitedby" => "INT references ${mysqlprefix}chatoperator(operatorid) on delete set null", + "invitations" => "INT NOT NULL DEFAULT 0", + "chats" => "INT NOT NULL DEFAULT 0", + "threadid" => "INT references ${mysqlprefix}chatthread(threadid) on delete set null" + ), ); $memtables = array(); @@ -122,6 +139,7 @@ $dbtables_can_update = array( "${mysqlprefix}chatgroup" => array("vcemail"), "${mysqlprefix}chatgroupoperator" => array(), "${mysqlprefix}chatresponses" => array(), + "${mysqlprefix}chatsitevisitor" => array(), ); function show_install_err($text) diff --git a/src/messenger/webim/install/dbperform.php b/src/messenger/webim/install/dbperform.php index 9f5c3ae8..c5e5d118 100644 --- a/src/messenger/webim/install/dbperform.php +++ b/src/messenger/webim/install/dbperform.php @@ -158,6 +158,11 @@ if ($act == "silentcreateall") { if ($res && mysql_num_rows($res) == 0) { runsql("ALTER TABLE ${mysqlprefix}chatmessage ADD INDEX idx_agentid (agentid)", $link); } + + $res = mysql_query("select null from information_schema.statistics where table_name = '${mysqlprefix}chatsitevisitor' and index_name = 'threadid'", $link); + if ($res && mysql_num_rows($res) == 0) { + runsql("ALTER TABLE ${mysqlprefix}chatsitevisitor ADD INDEX (threadid)", $link); + } } } diff --git a/src/messenger/webim/invite.css b/src/messenger/webim/invite.css new file mode 100644 index 00000000..ef968af0 --- /dev/null +++ b/src/messenger/webim/invite.css @@ -0,0 +1,65 @@ +/* + This file is part of Mibew Messenger project. + + Copyright (c) 2005-2011 Mibew Messenger Community + All rights reserved. The contents of this file are subject to the terms of + the Eclipse Public License v1.0 which accompanies this distribution, and + is available at http://www.eclipse.org/legal/epl-v10.html + + Alternatively, the contents of this file may be used under the terms of + the GNU General Public License Version 2 or later (the "GPL"), in which case + the provisions of the GPL are applicable instead of those above. If you wish + to allow use of your version of this file only under the terms of the GPL, and + not to allow others to use your version of this file under the terms of the + EPL, indicate your decision by deleting the provisions above and replace them + with the notice and other provisions required by the GPL. +*/ + +#mibewinvitationpopup { + border: 1px solid #aaa; + background-color: #ddd; + padding: 5px; + position: fixed; + top: 50%; + left: 0; + width: 400px; +} + +#mibewinvitationpopup h1, #mibewinvitationpopup p, #mibewinvitationclose a { + cursor: pointer; +} + +#mibewinvitationclose { + float: right; + background-color: red; + padding: 1px; + margin: 0; +} + +#mibewinvitationclose a { + font-family: "Trebuchet MS", Arial, Helvetica, sans-serif; + font-size: 20px; + font-weight: bold; + color: white; + margin: 0 4px 0 4px; +} + +#mibewinvitationclose a, #mibewinvitationclose a:link, #mibewinvitationclose a:hover { + text-decoration: none; +} + +#mibewinvitationpopup h1 { + text-align: center; +} + +#mibewinvitationpopup p { + padding: 2px; + margin: 2px; +} + +#mibewinvitationavatar { + margin: 2px; + margin-right: 5px; + cursor: pointer; + float: left; +} diff --git a/src/messenger/webim/invite.php b/src/messenger/webim/invite.php new file mode 100644 index 00000000..9c0471c1 --- /dev/null +++ b/src/messenger/webim/invite.php @@ -0,0 +1,68 @@ +" . htmlspecialchars($operatorName) . "" . getlocal("invitation.message") . "" . htmlspecialchars($operator['vcavatar']) . ""; +} +else { + echo ""; +} + +exit; +?> \ No newline at end of file diff --git a/src/messenger/webim/js/164/chat.js b/src/messenger/webim/js/164/chat.js index 479d2ba9..c29c3d2f 100644 --- a/src/messenger/webim/js/164/chat.js +++ b/src/messenger/webim/js/164/chat.js @@ -15,7 +15,7 @@ update:function(){this.updateOptions("refresh");this.updater=new Ajax.Request(th var b={}.extend(this._options);b.parameters+="&message="+encodeURIComponent(a);b.onComplete=function(a){this.requestComplete(a);if(this._options.message)this._options.message.value="",this._options.message.focus()}.bind(this);myRealAgent!="opera"&&this.enableInput(!1);this.updater=new Ajax.Request(this._options.servl,b)}},changeName:function(a){this.skipNextsound=!0;new Ajax.Request(this._options.servl,{parameters:"act=rename&thread="+(this._options.threadid||0)+"&token="+(this._options.token||0)+ "&name="+encodeURIComponent(a)})},onThreadClosed:function(a){var b=Ajax.getXml(a);b&&b.tagName=="closed"?setTimeout("window.close()",2E3):this.handleError(a,b,"cannot close")},closeThread:function(){var a="act=close&thread="+(this._options.threadid||0)+"&token="+(this._options.token||0);this._options.user&&(a+="&user=true");new Ajax.Request(this._options.servl,{parameters:a,onComplete:this.onThreadClosed.bind(this)})},processMessage:function(a,b){var c=NodeUtils.getNodeText(b);FrameUtils.insertIntoFrame(a, c)},showTyping:function(a){if($("typingdiv"))$("typingdiv").style.display=a?"inline":"none"},setupAvatar:function(a){a=NodeUtils.getNodeText(a);if(this._options.avatar&&this._options.user)this._options.avatar.innerHTML=a!=""?'':""},updateContent:function(a){var b=!1,c=this._options.container,d=NodeUtils.getAttrValue(a,"lastid");if(d)this._options.lastid=d;(d=NodeUtils.getAttrValue(a, -"typing"))&&this.showTyping(d=="1");if((d=NodeUtils.getAttrValue(a,"canpost"))&&(d=="1"&&!this.ownThread||this.ownThread&&d!="1"))window.location.href=window.location.href;for(d=0;d=0?(a="updated",this.lastupdate>0&&(c=((new Date).getTime()-this.lastupdate)/1E3,a=a+", "+c+" secs",c>10&&alert(a)),this.lastupdate=(new Date).getTime(), +"typing"))&&this.showTyping(d=="1");if((d=NodeUtils.getAttrValue(a,"canpost"))&&(d=="1"&&!this.ownThread||this.ownThread&&d!="1"))window.location.href=window.location.href;for(d=0;d=0?(a="updated",this.lastupdate>0&&(c=((new Date).getTime()-this.lastupdate)/1E3,a=a+", "+c+" secs",c>10&&alert(a)),this.lastupdate=(new Date).getTime(), this.setStatus(a)):this.clearStatus();b&&(FrameUtils.scrollDown(this._options.container),this.skipNextsound||(b=$("soundimg"),(b==null||b.className.match(/\bisound\b/))&&playSound(Chat.webimRoot+"/sounds/new_message.wav")),this.focused||window.focus())},isSendkey:function(a,b){return b==13&&(a||this._options.ignorectrl)||b==10},handleKeyDown:function(a){a?(ctrl=a.ctrlKey,a=a.which):(a=event.keyCode,ctrl=event.ctrlKey);if(this._options.message&&this.isSendkey(ctrl,a))return a=this._options.message.value, this._options.ignorectrl&&(a=a.replace(/[\r\n]+$/,"")),this.postMessage(a),!1;return!0},handleError:function(a,b){b&&b.tagName=="error"?this.setStatus(NodeUtils.getNodeValue(b,"descr")):this.setStatus("reconnecting")},showStatusDiv:function(a){if($("engineinfo"))$("engineinfo").style.display="inline",$("engineinfo").innerHTML=a},setStatus:function(a){this.statusTimeout&&clearTimeout(this.statusTimeout);this.showStatusDiv(a);this.statusTimeout=setTimeout(this.clearStatus.bind(this),4E3)},clearStatus:function(){$("engineinfo").style.display= "none"}});var Chat={threadUpdater:{},applyName:function(){Chat.threadUpdater.changeName($("uname").value);$("changename1").style.display="none";$("changename2").style.display="inline";$("unamelink").innerHTML=htmlescape($("uname").value)},showNameField:function(){$("changename1").style.display="inline";$("changename2").style.display="none"}}; diff --git a/src/messenger/webim/js/164/common.js b/src/messenger/webim/js/164/common.js index a1cb644b..4355c244 100644 --- a/src/messenger/webim/js/164/common.js +++ b/src/messenger/webim/js/164/common.js @@ -18,8 +18,8 @@ setTimeout(this.handleTimeout.bind(this),this._options.timeout);this.setRequestH clearTimeout(this.transportTimer),(this._options.onComplete||Ajax.emptyFunction)(this.transport)}catch(b){this.dispatchException(b)}this.transport.onreadystatechange=Ajax.emptyFunction}},dispatchException:function(a){(this._options.onException||Ajax.emptyFunction)(this,a)}}); var EventHelper={register:function(a,b,c){var d=a[b];a[b]=typeof d!="function"?c:function(){d();c()}}},Behaviour={list:[],register:function(a){Behaviour.list.push(a)},init:function(){EventHelper.register(window,"onload",function(){Behaviour.apply()})},apply:function(){for(h=0;sheet=Behaviour.list[h];h++)for(selector in sheet)if(list=document.getElementsBySelector(selector))for(i=0;element=list[i];i++)sheet[selector](element)}};Behaviour.init(); function getAllChildren(a){return a.all?a.all:a.getElementsByTagName("*")} -document.getElementsBySelector=function(a){if(!document.getElementsByTagName)return[];for(var a=a.split(" "),b=Array(document),c=0;c-1){var d=token.split("#"),e=d[0],b=document.getElementById(d[1]);if(b==null||e&&b.nodeName.toLowerCase()!=e)return[];b=Array(b)}else if(token.indexOf(".")>-1){d=token.split(".");e=d[0];d=d[1];e||(e="*");for(var l=[],j=0,n=0;n-1){var d=token.split("#"),f=d[0],b=document.getElementById(d[1]);if(b==null||f&&b.nodeName.toLowerCase()!=f)return[];b=Array(b)}else if(token.indexOf(".")>-1){d=token.split(".");f=d[0];d=d[1];f||(f="*");for(var g=[],j=0,n=0;n

'+b+"

";a+='
';if(b=document.getElementById("mibewinvitation"))b.innerHTML=a}mibewinvitetimer=setTimeout(function(){mibewInviteMakeRequest(mibewinviteurl, +mibewinvitetimeout)},mibewinvitetimeout)}}function mibewHideInvitation(){if(document.getElementById("mibewinvitationpopup"))document.getElementById("mibewinvitationpopup").style.display="none"}function mibewOpenAgent(){document.getElementById("mibewAgentButton")&&(document.getElementById("mibewAgentButton").onclick(),mibewHideInvitation())}; diff --git a/src/messenger/webim/js/source/build.xml b/src/messenger/webim/js/source/build.xml index 871a3217..00935358 100644 --- a/src/messenger/webim/js/source/build.xml +++ b/src/messenger/webim/js/source/build.xml @@ -28,6 +28,19 @@ + + + + + + + + + + + + + diff --git a/src/messenger/webim/js/source/invite.js b/src/messenger/webim/js/source/invite.js new file mode 100644 index 00000000..28b399ec --- /dev/null +++ b/src/messenger/webim/js/source/invite.js @@ -0,0 +1,94 @@ +var mibewinviterequest; +var mibewinviteurl; +var mibewinvitetimeout; +var mibewinvitetimer; + +var style = document.createElement('style'); +document.getElementsByTagName('head')[0].appendChild(style); + +if (!window.createPopup) { + style.appendChild(document.createTextNode('')); + style.setAttribute("type", "text/css"); +} + +var sheet = document.styleSheets[document.styleSheets.length - 1]; +if (!window.createPopup) { + var node = document.createTextNode(mibewInviteStyle); + style.appendChild(node); +} else { + sheet.cssText = mibewInviteStyle; +} + +function mibewInviteMakeRequest(url, timeout) +{ + mibewinviteurl = url; + mibewinvitetimeout = timeout; + if(window.XMLHttpRequest) + { + mibewinviterequest = new XMLHttpRequest(); + } + else if(window.ActiveXObject) + { + mibewinviterequest = new ActiveXObject("MSXML2.XMLHTTP"); + } + if (mibewinviterequest) { + mibewinviterequest.onreadystatechange = mibewInviteOnResponse; + } + mibewInviteSendRequest(url); +} + +function mibewInviteSendRequest(url) +{ + clearTimeout(mibewinvitetimer); + mibewinviterequest.open("GET", url + '&rnd=' + Math.random(1), true); + mibewinviterequest.send(); +} + +function mibewInviteCheckReadyState(obj) +{ + if ((obj.readyState == 4) && ((obj.status == 200) || (obj.status == 304))) {return true;} +} + +function mibewInviteOnResponse() +{ + if(mibewInviteCheckReadyState(mibewinviterequest)) + { + + var response = mibewinviterequest.responseXML.documentElement; + var invite = response.getElementsByTagName('message'); + if (invite[0]) { + var message = invite[0].firstChild.data; + var operator = response.getElementsByTagName('operator')[0] && response.getElementsByTagName('operator')[0].firstChild != null ? response.getElementsByTagName('operator')[0].firstChild.data : undefined; + var avatar = response.getElementsByTagName('avatar')[0] && response.getElementsByTagName('avatar')[0].firstChild != null ? response.getElementsByTagName('avatar')[0].firstChild.data : undefined; + + var popuptext = '
'; + popuptext += ''; + if (operator) { + popuptext += '

' + operator + '

'; + } + if (avatar) { + popuptext += '' + operator + ''; + } + popuptext += '

' + message + '

'; + popuptext += '
'; + var invitationdiv = document.getElementById("mibewinvitation"); + if (invitationdiv) { + invitationdiv.innerHTML = popuptext; + } + } + mibewinvitetimer = setTimeout( function(){ mibewInviteMakeRequest(mibewinviteurl, mibewinvitetimeout) }, mibewinvitetimeout); + } +} + +function mibewHideInvitation() { + if (document.getElementById('mibewinvitationpopup')) { + document.getElementById('mibewinvitationpopup').style.display='none'; + } +} + +function mibewOpenAgent() { + if (document.getElementById('mibewAgentButton')) { + document.getElementById('mibewAgentButton').onclick(); + mibewHideInvitation(); + } +} \ No newline at end of file diff --git a/src/messenger/webim/js/source/invite_op.js b/src/messenger/webim/js/source/invite_op.js new file mode 100644 index 00000000..b3eebca1 --- /dev/null +++ b/src/messenger/webim/js/source/invite_op.js @@ -0,0 +1,95 @@ +/** + * @preserve This file is part of Mibew Messenger project. + * http://mibew.org + * + * Copyright (c) 2005-2011 Mibew Messenger Community + * License: http://mibew.org/license.php + */ + +Ajax.InviteUpdater = Class.create(); +Class.inherit( Ajax.InviteUpdater, Ajax.Base, { + + initialize: function(_options) { + this.setOptions(_options); + this._options.onComplete = this.requestComplete.bind(this); + this._options.onException = this.handleException.bind(this); + this._options.onTimeout = this.handleTimeout.bind(this); + this._options.updateParams = this.updateParams.bind(this); + this._options.handleError = this.handleError.bind(this); + this._options.updateContent = this.updateContent.bind(this); + this._options.timeout = 5000; + this.frequency = (this._options.frequency || 2); + this.updater = {}; + this.update(); + }, + + handleException: function(_request, ex) { + if( this._options.handleError ) + this._options.handleError("offline, reconnecting"); + this.stopUpdate(); + this.timer = setTimeout(this.update.bind(this), 1000); + }, + + handleTimeout: function(_request) { + if( this._options.handleError ) + this._options.handleError("timeout, reconnecting"); + this.stopUpdate(); + this.timer = setTimeout(this.update.bind(this), 1000); + }, + + stopUpdate: function() { + if( this.updater._options ) + this.updater._options.onComplete = undefined; + clearTimeout(this.timer); + }, + + update: function() { + if( this._options.updateParams ) + this._options.parameters = (this._options.updateParams)(); + this.updater = new Ajax.Request(this._options.url, this._options); + }, + + requestComplete: function(presponse) { + try { + var xmlRoot = Ajax.getXml(presponse); + if( xmlRoot ) { + (this._options.updateContent || Ajax.emptyFunction)( xmlRoot ); + } else { + if( this._options.handleError ) + this._options.handleError("reconnecting"); + } + } catch(e) { + } + this.timer = setTimeout(this.update.bind(this), this.frequency * 1000); + }, + + updateParams: function() { + return "visitor=" + this._options.visitor; + }, + + handleError: function(s) { + }, + + updateContent: function(root) { + if( root.tagName == 'invitation' ) { + var invited = NodeUtils.getNodeValue(root, "invited"); + var threadid = NodeUtils.getNodeValue(root, "threadid"); + if (invited == "0") { + this.stopUpdate(); + window.close(); + } + else if (threadid != "0") { + this.stopUpdate(); + window.name = 'ImCenter' + threadid; + window.location=this._options.agentservl + '?thread=' + threadid; + + } + } + } + +}); + + +EventHelper.register(window, 'onload', function(){ + new Ajax.InviteUpdater(({}).extend(updaterOptions || {})); +}); diff --git a/src/messenger/webim/js/source/users.js b/src/messenger/webim/js/source/users.js index bd006825..80031cd2 100644 --- a/src/messenger/webim/js/source/users.js +++ b/src/messenger/webim/js/source/users.js @@ -73,7 +73,7 @@ var HtmlGenerationUtils = { return '' + content + '
'; }, - viewOpenCell: function(username,servlet,id,canview,canopen,ban,message,cantakenow) { + viewOpenCell: function(username,servlet,id,canview,canopen,ban,message,cantakenow,tracked,trackedlink) { var cellsCount = 2; var link = servlet+"?thread="+id; var gen = ''; @@ -95,17 +95,40 @@ var HtmlGenerationUtils = { gen += ''; cellsCount++; } + if ( tracked ) { + gen += ''; + gen += HtmlGenerationUtils.popupLink( trackedlink+"?thread="+id, localized[6], "ImTracked"+id, ''+localized[6]+'', 640, 480, null); + gen += ''; + cellsCount++; + } if( message != "" ) { gen += ''; gen += message.length > 30 ? message.substring(0,30) + '...' : message; gen += ''; } + return HtmlGenerationUtils.generateOneRowTable(gen); }, banCell: function(id,banid){ return ''+ HtmlGenerationUtils.popupLink( webimRoot+'/operator/ban.php?'+(banid ? 'id='+banid : 'thread='+id), localized[2], "ban"+id, ''+localized[2]+'', 720, 480, null)+ ''; + }, + viewVisOpenCell: function(username, inviteservlet, userid, trackedservlet, caninvite) { + var cellsCount = 2; + var gen = ''; + if(caninvite) { + gen += HtmlGenerationUtils.popupLink( inviteservlet+"?visitor="+userid, localized[7], "ImCenter"+userid, username, 640, 480, null); + } else { + gen += '' + username + ''; + } + gen += ''; + gen += ''; + var tr_link = HtmlGenerationUtils.popupLink( trackedservlet+"?visitor="+userid, localized[6], "ImTracked"+userid, ''+localized[6]+'', 640, 480, null); + tr_link = tr_link.replace("scrollbars=0","scrollbars=1"); + gen += tr_link; + gen += ''; + return HtmlGenerationUtils.generateOneRowTable(gen); } }; @@ -121,11 +144,15 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, { this.threadTimers = new Object(); this.delta = 0; this.t = this._options.table; + this.t2 = this._options.visitors_table; this.periodicalUpdater = new Ajax.PeriodicalUpdater(this._options); + this.old_visitors = new Object(); + this.visitors = new Object(); + this.visitorTimers = new Object(); }, updateParams: function() { - return "since=" + this._options.lastrevision + "&status=" + this._options.istatus + (this._options.showonline ? "&showonline=1" : ""); + return "since=" + this._options.lastrevision + "&status=" + this._options.istatus + (this._options.showonline ? "&showonline=1" : "") + (this._options.showvisitors ? "&showvisitors=1" : ""); }, setStatus: function(msg) { @@ -204,7 +231,7 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, { row.className = (ban == "blocked" && stateid != "chat") ? "ban" : "in"+stateid; row.id = "thr"+id; this.threadTimers[id] = new Array(vtime,modified,stateid); - CommonUtils.insertCell(row, "name", "visitor", null, null, HtmlGenerationUtils.viewOpenCell(vname,this._options.agentservl,id,canview,canopen,ban,message,stateid!='chat')); + CommonUtils.insertCell(row, "name", "visitor", null, null, HtmlGenerationUtils.viewOpenCell(vname,this._options.agentservl,id,canview,canopen,ban,message,stateid!='chat',this._options.showvisitors, this._options.trackedservl)); CommonUtils.insertCell(row, "contid", "visitor", "center", null, vaddr ); CommonUtils.insertCell(row, "state", "visitor", "center", null, vstate ); CommonUtils.insertCell(row, "op", "visitor", "center", null, agent ); @@ -217,7 +244,7 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, { } else { this.threadTimers[id] = new Array(vtime,modified,stateid); row.className = (ban == "blocked" && stateid != "chat") ? "ban" : "in"+stateid; - setcell(this.t, row,"name",HtmlGenerationUtils.viewOpenCell(vname,this._options.agentservl,id,canview,canopen,ban,message,stateid!='chat')); + setcell(this.t, row,"name",HtmlGenerationUtils.viewOpenCell(vname,this._options.agentservl,id,canview,canopen,ban,message,stateid!='chat',this._options.showvisitors, this._options.trackedservl)); setcell(this.t, row,"contid",vaddr); setcell(this.t, row,"state",vstate); setcell(this.t, row,"op",agent); @@ -332,6 +359,144 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, { div.innerHTML = names.join(', '); }, + updateVisitorsTimers: function() { + for (var i in this.visitorTimers) { + if (this.visitorTimers[i] != null) { + var value = this.visitorTimers[i]; + var row = CommonUtils.getRow("vis"+i, this.t2); + if( row != null ) { + function setcell(_table, row,id,pcontent) { + var cell = CommonUtils.getCell( id, row, _table ); + if( cell ) + cell.innerHTML = pcontent; + } + setcell(this.t2, row,"time",this.getTimeSince(value[0])); + setcell(this.t2, row,"modified",this.getTimeSince(value[1])); + if (value[2] != null) + setcell(this.t2, row,"invitationtime",this.getTimeSince(value[2])); + } + } + } + }, + + updateVisitor: function(node) { + var id, invited = false; + + for( var i = 0; i < node.attributes.length; i++ ) { + var attr = node.attributes[i]; + if( attr.nodeName == "id" ) + id = attr.nodeValue; + } + + function setcell(_table, row,id,pcontent) { + var cell = CommonUtils.getCell( id, row, _table ); + if( cell ) + cell.innerHTML = pcontent; + } + + var addr = NodeUtils.getNodeValue(node,"addr"); + var username = NodeUtils.getNodeValue(node,"username"); + var useragent = NodeUtils.getNodeValue(node,"useragent"); + var time = NodeUtils.getNodeValue(node,"time"); + var modified = NodeUtils.getNodeValue(node,"modified"); + + var invitations = NodeUtils.getNodeValue(node,"invitations"); + var chats = NodeUtils.getNodeValue(node,"chats"); + + var operator = null; + var invitationtime = null; + var invitation = node.getElementsByTagName("invitation")[0]; + for( var i = 0; i < invitation.childNodes.length; i++ ) { + var childnode = invitation.childNodes[i]; + if( childnode.tagName == 'operator' ) { + operator = childnode.firstChild.nodeValue; + } + else if ( childnode.tagName == 'invitationtime' ) { + invitationtime = childnode.firstChild.nodeValue; + } + } + var state = (operator == null) ? 'free' : 'invited'; + + var row = CommonUtils.getRow("vis"+id, this.t2); + + var startRow = CommonUtils.getRow("vis" + state, this.t2); + var endRow = CommonUtils.getRow("vis" + state + "end", this.t2); + + if( row != null && (row.rowIndex <= startRow.rowIndex || row.rowIndex >= endRow.rowIndex ) ) { + + this.t2.deleteRow(row.rowIndex); + this.visitorTimers[id] = null; + row = null; + } + + if (row == null) { + row = this.t2.insertRow(startRow.rowIndex+1); + row.id = "vis"+id; + this.visitorTimers[id] = new Array(time, modified, invitationtime); + CommonUtils.insertCell(row, "username", "visitor", null, null, HtmlGenerationUtils.viewVisOpenCell(username, this._options.inviteservl, id, this._options.trackedservl, operator==null)); + CommonUtils.insertCell(row, "addr", "visitor", "center", null, addr); + CommonUtils.insertCell(row, "time", "visitor", "center", null, this.getTimeSince(time) ); + CommonUtils.insertCell(row, "modified", "visitor", "center", null, this.getTimeSince(modified) ); + CommonUtils.insertCell(row, "operator", "visitor", "center", null, (operator != null) ? operator : '-'); + CommonUtils.insertCell(row, "invitationtime", "visitor", "center", null, (operator != null ? this.getTimeSince(invitationtime) : '-') ); + CommonUtils.insertCell(row, "invitations", "visitor", "center", null, invitations + ' / ' + chats); + CommonUtils.insertCell(row, "useragent", "visitor", "center", null, useragent); + } + else { + this.visitorTimers[id] = new Array(time, modified, invitationtime); + setcell(this.t2, row, "username",HtmlGenerationUtils.viewVisOpenCell(username, this._options.inviteservl, id, this._options.trackedservl, operator==null)); + setcell(this.t2, row, "addr", addr); + setcell(this.t2, row, "operator", (operator != null) ? operator : '-'); + setcell(this.t2, row, "time", this.getTimeSince(time) ); + setcell(this.t2, row, "modified", this.getTimeSince(modified) ); + setcell(this.t2, row, "invitationtime", (operator != null ? this.getTimeSince(invitationtime) : '-') ); + setcell(this.t2, row, "invitations", invitations + ' / ' + chats); + setcell(this.t2, row, "useragent", useragent); + } + + this.visitors[id] = 1; + + return false; + }, + + removeOldVisitors: function() { + for (id in this.old_visitors) { + if (this.visitors[id] === undefined) { + var row = CommonUtils.getRow("vis"+id, this.t2); + if( row ) { + this.t2.deleteRow(row.rowIndex); + } + this.visitorTimers[id] = null; + } + } + }, + + updateVisitorsList: function(visitors) { + var _status = $("visstatustd"); + if( _status) { + _status.innerHTML = (visitors > 0) ? "" : this._options.novisitors; + _status.height = (visitors > 0) ? 5 : 30; + } + }, + + updateVisitors: function(root) { + + this.old_visitors = this.visitors; + this.visitors = new Object(); + + var visitors_cnt = 0; + for( var i = 0; i < root.childNodes.length; i++ ) { + var node = root.childNodes[i]; + if( node.tagName == 'visitor' ) { + visitors_cnt++; + this.updateVisitor(node); + } + } + this.updateVisitorsTimers(); + this.removeOldVisitors(); + this.updateVisitorsList(visitors_cnt); + }, + updateContent: function(root) { if( root.tagName == 'update' ) { for( var i = 0; i < root.childNodes.length; i++ ) { @@ -341,6 +506,8 @@ Class.inherit( Ajax.ThreadListUpdater, Ajax.Base, { this.updateThreads(node); } else if (node.tagName == 'operators') { this.updateOperators(node); + } else if (node.tagName == 'visitors') { + this.updateVisitors(node); } } } else if( root.tagName == 'error' ) { @@ -377,7 +544,7 @@ Behaviour.register({ EventHelper.register(window, 'onload', function(){ webimRoot = updaterOptions.wroot; - new Ajax.ThreadListUpdater(({table:$("threadlist"),status:$("connstatus"),istatus:0}).extend(updaterOptions || {})); + new Ajax.ThreadListUpdater(({table:$("threadlist"),status:$("connstatus"),istatus:0,visitors_table:$("visitorslist")}).extend(updaterOptions || {})); if(!updaterOptions.havemenu) { togglemenu(); } diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php index 7deb64f7..2390a524 100644 --- a/src/messenger/webim/libs/chat.php +++ b/src/messenger/webim/libs/chat.php @@ -20,6 +20,8 @@ * Pavel Petroshenko - history search */ +require_once(dirname(__FILE__).'/track.php'); + $connection_timeout = 30; // sec $namecookie = "WEBIM_Data"; @@ -88,7 +90,7 @@ function post_message($threadid, $kind, $message, $from = null, $agentid = null) function prepare_html_message($text) { $escaped_text = htmlspecialchars($text); - $text_w_links = preg_replace('/(http|ftp):\/\/\S*/', '$0', $escaped_text); + $text_w_links = preg_replace('/(https?|ftp):\/\/\S*/', '$0', $escaped_text); $multiline = str_replace("\n", "
", $text_w_links); return $multiline; } @@ -445,6 +447,13 @@ function setup_chatview_for_operator($thread, $operator) $page['neediframesrc'] = needsFramesrc(); $page['historyParams'] = array("userid" => "" . $thread['userid']); $page['historyParamsLink'] = add_params($webimroot . "/operator/userhistory.php", $page['historyParams']); + if ($settings['enabletracking']) { + $link = connect(); + $visitor = track_get_visitor_by_threadid($thread['threadid'], $link); + $page['trackedParams'] = array("visitor" => "" . $visitor['visitorid']); + $page['trackedParamsLink'] = add_params($webimroot . "/operator/tracked.php", $page['trackedParams']); + mysql_close($link); + } $predefinedres = ""; $canned_messages = load_canned_messages($thread['locale'], $thread['groupid']); foreach ($canned_messages as $answer) { diff --git a/src/messenger/webim/libs/common.php b/src/messenger/webim/libs/common.php index 75a52e69..318cd29f 100644 --- a/src/messenger/webim/libs/common.php +++ b/src/messenger/webim/libs/common.php @@ -626,6 +626,7 @@ $settings = array( 'usercanchangename' => '1', 'enablegroups' => '0', 'enablestatistics' => '1', + 'enabletracking' => '0', 'enablepresurvey' => '1', 'surveyaskmail' => '0', 'surveyaskgroup' => '1', @@ -638,6 +639,12 @@ $settings = array( 'updatefrequency_operator' => 2, 'updatefrequency_chat' => 2, 'updatefrequency_oldchat' => 7, + + 'updatefrequency_tracking' => 10, + 'visitors_limit' => 20, /* Number of visitors to look over */ + 'invitation_lifetime' => 60, /* Lifetime for invitation to chat */ + 'tracking_lifetime' => 600, /* Time to store tracked old visitors' data */ + ); $settingsloaded = false; $settings_in_db = array(); diff --git a/src/messenger/webim/libs/getcode.php b/src/messenger/webim/libs/getcode.php index f533ba1a..64f3b13f 100644 --- a/src/messenger/webim/libs/getcode.php +++ b/src/messenger/webim/libs/getcode.php @@ -21,6 +21,7 @@ function generate_button($title, $locale, $style, $group, $inner, $showhost, $forcesecure, $modsecurity) { + global $settings; $link = get_app_location($showhost, $forcesecure) . "/client.php"; if ($locale) $link = append_query($link, "locale=$locale"); @@ -33,6 +34,15 @@ function generate_button($title, $locale, $style, $group, $inner, $showhost, $fo $jslink = append_query("'" . $link, "url='+escape(document.location.href$modsecfix)+'&referrer='+escape(document.referrer$modsecfix)"); $temp = get_popup($link, "$jslink", $inner, $title, "webim", "toolbar=0,scrollbars=0,location=0,status=1,menubar=0,width=640,height=480,resizable=1"); + if ($settings['enabletracking']) { + $temp = preg_replace('/^('; + } return "" . $temp . ""; } diff --git a/src/messenger/webim/libs/invitation.php b/src/messenger/webim/libs/invitation.php new file mode 100644 index 00000000..6b65c33d --- /dev/null +++ b/src/messenger/webim/libs/invitation.php @@ -0,0 +1,77 @@ + diff --git a/src/messenger/webim/libs/track.php b/src/messenger/webim/libs/track.php new file mode 100644 index 00000000..b6c71a36 --- /dev/null +++ b/src/messenger/webim/libs/track.php @@ -0,0 +1,121 @@ + $_SERVER['HTTP_USER_AGENT'], + 'remote_host' => get_remote_host() + ); + + return serialize($result); + +} + +function track_retrieve_details($visitor) +{ + return unserialize($visitor['details']); +} + +?> diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties index 135d4d70..7f917ba4 100644 --- a/src/messenger/webim/locales/en/properties +++ b/src/messenger/webim/locales/en/properties @@ -78,6 +78,7 @@ chat.thread.state_wait=In queue chat.thread.state_wait_for_another_agent=Waiting for operator chat.visitor.email=E-Mail: {0} chat.visitor.info=Info: {0} +chat.visitor.invitation.accepted=Visitor accepted invitation from operator {0} chat.wait=Thank you for contacting us. An operator will be with you shortly... chat.window.chatting_with=You chat with: chat.window.close_title=Close chat @@ -92,6 +93,7 @@ chat.window.title.user=Mibew Messenger chat.window.toolbar.mail_history=Send chat history by e-mail chat.window.toolbar.redirect_user=Redirect visitor to another operator chat.window.toolbar.refresh=Refresh +chat.window.toolbar.mute=Sound on/off clients.how_to=To answer the visitor click on his/her name in the list. clients.intro=This page displays a list of awaiting visitors. clients.no_clients=The list of awaiting visitors is empty @@ -200,6 +202,9 @@ install.updatedb=Please, run Update wizard to adjust your data installed.login_link=Proceed to login page installed.message=Application installed successfully. installed.notice=You can logon as admin with empty password.

!!! For security reasons, please change your password immediately and remove {0} folder from your server. +invitation.message=Hello, how can I help you? +invitation.sent=Invitation sent to visitor. Please wait for a while. +invitation.title=Invitation lang.choose=Choose your language leavemail.body=Your have a message from {0}:\n\n{2}\n\nHis email: {1}\n{3}\n--- \nYours site messenger leavemail.subject=Question from {0} @@ -248,6 +253,7 @@ page.analysis.search.head_messages=Visitor's messages page.analysis.search.head_name=Name page.analysis.search.head_operator=Operator page.analysis.search.head_time=Time in chat +page.analysis.trackedpath.title=Tracked visitor's path page.analysis.userhistory.intro=You can find chat history of your visitors here. page.analysis.userhistory.title=Visits history page.chat.old_browser.close=Close... @@ -366,7 +372,9 @@ pending.table.head.operator=Operator pending.table.head.state=State pending.table.head.total=Total time pending.table.head.waittime=Waiting time +pending.table.invite=Invite to chat pending.table.speak=Click to chat with the visitor +pending.table.tracked=Tracked visitor's path pending.table.view=Watch the chat permission.admin=System administration: settings, operators management, button generation permission.modifyprofile=Ability to modify profile @@ -430,6 +438,8 @@ settings.enablessl.description=Please, note that your web server should be confi settings.enablessl=Allow secure connections (SSL) settings.enablestatistics.description=Adds page with messenger usage reports. settings.enablestatistics=Enable "Statistics" +settings.enabletracking.description=Enable tracking of visitors' activity on your site and ability to invite visitors to chat. +settings.enabletracking=Enable "Tracking and inviting" settings.forcessl.description=Show chats only through https connection settings.forcessl=Force all chats to be secure settings.frequencychat.description=Specify the poll interval in seconds. Default is 2 seconds. @@ -438,12 +448,16 @@ settings.frequencyoldchat.description=Old browsers need to refresh the whole pag settings.frequencyoldchat=Page refresh time for old browsers settings.frequencyoperator.description=Specify the poll interval in seconds. Default is 2 seconds. settings.frequencyoperator=Operator's console refresh time +settings.frequencytracking.description=Specify the poll interval in seconds. Default is 10 seconds. +settings.frequencytracking=Tracking refresh time settings.geolink.description=Each IP becomes a link opening in new window. {ip} is substituted with a real ip. settings.geolink=Link to an external geolocation service settings.geolinkparams.description=Window size and toolbars hiding settings.geolinkparams=Geolocation window options settings.host.description=Destination for you company name or logo link settings.host=URL of your website +settings.invitationlifetime.description=Specify the lifetime of invitation in seconds. Default is 60 seconds. +settings.invitationlifetime=Invitation lifetime settings.leavemessage_captcha.description=Protection against automated spam (captcha) settings.leavemessage_captcha=Force visitor to enter verification code when leaving message settings.logo.description=Enter http address of your company logo @@ -466,10 +480,14 @@ settings.survey.askmail=Ask visitor e-mail settings.survey.askmessage.description=Show/hide initial question field in the survey settings.survey.askmessage=Show initial question field settings.title=Messenger settings +settings.trackinglifetime.description=Specify the lifetime of old visitor's tracks in seconds. Default is 600 seconds. +settings.trackinglifetime=Track lifetime settings.usercanchangename.description=Turn off to hide edit box from chat window settings.usercanchangename=Allows users to change their names settings.usernamepattern.description=How to build visitor identifying string from {name}, {id} or {addr}. Default: {name} settings.usernamepattern=Visitor's identifier +settings.visitorslimit.description=Specify the number of items to display in tracked visitors list. Default is 20. Set 0 for all visitors (not recommended). +settings.visitorslimit=Limit for tracked visitors list settings.wrong.email=Enter proper email address settings.wrong.onehostconnections="Max number of threads" field should be number site.title=mibew.org @@ -499,6 +517,12 @@ topMenu.logoff=Exit topMenu.main=Home topMenu.users.nomenu=without menu topMenu.users=Visitors +tracked.date=Visit time +tracked.empty.referrer=direct visit +tracked.intro=This page displays tracked history of visitor's activity on site. +tracked.link=Visited page +tracked.path=Tracked path of visitor +tracked.visitor.came.from=Visitor came from translate.direction=Direction: translate.show.all=All strings translate.show.foradmin=Strings for administrator @@ -516,3 +540,15 @@ updates.intro=Messenger updates. updates.latest=Latest version: updates.news=News: updates.title=Updates +visitors.how_to=To invite the visitor to chat click on his/her name in the list. +visitors.intro=The table below represents a list of visitors ready to chat on your site. +visitors.no_visitors=There are no visitors ready to chat on your site at present time +visitors.table.head.contactid=Visitor's address +visitors.table.head.etc=Misc +visitors.table.head.firsttimeonsite=First seen +visitors.table.head.invitations=Invitations / Chats +visitors.table.head.invitationtime=Invitation time +visitors.table.head.invited.by=Invited by +visitors.table.head.lasttimeonsite=Last seen +visitors.table.head.name=Name +visitors.title=Visitors on site diff --git a/src/messenger/webim/locales/names/level1 b/src/messenger/webim/locales/names/level1 index 2a6ac745..cecc2135 100644 --- a/src/messenger/webim/locales/names/level1 +++ b/src/messenger/webim/locales/names/level1 @@ -33,6 +33,7 @@ chat.window.send_message_short chat.window.title.agent chat.window.title.user chat.window.toolbar.mail_history +chat.window.toolbar.mute chat.window.toolbar.redirect_user chat.window.toolbar.refresh company.title @@ -46,6 +47,7 @@ harderrors.header image.chat.history image.chat.message image.chat.sprite +invitation.message leavemail.body leavemail.subject leavemessage.close diff --git a/src/messenger/webim/locales/names/level2 b/src/messenger/webim/locales/names/level2 index 2542d21a..a9cdf37b 100644 --- a/src/messenger/webim/locales/names/level2 +++ b/src/messenger/webim/locales/names/level2 @@ -43,6 +43,7 @@ chat.thread.state_closed chat.thread.state_loading chat.thread.state_wait chat.thread.state_wait_for_another_agent +chat.visitor.invitation.accepted clients.how_to clients.intro clients.no_clients @@ -75,6 +76,8 @@ image.button.save image.button.search install.newfeatures install.updatedb +invitation.sent +invitation.title lang.choose leftMenu.client_agents leftMenu.client_gen_button @@ -102,6 +105,7 @@ page.analysis.search.head_messages page.analysis.search.head_name page.analysis.search.head_operator page.analysis.search.head_time +page.analysis.trackedpath.title page.analysis.userhistory.intro page.analysis.userhistory.title page.gen_button.default_group @@ -136,7 +140,9 @@ pending.table.head.operator pending.table.head.state pending.table.head.total pending.table.head.waittime +pending.table.invite pending.table.speak +pending.table.tracked pending.table.view permission.admin permission.takeover @@ -197,3 +203,21 @@ topMenu.logoff topMenu.main topMenu.users topMenu.users.nomenu +tracked.date +tracked.empty.referrer +tracked.intro +tracked.link +tracked.path +tracked.visitor.came.from +visitors.how_to +visitors.intro +visitors.no_visitors +visitors.table.head.contactid +visitors.table.head.etc +visitors.table.head.firsttimeonsite +visitors.table.head.invitations +visitors.table.head.invitationtime +visitors.table.head.invited.by +visitors.table.head.lasttimeonsite +visitors.table.head.name +visitors.title diff --git a/src/messenger/webim/locales/ru/properties b/src/messenger/webim/locales/ru/properties index 677c4d6e..56c1967a 100644 --- a/src/messenger/webim/locales/ru/properties +++ b/src/messenger/webim/locales/ru/properties @@ -78,6 +78,7 @@ chat.thread.state_wait= chat.thread.state_wait_for_another_agent=Ожидание оператора chat.visitor.email=E-Mail: {0} chat.visitor.info=О Посетителе: {0} +chat.visitor.invitation.accepted=Посетитель принял приглашение от оператора {0} chat.wait=Пожалуйста, подождите немного, к Вам присоединится оператор.. chat.window.chatting_with=Вы общаетесь с: chat.window.close_title=Закрыть диалог @@ -92,6 +93,7 @@ chat.window.title.user=Mibew chat.window.toolbar.mail_history=Отправить историю диалога по электронной почте chat.window.toolbar.redirect_user=Перенаправить посетителя другому оператору chat.window.toolbar.refresh=Обновить содержимое диалога +chat.window.toolbar.mute=Вкл/выкл звук clients.how_to=Для ответа посетителю кликните на соответствующее имя в списке. clients.intro=На этой странице можно просмотреть список ожидающих ответа посетителей. clients.no_clients=В этой очереди ожидающих посетителей нет @@ -151,6 +153,7 @@ form.field.login.description= form.field.login=Логин form.field.mail.description=Для уведомлений и восстановления пароля. form.field.mail=Адрес электронной почты +form.field.mail.description=Для получения извещений и восстановления пароля. form.field.message=Сообщение form.field.name=Ваше имя form.field.password.description=Введите новый пароль или оставьте поле пустым, чтобы сохранить старый. @@ -200,6 +203,9 @@ install.updatedb= installed.login_link=Войти в систему installed.message=Установка успешно завершена. installed.notice=Вы можете войти в систему как admin с пустым паролем.

!!! В целях безопасности, удалите, пожалуйста, каталог {0} с вашего сервера и поменяйте пароль. +invitation.message=Здравствуйте! Могу ли я Вам помочь? +invitation.sent=Приглашение отправлено посетителю. Пожалуйста, немного подождите. +invitation.title=Приглашение lang.choose=Выберите ваш язык leavemail.body=Ваш посетитель '{0}' оставил сообщение:\n\n{2}\n\nЕmail: {1}\n{3}\n--- \nС уважением,\nВаш Веб Мессенджер leavemail.subject=Вопрос от {0} @@ -248,6 +254,7 @@ page.analysis.search.head_messages= page.analysis.search.head_name=Имя page.analysis.search.head_operator=Оператор page.analysis.search.head_time=Время в диалоге +page.analysis.trackedpath.title=Отслеженный путь посетителя page.analysis.userhistory.intro=На данной странице Вы можете увидеть все диалоги с Вашим посетителем. page.analysis.userhistory.title=История диалогов page.chat.old_browser.close=Закрыть... @@ -366,7 +373,9 @@ pending.table.head.operator= pending.table.head.state=Состояние pending.table.head.total=Общее время pending.table.head.waittime=Время ожидания +pending.table.invite=Отправить приглашение к диалогу pending.table.speak=Нажмите для того, чтобы обслужить посетителя +pending.table.tracked=Отслеженный путь посетителя pending.table.view=Подключиться к диалогу в режиме просмотра permission.admin=Администрирование системы: настройка, управление операторами, генерация кнопки permission.modifyprofile=Возможность изменять свой профиль @@ -422,6 +431,8 @@ settings.enablessl.description= settings.enablessl=Разрешать защищенные соединения (SSL) settings.enablestatistics.description=Добавляет страницу с отчетами по использованию мессенджера. settings.enablestatistics=Включить функцию "Статистика" +settings.enabletracking.description=Добавляет функцию отслеживания перемещений посетителей по Вашему сайту и возможность отправки им приглашений к диалогу. +settings.enabletracking=Включить функцию "Отслеживание и приглашение" settings.forcessl.description=Показывать чаты используя только защищенное соединение settings.forcessl=Принудительно переводить все чаты в защищенный режим settings.frequencychat.description=Укажите частоту опроса сервера в секундах. По умолчанию, 2 секунды. @@ -430,12 +441,16 @@ settings.frequencyoldchat.description= settings.frequencyoldchat=Периодичность обновления всего диалога для старых браузеров settings.frequencyoperator.description=Укажите частоту опроса сервера в секундах. По умолчанию, 2 секунды. settings.frequencyoperator=Периодичность обновления консоли оператора +settings.frequencytracking.description=Укажите частоту опроса блока слежения за посетителями в секундах. По умолчанию, 10 секунд. +settings.frequencytracking=Периодичность опроса блока слежения settings.geolink.description=На любом IP адресе можно будет открыть небольшое окно с геоинформацией. Можно использовать {ip}. settings.geolink=Ссылка на внешний geolocation сервис settings.geolinkparams.description=Размер окна и наличие тулбаров settings.geolinkparams=Опции для окна с геоинформацией settings.host.description=Будет открываться по нажатию на логотип или название компании в чат окне settings.host=Ссылка на ваш веб сайт +settings.invitationlifetime.description=Укажите срок действия приглашения к диалогу в секундах. По умолчанию, 60 секунд. +settings.invitationlifetime=Срок действия приглашения settings.leavemessage_captcha.description=Защита от автоматизированного спама (captcha) settings.leavemessage_captcha=Разрешать оставлять сообщение только после ввода специального кода с картинки settings.logo.description=Введите ссылку на логотип компании @@ -458,10 +473,14 @@ settings.survey.askmail= settings.survey.askmessage.description=Показать/спрятать поле ввода первого вопроса settings.survey.askmessage=Предлагать сразу же задать вопрос settings.title=Настройки мессенджера +settings.trackinglifetime.description=Укажите срок хранения старых отслеженных путей в секундах. По умолчанию, 600 секунд. +settings.trackinglifetime=Срок хранения отслеженных путей settings.usercanchangename.description=Возможность убрать поле смены имени из чат окна settings.usercanchangename=Разрешать посетителям менять имена settings.usernamepattern.description=Укажите как отобразить имя посетителя операторам. Можно использовать {name}, {id} и {addr}. По умолчанию: {name} settings.usernamepattern=Отображаемое имя посетителя +settings.visitorslimit.description=Укажите количество выводимых в списке отслеживаемых посетителей сайта. По умолчанию, 20. Укажите 0 для снятия ограничения (не рекомендуется). +settings.visitorslimit=Ограничение на число выводимых в списке отслеживаемых посетителей settings.wrong.email=Введите правильный адрес электронной почты settings.wrong.onehostconnections=Поле "Максимальное количество диалогов" должно быть числом site.title=mibew.org @@ -491,6 +510,12 @@ topMenu.logoff= topMenu.main=Главная topMenu.users.nomenu=без меню topMenu.users=Посетители +tracked.date=Время визита +tracked.empty.referrer=прямое посещение +tracked.intro=На этой странице отображается отслеженная история активности посетителя сайта. +tracked.link=Посещённая страница +tracked.path=Отслеженный путь посетителя +tracked.visitor.came.from=Посетитель пришёл со страницы translate.direction=Направление перевода: translate.show.all=Все строки translate.show.foradmin=Строки для администратора @@ -508,3 +533,15 @@ updates.intro= updates.latest=Последняя версия: updates.news=Новости: updates.title=Обновления +visitors.how_to=Для приглашения посетителя к диалогу кликните на его или её имя в списке. +visitors.intro=В рсположенной ниже таблице представлен список готовых к диалогу посетителей на Вашем сайте. +visitors.no_visitors=В настоящее время на Вашем сайте нет готовых к диалогу посетителей +visitors.table.head.contactid=Адрес посетителя +visitors.table.head.etc=Разное +visitors.table.head.firsttimeonsite=Впервые замечен +visitors.table.head.invitations=Приглашений / Диалогов +visitors.table.head.invitationtime=Время приглашения +visitors.table.head.invited.by=Кем приглашён +visitors.table.head.lasttimeonsite=Последний раз замечен +visitors.table.head.name=Имя +visitors.title=Посетители на сайте diff --git a/src/messenger/webim/operator/features.php b/src/messenger/webim/operator/features.php index ad193830..147b10b9 100644 --- a/src/messenger/webim/operator/features.php +++ b/src/messenger/webim/operator/features.php @@ -29,7 +29,7 @@ $page = array('agentId' => ''); $errors = array(); $options = array( - 'enableban', 'usercanchangename', 'enablegroups', 'enablestatistics', + 'enableban', 'usercanchangename', 'enablegroups', 'enablestatistics', 'enabletracking', 'enablessl', 'forcessl', 'enablepresurvey', 'surveyaskmail', 'surveyaskgroup', 'surveyaskmessage', 'enablepopupnotification', 'showonlineoperators', diff --git a/src/messenger/webim/operator/invitationstate.php b/src/messenger/webim/operator/invitationstate.php new file mode 100644 index 00000000..191ceeb6 --- /dev/null +++ b/src/messenger/webim/operator/invitationstate.php @@ -0,0 +1,45 @@ +'; +echo '' . ($invitation['invited'] ? $invitation['invited'] : '0') . ''; +echo '' . ($invitation['threadid'] ? $invitation['threadid'] : '0') . ''; +echo ''; +exit; + +?> diff --git a/src/messenger/webim/operator/invite.php b/src/messenger/webim/operator/invite.php new file mode 100644 index 00000000..17c35504 --- /dev/null +++ b/src/messenger/webim/operator/invite.php @@ -0,0 +1,44 @@ + diff --git a/src/messenger/webim/operator/performance.php b/src/messenger/webim/operator/performance.php index 31d52bba..be9ffb29 100644 --- a/src/messenger/webim/operator/performance.php +++ b/src/messenger/webim/operator/performance.php @@ -30,7 +30,9 @@ $errors = array(); $options = array( 'online_timeout', 'updatefrequency_operator', 'updatefrequency_chat', - 'updatefrequency_oldchat', 'max_connections_from_one_host'); + 'updatefrequency_oldchat', 'max_connections_from_one_host', + 'updatefrequency_tracking', 'visitors_limit', 'invitation_lifetime', + 'tracking_lifetime' ); loadsettings(); $params = array(); @@ -64,6 +66,30 @@ if (isset($_POST['onlinetimeout'])) { $errors[] = getlocal("settings.wrong.onehostconnections"); } + if ($settings['enabletracking']) { + + $params['updatefrequency_tracking'] = getparam('frequencytracking'); + if (!is_numeric($params['updatefrequency_tracking'])) { + $errors[] = wrong_field("settings.frequencytracking"); + } + + $params['visitors_limit'] = getparam('visitorslimit'); + if (!is_numeric($params['visitors_limit'])) { + $errors[] = wrong_field("settings.visitorslimit"); + } + + $params['invitation_lifetime'] = getparam('invitationlifetime'); + if (!is_numeric($params['invitation_lifetime'])) { + $errors[] = wrong_field("settings.invitationlifetime"); + } + + $params['tracking_lifetime'] = getparam('trackinglifetime'); + if (!is_numeric($params['tracking_lifetime'])) { + $errors[] = wrong_field("settings.trackinglifetime"); + } + + } + if (count($errors) == 0) { foreach ($options as $opt) { $settings[$opt] = $params[$opt]; @@ -79,6 +105,18 @@ $page['formfrequencyoperator'] = $params['updatefrequency_operator']; $page['formfrequencychat'] = $params['updatefrequency_chat']; $page['formfrequencyoldchat'] = $params['updatefrequency_oldchat']; $page['formonehostconnections'] = $params['max_connections_from_one_host']; + +if ($settings['enabletracking']) { + + $page['formfrequencytracking'] = $params['updatefrequency_tracking']; + $page['formvisitorslimit'] = $params['visitors_limit']; + $page['forminvitationlifetime'] = $params['invitation_lifetime']; + $page['formtrackinglifetime'] = $params['tracking_lifetime']; + +} + +$page['enabletracking'] = $settings['enabletracking']; + $page['stored'] = isset($_GET['stored']); prepare_menu($operator); diff --git a/src/messenger/webim/operator/tracked.php b/src/messenger/webim/operator/tracked.php new file mode 100644 index 00000000..91d63c88 --- /dev/null +++ b/src/messenger/webim/operator/tracked.php @@ -0,0 +1,69 @@ + $v) { + $page['history'][] = array( 'date' => date_to_text($k), + 'link' => htmlspecialchars($v) ); +} +start_html_output(); +require('../view/tracked.php'); +?> \ No newline at end of file diff --git a/src/messenger/webim/operator/update.php b/src/messenger/webim/operator/update.php index 066b5cc4..b23e6cdf 100644 --- a/src/messenger/webim/operator/update.php +++ b/src/messenger/webim/operator/update.php @@ -24,6 +24,7 @@ require_once('../libs/chat.php'); require_once('../libs/userinfo.php'); require_once('../libs/operator.php'); require_once('../libs/groups.php'); +require_once('../libs/track.php'); $operator = get_logged_in(); if (!$operator) { @@ -167,9 +168,97 @@ function print_operators() echo ""; } +function visitor_to_xml($visitor, $link) +{ + $result = ""; + +// $result .= "" . htmlspecialchars($visitor['userid']) . ""; + $result .= "" . htmlspecialchars($visitor['username']) . ""; + + $result .= ""; + $result .= "" . $visitor['unix_timestamp(lasttime)'] . "000"; +// $result .= "" . htmlspecialchars($visitor['entry']) . ""; + +// $result .= ""; +// $path = track_retrieve_path($visitor); +// ksort($path); +// foreach ($path as $k => $v) { +// $result .= "" . htmlspecialchars($v) . ""; +// } +// $result .= ""; + + $details = track_retrieve_details($visitor); + $userAgent = get_useragent_version($details['user_agent']); + $result .= "" . $userAgent . ""; + $result .= "" . htmlspecialchars(get_user_addr($details['remote_host'])) . ""; + + $result .= "" . $visitor['invitations'] . ""; + $result .= "" . $visitor['chats'] . ""; + + $result .= ""; + if ($visitor['invited']) { + $result .= "" . $visitor['unix_timestamp(invitationtime)'] . "000"; + $operator = get_operator_name(operator_by_id_($visitor['invitedby'], $link)); + $result .= "" . htmlspecialchars(htmlspecialchars($operator)) . ""; + } + $result .= ""; + + $result .= ""; + return $result; +} + +function print_visitors() +{ + global $webim_encoding, $settings, $state_closed, $state_left, $mysqlprefix; + + $link = connect(); + +// Remove old visitors' tracks + $query = "DELETE FROM ${mysqlprefix}chatsitevisitor WHERE (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(lasttime)) > " . $settings['tracking_lifetime'] . + " AND (threadid IS NULL OR (SELECT count(*) FROM ${mysqlprefix}chatthread WHERE threadid = ${mysqlprefix}chatsitevisitor.threadid" . + " AND istate <> $state_closed AND istate <> $state_left) = 0)"; + perform_query($query, $link); + +// Remove old invitations + $query = "UPDATE ${mysqlprefix}chatsitevisitor SET invited = 0, invitationtime = NULL, invitedby = NULL" . + " WHERE threadid IS NULL AND (UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - UNIX_TIMESTAMP(invitationtime)) > " . + $settings['invitation_lifetime']; + perform_query($query, $link); + +// Remove associations of visitors with closed threads + $query = "UPDATE ${mysqlprefix}chatsitevisitor SET threadid = NULL WHERE threadid IS NOT NULL AND" . + " (SELECT count(*) FROM ${mysqlprefix}chatthread WHERE threadid = ${mysqlprefix}chatsitevisitor.threadid" . + " AND istate <> $state_closed AND istate <> $state_left) = 0"; + perform_query($query, $link); + + $output = array(); + + $query = "SELECT visitorid, userid, username, unix_timestamp(firsttime), unix_timestamp(lasttime), " . + "entry, path, details, invited, unix_timestamp(invitationtime), invitedby, invitations, chats " . + "FROM ${mysqlprefix}chatsitevisitor " . + "WHERE threadid IS NULL " . + "ORDER BY invited, lasttime DESC, invitations"; + $query .= ($settings['visitors_limit'] == '0') ? "" : " LIMIT " . $settings['visitors_limit']; + + $rows = select_multi_assoc($query, $link); + foreach ($rows as $row) { + $visitor = visitor_to_xml($row, $link); + $output[] = $visitor; + } + + mysql_close($link); + + echo ""; + foreach ($output as $thr) { + print myiconv($webim_encoding, "utf-8", $thr); + } + echo ""; +} + $since = verifyparam("since", "/^\d{1,9}$/", 0); $status = verifyparam("status", "/^\d{1,2}$/", 0); $showonline = verifyparam("showonline", "/^1$/", 0); +$showvisitors = verifyparam("showvisitors", "/^1$/", 0); $link = connect(); loadsettings_($link); @@ -185,6 +274,9 @@ if ($showonline) { print_operators(); } print_pending_threads($groupids, $since); +if ($showvisitors) { + print_visitors(); +} echo ''; notify_operator_alive($operator['operatorid'], $status); exit; diff --git a/src/messenger/webim/operator/users.php b/src/messenger/webim/operator/users.php index dba8d1f4..97160e24 100644 --- a/src/messenger/webim/operator/users.php +++ b/src/messenger/webim/operator/users.php @@ -39,6 +39,7 @@ $page['showpopup'] = $settings['enablepopupnotification'] == '1' ? "1" : "0"; $page['frequency'] = $settings['updatefrequency_operator']; $page['istatus'] = $status; $page['showonline'] = $settings['showonlineoperators'] == '1' ? "1" : "0"; +$page['showvisitors'] = $settings['enabletracking'] == '1' ? "1" : "0"; prepare_menu($operator); start_html_output(); diff --git a/src/messenger/webim/styles/default/images/buttons/tracked.gif b/src/messenger/webim/styles/default/images/buttons/tracked.gif new file mode 100644 index 0000000000000000000000000000000000000000..afe58f588a583a6b476ccb3d6b90edb79a3108ac GIT binary patch literal 1232 zcmeIx>rYz+7zXgeU<(iejC7d@ENnO&n=T3?LYx8Gp3+jfg3JOFWhk8>Y?R9aVUm=t zAk49dYY9x;xQ#$Cgv@D-n#ph`lVD;dA%JwHJ-q=fZRzD)dtSRg!2iG}zdYaGFK_bX ziv(HORq;qXVjV-)&i?Z}XLTb-znQbF%f+zV6&=^4pyEe5V0a|Ke zR;hPe>a-SlZ9&CBzO549Zi#dIynpAs&o1*jf=cn-QruDI-z~!(<@jE?+j#-^U9h{} z$K4f#`vYR{!ywWVR7rX+lEg))r;7Aek-m>8-^Y}{n)1sjTu$J@z7#|gH8fF6leM(- zGERO<6Lqxn3PIMtI0#^fp)&ScYz}qRd zEkInO*>)DLv2G;+pRv%vdQ>DRS+AOeP8QSvy#P0W>|>x0pda8iz#za7z#V|E0lopa z2QUV{Nya)lAb`B~;^@UtkZ=}(h(zJsNZ$34xRVu6=M3}R zu_>vXLD%h9-f7(3n9j&QmzdSCJ|_yb6sB}>@`@uTdgI2?8?o`n!op*Q&wTQvEMi}+ z@mFXubm!7R8B_(QfB~wi&-jY2~WTtd2$&!v8(fpqB^o(|S=6)i%#C>B*bCu#m%dLMV z%<^uk*Y5BReEy(*RkPOK+ta@zP=_}@)OJTB^1p{B%74~M{dVr2LOXgrZ*5#Qpy=RF z3SZh?s$3No4Tuk?iJ~6MO3%)ZghYmD_M@D_Fn4HFX!n>Z@>G5Q0wV8l^J3EHH>;vD zOmn|QXa3@P9CtT)lwUrGbgIG*#42(_6O_rS@FRsvCGvXioTz-Heyls@^sqt|k)l?1 g?&q8+n%`H_qIxEcdoTOARwiiqYoH>U6N|k4FI5dPy8r+H literal 0 HcmV?d00001 diff --git a/src/messenger/webim/styles/default/templates/chat.tpl b/src/messenger/webim/styles/default/templates/chat.tpl index 979ddfd7..dbc777d3 100644 --- a/src/messenger/webim/styles/default/templates/chat.tpl +++ b/src/messenger/webim/styles/default/templates/chat.tpl @@ -60,6 +60,13 @@ var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",freque } .ilog { background-position: 0px 0px;width: 20px; height: 80px; } .imessage { background-position: 0px -82px;width: 20px; height: 85px; } +.itracked { + background: transparent url(${tplroot}/images/buttons/tracked.gif) no-repeat scroll 0px 0px; + width: 25px; height: 25px; + -moz-background-clip: -moz-initial; + -moz-background-origin: -moz-initial; + -moz-background-inline-policy: -moz-initial; +} @@ -175,10 +182,13 @@ ${endif:canpost} ${if:historyParams} History  ${endif:historyParams} +${if:trackedParams} + Tracked path  +${endif:trackedParams} ${endif:agent} - + Sound  - + Refresh  ${if:sslLink} diff --git a/src/messenger/webim/styles/original/images/buttons/tracked.gif b/src/messenger/webim/styles/original/images/buttons/tracked.gif new file mode 100644 index 0000000000000000000000000000000000000000..b7250b1c37fe759cf76cea2851f850876c29c929 GIT binary patch literal 1268 zcmdth`A?Gv90u?gCs2k)j?9RGrG*6;lgZ3x8AaU5!bP!gF( zI3&}J#crt##vm1t;TGHm#vtm3WFed_y$iOK(&Ih)_WiE@8+-D}^ZWC|lPcgPCKZPv zVTkcpWZ~l_W%B%TvT8N?-xa1-%bZ(b=~h^JCCi{@skE#`J$qimR;xHBEk~{8X!M*F z71yNVuB~#{_1tAGSEJ{yXt`PgSGCGpSMe-r-nx#bQ>VUE^UZ3$MZ-56_-YN`V&rQz z0;^tNG77XNfnJ+t)u)-Y!cCpfsuOOSgr+s2Q7^LTMOy}u-Eh>)VMwc&gm)=CsF zb7SRh>lq9$cM}yPQArYKNcUNiJWFhy!`xLQ`6cP7!O3cpJm>M8_jqbORILYXAgDSI zcEL?GP;h~=HDYj)f=iUW35Q0?A;sY`1yX=kfUg0+PQrD7c7RTRTL8BKz6JOW;Cp~O z06&7Whj8@}AP2P14ZVQ%yP*%DAK(`t21ytM7zVfxFbXgR@EgDcz`O_+GGQ?n7V}}r zs{mHSpp<|CVB;Qa41p2A_6OJ|!SOdZ{sHGKxE28QS^{(#JQz?U03iS0FsNX5bxCne ziI`qnS|g#S3Pc$Q1K;k0Ab{+9wfogk5E_L*Ksa9^OKFy8_2o|~eqbLP$!OgxDVv+T zx~rrs1e>0FThO3cevtjejqb!M_tvXOlRCt$?UD9?4E1iyjw6--QK}|I&t^>TX{{d{nRlqEUCA z@t8-T^BuSoEqW+^a)4HOgZ4%w zn)FCtA&<#?*h^)do?VED2C-3hoAZ%ZeY~UOwas9 z-^zJMD09-nxYB#dulCQkF~tQn3~mTp*R^|Bf~1j!w5J67hNh56vvjmqHu3sNc>+^h zNX|6xNEq2Oxg*J}VDH?2Q6Y`t#|DQ*GiCJ4KHI}*{`8|?p*Q)5(&@~=po)&0%)##a zt$RNitC|Riz8192Z+C`_=@WS5h2Y2l?ftZUqeV5r`3mWQpxFLiye)o2vGpXS&XAPB HL_Yct*&ca_ literal 0 HcmV?d00001 diff --git a/src/messenger/webim/styles/original/templates/chat.tpl b/src/messenger/webim/styles/original/templates/chat.tpl index afcc5ef2..df7b1327 100644 --- a/src/messenger/webim/styles/original/templates/chat.tpl +++ b/src/messenger/webim/styles/original/templates/chat.tpl @@ -40,6 +40,13 @@ var threadParams = { servl:"${webimroot}/thread.php",wroot:"${webimroot}",freque } .ilog { background-position: 0px 0px;width: 20px; height: 80px; } .imessage { background-position: 0px -82px;width: 20px; height: 85px; } +.itracked { + background: transparent url(${tplroot}/images/buttons/tracked.gif) no-repeat scroll 0px 0px; + width: 25px; height: 25px; + -moz-background-clip: -moz-initial; + -moz-background-origin: -moz-initial; + -moz-background-inline-policy: -moz-initial; +} @@ -172,8 +179,11 @@ ${endif:canpost} ${if:historyParams} History  ${endif:historyParams} +${if:trackedParams} + Tracked path  +${endif:trackedParams} ${endif:agent} - + Sound  diff --git a/src/messenger/webim/styles/simplicity/images/buttons/tracked.gif b/src/messenger/webim/styles/simplicity/images/buttons/tracked.gif new file mode 100644 index 0000000000000000000000000000000000000000..42fe9cf9edfc4ea705e766615aa2c447efee5262 GIT binary patch literal 708 zcmZ?wbhEHb6lM@+IOfUl!gk#&r|tJWR=jiFe>HURC*MEzFt``2Uw?EE*`g`uDU-LfvpZo9Y($_E6 zT>i88^WUXk|F8J}f93zTJMRD7{NexB|6dQj`F7;}{{#Pjo&56u#Q*;{{sRHSPymYm z1f7dg6H8K46v{J8G8EiBeFGR2f3h&LGt@KafP4UoCKwziys;o4>z-_706mJI5>8Rs2BVd5M0Q7GTJy(>%)=m2t6i`OeKzkUk${msg:page.analysis.userhistory.title} ${endif:historyParams} + ${if:trackedParams} + + ${msg:page.analysis.trackedpath.title} + + ${endif:trackedParams} ${endif:agent} - Sound On/Off + ${msg:chat.window.toolbar.mute} ${msg:chat.window.toolbar.refresh} diff --git a/src/messenger/webim/view/features.php b/src/messenger/webim/view/features.php index 9b8361a4..559411a1 100644 --- a/src/messenger/webim/view/features.php +++ b/src/messenger/webim/view/features.php @@ -124,6 +124,15 @@ require_once('inc_errors.php');
+
+
+
+ /> +
+
+
+
+
diff --git a/src/messenger/webim/view/invite.php b/src/messenger/webim/view/invite.php new file mode 100644 index 00000000..34dac425 --- /dev/null +++ b/src/messenger/webim/view/invite.php @@ -0,0 +1,48 @@ + + + + + + + + +
+ + \ No newline at end of file diff --git a/src/messenger/webim/view/pending_users.php b/src/messenger/webim/view/pending_users.php index f4e6d253..ccaa812e 100644 --- a/src/messenger/webim/view/pending_users.php +++ b/src/messenger/webim/view/pending_users.php @@ -34,12 +34,16 @@ var localized = new Array( "", "", "", - "" + "", + "", + "" ); var updaterOptions = { url:"/operator/update.php",wroot:"", agentservl:"/operator/agent.php", frequency:, istatus:, - noclients:"", havemenu: , showpopup: , showonline: }; + noclients:"", havemenu: , showpopup: , + showonline: , showvisitors: , novisitors: "", + trackedservl:"/operator/tracked.php", inviteservl:"/operator/invite.php" }; //--> + +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + +
Loading....
+
+
diff --git a/src/messenger/webim/view/performance.php b/src/messenger/webim/view/performance.php index 51f2a32e..937a2224 100644 --- a/src/messenger/webim/view/performance.php +++ b/src/messenger/webim/view/performance.php @@ -90,6 +90,44 @@ require_once('inc_errors.php');
+ +
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+ +
+
+
+ +
+
+
+
+ +
diff --git a/src/messenger/webim/view/tracked.php b/src/messenger/webim/view/tracked.php new file mode 100644 index 00000000..f68b66ec --- /dev/null +++ b/src/messenger/webim/view/tracked.php @@ -0,0 +1,89 @@ + + + + +

+ +
+ + +
+ +
+ : +
+
+ + + + + +
+
+
+ +
+ + + + + + + + + 0) { + foreach( $page['history'] as $step ) { +?> + + + + + + +
+ + + +
+ + + +
+ +
+
+ + + \ No newline at end of file