• 替换内容里面的图片


    function doreplace($str){
    global $api,$empire,$class_r,$dbtbpre,$public_r;

    $text=Repurl($str);
    $exp1="[--copyurl--]";
    $exp2="[/--copyurl--]";
    $rr=explode($exp1,$text);
    $j=1;
    for($i=1;$i<count($rr);$i++)
    {
    $r1=explode($exp2,$rr[$i]);
    $dourl=$r1[0];
    $dourl = trim($dourl,'.');
    // echo $dourl."<br>";

    if(!strstr($dourl, '.edu')){
    if(!strstr($dourl, '.gov')){
    // if(!strstr($dourl, 'js')||!strstr($dourl, 'css')){
    $one = $empire->fetch1("select * from {$dbtbpre}ecms_news_allow_weburl where url like '%{$dourl}%'");
    // print_r($one);
    if(empty($one)){
    // echo "1";
    // $dourl = $one[url];
    $text = str_replace($exp1.$dourl.$exp2,'网址未加载',$text);
    }else{
    // echo "2";
    $text = str_replace($exp1.$dourl.$exp2,$dourl,$text);
    // echo $text;
    }
    // }else{
    // $text = str_replace($exp1.'.'.$dourl.$exp2,'.'.$dourl,$text);
    // }
    }else{
    $text = str_replace($exp1.$dourl.$exp2,$dourl,$text);
    }
    }else{
    $text = str_replace($exp1.$dourl.$exp2,$dourl,$text);
    // $text = str_replace($exp1.'.'.$dourl.$exp2,'.'.$dourl,$text);
    }
    // echo $dourl."<br>";
    }
    // exit('123');
    return $text;
    }

    //替换图片标签
    function Repurl($text){
    global $ecms_config;
    $exp1="[--copyurl--]";
    $exp2="[/--copyurl--]";
    $pattern = "/[a-z0-9][a-z0-9-]*?.(?:com|cn|net|org|gov|cc)(?:.(?:cn))?/";
    // $pattern = "/[.]{1}[a-zd-]+[.]{1}[a-zd]*/";
    $str = '';
    // $isMatched = preg_match('/[a-z0-9][a-z0-9-]*?.(?:com|cn|net|org|gov|cc)(?:.(?:cn))?/', $str, $matches);
    // var_dump($isMatched, $matches);
    // '~^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(?([^#]*))?(#(.*))?~i';
    // $pattern="/[a-z0-9][a-z0-9-]*?.(?:com|cn|net|org|gov|info|la|cc|co|jp)(?:.(?:cn|jp))?/";
    // "(.)[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(.(net|com|cn|org|cc|tv))+.?"
    // $pattern="/[.]{1}[a-zd-]+[.]{1}[a-zd]*/";
    // $pattern="/[.]{1}[a-zd-]+[.]{1}[a-zd]*[/]*[A-Za-zd]*[/]*[A-Za-zd]*/";//匹配域名后整个链接
    $text = preg_replace($pattern,$exp1."${0}".$exp2,$text);
    return $text;
    }

  • 相关阅读:
    linux下进度条的简单实现
    简单vim配置
    Linux下find指令
    Python学习笔记十三_操作数据库
    Python学习笔记十二_常用模块
    Python学习笔记十一_函数返回多值、列表生成式、循环多变量、入参格式声明
    Python学习笔记十_模块、第三方模块安装、模块导入
    Python函数及json练习_双色球
    Python函数及json练习_商品管理
    Python json练习_读写文件函数
  • 原文地址:https://www.cnblogs.com/songadmin/p/14875018.html
Copyright © 2020-2023  润新知