织梦DEDECMS gbk站点mip改造方案

织梦教程 强烈建议 2024-02-06 14:12 97 0

????***???????????

????1??js?????????????????????滻

????2?????e??mip?????

????head???

????body???

????3??head????????dedecms????????????url??

????4???????css????????齫css????е????????????У???????????????css.htm??????{dede:includefilename="css.htm"/}?滻???????е???

????????е?????css????????в????滻????????С???????????????п?????????д????????????????????????????????????????????е?????????????????á???

??????????????????????????????滻??????????????????????????????????

??????????????????????

?????? ?????????????

??????? /include/dedetag.class.php????н????????????????????

????function SaveTo($filename)

????{

????$fp=@fopen($filename,"w")or die("DedeTag Engine Create File False");

????fwrite($fp,$this->GetResult());

????fclose($fp);

????}

?????滻???????????????????????и??????

????//·??????????????$content?????????$feed_url???????$f_url:???·??????????

????function relative_to_absolute($content,$protocol, $domain, $f_url) {

????//???????·??????href="/a/b.html"?????

????$new_content=preg_replace('/href\s*\=\s*([\'"])\s*//','href='.$protocol.$domain.'/', $content);

????$new_content=preg_replace('/src\s*\=\s*([\'"])\s*//', 'src='.$protocol.$domain.'/',$new_content);

????//???????·??????href="a/b.html"?????

????$new_content=preg_replace('/href\s*\=\s*([\'"])(?!(http|https)://)/','href='.$protocol.$domain.$f_url,$new_content);

????$new_content=preg_replace('/src\s*\=\s*([\'"])(?!(http|https)://)/','src='.$protocol.$domain.$f_url, $new_content);

????return $new_content;

????}

????function SaveTo($filename)

????{

????$fp=@fopen($filename,"w") ordie("DedeTag Engine Create File False");

????if(substr($_SERVER['PHP_SELF'],-6)=='_m.php'||substr($filename,-13)=='/m/index.html'){ //??????????????????????????????pc???gbk????????????????????????ж???????

????$f_url=explode('www.????.com/m',dirname($filename));//???·??????????????·??????????

????//??dirname($filename)????????***·???D:/????.com/m/yygk/xwzx???????????www.????.com/m???????????·??????????????/yygk/xwzx????

????$html=$this->GetResult();

????$html=$this->relative_to_absolute($html,'http://','m.????.com',$f_url[1].'/');//???·?????***·??

????$html=str_replace('','',iconv('gbk','utf-8//ignore',$html)); //????utf-8??????????fwrite?????????????????????

????$html=str_replace('?????target

????$html=str_replace('???

????if(preg_match_all('/\sstyle\s*\=\s*[\'"](.*?)[\'"]/',$html,$css)){

????$css0=array_unique($css[0]);//???????style

????foreach($css0as $k=> $v){

????$html=str_replace($v,'class="mip_add_css_'.$k.'"',$html); //mip_add_css_?????????????????????????????????????????????

????$temp_name='mip_add_css_'.$k;

????$$temp_name=$css[1][$k];

????$add_css.='.'.$temp_name.'{'.$css[1][$k]."}\n";

????}

????$html=str_replace('',"