Browse Source

replace special chars of nickname

master
filesite 7 months ago
parent
commit
b04374a9f7
  1. 13
      plugins/Common.php
  2. 6
      themes/tajian/controller/FrontapiController.php
  3. 2
      themes/tajian/views/layout/main.php
  4. 2
      themes/tajian/views/site/myindex.php

13
plugins/Common.php

@ -3,6 +3,19 @@ @@ -3,6 +3,19 @@
* 常用的公用方法
*/
Class Common {
public static function cleanSpecialChars($str) {
$findChars = array(
'"',
"'",
'&',
'<',
'>',
'\/',
);
return str_replace($findChars, '', $str);
}
public static function isCellphoneNumber($number) {
return preg_match("/^1[3456789][0-9]{9}$/", $number);
}

6
themes/tajian/controller/FrontapiController.php

@ -690,7 +690,11 @@ eof; @@ -690,7 +690,11 @@ eof;
if (empty($nickname)) {
$err = "请填写注册你的昵称";
}else if (mb_strlen($nickname, 'utf-8') < 2 || mb_strlen($nickname, 'utf-8') > 5) {
}else {
$nickname = Common::cleanSpecialChars($nickname);
}
if (mb_strlen($nickname, 'utf-8') < 2 || mb_strlen($nickname, 'utf-8') > 5) {
$err = "昵称至少 2 个汉字,最多 5 个汉字,请按规则填写";
}

2
themes/tajian/views/layout/main.php

@ -24,7 +24,7 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use @@ -24,7 +24,7 @@ if (!empty(FSC::$app['config']['multipleUserUriParse']) && !empty(FSC::$app['use
<a class="log_tn clearfix" href="/">
<span class="verBaseline">Ta荐</span>
<?php if (!empty($viewData['nickname'])) { ?>
- <strong><?=$viewData['nickname']?></strong>
- <strong><?=htmlspecialchars($viewData['nickname'], ENT_QUOTES)?></strong>
<?php } ?>
</a>
<div class="search hide_movi_xs hide">

2
themes/tajian/views/site/myindex.php

@ -44,7 +44,7 @@ if (!empty($viewData['tags'])) { //显示tags分类 @@ -44,7 +44,7 @@ if (!empty($viewData['tags'])) { //显示tags分类
//输出分类名称
echo <<<eof
<div class="tgroup">
<a href="{$linkPrefix}/list/?id={$id}" class="morelink">&gt;&gt;更多</a>
<a href="{$linkPrefix}/list/?id={$id}" class="morelink">更多&gt;&gt;</a>
<h3>{$item['name']}</h3>
</div>
<div class="clearfix">

Loading…
Cancel
Save