PHP替换文章内链的函数 php关键词替换(含屏蔽还原原始链接功能)

php中文网
发布: 2016-07-25 08:57:39
原创
1609人浏览过
  1. /*

  2. * php替换文章内链
  3. * by bbs.it-home.org
  4. */
  5. function _base64_encode($t,$str) {
  6. return $t.""".base64_encode($str).""";
  7. }
  8. function _base64_decode($t,$str) {
  9. return $t.""".base64_decode($str).""";
  10. }
  11. function _keylinks($txt, $replacenum = '',$link_mode = 1) {

  12. /* 屏蔽原始的 a */
  13. $replace_a = "_base64_encode('ori_a=','\0')";
  14. $replace1_a = "stripslashes(base64_decode('\1'))";
  15. $search_a = "/.*?/isxe";
  16. $search1_a = "/ori_a=(".*?")/isxe";
  17. $txt = preg_replace($search_a, $replace_a, $txt);
  18. /* 屏蔽alt title src */

  19. $search = "/(alts*=s*|titles*=s*|srcs*=s*) # find (["'])?(.*?) # find single or double quote
  20. (?(2)\2|s+?) # if quote found, match up to next matching
  21. # quote, otherwise match up to next space
  22. /isxe";
  23. $replace = "_base64_encode('\1','\3')";
  24. $replace1 = "_base64_decode('\1','\3')";
  25. $txt = preg_replace($search, $replace, $txt);
  26. echo $txt;
  27. echo "
    http://bbs.it-home.org/



    ";
  28. /*
  29. $keywords = $this->data['keywords'];
  30. if($keywords) $keywords = strpos(',',$keywords) === false ? explode(' ',$keywords) : explode(',',$keywords);
  31. if($link_mode && !empty($keywords)) {
  32. foreach($keywords as $keyword) {
  33. $linkdatas[] = $keyword;
  34. }
  35. } else {
  36. $linkdatas = getcache('keylink','commons');
  37. }
  38. if($linkdatas) {
  39. $word = $replacement = array();
  40. foreach($linkdatas as $v) {
  41. if($link_mode && $keywords) {
  42. $word1[] = '/'.preg_quote($v, '/').'/';
  43. $word2[] = $v;
  44. $replacement[] = ''.$v.'';
  45. } else {
  46. $word1[] = '/'.preg_quote($v[0], '/').'/';
  47. $word2[] = $v[0];
  48. $replacement[] = ''.$v[0].'';
  49. }
  50. }
  51. if($replacenum != '') {
  52. $txt = preg_replace($word1, $replacement, $txt, $replacenum);
  53. } else {
  54. $txt = str_replace($word2, $replacement, $txt);
  55. }
  56. }
  57. */
  58. /* 还原原始 a */
  59. $txt = preg_replace($search1_a, $replace1_a, $txt);
  60. /* 还原alt title src */
  61. $txt = preg_replace($search, $replace1, $txt);
  62. echo $txt;
  63. return $txt;
  64. }
  65. $con = "

      性生活过度伤害前列腺。和谐美满的性生活,是男女生理的天然需要,是夫妻感情的粘合剂之一,是夫妻生活必不少的重要组成部分。但是有此想法的夫妻可要注意了。因为做x爱时间并非越长越好,夫妻的性生活的和谐与美满也不由性xai时间的长短来决定。反而,超时性XZ爱,还会影响到夫妻的健康,甚至引发各种疾病。

    Swapface人脸交换
    Swapface人脸交换

    一款创建逼真人脸交换的AI换脸工具

    Swapface人脸交换 45
    查看详情 Swapface人脸交换
  66. 性生活过度伤害前列腺

    ";
  67. _keylinks($con);

  68. ?>

    立即学习PHP免费学习笔记(深入)”;

复制代码


PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号