diff --git a/src/webim/libs/chat.php b/src/webim/libs/chat.php index ccc706b6..ac1b3330 100644 --- a/src/webim/libs/chat.php +++ b/src/webim/libs/chat.php @@ -15,7 +15,8 @@ $connection_timeout = 30; // sec -$namecookie = "WEBIM_Name"; +$simplenamecookie = "WEBIM_Name"; // 1.0.8 and earlier +$namecookie = "WEBIM_Data"; // 1.0.9+ $state_queue = 0; $state_waiting = 1; @@ -447,8 +448,16 @@ function check_for_reassign($thread,$operator) { } function visitor_from_request() { - global $namecookie; - $userName = isset($_COOKIE[$namecookie]) ? $_COOKIE[$namecookie] : getstring("chat.default.username"); + global $namecookie, $simplenamecookie, $compatibility_encoding, $webim_encoding; + $userName = getstring("chat.default.username"); + if( isset($_COOKIE[$namecookie]) ) { + $data = base64_decode(strtr($_COOKIE[$namecookie],'-_,', '+/=')); + if( strlen($data) > 0 ) { + $userName = myiconv("utf-8",$webim_encoding,$data); + } + } else if( isset($_COOKIE[$simplenamecookie]) && isset($compatibility_encoding) ) { + $userName = myiconv($compatibility_encoding,$webim_encoding,$_COOKIE[$simplenamecookie]); + } return array( 'name' => $userName ); } diff --git a/src/webim/libs/config.php b/src/webim/libs/config.php index 7b2a9db3..05cc69a4 100644 --- a/src/webim/libs/config.php +++ b/src/webim/libs/config.php @@ -29,19 +29,17 @@ $mysqlpass = "123"; * Localization parameters */ - -/* Use CP-1251 database */ -/* -$dbencoding = "cp1251"; -$webim_encoding = "cp1251"; -$force_charset_in_connection = true; -*/ - /* Use UTF-8 database */ $dbencoding = "utf8"; $webim_encoding = "utf-8"; $force_charset_in_connection = true; +/* + * Web Messenger 1.0.8 an earlier stored user name in cookie in "webim_encoding". If + * you used this versions of webim set your previous encoding here. + */ +$compatibility_encoding = "cp1251"; + /* * From field in outgoing mail. */ diff --git a/src/webim/operator/update.php b/src/webim/operator/update.php index b39107e7..ee5cec36 100644 --- a/src/webim/operator/update.php +++ b/src/webim/operator/update.php @@ -44,7 +44,7 @@ function thread_to_xml($thread) { if( $state == "closed" ) return $result."/>"; - $state = myiconv($webim_encoding,"utf-8",getstring($threadstate_key[$thread['istate']])); + $state = getstring($threadstate_key[$thread['istate']]); $threadoperator = ($thread['agentName'] ? $thread['agentName'] : "-"); $result .= " canopen=\"true\""; @@ -97,4 +97,4 @@ print_pending_threads($since); notify_operator_alive($operator['operatorid']); exit; -?> \ No newline at end of file +?> diff --git a/src/webim/thread.php b/src/webim/thread.php index eb70aa99..fd7917fa 100644 --- a/src/webim/thread.php +++ b/src/webim/thread.php @@ -65,7 +65,8 @@ if( $act == "refresh" ) { $newname = getrawparam('name'); rename_user($thread, $newname); - setcookie($namecookie, $newname, time()+60*60*24*365); + $data = strtr(base64_encode(myiconv($webim_encoding,"utf-8",$newname)), '+/=', '-_,'); + setcookie($namecookie, $data, time()+60*60*24*365); start_xml_output(); echo ""; exit; @@ -88,4 +89,4 @@ if( $act == "refresh" ) { } -?> \ No newline at end of file +?>