cvs: pear /Services_Pingback generate_package_xml.php package.xml package2.xml /Services_Pingback/Services Pingback.php /Services_Pingback/examples
receive.php send.php source.php target.php
| From: | Firman Wandayandi | Date: | Sun, 02 Oct 2005 17:35:43 +0000 |
| Subject: | cvs: pear /Services_Pingback generate_package_xml.php package.xml package2.xml /Services_Pingback/Services Pingback.php /Services_Pingback/examples receive.php send.php source.php target.php |
||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35224@lists.php.net to get a copy of this message | ||
firman Sun Oct 2 13:35:43 2005 EDT
Added files:
/pear/Services_Pingback/Services Pingback.php
/pear/Services_Pingback/examples receive.php send.php source.php
target.php
/pear/Services_Pingback generate_package_xml.php package.xml
package2.xml
Log:
Initial commit
http://cvs.php.net/co.php/pear/Services_Pingback/Services/Pingback.php?r=1.1&p=1 Index: pear/Services_Pingback/Services/Pingback.php +++ pear/Services_Pingback/Services/Pingback.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * PHP implementation of Pingback. * * This file contains Services_Pingback that is able to be work as Pingback * User-Agent. * * PHP versions 4 and 5 * * LICENSE: * * BSD License * * Copyright (c) 2005 Firman Wandayandi * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * 3. Neither the name of Firman Wandayandi nor the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Web Services * @package Services_Pingback * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2005 Firman Wandayandi * @license http://www.opensource.org/licenses/bsd-license.php * BSD License * @version CVS: $Id: Pingback.php,v 1.1 2005/10/02 17:35:42 firman Exp $ */ // }}} // {{{ Dependencies /** * Load PEAR::Net_URL for URL manipulation. */ require_once 'Net/URL.php'; /** * Load PEAR::HTTP_Request for HTTP request interface. */ require_once 'HTTP/Request.php'; /** * Load PEAR::XML_RPC for XML_RPC interface. */ require_once 'XML/RPC.php'; /** * Load PEAR::XML_RPC_Server for creating Pingback server. */ require_once 'XML/RPC/Server.php'; // }}} // {{{ Constants /** * A generic fault code. */ define('SERVICES_PINGBACK_ERROR', 0); /** * The source URI does not exist. */ define('SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS', 16); /** * The source URI does not contain a link to the target URI, and so cannot be * used as a source. */ define('SERVICES_PINGBACK_ERROR_NO_TARGET_LINK', 17); /** * The specified target URI does not exist. */ define('SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS', 32); /** * The specified target URI cannot be used as a target. */ define('SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE', 33); /** * The pingback has already been registered. */ define('SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED', 48); /** * Access denied. */ define('SERVICES_PINGBACK_ERROR_ACCESS_DENIED', 49); /** * The server could not communicate with an upstream server, or received an * error from an upstream server, and therefore could not complete the request. * This is similar to HTTP's 402 Bad Gateway error. */ define('SERVICES_PINGBACK_ERROR_UPSTREAM_ERROR', 50); /** * XML-RPC string type. */ define('SERVICES_PINGBACK_XML_RPC_STRING', $GLOBALS['XML_RPC_String']); // }}} // {{{ Global Variables /** * An instance of Services_Pingback object. * * This is the way to make the server working when XML-RPC ping method called. * This also meant that only one instance Pingback server can be run at one time. * * @global object $GLOBALS['_Services_Pingback_server'] * @name $_Services_Pingback_server */ $GLOBALS['_Services_Pingback_server'] = null; // }}} // {{{ Class: Services_Pingback /** * Pingback user-agent class. * * This class implemented of Pingback 1.0 specification, visit * http://www.hixie.ch/specs/pingback/pingback for more information. * * @category Web Services * @package Services_Pingback * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2005 Firman Wandayandi * @license http://www.opensource.org/licenses/bsd-license.php * BSD License * @version Release: @package_version@ * @todo Enabled access denied and upstream error response. * @todo Extract more pretty context of source and flexible direction. * @todo Finished PHPUnit test classes. */ class Services_Pingback { // {{{ Properties /** * Pingback data. * * @var array * @access private */ var $_data = array( 'sourceURI' => '', 'targetURI' => '', 'pingbackURI' => '' ); /** * Available options for Services_Pingback. * * @var array * @access private */ var $_options = array( 'timeout' => 30, 'allowRedirects' => true, 'maxRedirects' => 2, 'fetchsize' => 255, 'debug' => false ); /** * Pingback XML-RPC dispatches method. * * @var array * @access private */ var $_dispatches = array( 'pingback.ping' => array( 'function' => array('Services_Pingback', 'ping'), 'signature' => array( array( SERVICES_PINGBACK_XML_RPC_STRING, SERVICES_PINGBACK_XML_RPC_STRING, SERVICES_PINGBACK_XML_RPC_STRING ) ), 'docstring' => 'Register your comment via Pingback sytem' ) ); /** * Registered pingback URIs. * * @var array * @access private */ var $_registeredSources = array(); /** * Entities translation table. * * @var array * @access private */ var $_transEntities = array( '&' => '&', '<' => '<', '>' => '>', '"' => '"' ); /** * Fetched source context. * * @var string * @access private */ var $_sourceContext = ''; // }}} // {{{ Constructor /** * Constructor. * * @param array $data The pingback data, are: * <pre> * sourceURI The absolute URI of the post on the source page containing the link to the target site. * targetURI The absolute URI of the target of the link, as given on the source page. * pingbackURI (optional) Manually sets a Pingback URI. * </pre> * * @param array $options Option for pingback. Valid options are: * <pre> * timeout (optional) Connection timeout in seconds (float), default 30 seconds. * allowRedirects (optional) Whether follow redirect or not (bool), default TRUE. * maxRedirects (optional) Max Number of redirects (int), default 2. * fetchsize (optional) A size of string to fetch in bytes (int), default 255. * debug (optional) Whether print out debug messages or not (bool), defaul FALSE. * </pre> * * @access public */ function Services_Pingback($data = null, $options = null) { if (is_array($data)) { $this->setFromArray($data); } if (is_array($options)) { $this->setOptions($options); } } // }}} // {{{ setOptions() /** * Set the options of the Services_Pingback object. * * @param array $options An associative array contains options. * * @see create() * @access public */ function setOptions($options) { if (!is_array($options)) { return PEAR::raiseError('Type mistmatch, only array accepted.'); } foreach ($options as $option => $value) { if (!isset($this->_options[$option])) { return PEAR::raiseError('Unknown option "' . $option . '".'); } switch ($option) { case 'timeout': if (!is_float($value) || $value < 0) { return PEAR::raiseError('Invalid value for options "' . $option . '".'); } break; case 'allowRedirects': if (!is_bool($value)) { return PEAR::raiseError('Invalid value for option "'.$option.'".'); } break; case 'maxRedirects': if (!is_int($value) || ($value < 0)) { return PEAR::raiseError('Invalid value for option "'.$option.'".'); } break; case 'fetchsize': if (!is_int($value) || $value <= 0) { return PEAR::raiseError('Invalid value for option "' . $option . '".'); } break; case 'debug': if (!is_bool($value)) { return PEAR::raiseError('Invalid value for option "' . $option . '".'); } break; } $this->_options[$option] = $value; } return true; } // }}} // {{{ getOptions() /** * Get current options. * * @return array An associative array of options. * @access public */ function getOptions() { return $this->_options; } // }}} // {{{ set() /** * Set a pingback data. * * @param string $key Data key name. * @param string $value Data value. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public */ function set($key, $value) { if (!isset($this->_data[$key])) { return PEAR::raiseError('Unknown data key "' . $key . '".'); } $this->_data[$key] = $value; return true; } // }}} // {{{ get() /** * Get a pingback data. * * @param string $key Data key name. * * @return mixed Data value or NULL if data not found. * @access public */ function get($key) { if (isset($this->_data[$key])) { return $this->_data[$key]; } return null; } // }}} // {{{ setFromArray() /** * Set the pingback data from an associative array. * * @param array $data An associative array of data. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @see set() */ function setFromArray($data) { if (!is_array($data)) { return PEAR::raiseError('Type mistmatch, only array accepted.'); } foreach ($data as $key => $value) { $res = $this->set($key, $value); if (PEAR::isError($res)) { return $res; } } return true; } // }}} // {{{ setRegisteredSources() /** * Set registered pingback source URIs. * * This method will override current registered sources data. For avoid it * use addRegisteredSource(). * * @param array $data An array contains sources. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @see addRegisteredSource() * @see isPingbackRegistered() */ function setRegisteredSources($data) { if (!is_array($data)) { return PEAR::raiseError('Type mistmatch, only array accepted.'); } $this->_registeredSources = $data; return true; } // }}} // {{{ addRegisteredSource() /** * Add registered pingback source(s). * * @param mixed $data A string URI or An array contains URIs. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @see setRegisteredSources() * @see isPingbackRegistered() */ function addRegisteredSource($data) { if (is_array($data)) { foreach ($data as $value) { $this->addRegisteredSource($value); } } else if (is_string($data) && !empty($data)) { $this->_registeredSources[] = $data; } else { return PEAR::raiseError('Invalid value'); } return true; } // }}} // {{{ getRegisteredSources() /** * Get registered pingback source URIs. * * @return array List of registered source URIs. * @access public */ function getRegisteredSources() { return $this->_registeredSources(); } // }}} // {{{ autodiscover() /** * Implemented of Pingback autodiscovery algorithm. * * This method send a request to given URI, then see if the header contain * Pingback header, if not attempt to find a Pingback link on the body contents. * This algorithm is one of requirement of the Pingback clients specification. * * @param string $uri URI to discover. * * @return string|PEAR_Error A Pingback URI on success or PEAR_Error on failure. * @access public * @see sendHTTPRequest() * @see expandEntities() */ function autodiscover($uri) { $res = $this->sendHTTPRequest($uri); if (PEAR::isError($res)) { return $res; } $pingbackURI = ''; if (isset($res['header']['x-pingback']) && !empty($res['header']['x-pingback'])) { $pingbackURI = $res['header']['x-pingback']; } else if (preg_match('@\<link rel="pingback" href="([^"]+)" ?\/?\>@i', $res['body'], $matches)) { $pingbackURI = $matches[1]; } if (!empty($pingbackURI)) { $pingbackURI = $this->expandEntities($pingbackURI); } return $pingbackURI; } // }}} // {{{ send() /** * Send a pingback. * * @param array $data (optional) An array of pingback data. * * @access public * @see autodiscover() */ function send($data = null) { if ($data !== null) { $res = $this->setFromArray($data); if (PEAR::isError($res)) { return $res; } } // Find the whether if source and target is equal or not. if (strstr($this->_data['sourceURI'], $this->_data['targetURI'])) { return PEAR::raiseError('Target URI is equal with source URI'); } // pingback URI set if (empty($this->_data['pingbackURI'])) { $res = Services_Pingback::autodiscover($this->_data['targetURI']); if (PEAR::isError($res)) { return $res; } else if (empty($res)) { return PEAR::raiseError('Target URI is not a pingback-enabled resource'); } $this->_data['pingbackURI'] = $res; } // Prepare an XML-RPC Message. $eArgs = array( XML_RPC_encode($this->_data['sourceURI']), XML_RPC_encode($this->_data['targetURI']) ); $msg = new XML_RPC_Message('pingback.ping', $eArgs); // Prepare full path of URI to conforms XML_RPC_Client parameter. $url = new Net_URL($this->_data['pingbackURI']); $path = $url->path; $querystring = $url->getQueryString(); if (!empty($querystring)) { $path .= '?' . $querystring; } $cli = new XML_RPC_Client($path, $url->protocol . '://' . $url->host, $url->port); $cli->setDebug((int) $this->_options['debug']); $res = $cli->send($msg); $val = $res->value(); if (!is_object($val) || !is_a($val, 'XML_RPC_value')) { return PEAR::raiseError('Response Error: ' . $res->faultString()); } return XML_RPC_decode($val); } // }}} // {{{ receive() /** * Receive pingback call. * * @access public */ function receive() { $GLOBALS['_Services_Pingback_server'] =& $this; new XML_RPC_Server($this->_dispatches, 1, $this->_options['debug']); } // }}} // {{{ errorMessage() /** * Get error message. * * @param int $value Error code. * * @return string Error message. * @access public */ function errorMessage($value) { $errorMessages = array( SERVICES_PINGBACK_ERROR => 'Unknown error', SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS => 'Source URI doesn\'t exist', SERVICES_PINGBACK_ERROR_NO_TARGET_LINK => 'Source URI doesn\'t contain a link to the target URI', SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS => 'Target URI doesn\'t exist', SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE => 'Target URI is not a pingback-enabled resource', SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED => 'Pingback has already been registered', SERVICES_PINGBACK_ERROR_ACCESS_DENIED => 'Access denied', SERVICES_PINGBACK_ERROR_UPSTREAM_ERROR => 'Upstream server error' ); return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[SERVICES_PINGBACK_ERROR]; } // }}} // {{{ sendHTTPRequest() /** * Send a HTTP 1/1 request. * * @param string $uri URI. * * @return array|PEAR_Error An associative array of result containing keys * 'code', 'header' and 'body' on success or * PEAR_Error on failure. * @access public */ function sendHTTPRequest($uri) { $params = array( 'timeout' => $this->_options['timeout'], 'allowRedirects' => $this->_options['allowRedirects'], 'maxRedirects' => $this->_options['maxRedirects'] ); $req = new HTTP_Request($uri, $params); $req->sendRequest(); if (PEAR::isError($req)) { return $req; } if ($req->getResponseCode() != 200) { return PEAR::raiseError('Host returned error: ' . $req->getResponseCode()); } return array( 'code' => $req->getResponseCode(), 'header' => $req->getResponseHeader(), 'body' => $req->getResponseBody() ); } // }}} // {{{ expandEntities() /** * Expand the entities. * * There are four allowed entities (& for &, < for <, > for > and * " for "). * * @param string $str A string to expand, normally is a uri. * * @return string A result. * @access public */ function expandEntities($str) { return strtr($str, $this->_transEntities); } // }}} // {{{ sendPingbackHeader() /** * Send a Pingback header to tell this is a pingback-enable resource. * * @param string $pingbackURI (optional) Pingback URI, if not given URI is * the current URI. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @static */ function sendPingbackHeader($pingbackURI = null) { if (headers_sent()) { return PEAR::raiseError('Header already sent, cannot sent Pingback header'); } if ($pingbackURI === null) { $url = new Net_URL($url); $pingbackURI = $url->getURL(); } header('X-Pingback: ' . $pingbackURI); return true; } // }}} // {{{ isURIExist() /** * Find out the whether the URI is exist, done with fopen(). * * @param string $uri URI to verify. * * @return bool TRUE if exist, otherwise FALSE. * @access public * @static */ function isURIExist($uri) { if (is_resource(@fopen($uri, 'r'))) { return true; } return false; } // }}} // {{{ isSourceLinked() /** * Find the a link to URI on the contents body of given URI. * * @param string $uri URI to scans. * @param string $linkURI URI to be found on the link. * * @return bool TRUE if a link found, otherwise FALSE. * @access public * @see sendHTTPRequest() */ function isSourceLinked() { $res = $this->sendHTTPRequest($this->_data['sourceURI']); if (PEAR::isError($res)) { return $res; } if (preg_match('@\<a.+href="'. preg_quote($this->_data['targetURI']) . '".*\>.+\<\/a\>@', $res['body'])) { return true; } return false; } // }}} // {{{ isPingbackRegistered() /** * Find out the whether if pingback from URI has already registered. * * @param string $sourceURI Source URI. * * @return bool TRUE if has already registered, otherwise FALSE. * @access public */ function isPingbackRegistered() { if (in_array($this->_data['sourceURI'], $this->_registeredSources)) { return true; } return false; } // }}} // {{{ isPingbackEnabled() /** * Find the whether a resouce is a pingback-enabled or not. * * @param string $uri URI to scans. * * @return bool|PEAR_Error TRUE if it's pingback-enabled, otherwise FALSE or * PEAR_Error on failure. * @access public */ function isTargetPingbackEnabled() { $res = $this->autodiscover($this->_data['targetURI']); if (PEAR::isError($res)) { return $res; } if (!empty($res)) { return true; } return false; } // }}} // {{{ fetchSourceContext() /** * Fetch page context for current call. * * @return array|PEAR_Error An array of context on success or PEAR_Error on failure. * @access public */ function fetchSourceContext() { $res = $this->sendHTTPRequest($this->_data['sourceURI']); if (PEAR::isError($res)) { return $res; } $this->_sourceContext= array( 'title' => 'Untitled', 'content' => '', 'url' => $this->_data['sourceURI'] ); $str = $res['body']; // Extract the page title first. if (preg_match('@<title>([^<]*?)</title>@is', $str, $matches)) { $this->_sourceContext['title'] = $matches[1]; } // Extract the page body. if (preg_match('@<body[^>]*>(.*)<\/body>@is', $str, $matches)) { $str = $matches[1]; } // Remove unecessary elements. $removeElems = array( 'style', 'script', 'meta', ); foreach ($removeElems as $elem) { $str = preg_replace('@<' . $elem . '[^>]*\/>@is', '', $str); $str = preg_replace('@<' . $elem . '[^>]*>.*<\/' . $elem . '>@is', '', $str); } // Strips all tags except <a>. $str = strip_tags($str, '<a>'); // Strips all links except target URI. if (preg_match_all('@<a.+href="(.+)".*>.+?<\/a>@i', $str, $matches, PREG_SET_ORDER)) { foreach ($matches as $res) { if (!strstr($res[1], $this->_data['targetURI'])) { $str = str_replace($res[0], $res[1], $str); } } } // Extract the context, from exact target link position. if (preg_match('@<a.+href="'. preg_quote($this->_data['targetURI']) . '".*>.+<\/a>@i', $str, $matches)) { $linkText = $matches[0]; $linkPos = strpos($str, $linkText); $linkLen = strlen($linkText); $sideSize = (int)(($this->_options['fetchsize'] - $linkLen) / 2); if ($sideSize > $linkPos) { $leftText = ''; $leftStart = 0; } else { $leftText = '... '; $leftStart = $linkPos - ($sideSize - 4); } $leftText .= substr($str, $leftStart, $linkPos - $leftStart); $rightText = substr($str, $linkPos + $linkLen); if (strlen($rightText) > $sideSize) { $rightText = substr($rightText, 0, $sideSize - 4) . ' ...'; } $this->_sourceContext['content'] = trim($leftText . $linkText . $rightText); } return true; } // }}} // {{{ getSourceContext() /** * Get fetched source context. * * @return string Fetched source context. * @access public */ function getSourceContext() { return $this->_sourceContext; } // }}} // {{{ ping() /** * A callback of Pingback XML-RPC pingback.ping method. * * @param object $msg An instance of XML_RPC_Message object. * * @return XML_RPC_Response A result of current call. * @access public * @static * @see isURIExist() * @see isSourceLinked() * @see isTargetPingbackEnabled() * @see isPingbackRegistered() * @see fetchSourceContext() * @see getSourceContext() */ function ping($msg) { $Services_Pingback_server =& $GLOBALS['_Services_Pingback_server']; $sourceURI = $msg->params[0]->getval(); $targetURI = $msg->params[1]->getval(); $Services_Pingback_server->set('sourceURI', $sourceURI); $Services_Pingback_server->set('targetURI', $targetURI); if (!Services_Pingback::isURIExist($sourceURI)) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS ) ); } if (!$Services_Pingback_server->isSourceLinked()) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_NO_TARGET_LINK, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_NO_TARGET_LINK ) ); } if (!Services_Pingback::isURIExist($targetURI)) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS ) ); } if (!$Services_Pingback_server->isTargetPingbackEnabled()) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE ) ); } if ($Services_Pingback_server->isPingbackRegistered()) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED ) ); } $Services_Pingback_server->fetchSourceContext(); return new XML_RPC_Response(new XML_RPC_Value('Pingback from ' . $sourceURI . ' success')); } // }}} } ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/receive.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/receive.php +++ pear/Services_Pingback/examples/receive.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Services_Pingback receive example. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } // Load Services_Pingback. require_once 'Services/Pingback.php'; // Receive pingback call. $pingback = new Services_Pingback; // Turn on debug mode. # $pingback->setOptions(array('debug' => true)); $pingback->receive(); print "\n" . '------------------------ Context -------------------------' . "\n"; print '<!--' . "\n"; $context = $pingback->getSourceContext(); foreach ($context as $key => $value) { print "$key = $value\n"; } print '-->' . "\n"; print '------------------------ Context -------------------------' . "\n"; /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/send.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/send.php +++ pear/Services_Pingback/examples/send.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Services_Pingback send example. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } // Load Services_Pingback require_once 'Services/Pingback.php'; // Setting up URIs $selfURI = 'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $sourceURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/source.php'; $targetURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/target.php'; // let's assume that we don't know this pingback URI, to test // Services_Pingback::autoDiscover() method. $pingbackURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/receive.php'; $options = array( 'debug' => true ); $data = array( 'sourceURI' => $sourceURI, 'targetURI' => $targetURI ); $pingback = new Services_Pingback($data, $options); print '<h2>Services_Pingback Example</h2>' . "\n" . 'Sources: ' . '<a href="' . $selfURI . '?source" target="_blank">send.php</a> | ' . '<a href="' . $pingbackURI . '?source" target="_blank">receive.php</a> | ' . '<a href="' . $sourceURI . '?source" target="_blank">source.php</a> | ' . '<a href="' . $targetURI . '?source" target="_blank">target.php</a>' . '<hr />' . "\n" . '<strong>source URI</strong>: <a href="' . $sourceURI . '" target="_blank">' . $sourceURI . "</a><br />\n" . '<strong>target URI</strong>: <a href="' . $targetURI . '" target="_blank">' . $targetURI . "</a><br />\n"; print '<strong>------------------------- Sending Pingback --------------------------</strong>' . "<br />\n"; $res = $pingback->send(); print '<strong>------------------------- Received Response -------------------------</strong>' . "<br />\n"; if (PEAR::isError($res)) { $response = $res->getMessage(); } else { $response = $res; } print '<strong>Response</strong>: ' . $response; /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/source.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/source.php +++ pear/Services_Pingback/examples/source.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Source blog. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } $targetURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/target.php'; //$targetURI = 'http://localhost/tests/blog/wordpress/?p=1'; ?> <!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Service_Pingback Test Source</title> </head> <body> <p>Try to send pingback call to <a href="<?php print $targetURI ?>"><?php print $targetURI ?></a> and see what happen.</p> </body> </html> <?php /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/target.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/target.php +++ pear/Services_Pingback/examples/target.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Target blog. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } $pingbackURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/receive.php'; ?> <!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <link rel="pingback" href="<?php print $pingbackURI ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Services_Pingback Test Target</title> </head> <body> <p>What's up there, is it anyone link to me?</p> </body> </html> <?php /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/generate_package_xml.php?r=1.1&p=1 Index: pear/Services_Pingback/generate_package_xml.php +++ pear/Services_Pingback/generate_package_xml.php <?php require_once('PEAR/PackageFileManager.php'); $pkg = new PEAR_PackageFileManager; $packagedir = dirname(__FILE__); $self = basename(__FILE__); $desc = "A package implemented of Pingback in PHP, able to sending and receiving a pingback."; $options = array( 'doctype' => 'D:\Net\www\htdocs\PEAR\PEAR\data\PEAR\package.dtd', 'package' => 'Services_Pingback', 'license' => 'BSD License', 'baseinstalldir' => '', 'version' => '0.2.0dev2', 'packagedirectory' => $packagedir, 'pathtopackagefile' => $packagedir, 'state' => 'devel', 'filelistgenerator' => 'file', 'notes' => 'Initial release of Services_Pingback', 'summary' => 'A Pingback User-Agent class.', 'description' => $desc, 'ignore' => array( 'package.xml', '*.tgz', $self ) ); $e = $pkg->setOptions($options); if (PEAR::isError($e)) { echo $e->getMessage(); die; } // hack until they get their shit in line with docroot role $pkg->addRole('tpl', 'php'); $pkg->addRole('png', 'php'); $pkg->addRole('gif', 'php'); $pkg->addRole('jpg', 'php'); $pkg->addRole('css', 'php'); $pkg->addRole('js', 'php'); $pkg->addRole('ini', 'php'); $pkg->addRole('inc', 'php'); $pkg->addRole('afm', 'php'); $pkg->addRole('pkg', 'doc'); $pkg->addRole('cls', 'doc'); $pkg->addRole('proc', 'doc'); $pkg->addRole('txt', 'doc'); $pkg->addRole('sh', 'script'); $pkg->addMaintainer('firman', 'lead', 'Firman Wandayandi', 'firman@php.net'); $pkg->addDependency('XML_RPC', '1.0.3RC1', 'ge', 'pkg'); $pkg->addDependency('Net_URL', '1.0.14', 'ge', 'pkg'); $pkg->addDependency('HTTP_Request', '1.2.4', 'ge', 'pkg'); $pkg->addDependency('PHP', '4.3.0', 'ge', 'php'); $pkg->addReplacement('Services/Pingback.php', 'package-info', '@package_version@', 'version'); $e = $pkg->writePackageFile(); if (PEAR::isError($e)) { echo $e->getMessage(); } ?> http://cvs.php.net/co.php/pear/Services_Pingback/package.xml?r=1.1&p=1 Index: pear/Services_Pingback/package.xml +++ pear/Services_Pingback/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0" packagerversion="1.4.0a11"> <name>Services_Pingback</name> <summary>A Pingback User-Agent class.</summary> <description>A package implemented of Pingback in PHP, able to sending and receiving a pingback. </description> <maintainers> <maintainer> <user>firman</user> <name>Firman Wandayandi</name> <email>firman@php.net</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.2.0dev2</version> <date>2005-06-04</date> <license>BSD License</license> <state>devel</state> <notes>Initial release of Services_Pingback </notes> <deps> <dep type="pkg" rel="ge" version="1.0.3RC1" optional="no">XML_RPC</dep> <dep type="pkg" rel="ge" version="1.0.14" optional="no">Net_URL</dep> <dep type="pkg" rel="ge" version="1.2.4" optional="no">HTTP_Request</dep> <dep type="php" rel="ge" version="4.3.0" optional="no"/> </deps> <provides type="class" name="Services_Pingback" /> <provides type="function" name="Services_Pingback::setOptions" /> <provides type="function" name="Services_Pingback::getOptions" /> <provides type="function" name="Services_Pingback::set" /> <provides type="function" name="Services_Pingback::get" /> <provides type="function" name="Services_Pingback::setFromArray" /> <provides type="function" name="Services_Pingback::setRegisteredSources" /> <provides type="function" name="Services_Pingback::addRegisteredSource" /> <provides type="function" name="Services_Pingback::getRegisteredSources" /> <provides type="function" name="Services_Pingback::autodiscover" /> <provides type="function" name="Services_Pingback::send" /> <provides type="function" name="Services_Pingback::receive" /> <provides type="function" name="Services_Pingback::errorMessage" /> <provides type="function" name="Services_Pingback::sendHTTPRequest" /> <provides type="function" name="Services_Pingback::expandEntities" /> <provides type="function" name="Services_Pingback::sendPingbackHeader" /> <provides type="function" name="Services_Pingback::isURIExist" /> <provides type="function" name="Services_Pingback::isSourceLinked" /> <provides type="function" name="Services_Pingback::isPingbackRegistered" /> <provides type="function" name="Services_Pingback::isTargetPingbackEnabled" /> <provides type="function" name="Services_Pingback::fetchSourceContext" /> <provides type="function" name="Services_Pingback::getSourceContext" /> <provides type="function" name="Services_Pingback::ping" /> <filelist> <file role="doc" baseinstalldir="" name="examples/receive.php"/> <file role="doc" baseinstalldir="" name="examples/send.php"/> <file role="doc" baseinstalldir="" name="examples/source.php"/> <file role="doc" baseinstalldir="" name="examples/target.php"/> <file role="php" baseinstalldir="" name="Services/Pingback.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </filelist> </release> <changelog> <release> <version>0.2.0dev2</version> <date>2005-06-04</date> <license>BSD License</license> <state>devel</state> <notes>Initial release of Services_Pingback </notes> </release> </changelog> </package> http://cvs.php.net/co.php/pear/Services_Pingback/package2.xml?r=1.1&p=1 Index: pear/Services_Pingback/package2.xml +++ pear/Services_Pingback/package2.xml <?xml version="1.0"?> <package packagerversion="1.4.0a11" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>Services_Pingback</name> <channel>pear.php.net</channel> <summary>A Pingback User-Agent class.</summary> <description>A package implemented of Pingback in PHP, able to sending and receiving a pingback. </description> <lead> <name>Firman Wandayandi</name> <user>firman</user> <email>firman@php.net</email> <active>yes</active> </lead> <date>2005-06-04</date> <time>21:32:45</time> <version> <release>0.2.0dev2</release> <api>0.2.0dev2</api> </version> <stability> <release>devel</release> <api>devel</api> </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license> <notes>Initial release of Services_Pingback </notes> <contents> <dir name="/"> <dir name="examples"> <file baseinstalldir="" name="receive.php" role="doc" /> <file baseinstalldir="" name="send.php" role="doc" /> <file baseinstalldir="" name="source.php" role="doc" /> <file baseinstalldir="" name="target.php" role="doc" /> </dir> <!-- /examples --> <dir name="Services"> <file baseinstalldir="" name="Pingback.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> </dir> <!-- /Services --> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>4.3.0</min> </php> <pearinstaller> <min>1.4.0a1</min> </pearinstaller> <package> <name>XML_RPC</name> <channel>pear.php.net</channel> <min>1.0.3RC1</min> </package> <package> <name>Net_URL</name> <channel>pear.php.net</channel> <min>1.0.14</min> </package> <package> <name>HTTP_Request</name> <channel>pear.php.net</channel> <min>1.2.4</min> </package> </required> </dependencies> <phprelease /> <changelog> <release> <version> <release>0.2.0dev2</release> <api>0.2.0dev2</api> </version> <stability> <release>devel</release> <api>devel</api> </stability> <date>2005-06-04</date> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license> <notes>Initial release of Services_Pingback </notes> </release> </changelog> </package>
http://cvs.php.net/co.php/pear/Services_Pingback/Services/Pingback.php?r=1.1&p=1 Index: pear/Services_Pingback/Services/Pingback.php +++ pear/Services_Pingback/Services/Pingback.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */ // {{{ Header /** * PHP implementation of Pingback. * * This file contains Services_Pingback that is able to be work as Pingback * User-Agent. * * PHP versions 4 and 5 * * LICENSE: * * BSD License * * Copyright (c) 2005 Firman Wandayandi * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * 3. Neither the name of Firman Wandayandi nor the names of * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * @category Web Services * @package Services_Pingback * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2005 Firman Wandayandi * @license http://www.opensource.org/licenses/bsd-license.php * BSD License * @version CVS: $Id: Pingback.php,v 1.1 2005/10/02 17:35:42 firman Exp $ */ // }}} // {{{ Dependencies /** * Load PEAR::Net_URL for URL manipulation. */ require_once 'Net/URL.php'; /** * Load PEAR::HTTP_Request for HTTP request interface. */ require_once 'HTTP/Request.php'; /** * Load PEAR::XML_RPC for XML_RPC interface. */ require_once 'XML/RPC.php'; /** * Load PEAR::XML_RPC_Server for creating Pingback server. */ require_once 'XML/RPC/Server.php'; // }}} // {{{ Constants /** * A generic fault code. */ define('SERVICES_PINGBACK_ERROR', 0); /** * The source URI does not exist. */ define('SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS', 16); /** * The source URI does not contain a link to the target URI, and so cannot be * used as a source. */ define('SERVICES_PINGBACK_ERROR_NO_TARGET_LINK', 17); /** * The specified target URI does not exist. */ define('SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS', 32); /** * The specified target URI cannot be used as a target. */ define('SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE', 33); /** * The pingback has already been registered. */ define('SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED', 48); /** * Access denied. */ define('SERVICES_PINGBACK_ERROR_ACCESS_DENIED', 49); /** * The server could not communicate with an upstream server, or received an * error from an upstream server, and therefore could not complete the request. * This is similar to HTTP's 402 Bad Gateway error. */ define('SERVICES_PINGBACK_ERROR_UPSTREAM_ERROR', 50); /** * XML-RPC string type. */ define('SERVICES_PINGBACK_XML_RPC_STRING', $GLOBALS['XML_RPC_String']); // }}} // {{{ Global Variables /** * An instance of Services_Pingback object. * * This is the way to make the server working when XML-RPC ping method called. * This also meant that only one instance Pingback server can be run at one time. * * @global object $GLOBALS['_Services_Pingback_server'] * @name $_Services_Pingback_server */ $GLOBALS['_Services_Pingback_server'] = null; // }}} // {{{ Class: Services_Pingback /** * Pingback user-agent class. * * This class implemented of Pingback 1.0 specification, visit * http://www.hixie.ch/specs/pingback/pingback for more information. * * @category Web Services * @package Services_Pingback * @author Firman Wandayandi <firman@php.net> * @copyright Copyright (c) 2005 Firman Wandayandi * @license http://www.opensource.org/licenses/bsd-license.php * BSD License * @version Release: @package_version@ * @todo Enabled access denied and upstream error response. * @todo Extract more pretty context of source and flexible direction. * @todo Finished PHPUnit test classes. */ class Services_Pingback { // {{{ Properties /** * Pingback data. * * @var array * @access private */ var $_data = array( 'sourceURI' => '', 'targetURI' => '', 'pingbackURI' => '' ); /** * Available options for Services_Pingback. * * @var array * @access private */ var $_options = array( 'timeout' => 30, 'allowRedirects' => true, 'maxRedirects' => 2, 'fetchsize' => 255, 'debug' => false ); /** * Pingback XML-RPC dispatches method. * * @var array * @access private */ var $_dispatches = array( 'pingback.ping' => array( 'function' => array('Services_Pingback', 'ping'), 'signature' => array( array( SERVICES_PINGBACK_XML_RPC_STRING, SERVICES_PINGBACK_XML_RPC_STRING, SERVICES_PINGBACK_XML_RPC_STRING ) ), 'docstring' => 'Register your comment via Pingback sytem' ) ); /** * Registered pingback URIs. * * @var array * @access private */ var $_registeredSources = array(); /** * Entities translation table. * * @var array * @access private */ var $_transEntities = array( '&' => '&', '<' => '<', '>' => '>', '"' => '"' ); /** * Fetched source context. * * @var string * @access private */ var $_sourceContext = ''; // }}} // {{{ Constructor /** * Constructor. * * @param array $data The pingback data, are: * <pre> * sourceURI The absolute URI of the post on the source page containing the link to the target site. * targetURI The absolute URI of the target of the link, as given on the source page. * pingbackURI (optional) Manually sets a Pingback URI. * </pre> * * @param array $options Option for pingback. Valid options are: * <pre> * timeout (optional) Connection timeout in seconds (float), default 30 seconds. * allowRedirects (optional) Whether follow redirect or not (bool), default TRUE. * maxRedirects (optional) Max Number of redirects (int), default 2. * fetchsize (optional) A size of string to fetch in bytes (int), default 255. * debug (optional) Whether print out debug messages or not (bool), defaul FALSE. * </pre> * * @access public */ function Services_Pingback($data = null, $options = null) { if (is_array($data)) { $this->setFromArray($data); } if (is_array($options)) { $this->setOptions($options); } } // }}} // {{{ setOptions() /** * Set the options of the Services_Pingback object. * * @param array $options An associative array contains options. * * @see create() * @access public */ function setOptions($options) { if (!is_array($options)) { return PEAR::raiseError('Type mistmatch, only array accepted.'); } foreach ($options as $option => $value) { if (!isset($this->_options[$option])) { return PEAR::raiseError('Unknown option "' . $option . '".'); } switch ($option) { case 'timeout': if (!is_float($value) || $value < 0) { return PEAR::raiseError('Invalid value for options "' . $option . '".'); } break; case 'allowRedirects': if (!is_bool($value)) { return PEAR::raiseError('Invalid value for option "'.$option.'".'); } break; case 'maxRedirects': if (!is_int($value) || ($value < 0)) { return PEAR::raiseError('Invalid value for option "'.$option.'".'); } break; case 'fetchsize': if (!is_int($value) || $value <= 0) { return PEAR::raiseError('Invalid value for option "' . $option . '".'); } break; case 'debug': if (!is_bool($value)) { return PEAR::raiseError('Invalid value for option "' . $option . '".'); } break; } $this->_options[$option] = $value; } return true; } // }}} // {{{ getOptions() /** * Get current options. * * @return array An associative array of options. * @access public */ function getOptions() { return $this->_options; } // }}} // {{{ set() /** * Set a pingback data. * * @param string $key Data key name. * @param string $value Data value. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public */ function set($key, $value) { if (!isset($this->_data[$key])) { return PEAR::raiseError('Unknown data key "' . $key . '".'); } $this->_data[$key] = $value; return true; } // }}} // {{{ get() /** * Get a pingback data. * * @param string $key Data key name. * * @return mixed Data value or NULL if data not found. * @access public */ function get($key) { if (isset($this->_data[$key])) { return $this->_data[$key]; } return null; } // }}} // {{{ setFromArray() /** * Set the pingback data from an associative array. * * @param array $data An associative array of data. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @see set() */ function setFromArray($data) { if (!is_array($data)) { return PEAR::raiseError('Type mistmatch, only array accepted.'); } foreach ($data as $key => $value) { $res = $this->set($key, $value); if (PEAR::isError($res)) { return $res; } } return true; } // }}} // {{{ setRegisteredSources() /** * Set registered pingback source URIs. * * This method will override current registered sources data. For avoid it * use addRegisteredSource(). * * @param array $data An array contains sources. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @see addRegisteredSource() * @see isPingbackRegistered() */ function setRegisteredSources($data) { if (!is_array($data)) { return PEAR::raiseError('Type mistmatch, only array accepted.'); } $this->_registeredSources = $data; return true; } // }}} // {{{ addRegisteredSource() /** * Add registered pingback source(s). * * @param mixed $data A string URI or An array contains URIs. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @see setRegisteredSources() * @see isPingbackRegistered() */ function addRegisteredSource($data) { if (is_array($data)) { foreach ($data as $value) { $this->addRegisteredSource($value); } } else if (is_string($data) && !empty($data)) { $this->_registeredSources[] = $data; } else { return PEAR::raiseError('Invalid value'); } return true; } // }}} // {{{ getRegisteredSources() /** * Get registered pingback source URIs. * * @return array List of registered source URIs. * @access public */ function getRegisteredSources() { return $this->_registeredSources(); } // }}} // {{{ autodiscover() /** * Implemented of Pingback autodiscovery algorithm. * * This method send a request to given URI, then see if the header contain * Pingback header, if not attempt to find a Pingback link on the body contents. * This algorithm is one of requirement of the Pingback clients specification. * * @param string $uri URI to discover. * * @return string|PEAR_Error A Pingback URI on success or PEAR_Error on failure. * @access public * @see sendHTTPRequest() * @see expandEntities() */ function autodiscover($uri) { $res = $this->sendHTTPRequest($uri); if (PEAR::isError($res)) { return $res; } $pingbackURI = ''; if (isset($res['header']['x-pingback']) && !empty($res['header']['x-pingback'])) { $pingbackURI = $res['header']['x-pingback']; } else if (preg_match('@\<link rel="pingback" href="([^"]+)" ?\/?\>@i', $res['body'], $matches)) { $pingbackURI = $matches[1]; } if (!empty($pingbackURI)) { $pingbackURI = $this->expandEntities($pingbackURI); } return $pingbackURI; } // }}} // {{{ send() /** * Send a pingback. * * @param array $data (optional) An array of pingback data. * * @access public * @see autodiscover() */ function send($data = null) { if ($data !== null) { $res = $this->setFromArray($data); if (PEAR::isError($res)) { return $res; } } // Find the whether if source and target is equal or not. if (strstr($this->_data['sourceURI'], $this->_data['targetURI'])) { return PEAR::raiseError('Target URI is equal with source URI'); } // pingback URI set if (empty($this->_data['pingbackURI'])) { $res = Services_Pingback::autodiscover($this->_data['targetURI']); if (PEAR::isError($res)) { return $res; } else if (empty($res)) { return PEAR::raiseError('Target URI is not a pingback-enabled resource'); } $this->_data['pingbackURI'] = $res; } // Prepare an XML-RPC Message. $eArgs = array( XML_RPC_encode($this->_data['sourceURI']), XML_RPC_encode($this->_data['targetURI']) ); $msg = new XML_RPC_Message('pingback.ping', $eArgs); // Prepare full path of URI to conforms XML_RPC_Client parameter. $url = new Net_URL($this->_data['pingbackURI']); $path = $url->path; $querystring = $url->getQueryString(); if (!empty($querystring)) { $path .= '?' . $querystring; } $cli = new XML_RPC_Client($path, $url->protocol . '://' . $url->host, $url->port); $cli->setDebug((int) $this->_options['debug']); $res = $cli->send($msg); $val = $res->value(); if (!is_object($val) || !is_a($val, 'XML_RPC_value')) { return PEAR::raiseError('Response Error: ' . $res->faultString()); } return XML_RPC_decode($val); } // }}} // {{{ receive() /** * Receive pingback call. * * @access public */ function receive() { $GLOBALS['_Services_Pingback_server'] =& $this; new XML_RPC_Server($this->_dispatches, 1, $this->_options['debug']); } // }}} // {{{ errorMessage() /** * Get error message. * * @param int $value Error code. * * @return string Error message. * @access public */ function errorMessage($value) { $errorMessages = array( SERVICES_PINGBACK_ERROR => 'Unknown error', SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS => 'Source URI doesn\'t exist', SERVICES_PINGBACK_ERROR_NO_TARGET_LINK => 'Source URI doesn\'t contain a link to the target URI', SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS => 'Target URI doesn\'t exist', SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE => 'Target URI is not a pingback-enabled resource', SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED => 'Pingback has already been registered', SERVICES_PINGBACK_ERROR_ACCESS_DENIED => 'Access denied', SERVICES_PINGBACK_ERROR_UPSTREAM_ERROR => 'Upstream server error' ); return isset($errorMessages[$value]) ? $errorMessages[$value] : $errorMessages[SERVICES_PINGBACK_ERROR]; } // }}} // {{{ sendHTTPRequest() /** * Send a HTTP 1/1 request. * * @param string $uri URI. * * @return array|PEAR_Error An associative array of result containing keys * 'code', 'header' and 'body' on success or * PEAR_Error on failure. * @access public */ function sendHTTPRequest($uri) { $params = array( 'timeout' => $this->_options['timeout'], 'allowRedirects' => $this->_options['allowRedirects'], 'maxRedirects' => $this->_options['maxRedirects'] ); $req = new HTTP_Request($uri, $params); $req->sendRequest(); if (PEAR::isError($req)) { return $req; } if ($req->getResponseCode() != 200) { return PEAR::raiseError('Host returned error: ' . $req->getResponseCode()); } return array( 'code' => $req->getResponseCode(), 'header' => $req->getResponseHeader(), 'body' => $req->getResponseBody() ); } // }}} // {{{ expandEntities() /** * Expand the entities. * * There are four allowed entities (& for &, < for <, > for > and * " for "). * * @param string $str A string to expand, normally is a uri. * * @return string A result. * @access public */ function expandEntities($str) { return strtr($str, $this->_transEntities); } // }}} // {{{ sendPingbackHeader() /** * Send a Pingback header to tell this is a pingback-enable resource. * * @param string $pingbackURI (optional) Pingback URI, if not given URI is * the current URI. * * @return bool|PEAR_Error TRUE on success or PEAR_Error on failure. * @access public * @static */ function sendPingbackHeader($pingbackURI = null) { if (headers_sent()) { return PEAR::raiseError('Header already sent, cannot sent Pingback header'); } if ($pingbackURI === null) { $url = new Net_URL($url); $pingbackURI = $url->getURL(); } header('X-Pingback: ' . $pingbackURI); return true; } // }}} // {{{ isURIExist() /** * Find out the whether the URI is exist, done with fopen(). * * @param string $uri URI to verify. * * @return bool TRUE if exist, otherwise FALSE. * @access public * @static */ function isURIExist($uri) { if (is_resource(@fopen($uri, 'r'))) { return true; } return false; } // }}} // {{{ isSourceLinked() /** * Find the a link to URI on the contents body of given URI. * * @param string $uri URI to scans. * @param string $linkURI URI to be found on the link. * * @return bool TRUE if a link found, otherwise FALSE. * @access public * @see sendHTTPRequest() */ function isSourceLinked() { $res = $this->sendHTTPRequest($this->_data['sourceURI']); if (PEAR::isError($res)) { return $res; } if (preg_match('@\<a.+href="'. preg_quote($this->_data['targetURI']) . '".*\>.+\<\/a\>@', $res['body'])) { return true; } return false; } // }}} // {{{ isPingbackRegistered() /** * Find out the whether if pingback from URI has already registered. * * @param string $sourceURI Source URI. * * @return bool TRUE if has already registered, otherwise FALSE. * @access public */ function isPingbackRegistered() { if (in_array($this->_data['sourceURI'], $this->_registeredSources)) { return true; } return false; } // }}} // {{{ isPingbackEnabled() /** * Find the whether a resouce is a pingback-enabled or not. * * @param string $uri URI to scans. * * @return bool|PEAR_Error TRUE if it's pingback-enabled, otherwise FALSE or * PEAR_Error on failure. * @access public */ function isTargetPingbackEnabled() { $res = $this->autodiscover($this->_data['targetURI']); if (PEAR::isError($res)) { return $res; } if (!empty($res)) { return true; } return false; } // }}} // {{{ fetchSourceContext() /** * Fetch page context for current call. * * @return array|PEAR_Error An array of context on success or PEAR_Error on failure. * @access public */ function fetchSourceContext() { $res = $this->sendHTTPRequest($this->_data['sourceURI']); if (PEAR::isError($res)) { return $res; } $this->_sourceContext= array( 'title' => 'Untitled', 'content' => '', 'url' => $this->_data['sourceURI'] ); $str = $res['body']; // Extract the page title first. if (preg_match('@<title>([^<]*?)</title>@is', $str, $matches)) { $this->_sourceContext['title'] = $matches[1]; } // Extract the page body. if (preg_match('@<body[^>]*>(.*)<\/body>@is', $str, $matches)) { $str = $matches[1]; } // Remove unecessary elements. $removeElems = array( 'style', 'script', 'meta', ); foreach ($removeElems as $elem) { $str = preg_replace('@<' . $elem . '[^>]*\/>@is', '', $str); $str = preg_replace('@<' . $elem . '[^>]*>.*<\/' . $elem . '>@is', '', $str); } // Strips all tags except <a>. $str = strip_tags($str, '<a>'); // Strips all links except target URI. if (preg_match_all('@<a.+href="(.+)".*>.+?<\/a>@i', $str, $matches, PREG_SET_ORDER)) { foreach ($matches as $res) { if (!strstr($res[1], $this->_data['targetURI'])) { $str = str_replace($res[0], $res[1], $str); } } } // Extract the context, from exact target link position. if (preg_match('@<a.+href="'. preg_quote($this->_data['targetURI']) . '".*>.+<\/a>@i', $str, $matches)) { $linkText = $matches[0]; $linkPos = strpos($str, $linkText); $linkLen = strlen($linkText); $sideSize = (int)(($this->_options['fetchsize'] - $linkLen) / 2); if ($sideSize > $linkPos) { $leftText = ''; $leftStart = 0; } else { $leftText = '... '; $leftStart = $linkPos - ($sideSize - 4); } $leftText .= substr($str, $leftStart, $linkPos - $leftStart); $rightText = substr($str, $linkPos + $linkLen); if (strlen($rightText) > $sideSize) { $rightText = substr($rightText, 0, $sideSize - 4) . ' ...'; } $this->_sourceContext['content'] = trim($leftText . $linkText . $rightText); } return true; } // }}} // {{{ getSourceContext() /** * Get fetched source context. * * @return string Fetched source context. * @access public */ function getSourceContext() { return $this->_sourceContext; } // }}} // {{{ ping() /** * A callback of Pingback XML-RPC pingback.ping method. * * @param object $msg An instance of XML_RPC_Message object. * * @return XML_RPC_Response A result of current call. * @access public * @static * @see isURIExist() * @see isSourceLinked() * @see isTargetPingbackEnabled() * @see isPingbackRegistered() * @see fetchSourceContext() * @see getSourceContext() */ function ping($msg) { $Services_Pingback_server =& $GLOBALS['_Services_Pingback_server']; $sourceURI = $msg->params[0]->getval(); $targetURI = $msg->params[1]->getval(); $Services_Pingback_server->set('sourceURI', $sourceURI); $Services_Pingback_server->set('targetURI', $targetURI); if (!Services_Pingback::isURIExist($sourceURI)) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_SOURCE_NOT_EXISTS ) ); } if (!$Services_Pingback_server->isSourceLinked()) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_NO_TARGET_LINK, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_NO_TARGET_LINK ) ); } if (!Services_Pingback::isURIExist($targetURI)) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_TARGET_NOT_EXISTS ) ); } if (!$Services_Pingback_server->isTargetPingbackEnabled()) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_TARGET_NOT_RESOURCE ) ); } if ($Services_Pingback_server->isPingbackRegistered()) { return new XML_RPC_Response(0, SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED, Services_Pingback::errorMessage( SERVICES_PINGBACK_ERROR_ALREADY_REGISTERED ) ); } $Services_Pingback_server->fetchSourceContext(); return new XML_RPC_Response(new XML_RPC_Value('Pingback from ' . $sourceURI . ' success')); } // }}} } ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/receive.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/receive.php +++ pear/Services_Pingback/examples/receive.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Services_Pingback receive example. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } // Load Services_Pingback. require_once 'Services/Pingback.php'; // Receive pingback call. $pingback = new Services_Pingback; // Turn on debug mode. # $pingback->setOptions(array('debug' => true)); $pingback->receive(); print "\n" . '------------------------ Context -------------------------' . "\n"; print '<!--' . "\n"; $context = $pingback->getSourceContext(); foreach ($context as $key => $value) { print "$key = $value\n"; } print '-->' . "\n"; print '------------------------ Context -------------------------' . "\n"; /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/send.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/send.php +++ pear/Services_Pingback/examples/send.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Services_Pingback send example. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } // Load Services_Pingback require_once 'Services/Pingback.php'; // Setting up URIs $selfURI = 'http://' .$_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; $sourceURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/source.php'; $targetURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/target.php'; // let's assume that we don't know this pingback URI, to test // Services_Pingback::autoDiscover() method. $pingbackURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/receive.php'; $options = array( 'debug' => true ); $data = array( 'sourceURI' => $sourceURI, 'targetURI' => $targetURI ); $pingback = new Services_Pingback($data, $options); print '<h2>Services_Pingback Example</h2>' . "\n" . 'Sources: ' . '<a href="' . $selfURI . '?source" target="_blank">send.php</a> | ' . '<a href="' . $pingbackURI . '?source" target="_blank">receive.php</a> | ' . '<a href="' . $sourceURI . '?source" target="_blank">source.php</a> | ' . '<a href="' . $targetURI . '?source" target="_blank">target.php</a>' . '<hr />' . "\n" . '<strong>source URI</strong>: <a href="' . $sourceURI . '" target="_blank">' . $sourceURI . "</a><br />\n" . '<strong>target URI</strong>: <a href="' . $targetURI . '" target="_blank">' . $targetURI . "</a><br />\n"; print '<strong>------------------------- Sending Pingback --------------------------</strong>' . "<br />\n"; $res = $pingback->send(); print '<strong>------------------------- Received Response -------------------------</strong>' . "<br />\n"; if (PEAR::isError($res)) { $response = $res->getMessage(); } else { $response = $res; } print '<strong>Response</strong>: ' . $response; /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/source.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/source.php +++ pear/Services_Pingback/examples/source.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Source blog. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } $targetURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/target.php'; //$targetURI = 'http://localhost/tests/blog/wordpress/?p=1'; ?> <!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Service_Pingback Test Source</title> </head> <body> <p>Try to send pingback call to <a href="<?php print $targetURI ?>"><?php print $targetURI ?></a> and see what happen.</p> </body> </html> <?php /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/examples/target.php?r=1.1&p=1 Index: pear/Services_Pingback/examples/target.php +++ pear/Services_Pingback/examples/target.php <?php /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker */ /** * Target blog. */ if (isset($_REQUEST['source'])) { highlight_file(__FILE__); die; } $pingbackURI = 'http://' .$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . '/receive.php'; ?> <!DOCTYPE html public "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US"> <head> <link rel="pingback" href="<?php print $pingbackURI ?>" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Services_Pingback Test Target</title> </head> <body> <p>What's up there, is it anyone link to me?</p> </body> </html> <?php /* * Local variables: * mode: php * tab-width: 4 * c-basic-offset: 4 * c-hanging-comment-ender-p: nil * End: */ ?> http://cvs.php.net/co.php/pear/Services_Pingback/generate_package_xml.php?r=1.1&p=1 Index: pear/Services_Pingback/generate_package_xml.php +++ pear/Services_Pingback/generate_package_xml.php <?php require_once('PEAR/PackageFileManager.php'); $pkg = new PEAR_PackageFileManager; $packagedir = dirname(__FILE__); $self = basename(__FILE__); $desc = "A package implemented of Pingback in PHP, able to sending and receiving a pingback."; $options = array( 'doctype' => 'D:\Net\www\htdocs\PEAR\PEAR\data\PEAR\package.dtd', 'package' => 'Services_Pingback', 'license' => 'BSD License', 'baseinstalldir' => '', 'version' => '0.2.0dev2', 'packagedirectory' => $packagedir, 'pathtopackagefile' => $packagedir, 'state' => 'devel', 'filelistgenerator' => 'file', 'notes' => 'Initial release of Services_Pingback', 'summary' => 'A Pingback User-Agent class.', 'description' => $desc, 'ignore' => array( 'package.xml', '*.tgz', $self ) ); $e = $pkg->setOptions($options); if (PEAR::isError($e)) { echo $e->getMessage(); die; } // hack until they get their shit in line with docroot role $pkg->addRole('tpl', 'php'); $pkg->addRole('png', 'php'); $pkg->addRole('gif', 'php'); $pkg->addRole('jpg', 'php'); $pkg->addRole('css', 'php'); $pkg->addRole('js', 'php'); $pkg->addRole('ini', 'php'); $pkg->addRole('inc', 'php'); $pkg->addRole('afm', 'php'); $pkg->addRole('pkg', 'doc'); $pkg->addRole('cls', 'doc'); $pkg->addRole('proc', 'doc'); $pkg->addRole('txt', 'doc'); $pkg->addRole('sh', 'script'); $pkg->addMaintainer('firman', 'lead', 'Firman Wandayandi', 'firman@php.net'); $pkg->addDependency('XML_RPC', '1.0.3RC1', 'ge', 'pkg'); $pkg->addDependency('Net_URL', '1.0.14', 'ge', 'pkg'); $pkg->addDependency('HTTP_Request', '1.2.4', 'ge', 'pkg'); $pkg->addDependency('PHP', '4.3.0', 'ge', 'php'); $pkg->addReplacement('Services/Pingback.php', 'package-info', '@package_version@', 'version'); $e = $pkg->writePackageFile(); if (PEAR::isError($e)) { echo $e->getMessage(); } ?> http://cvs.php.net/co.php/pear/Services_Pingback/package.xml?r=1.1&p=1 Index: pear/Services_Pingback/package.xml +++ pear/Services_Pingback/package.xml <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0"> <package version="1.0" packagerversion="1.4.0a11"> <name>Services_Pingback</name> <summary>A Pingback User-Agent class.</summary> <description>A package implemented of Pingback in PHP, able to sending and receiving a pingback. </description> <maintainers> <maintainer> <user>firman</user> <name>Firman Wandayandi</name> <email>firman@php.net</email> <role>lead</role> </maintainer> </maintainers> <release> <version>0.2.0dev2</version> <date>2005-06-04</date> <license>BSD License</license> <state>devel</state> <notes>Initial release of Services_Pingback </notes> <deps> <dep type="pkg" rel="ge" version="1.0.3RC1" optional="no">XML_RPC</dep> <dep type="pkg" rel="ge" version="1.0.14" optional="no">Net_URL</dep> <dep type="pkg" rel="ge" version="1.2.4" optional="no">HTTP_Request</dep> <dep type="php" rel="ge" version="4.3.0" optional="no"/> </deps> <provides type="class" name="Services_Pingback" /> <provides type="function" name="Services_Pingback::setOptions" /> <provides type="function" name="Services_Pingback::getOptions" /> <provides type="function" name="Services_Pingback::set" /> <provides type="function" name="Services_Pingback::get" /> <provides type="function" name="Services_Pingback::setFromArray" /> <provides type="function" name="Services_Pingback::setRegisteredSources" /> <provides type="function" name="Services_Pingback::addRegisteredSource" /> <provides type="function" name="Services_Pingback::getRegisteredSources" /> <provides type="function" name="Services_Pingback::autodiscover" /> <provides type="function" name="Services_Pingback::send" /> <provides type="function" name="Services_Pingback::receive" /> <provides type="function" name="Services_Pingback::errorMessage" /> <provides type="function" name="Services_Pingback::sendHTTPRequest" /> <provides type="function" name="Services_Pingback::expandEntities" /> <provides type="function" name="Services_Pingback::sendPingbackHeader" /> <provides type="function" name="Services_Pingback::isURIExist" /> <provides type="function" name="Services_Pingback::isSourceLinked" /> <provides type="function" name="Services_Pingback::isPingbackRegistered" /> <provides type="function" name="Services_Pingback::isTargetPingbackEnabled" /> <provides type="function" name="Services_Pingback::fetchSourceContext" /> <provides type="function" name="Services_Pingback::getSourceContext" /> <provides type="function" name="Services_Pingback::ping" /> <filelist> <file role="doc" baseinstalldir="" name="examples/receive.php"/> <file role="doc" baseinstalldir="" name="examples/send.php"/> <file role="doc" baseinstalldir="" name="examples/source.php"/> <file role="doc" baseinstalldir="" name="examples/target.php"/> <file role="php" baseinstalldir="" name="Services/Pingback.php"> <replace type="package-info" from="@package_version@" to="version"/> </file> </filelist> </release> <changelog> <release> <version>0.2.0dev2</version> <date>2005-06-04</date> <license>BSD License</license> <state>devel</state> <notes>Initial release of Services_Pingback </notes> </release> </changelog> </package> http://cvs.php.net/co.php/pear/Services_Pingback/package2.xml?r=1.1&p=1 Index: pear/Services_Pingback/package2.xml +++ pear/Services_Pingback/package2.xml <?xml version="1.0"?> <package packagerversion="1.4.0a11" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>Services_Pingback</name> <channel>pear.php.net</channel> <summary>A Pingback User-Agent class.</summary> <description>A package implemented of Pingback in PHP, able to sending and receiving a pingback. </description> <lead> <name>Firman Wandayandi</name> <user>firman</user> <email>firman@php.net</email> <active>yes</active> </lead> <date>2005-06-04</date> <time>21:32:45</time> <version> <release>0.2.0dev2</release> <api>0.2.0dev2</api> </version> <stability> <release>devel</release> <api>devel</api> </stability> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license> <notes>Initial release of Services_Pingback </notes> <contents> <dir name="/"> <dir name="examples"> <file baseinstalldir="" name="receive.php" role="doc" /> <file baseinstalldir="" name="send.php" role="doc" /> <file baseinstalldir="" name="source.php" role="doc" /> <file baseinstalldir="" name="target.php" role="doc" /> </dir> <!-- /examples --> <dir name="Services"> <file baseinstalldir="" name="Pingback.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> </dir> <!-- /Services --> </dir> <!-- / --> </contents> <dependencies> <required> <php> <min>4.3.0</min> </php> <pearinstaller> <min>1.4.0a1</min> </pearinstaller> <package> <name>XML_RPC</name> <channel>pear.php.net</channel> <min>1.0.3RC1</min> </package> <package> <name>Net_URL</name> <channel>pear.php.net</channel> <min>1.0.14</min> </package> <package> <name>HTTP_Request</name> <channel>pear.php.net</channel> <min>1.2.4</min> </package> </required> </dependencies> <phprelease /> <changelog> <release> <version> <release>0.2.0dev2</release> <api>0.2.0dev2</api> </version> <stability> <release>devel</release> <api>devel</api> </stability> <date>2005-06-04</date> <license uri="http://www.opensource.org/licenses/bsd-license.php">BSD License</license> <notes>Initial release of Services_Pingback </notes> </release> </changelog> </package>