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=','\\0')";
- $replace1_a = "\stripslashes(base64_decode('\\1'))";
- $search_a = "/.*?/isxe";
- $search1_a = "/ori_a=(\".*?\")/isxe";
- $txt = preg_replace($search_a, $replace_a, $txt);
/* 屏蔽alt title src */
- $search = "/(alt\s*=\s*|title\s*=\s*|src\s*=\s*) # find ([\"\'])?(.*?) # find single or double quote
- (?(2)\\2|\s+?) # if quote found, match up to next matching
- # quote, otherwise match up to next space
- /isxe";
- $replace = "\_base64_encode('\\1','\\3')";
- $replace1 = "\_base64_decode('\\1','\\3')";
- $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