Use only UTF-8 encoding

This commit is contained in:
Dmitriy Simushev 2014-05-14 12:16:04 +00:00
parent a93517dcf1
commit 7042f3dd9e
36 changed files with 164 additions and 360 deletions

View File

@ -304,7 +304,7 @@ function show_install_err($text)
function create_table($id, $link) function create_table($id, $link)
{ {
global $dbtables, $dbtables_indexes, $memtables, $dbencoding, $mysqlprefix; global $dbtables, $dbtables_indexes, $memtables, $mysqlprefix;
if (!isset($dbtables[$id])) { if (!isset($dbtables[$id])) {
show_install_err("Unknown table: $id, " . mysql_error($link)); show_install_err("Unknown table: $id, " . mysql_error($link));
@ -324,7 +324,7 @@ function create_table($id, $link)
} }
$query = preg_replace("/,\n$/", "", $query); $query = preg_replace("/,\n$/", "", $query);
$query .= ") charset $dbencoding"; $query .= ") charset utf8";
if (in_array($id, $memtables)) { if (in_array($id, $memtables)) {
$query .= " ENGINE=MEMORY"; $query .= " ENGINE=MEMORY";
} else { } else {

View File

@ -37,7 +37,6 @@ define('MIBEW_WEB_ROOT', $mibewroot);
// Include common functions // Include common functions
require_once(MIBEW_FS_ROOT.'/libs/common/constants.php'); 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/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/locale.php');
require_once(MIBEW_FS_ROOT.'/libs/common/misc.php'); require_once(MIBEW_FS_ROOT.'/libs/common/misc.php');
require_once(MIBEW_FS_ROOT.'/libs/common/response.php'); require_once(MIBEW_FS_ROOT.'/libs/common/response.php');
@ -65,7 +64,7 @@ if ($act == "silentcreateall") {
} else { } else {
mysql_select_db($mysqldb, $link) or show_install_err('Could not select database'); mysql_select_db($mysqldb, $link) or show_install_err('Could not select database');
if ($force_charset_in_connection) { if ($force_charset_in_connection) {
mysql_query("SET character set $dbencoding", $link); mysql_query("SET character set utf8", $link);
} }
if ($act == "ct") { if ($act == "ct") {

View File

@ -52,7 +52,6 @@ define('MIBEW_WEB_ROOT', $base_url);
// Include common functions // Include common functions
require_once(MIBEW_FS_ROOT.'/libs/common/constants.php'); 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/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/locale.php');
require_once(MIBEW_FS_ROOT.'/libs/common/misc.php'); require_once(MIBEW_FS_ROOT.'/libs/common/misc.php');
require_once(MIBEW_FS_ROOT.'/libs/common/response.php'); require_once(MIBEW_FS_ROOT.'/libs/common/response.php');
@ -199,11 +198,11 @@ function check_connection()
function check_database($link) 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)) { if (mysql_select_db($mysqldb, $link)) {
$page['done'][] = getlocal2("install.2.db_exists", array($mysqldb)); $page['done'][] = getlocal2("install.2.db_exists", array($mysqldb));
if ($force_charset_in_connection) { if ($force_charset_in_connection) {
mysql_query("SET character set $dbencoding", $link); mysql_query("SET character set utf8", $link);
} }
return true; return true;
} else { } else {

View File

@ -221,10 +221,10 @@ function setup_logo($group = null)
: $top_level_group['vchosturl']; : $top_level_group['vchosturl'];
$data['company'] = array( $data['company'] = array(
'name' => to_page($group_name), 'name' => $group_name,
'chatLogoURL' => to_page($logo), 'chatLogoURL' => $logo,
); );
$data['mibewHost'] = to_page($mibew_host); $data['mibewHost'] = $mibew_host;
return $data; return $data;
} }
@ -285,12 +285,12 @@ function setup_leavemessage($name, $email, $group_id, $info, $referrer)
} }
$data['leaveMessage']['leaveMessageForm'] = array( $data['leaveMessage']['leaveMessageForm'] = array(
'name' => to_page($name), 'name' => $name,
'email' => to_page($email), 'email' => $email,
'groupId' => $group_id, 'groupId' => $group_id,
'groupName' => $group_name, 'groupName' => $group_name,
'info' => to_page($info), 'info' => $info,
'referrer' => to_page($referrer), 'referrer' => $referrer,
'showCaptcha' => (bool) (Settings::get("enablecaptcha") == "1" && can_show_captcha()), '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'] = array();
$data['survey']['surveyForm'] = array( $data['survey']['surveyForm'] = array(
'name' => to_page($name), 'name' => $name,
'groupId' => $group_id, 'groupId' => $group_id,
'email' => to_page($email), 'email' => $email,
'info' => to_page($info), 'info' => $info,
'referrer' => to_page($referrer), 'referrer' => $referrer,
'showEmail' => (bool) (Settings::get("surveyaskmail") == "1"), 'showEmail' => (bool) (Settings::get("surveyaskmail") == "1"),
'showMessage' => (bool) (Settings::get("surveyaskmessage") == "1"), 'showMessage' => (bool) (Settings::get("surveyaskmessage") == "1"),
'canChangeName' => (bool) (Settings::get('usercanchangename') == "1"), 'canChangeName' => (bool) (Settings::get('usercanchangename') == "1"),
@ -463,9 +463,9 @@ function setup_chatview(Thread $thread)
'token' => $thread->lastToken 'token' => $thread->lastToken
); );
$data['page.title'] = to_page( $data['page.title'] = empty($group['vcchattitle'])
empty($group['vcchattitle']) ? Settings::get('chattitle') : $group['vcchattitle'] ? Settings::get('chattitle')
); : $group['vcchattitle'];
$data['chat']['page'] = array( $data['chat']['page'] = array(
'title' => $data['page.title'] 'title' => $data['page.title']
); );
@ -516,7 +516,7 @@ function setup_chatview_for_user(Thread $thread)
// Set user info // Set user info
$data['chat']['user'] = array( $data['chat']['user'] = array(
'name' => htmlspecialchars(to_page($thread->userName)), 'name' => htmlspecialchars($thread->userName),
'canChangeName' => (bool) (Settings::get('usercanchangename') == "1"), 'canChangeName' => (bool) (Settings::get('usercanchangename') == "1"),
'defaultName' => (bool) (getstring("chat.default.username") != $thread->userName), 'defaultName' => (bool) (getstring("chat.default.username") != $thread->userName),
'canPost' => true, 'canPost' => true,
@ -556,12 +556,10 @@ function setup_chatview_for_operator(Thread $thread, $operator)
// Set operator info // Set operator info
$data['chat']['user'] = array( $data['chat']['user'] = array(
'name' => htmlspecialchars( 'name' => htmlspecialchars(
to_page( get_user_name(
get_user_name( $thread->userName,
$thread->userName, $thread->remote,
$thread->remote, $thread->userId
$thread->userId
)
) )
), ),
'canPost' => (bool) ($thread->agentId == $operator['operatorid']), 'canPost' => (bool) ($thread->agentId == $operator['operatorid']),
@ -607,13 +605,9 @@ function setup_chatview_for_operator(Thread $thread, $operator)
foreach ($canned_messages as $answer) { foreach ($canned_messages as $answer) {
$predefined_answers[] = array( $predefined_answers[] = array(
'short' => htmlspecialchars( 'short' => htmlspecialchars(
to_page($answer['vctitle'] ? $answer['vctitle'] : cut_string($answer['vcvalue'], 97, '...')) $answer['vctitle'] ? $answer['vctitle'] : cut_string($answer['vcvalue'], 97, '...')
), ),
'full' => myiconv( 'full' => $answer['vcvalue'],
MIBEW_ENCODING,
getoutputenc(),
$answer['vcvalue']
)
); );
} }
$data['chat']['messageForm']['predefinedAnswers'] = $predefined_answers; $data['chat']['messageForm']['predefinedAnswers'] = $predefined_answers;
@ -661,7 +655,7 @@ function visitor_from_request()
if (isset($_COOKIE[USERNAME_COOKIE_NAME])) { if (isset($_COOKIE[USERNAME_COOKIE_NAME])) {
$data = base64_decode(strtr($_COOKIE[USERNAME_COOKIE_NAME], '-_,', '+/=')); $data = base64_decode(strtr($_COOKIE[USERNAME_COOKIE_NAME], '-_,', '+/='));
if (strlen($data) > 0) { if (strlen($data) > 0) {
$user_name = myiconv("utf-8", MIBEW_ENCODING, $data); $user_name = $data;
} }
} }

View File

@ -38,9 +38,7 @@ class HistoryController extends AbstractController
$page = array(); $page = array();
$operator = $request->attributes->get('_operator'); $operator = $request->attributes->get('_operator');
$query = $request->query->has('q') $query = $request->query->get('q', false);
? myiconv(getoutputenc(), MIBEW_ENCODING, $request->query->get('q'))
: false;
$search_type = $request->query->get('type'); $search_type = $request->query->get('type');
if (!in_array($search_type, array('all', 'message', 'operator', 'visitor'))) { if (!in_array($search_type, array('all', 'message', 'operator', 'visitor'))) {
@ -135,12 +133,12 @@ class HistoryController extends AbstractController
$page['pagination.items'][] = array( $page['pagination.items'][] = array(
'threadId' => $thread->id, 'threadId' => $thread->id,
'userName' => to_page($thread->userName), 'userName' => $thread->userName,
'userAddress' => get_user_addr(to_page($thread->remote)), 'userAddress' => get_user_addr($thread->remote),
'agentName' => to_page($thread->agentName), 'agentName' => $thread->agentName,
'messageCount' => to_page($thread->messageCount), 'messageCount' => $thread->messageCount,
'groupName' => ($group_name_set 'groupName' => ($group_name_set
? to_page($group_name[$thread->groupId]) ? $group_name[$thread->groupId]
: false), : false),
'chatTime' => $thread->modified - $thread->created, 'chatTime' => $thread->modified - $thread->created,
'chatCreated' => $thread->created, 'chatCreated' => $thread->created,
@ -151,7 +149,7 @@ class HistoryController extends AbstractController
$page['pagination.items'] = false; $page['pagination.items'] = false;
} }
$page['formq'] = to_page($query); $page['formq'] = $query;
} else { } else {
$page['pagination'] = false; $page['pagination'] = false;
$page['pagination.items'] = false; $page['pagination.items'] = false;
@ -187,13 +185,13 @@ class HistoryController extends AbstractController
$group = group_by_id($thread->groupId); $group = group_by_id($thread->groupId);
$thread_info = array( $thread_info = array(
'userName' => to_page($thread->userName), 'userName' => $thread->userName,
'userAddress' => get_user_addr(to_page($thread->remote)), 'userAddress' => get_user_addr($thread->remote),
'userAgentVersion' => get_user_agent_version(to_page($thread->userAgent)), 'userAgentVersion' => get_user_agent_version($thread->userAgent),
'agentName' => to_page($thread->agentName), 'agentName' => $thread->agentName,
'chatTime' => ($thread->modified - $thread->created), 'chatTime' => ($thread->modified - $thread->created),
'chatStarted' => $thread->created, 'chatStarted' => $thread->created,
'groupName' => to_page(get_group_name($group)), 'groupName' => get_group_name($group),
); );
$page['threadInfo'] = $thread_info; $page['threadInfo'] = $thread_info;
@ -256,10 +254,10 @@ class HistoryController extends AbstractController
foreach ($page['pagination.items'] as $key => $item) { foreach ($page['pagination.items'] as $key => $item) {
$thread = Thread::createFromDbInfo($item); $thread = Thread::createFromDbInfo($item);
$page['pagination.items'][$key] = array( $page['pagination.items'][$key] = array(
'threadId' => to_page($thread->id), 'threadId' => $thread->id,
'userName' => to_page($thread->userName), 'userName' => $thread->userName,
'userAddress' => get_user_addr(to_page($thread->remote)), 'userAddress' => get_user_addr($thread->remote),
'agentName' => to_page($thread->agentName), 'agentName' => $thread->agentName,
'chatTime' => ($thread->modified - $thread->created), 'chatTime' => ($thread->modified - $thread->created),
'chatCreated' => $thread->created, 'chatCreated' => $thread->created,
); );

View File

@ -384,7 +384,7 @@ class ThreadProcessor extends ClientSideProcessor
//Rename user //Rename user
$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($args['name']), '+/=', '-_,');
setcookie(USERNAME_COOKIE_NAME, $data, time() + 60 * 60 * 24 * 365); 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'])) { if (Settings::get('usercanchangename') == "1" && !empty($args['name'])) {
$newname = $args['name']; $newname = $args['name'];
if ($newname != $visitor['name']) { if ($newname != $visitor['name']) {
$data = strtr( $data = strtr(base64_encode($newname), '+/=', '-_,');
base64_encode(myiconv(MIBEW_ENCODING, "utf-8", $newname)),
'+/=',
'-_,'
);
setcookie(USERNAME_COOKIE_NAME, $data, time() + 60 * 60 * 24 * 365); setcookie(USERNAME_COOKIE_NAME, $data, time() + 60 * 60 * 24 * 365);
$visitor['name'] = $newname; $visitor['name'] = $newname;
} }

View File

@ -521,12 +521,7 @@ class UsersProcessor extends ClientSideProcessor
$result_list[] = array( $result_list[] = array(
'id' => (int) $item['operatorid'], 'id' => (int) $item['operatorid'],
// Convert name to UTF-8 'name' => htmlspecialchars($item['vclocalename']),
'name' => myiconv(
MIBEW_ENCODING,
"utf-8",
htmlspecialchars($item['vclocalename'])
),
'away' => (bool) operator_is_away($item) 'away' => (bool) operator_is_away($item)
); );
} }

View File

@ -778,13 +778,6 @@ class Thread
); );
foreach ($messages as $key => $msg) { 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 // Process data attached to the message
if (!empty($messages[$key]['data'])) { if (!empty($messages[$key]['data'])) {
$messages[$key]['data'] = unserialize( $messages[$key]['data'] = unserialize(
@ -794,13 +787,6 @@ class Thread
$messages[$key]['data'] = array(); $messages[$key]['data'] = array();
} }
// Change message body encoding
$messages[$key]['message'] = myiconv(
MIBEW_ENCODING,
"utf-8",
$msg['message']
);
// Get last message ID // Get last message ID
if ($msg['id'] > $last_id) { if ($msg['id'] > $last_id) {
$last_id = $msg['id']; $last_id = $msg['id'];

View File

@ -50,11 +50,6 @@ define('DEFAULT_CRON_KEY', md5(
*/ */
define('VISITOR_COOKIE_NAME', 'MIBEW_VisitorID'); define('VISITOR_COOKIE_NAME', 'MIBEW_VisitorID');
/**
* Internal system encoding
*/
define('MIBEW_ENCODING', $mibew_encoding);
/** /**
* Names for chat-related cookies * Names for chat-related cookies
*/ */

View File

@ -1,49 +0,0 @@
<?php
/*
* Copyright 2005-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$_utf8win1251 = array(
"\xD0\x90" => "\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");

View File

@ -48,28 +48,6 @@ define(
*/ */
define('CURRENT_LOCALE', get_locale()); 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) function locale_exists($locale)
{ {
return file_exists(MIBEW_FS_ROOT . "/locales/$locale/properties"); 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. * Load localized messages id some service locale info.
* *
* @global array $messages Localized messages array * @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. * @param string $locale Name of a locale whose messages should be loaded.
*/ */
function load_messages($locale) function load_messages($locale)
{ {
global $messages, $output_encoding; global $messages;
// Load core localization // Load core localization
$locale_file = MIBEW_FS_ROOT . "/locales/{$locale}/properties"; $locale_file = MIBEW_FS_ROOT . "/locales/{$locale}/properties";
$locale_data = read_locale_file($locale_file); $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']; $messages[$locale] = $locale_data['messages'];
// Plugins are unavailable on system installation // Plugins are unavailable on system installation
@ -224,25 +197,13 @@ function load_messages($locale)
* *
* @param string $path Locale file path * @param string $path Locale file path
* @return array Associative array with following keys: * @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 * - 'messages': associative array of localized strings. The keys of the array
* are localization keys and the values of the array are localized strings. * are localization keys and the values of the array are localized strings.
* All localized strings have internal Mibew encoding(see $mibew_encoding * All localized strings are encoded in UTF-8.
* value in libs/config.php).
*/ */
function read_locale_file($path) function read_locale_file($path)
{ {
// Set default values // Set default values
$current_encoding = MIBEW_ENCODING;
$output_encoding = null;
$messages = array(); $messages = array();
$fp = fopen($path, "r"); $fp = fopen($path, "r");
@ -256,44 +217,16 @@ function read_locale_file($path)
if (count($line_parts) == 2) { if (count($line_parts) == 2) {
$key = $line_parts[0]; $key = $line_parts[0];
$value = $line_parts[1]; $value = $line_parts[1];
// Check if key is service field and treat it as $messages[$key] = str_replace("\\n", "\n", trim($value));
// 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))
);
}
} }
} }
fclose($fp); fclose($fp);
return array( return array(
'encoding' => $current_encoding,
'output_encoding' => $output_encoding,
'messages' => $messages '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) function getstring_($text, $locale, $raw = false)
{ {
global $messages; global $messages;
@ -326,11 +259,7 @@ function getlocal($text, $raw = false)
function getlocal_($text, $locale, $raw = false) function getlocal_($text, $locale, $raw = false)
{ {
$string = myiconv( $string = getstring_($text, $locale, true);
MIBEW_ENCODING,
getoutputenc(),
getstring_($text, $locale, true)
);
return $raw ? $string : sanitize_string($string, 'low', 'moderate'); return $raw ? $string : sanitize_string($string, 'low', 'moderate');
} }
@ -352,11 +281,7 @@ function getstring2($text, $params, $raw = false)
function getlocal2($text, $params, $raw = false) function getlocal2($text, $params, $raw = false)
{ {
$string = myiconv( $string = getstring_($text, CURRENT_LOCALE, true);
MIBEW_ENCODING,
getoutputenc(),
getstring_($text, CURRENT_LOCALE, true)
);
for ($i = 0; $i < count($params); $i++) { for ($i = 0; $i < count($params); $i++) {
$string = str_replace("{" . $i . "}", $params[$i], $string); $string = str_replace("{" . $i . "}", $params[$i], $string);
@ -368,7 +293,7 @@ function getlocal2($text, $params, $raw = false)
/* prepares for Javascript string */ /* prepares for Javascript string */
function get_local_for_js($text, $params) 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)); $string = str_replace("\"", "\\\"", str_replace("\n", "\\n", $string));
for ($i = 0; $i < count($params); $i++) { for ($i = 0; $i < count($params); $i++) {
$string = str_replace("{" . $i . "}", $params[$i], $string); $string = str_replace("{" . $i . "}", $params[$i], $string);
@ -398,7 +323,6 @@ function save_message($locale, $key, $value)
{ {
$result = ""; $result = "";
$added = false; $added = false;
$current_encoding = MIBEW_ENCODING;
$fp = fopen(MIBEW_FS_ROOT . "/locales/$locale/properties", "r"); $fp = fopen(MIBEW_FS_ROOT . "/locales/$locale/properties", "r");
if ($fp === false) { if ($fp === false) {
die("unable to open properties for locale $locale"); die("unable to open properties for locale $locale");
@ -407,15 +331,10 @@ function save_message($locale, $key, $value)
$line = fgets($fp, 4096); $line = fgets($fp, 4096);
$key_val = preg_split("/=/", $line, 2); $key_val = preg_split("/=/", $line, 2);
if (isset($key_val[1])) { if (isset($key_val[1])) {
if ($key_val[0] == 'encoding') { if (!$added && $key_val[0] == $key) {
$current_encoding = trim($key_val[1]);
} elseif (!$added && $key_val[0] == $key) {
$line = "$key=" $line = "$key="
. myiconv( . str_replace("\r", "", str_replace("\n", "\\n", trim($value)))
MIBEW_ENCODING, . "\n";
$current_encoding,
str_replace("\r", "", str_replace("\n", "\\n", trim($value)))
) . "\n";
$added = true; $added = true;
} }
} }
@ -424,11 +343,8 @@ function save_message($locale, $key, $value)
fclose($fp); fclose($fp);
if (!$added) { if (!$added) {
$result .= "$key=" $result .= "$key="
. myiconv( . str_replace("\r", "", str_replace("\n", "\\n", trim($value)))
MIBEW_ENCODING, . "\n";
$current_encoding,
str_replace("\r", "", str_replace("\n", "\\n", trim($value)))
) . "\n";
} }
$fp = @fopen(MIBEW_FS_ROOT . "/locales/$locale/properties", "w"); $fp = @fopen(MIBEW_FS_ROOT . "/locales/$locale/properties", "w");
if ($fp !== false) { if ($fp !== false) {
@ -451,11 +367,7 @@ function save_message($locale, $key, $value)
fwrite( fwrite(
$fp, $fp,
("$key=" ("$key="
. myiconv( . str_replace("\r", "", str_replace("\n", "\\n", trim($value)))
MIBEW_ENCODING,
$current_encoding,
str_replace("\r", "", str_replace("\n", "\\n", trim($value)))
)
. "\n") . "\n")
); );
fclose($fp); fclose($fp);
@ -463,4 +375,3 @@ function save_message($locale, $key, $value)
} }
$messages = array(); $messages = array();
$output_encoding = array();

View File

@ -22,7 +22,7 @@ use Mibew\Settings;
function get_raw_param($name) function get_raw_param($name)
{ {
if (isset($_POST[$name])) { if (isset($_POST[$name])) {
$value = myiconv("utf-8", MIBEW_ENCODING, $_POST[$name]); $value = $_POST[$name];
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$value = stripslashes($value); $value = stripslashes($value);
} }
@ -36,7 +36,7 @@ function get_raw_param($name)
function get_param($name) function get_param($name)
{ {
if (isset($_POST[$name])) { if (isset($_POST[$name])) {
$value = myiconv(getoutputenc(), MIBEW_ENCODING, $_POST[$name]); $value = $_POST[$name];
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$value = stripslashes($value); $value = stripslashes($value);
} }
@ -51,7 +51,7 @@ function get_get_param($name, $default = '')
if (!isset($_GET[$name]) || !$_GET[$name]) { if (!isset($_GET[$name]) || !$_GET[$name]) {
return $default; return $default;
} }
$value = myiconv("utf-8", MIBEW_ENCODING, unicode_urldecode($_GET[$name])); $value = unicode_urldecode($_GET[$name]);
if (get_magic_quotes_gpc()) { if (get_magic_quotes_gpc()) {
$value = stripslashes($value); $value = stripslashes($value);
} }

View File

@ -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"'); 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 * Load additional CSS files, required by plugins, and build HTML code to
* include them * include them

View File

@ -27,11 +27,6 @@
*/ */
$mibewroot = "/mibew"; $mibewroot = "/mibew";
/*
* Internal encoding
*/
$mibew_encoding = "utf-8";
/* /*
* MySQL Database parameters * MySQL Database parameters
*/ */
@ -41,7 +36,6 @@ $mysqllogin = "";
$mysqlpass = ""; $mysqlpass = "";
$mysqlprefix = ""; $mysqlprefix = "";
$dbencoding = "utf8";
$force_charset_in_connection = true; $force_charset_in_connection = true;
$use_persistent_connection = false; $use_persistent_connection = false;
@ -50,7 +44,6 @@ $use_persistent_connection = false;
* Mailbox * Mailbox
*/ */
$mibew_mailbox = "mibew@yourdomain.com"; $mibew_mailbox = "mibew@yourdomain.com";
$mail_encoding = "utf-8";
/* /*
* Locales * Locales

View File

@ -53,7 +53,6 @@ require_once(MIBEW_FS_ROOT . '/vendor/autoload.php');
// Include common libs // Include common libs
require_once(MIBEW_FS_ROOT . '/libs/common/configurations.php'); 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/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/locale.php');
require_once(MIBEW_FS_ROOT . '/libs/common/csrf.php'); require_once(MIBEW_FS_ROOT . '/libs/common/csrf.php');
require_once(MIBEW_FS_ROOT . '/libs/common/datetime.php'); require_once(MIBEW_FS_ROOT . '/libs/common/datetime.php');
@ -83,7 +82,7 @@ session_start();
$mysqldb, $mysqldb,
$mysqlprefix, $mysqlprefix,
$force_charset_in_connection, $force_charset_in_connection,
$dbencoding 'utf8'
); );
if (function_exists("date_default_timezone_set")) { if (function_exists("date_default_timezone_set")) {

View File

@ -302,7 +302,7 @@ function setup_invitation_view(Thread $thread)
); );
$data['invitation']['user'] = array( $data['invitation']['user'] = array(
'name' => htmlspecialchars(to_page($thread->userName)), 'name' => htmlspecialchars($thread->userName),
'canChangeName' => false, 'canChangeName' => false,
'isAgent' => false, 'isAgent' => false,
); );

View File

@ -15,25 +15,16 @@
* limitations under the License. * 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) function mibew_mail($to_addr, $reply_to, $subject, $body)
{ {
global $mibew_mailbox, $mail_encoding; global $mibew_mailbox;
$headers = "From: $mibew_mailbox\r\n" $headers = "From: $mibew_mailbox\r\n"
. "Reply-To: " . myiconv(MIBEW_ENCODING, $mail_encoding, $reply_to) . "\r\n" . "Reply-To: " . $reply_to . "\r\n"
. "Content-Type: text/plain; charset=$mail_encoding\r\n" . "Content-Type: text/plain; charset=utf-8\r\n"
. 'X-Mailer: PHP/' . phpversion(); . 'X-Mailer: PHP/' . phpversion();
$real_subject = "=?" . $mail_encoding . "?B?" $real_subject = "=?utf-8?B?" . base64_encode($subject) . "?=";
. base64_encode(myiconv(MIBEW_ENCODING, $mail_encoding, $subject)) . "?=";
$body = preg_replace("/\n/", "\r\n", $body); $body = preg_replace("/\n/", "\r\n", $body);
@ -42,7 +33,7 @@ function mibew_mail($to_addr, $reply_to, $subject, $body)
@mail( @mail(
$to_addr, $to_addr,
$real_subject, $real_subject,
wordwrap(myiconv(MIBEW_ENCODING, $mail_encoding, $body), 70), wordwrap($body, 70),
$headers $headers
); );
if (isset($old_from)) { if (isset($old_from)) {

View File

@ -701,8 +701,8 @@ function setup_redirect_links($threadid, $operator, $token)
: getlocal("char.redirect.operator.away_suff")) : getlocal("char.redirect.operator.away_suff"))
: ""; : "";
$agent_list .= "<li><a href=\"" . add_params(MIBEW_WEB_ROOT . "/operator/redirect.php", $params) $agent_list .= "<li><a href=\"" . add_params(MIBEW_WEB_ROOT . "/operator/redirect.php", $params)
. "\" title=\"" . to_page(get_operator_name($agent)) . "\">" . "\" title=\"" . get_operator_name($agent) . "\">"
. to_page(get_operator_name($agent)) . get_operator_name($agent)
. "</a> $status</li>"; . "</a> $status</li>";
} }
$result['redirectToAgent'] = $agent_list; $result['redirectToAgent'] = $agent_list;
@ -716,8 +716,8 @@ function setup_redirect_links($threadid, $operator, $token)
? getlocal("char.redirect.operator.online_suff") ? getlocal("char.redirect.operator.online_suff")
: (group_is_away($group) ? getlocal("char.redirect.operator.away_suff") : ""); : (group_is_away($group) ? getlocal("char.redirect.operator.away_suff") : "");
$group_list .= "<li><a href=\"" . add_params(MIBEW_WEB_ROOT . "/operator/redirect.php", $params) $group_list .= "<li><a href=\"" . add_params(MIBEW_WEB_ROOT . "/operator/redirect.php", $params)
. "\" title=\"" . to_page(get_group_name($group)) . "\">" . "\" title=\"" . get_group_name($group) . "\">"
. to_page(get_group_name($group)) . get_group_name($group)
. "</a> $status</li>"; . "</a> $status</li>";
} }
} }
@ -771,7 +771,7 @@ function prepare_menu($operator, $has_right = true)
$result = array(); $result = array();
$result['showMenu'] = true; $result['showMenu'] = true;
$result['operator'] = to_page(get_operator_name($operator)); $result['operator'] = get_operator_name($operator);
$result['goOnlineLink'] = getlocal2( $result['goOnlineLink'] = getlocal2(
"menu.goonline", "menu.goonline",
array(MIBEW_WEB_ROOT . "/operator/users?nomenu") array(MIBEW_WEB_ROOT . "/operator/users?nomenu")

View File

@ -77,8 +77,8 @@ if (!isset($_GET['token'])) {
if ($force_take == false) { if ($force_take == false) {
$page = array( $page = array(
'user' => to_page($thread->userName), 'user' => $thread->userName,
'agent' => to_page($thread->agentName), 'agent' => $thread->agentName,
'link' => $_SERVER['PHP_SELF'] . "?thread=$thread_id&force=true", 'link' => $_SERVER['PHP_SELF'] . "?thread=$thread_id&force=true",
'title' => getlocal("confirm.take.head"), 'title' => getlocal("confirm.take.head"),
); );

View File

@ -83,7 +83,7 @@ if (!$op) {
header("Location: " . MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . intval($op_id)); header("Location: " . MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . intval($op_id));
exit; exit;
} else { } else {
$page['avatar'] = to_page($op['vcavatar']); $page['avatar'] = $op['vcavatar'];
} }
} else { } else {
if (isset($_GET['delete']) && $_GET['delete'] == "true" && $can_modify) { 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)); header("Location: " . MIBEW_WEB_ROOT . "/operator/avatar.php?op=" . intval($op_id));
exit; 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['canmodify'] = $can_modify ? "1" : "";
$page['title'] = getlocal("page_avatar.title"); $page['title'] = getlocal("page_avatar.title");
$page['menuid'] = ($operator['operatorid'] == $op_id) ? "profile" : "operators"; $page['menuid'] = ($operator['operatorid'] == $op_id) ? "profile" : "operators";

View File

@ -88,10 +88,10 @@ if (isset($_POST['address'])) {
$page['saved'] = true; $page['saved'] = true;
$page['address'] = $address; $page['address'] = $address;
} else { } else {
$page['banId'] = to_page($ban_id); $page['banId'] = $ban_id;
$page['formaddress'] = to_page($address); $page['formaddress'] = $address;
$page['formdays'] = to_page($days); $page['formdays'] = $days;
$page['formcomment'] = to_page($comment); $page['formcomment'] = $comment;
$page['threadid'] = $thread_id; $page['threadid'] = $thread_id;
} }
} elseif (isset($_GET['id'])) { } elseif (isset($_GET['id'])) {
@ -108,10 +108,10 @@ if (isset($_POST['address'])) {
); );
if ($ban) { if ($ban) {
$page['banId'] = to_page($ban['banid']); $page['banId'] = $ban['banid'];
$page['formaddress'] = to_page($ban['address']); $page['formaddress'] = $ban['address'];
$page['formdays'] = to_page(round($ban['days'] / 86400)); $page['formdays'] = round($ban['days'] / 86400);
$page['formcomment'] = to_page($ban['comment']); $page['formcomment'] = $ban['comment'];
} else { } else {
$page['errors'][] = "Wrong id"; $page['errors'][] = "Wrong id";
} }
@ -119,9 +119,9 @@ if (isset($_POST['address'])) {
$thread_id = verify_param('thread', "/^\d{1,9}$/"); $thread_id = verify_param('thread', "/^\d{1,9}$/");
$thread = Thread::load($thread_id); $thread = Thread::load($thread_id);
if ($thread) { if ($thread) {
$page['thread'] = htmlspecialchars(to_page($thread->userName)); $page['thread'] = htmlspecialchars($thread->userName);
$page['threadid'] = $thread_id; $page['threadid'] = $thread_id;
$page['formaddress'] = to_page($thread->remote); $page['formaddress'] = $thread->remote;
$page['formdays'] = 15; $page['formdays'] = 15;
} }
} }

View File

@ -54,7 +54,7 @@ $blocked_list = $db->query(
); );
foreach ($blocked_list as &$item) { foreach ($blocked_list as &$item) {
$item['comment'] = to_page($item['comment']); $item['comment'] = $item['comment'];
} }
unset($item); unset($item);

View File

@ -89,8 +89,8 @@ if (isset($_GET['act']) && $_GET['act'] == 'delete') {
$canned_messages = load_canned_messages($lang, $group_id); $canned_messages = load_canned_messages($lang, $group_id);
foreach ($canned_messages as &$message) { foreach ($canned_messages as &$message) {
$message['vctitle'] = to_page($message['vctitle']); $message['vctitle'] = $message['vctitle'];
$message['vcvalue'] = to_page($message['vcvalue']); $message['vcvalue'] = $message['vcvalue'];
} }
unset($message); unset($message);

View File

@ -75,8 +75,8 @@ if (isset($_POST['message']) && isset($_POST['title'])) {
$page['saved'] = false; $page['saved'] = false;
$page['key'] = $string_id; $page['key'] = $string_id;
$page['formtitle'] = to_page($title); $page['formtitle'] = $title;
$page['formmessage'] = to_page($message); $page['formmessage'] = $message;
$page['title'] = empty($string_id) ? getlocal("cannednew.title") : getlocal("cannededit.title"); $page['title'] = empty($string_id) ? getlocal("cannednew.title") : getlocal("cannededit.title");
$page = array_merge($page, prepare_menu($operator, false)); $page = array_merge($page, prepare_menu($operator, false));

View File

@ -109,18 +109,18 @@ if (isset($_POST['name'])) {
exit; exit;
} }
} else { } else {
$page['formname'] = to_page($name); $page['formname'] = $name;
$page['formdescription'] = to_page($description); $page['formdescription'] = $description;
$page['formcommonname'] = to_page($common_name); $page['formcommonname'] = $common_name;
$page['formcommondescription'] = to_page($common_description); $page['formcommondescription'] = $common_description;
$page['formemail'] = to_page($email); $page['formemail'] = $email;
$page['formweight'] = to_page($weight); $page['formweight'] = $weight;
$page['formparentgroup'] = to_page($parent_group); $page['formparentgroup'] = $parent_group;
$page['grid'] = to_page($group_id); $page['grid'] = $group_id;
$page['formtitle'] = to_page($title); $page['formtitle'] = $title;
$page['formchattitle'] = to_page($chat_title); $page['formchattitle'] = $chat_title;
$page['formhosturl'] = to_page($host_url); $page['formhosturl'] = $host_url;
$page['formlogo'] = to_page($logo); $page['formlogo'] = $logo;
} }
} elseif (isset($_GET['gid'])) { } elseif (isset($_GET['gid'])) {
$group_id = verify_param('gid', "/^\d{1,9}$/"); $group_id = verify_param('gid', "/^\d{1,9}$/");
@ -128,20 +128,20 @@ if (isset($_POST['name'])) {
if (!$group) { if (!$group) {
$page['errors'][] = getlocal("page.group.no_such"); $page['errors'][] = getlocal("page.group.no_such");
$page['grid'] = to_page($group_id); $page['grid'] = $group_id;
} else { } else {
$page['formname'] = to_page($group['vclocalname']); $page['formname'] = $group['vclocalname'];
$page['formdescription'] = to_page($group['vclocaldescription']); $page['formdescription'] = $group['vclocaldescription'];
$page['formcommonname'] = to_page($group['vccommonname']); $page['formcommonname'] = $group['vccommonname'];
$page['formcommondescription'] = to_page($group['vccommondescription']); $page['formcommondescription'] = $group['vccommondescription'];
$page['formemail'] = to_page($group['vcemail']); $page['formemail'] = $group['vcemail'];
$page['formweight'] = to_page($group['iweight']); $page['formweight'] = $group['iweight'];
$page['formparentgroup'] = to_page($group['parent']); $page['formparentgroup'] = $group['parent'];
$page['grid'] = to_page($group['groupid']); $page['grid'] = $group['groupid'];
$page['formtitle'] = to_page($group['vctitle']); $page['formtitle'] = $group['vctitle'];
$page['formchattitle'] = to_page($group['vcchattitle']); $page['formchattitle'] = $group['vcchattitle'];
$page['formhosturl'] = to_page($group['vchosturl']); $page['formhosturl'] = $group['vchosturl'];
$page['formlogo'] = to_page($group['vclogo']); $page['formlogo'] = $group['vclogo'];
} }
} }

View File

@ -50,7 +50,7 @@ if (!$group) {
} }
$page['formop'] = array(); $page['formop'] = array();
$page['currentgroup'] = $group ? to_page(htmlspecialchars($group['vclocalname'])) : ""; $page['currentgroup'] = $group ? htmlspecialchars($group['vclocalname']) : "";
$checked_operators = array(); $checked_operators = array();
foreach (get_group_members($group_id) as $rel) { foreach (get_group_members($group_id) as $rel) {
@ -59,8 +59,8 @@ foreach (get_group_members($group_id) as $rel) {
$page['operators'] = array(); $page['operators'] = array();
foreach ($operators as $op) { foreach ($operators as $op) {
$op['vclocalename'] = to_page($op['vclocalename']); $op['vclocalename'] = $op['vclocalename'];
$op['vclogin'] = to_page($op['vclogin']); $op['vclogin'] = $op['vclogin'];
$op['checked'] = in_array($op['operatorid'], $checked_operators); $op['checked'] = in_array($op['operatorid'], $checked_operators);
$page['operators'][] = $op; $page['operators'][] = $op;

View File

@ -57,12 +57,12 @@ $sort['desc'] = (verify_param("sortdirection", "/^(desc|asc)$/", "desc") == "des
// Load and prepare groups // Load and prepare groups
$groups = get_sorted_groups($sort); $groups = get_sorted_groups($sort);
foreach ($groups as &$group) { foreach ($groups as &$group) {
$group['vclocalname'] = to_page($group['vclocalname']); $group['vclocalname'] = $group['vclocalname'];
$group['vclocaldescription'] = to_page($group['vclocaldescription']); $group['vclocaldescription'] = $group['vclocaldescription'];
$group['isOnline'] = group_is_online($group); $group['isOnline'] = group_is_online($group);
$group['isAway'] = group_is_away($group); $group['isAway'] = group_is_away($group);
$group['lastTimeOnline'] = time() - ($group['ilastseen'] ? $group['ilastseen'] : time()); $group['lastTimeOnline'] = time() - ($group['ilastseen'] ? $group['ilastseen'] : time());
$group['inumofagents'] = to_page($group['inumofagents']); $group['inumofagents'] = $group['inumofagents'];
} }
unset($group); unset($group);

View File

@ -123,12 +123,12 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
exit; exit;
} }
} else { } else {
$page['formlogin'] = to_page($login); $page['formlogin'] = $login;
$page['formname'] = to_page($local_name); $page['formname'] = $local_name;
$page['formemail'] = to_page($email); $page['formemail'] = $email;
$page['formcommonname'] = to_page($common_name); $page['formcommonname'] = $common_name;
$page['formcode'] = to_page($code); $page['formcode'] = $code;
$page['opid'] = to_page($op_id); $page['opid'] = $op_id;
} }
} elseif (isset($_GET['op'])) { } elseif (isset($_GET['op'])) {
$op_id = verify_param('op', "/^\d{1,9}$/"); $op_id = verify_param('op', "/^\d{1,9}$/");
@ -136,19 +136,19 @@ if ((isset($_POST['login']) || !is_capable(CAN_ADMINISTRATE, $operator)) && isse
if (!$op) { if (!$op) {
$page['errors'][] = getlocal("no_such_operator"); $page['errors'][] = getlocal("no_such_operator");
$page['opid'] = to_page($op_id); $page['opid'] = $op_id;
} else { } else {
//show an error if the admin password hasn't been set yet. //show an error if the admin password hasn't been set yet.
if (check_password_hash($operator['vclogin'], '', $operator['vcpassword']) && !isset($_GET['stored'])) { if (check_password_hash($operator['vclogin'], '', $operator['vcpassword']) && !isset($_GET['stored'])) {
$page['errors'][] = getlocal("my_settings.error.no_password"); $page['errors'][] = getlocal("my_settings.error.no_password");
} }
$page['formlogin'] = to_page($op['vclogin']); $page['formlogin'] = $op['vclogin'];
$page['formname'] = to_page($op['vclocalename']); $page['formname'] = $op['vclocalename'];
$page['formemail'] = to_page($op['vcemail']); $page['formemail'] = $op['vcemail'];
$page['formcommonname'] = to_page($op['vccommonname']); $page['formcommonname'] = $op['vccommonname'];
$page['formcode'] = to_page($op['code']); $page['formcode'] = $op['code'];
$page['opid'] = to_page($op['operatorid']); $page['opid'] = $op['operatorid'];
} }
} }

View File

@ -108,9 +108,9 @@ $operators_list = get_operators_list($list_options);
// Prepare operator to render in template // Prepare operator to render in template
foreach ($operators_list as &$item) { foreach ($operators_list as &$item) {
$item['vclogin'] = to_page($item['vclogin']); $item['vclogin'] = $item['vclogin'];
$item['vclocalename'] = to_page($item['vclocalename']); $item['vclocalename'] = $item['vclocalename'];
$item['vccommonname'] = to_page($item['vccommonname']); $item['vccommonname'] = $item['vccommonname'];
$item['isAvailable'] = operator_is_available($item); $item['isAvailable'] = operator_is_available($item);
$item['isAway'] = operator_is_away($item); $item['isAway'] = operator_is_away($item);
$item['lastTimeOnline'] = time() - $item['time']; $item['lastTimeOnline'] = time() - $item['time'];

View File

@ -63,7 +63,7 @@ if (!$op) {
} }
$page['currentop'] = $op $page['currentop'] = $op
? to_page(get_operator_name($op)) . " (" . $op['vclogin'] . ")" ? get_operator_name($op) . " (" . $op['vclogin'] . ")"
: getlocal("not_found"); : getlocal("not_found");
$page['canmodify'] = $can_modify ? "1" : ""; $page['canmodify'] = $can_modify ? "1" : "";
@ -76,8 +76,8 @@ if ($op) {
$page['groups'] = array(); $page['groups'] = array();
foreach ($groups as $group) { foreach ($groups as $group) {
$group['vclocalname'] = to_page($group['vclocalname']); $group['vclocalname'] = $group['vclocalname'];
$group['vclocaldescription'] = to_page($group['vclocaldescription']); $group['vclocaldescription'] = $group['vclocaldescription'];
$group['checked'] = in_array($group['groupid'], $checked_groups); $group['checked'] = in_array($group['groupid'], $checked_groups);
$page['groups'][] = $group; $page['groups'][] = $group;

View File

@ -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(); $checked_permissions = array();
if ($op) { if ($op) {

View File

@ -47,7 +47,7 @@ if (isset($_GET['nextGroup'])) {
if ($next_group) { if ($next_group) {
$page['message'] = getlocal2( $page['message'] = getlocal2(
"chat.redirected.group.content", "chat.redirected.group.content",
array(to_page(get_group_name($next_group))) array(get_group_name($next_group))
); );
if ($thread->state == Thread::STATE_CHATTING) { if ($thread->state == Thread::STATE_CHATTING) {
$thread->state = Thread::STATE_WAITING; $thread->state = Thread::STATE_WAITING;
@ -79,7 +79,7 @@ if (isset($_GET['nextGroup'])) {
if ($next_operator) { if ($next_operator) {
$page['message'] = getlocal2( $page['message'] = getlocal2(
"chat.redirected.content", "chat.redirected.content",
array(to_page(get_operator_name($next_operator))) array(get_operator_name($next_operator))
); );
if ($thread->state == Thread::STATE_CHATTING) { if ($thread->state == Thread::STATE_CHATTING) {
$thread->state = Thread::STATE_WAITING; $thread->state = Thread::STATE_WAITING;

View File

@ -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['localeLinks'] = get_locale_links(MIBEW_WEB_ROOT . "/operator/restore.php");
$page['isdone'] = false; $page['isdone'] = false;

View File

@ -141,17 +141,17 @@ if (isset($_POST['email']) && isset($_POST['title']) && isset($_POST['logo'])) {
} }
} }
$page['formemail'] = to_page($params['email']); $page['formemail'] = $params['email'];
$page['formtitle'] = to_page($params['title']); $page['formtitle'] = $params['title'];
$page['formlogo'] = to_page($params['logo']); $page['formlogo'] = $params['logo'];
$page['formhosturl'] = to_page($params['hosturl']); $page['formhosturl'] = $params['hosturl'];
$page['formgeolink'] = to_page($params['geolink']); $page['formgeolink'] = $params['geolink'];
$page['formgeolinkparams'] = to_page($params['geolinkparams']); $page['formgeolinkparams'] = $params['geolinkparams'];
$page['formusernamepattern'] = to_page($params['usernamepattern']); $page['formusernamepattern'] = $params['usernamepattern'];
$page['formpagestyle'] = $styles_params['page_style']; $page['formpagestyle'] = $styles_params['page_style'];
$page['availablePageStyles'] = $page_style_list; $page['availablePageStyles'] = $page_style_list;
$page['formchatstyle'] = $styles_params['chat_style']; $page['formchatstyle'] = $styles_params['chat_style'];
$page['formchattitle'] = to_page($params['chattitle']); $page['formchattitle'] = $params['chattitle'];
$page['formsendmessagekey'] = $params['sendmessagekey']; $page['formsendmessagekey'] = $params['sendmessagekey'];
$page['availableChatStyles'] = $chat_style_list; $page['availableChatStyles'] = $chat_style_list;
$page['stored'] = isset($_GET['stored']); $page['stored'] = isset($_GET['stored']);

View File

@ -29,7 +29,7 @@ force_password($operator);
setlocale(LC_TIME, getstring("time.locale")); setlocale(LC_TIME, getstring("time.locale"));
$page = array(); $page = array();
$page['operator'] = to_page(get_operator_name($operator)); $page['operator'] = get_operator_name($operator);
$page['availableDays'] = range(1, 31); $page['availableDays'] = range(1, 31);
$page['availableMonth'] = get_month_selection(time() - 400 * 24 * 60 * 60, time() + 50 * 24 * 60 * 60); $page['availableMonth'] = get_month_selection(time() - 400 * 24 * 60 * 60, time() + 50 * 24 * 60 * 60);
$page['showresults'] = false; $page['showresults'] = false;
@ -164,7 +164,7 @@ if ($statistics_type == 'bydate') {
// cannot do it in a template. // cannot do it in a template.
// TODO: Remove this block when "to_page" function will be removed. // TODO: Remove this block when "to_page" function will be removed.
foreach ($page['reportByAgent'] as &$row) { foreach ($page['reportByAgent'] as &$row) {
$row['name'] = to_page($row['name']); $row['name'] = $row['name'];
} }
unset($row); unset($row);

View File

@ -41,8 +41,8 @@ $lang2 = $messages[$target];
$page = array( $page = array(
'lang1' => $source, 'lang1' => $source,
'lang2' => $target, 'lang2' => $target,
'title1' => to_page(isset($lang1["localeid"]) ? $lang1["localeid"] : $source), 'title1' => (isset($lang1["localeid"]) ? $lang1["localeid"] : $source),
'title2' => to_page(isset($lang2["localeid"]) ? $lang2["localeid"] : $target), 'title2' => (isset($lang2["localeid"]) ? $lang2["localeid"] : $target),
'errors' => array(), 'errors' => array(),
); );
@ -115,9 +115,9 @@ foreach ($all_keys as $key) {
'id' => $key, 'id' => $key,
'l1' => $t_source, 'l1' => $t_source,
'l2' => $value, 'l2' => $value,
'idToPage' => to_page($key), 'idToPage' => $key,
'l1ToPage' => to_page($t_source), 'l1ToPage' => $t_source,
'l2ToPage' => to_page($value), 'l2ToPage' => $value,
); );
} }
} }