Deleted the utf8_ functions

This commit is contained in:
Visman 2017-01-08 19:03:08 +07:00
parent 9379a19cb9
commit 31fafc1ed4
6 changed files with 20 additions and 40 deletions

View file

@ -59,12 +59,6 @@ if (!defined('PUN_DEBUG'))
// Load the functions script
require PUN_ROOT.'include/functions.php';
// Load UTF-8 functions
require PUN_ROOT.'include/utf8/utf8.php';
// Strip out "bad" UTF-8 characters
forum_remove_bad_characters();
// Reverse the effect of register_globals
forum_unregister_globals();
@ -1087,7 +1081,7 @@ switch ($stage)
{
unset($cur_moderators[$old_username]);
$cur_moderators[$username] = $id;
uksort($cur_moderators, 'utf8_strcasecmp');
uksort($cur_moderators, function ($a, $b) {return strcmp(mb_strtolower($a), mb_strtolower($b));});
$db->query('UPDATE '.$db->prefix.'forums SET moderators=\''.$db->escape(serialize($cur_moderators)).'\' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}

View file

@ -47,12 +47,6 @@ require PUN_ROOT.'include/functions.php';
// Load addon functionality
require PUN_ROOT.'include/addons.php';
// Load UTF-8 functions
require PUN_ROOT.'include/utf8/utf8.php';
// Strip out "bad" UTF-8 characters
forum_remove_bad_characters();
// Reverse the effect of register_globals
forum_unregister_globals();

View file

@ -448,7 +448,7 @@ function check_bans()
continue;
}
if ($cur_ban['username'] != '' && utf8_strtolower($pun_user['username']) == utf8_strtolower($cur_ban['username']))
if ($cur_ban['username'] != '' && mb_strtolower($pun_user['username']) == mb_strtolower($cur_ban['username']))
$is_banned = true;
if ($cur_ban['ip'] != '')
@ -499,9 +499,6 @@ function check_username($username, $exclude_id = null)
$db = $container->get('DB');
// Include UTF-8 function
require_once PUN_ROOT.'include/utf8/strcasecmp.php';
// Convert multiple whitespace characters into one (to prevent people from registering with indistinguishable usernames)
$username = preg_replace('%\s+%s', ' ', $username);
@ -512,7 +509,7 @@ function check_username($username, $exclude_id = null)
$errors[] = $lang_prof_reg['Username too long'];
else if (!preg_match('%^\p{L}[\p{L}\p{N}_ ]+$%uD', $username)) // строгая проверка имени пользователя - Visman
$errors[] = $lang_prof_reg['Username Error'];
else if (!strcasecmp($username, 'Guest') || !utf8_strcasecmp($username, $lang_common['Guest']))
else if (!strcasecmp($username, 'Guest') || !strcmp(mb_strtolower($username), mb_strtolower($lang_common['Guest'])))
$errors[] = $lang_prof_reg['Username guest'];
else if (preg_match('%[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}%', $username) || preg_match('%((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))%', $username))
$errors[] = $lang_prof_reg['Username IP'];
@ -539,7 +536,7 @@ function check_username($username, $exclude_id = null)
// Check username for any banned usernames
foreach ($pun_bans as $cur_ban)
{
if ($cur_ban['username'] != '' && utf8_strtolower($username) == utf8_strtolower($cur_ban['username']))
if ($cur_ban['username'] != '' && mb_strtolower($username) == mb_strtolower($cur_ban['username']))
{
$errors[] = $lang_prof_reg['Banned username'];
break;
@ -974,11 +971,11 @@ function get_title($user)
$ban_list = array();
foreach ($pun_bans as $cur_ban)
$ban_list[] = utf8_strtolower($cur_ban['username']);
$ban_list[] = mb_strtolower($cur_ban['username']);
}
// If the user is banned
if (in_array(utf8_strtolower($user['username']), $ban_list))
if (in_array(mb_strtolower($user['username']), $ban_list))
$user_title = $lang_common['Banned'];
// If the user has a custom title
else if ($user['title'] != '')
@ -1398,7 +1395,7 @@ function pun_linebreaks($str)
//
function is_all_uppercase($string)
{
return utf8_strtoupper($string) == $string && utf8_strtolower($string) != $string;
return mb_strtoupper($string) == $string && mb_strtolower($string) != $string;
}

View file

@ -52,7 +52,7 @@ function split_words_clear_link_minor($arr)
$res.= split_words_clear_link_minor($text);
continue;
}
$text = utf8_strtolower(rawurldecode($text));
$text = mb_strtolower(rawurldecode($text));
$text = ucp_preg_replace('%[^\p{L}\p{N}]+%u', ' ', $text);
$text = preg_replace('%(?<=\b)((\d+(?=[a-z])|[a-z]+(?=\d)){3,}\w*)(?=\b)%u', ' ', $text);
$text = preg_replace('%(?<=\b)\d+|\d+(?=\b)%u', '', $text);
@ -248,8 +248,8 @@ function update_search_index($mode, $post_id, $message, $subject = null)
$db = $container->get('DB');
$message = utf8_strtolower($message);
$subject = utf8_strtolower($subject);
$message = mb_strtolower($message);
$subject = mb_strtolower($subject);
// Remove any bbcode that we shouldn't index
$message = strip_bbcode($message);

View file

@ -9,11 +9,6 @@
define('PUN_ROOT', dirname(__FILE__).'/');
require PUN_ROOT.'include/common.php';
// Include UTF-8 function
require PUN_ROOT.'include/utf8/substr_replace.php';
require PUN_ROOT.'include/utf8/ucwords.php'; // utf8_ucwords needs utf8_substr_replace
require PUN_ROOT.'include/utf8/strcasecmp.php';
$request = $container->get('Request');
$action = $request->getStr('action');
@ -541,7 +536,7 @@ else if ($request->isPost('update_forums'))
$result = $db->query('SELECT username FROM '.$db->prefix.'users WHERE id='.$id) or error('Unable to fetch user info', __FILE__, __LINE__, $db->error());
$username = $db->result($result);
$moderator_in = array_keys($request->post('moderator_in', array());
$moderator_in = array_keys($request->post('moderator_in', array()));
// Loop through all forums
$result = $db->query('SELECT id, moderators FROM '.$db->prefix.'forums') or error('Unable to fetch forum list', __FILE__, __LINE__, $db->error());
@ -553,7 +548,7 @@ else if ($request->isPost('update_forums'))
if (in_array($cur_forum['id'], $moderator_in) && !in_array($id, $cur_moderators))
{
$cur_moderators[$username] = $id;
uksort($cur_moderators, 'utf8_strcasecmp');
uksort($cur_moderators, function ($a, $b) {return strcmp(mb_strtolower($a), mb_strtolower($b));});
$db->query('UPDATE '.$db->prefix.'forums SET moderators=\''.$db->escape(serialize($cur_moderators)).'\' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}
@ -871,9 +866,9 @@ else if ($request->isPost('form_sent'))
{
// A list of words that the title may not contain
// If the language is English, there will be some duplicates, but it's not the end of the world
$forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', utf8_strtolower($lang_common['Member']), utf8_strtolower($lang_common['Moderator']), utf8_strtolower($lang_common['Administrator']), utf8_strtolower($lang_common['Banned']), utf8_strtolower($lang_common['Guest']));
$forbidden = array('member', 'moderator', 'administrator', 'banned', 'guest', mb_strtolower($lang_common['Member']), mb_strtolower($lang_common['Moderator']), mb_strtolower($lang_common['Administrator']), mb_strtolower($lang_common['Banned']), mb_strtolower($lang_common['Guest']));
if (in_array(utf8_strtolower($form['title']), $forbidden))
if (in_array(mb_strtolower($form['title']), $forbidden))
message($lang_profile['Forbidden title']);
}
}
@ -913,7 +908,7 @@ else if ($request->isPost('form_sent'))
else if (substr_count($form['signature'], "\n") > ($pun_config['p_sig_lines']-1))
message(sprintf($lang_prof_reg['Sig too many lines'], $pun_config['p_sig_lines']));
else if ($form['signature'] && $pun_config['p_sig_all_caps'] == '0' && is_all_uppercase($form['signature']) && !$pun_user['is_admmod'])
$form['signature'] = utf8_ucwords(utf8_strtolower($form['signature']));
$form['signature'] = mb_strtolower($form['signature']);
// Validate BBCode syntax
if ($pun_config['p_sig_bbcode'] == '1')
@ -1057,7 +1052,7 @@ else if ($request->isPost('form_sent'))
{
unset($cur_moderators[$old_username]);
$cur_moderators[$form['username']] = $id;
uksort($cur_moderators, 'utf8_strcasecmp');
uksort($cur_moderators, function ($a, $b) {return strcmp(mb_strtolower($a), mb_strtolower($b));});
$db->query('UPDATE '.$db->prefix.'forums SET moderators=\''.$db->escape(serialize($cur_moderators)).'\' WHERE id='.$cur_forum['id']) or error('Unable to update forum', __FILE__, __LINE__, $db->error());
}

View file

@ -17,7 +17,7 @@ require PUN_ROOT.'lang/'.$pun_user['language'].'/search.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/forum.php';
$request = $container->get('Request');
$action = $request->isGet('action');
$action = $request->getStr('action');
if ($pun_user['g_read_board'] == '0')
message($lang_common['No view'], false, '403 Forbidden');
@ -58,8 +58,8 @@ if (! empty($action) || $request->isGet('search_id'))
// If it's a regular search (keywords and/or author)
else if ($action === 'search')
{
$keywords = utf8_strtolower(trim($request->getStr('keywords')));
$author = utf8_strtolower(trim($request->getStr('author')));
$keywords = mb_strtolower(trim($request->getStr('keywords')));
$author = mb_strtolower(trim($request->getStr('author')));
if (preg_match('%^[\*\%]+$%', $keywords) || (mb_strlen(str_replace(array('*', '%'), '', $keywords)) < PUN_SEARCH_MIN_WORD && !is_cjk($keywords)))
$keywords = '';
@ -279,7 +279,7 @@ if (! empty($action) || $request->isGet('search_id'))
}
// If it's a search for author name (and that author name isn't Guest)
if ($author && $author != 'guest' && $author != utf8_strtolower($lang_common['Guest']))
if ($author && $author != 'guest' && $author != mb_strtolower($lang_common['Guest']))
{
switch ($container->getParameter('DB_TYPE'))
{