From 7042f3dd9e73a00a93efdf6fa5eeb6c295b5d296 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Wed, 14 May 2014 12:16:04 +0000 Subject: [PATCH] Use only UTF-8 encoding --- src/mibew/install/dbinfo.php | 4 +- src/mibew/install/dbperform.php | 3 +- src/mibew/install/index.php | 5 +- src/mibew/libs/chat.php | 50 ++++---- .../Mibew/Controller/HistoryController.php | 34 +++--- .../RequestProcessor/ThreadProcessor.php | 8 +- .../Mibew/RequestProcessor/UsersProcessor.php | 7 +- src/mibew/libs/classes/Mibew/Thread.php | 14 --- src/mibew/libs/common/constants.php | 5 - src/mibew/libs/common/converter.php | 49 -------- src/mibew/libs/common/locale.php | 113 ++---------------- src/mibew/libs/common/request.php | 6 +- src/mibew/libs/common/response.php | 5 - src/mibew/libs/default_config.php | 7 -- src/mibew/libs/init.php | 3 +- src/mibew/libs/invitation.php | 2 +- src/mibew/libs/notify.php | 19 +-- src/mibew/libs/operator.php | 10 +- src/mibew/operator/agent.php | 4 +- src/mibew/operator/avatar.php | 6 +- src/mibew/operator/ban.php | 20 ++-- src/mibew/operator/blocked.php | 2 +- src/mibew/operator/canned.php | 4 +- src/mibew/operator/cannededit.php | 4 +- src/mibew/operator/group.php | 50 ++++---- src/mibew/operator/groupmembers.php | 6 +- src/mibew/operator/groups.php | 6 +- src/mibew/operator/operator.php | 26 ++-- src/mibew/operator/operators.php | 6 +- src/mibew/operator/opgroups.php | 6 +- src/mibew/operator/permissions.php | 4 +- src/mibew/operator/redirect.php | 4 +- src/mibew/operator/restore.php | 2 +- src/mibew/operator/settings.php | 16 +-- src/mibew/operator/statistics.php | 4 +- src/mibew/operator/translate.php | 10 +- 36 files changed, 164 insertions(+), 360 deletions(-) delete mode 100644 src/mibew/libs/common/converter.php diff --git a/src/mibew/install/dbinfo.php b/src/mibew/install/dbinfo.php index 8b08f40a..59927ba8 100644 --- a/src/mibew/install/dbinfo.php +++ b/src/mibew/install/dbinfo.php @@ -304,7 +304,7 @@ function show_install_err($text) function create_table($id, $link) { - global $dbtables, $dbtables_indexes, $memtables, $dbencoding, $mysqlprefix; + global $dbtables, $dbtables_indexes, $memtables, $mysqlprefix; if (!isset($dbtables[$id])) { show_install_err("Unknown table: $id, " . mysql_error($link)); @@ -324,7 +324,7 @@ function create_table($id, $link) } $query = preg_replace("/,\n$/", "", $query); - $query .= ") charset $dbencoding"; + $query .= ") charset utf8"; if (in_array($id, $memtables)) { $query .= " ENGINE=MEMORY"; } else { diff --git a/src/mibew/install/dbperform.php b/src/mibew/install/dbperform.php index 6031ce1b..6545614e 100644 --- a/src/mibew/install/dbperform.php +++ b/src/mibew/install/dbperform.php @@ -37,7 +37,6 @@ define('MIBEW_WEB_ROOT', $mibewroot); // Include common functions require_once(MIBEW_FS_ROOT.'/libs/common/constants.php'); require_once(MIBEW_FS_ROOT.'/libs/common/verification.php'); -require_once(MIBEW_FS_ROOT.'/libs/common/converter.php'); require_once(MIBEW_FS_ROOT.'/libs/common/locale.php'); require_once(MIBEW_FS_ROOT.'/libs/common/misc.php'); require_once(MIBEW_FS_ROOT.'/libs/common/response.php'); @@ -65,7 +64,7 @@ if ($act == "silentcreateall") { } else { mysql_select_db($mysqldb, $link) or show_install_err('Could not select database'); if ($force_charset_in_connection) { - mysql_query("SET character set $dbencoding", $link); + mysql_query("SET character set utf8", $link); } if ($act == "ct") { diff --git a/src/mibew/install/index.php b/src/mibew/install/index.php index 5e387232..592adb99 100644 --- a/src/mibew/install/index.php +++ b/src/mibew/install/index.php @@ -52,7 +52,6 @@ define('MIBEW_WEB_ROOT', $base_url); // Include common functions require_once(MIBEW_FS_ROOT.'/libs/common/constants.php'); require_once(MIBEW_FS_ROOT.'/libs/common/verification.php'); -require_once(MIBEW_FS_ROOT.'/libs/common/converter.php'); require_once(MIBEW_FS_ROOT.'/libs/common/locale.php'); require_once(MIBEW_FS_ROOT.'/libs/common/misc.php'); require_once(MIBEW_FS_ROOT.'/libs/common/response.php'); @@ -199,11 +198,11 @@ function check_connection() function check_database($link) { - global $mysqldb, $force_charset_in_connection, $dbencoding, $page; + global $mysqldb, $force_charset_in_connection, $page; if (mysql_select_db($mysqldb, $link)) { $page['done'][] = getlocal2("install.2.db_exists", array($mysqldb)); if ($force_charset_in_connection) { - mysql_query("SET character set $dbencoding", $link); + mysql_query("SET character set utf8", $link); } return true; } else { diff --git a/src/mibew/libs/chat.php b/src/mibew/libs/chat.php index 96c50bff..bc30318b 100644 --- a/src/mibew/libs/chat.php +++ b/src/mibew/libs/chat.php @@ -221,10 +221,10 @@ function setup_logo($group = null) : $top_level_group['vchosturl']; $data['company'] = array( - 'name' => to_page($group_name), - 'chatLogoURL' => to_page($logo), + 'name' => $group_name, + 'chatLogoURL' => $logo, ); - $data['mibewHost'] = to_page($mibew_host); + $data['mibewHost'] = $mibew_host; return $data; } @@ -285,12 +285,12 @@ function setup_leavemessage($name, $email, $group_id, $info, $referrer) } $data['leaveMessage']['leaveMessageForm'] = array( - 'name' => to_page($name), - 'email' => to_page($email), + 'name' => $name, + 'email' => $email, 'groupId' => $group_id, 'groupName' => $group_name, - 'info' => to_page($info), - 'referrer' => to_page($referrer), + 'info' => $info, + 'referrer' => $referrer, 'showCaptcha' => (bool) (Settings::get("enablecaptcha") == "1" && can_show_captcha()), ); @@ -331,11 +331,11 @@ function setup_survey($name, $email, $group_id, $info, $referrer) $data['survey'] = array(); $data['survey']['surveyForm'] = array( - 'name' => to_page($name), + 'name' => $name, 'groupId' => $group_id, - 'email' => to_page($email), - 'info' => to_page($info), - 'referrer' => to_page($referrer), + 'email' => $email, + 'info' => $info, + 'referrer' => $referrer, 'showEmail' => (bool) (Settings::get("surveyaskmail") == "1"), 'showMessage' => (bool) (Settings::get("surveyaskmessage") == "1"), 'canChangeName' => (bool) (Settings::get('usercanchangename') == "1"), @@ -463,9 +463,9 @@ function setup_chatview(Thread $thread) 'token' => $thread->lastToken ); - $data['page.title'] = to_page( - empty($group['vcchattitle']) ? Settings::get('chattitle') : $group['vcchattitle'] - ); + $data['page.title'] = empty($group['vcchattitle']) + ? Settings::get('chattitle') + : $group['vcchattitle']; $data['chat']['page'] = array( 'title' => $data['page.title'] ); @@ -516,7 +516,7 @@ function setup_chatview_for_user(Thread $thread) // Set user info $data['chat']['user'] = array( - 'name' => htmlspecialchars(to_page($thread->userName)), + 'name' => htmlspecialchars($thread->userName), 'canChangeName' => (bool) (Settings::get('usercanchangename') == "1"), 'defaultName' => (bool) (getstring("chat.default.username") != $thread->userName), 'canPost' => true, @@ -556,12 +556,10 @@ function setup_chatview_for_operator(Thread $thread, $operator) // Set operator info $data['chat']['user'] = array( 'name' => htmlspecialchars( - to_page( - get_user_name( - $thread->userName, - $thread->remote, - $thread->userId - ) + get_user_name( + $thread->userName, + $thread->remote, + $thread->userId ) ), 'canPost' => (bool) ($thread->agentId == $operator['operatorid']), @@ -607,13 +605,9 @@ function setup_chatview_for_operator(Thread $thread, $operator) foreach ($canned_messages as $answer) { $predefined_answers[] = array( 'short' => htmlspecialchars( - to_page($answer['vctitle'] ? $answer['vctitle'] : cut_string($answer['vcvalue'], 97, '...')) + $answer['vctitle'] ? $answer['vctitle'] : cut_string($answer['vcvalue'], 97, '...') ), - 'full' => myiconv( - MIBEW_ENCODING, - getoutputenc(), - $answer['vcvalue'] - ) + 'full' => $answer['vcvalue'], ); } $data['chat']['messageForm']['predefinedAnswers'] = $predefined_answers; @@ -661,7 +655,7 @@ function visitor_from_request() if (isset($_COOKIE[USERNAME_COOKIE_NAME])) { $data = base64_decode(strtr($_COOKIE[USERNAME_COOKIE_NAME], '-_,', '+/=')); if (strlen($data) > 0) { - $user_name = myiconv("utf-8", MIBEW_ENCODING, $data); + $user_name = $data; } } diff --git a/src/mibew/libs/classes/Mibew/Controller/HistoryController.php b/src/mibew/libs/classes/Mibew/Controller/HistoryController.php index a18e37b9..e7c3d67c 100644 --- a/src/mibew/libs/classes/Mibew/Controller/HistoryController.php +++ b/src/mibew/libs/classes/Mibew/Controller/HistoryController.php @@ -38,9 +38,7 @@ class HistoryController extends AbstractController $page = array(); $operator = $request->attributes->get('_operator'); - $query = $request->query->has('q') - ? myiconv(getoutputenc(), MIBEW_ENCODING, $request->query->get('q')) - : false; + $query = $request->query->get('q', false); $search_type = $request->query->get('type'); if (!in_array($search_type, array('all', 'message', 'operator', 'visitor'))) { @@ -135,12 +133,12 @@ class HistoryController extends AbstractController $page['pagination.items'][] = array( 'threadId' => $thread->id, - 'userName' => to_page($thread->userName), - 'userAddress' => get_user_addr(to_page($thread->remote)), - 'agentName' => to_page($thread->agentName), - 'messageCount' => to_page($thread->messageCount), + 'userName' => $thread->userName, + 'userAddress' => get_user_addr($thread->remote), + 'agentName' => $thread->agentName, + 'messageCount' => $thread->messageCount, 'groupName' => ($group_name_set - ? to_page($group_name[$thread->groupId]) + ? $group_name[$thread->groupId] : false), 'chatTime' => $thread->modified - $thread->created, 'chatCreated' => $thread->created, @@ -151,7 +149,7 @@ class HistoryController extends AbstractController $page['pagination.items'] = false; } - $page['formq'] = to_page($query); + $page['formq'] = $query; } else { $page['pagination'] = false; $page['pagination.items'] = false; @@ -187,13 +185,13 @@ class HistoryController extends AbstractController $group = group_by_id($thread->groupId); $thread_info = array( - 'userName' => to_page($thread->userName), - 'userAddress' => get_user_addr(to_page($thread->remote)), - 'userAgentVersion' => get_user_agent_version(to_page($thread->userAgent)), - 'agentName' => to_page($thread->agentName), + 'userName' => $thread->userName, + 'userAddress' => get_user_addr($thread->remote), + 'userAgentVersion' => get_user_agent_version($thread->userAgent), + 'agentName' => $thread->agentName, 'chatTime' => ($thread->modified - $thread->created), 'chatStarted' => $thread->created, - 'groupName' => to_page(get_group_name($group)), + 'groupName' => get_group_name($group), ); $page['threadInfo'] = $thread_info; @@ -256,10 +254,10 @@ class HistoryController extends AbstractController foreach ($page['pagination.items'] as $key => $item) { $thread = Thread::createFromDbInfo($item); $page['pagination.items'][$key] = array( - 'threadId' => to_page($thread->id), - 'userName' => to_page($thread->userName), - 'userAddress' => get_user_addr(to_page($thread->remote)), - 'agentName' => to_page($thread->agentName), + 'threadId' => $thread->id, + 'userName' => $thread->userName, + 'userAddress' => get_user_addr($thread->remote), + 'agentName' => $thread->agentName, 'chatTime' => ($thread->modified - $thread->created), 'chatCreated' => $thread->created, ); diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php index 8300cd36..044a2bc3 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/ThreadProcessor.php @@ -384,7 +384,7 @@ class ThreadProcessor extends ClientSideProcessor //Rename user $thread->renameUser($args['name']); // Update user name in cookies - $data = strtr(base64_encode(myiconv(MIBEW_ENCODING, "utf-8", $args['name'])), '+/=', '-_,'); + $data = strtr(base64_encode($args['name']), '+/=', '-_,'); setcookie(USERNAME_COOKIE_NAME, $data, time() + 60 * 60 * 24 * 365); } @@ -464,11 +464,7 @@ class ThreadProcessor extends ClientSideProcessor if (Settings::get('usercanchangename') == "1" && !empty($args['name'])) { $newname = $args['name']; if ($newname != $visitor['name']) { - $data = strtr( - base64_encode(myiconv(MIBEW_ENCODING, "utf-8", $newname)), - '+/=', - '-_,' - ); + $data = strtr(base64_encode($newname), '+/=', '-_,'); setcookie(USERNAME_COOKIE_NAME, $data, time() + 60 * 60 * 24 * 365); $visitor['name'] = $newname; } diff --git a/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php b/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php index 7b385a21..82d12c87 100644 --- a/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php +++ b/src/mibew/libs/classes/Mibew/RequestProcessor/UsersProcessor.php @@ -521,12 +521,7 @@ class UsersProcessor extends ClientSideProcessor $result_list[] = array( 'id' => (int) $item['operatorid'], - // Convert name to UTF-8 - 'name' => myiconv( - MIBEW_ENCODING, - "utf-8", - htmlspecialchars($item['vclocalename']) - ), + 'name' => htmlspecialchars($item['vclocalename']), 'away' => (bool) operator_is_away($item) ); } diff --git a/src/mibew/libs/classes/Mibew/Thread.php b/src/mibew/libs/classes/Mibew/Thread.php index 01eb7b89..fb53350c 100644 --- a/src/mibew/libs/classes/Mibew/Thread.php +++ b/src/mibew/libs/classes/Mibew/Thread.php @@ -778,13 +778,6 @@ class Thread ); foreach ($messages as $key => $msg) { - // Change sender name encoding - $messages[$key]['name'] = myiconv( - MIBEW_ENCODING, - "utf-8", - $msg['name'] - ); - // Process data attached to the message if (!empty($messages[$key]['data'])) { $messages[$key]['data'] = unserialize( @@ -794,13 +787,6 @@ class Thread $messages[$key]['data'] = array(); } - // Change message body encoding - $messages[$key]['message'] = myiconv( - MIBEW_ENCODING, - "utf-8", - $msg['message'] - ); - // Get last message ID if ($msg['id'] > $last_id) { $last_id = $msg['id']; diff --git a/src/mibew/libs/common/constants.php b/src/mibew/libs/common/constants.php index 874ac459..18bf768b 100644 --- a/src/mibew/libs/common/constants.php +++ b/src/mibew/libs/common/constants.php @@ -50,11 +50,6 @@ define('DEFAULT_CRON_KEY', md5( */ define('VISITOR_COOKIE_NAME', 'MIBEW_VisitorID'); -/** - * Internal system encoding - */ -define('MIBEW_ENCODING', $mibew_encoding); - /** * Names for chat-related cookies */ diff --git a/src/mibew/libs/common/converter.php b/src/mibew/libs/common/converter.php deleted file mode 100644 index f06d38d5..00000000 --- a/src/mibew/libs/common/converter.php +++ /dev/null @@ -1,49 +0,0 @@ - "\xC0", "\xD0\x91" => "\xC1", "\xD0\x92" => "\xC2", "\xD0\x93" => "\xC3", "\xD0\x94" => "\xC4", - "\xD0\x95" => "\xC5", "\xD0\x81" => "\xA8", "\xD0\x96" => "\xC6", "\xD0\x97" => "\xC7", "\xD0\x98" => "\xC8", - "\xD0\x99" => "\xC9", "\xD0\x9A" => "\xCA", "\xD0\x9B" => "\xCB", "\xD0\x9C" => "\xCC", "\xD0\x9D" => "\xCD", - "\xD0\x9E" => "\xCE", "\xD0\x9F" => "\xCF", "\xD0\xA0" => "\xD0", "\xD0\xA1" => "\xD1", "\xD0\xA2" => "\xD2", - "\xD0\xA3" => "\xD3", "\xD0\xA4" => "\xD4", "\xD0\xA5" => "\xD5", "\xD0\xA6" => "\xD6", "\xD0\xA7" => "\xD7", - "\xD0\xA8" => "\xD8", "\xD0\xA9" => "\xD9", "\xD0\xAA" => "\xDA", "\xD0\xAB" => "\xDB", "\xD0\xAC" => "\xDC", - "\xD0\xAD" => "\xDD", "\xD0\xAE" => "\xDE", "\xD0\xAF" => "\xDF", "\xD0\x87" => "\xAF", "\xD0\x86" => "\xB2", - "\xD0\x84" => "\xAA", "\xD0\x8E" => "\xA1", "\xD0\xB0" => "\xE0", "\xD0\xB1" => "\xE1", "\xD0\xB2" => "\xE2", - "\xD0\xB3" => "\xE3", "\xD0\xB4" => "\xE4", "\xD0\xB5" => "\xE5", "\xD1\x91" => "\xB8", "\xD0\xB6" => "\xE6", - "\xD0\xB7" => "\xE7", "\xD0\xB8" => "\xE8", "\xD0\xB9" => "\xE9", "\xD0\xBA" => "\xEA", "\xD0\xBB" => "\xEB", - "\xD0\xBC" => "\xEC", "\xD0\xBD" => "\xED", "\xD0\xBE" => "\xEE", "\xD0\xBF" => "\xEF", "\xD1\x80" => "\xF0", - "\xD1\x81" => "\xF1", "\xD1\x82" => "\xF2", "\xD1\x83" => "\xF3", "\xD1\x84" => "\xF4", "\xD1\x85" => "\xF5", - "\xD1\x86" => "\xF6", "\xD1\x87" => "\xF7", "\xD1\x88" => "\xF8", "\xD1\x89" => "\xF9", "\xD1\x8A" => "\xFA", - "\xD1\x8B" => "\xFB", "\xD1\x8C" => "\xFC", "\xD1\x8D" => "\xFD", "\xD1\x8E" => "\xFE", "\xD1\x8F" => "\xFF", - "\xD1\x96" => "\xB3", "\xD1\x97" => "\xBF", "\xD1\x94" => "\xBA", "\xD1\x9E" => "\xA2"); -$_win1251utf8 = array( - "\xC0" => "\xD0\x90", "\xC1" => "\xD0\x91", "\xC2" => "\xD0\x92", "\xC3" => "\xD0\x93", "\xC4" => "\xD0\x94", - "\xC5" => "\xD0\x95", "\xA8" => "\xD0\x81", "\xC6" => "\xD0\x96", "\xC7" => "\xD0\x97", "\xC8" => "\xD0\x98", - "\xC9" => "\xD0\x99", "\xCA" => "\xD0\x9A", "\xCB" => "\xD0\x9B", "\xCC" => "\xD0\x9C", "\xCD" => "\xD0\x9D", - "\xCE" => "\xD0\x9E", "\xCF" => "\xD0\x9F", "\xD0" => "\xD0\xA0", "\xD1" => "\xD0\xA1", "\xD2" => "\xD0\xA2", - "\xD3" => "\xD0\xA3", "\xD4" => "\xD0\xA4", "\xD5" => "\xD0\xA5", "\xD6" => "\xD0\xA6", "\xD7" => "\xD0\xA7", - "\xD8" => "\xD0\xA8", "\xD9" => "\xD0\xA9", "\xDA" => "\xD0\xAA", "\xDB" => "\xD0\xAB", "\xDC" => "\xD0\xAC", - "\xDD" => "\xD0\xAD", "\xDE" => "\xD0\xAE", "\xDF" => "\xD0\xAF", "\xAF" => "\xD0\x87", "\xB2" => "\xD0\x86", - "\xAA" => "\xD0\x84", "\xA1" => "\xD0\x8E", "\xE0" => "\xD0\xB0", "\xE1" => "\xD0\xB1", "\xE2" => "\xD0\xB2", - "\xE3" => "\xD0\xB3", "\xE4" => "\xD0\xB4", "\xE5" => "\xD0\xB5", "\xB8" => "\xD1\x91", "\xE6" => "\xD0\xB6", - "\xE7" => "\xD0\xB7", "\xE8" => "\xD0\xB8", "\xE9" => "\xD0\xB9", "\xEA" => "\xD0\xBA", "\xEB" => "\xD0\xBB", - "\xEC" => "\xD0\xBC", "\xED" => "\xD0\xBD", "\xEE" => "\xD0\xBE", "\xEF" => "\xD0\xBF", "\xF0" => "\xD1\x80", - "\xF1" => "\xD1\x81", "\xF2" => "\xD1\x82", "\xF3" => "\xD1\x83", "\xF4" => "\xD1\x84", "\xF5" => "\xD1\x85", - "\xF6" => "\xD1\x86", "\xF7" => "\xD1\x87", "\xF8" => "\xD1\x88", "\xF9" => "\xD1\x89", "\xFA" => "\xD1\x8A", - "\xFB" => "\xD1\x8B", "\xFC" => "\xD1\x8C", "\xFD" => "\xD1\x8D", "\xFE" => "\xD1\x8E", "\xFF" => "\xD1\x8F", - "\xB3" => "\xD1\x96", "\xBF" => "\xD1\x97", "\xBA" => "\xD1\x94", "\xA2" => "\xD1\x9E"); diff --git a/src/mibew/libs/common/locale.php b/src/mibew/libs/common/locale.php index 566ed251..d4b6e9cf 100644 --- a/src/mibew/libs/common/locale.php +++ b/src/mibew/libs/common/locale.php @@ -48,28 +48,6 @@ define( */ define('CURRENT_LOCALE', get_locale()); -function myiconv($in_enc, $out_enc, $string) -{ - global $_utf8win1251, $_win1251utf8; - if ($in_enc == $out_enc) { - return $string; - } - if (function_exists('iconv')) { - $converted = @iconv($in_enc, $out_enc, $string); - if ($converted !== false) { - return $converted; - } - } - if ($in_enc == "cp1251" && $out_enc == "utf-8") { - return strtr($string, $_win1251utf8); - } - if ($in_enc == "utf-8" && $out_enc == "cp1251") { - return strtr($string, $_utf8win1251); - } - - return $string; // do not know how to convert -} - function locale_exists($locale) { return file_exists(MIBEW_FS_ROOT . "/locales/$locale/properties"); @@ -173,22 +151,17 @@ function get_locale_links($href) * Load localized messages id some service locale info. * * @global array $messages Localized messages array - * @global array $output_encoding Array of mapping locales to output encodings * * @param string $locale Name of a locale whose messages should be loaded. */ function load_messages($locale) { - global $messages, $output_encoding; + global $messages; // Load core localization $locale_file = MIBEW_FS_ROOT . "/locales/{$locale}/properties"; $locale_data = read_locale_file($locale_file); - if (!is_null($locale_data['output_encoding'])) { - $output_encoding[$locale] = $locale_data['output_encoding']; - } - $messages[$locale] = $locale_data['messages']; // Plugins are unavailable on system installation @@ -224,25 +197,13 @@ function load_messages($locale) * * @param string $path Locale file path * @return array Associative array with following keys: - * - 'encoding': string, one of service field from locale file, determines - * encoding of strings in the locale file. If there is no 'encoding' field in - * the locale file, this variable will be equal to $mibew_encoding. - * - * - 'output_encoding': string, one of service field from locale file, - * determines in what encoding document should be output for this locale. - * If there is no 'output_encoding' field in the locale file, this variable - * will bew equal to NULL. - * * - 'messages': associative array of localized strings. The keys of the array * are localization keys and the values of the array are localized strings. - * All localized strings have internal Mibew encoding(see $mibew_encoding - * value in libs/config.php). + * All localized strings are encoded in UTF-8. */ function read_locale_file($path) { // Set default values - $current_encoding = MIBEW_ENCODING; - $output_encoding = null; $messages = array(); $fp = fopen($path, "r"); @@ -256,44 +217,16 @@ function read_locale_file($path) if (count($line_parts) == 2) { $key = $line_parts[0]; $value = $line_parts[1]; - // Check if key is service field and treat it as - // localized string otherwise - if ($key == 'encoding') { - $current_encoding = trim($value); - } elseif ($key == 'output_encoding') { - $output_encoding = trim($value); - } elseif ($current_encoding == MIBEW_ENCODING) { - $messages[$key] = str_replace("\\n", "\n", trim($value)); - } else { - $messages[$key] = myiconv( - $current_encoding, - MIBEW_ENCODING, - str_replace("\\n", "\n", trim($value)) - ); - } + $messages[$key] = str_replace("\\n", "\n", trim($value)); } } fclose($fp); return array( - 'encoding' => $current_encoding, - 'output_encoding' => $output_encoding, 'messages' => $messages ); } -function getoutputenc() -{ - global $output_encoding, $messages; - if (!isset($messages[CURRENT_LOCALE])) { - load_messages(CURRENT_LOCALE); - } - - return isset($output_encoding[CURRENT_LOCALE]) - ? $output_encoding[CURRENT_LOCALE] - : MIBEW_ENCODING; -} - function getstring_($text, $locale, $raw = false) { global $messages; @@ -326,11 +259,7 @@ function getlocal($text, $raw = false) function getlocal_($text, $locale, $raw = false) { - $string = myiconv( - MIBEW_ENCODING, - getoutputenc(), - getstring_($text, $locale, true) - ); + $string = getstring_($text, $locale, true); return $raw ? $string : sanitize_string($string, 'low', 'moderate'); } @@ -352,11 +281,7 @@ function getstring2($text, $params, $raw = false) function getlocal2($text, $params, $raw = false) { - $string = myiconv( - MIBEW_ENCODING, - getoutputenc(), - getstring_($text, CURRENT_LOCALE, true) - ); + $string = getstring_($text, CURRENT_LOCALE, true); for ($i = 0; $i < count($params); $i++) { $string = str_replace("{" . $i . "}", $params[$i], $string); @@ -368,7 +293,7 @@ function getlocal2($text, $params, $raw = false) /* prepares for Javascript string */ function get_local_for_js($text, $params) { - $string = myiconv(MIBEW_ENCODING, getoutputenc(), getstring_($text, CURRENT_LOCALE)); + $string = getstring_($text, CURRENT_LOCALE); $string = str_replace("\"", "\\\"", str_replace("\n", "\\n", $string)); for ($i = 0; $i < count($params); $i++) { $string = str_replace("{" . $i . "}", $params[$i], $string); @@ -398,7 +323,6 @@ function save_message($locale, $key, $value) { $result = ""; $added = false; - $current_encoding = MIBEW_ENCODING; $fp = fopen(MIBEW_FS_ROOT . "/locales/$locale/properties", "r"); if ($fp === false) { die("unable to open properties for locale $locale"); @@ -407,15 +331,10 @@ function save_message($locale, $key, $value) $line = fgets($fp, 4096); $key_val = preg_split("/=/", $line, 2); if (isset($key_val[1])) { - if ($key_val[0] == 'encoding') { - $current_encoding = trim($key_val[1]); - } elseif (!$added && $key_val[0] == $key) { + if (!$added && $key_val[0] == $key) { $line = "$key=" - . myiconv( - MIBEW_ENCODING, - $current_encoding, - str_replace("\r", "", str_replace("\n", "\\n", trim($value))) - ) . "\n"; + . str_replace("\r", "", str_replace("\n", "\\n", trim($value))) + . "\n"; $added = true; } } @@ -424,11 +343,8 @@ function save_message($locale, $key, $value) fclose($fp); if (!$added) { $result .= "$key=" - . myiconv( - MIBEW_ENCODING, - $current_encoding, - str_replace("\r", "", str_replace("\n", "\\n", trim($value))) - ) . "\n"; + . str_replace("\r", "", str_replace("\n", "\\n", trim($value))) + . "\n"; } $fp = @fopen(MIBEW_FS_ROOT . "/locales/$locale/properties", "w"); if ($fp !== false) { @@ -451,11 +367,7 @@ function save_message($locale, $key, $value) fwrite( $fp, ("$key=" - . myiconv( - MIBEW_ENCODING, - $current_encoding, - str_replace("\r", "", str_replace("\n", "\\n", trim($value))) - ) + . str_replace("\r", "", str_replace("\n", "\\n", trim($value))) . "\n") ); fclose($fp); @@ -463,4 +375,3 @@ function save_message($locale, $key, $value) } $messages = array(); -$output_encoding = array(); diff --git a/src/mibew/libs/common/request.php b/src/mibew/libs/common/request.php index 4ca81a0d..f2463a62 100644 --- a/src/mibew/libs/common/request.php +++ b/src/mibew/libs/common/request.php @@ -22,7 +22,7 @@ use Mibew\Settings; function get_raw_param($name) { if (isset($_POST[$name])) { - $value = myiconv("utf-8", MIBEW_ENCODING, $_POST[$name]); + $value = $_POST[$name]; if (get_magic_quotes_gpc()) { $value = stripslashes($value); } @@ -36,7 +36,7 @@ function get_raw_param($name) function get_param($name) { if (isset($_POST[$name])) { - $value = myiconv(getoutputenc(), MIBEW_ENCODING, $_POST[$name]); + $value = $_POST[$name]; if (get_magic_quotes_gpc()) { $value = stripslashes($value); } @@ -51,7 +51,7 @@ function get_get_param($name, $default = '') if (!isset($_GET[$name]) || !$_GET[$name]) { return $default; } - $value = myiconv("utf-8", MIBEW_ENCODING, unicode_urldecode($_GET[$name])); + $value = unicode_urldecode($_GET[$name]); if (get_magic_quotes_gpc()) { $value = stripslashes($value); } diff --git a/src/mibew/libs/common/response.php b/src/mibew/libs/common/response.php index 4acbcde9..ece1c2a6 100644 --- a/src/mibew/libs/common/response.php +++ b/src/mibew/libs/common/response.php @@ -77,11 +77,6 @@ function start_js_output() header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'); } -function to_page($text) -{ - return myiconv(MIBEW_ENCODING, getoutputenc(), $text); -} - /** * Load additional CSS files, required by plugins, and build HTML code to * include them diff --git a/src/mibew/libs/default_config.php b/src/mibew/libs/default_config.php index 7e962000..4d8f8275 100644 --- a/src/mibew/libs/default_config.php +++ b/src/mibew/libs/default_config.php @@ -27,11 +27,6 @@ */ $mibewroot = "/mibew"; -/* - * Internal encoding - */ -$mibew_encoding = "utf-8"; - /* * MySQL Database parameters */ @@ -41,7 +36,6 @@ $mysqllogin = ""; $mysqlpass = ""; $mysqlprefix = ""; -$dbencoding = "utf8"; $force_charset_in_connection = true; $use_persistent_connection = false; @@ -50,7 +44,6 @@ $use_persistent_connection = false; * Mailbox */ $mibew_mailbox = "mibew@yourdomain.com"; -$mail_encoding = "utf-8"; /* * Locales diff --git a/src/mibew/libs/init.php b/src/mibew/libs/init.php index 7d29581e..5ab4022d 100644 --- a/src/mibew/libs/init.php +++ b/src/mibew/libs/init.php @@ -53,7 +53,6 @@ require_once(MIBEW_FS_ROOT . '/vendor/autoload.php'); // Include common libs require_once(MIBEW_FS_ROOT . '/libs/common/configurations.php'); require_once(MIBEW_FS_ROOT . '/libs/common/verification.php'); -require_once(MIBEW_FS_ROOT . '/libs/common/converter.php'); require_once(MIBEW_FS_ROOT . '/libs/common/locale.php'); require_once(MIBEW_FS_ROOT . '/libs/common/csrf.php'); require_once(MIBEW_FS_ROOT . '/libs/common/datetime.php'); @@ -83,7 +82,7 @@ session_start(); $mysqldb, $mysqlprefix, $force_charset_in_connection, - $dbencoding + 'utf8' ); if (function_exists("date_default_timezone_set")) { diff --git a/src/mibew/libs/invitation.php b/src/mibew/libs/invitation.php index 94d083ad..5b7e84d6 100644 --- a/src/mibew/libs/invitation.php +++ b/src/mibew/libs/invitation.php @@ -302,7 +302,7 @@ function setup_invitation_view(Thread $thread) ); $data['invitation']['user'] = array( - 'name' => htmlspecialchars(to_page($thread->userName)), + 'name' => htmlspecialchars($thread->userName), 'canChangeName' => false, 'isAgent' => false, ); diff --git a/src/mibew/libs/notify.php b/src/mibew/libs/notify.php index 941a2ba2..fbb30187 100644 --- a/src/mibew/libs/notify.php +++ b/src/mibew/libs/notify.php @@ -15,25 +15,16 @@ * limitations under the License. */ -/** - * Send an email - * - * @param string $to_addr Comma separated list recipient emails - * @param string $reply_to Comma separated list replies emails - * @param string $subject subject of email - * @param string $body text of email. - */ function mibew_mail($to_addr, $reply_to, $subject, $body) { - global $mibew_mailbox, $mail_encoding; + global $mibew_mailbox; $headers = "From: $mibew_mailbox\r\n" - . "Reply-To: " . myiconv(MIBEW_ENCODING, $mail_encoding, $reply_to) . "\r\n" - . "Content-Type: text/plain; charset=$mail_encoding\r\n" + . "Reply-To: " . $reply_to . "\r\n" + . "Content-Type: text/plain; charset=utf-8\r\n" . 'X-Mailer: PHP/' . phpversion(); - $real_subject = "=?" . $mail_encoding . "?B?" - . base64_encode(myiconv(MIBEW_ENCODING, $mail_encoding, $subject)) . "?="; + $real_subject = "=?utf-8?B?" . base64_encode($subject) . "?="; $body = preg_replace("/\n/", "\r\n", $body); @@ -42,7 +33,7 @@ function mibew_mail($to_addr, $reply_to, $subject, $body) @mail( $to_addr, $real_subject, - wordwrap(myiconv(MIBEW_ENCODING, $mail_encoding, $body), 70), + wordwrap($body, 70), $headers ); if (isset($old_from)) { diff --git a/src/mibew/libs/operator.php b/src/mibew/libs/operator.php index f354523d..c7b5ecbd 100644 --- a/src/mibew/libs/operator.php +++ b/src/mibew/libs/operator.php @@ -701,8 +701,8 @@ function setup_redirect_links($threadid, $operator, $token) : getlocal("char.redirect.operator.away_suff")) : ""; $agent_list .= "
  • " - . to_page(get_operator_name($agent)) + . "\" title=\"" . get_operator_name($agent) . "\">" + . get_operator_name($agent) . " $status
  • "; } $result['redirectToAgent'] = $agent_list; @@ -716,8 +716,8 @@ function setup_redirect_links($threadid, $operator, $token) ? getlocal("char.redirect.operator.online_suff") : (group_is_away($group) ? getlocal("char.redirect.operator.away_suff") : ""); $group_list .= "
  • " - . to_page(get_group_name($group)) + . "\" title=\"" . get_group_name($group) . "\">" + . get_group_name($group) . " $status
  • "; } } @@ -771,7 +771,7 @@ function prepare_menu($operator, $has_right = true) $result = array(); $result['showMenu'] = true; - $result['operator'] = to_page(get_operator_name($operator)); + $result['operator'] = get_operator_name($operator); $result['goOnlineLink'] = getlocal2( "menu.goonline", array(MIBEW_WEB_ROOT . "/operator/users?nomenu") diff --git a/src/mibew/operator/agent.php b/src/mibew/operator/agent.php index 946b5d4a..95e8c438 100644 --- a/src/mibew/operator/agent.php +++ b/src/mibew/operator/agent.php @@ -77,8 +77,8 @@ if (!isset($_GET['token'])) { if ($force_take == false) { $page = array( - 'user' => to_page($thread->userName), - 'agent' => to_page($thread->agentName), + 'user' => $thread->userName, + 'agent' => $thread->agentName, 'link' => $_SERVER['PHP_SELF'] . "?thread=$thread_id&force=true", 'title' => getlocal("confirm.take.head"), ); diff --git a/src/mibew/operator/avatar.php b/src/mibew/operator/avatar.php index e069e0b1..23218705 100644 --- a/src/mibew/operator/avatar.php +++ b/src/mibew/operator/avatar.php @@ -83,7 +83,7 @@ if (!$op) { header("Location: " . MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . intval($op_id)); exit; } else { - $page['avatar'] = to_page($op['vcavatar']); + $page['avatar'] = $op['vcavatar']; } } else { if (isset($_GET['delete']) && $_GET['delete'] == "true" && $can_modify) { @@ -91,10 +91,10 @@ if (!$op) { header("Location: " . MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . intval($op_id)); exit; } - $page['avatar'] = to_page($op['vcavatar']); + $page['avatar'] = $op['vcavatar']; } -$page['currentop'] = $op ? to_page(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : getlocal("not_found"); +$page['currentop'] = $op ? get_operator_name($op) . " (" . $op['vclogin'] . ")" : getlocal("not_found"); $page['canmodify'] = $can_modify ? "1" : ""; $page['title'] = getlocal("page_avatar.title"); $page['menuid'] = ($operator['operatorid'] == $op_id) ? "profile" : "operators"; diff --git a/src/mibew/operator/ban.php b/src/mibew/operator/ban.php index 2718124c..a7cb519b 100644 --- a/src/mibew/operator/ban.php +++ b/src/mibew/operator/ban.php @@ -88,10 +88,10 @@ if (isset($_POST['address'])) { $page['saved'] = true; $page['address'] = $address; } else { - $page['banId'] = to_page($ban_id); - $page['formaddress'] = to_page($address); - $page['formdays'] = to_page($days); - $page['formcomment'] = to_page($comment); + $page['banId'] = $ban_id; + $page['formaddress'] = $address; + $page['formdays'] = $days; + $page['formcomment'] = $comment; $page['threadid'] = $thread_id; } } elseif (isset($_GET['id'])) { @@ -108,10 +108,10 @@ if (isset($_POST['address'])) { ); if ($ban) { - $page['banId'] = to_page($ban['banid']); - $page['formaddress'] = to_page($ban['address']); - $page['formdays'] = to_page(round($ban['days'] / 86400)); - $page['formcomment'] = to_page($ban['comment']); + $page['banId'] = $ban['banid']; + $page['formaddress'] = $ban['address']; + $page['formdays'] = round($ban['days'] / 86400); + $page['formcomment'] = $ban['comment']; } else { $page['errors'][] = "Wrong id"; } @@ -119,9 +119,9 @@ if (isset($_POST['address'])) { $thread_id = verify_param('thread', "/^\d{1,9}$/"); $thread = Thread::load($thread_id); if ($thread) { - $page['thread'] = htmlspecialchars(to_page($thread->userName)); + $page['thread'] = htmlspecialchars($thread->userName); $page['threadid'] = $thread_id; - $page['formaddress'] = to_page($thread->remote); + $page['formaddress'] = $thread->remote; $page['formdays'] = 15; } } diff --git a/src/mibew/operator/blocked.php b/src/mibew/operator/blocked.php index ee5666b3..56049993 100644 --- a/src/mibew/operator/blocked.php +++ b/src/mibew/operator/blocked.php @@ -54,7 +54,7 @@ $blocked_list = $db->query( ); foreach ($blocked_list as &$item) { - $item['comment'] = to_page($item['comment']); + $item['comment'] = $item['comment']; } unset($item); diff --git a/src/mibew/operator/canned.php b/src/mibew/operator/canned.php index a946239c..9f29fed4 100644 --- a/src/mibew/operator/canned.php +++ b/src/mibew/operator/canned.php @@ -89,8 +89,8 @@ if (isset($_GET['act']) && $_GET['act'] == 'delete') { $canned_messages = load_canned_messages($lang, $group_id); foreach ($canned_messages as &$message) { - $message['vctitle'] = to_page($message['vctitle']); - $message['vcvalue'] = to_page($message['vcvalue']); + $message['vctitle'] = $message['vctitle']; + $message['vcvalue'] = $message['vcvalue']; } unset($message); diff --git a/src/mibew/operator/cannededit.php b/src/mibew/operator/cannededit.php index 2a5447f7..2c673530 100644 --- a/src/mibew/operator/cannededit.php +++ b/src/mibew/operator/cannededit.php @@ -75,8 +75,8 @@ if (isset($_POST['message']) && isset($_POST['title'])) { $page['saved'] = false; $page['key'] = $string_id; -$page['formtitle'] = to_page($title); -$page['formmessage'] = to_page($message); +$page['formtitle'] = $title; +$page['formmessage'] = $message; $page['title'] = empty($string_id) ? getlocal("cannednew.title") : getlocal("cannededit.title"); $page = array_merge($page, prepare_menu($operator, false)); diff --git a/src/mibew/operator/group.php b/src/mibew/operator/group.php index c9e353cc..3ac887c9 100644 --- a/src/mibew/operator/group.php +++ b/src/mibew/operator/group.php @@ -109,18 +109,18 @@ if (isset($_POST['name'])) { exit; } } else { - $page['formname'] = to_page($name); - $page['formdescription'] = to_page($description); - $page['formcommonname'] = to_page($common_name); - $page['formcommondescription'] = to_page($common_description); - $page['formemail'] = to_page($email); - $page['formweight'] = to_page($weight); - $page['formparentgroup'] = to_page($parent_group); - $page['grid'] = to_page($group_id); - $page['formtitle'] = to_page($title); - $page['formchattitle'] = to_page($chat_title); - $page['formhosturl'] = to_page($host_url); - $page['formlogo'] = to_page($logo); + $page['formname'] = $name; + $page['formdescription'] = $description; + $page['formcommonname'] = $common_name; + $page['formcommondescription'] = $common_description; + $page['formemail'] = $email; + $page['formweight'] = $weight; + $page['formparentgroup'] = $parent_group; + $page['grid'] = $group_id; + $page['formtitle'] = $title; + $page['formchattitle'] = $chat_title; + $page['formhosturl'] = $host_url; + $page['formlogo'] = $logo; } } elseif (isset($_GET['gid'])) { $group_id = verify_param('gid', "/^\d{1,9}$/"); @@ -128,20 +128,20 @@ if (isset($_POST['name'])) { if (!$group) { $page['errors'][] = getlocal("page.group.no_such"); - $page['grid'] = to_page($group_id); + $page['grid'] = $group_id; } else { - $page['formname'] = to_page($group['vclocalname']); - $page['formdescription'] = to_page($group['vclocaldescription']); - $page['formcommonname'] = to_page($group['vccommonname']); - $page['formcommondescription'] = to_page($group['vccommondescription']); - $page['formemail'] = to_page($group['vcemail']); - $page['formweight'] = to_page($group['iweight']); - $page['formparentgroup'] = to_page($group['parent']); - $page['grid'] = to_page($group['groupid']); - $page['formtitle'] = to_page($group['vctitle']); - $page['formchattitle'] = to_page($group['vcchattitle']); - $page['formhosturl'] = to_page($group['vchosturl']); - $page['formlogo'] = to_page($group['vclogo']); + $page['formname'] = $group['vclocalname']; + $page['formdescription'] = $group['vclocaldescription']; + $page['formcommonname'] = $group['vccommonname']; + $page['formcommondescription'] = $group['vccommondescription']; + $page['formemail'] = $group['vcemail']; + $page['formweight'] = $group['iweight']; + $page['formparentgroup'] = $group['parent']; + $page['grid'] = $group['groupid']; + $page['formtitle'] = $group['vctitle']; + $page['formchattitle'] = $group['vcchattitle']; + $page['formhosturl'] = $group['vchosturl']; + $page['formlogo'] = $group['vclogo']; } } diff --git a/src/mibew/operator/groupmembers.php b/src/mibew/operator/groupmembers.php index 3dd170b6..fce8d6f3 100644 --- a/src/mibew/operator/groupmembers.php +++ b/src/mibew/operator/groupmembers.php @@ -50,7 +50,7 @@ if (!$group) { } $page['formop'] = array(); -$page['currentgroup'] = $group ? to_page(htmlspecialchars($group['vclocalname'])) : ""; +$page['currentgroup'] = $group ? htmlspecialchars($group['vclocalname']) : ""; $checked_operators = array(); foreach (get_group_members($group_id) as $rel) { @@ -59,8 +59,8 @@ foreach (get_group_members($group_id) as $rel) { $page['operators'] = array(); foreach ($operators as $op) { - $op['vclocalename'] = to_page($op['vclocalename']); - $op['vclogin'] = to_page($op['vclogin']); + $op['vclocalename'] = $op['vclocalename']; + $op['vclogin'] = $op['vclogin']; $op['checked'] = in_array($op['operatorid'], $checked_operators); $page['operators'][] = $op; diff --git a/src/mibew/operator/groups.php b/src/mibew/operator/groups.php index 27aec0fa..dce0ce80 100644 --- a/src/mibew/operator/groups.php +++ b/src/mibew/operator/groups.php @@ -57,12 +57,12 @@ $sort['desc'] = (verify_param("sortdirection", "/^(desc|asc)$/", "desc") == "des // Load and prepare groups $groups = get_sorted_groups($sort); foreach ($groups as &$group) { - $group['vclocalname'] = to_page($group['vclocalname']); - $group['vclocaldescription'] = to_page($group['vclocaldescription']); + $group['vclocalname'] = $group['vclocalname']; + $group['vclocaldescription'] = $group['vclocaldescription']; $group['isOnline'] = group_is_online($group); $group['isAway'] = group_is_away($group); $group['lastTimeOnline'] = time() - ($group['ilastseen'] ? $group['ilastseen'] : time()); - $group['inumofagents'] = to_page($group['inumofagents']); + $group['inumofagents'] = $group['inumofagents']; } unset($group); diff --git a/src/mibew/operator/operator.php b/src/mibew/operator/operator.php index 59677a40..395584ef 100644 --- a/src/mibew/operator/operator.php +++ b/src/mibew/operator/operator.php @@ -123,12 +123,12 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse exit; } } else { - $page['formlogin'] = to_page($login); - $page['formname'] = to_page($local_name); - $page['formemail'] = to_page($email); - $page['formcommonname'] = to_page($common_name); - $page['formcode'] = to_page($code); - $page['opid'] = to_page($op_id); + $page['formlogin'] = $login; + $page['formname'] = $local_name; + $page['formemail'] = $email; + $page['formcommonname'] = $common_name; + $page['formcode'] = $code; + $page['opid'] = $op_id; } } elseif (isset($_GET['op'])) { $op_id = verify_param('op', "/^\d{1,9}$/"); @@ -136,19 +136,19 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse if (!$op) { $page['errors'][] = getlocal("no_such_operator"); - $page['opid'] = to_page($op_id); + $page['opid'] = $op_id; } else { //show an error if the admin password hasn't been set yet. if (check_password_hash($operator['vclogin'], '', $operator['vcpassword']) && !isset($_GET['stored'])) { $page['errors'][] = getlocal("my_settings.error.no_password"); } - $page['formlogin'] = to_page($op['vclogin']); - $page['formname'] = to_page($op['vclocalename']); - $page['formemail'] = to_page($op['vcemail']); - $page['formcommonname'] = to_page($op['vccommonname']); - $page['formcode'] = to_page($op['code']); - $page['opid'] = to_page($op['operatorid']); + $page['formlogin'] = $op['vclogin']; + $page['formname'] = $op['vclocalename']; + $page['formemail'] = $op['vcemail']; + $page['formcommonname'] = $op['vccommonname']; + $page['formcode'] = $op['code']; + $page['opid'] = $op['operatorid']; } } diff --git a/src/mibew/operator/operators.php b/src/mibew/operator/operators.php index c53059df..dcb627e9 100644 --- a/src/mibew/operator/operators.php +++ b/src/mibew/operator/operators.php @@ -108,9 +108,9 @@ $operators_list = get_operators_list($list_options); // Prepare operator to render in template foreach ($operators_list as &$item) { - $item['vclogin'] = to_page($item['vclogin']); - $item['vclocalename'] = to_page($item['vclocalename']); - $item['vccommonname'] = to_page($item['vccommonname']); + $item['vclogin'] = $item['vclogin']; + $item['vclocalename'] = $item['vclocalename']; + $item['vccommonname'] = $item['vccommonname']; $item['isAvailable'] = operator_is_available($item); $item['isAway'] = operator_is_away($item); $item['lastTimeOnline'] = time() - $item['time']; diff --git a/src/mibew/operator/opgroups.php b/src/mibew/operator/opgroups.php index 5d930c31..f26f7843 100644 --- a/src/mibew/operator/opgroups.php +++ b/src/mibew/operator/opgroups.php @@ -63,7 +63,7 @@ if (!$op) { } $page['currentop'] = $op - ? to_page(get_operator_name($op)) . " (" . $op['vclogin'] . ")" + ? get_operator_name($op) . " (" . $op['vclogin'] . ")" : getlocal("not_found"); $page['canmodify'] = $can_modify ? "1" : ""; @@ -76,8 +76,8 @@ if ($op) { $page['groups'] = array(); foreach ($groups as $group) { - $group['vclocalname'] = to_page($group['vclocalname']); - $group['vclocaldescription'] = to_page($group['vclocaldescription']); + $group['vclocalname'] = $group['vclocalname']; + $group['vclocaldescription'] = $group['vclocaldescription']; $group['checked'] = in_array($group['groupid'], $checked_groups); $page['groups'][] = $group; diff --git a/src/mibew/operator/permissions.php b/src/mibew/operator/permissions.php index 3844edc4..955c3ff9 100644 --- a/src/mibew/operator/permissions.php +++ b/src/mibew/operator/permissions.php @@ -62,7 +62,9 @@ if (!$op) { } } -$page['currentop'] = $op ? to_page(get_operator_name($op)) . " (" . $op['vclogin'] . ")" : getlocal("not_found"); +$page['currentop'] = $op + ? get_operator_name($op) . " (" . $op['vclogin'] . ")" + : getlocal("not_found"); $checked_permissions = array(); if ($op) { diff --git a/src/mibew/operator/redirect.php b/src/mibew/operator/redirect.php index 5acf4426..1fb6fe52 100644 --- a/src/mibew/operator/redirect.php +++ b/src/mibew/operator/redirect.php @@ -47,7 +47,7 @@ if (isset($_GET['nextGroup'])) { if ($next_group) { $page['message'] = getlocal2( "chat.redirected.group.content", - array(to_page(get_group_name($next_group))) + array(get_group_name($next_group)) ); if ($thread->state == Thread::STATE_CHATTING) { $thread->state = Thread::STATE_WAITING; @@ -79,7 +79,7 @@ if (isset($_GET['nextGroup'])) { if ($next_operator) { $page['message'] = getlocal2( "chat.redirected.content", - array(to_page(get_operator_name($next_operator))) + array(get_operator_name($next_operator)) ); if ($thread->state == Thread::STATE_CHATTING) { $thread->state = Thread::STATE_WAITING; diff --git a/src/mibew/operator/restore.php b/src/mibew/operator/restore.php index 624dd2fc..65aeed26 100644 --- a/src/mibew/operator/restore.php +++ b/src/mibew/operator/restore.php @@ -85,7 +85,7 @@ if (isset($_POST['loginoremail'])) { } } -$page['formloginoremail'] = to_page($login_or_email); +$page['formloginoremail'] = $login_or_email; $page['localeLinks'] = get_locale_links(MIBEW_WEB_ROOT . "/operator/restore.php"); $page['isdone'] = false; diff --git a/src/mibew/operator/settings.php b/src/mibew/operator/settings.php index e218f854..a097cd47 100644 --- a/src/mibew/operator/settings.php +++ b/src/mibew/operator/settings.php @@ -141,17 +141,17 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) { } } -$page['formemail'] = to_page($params['email']); -$page['formtitle'] = to_page($params['title']); -$page['formlogo'] = to_page($params['logo']); -$page['formhosturl'] = to_page($params['hosturl']); -$page['formgeolink'] = to_page($params['geolink']); -$page['formgeolinkparams'] = to_page($params['geolinkparams']); -$page['formusernamepattern'] = to_page($params['usernamepattern']); +$page['formemail'] = $params['email']; +$page['formtitle'] = $params['title']; +$page['formlogo'] = $params['logo']; +$page['formhosturl'] = $params['hosturl']; +$page['formgeolink'] = $params['geolink']; +$page['formgeolinkparams'] = $params['geolinkparams']; +$page['formusernamepattern'] = $params['usernamepattern']; $page['formpagestyle'] = $styles_params['page_style']; $page['availablePageStyles'] = $page_style_list; $page['formchatstyle'] = $styles_params['chat_style']; -$page['formchattitle'] = to_page($params['chattitle']); +$page['formchattitle'] = $params['chattitle']; $page['formsendmessagekey'] = $params['sendmessagekey']; $page['availableChatStyles'] = $chat_style_list; $page['stored'] = isset($_GET['stored']); diff --git a/src/mibew/operator/statistics.php b/src/mibew/operator/statistics.php index e373f9ab..599ea840 100644 --- a/src/mibew/operator/statistics.php +++ b/src/mibew/operator/statistics.php @@ -29,7 +29,7 @@ force_password($operator); setlocale(LC_TIME, getstring("time.locale")); $page = array(); -$page['operator'] = to_page(get_operator_name($operator)); +$page['operator'] = get_operator_name($operator); $page['availableDays'] = range(1, 31); $page['availableMonth'] = get_month_selection(time() - 400 * 24 * 60 * 60, time() + 50 * 24 * 60 * 60); $page['showresults'] = false; @@ -164,7 +164,7 @@ if ($statistics_type == 'bydate') { // cannot do it in a template. // TODO: Remove this block when "to_page" function will be removed. foreach ($page['reportByAgent'] as &$row) { - $row['name'] = to_page($row['name']); + $row['name'] = $row['name']; } unset($row); diff --git a/src/mibew/operator/translate.php b/src/mibew/operator/translate.php index 503aec5e..2ad20927 100644 --- a/src/mibew/operator/translate.php +++ b/src/mibew/operator/translate.php @@ -41,8 +41,8 @@ $lang2 = $messages[$target]; $page = array( 'lang1' => $source, 'lang2' => $target, - 'title1' => to_page(isset($lang1["localeid"]) ? $lang1["localeid"] : $source), - 'title2' => to_page(isset($lang2["localeid"]) ? $lang2["localeid"] : $target), + 'title1' => (isset($lang1["localeid"]) ? $lang1["localeid"] : $source), + 'title2' => (isset($lang2["localeid"]) ? $lang2["localeid"] : $target), 'errors' => array(), ); @@ -115,9 +115,9 @@ foreach ($all_keys as $key) { 'id' => $key, 'l1' => $t_source, 'l2' => $value, - 'idToPage' => to_page($key), - 'l1ToPage' => to_page($t_source), - 'l2ToPage' => to_page($value), + 'idToPage' => $key, + 'l1ToPage' => $t_source, + 'l2ToPage' => $value, ); } }