diff --git a/src/messenger/webim/chat.css b/src/messenger/webim/chat.css
deleted file mode 100644
index c2ff8ba4..00000000
--- a/src/messenger/webim/chat.css
+++ /dev/null
@@ -1,195 +0,0 @@
-a {
- text-decoration: underline;
-}
-
-a:hover {
- text-decoration: none;
-}
-
-a img {
- font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
- font-size: 11px;
-}
-
-form {
- margin-bottom: 0px;
- margin-top: 0px;
-}
-
-div#typingdiv, div#engineinfo {
- border: 0px solid gray;
- font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
- font-size: 11px;
- padding-right: 10px;
- padding-left: 10px;
- background: #fafafa;
- color: #B11E23;
-}
-
-.bgcn {
- background-position: center;
- background-repeat: no-repeat;
-}
-
-.bgrn {
- background-position: right;
- background-repeat: no-repeat;
-}
-
-.bgcy {
- background-position: center;
- background-repeat: repeat-y;
-}
-
-.bgry {
- background-position: right;
- background-repeat: repeat-y;
-}
-
-.bgly {
- background-position: left;
- background-repeat: repeat-y;
-}
-
-.bgbx {
- background-position: bottom;
- background-repeat: repeat-x;
-}
-
-.window {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 12px;
- color: #000000;
-}
-
-.window a {
- color: #880000;
-}
-
-.window h1 {
- margin-top: 0px;
- margin-bottom: 0px;
- font-size: 18px;
- color: #000000;
- font-weight: normal;
-}
-
-.window h2 {
- margin-top: 0px;
- margin-bottom: 0px;
- font-size: 12px;
- color: #000000;
-}
-
-.text {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 12px;
- color: #000000;
-}
-
-.text span.grey {
- color: #787878;
-}
-
-.www a {
- font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
- font-size: 10px;
- color: #FFFFFF;
- text-decoration: none;
-}
-
-.message {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 12px;
- color: #4F4F4F;
- padding-left: 3px;
- padding-top: 3px;
- padding-bottom: 3px;
- padding-right: 3px;
- line-height: 17px;
-}
-
-.message span.time {
- color: #000000;
-}
-
-.message span.nuser {
- color: #B11E23;
- font-weight: bold;
-}
-
-.message span.nagent {
- font-weight: bold;
-}
-
-.message span.minf {
- color: #1E48B1;
- font-size: 11px;
-}
-
-.message span.mevent {
- color: #A1A1A1;
- font-size: 11px;
-}
-
-.message span.mhidden {
- color: #A1A1A1;
- font-size: 11px;
-}
-
-.message span.mconn {
- color: #A1A1A1;
- font-size: 11px;
-}
-
-textarea.message {
- width: 100%;
- height: 100%;
- border: 0px solid Blue;
- overflow: auto;
- margin-left: 3px;
- margin-top: 3px;
- margin-bottom: 3px;
- margin-right: 5px;
-}
-
-.username {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 12px;
- color: #383838;
- padding-left: 3px;
-}
-
-input.username {
- border: 1px solid #878787;
-}
-
-.answer {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 11px;
- color: #575757;
- width: 170px;
-}
-
-.submit a {
- font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
- font-size: 11px;
- color: #000000;
- text-decoration: none;
-}
-
-.button a {
- font-family: Arial, Helvetica, sans-serif;
- font-size: 11px;
- color: #666666;
-}
-
-.copyr {
- font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
- font-size: 10px;
- color: #929292;
-}
-
-.copyr a {
- color: #929292;
-}
\ No newline at end of file
diff --git a/src/messenger/webim/client.php b/src/messenger/webim/client.php
index 19494b67..5f458315 100644
--- a/src/messenger/webim/client.php
+++ b/src/messenger/webim/client.php
@@ -18,12 +18,26 @@ require_once('libs/operator.php');
require_once('libs/groups.php');
require_once('libs/expand.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 processed");
+ }
+ exit;
+ }
+}
+
if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
$chatstyle = verifyparam( "style", "/^\w+$/", "");
$info = getgetparam('info');
$email = getgetparam('email');
$thread = NULL;
+ $firstmessage = NULL;
if( isset($_SESSION['threadid']) ) {
$thread = reopen_thread($_SESSION['threadid']);
}
@@ -39,7 +53,6 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
exit;
}
- loadsettings();
$groupid = "";
if($settings['enablegroups'] == '1') {
$groupid = verifyparam( "group", "/^\d{1,8}$/", "");
@@ -51,11 +64,36 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
}
}
+ $visitor = visitor_from_request();
$referer = isset($_GET['url']) ? $_GET['url'] :
(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : "");
if(isset($_GET['referrer']) && $_GET['referrer']) {
$referer .= "\n".$_GET['referrer'];
}
+
+ if($settings['enablepresurvey'] == '1') {
+ if(isset($_POST['survey']) && $_POST['survey'] == 'on') {
+ $firstmessage = getparam("message");
+ $info = getparam("info");
+ $email = getparam("email");
+ 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, $data, time()+60*60*24*365);
+ $visitor['name'] = $newname;
+ }
+ }
+ $referer = urldecode(getparam("referrer"));
+ } else {
+ $page = array();
+ setup_logo();
+ setup_survey($visitor['name'], $email, $groupid, $info, $referer);
+ expand("styles", getchatstyle(), "survey.tpl");
+ exit;
+ }
+ }
+
$extAddr = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_X_FORWARDED_FOR']) &&
$_SERVER['HTTP_X_FORWARDED_FOR'] != $_SERVER['REMOTE_ADDR']) {
@@ -63,7 +101,6 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
}
$userbrowser = $_SERVER['HTTP_USER_AGENT'];
$remoteHost = isset($_SERVER['REMOTE_HOST']) ? $_SERVER['REMOTE_HOST'] : $extAddr;
- $visitor = visitor_from_request();
$thread = create_thread($groupid,$visitor['name'], $remoteHost, $referer,$current_locale,$visitor['id'], $userbrowser);
$_SESSION['threadid'] = $thread['threadid'];
if( $referer ) {
@@ -76,6 +113,12 @@ if( !isset($_GET['token']) || !isset($_GET['thread']) ) {
if($info) {
post_message($thread['threadid'],$kind_for_agent,getstring2('chat.visitor.info',array($info)));
}
+ if($firstmessage) {
+ $postedid = post_message($thread['threadid'],$kind_user,$firstmessage,$visitor['name']);
+ $link = connect();
+ commit_thread( $thread['threadid'], array('shownmessageid' => $postedid), $link);
+ mysql_close($link);
+ }
}
$threadid = $thread['threadid'];
$token = $thread['ltoken'];
diff --git a/src/messenger/webim/libs/chat.php b/src/messenger/webim/libs/chat.php
index 50a6fae7..7736b973 100644
--- a/src/messenger/webim/libs/chat.php
+++ b/src/messenger/webim/libs/chat.php
@@ -54,8 +54,8 @@ function post_message_($threadid,$kind,$message,$link,$from=null,$utime=null,$op
"insert into chatmessage (threadid,ikind,tmessage,tname,agentId,dtmcreated) values (%s, %s,'%s',%s,%s,%s)",
$threadid,
$kind,
- quote_smart($message,$link),
- $from ? "'".quote_smart($from,$link)."'" : "null",
+ mysql_real_escape_string($message,$link),
+ $from ? "'".mysql_real_escape_string($from,$link)."'" : "null",
$opid ? $opid : "0",
$utime ? "FROM_UNIXTIME($utime)" : "CURRENT_TIMESTAMP" );
@@ -263,6 +263,29 @@ function setup_logo() {
$page['webimHost'] = topage($settings['hosturl']);
}
+function setup_survey($name, $email, $groupid, $info, $referrer) {
+ global $settings, $page;
+
+ $page['formname'] = topage($name);
+ $page['formemail'] = topage($email);
+ $page['formgroupid'] = $groupid;
+ $page['forminfo'] = topage($info);
+ $page['referrer'] = urlencode(topage($referrer));
+
+ if($settings['enablegroups'] == '1' && $settings["surveyaskgroup"] == "1") {
+ $allgroups = get_groups(false);
+ $val = "";
+ foreach($allgroups as $k) {
+ $val .= "";
+ }
+ $page['groups'] = $val;
+ }
+
+ $page['showemail'] = $settings["surveyaskmail"] == "1" ? "1" : "";
+ $page['showmessage'] = $settings["surveyaskmessage"] == "1" ? "1" : "";
+ $page['showname'] = $settings['usercanchangename'] == "1" ? "1" : "";
+}
+
function setup_chatview_for_user($thread,$level) {
global $page, $webimroot, $settings;
loadsettings();
@@ -276,7 +299,7 @@ function setup_chatview_for_user($thread,$level) {
$page['level'] = $level;
$page['ct.chatThreadId'] = $thread['threadid'];
$page['ct.token'] = $thread['ltoken'];
- $page['ct.user.name'] = topage($thread['userName']);
+ $page['ct.user.name'] = htmlspecialchars(topage($thread['userName']));
$page['canChangeName'] = $settings['usercanchangename'] == "1";
$page['chat.title'] = topage($settings['chattitle']);
@@ -304,7 +327,7 @@ function setup_chatview_for_operator($thread,$operator) {
$page['canpost'] = $thread['agentId'] == $operator['operatorid'];
$page['ct.chatThreadId'] = $thread['threadid'];
$page['ct.token'] = $thread['ltoken'];
- $page['ct.user.name'] = topage(get_user_name($thread['userName'],$thread['remote'],$thread['userid']));
+ $page['ct.user.name'] = htmlspecialchars(topage(get_user_name($thread['userName'],$thread['remote'],$thread['userid'])));
$page['chat.title'] = topage($settings['chattitle']);
setup_logo();
@@ -422,7 +445,7 @@ function thread_by_id_($id,$link) {
}
function ban_for_addr_($addr,$link) {
- return select_one_row("select banid,comment from chatban where unix_timestamp(dtmtill) > unix_timestamp(CURRENT_TIMESTAMP) AND address = '".quote_smart($addr,$link)."'", $link );
+ return select_one_row("select banid,comment from chatban where unix_timestamp(dtmtill) > unix_timestamp(CURRENT_TIMESTAMP) AND address = '".mysql_real_escape_string($addr,$link)."'", $link );
}
function thread_by_id($id) {
diff --git a/src/messenger/webim/locales/en/properties b/src/messenger/webim/locales/en/properties
index a258de7f..22c72c7b 100644
--- a/src/messenger/webim/locales/en/properties
+++ b/src/messenger/webim/locales/en/properties
@@ -225,7 +225,7 @@ page.gen_button.choose_locale=Target locale
page.gen_button.choose_style=Chat window style
page.gen_button.code.description=Caution! Please don't change
the code manually because
we don't guarantee that
it will work!
page.gen_button.code=HTML code
-page.gen_button.default_group=All operators
+page.gen_button.default_group=-all operators-
page.gen_button.include_site_name=Include host name into code
page.gen_button.intro=You can generate HTML code to place at your site here.
page.gen_button.sample=Example
@@ -313,6 +313,13 @@ permission.takeover=Take over chat thread
permission.viewthreads=View another operator's chat thread
permissions.intro=Here you can control operator's permissions
permissions.title=Permissions
+presurvey.title=Live support
+presurvey.intro=Thanks for contacting us! To better serve you, please fill out the form below and click the Start Chat button.
+presurvey.name=Name:
+presurvey.mail=Email:
+presurvey.department=Choose Department:
+presurvey.question=Initial Question:
+presurvey.submit=Start Chat
report.bydate.1=Date
report.bydate.2=Chat threads
report.bydate.3=Messages from operators
@@ -344,6 +351,10 @@ 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.enablepresurvey.description=Forces user to fill out a special form to start chat.
+settings.enablepresurvey=Enable "Pre-chat survey"
+settings.forcessl.description=Show chats only through https connection
+settings.forcessl=Force all chats to be secure
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
@@ -354,6 +365,12 @@ settings.logo.description=Enter http address of your company logo
settings.logo=Your company logo
settings.no.title=Please enter your company title
settings.saved=Changes saved
+settings.survey.askgroup.description=Show/hide department selection field in the survey
+settings.survey.askgroup=Allows visitor to choose department/group
+settings.survey.askmail.description=Show/hide email field in the survey
+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.usercanchangename.description=Turn off to hide edit box from chat window
settings.usercanchangename=Allows users to change their names
diff --git a/src/messenger/webim/styles/default/templates/survey.tpl b/src/messenger/webim/styles/default/templates/survey.tpl
new file mode 100644
index 00000000..966f0386
--- /dev/null
+++ b/src/messenger/webim/styles/default/templates/survey.tpl
@@ -0,0 +1,167 @@
+
+
+
+ + + + + + | +