作者 邓超

x

... ... @@ -298,7 +298,8 @@ class Home extends Base {
$sendData['receipt'] = empty($formData['receipt']) ? '' : 1;// 回执,阅读后收回执的邮箱
$sendData['priority'] = $formData['priority']??3;// 是否紧急邮件
$sendData['subject'] = $formData['subject'];// //Content 主题,标题
$sendData['body'] = $formData['body'];
// 删除script标记
$sendData['body'] = strip_tags_content($formData['body'],'<script>',true);
// 不重要的信息
$sendData['jobName'] = $formData['jobName']??'';//任务标题
$sendData['massSuit'] = $formData['massSuit']??0;// 是否是群发单显
... ...
... ... @@ -400,7 +400,46 @@ function paramHas(string $name):bool {
}
/**
* Sample text:
$text = '<b>sample</b> text with <div>tags</div>';
Result for strip_tags($text):
sample text with tags
Result for strip_tags_content($text):
text with
Result for strip_tags_content($text, '<b>'):
<b>sample</b> text with
Result for strip_tags_content($text, '<b>', TRUE);
text with <div>tags</div>
I hope that someone is useful :)
* 删除html标记
* @param $text
* @param string $tags
* @param false $invert
* @return string|string[]|null
* @author:dc
* @time 2023/6/20 18:05
*/
function strip_tags_content($text, $tags = '', $invert = FALSE) {
preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $tags);
$tags = array_unique($tags[1]);
if(is_array($tags) AND count($tags) > 0) {
if($invert == FALSE) {
return preg_replace('@<(?!(?:'. implode('|', $tags) .')\b)(\w+)\b.*?>.*?</\1>@si', '', $text);
}
else {
return preg_replace('@<('. implode('|', $tags) .')\b.*?>.*?</\1>@si', '', $text);
}
}
elseif($invert == FALSE) {
return preg_replace('@<(\w+)\b.*?>.*?</\1>@si', '', $text);
}
return $text;
}
... ...