五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > 織夢dede后臺文章內(nèi)容保存iframe變圖片的解決方法

織夢dede后臺文章內(nèi)容保存iframe變圖片的解決方法

文章來源:365jz.com     點擊數(shù):807    更新時間:2019-05-20 00:51   參與評論

織夢后臺文章添加iframe前

保存文章后,就iframe就變成了圖片

解決方法


添加文章時 添加優(yōu)酷視頻 :<iframe height=498 width=510 src='http://player.youku.com/embed/XNDAzNTAzODE4OA==' frameborder=0 'allowfullscreen'></iframe> 

提交后被替換成 


<iframe frameborder="0" height="498" src="/uploads/allimg/190128/1U9241554-1.jpg" width="510"></iframe>


經(jīng)測試,發(fā)現(xiàn)問題出在保存之前對body內(nèi)容的處理上 


打開 dede\inc\inc_archives_functions.php 找到

preg_match_all("/src=[\"|'|\s]([^\"|^\'|^\s]*?)/isU",$body,$img_array);

改成

preg_match_all("/<img.*?src=[\"|'|\s]([^\"|^\'|^\s]*?)/isU",$body,$img_array);

保存,完成,重新插入iframe代碼試試。


另外的方法:

//遠程圖片本地化
if($remote==1)
{
    $body = GetCurContent($body);   //dede/inc/inc_archives_functions.php 644行  
}

 


把函數(shù)GetCurContent做如下修改可暫時解決(未側(cè)式是否會引起其他問題,應(yīng)該把所有的圖片格式都枚舉出來)


/**
 * 獲得文章body里的外部資源
 *
 * @access    public
 * @param     string  $body  文檔內(nèi)容
 * @return    string
 */
function GetCurContent($body)
{
    global $cfg_multi_site,$cfg_basehost,$cfg_basedir,$cfg_image_dir,$arcID,$cuserLogin,$dsql;
    $cfg_uploaddir = $cfg_image_dir;
    $htd = new DedeHttpDown();
    $basehost = "http://".$_SERVER["HTTP_HOST"];
    $img_array = array();
    preg_match_all("/src=[\"|'|\s]([^\"|^\'|^\s]*?)/isU",$body,$img_array);
    
    $img_array = array_unique($img_array[1]);
    $imgUrl = $cfg_uploaddir.'/'.MyDate("ymd", time());
    $imgPath = $cfg_basedir.$imgUrl;
    if(!is_dir($imgPath.'/'))
    {
        MkdirAll($imgPath, $GLOBALS['cfg_dir_purview']);
        CloseFtp();
    }
    $milliSecond = MyDate('His',time());
    foreach($img_array as $key=>$value)
    {
        if(preg_match("#".$basehost."#i", $value))
        {
            continue;
        }
        if($cfg_basehost != $basehost && preg_match("#".$cfg_basehost."#i", $value))
        {
            continue;
        }
        if(!preg_match("#^(http|https):\/\/#i", $value))
        {
            continue;
        }
        $htd->OpenUrl($value);
        $itype = $htd->GetHead("content-type");
        $itype = substr($value, -4, 4);
        if(!preg_match("#\.(jpg|gif|png)#i", $itype))
        {
            if($itype=='image/gif')
            {
                $itype = ".gif";
            }
            else if($itype=='image/png')
            {
                $itype = ".png";
            }else if($itype=='image/jpg'){  //不知道jpeg格式的是否一樣,如果不一樣還得增加jpeg判斷
                $itype = '.jpg';
            }
            else
            {
                continue;  //原函數(shù)未處理沒有后綴名的情況,應(yīng)該在這里判斷視頻或者。。。。。。,這樣寫將不再解析除了 gif png jpg 以外的圖片格式,如 bmp
            }
        }
        $milliSecondN = dd2char($milliSecond.mt_rand(1000, 8000));
        $value = trim($value);
        $rndFileName = $imgPath.'/'.$milliSecondN.'-'.$key.$itype;
        $fileurl = $imgUrl.'/'.$milliSecondN.'-'.$key.$itype;
        $rs = $htd->SaveToBin($rndFileName);
        if($rs)
        {
            $info = '';
            $imginfos = GetImageSize($rndFileName, $info);
            $fsize = filesize($rndFileName);
            //保存圖片附件信息
            $inquery = "INSERT INTO `axcms_uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)
            VALUES ('{$arcID}','$rndFileName','$fileurl','1','{$imginfos[0]}','$imginfos[1]','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); ";
            $dsql->ExecuteNoneQuery($inquery);
            $fid = $dsql->GetLastID();
            AddMyAddon($fid, $fileurl);
            if($cfg_multi_site == 'Y')
            {
                $fileurl = $cfg_basehost.$fileurl;
            }
            $body = str_replace($value, $fileurl, $body);
            @WaterImg($rndFileName, 'down');
        }
    }
    $htd->Close();
    return $body;
}


如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答!! 點擊進入論壇

發(fā)表評論 (807人查看0條評論)
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號