⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 weblog_pinger.php

📁 BLOG HOSTER---PHP & MYSQL Create Blogs in seconds Installation of your BlogHoster system is easy.
💻 PHP
字号:
<?
/* weblog_pinger.php

Weblog_Pinger PHP Class Library by Rogers Cadenhead
Version 1.1
Web: http://www.cadenhead.org/workbench/weblog-pinger
   
Copyright (C) 2004 Rogers Cadenhead

The Weblog_Pinger class can send a ping message over XML-RPC to
weblog notification services such as Weblogs.Com, Blo.gs,
and Technorati.

This class should be stored in a directory accessible to
the PHP scripts that will use it.

This software requires the XML-RPC for PHP class library by
Usefulinc: http://xmlrpc.usefulinc.com/php.html. 

Example use:

require('weblog_pinger.php');
$pinger = new Weblog_Pinger();
echo $pinger->ping_ping_o_matic("Ekzemplo",
    "http://www.ekzemplo.com/");

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. */

// include the XML-RPC class library
require_once('xmlrpc.inc');

class Weblog_Pinger {
    // Weblogs.Com XML-RPC settings
    var $weblogs_com_server = "rpc.weblogs.com";
    var $weblogs_com_port = 80;
    var $weblogs_com_path = "/RPC2";
    var $weblogs_com_method = "weblogUpdates.ping";
    // Blo.gs XML-RPC settings
    var $blo_gs_server = "ping.blo.gs";
    var $blo_gs_port = 80;
    var $blo_gs_path = "/";
    var $blo_gs_method = "weblogUpdates.ping";
    // Ping-o-Matic XML-RPC settings
    var $ping_o_matic_server = "rpc.pingomatic.com";
    var $ping_o_matic_port = 80;
    var $ping_o_matic_path = "/RPC2";
    var $ping_o_matic_method = "weblogUpdates.ping";
    // Technorati XML-RPC settings
    var $technorati_server = "rpc.technorati.com";
    var $technorati_port = 80;
    var $technorati_path = "/rpc/ping";
    var $technorati_method = "weblogUpdates.ping";
    // Audio.Weblogs.Com XML-RPC settings
    var $audio_weblogs_com_server = "audiorpc.weblogs.com";
    var $audio_weblogs_com_port = 80;
    var $audio_weblogs_com_path = "/RPC2";
    var $audio_weblogs_com_method = "weblogUpdates.ping";    
    
    var $software_version = "1.1";
    var $debug = false;

    // report errors
    function report_error($message) {
//      error_log("Weblog Pinger: " . $message);
    }
    
    /* Ping Weblogs.Com to indicate that a weblog has been updated. Returns true
    on success and false on failure. */
    function ping_weblogs_com($weblog_name, $weblog_url, $changes_url = "", $category = "") {
        return $this->ping($this->weblogs_com_server, $this->weblogs_com_port,
            $this->weblogs_com_path, $this->weblogs_com_method, $weblog_name,
            $weblog_url, $changes_url, $category);
    }

    /* Ping Blo.gs to indicate that a weblog has been updated. Returns true on success
    and false on failure. */
    function ping_blo_gs($weblog_name, $weblog_url, $changes_url = "", $category = "") {
        return $this->ping($this->blo_gs_server, $this->blo_gs_port,
            $this->blo_gs_path, $this->blo_gs_method, $weblog_name, $weblog_url,
            $changes_url, $category);
    }
    
    /* Ping Technorati to indicate that a weblog has been updated. Returns true on
    success and false on failure. */
    function ping_technorati($weblog_name, $weblog_url, $changes_url = "", $category = "") {
        return $this->ping($this->technorati_server, $this->technorati_port,
            $this->technorati_path, $this->technorati_method, $weblog_name, $weblog_url,
            $changes_url, $category);
    }

    /* Ping all of the above services to indicate that a weblog has been updated.
    Returns true on success and false on failure. */
    function ping_all($weblog_name, $weblog_url, $changes_url = "", $category = "") {
        $error[0] = $this->ping_technorati($weblog_name, $weblog_url, $changes_url, $category);
        $error[1] = $this->ping_weblogs_com($weblog_name, $weblog_url, $changes_url, $category);
        $error[2] = $this->ping_blo_gs($weblog_name, $weblog_url, $changes_url, $category);
	    $all_ok = $error[0] & $error[1] & $error[2];
	    return array($all_ok, $error);
    }

    /* Ping Pingomatic to indicate that a weblog has been updated. Returns true on success
    and false on failure. */
    function ping_ping_o_matic($weblog_name, $weblog_url, $changes_url = "", $category = "") {
        return $this->ping($this->ping_o_matic_server, $this->ping_o_matic_port,
            $this->ping_o_matic_path, $this->ping_o_matic_method, $weblog_name,
            $weblog_url, $changes_url, $category);
    }
    
    /* Ping Audio.Weblogs.Com to indicate that a weblog with a podcast has been updated.
    Returns true on success and false on failure. */
    function ping_audio_weblogs_com($weblog_name, $weblog_url, $changes_url = "",
        $category = "") {
        
        return $this->ping($this->audio_weblogs_com_server, $this->audio_weblogs_com_port,
            $this->audio_weblogs_com_path, $this->audio_weblogs_com_method, $weblog_name,
            $weblog_url, $changes_url, $category);
    }

    /* Multi-purpose ping for any XML-RPC server that supports the Weblogs.Com interface. */
    function ping($xml_rpc_server, $xml_rpc_port, $xml_rpc_path, $xml_rpc_method,
        $weblog_name, $weblog_url, $changes_url, $category) {

        // build the parameters
        $name_param = new xmlrpcval($weblog_name, 'string');
        $url_param = new xmlrpcval($weblog_url, 'string');
        $changes_param = new xmlrpcval($changes_url, 'string');
        $cat_param = new xmlrpcval($category, 'string');
    
        if ($category_url != "") {
            $params = array($name_param, $url_param, $changes_param, $cat_param);
        } else {
            if ($changes_url != "") {
              $params = array($name_param, $url_param, $changes_param);
          } else {
              $params = array($name_param, $url_param);
            }
        } 
    
        // create the message
        $message = new xmlrpcmsg($xml_rpc_method, $params);
        $client = new xmlrpc_client($xml_rpc_path, $xml_rpc_server, 
            $xml_rpc_port);
        $response = $client->send($message);
        if ($response == 0) {
            $this->report_error("Error pinging " . $xml_rpc_server . ": "
                . $client->errno . " " . $client->errstring);
//            return false;
            return "1";
        }
        if ($response->faultCode() != 0)  {
            $this->report_error("Error pinging " . $xml_rpc_server . ": "
                . $response->faultCode() . " " . $response->faultString());
//            return false;
            return "2";

        }
        $response_value = $response->value();
        if ($this->debug) $this->report_error($response_value->serialize());
        $fl_error = $response_value->structmem('flerror');
        $message = $response_value->structmem('message');
        
        // read the response
        if ($fl_error->scalarval() != false) {
            $this->report_error("Error pinging " . $xml_rpc_server . ": "
                . $message->scalarval());
//            return false;
            return "3";
        }
        
        return "4";     
    }
}
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -