網站程式可以透過 PING RPC2 服務自動提醒百度搜尋引擎收錄你的網站,即時的哦!

首先新建一個新檔案,檔名自定,放 DZX 論壇的根目錄!

要自定名字的原因是,雖然百度提倡這麼幹,但是你不能老重複的提交啊,老虎屁股動不得!所以改名,以免別人搗蛋,你的站 K 了啥的,就別賴我了!

我這裡暫定名為: ping.php

這裡修改網址,修改中文部分為你的!

開啟了偽靜態的 ping.php 程式碼用這個

  1. <?php
  2. if(isset($_GET['action']))
  3. {
  4. $canshu=$_GET['action'];
  5. }
  6. function postUrl($url, $postvar)
  7. {
  8.     $ch = curl_init();
  9.     $headers = array(
  10.         "POST ".$url." HTTP/1.0",
  11.         "Content-type: text/xml; charset="utf-8"",
  12.         "Accept: text/xml",
  13.         "Content-length: ".strlen($postvar)
  14.     );
  15.     curl_setopt($ch, CURLOPT_URL, $url);
  16.     curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  17.     curl_setopt($ch, CURLOPT_POST, 1);
  18.     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  19.     curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
  20.     $res = curl_exec ($ch);
  21.     curl_close ($ch);
  22.     return $res;
  23. }
  24. $baiduXML = "<?xml version="1.0" encoding="utf-8"?>
  25.    <methodCall>
  26.    <methodName>weblogUpdates.extendedPing</methodName>
  27.    <params>
  28.    <param><value><string> 你的站名</string></value></param>
  29.    <param><value><string>http://你的 DZX 網址/</string></value></param>
  30.    <param><value><string>http://你的 DZX 網址/thread-$canshu-1-1.html</string></value></param>
  31.    <param><value><string>http://你的 DZX 網址/forum.php?mod=rss</string></value></param>
  32.    </params>
  33.    </methodCall>";
  34. $res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
  35. if ( strpos($res, "<int>0</int>") )
  36. {
  37.         header ("Location:http://你的 DZX 網址/thread-$canshu-1-1.html");
  38. }
  39. else
  40. {
  41.         header ("Location:http://你的 DZX 網址/thread-$canshu-1-1.html#");
  42. }
  43. ?>

沒開啟偽靜態的 ping.php 用這個

  1. <?php
  2. if(isset($_GET['action']))
  3. {
  4. $canshu=$_GET['action'];
  5. }
  6. function postUrl($url, $postvar)
  7. {
  8. $ch = curl_init();
  9. $headers = array(
  10. "POST ".$url." HTTP/1.0",
  11. "Content-type: text/xml; charset="utf-8"",
  12. "Accept: text/xml",
  13. "Content-length: ".strlen($postvar)
  14. );
  15. curl_setopt($ch, CURLOPT_URL, $url);
  16. curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  17. curl_setopt($ch, CURLOPT_POST, 1);
  18. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  19. curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
  20. $res = curl_exec ($ch);
  21. curl_close ($ch);
  22. return $res;
  23. }
  24. $baiduXML = "<?xml version="1.0" encoding="utf-8"?>
  25. <methodCall>
  26. <methodName>weblogUpdates.extendedPing</methodName>
  27. <params>
  28. <param><value><string> 你的站名</string></value></param>
  29. <param><value><string>http://你的 DZX 網址/</string></value></param>
  30. <param><value><string>http://你的 DZX 網址
    /forum.php?mod=viewthread&tid=$canshu</string></value></param>
  31. <param><value><string>http://你的 DZX 網址/forum.php?mod=rss</string></value></param>
  32. </params>
  33. </methodCall>";
  34. $res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
  35. if ( strpos($res, "<int>0</int>") )
  36. {
  37. header ("Location:http://你的 DZX 網址/forum.php?mod=viewthread&tid=$canshu");
  38. }
  39. else
  40. {
  41. header ("Location:http://你的 DZX 網址/forum.php?mod=viewthread&tid=$canshu#");
  42. }
  43. ?>


修改檔案 sourceincludepostpost_newthread.php

DZX2.0

找到:

  1. showmessage('post_newthread_succeed', "forum.php?mod=viewthread&tid=$tid&extra=$extra", $param);

替換為:

  1. showmessage('post_newthread_succeed', "ping 檔案的檔名稱.php?action=$tid", $param);

DZX2.5

找到:

  1. showmessage('post_newthread_succeed', $returnurl, $values, $param);

替換為:

  1. showmessage('post_newthread_succeed', "ping 檔案的檔名稱.php?action=$tid", $values, $param);

Tips:

如果 PING 失敗,那麼你發新帖後跳轉的網址最後面會有一個 #號!

測試是否 PING 成功,也可以訪問 http://你的 DZX 網址/ping 檔案的檔名稱.php?action=任意新帖子 ID,不成功的話,網址後面會有 #號。

搜尋引擎對原創內容的提權是很厲害的,不要每天到處去轉載帖子,轉載文章!

抽空去 「偽原創」 一篇文章,組織一下別人的新聞,編輯下內容,使之成為自己的原創內容,這樣,你發一篇,我敢保證百度收錄一篇,而且權重剛剛的。

很多大站的新聞編輯都是這麼幹的。不信自己搜搜熱門的關鍵詞,在百度新聞裡搜,然後看看同一篇文章大家的區別在哪裡。