fix encoding of state, new way to store name in cookie

git-svn-id: https://webim.svn.sourceforge.net/svnroot/webim/trunk@71 c66351dc-e62f-0410-b875-e3a5c0b9693f
This commit is contained in:
Evgeny Gryaznov 2008-05-12 09:23:16 +00:00
parent 43c74fd0d4
commit 475200747c
4 changed files with 23 additions and 15 deletions

View File

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

View File

@ -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.
*/

View File

@ -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\"";

View File

@ -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 "<changedname></changedname>";
exit;