Home > CMS Tutorial > Empire CMS > How to automatically submit imperial cms to Baidu

How to automatically submit imperial cms to Baidu

angryTom
Release: 2019-07-31 14:34:50
Original
3802 people have browsed it

How to automatically submit imperial cms to Baidu

If you want to know more about Empire cms, you can click: Empire cms tutorial

Empire cms implements Baidu's active push (non-plugin) method.

Modify 3 files and find out ecmsinfo.php, listinfo.php, userfun.php

1, e/admin/ecmsinfo.php

Add

elseif($enews=="Post_Baidu_sitemap")//文章实时发送百度
{
    $id=$_POST['id'];
    $urls=$_POST['titleurl'];
    ePostBaiduSitemap($id,$urls);

}
Copy after login

2 after any elseif{....} , e/data/html/list/listinfo.php

Add

<input name="id[]" type="checkbox" id="id[]" value="<?=$r[id]?>"<?=$checked?>>
<input name="infoid[]" type="hidden" value="<?=$r[&#39;id&#39;]?>">
Copy after login

after

<input name="titleurl[<?=$r[id]?>]" type="hidden" value=&#39;<?=$titleurl?>&#39;>
Copy after login

in the last Add

  <tr bgcolor="#FFFFFF"> 
      <td height="25" colspan="8">
 <input type="submit" name="Submit101" value="批量提交百度" onClick="document.listform.enews.value=&#39;Post_Baidu_sitemap&#39;;document.listform.action=&#39;ecmsinfo.php&#39;;"><font color="#666666"><p>备注:多选框蓝色为未审核信息;发布者红色为会员投稿;信息ID粗体为未生成,点击ID可刷新页面.</p></font></td>
    </tr>
Copy after login

3 before the label, e/class/userfun.phpAdd

//发送给百度时时更新-------------------------------
function ePostBaiduSitemap($id,$_urls){
    $site = &#39;www.xxxxx.com&#39;;//你的网站域名
    $token = &#39;xxxxxxx&#39;;//百度给的token
    $count = count($id); 
    if (empty($count))
    {
        printerror("未选择信息ID", "", 1, 0, 1);
    }
    $urls=array();
    for($i=0;$i<$count;$i++)
    {
        $id[$i] = (int)$id[$i];
        if (array_key_exists($id[$i],$_urls)){
            $urls[] = $_urls[$id[$i]];
        }
    }
    $api = "http://data.zz.baidu.com/urls?site=$site&token=$token";
    $ch = curl_init();
    $options =  array(
        CURLOPT_URL => $api,
        CURLOPT_POST => true,
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_POSTFIELDS => implode("\n", $urls),
        CURLOPT_HTTPHEADER => array(&#39;Content-Type: text/plain&#39;),
    );
    curl_setopt_array($ch, $options);
    $result = curl_exec($ch);
    $httpstat = curl_getinfo($ch,CURLINFO_HTTP_CODE); 
    curl_close($ch);
    if($httpstat==200){
        $obj = json_decode($result);
        printerror("今天剩余{$obj->remain}条,成功提交{$obj->success}条", "", 1, 0, 1);
    }else{
        printerror(&#39;推送失败&#39;, "", 1, 0, 1);
    }
}
Copy after login

Use:

Website background - information

Click on any tree list on the left

## In the information management on the right, check the articles to be submitted to Baidu

Then click Batch Submit to Baidu below the list!

The above is the detailed content of How to automatically submit imperial cms to Baidu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template