dede织梦/gbk站点mip改造方案分享

织梦教程 强烈建议 2024-02-06 13:30 159 0
???????? ???????????????????????????dedecms/gbk???????????mip?????????????·?????????????????????1????????????????????? ????1????utf-8??????????? ?????Щ?????????????????????????utf-8??cms??????????????????????????????·???????????????ο???????????Щ????????????????????cms?????????????????·??????????????????????gbk??????????????????????????????????????????Щ??????????????????????????÷?????***????????????????????????й????о???????????????????????????滻???????????????????????????????????????У??????????????????????????2??3???????·???????????? ????2??·????????/?????е????·?????????????url??????????????ò????????????????????·????????????????????·?????????url?????????????Щ???????????????????????·???????????? ????3????????????? ?????????????????????????????????????????????????????????????????cms????????????????????????????????????mip???????????????????????????????????????????????? ????4??js???? ????mip?淶??????js?????????????????????????????????js??????????????Ч???????????????滻?????????????????????????????mip???????????′?????淶?????????????????к??js??????????????????????????????????????***????????????????????????????????????js???mip??????????????????????????o??????????????ò?????mip???? ????5??????С???? ???????????????????г????????????????????css???о?????? ??????????mip cache???????????????302????????????302?????????mip??Ч???????????????????????????????????????????????????????????????δ????·???????′???? ????????????bug????mip-carousel??????????????????????????????????????????? ??????mip?????????????success?????????????????????????????????? ????????????dedecms/gbk?????mip???? ????***??????????? ????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('',"