我使用以下代码并尝试添加/ u但没有运气
例如,如果我用unicode语言键入amazon,它应该根据单词和链接列表将单词链接到amazon.com。这是在添加帖子时发生的。
我应该把/ u支持在这个脚本中支持unicode吗?
function bop_word_link ($bop_message, $notetype)
{
global $vbulletin, $bop5wl_count, $vbphrase;
//Disable for specific usergroups
if (is_member_of($vbulletin->userinfo, explode(',', $vbulletin->options['bop5wl_groups'])))
{
return $bop_message;
}
//Disable if custom profile field is present and marked off.
$bopfieldw = "field" . $vbulletin->options['bop5wl_field'];
if (($vbulletin->options['bop5wl_field'] != 0) AND ($vbulletin->userinfo[$bopfieldw] == "Off"))
{
return $bop_message;
}
//Disable in specific styles
if (in_array($vbulletin->userinfo['styleid'], explode(",", $vbulletin->options['bop5wl_styles'])))
{
return $bop_message;
}
$custreg = $vbulletin->options['bop5wl_custregex'];
if (!$vbulletin->options['bop5wl_file'])
{
$bop_find_array = explode ("\r\n", $vbulletin->options['bop5wl_words']);
$bop_replace_array = explode ("\r\n", $vbulletin->options['bop5wl_links']);
}
else
{
$bopfile = gzopen($vbulletin->options['bop5wl_file'], "r");
if ($bopfile !== FALSE)
{
$row = 0;
while (($bopdata = fgetcsv($bopfile, 2000, ",")) !== FALSE)
{
$bopnum = count($bopdata);
$bop_find_array[$row] = $bopdata[0];
$bop_replace_array[$row] = $bopdata[1];
$bop_target_array[$row] = $bopdata[2];
$bop_nofollow_array[$row] = $bopdata[3];
$row++;
}
gzclose($bopfile);
}
else
{
echo "Word Links Error - Data File Not Found!<br />Administrator should disable Word Links plugin or verify data file exists.<br />\n";
die();
}
}
$bop_find_array = array_filter($bop_find_array);
$bop_find_array = array_values($bop_find_array);
$bop_replace_array = array_filter($bop_replace_array);
$bop_replace_array = array_values($bop_replace_array);
if ($vbulletin->options['bop5wl_newwin'])
$boptarg = ' target="_blank" ';
else
$boptarg = ' target="_self" ';
if ($vbulletin->options['bop5wl_nofollow'])
$bopnofollow = ' rel="nofollow" ';
else
$bopnofollow = '';
if ($vbulletin->options['bop5wl_css'])
{
$bopspan1 = '<span class="boplink">';
$bopspan2 = '</span>';
}
else
{
$bopspan1 = '';
$bopspan2 = '';
}
$bopi = 0;
foreach ($bop_replace_array AS &$boplink)
{
if ($bop_target_array[$bopi] == NULL)
$bop_target_array[$bopi] = $boptarg;
else
$bop_target_array[$bopi] = ' target="'.trim($bop_target_array[$bopi]).'" ';
if ($bop_nofollow_array[$bopi] == NULL)
$bop_nofollow_array[$bopi] = $bopnofollow;
else
$bop_nofollow_array[$bopi] = ' rel="'.trim($bop_nofollow_array[$bopi]).'" ';
$bop_find_array[$bopi] = trim ($bop_find_array[$bopi]);
$boplink = $bopspan1 . '<a href="'.trim($boplink).'"' . $bop_target_array[$bopi] . $bop_nofollow_array[$bopi] . ' >$1</a>' . $bopspan2;
$bopi++;
}
if ($vbulletin->options['bop5wl_whole'])
$bopwd = "\b";
else
$bopwd = "";
if ($vbulletin->options['bop5wl_case'])
$bopcase = "";
else
$bopcase = "i";
foreach ($bop_find_array AS &$bopfind)
{
$bopfind = preg_quote (htmlspecialchars($bopfind));
$bopfind = '~'.$bopwd.'('.$bopfind.')'.$bopwd.'(?![^<]*(</a>|" />|width="\d+"|target="_blank"|'.$custreg.'width=\'\d+\'|follow">|rel="thickbox">|onclick="[\w .()]+"))~'.$bopcase;
// Help with the above regex was provided by:
// http://stackoverflow.com/questions/6009415/
}
$boplim = $vbulletin->options['bop5wl_max'];
if ($boplim < 1)
$boplim = -1;
$bopcount = 0;
if (($vbulletin->options['bop5wl_pagemax'] == 0) OR ($bop5wl_count < $vbulletin->options['bop5wl_pagemax']))
{
$bop_message = preg_replace ($bop_find_array, $bop_replace_array, $bop_message, $boplim, $bopcount);
$bop5wl_count += $bopcount;
}
if ($bopcount > 0 AND $vbulletin->options['bop5wl_note'])
{
if ($notetype == "post")
$bop_message .= construct_phrase($vbphrase['bop5_wordlinks_note'], $bopcount);
elseif ($notetype == "article")
$bop_message .= construct_phrase($vbphrase['bop5_wordlinks_note_art'], $bopcount);
elseif ($notetype == "blog")
$bop_message .= construct_phrase($vbphrase['bop5_wordlinks_note_blog'], $bopcount);
elseif ($notetype == "comment")
$bop_message .= construct_phrase($vbphrase['bop5_wordlinks_note_com'], $bopcount);
else // ($notetype == "message")
$bop_message .= construct_phrase($vbphrase['bop5_wordlinks_note_mess'], $bopcount);
}
return $bop_message;
}