mirror of
https://github.com/Mibew/mibew.git
synced 2025-02-01 05:44:41 +03:00
Define constants for all cookies' names
This commit is contained in:
parent
5a47fa8074
commit
7b5caf0e8d
@ -25,8 +25,13 @@ require_once(dirname(__FILE__).'/classes/request_processor.php');
|
|||||||
require_once(dirname(__FILE__).'/classes/client_side_processor.php');
|
require_once(dirname(__FILE__).'/classes/client_side_processor.php');
|
||||||
require_once(dirname(__FILE__).'/classes/thread_processor.php');
|
require_once(dirname(__FILE__).'/classes/thread_processor.php');
|
||||||
|
|
||||||
$namecookie = "MIBEW_Data";
|
|
||||||
$usercookie = "MIBEW_UserID";
|
/**
|
||||||
|
* Names for chat-related cookies
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('USERID_COOKIE_NAME', 'MIBEW_UserID');
|
||||||
|
define('USERNAME_COOKIE_NAME', 'MIBEW_Data');
|
||||||
|
|
||||||
function message_to_text($msg)
|
function message_to_text($msg)
|
||||||
{
|
{
|
||||||
@ -582,11 +587,11 @@ function ban_for_addr($addr)
|
|||||||
|
|
||||||
function visitor_from_request()
|
function visitor_from_request()
|
||||||
{
|
{
|
||||||
global $namecookie, $mibew_encoding, $usercookie;
|
global $mibew_encoding;
|
||||||
$defaultName = getstring("chat.default.username");
|
$defaultName = getstring("chat.default.username");
|
||||||
$userName = $defaultName;
|
$userName = $defaultName;
|
||||||
if (isset($_COOKIE[$namecookie])) {
|
if (isset($_COOKIE[USERNAME_COOKIE_NAME])) {
|
||||||
$data = base64_decode(strtr($_COOKIE[$namecookie], '-_,', '+/='));
|
$data = base64_decode(strtr($_COOKIE[USERNAME_COOKIE_NAME], '-_,', '+/='));
|
||||||
if (strlen($data) > 0) {
|
if (strlen($data) > 0) {
|
||||||
$userName = myiconv("utf-8", $mibew_encoding, $data);
|
$userName = myiconv("utf-8", $mibew_encoding, $data);
|
||||||
}
|
}
|
||||||
@ -596,11 +601,11 @@ function visitor_from_request()
|
|||||||
$userName = getgetparam('name', $userName);
|
$userName = getgetparam('name', $userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_COOKIE[$usercookie])) {
|
if (isset($_COOKIE[USERID_COOKIE_NAME])) {
|
||||||
$userId = $_COOKIE[$usercookie];
|
$userId = $_COOKIE[USERID_COOKIE_NAME];
|
||||||
} else {
|
} else {
|
||||||
$userId = uniqid('', TRUE);
|
$userId = uniqid('', TRUE);
|
||||||
setcookie($usercookie, $userId, time() + 60 * 60 * 24 * 365);
|
setcookie(USERID_COOKIE_NAME, $userId, time() + 60 * 60 * 24 * 365);
|
||||||
}
|
}
|
||||||
return array('id' => $userId, 'name' => $userName);
|
return array('id' => $userId, 'name' => $userName);
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,7 @@ class ThreadProcessor extends ClientSideProcessor {
|
|||||||
* @throws ThreadProcessorException
|
* @throws ThreadProcessorException
|
||||||
*/
|
*/
|
||||||
protected function apiRename($args) {
|
protected function apiRename($args) {
|
||||||
global $namecookie, $mibew_encoding;
|
global $mibew_encoding;
|
||||||
|
|
||||||
// Check rename possibility
|
// Check rename possibility
|
||||||
if( Settings::get('usercanchangename') != "1" ) {
|
if( Settings::get('usercanchangename') != "1" ) {
|
||||||
@ -375,7 +375,7 @@ class ThreadProcessor extends ClientSideProcessor {
|
|||||||
$thread->renameUser($args['name']);
|
$thread->renameUser($args['name']);
|
||||||
// Update user name in cookies
|
// Update user name in cookies
|
||||||
$data = strtr(base64_encode(myiconv($mibew_encoding,"utf-8",$args['name'])), '+/=', '-_,');
|
$data = strtr(base64_encode(myiconv($mibew_encoding,"utf-8",$args['name'])), '+/=', '-_,');
|
||||||
setcookie($namecookie, $data, time()+60*60*24*365);
|
setcookie(USERNAME_COOKIE_NAME, $data, time()+60*60*24*365);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -413,7 +413,6 @@ class ThreadProcessor extends ClientSideProcessor {
|
|||||||
/**
|
/**
|
||||||
* Process submitted prechat survey.
|
* Process submitted prechat survey.
|
||||||
*
|
*
|
||||||
* @global string $namecookie Name of cookie that store visitor name
|
|
||||||
* @param array $args Associative array of arguments. It must contains
|
* @param array $args Associative array of arguments. It must contains
|
||||||
* following keys:
|
* following keys:
|
||||||
* - 'threadId': for this function this param equals to null;
|
* - 'threadId': for this function this param equals to null;
|
||||||
@ -429,7 +428,6 @@ class ThreadProcessor extends ClientSideProcessor {
|
|||||||
* - 'options': options array for next module.
|
* - 'options': options array for next module.
|
||||||
*/
|
*/
|
||||||
protected function apiProcessSurvey($args) {
|
protected function apiProcessSurvey($args) {
|
||||||
global $namecookie;
|
|
||||||
|
|
||||||
$visitor = visitor_from_request();
|
$visitor = visitor_from_request();
|
||||||
|
|
||||||
@ -459,7 +457,7 @@ class ThreadProcessor extends ClientSideProcessor {
|
|||||||
'+/=',
|
'+/=',
|
||||||
'-_,'
|
'-_,'
|
||||||
);
|
);
|
||||||
setcookie($namecookie, $data, time()+60*60*24*365);
|
setcookie(USERNAME_COOKIE_NAME, $data, time()+60*60*24*365);
|
||||||
$visitor['name'] = $newname;
|
$visitor['name'] = $newname;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,7 @@ $default_cron_key = md5(
|
|||||||
/**
|
/**
|
||||||
* Name for cookie to track visitor
|
* Name for cookie to track visitor
|
||||||
*/
|
*/
|
||||||
$visitorcookie = "MIBEW_VisitorID";
|
|
||||||
|
define('VISITOR_COOKIE_NAME', 'MIBEW_VisitorID');
|
||||||
|
|
||||||
?>
|
?>
|
@ -18,7 +18,10 @@
|
|||||||
require_once(dirname(__FILE__).'/converter.php');
|
require_once(dirname(__FILE__).'/converter.php');
|
||||||
require_once(dirname(__FILE__).'/verification.php');
|
require_once(dirname(__FILE__).'/verification.php');
|
||||||
|
|
||||||
$locale_cookie_name = 'mibew_locale';
|
/**
|
||||||
|
* Name for the cookie to store locale code in use
|
||||||
|
*/
|
||||||
|
define('LOCALE_COOKIE_NAME', 'mibew_locale');
|
||||||
|
|
||||||
// test and set default locales
|
// test and set default locales
|
||||||
$default_locale = locale_pattern_check($default_locale) && locale_exists($default_locale) ? $default_locale : 'en';
|
$default_locale = locale_pattern_check($default_locale) && locale_exists($default_locale) ? $default_locale : 'en';
|
||||||
@ -73,10 +76,10 @@ function get_available_locales()
|
|||||||
|
|
||||||
function get_user_locale()
|
function get_user_locale()
|
||||||
{
|
{
|
||||||
global $default_locale, $locale_cookie_name;
|
global $default_locale;
|
||||||
|
|
||||||
if (isset($_COOKIE['mibew_locale'])) {
|
if (isset($_COOKIE[LOCALE_COOKIE_NAME])) {
|
||||||
$requested_lang = $_COOKIE['mibew_locale'];
|
$requested_lang = $_COOKIE[LOCALE_COOKIE_NAME];
|
||||||
if (locale_pattern_check($requested_lang) && locale_exists($requested_lang))
|
if (locale_pattern_check($requested_lang) && locale_exists($requested_lang))
|
||||||
return $requested_lang;
|
return $requested_lang;
|
||||||
}
|
}
|
||||||
@ -100,7 +103,7 @@ function get_user_locale()
|
|||||||
|
|
||||||
function get_locale()
|
function get_locale()
|
||||||
{
|
{
|
||||||
global $mibewroot, $locale_cookie_name;
|
global $mibewroot;
|
||||||
|
|
||||||
$locale = verifyparam("locale", "/./", "");
|
$locale = verifyparam("locale", "/./", "");
|
||||||
|
|
||||||
@ -114,7 +117,7 @@ function get_locale()
|
|||||||
$locale = get_user_locale();
|
$locale = get_user_locale();
|
||||||
}
|
}
|
||||||
|
|
||||||
setcookie($locale_cookie_name, $locale, time() + 60 * 60 * 24 * 1000, "$mibewroot/");
|
setcookie(LOCALE_COOKIE_NAME, $locale, time() + 60 * 60 * 24 * 1000, "$mibewroot/");
|
||||||
return $locale;
|
return $locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
|
|
||||||
function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity, $operator_code)
|
function generate_button($title, $locale, $style, $invitationstyle, $group, $inner, $showhost, $forcesecure, $modsecurity, $operator_code)
|
||||||
{
|
{
|
||||||
global $visitorcookie;
|
|
||||||
$app_location = get_app_location($showhost, $forcesecure);
|
$app_location = get_app_location($showhost, $forcesecure);
|
||||||
$link = $app_location . "/client.php";
|
$link = $app_location . "/client.php";
|
||||||
if ($locale)
|
if ($locale)
|
||||||
@ -67,7 +66,7 @@ function generate_button($title, $locale, $style, $invitationstyle, $group, $inn
|
|||||||
$widget_data['locale'] = $locale;
|
$widget_data['locale'] = $locale;
|
||||||
|
|
||||||
// Name of the cookie to track user. Use if third-party cookie blocked
|
// Name of the cookie to track user. Use if third-party cookie blocked
|
||||||
$widget_data['visitorCookieName'] = $visitorcookie;
|
$widget_data['visitorCookieName'] = VISITOR_COOKIE_NAME;
|
||||||
|
|
||||||
// Build additional button code
|
// Build additional button code
|
||||||
$temp = preg_replace('/^(<a )/', '\1id="mibewAgentButton" ', $temp) .
|
$temp = preg_replace('/^(<a )/', '\1id="mibewAgentButton" ', $temp) .
|
||||||
|
Loading…
Reference in New Issue
Block a user