pre-chat survey (only default theme)

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@452 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2009-04-04 23:51:16 +00:00
parent ece83a4cfc
commit 5be4f64cc6
5 changed files with 258 additions and 203 deletions

View File

@ -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;
}

View File

@ -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'];

View File

@ -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 .= "<option value=\"".$k['groupid']."\"".($k['groupid'] == $groupid ? " selected=\"selected\"" : "").">".$k['vclocalname']."</option>";
}
$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) {

View File

@ -225,7 +225,7 @@ page.gen_button.choose_locale=Target locale
page.gen_button.choose_style=Chat window style
page.gen_button.code.description=<strong>Caution!</strong> Please don't change<br/> the code manually because<br/> we don't guarantee that<br/> 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

View File

@ -0,0 +1,167 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>${msg:presurvey.title}</title>
<link rel="shortcut icon" href="${webimroot}/images/favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" type="text/css" href="${tplroot}/chat.css" />
</head>
<style>
#header{
height:50px;
background:url(${tplroot}/images/bg_domain.gif) repeat-x top;
background-color:#5AD66B;
width:99.6%;
margin:0px 0px 20px 0px;
}
#header .mmimg{
background:url(${tplroot}/images/quadrat.gif) bottom left no-repeat;
}
.form td{
background-color:#f4f4f4;
color:#525252;
}
.but{
font-family:Verdana !important;
font-size:11px;
font-weight: bold;
background:url(${tplroot}/images/wmchat.png) top left no-repeat;
background-position:0px -25px;
display:block;
text-align:center;
padding-top:2px;
color:white;
width:186px;
height:18px;
text-decoration:none;
}
</style>
<body bgcolor="#FFFFFF" text="#000000" link="#C28400" vlink="#C28400" alink="#C28400" style="margin:0px;">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top">
<form name="surveyForm" method="post" action="${webimroot}/client.php">
<input type="hidden" name="style" value="${styleid}"/>
<input type="hidden" name="info" value="${form:info}"/>
<input type="hidden" name="referrer" value="${page:referrer}"/>
<input type="hidden" name="survey" value="on"/>
${ifnot:showemail}<input type="hidden" name="email" value="${form:email}"/>${endif:showemail}
${ifnot:groups}${if:formgroupid}<input type="hidden" name="group" value="${form:groupid}"/>${endif:formgroupid}${endif:groups}
${ifnot:showmessage}<input type="hidden" name="message" value="${form:message}"/>${endif:showmessage}
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top" height="150" style="padding:5px">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="100%" height="100" style="padding-left:20px;">
${if:ct.company.chatLogoURL}
${if:webimHost}
<a onclick="window.open('${page:webimHost}');return false;" href="${page:webimHost}">
<img src="${page:ct.company.chatLogoURL}" border="0" alt="">
</a>
${else:webimHost}
<img src="${page:ct.company.chatLogoURL}" border="0" alt="">
${endif:webimHost}
${else:ct.company.chatLogoURL}
${if:webimHost}
<a onclick="window.open('${page:webimHost}');return false;" href="${page:webimHost}">
<img src="${webimroot}/images/webimlogo.gif" border="0" alt="">
</a>
${else:webimHost}
<img src="${webimroot}/images/webimlogo.gif" border="0" alt="">
${endif:webimHost}
${endif:ct.company.chatLogoURL}
</td>
<td nowrap style="padding-right:10px"><SPAN style="font-size:16px;font-weight:bold;color:#525252">${msg:presurvey.title}</SPAN></td>
</tr>
</table>
<table cellspacing="0" cellpadding="0" border="0" id="header" class="bg_domain">
<tr>
<td style="padding-left:20px;width:612px;color:white;" class="mmimg">
${msg:presurvey.intro}
</td>
<td align="right" style="padding-right:17px;">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href="javascript:window.close();" title="${msg:leavemessage.close}"><img src='${tplroot}/images/buttons/back.gif' width="25" height="25" border="0" alt="" /></a></td>
<td width="5"></td>
<td class="button"><a href="javascript:window.close();" title="${msg:leavemessage.close}">${msg:leavemessage.close}</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" style="padding:0px 0px 0px 24px;">
${if:errors}
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top"><img src='${webimroot}/images/icon_err.gif' width="40" height="40" border="0" alt="" /></td>
<td width="10"></td>
<td class="text">
${errors}
</td>
</tr>
</table>
${endif:errors}
<table cellspacing="1" cellpadding="5" border="0" class="form">
${if:groups}
<tr>
<td class="text">${msg:presurvey.department}</td>
<td>
<select name="group">${page:groups}</select>
</td>
</tr>
${endif:groups}
<tr>
<td class="text">${msg:presurvey.name}</td>
<td><input type="text" name="name" size="50" value="${form:name}" class="username" ${ifnot:showname}disabled="disabled"${endif:showname}/></td>
</tr>
${if:showemail}
<tr>
<td class="text">${msg:presurvey.mail}</td>
<td><input type="text" name="email" size="50" value="${form:email}" class="username"/></td>
</tr>
${endif:showemail}
${if:showmessage}
<tr>
<td class="text">${msg:presurvey.question}:</td>
<td valign="top">
<textarea name="message" tabindex="0" cols="45" rows="2" style="border:1px solid #878787; overflow:auto">${form:message}</textarea>
</td>
</tr>
${endif:showmessage}
<tr>
<td colspan="2" align="right">
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td><a href="javascript:document.surveyForm.submit();" class="but" id="sndmessagelnk">${msg:presurvey.submit}</a></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="top" style="padding:24px">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</body>
</html>