首页站内杂志技术文摘
文章内容页

帝国cms同步更新的另一方法(非东坡移动端同步生成)

  • 作者:雨祺
  • 来源: 原创
  • 发表于2023-12-09 15:25:08
  • 被阅读0
  • 帝国cms同步更新的另一方法(非东坡移动端同步生成),帝国cms7.2 7.5多端口同步刷新的方法。

    第一步,主端-添加一个扩展变量 tongBuRe  ,写入内存,作为同步刷新的开关,为1开,为0关。

    第二步,主端-修改文件 e/class/functions.php,在尾部附加一个新的函数
    1. //多端刷新函数 
    2. function shuaxin($act,$args,$en){ 
    3.     global $emoreport_r,$public_r; 
    4.     if(!$public_r['add_tongBuRe'])return ''
    5.     $shuaxin['action']=$act; 
    6.     $shuaxin['canshu']=$args; 
    7.     $shuaxin['en']=$en; 
    8.     $shuaxin['purl']=$emoreport_r[$en]['purl'].'e/extend/shuaxin/index.php'
    9.     $shuaxin['postpass']=$emoreport_r[$en]['postpass']; 
    10.     $data['token']=md5(json_encode($shuaxin)); 
    11.     unset($shuaxin['postpass']); 
    12.     $data['data']=json_encode($shuaxin); 
    13.     $ch = curl_init(); 
    14.         curl_setopt($ch, CURLOPT_URL, $shuaxin['purl']); 
    15.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
    16.         curl_setopt($ch, CURLOPT_HEADER, 0); 
    17.         curl_setopt($ch,CURLOPT_TIMEOUT,60); //定义超时60秒钟  
    18.         curl_setopt($ch, CURLOPT_POST, 1); 
    19.         curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); 
    20.         $output = curl_exec($ch); 
    21.         $errorCode = curl_errno($ch); 
    22.     curl_close($ch); 
    23.     if(0 !== $errorCode) { 
    24.         return $errorCode; 
    25.     } 
    26.     return $output; 

    第三步,还是这个文件,把这么一句 

    1. shuaxin(__FUNCTION__,func_get_args(),2); 

    插入到这个文件的三个地方。
    (1)同步首页 

    1. function GetIndextemp(){   

    (2)同步内容页

    1. function GetHtml($classid,$id,$add,$ecms=0,$doall=0){ 

    (3)同步列表页

    1. function ListHtml($classid,$fields,$enews=0,$userlistr=""){ 

    (4)  同步索引类信息列表

    1. function ListHtmlIndex($classid,$fields,$enews=0,$userlistr=""){ 

    另外,对于文件 /e/class/hinfofun.php  查找 

    1. function AddInfoToReHtml($classid,$dore){ 

    在其后插入: 

    1. shuaxin(__FUNCTION__,func_get_args(),2); 

    希望在刷新主端首页的时候,也同时刷新手机端的首页,我们就在这个函数中插入好了!其他同理。

    1. //取得首页模板 
    2. function GetIndextemp(){ 
    3.     global $empire,$dbtbpre,$public_r; 
    4.     // add 
    5.     shuaxin(__FUNCTION__,func_get_args(),2); 
    6.     //jadd end 
    7.     if($public_r['indexpageid']) 
    8.     { 
    9.         $r=$empire->fetch1("select temptext from {$dbtbpre}enewsindexpage where tempid='".$public_r['indexpageid']."'"); 
    10.         return $r['temptext']; 
    11.     } 
    12.     $r=$empire->fetch1("select indextemp from ".GetTemptb("enewspubtemp")." limit 1"); 
    13.     return $r['indextemp']; 

    最后在手机端的e/extend/shuaxin/index.php文件中,处理下这个请求:

    1. <?php 
    2. define('EmpireCMSAdmin','1'); 
    3. require("../../class/connect.php"); 
    4. require("../../class/db_sql.php"); 
    5. require("../../class/functions.php"); 
    6. require("../../data/dbcache/class.php"); 
    7. require("../../class/t_functions.php"); 
    8. require "../".LoadLang("pub/fun.php"); 
    9. require("../../class/delpath.php"); 
    10. require("../../class/copypath.php"); 
    11. require("../../data/dbcache/MemberLevel.php"); 
    12. //会员 
    13. //require("../member/class/user.php"); 
    14. require("../../class/hinfofun.php"); 
    15. $link=db_connect(); 
    16. $empire=new mysqlquery(); 
    17. $editor=1; 
    18. //验证用户 
    19. $token=$_POST['token']; 
    20. $shuaxin=json_decode($_POST['data'],true); 
    21. //en 为多端id 
    22. $en=$shuaxin['en']; 
    23. $shuaxin['postpass']=$emoreport_r[$en]['postpass']; 
    24. if($token!==md5(json_encode($shuaxin)))exit(false); 
    25. //分类刷新 
    26. switch($shuaxin['action']){ 
    27.     case 'GetHtml'
    28.         GetHtml($shuaxin['canshu'][0],$shuaxin['canshu'][1],'',0,1);//生成信息文件 
    29.         break
    30.     case 'GetIndextemp':   
    31.         $indextemp=GetIndextemp(); 
    32.         NewsBq(0,$indextemp,1,0); //刷新首页 
    33.         break
    34.     case 'ListHtml'
    35.         ListHtml($shuaxin['canshu'][0],$shuaxin['canshu'][1],$shuaxin['canshu'][2],$shuaxin['canshu'][3]);//刷新列表 
    36.         break
    37.     case 'ListHtmlIndex'
    38.         ListHtmlIndex($shuaxin['canshu'][0],$shuaxin['canshu'][1],$shuaxin['canshu'][2],$shuaxin['canshu'][3]);//刷新索引类信息列 
    39.     case 'ReListHtml'
    40.         ReListHtml($shuaxin['canshu'][0],$shuaxin['canshu'][1]);//刷新信息列表    
    41.         break
    42.     case 'AddInfoToReHtml'
    43.         AddInfoToReHtml($shuaxin['canshu'][0],$shuaxin['canshu'][1]); 
    44.         break
    45.     default
    46.         exit('0'); 
    47. exit(1); 
    这样简单的修改后,就可以实现帝国cms7.x的多端同步生成。
    【审核人:站长】

        标题:帝国cms同步更新的另一方法(非东坡移动端同步生成)

        本文链接:https://www.meiweny.cn/zazhi/zhongwangjiaocheng/317.html

        赞一下

        深度阅读

        • 您也可以注册成为美文苑的作者,发表您的原创作品、分享您的心情!

        阅读记录

          关注美文苑