PHP替換文章內鏈的函數 php關鍵字替換(含屏蔽還原原始連結功能)
-
-
/* - * PHP替换文章内链
- * by bbs.it-home.org
- */
- function _base64_encode($t,$str) {
- return $t.""".base64_encode($str).""";
- }
- function _base64_decode($t,$str) {
- return $t.""".base64_decode($str).""";
- }
function _keylinks($txt, $replacenum = '',$link_mode = 1) {
- /* 屏蔽原始的 a */
- $replace_a = "_base64_encode('ori_a=','
')"; $replace1_a = "stripslashes(base64_decode(''))";
$search_a = "/.*?/isxe";
$search1_a = "/ori_a=(".*?")/isxe";
$txt = preg_replace($search_a, $replace_a, $txt);
/* 屏蔽alt title src */
$search = "/(alts*=s*|titles*=s*|srcs*=s*) # find (["'])?(.*?) # find single or double quote (?(2)|s+?) # if quote found, match up to next matching # quote, otherwise match up to next space /isxe"; $replace = "_base64_encode('','')"; $replace1 = "_base64_decode('','')"; $txt = preg_replace($search, $replace, $txt); echo $txt; echo " http://bbs.it-home.org/
";
/*
$keywords = $this->data['keywords'];
if($keywords) $keywords = strpos(',',$keywords) === false ? explode(' ',$keywords) : explode(',',$keywords);
if($link_mode && !empty($keywords)) {
foreach($keywords as $keyword) {
$linkdatas[] = $keyword;
}
} else {
$linkdatas = getcache('keylink','commons');
}
if($linkdatas) {
$word = $replacement = array();
foreach($linkdatas as $v) {
if($link_mode && $keywords) {
$word1[] = '/'.preg_quote($v, '/').'/';
$word2[] = $v;
$replacement[] = ''.$v.'';
} else {
$word1[] = '/'.preg_quote($v[0], '/').'/';
$word2[] = $v[0];
$replacement[] = ''.$v[0].'';
}
}
if($replacenum != '') {
$txt = preg_replace($word1, $replacement, $txt, $replacenum);
} else {
$txt = str_replace($word2, $replacement, $txt);
}
}
*/
/* 还原原始 a */
$txt = preg_replace($search1_a, $replace1_a, $txt);
/* 还原alt title src */
$txt = preg_replace($search, $replace1, $txt);
echo $txt;
return $txt;
}
$con = " 性生活过度伤害前列腺。和谐美满的性生活,是男女生理的天然需要,是夫妻感情的粘合剂之一,是夫妻生活必不少的重要组成部分。但是有此想法的夫妻可要注意了。因为做x爱时间并非越长越好,夫妻的性生活的和谐与美满也不由性xai时间的长短来决定。反而,超时性XZ爱,还会影响到夫妻的健康,甚至引发各种疾病。
";
_keylinks($con);
?>
复制代码
|
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
-
2024-10-22 09:46:29
-
2024-10-13 13:53:41
-
2024-10-12 12:15:51
-
2024-10-11 22:47:31
-
2024-10-11 19:36:51
-
2024-10-11 15:50:41
-
2024-10-11 15:07:41
-
2024-10-11 14:21:21
-
2024-10-11 12:59:11
-
2024-10-11 12:17:31