add xmlrpc library & server
This commit is contained in:
parent
581e6bb537
commit
956c762979
15 changed files with 5579 additions and 29 deletions
4
NEWS
4
NEWS
|
@ -1,3 +1,7 @@
|
|||
v1.1.7 (Jun XX, 2006)
|
||||
|
||||
* XML-RPC API (using XML-RPC for PHP, from http://phpxmlrpc.sourceforge.net/)
|
||||
|
||||
v1.1.6 (May 02, 2006)
|
||||
|
||||
* Bugfixes
|
||||
|
|
29
backend.php
29
backend.php
|
@ -1662,34 +1662,9 @@
|
|||
$feed_link = db_escape_string(trim($_GET["link"]));
|
||||
$cat_id = db_escape_string($_GET["cid"]);
|
||||
|
||||
if ($cat_id == "0" || !$cat_id) {
|
||||
$cat_qpart = "NULL";
|
||||
if (subscribe_to_feed($link, $feed_link, $cat_id)) {
|
||||
print "Added feed.";
|
||||
} else {
|
||||
$cat_qpart = "'$cat_id'";
|
||||
}
|
||||
|
||||
$result = db_query($link,
|
||||
"SELECT id FROM ttrss_feeds
|
||||
WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]);
|
||||
|
||||
if (db_num_rows($result) == 0) {
|
||||
|
||||
$result = db_query($link,
|
||||
"INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
|
||||
VALUES ('".$_SESSION["uid"]."', '$feed_link',
|
||||
'[Unknown]', $cat_qpart)");
|
||||
|
||||
$result = db_query($link,
|
||||
"SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$feed_id = db_fetch_result($result, 0, "id");
|
||||
|
||||
if ($feed_id) {
|
||||
update_rss_feed($link, $feed_link, $feed_id, true);
|
||||
}
|
||||
} else {
|
||||
|
||||
print "<div class=\"warning\">
|
||||
Feed <b>$feed_link</b> already exists in the database.
|
||||
</div>";
|
||||
|
|
|
@ -801,7 +801,19 @@
|
|||
db_query($link, "COMMIT");
|
||||
|
||||
}
|
||||
|
||||
|
||||
function lookup_user_id($link, $user) {
|
||||
|
||||
$result = db_query($link, "SELECT id FROM ttrss_users WHERE
|
||||
login = '$login'");
|
||||
|
||||
if (db_num_rows($result) == 1) {
|
||||
return db_fetch_result($result, 0, "id");
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function authenticate_user($link, $login, $password) {
|
||||
|
||||
$pwd_hash = 'SHA1:' . sha1($password);
|
||||
|
@ -1511,4 +1523,40 @@
|
|||
|
||||
print "<error error-code=\"$code\" error-msg=\"$error_msg\"/>";
|
||||
}
|
||||
|
||||
function subscribe_to_feed($link, $feed_link, $cat_id = 0) {
|
||||
|
||||
if ($cat_id == "0" || !$cat_id) {
|
||||
$cat_qpart = "NULL";
|
||||
} else {
|
||||
$cat_qpart = "'$cat_id'";
|
||||
}
|
||||
|
||||
$result = db_query($link,
|
||||
"SELECT id FROM ttrss_feeds
|
||||
WHERE feed_url = '$feed_link' AND owner_uid = ".$_SESSION["uid"]);
|
||||
|
||||
if (db_num_rows($result) == 0) {
|
||||
|
||||
$result = db_query($link,
|
||||
"INSERT INTO ttrss_feeds (owner_uid,feed_url,title,cat_id)
|
||||
VALUES ('".$_SESSION["uid"]."', '$feed_link',
|
||||
'[Unknown]', $cat_qpart)");
|
||||
|
||||
$result = db_query($link,
|
||||
"SELECT id FROM ttrss_feeds WHERE feed_url = '$feed_link'
|
||||
AND owner_uid = " . $_SESSION["uid"]);
|
||||
|
||||
$feed_id = db_fetch_result($result, 0, "id");
|
||||
|
||||
if ($feed_id) {
|
||||
update_rss_feed($link, $feed_link, $feed_id, true);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<?
|
||||
define(VERSION, "1.1.6");
|
||||
define(VERSION, "1.1.6.99");
|
||||
?>
|
||||
|
|
62
xml-rpc.php
Normal file
62
xml-rpc.php
Normal file
|
@ -0,0 +1,62 @@
|
|||
<?
|
||||
require "xmlrpc/lib/xmlrpc.inc";
|
||||
require "xmlrpc/lib/xmlrpcs.inc";
|
||||
|
||||
require_once "sanity_check.php";
|
||||
require_once "config.php";
|
||||
|
||||
require_once "db.php";
|
||||
require_once "db-prefs.php";
|
||||
require_once "functions.php";
|
||||
|
||||
$link = db_connect(DB_HOST, DB_USER, DB_PASS, DB_NAME);
|
||||
|
||||
if (!$link) {
|
||||
if (DB_TYPE == "mysql") {
|
||||
print mysql_error();
|
||||
}
|
||||
// PG seems to display its own errors just fine by default.
|
||||
return;
|
||||
}
|
||||
|
||||
if (DB_TYPE == "pgsql") {
|
||||
pg_query("set client_encoding = 'utf-8'");
|
||||
}
|
||||
|
||||
function subscribeToFeed($msg) {
|
||||
# $value = new xmlrpcval("OK");
|
||||
|
||||
global $link;
|
||||
|
||||
$login_o = $msg->getParam(0);
|
||||
$pass_o = $msg->getParam(1);
|
||||
$feed_url_o = $msg->getParam(2);
|
||||
|
||||
$login = $login_o->scalarval();
|
||||
$pass = $pass_o->scalarval();
|
||||
$feed_url = $feed_url_o->scalarval();
|
||||
|
||||
$user_id = authenticate_user($link, $login, $pass);
|
||||
|
||||
if (authenticate_user($link, $login, $pass)) {
|
||||
if (subscribe_to_feed($link, $feed_url)) {
|
||||
$reply_msg = "Subscribed successfully.";
|
||||
} else {
|
||||
$reply_msg = "Feed already exists in the database.";
|
||||
}
|
||||
} else {
|
||||
$reply_msg = "Login failed.";
|
||||
}
|
||||
|
||||
return new xmlrpcresp(new xmlrpcval($reply_msg));
|
||||
}
|
||||
|
||||
$subscribeToFeed_sig = array(array($xmlrpcString,
|
||||
$xmlrpcString, $xmlrpcString, $xmlrpcString));
|
||||
|
||||
$s = new xmlrpc_server(
|
||||
array(
|
||||
"rss.subscribeToFeed" => array("function" => "subscribeToFeed",
|
||||
"signature" => $subscribeToFeed_sig))
|
||||
);
|
||||
?>
|
188
xmlrpc/NEWS
Normal file
188
xmlrpc/NEWS
Normal file
|
@ -0,0 +1,188 @@
|
|||
XML-RPC for PHP version 2.0 - 2006/04/22
|
||||
|
||||
I'm pleased to announce XML-RPC for PHP version 2.0, final.
|
||||
|
||||
With respect to the last release candidate, this release corrects a few small
|
||||
bugs and adds a couple of new features: more authentication options (digest and
|
||||
ntlm for servers, ntlm for proxies, and some https custom certificates stuff);
|
||||
all the examples have been reviewed and some demo files added,
|
||||
including a ready-made xmlrpc proxy (useful e.g. for ajax calls, when the xmlrpc
|
||||
client is a browser); the server logs more warning messages for incorrect situations;
|
||||
both client and server are more tolerant of commonly-found mistakes.
|
||||
The debugger has been upgraded to reflect the new client capabilities.
|
||||
|
||||
In greater detail:
|
||||
|
||||
* fixed bug: method xmlrpcval::structmemexists($value) would not work
|
||||
* fixed bug: wrap_xmlrpc_method would fail if invoked with a client object that
|
||||
has return_type=phpvals
|
||||
* fixed bug: in case of call to client::multicall without fallback and server error
|
||||
* fixed bug: recursive serialization of xmlrpcvals loosing specified UTF8 charset
|
||||
* fixed bug: serializing to ISO-8859-1 with php 5 would raise an error if non-ascii
|
||||
chars where found when decoding
|
||||
* new: client can use NTLM and Digest authentication methods for https and http 1.1
|
||||
connections; authentication to proxy can be set to NTLM, too
|
||||
* new: server tolerates user functions returning a single xmlrpcval object instead
|
||||
of an xmlrpcresp
|
||||
* new: server does more checks for presence and correct return type of user
|
||||
coded method handling functions, and logs inconsistencies to php error log
|
||||
* new: client method SetCaCertificate($cert, $is_dir) to validate server against
|
||||
* new: both server and client tolerate receiving 'true' and 'false' for bool values
|
||||
(which btw are not valid according to the xmlrpc spec)
|
||||
|
||||
|
||||
XML-RPC for PHP version 2.0RC3 - 2006/01/22
|
||||
|
||||
This release corrects a few bugs and adds some interesting new features.
|
||||
It has been tested with PHP up to 4.4.2 and 5.1.2.
|
||||
|
||||
* fixed bug: server not recognizing clients that declare support for http compression
|
||||
* fixed bug: serialization of new xmlrpcval (8, 'string') when internal encoding
|
||||
set to UTF-8
|
||||
* fixed bug: serialization of new xmlrpcval ('hello', 'int') would produce
|
||||
invalid xml-rpc
|
||||
* new: let the server accept 'class::method' syntax in the dispatch map
|
||||
* new: php_xmlrpc_decode() can decode xmlrpcmessage objects
|
||||
* new: both client and server can specify a charset to be used for serializing
|
||||
values instead of the default 'US-ASCII+xml-entities-for-other-characters'.
|
||||
Values allowed: ISO-8859-1 and UTF-8
|
||||
* new: the server object can register 'plain' php functions instead of functions
|
||||
that accept a single parameter of type xmlrpcmsg. Faster, uses less memory
|
||||
(but comes with minor drawbacks as well, read the manual for more details)
|
||||
* new: client::setDebug(2) can be used to have the request payload printed to
|
||||
screen before being sent
|
||||
* new: server::service($data) lets user parse data other than POST body, for
|
||||
easier testing / subclassing
|
||||
* changed: framework-generated debug messages are sent back by the server base64
|
||||
encoded, to avoid any charset/xml compatibility problem
|
||||
* other minor fixes
|
||||
|
||||
The usual refactoring of a lot of (private) methods has taken place, with new
|
||||
parameters added to some functions.
|
||||
Javadoc documentation has been improved a lot.
|
||||
The HTML documentation has been shuffled around a bit, hoping to give it a more
|
||||
logical organization.
|
||||
|
||||
The experimental support for the JSON protocol has been removed, and will be
|
||||
packaged as a separate download with some extra very interesting stuff (human
|
||||
readable auto-generated documentation, anyone?).
|
||||
|
||||
|
||||
XML-RPC for PHP version 2.0RC2 - 2005/11/22
|
||||
|
||||
This release corrects a few bugs and adds basically one new method for better
|
||||
HTTPS support:
|
||||
|
||||
* fixed two bugs that prevented xmlrpc calls to take place over https
|
||||
* fixed two bugs that prevented proper recognition of xml character set
|
||||
when it was declared inside the xml prologue
|
||||
* added xmlrpc_client::setKey($key, $keypass) method, to allow using client
|
||||
side certificates for https connections
|
||||
* fixed bug that prevented proper serialization of string xmlrpcvals when
|
||||
$xmlrpc_internalencoding was set to UTF-8
|
||||
* fixed bug in xmlrpc_server::echoInput() (and marked method as deprecated)
|
||||
* correctly set cookies/http headers into xmlrpcresp objects even when the
|
||||
sned() method call fails for some reason
|
||||
* added a benchmark file in the testsuite directory
|
||||
|
||||
A couple of (private/protected) methods have been refactored, as well as a
|
||||
couple of extra parameters added to some (private) functions - this has no
|
||||
impact on the public API and should be of interest primarily to people extending
|
||||
/ subclassing the lib.
|
||||
|
||||
There is also new, PARTIAL support for the JSON-RPC protocol, implemented in
|
||||
two files in the extras dir (more info about json-rpc at http://json-rpc.org)
|
||||
|
||||
|
||||
XML-RPC for PHP version 2.0RC1 - 2005/10/03
|
||||
|
||||
I'm pleased to announce XML-RPC for PHP version 2.0, release candidate 1.
|
||||
|
||||
This release introduces so many new features it is almost impossible to list them
|
||||
here, making the library finally on pair with, if not more advanced than, any other
|
||||
similar offer (e.g. the PEAR XMLRPC package or the Incutio IXR library).
|
||||
No, really, trust me.
|
||||
|
||||
The minimum supported PHP version is now 4.2 - natively - or 4.0.4pl1 - by usage of
|
||||
a couple of compatibility classes (code taken from PEAR php_compat package).
|
||||
|
||||
The placement of files and directories in the distribution has been deeply modified,
|
||||
in the hope of making it more clear, now that the file count has increased.
|
||||
I hope you find it easy.
|
||||
|
||||
Support for "advanced" HTTP features such as cookies, proxies and keep-alives has
|
||||
been added at last.
|
||||
|
||||
It is now much easier to convert between xmlrpcval objects and php values, and
|
||||
in fact php_xmlrpc_encode and php_xmlrpc_decode are now the recommended methods
|
||||
for all cases, except when encoding base64 data.
|
||||
|
||||
Two new (experimental) functions have been added, allowing automagic conversion
|
||||
of a php function into an xmlrpc method to be exposed and vice-versa.
|
||||
|
||||
PHP objects can be now automatically serialized as xmlrpc struct values and
|
||||
correctly deserialized on the other end of the transmission, provided that the
|
||||
same class definition is present on both sides and no object members are of
|
||||
type resource.
|
||||
|
||||
A lot of the existing class methods have been overloaded with extra parameters
|
||||
or new functionality, and a few added ex-novo, making usage easier than ever.
|
||||
|
||||
A complete debugger solution is included in the distribution. It needs a web server
|
||||
to run (a freely available version of the same debugger is accessible online, it
|
||||
can be found at http://phpxmlrpc.sourceforge.net).
|
||||
|
||||
For a more detailed list of changes, please read carefully chapter 2 of the
|
||||
included documentation, or, even better, take a look at the source code, which
|
||||
is commented in javadoc style quite a bit.
|
||||
|
||||
|
||||
XML-RPC for PHP version 1.2 - 2005/08/14
|
||||
|
||||
This removes all use of eval(), which is a potential security problem.
|
||||
All users are encouraged to upgrade as soon as possible.
|
||||
As of this release we are no longer php3-compatible.
|
||||
|
||||
|
||||
XML-RPC for PHP version 1.1.1 - 2005/06/30
|
||||
|
||||
This is a security vulnerability fix release.
|
||||
All users are invited to upgrade as soon as possible.
|
||||
|
||||
|
||||
XML-RPC for PHP version 1.1 - 2005/05/03
|
||||
|
||||
I'm pleased to announce XML-RPC for PHP version 1.1
|
||||
It's taken two years to get to the this point, but here we are, finally.
|
||||
|
||||
This is a bugfix and maintenance release. No major new features have been added.
|
||||
All known bugs have been ironed out, unless fixing would have meant breaking
|
||||
the API.
|
||||
The code has been tested with PHP 3, 4 and 5, even tough PHP 4 is the main
|
||||
development platform (and some warnings will be emitted when runnning PHP5).
|
||||
|
||||
Notheworthy changes include:
|
||||
|
||||
* do not clash any more with the EPI xmlrpc extension bundled with PHP 4 and 5
|
||||
* fixed the unicode/charset problems that have been plaguing the lib for years
|
||||
* proper parsing of int and float values prepended with zeroes or the '+' char
|
||||
* accept float values in exponential notation
|
||||
* configurable http user-agent string
|
||||
* use the same timeout on client socket reads as used for connecting
|
||||
* more explicative error messages in xmlrpcresponse in many cases
|
||||
* much more tolerant parsing of malformed http responses from xmlrpc servers
|
||||
* fixed memleak that prevented the client to be used in never-ending scripts
|
||||
* parse bigger xmlrpc messages without crashing (1MB in size or more)
|
||||
* be tolerant to xmlrpc responses generated on public servers that add
|
||||
javascript advertising at the end of hosted content
|
||||
* the lib generates quite a few less PHP warnings during standard operation
|
||||
|
||||
This is the last release that will support PHP 3.
|
||||
The next release will include better support for PHP 5 and (possibly) a slew of
|
||||
new features.
|
||||
|
||||
The changelog is available at:
|
||||
http://cvs.sourceforge.net/viewcvs.py/phpxmlrpc/xmlrpc/ChangeLog?view=markup
|
||||
|
||||
Please report bugs to the XML-RPC PHP mailing list or to the sourceforge project
|
||||
pages at http://sourceforge.net/projects/phpxmlrpc/
|
7
xmlrpc/README
Normal file
7
xmlrpc/README
Normal file
|
@ -0,0 +1,7 @@
|
|||
HTML documentation can be found in the doc/ directory.
|
||||
|
||||
Recent changes in the ChangeLog
|
||||
|
||||
Use of this software is subject to the terms in doc/index.html
|
||||
|
||||
The passphrase for the rsakey.pem certificate is 'test'.
|
42
xmlrpc/extras/test.py
Normal file
42
xmlrpc/extras/test.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from xmlrpclib import *
|
||||
import sys
|
||||
|
||||
server = Server("http://madoka.spb.ru/~fox/testbox/tt-rss/xml-rpc.php")
|
||||
|
||||
try:
|
||||
# print server.rss.getAllFeeds("fox", "sotona");
|
||||
|
||||
print server.rss.subscribeToFeed("admin", "password",
|
||||
"http://tt-rss.spb.ru/forum/rss.php");
|
||||
|
||||
# print "Got '" + server.examples.getStateName(32) + "'"
|
||||
#
|
||||
# r = server.mail.send("edd", "Test",
|
||||
# "Bonjour.", "freddy", "", "",
|
||||
# 'text/plain; charset="iso-8859-1"')
|
||||
# if r:
|
||||
# print "Mail sent OK"
|
||||
# else:
|
||||
# print "Error sending mail"
|
||||
#
|
||||
#
|
||||
# r = server.examples.echo('Three "blind" mice - ' + "See 'how' they run")
|
||||
# print r
|
||||
#
|
||||
# # name/age example. this exercises structs and arrays
|
||||
#
|
||||
# a = [ {'name': 'Dave', 'age': 35}, {'name': 'Edd', 'age': 45 },
|
||||
# {'name': 'Fred', 'age': 23}, {'name': 'Barney', 'age': 36 }]
|
||||
# r = server.examples.sortByAge(a)
|
||||
# print r
|
||||
#
|
||||
# # test base 64
|
||||
# b = Binary("Mary had a little lamb She tied it to a pylon")
|
||||
# b.encode(sys.stdout)
|
||||
# r = server.examples.decode64(b)
|
||||
# print r
|
||||
|
||||
except Error, v:
|
||||
print "XML-RPC Error:",v
|
55
xmlrpc/lib/compat/array_key_exists.php
Normal file
55
xmlrpc/lib/compat/array_key_exists.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Aidan Lister <aidan@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: array_key_exists.php,v 1.1 2005/07/11 16:34:35 ggiunta Exp $
|
||||
|
||||
|
||||
/**
|
||||
* Replace array_key_exists()
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_Compat
|
||||
* @link http://php.net/function.array_key_exists
|
||||
* @author Aidan Lister <aidan@php.net>
|
||||
* @version $Revision: 1.1 $
|
||||
* @since PHP 4.1.0
|
||||
* @require PHP 4.0.0 (user_error)
|
||||
*/
|
||||
if (!function_exists('array_key_exists')) {
|
||||
function array_key_exists($key, $search)
|
||||
{
|
||||
if (!is_scalar($key)) {
|
||||
user_error('array_key_exists() The first argument should be either a string or an integer',
|
||||
E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_object($search)) {
|
||||
$search = get_object_vars($search);
|
||||
}
|
||||
|
||||
if (!is_array($search)) {
|
||||
user_error('array_key_exists() The second argument should be either an array or an object',
|
||||
E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
return in_array($key, array_keys($search));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
47
xmlrpc/lib/compat/is_a.php
Normal file
47
xmlrpc/lib/compat/is_a.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Aidan Lister <aidan@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: is_a.php,v 1.2 2005/11/21 10:57:23 ggiunta Exp $
|
||||
|
||||
|
||||
/**
|
||||
* Replace function is_a()
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_Compat
|
||||
* @link http://php.net/function.is_a
|
||||
* @author Aidan Lister <aidan@php.net>
|
||||
* @version $Revision: 1.2 $
|
||||
* @since PHP 4.2.0
|
||||
* @require PHP 4.0.0 (user_error) (is_subclass_of)
|
||||
*/
|
||||
if (!function_exists('is_a')) {
|
||||
function is_a($object, $class)
|
||||
{
|
||||
if (!is_object($object)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (get_class($object) == strtolower($class)) {
|
||||
return true;
|
||||
} else {
|
||||
return is_subclass_of($object, $class);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
38
xmlrpc/lib/compat/is_scalar.php
Normal file
38
xmlrpc/lib/compat/is_scalar.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: is_scalar.php,v 1.2 2005/11/21 10:57:23 ggiunta Exp $
|
||||
|
||||
|
||||
/**
|
||||
* Replace is_scalar()
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_Compat
|
||||
* @link http://php.net/function.is_scalar
|
||||
* @author Gaetano Giunta
|
||||
* @version $Revision: 1.2 $
|
||||
* @since PHP 4.0.5
|
||||
* @require PHP 4 (is_bool)
|
||||
*/
|
||||
if (!function_exists('is_scalar')) {
|
||||
function is_scalar($val)
|
||||
{
|
||||
// Check input
|
||||
return (is_bool($val) || is_int($val) || is_float($val) || is_string($val));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
105
xmlrpc/lib/compat/var_export.php
Normal file
105
xmlrpc/lib/compat/var_export.php
Normal file
|
@ -0,0 +1,105 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Aidan Lister <aidan@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: var_export.php,v 1.2 2005/11/21 10:57:23 ggiunta Exp $
|
||||
|
||||
|
||||
/**
|
||||
* Replace var_export()
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_Compat
|
||||
* @link http://php.net/function.var_export
|
||||
* @author Aidan Lister <aidan@php.net>
|
||||
* @version $Revision: 1.2 $
|
||||
* @since PHP 4.2.0
|
||||
* @require PHP 4.0.0 (user_error)
|
||||
*/
|
||||
if (!function_exists('var_export')) {
|
||||
function var_export($array, $return = false, $lvl=0)
|
||||
{
|
||||
// Common output variables
|
||||
$indent = ' ';
|
||||
$doublearrow = ' => ';
|
||||
$lineend = ",\n";
|
||||
$stringdelim = '\'';
|
||||
|
||||
// Check the export isn't a simple string / int
|
||||
if (is_string($array)) {
|
||||
$out = $stringdelim . str_replace('\'', '\\\'', str_replace('\\', '\\\\', $array)) . $stringdelim;
|
||||
} elseif (is_int($array) || is_float($array)) {
|
||||
$out = (string)$array;
|
||||
} elseif (is_bool($array)) {
|
||||
$out = $array ? 'true' : 'false';
|
||||
} elseif (is_null($array)) {
|
||||
$out = 'NULL';
|
||||
} elseif (is_resource($array)) {
|
||||
$out = 'resource';
|
||||
} else {
|
||||
// Begin the array export
|
||||
// Start the string
|
||||
$out = "array (\n";
|
||||
|
||||
// Loop through each value in array
|
||||
foreach ($array as $key => $value) {
|
||||
// If the key is a string, delimit it
|
||||
if (is_string($key)) {
|
||||
$key = str_replace('\'', '\\\'', str_replace('\\', '\\\\', $key));
|
||||
$key = $stringdelim . $key . $stringdelim;
|
||||
}
|
||||
|
||||
$val = var_export($value, true, $lvl+1);
|
||||
// Delimit value
|
||||
/*if (is_array($value)) {
|
||||
// We have an array, so do some recursion
|
||||
// Do some basic recursion while increasing the indent
|
||||
$recur_array = explode($newline, var_export($value, true));
|
||||
$temp_array = array();
|
||||
foreach ($recur_array as $recur_line) {
|
||||
$temp_array[] = $indent . $recur_line;
|
||||
}
|
||||
$recur_array = implode($newline, $temp_array);
|
||||
$value = $newline . $recur_array;
|
||||
} elseif (is_null($value)) {
|
||||
$value = 'NULL';
|
||||
} else {
|
||||
$value = str_replace($find, $replace, $value);
|
||||
$value = $stringdelim . $value . $stringdelim;
|
||||
}*/
|
||||
|
||||
// Piece together the line
|
||||
for ($i = 0; $i < $lvl; $i++)
|
||||
$out .= $indent;
|
||||
$out .= $key . $doublearrow . $val . $lineend;
|
||||
}
|
||||
|
||||
// End our string
|
||||
for ($i = 0; $i < $lvl; $i++)
|
||||
$out .= $indent;
|
||||
$out .= ")";
|
||||
}
|
||||
|
||||
// Decide method of output
|
||||
if ($return === true) {
|
||||
return $out;
|
||||
} else {
|
||||
echo $out;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
179
xmlrpc/lib/compat/version_compare.php
Normal file
179
xmlrpc/lib/compat/version_compare.php
Normal file
|
@ -0,0 +1,179 @@
|
|||
<?php
|
||||
// +----------------------------------------------------------------------+
|
||||
// | PHP Version 4 |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Copyright (c) 1997-2004 The PHP Group |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | This source file is subject to version 3.0 of the PHP license, |
|
||||
// | that is bundled with this package in the file LICENSE, and is |
|
||||
// | available at through the world-wide-web at |
|
||||
// | http://www.php.net/license/3_0.txt. |
|
||||
// | If you did not receive a copy of the PHP license and are unable to |
|
||||
// | obtain it through the world-wide-web, please send a note to |
|
||||
// | license@php.net so we can mail you a copy immediately. |
|
||||
// +----------------------------------------------------------------------+
|
||||
// | Authors: Philippe Jausions <Philippe.Jausions@11abacus.com> |
|
||||
// | Aidan Lister <aidan@php.net> |
|
||||
// +----------------------------------------------------------------------+
|
||||
//
|
||||
// $Id: version_compare.php,v 1.1 2005/07/11 16:34:36 ggiunta Exp $
|
||||
|
||||
|
||||
/**
|
||||
* Replace version_compare()
|
||||
*
|
||||
* @category PHP
|
||||
* @package PHP_Compat
|
||||
* @link http://php.net/function.version_compare
|
||||
* @author Philippe Jausions <Philippe.Jausions@11abacus.com>
|
||||
* @author Aidan Lister <aidan@php.net>
|
||||
* @version $Revision: 1.1 $
|
||||
* @since PHP 4.1.0
|
||||
* @require PHP 4.0.0 (user_error)
|
||||
*/
|
||||
if (!function_exists('version_compare')) {
|
||||
function version_compare($version1, $version2, $operator = '<')
|
||||
{
|
||||
// Check input
|
||||
if (!is_scalar($version1)) {
|
||||
user_error('version_compare() expects parameter 1 to be string, ' .
|
||||
gettype($version1) . ' given', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_scalar($version2)) {
|
||||
user_error('version_compare() expects parameter 2 to be string, ' .
|
||||
gettype($version2) . ' given', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!is_scalar($operator)) {
|
||||
user_error('version_compare() expects parameter 3 to be string, ' .
|
||||
gettype($operator) . ' given', E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
// Standardise versions
|
||||
$v1 = explode('.',
|
||||
str_replace('..', '.',
|
||||
preg_replace('/([^0-9\.]+)/', '.$1.',
|
||||
str_replace(array('-', '_', '+'), '.',
|
||||
trim($version1)))));
|
||||
|
||||
$v2 = explode('.',
|
||||
str_replace('..', '.',
|
||||
preg_replace('/([^0-9\.]+)/', '.$1.',
|
||||
str_replace(array('-', '_', '+'), '.',
|
||||
trim($version2)))));
|
||||
|
||||
// Replace empty entries at the start of the array
|
||||
while (empty($v1[0]) && array_shift($v1)) {}
|
||||
while (empty($v2[0]) && array_shift($v2)) {}
|
||||
|
||||
// Release state order
|
||||
// '#' stands for any number
|
||||
$versions = array(
|
||||
'dev' => 0,
|
||||
'alpha' => 1,
|
||||
'a' => 1,
|
||||
'beta' => 2,
|
||||
'b' => 2,
|
||||
'RC' => 3,
|
||||
'#' => 4,
|
||||
'p' => 5,
|
||||
'pl' => 5);
|
||||
|
||||
// Loop through each segment in the version string
|
||||
$compare = 0;
|
||||
for ($i = 0, $x = min(count($v1), count($v2)); $i < $x; $i++) {
|
||||
if ($v1[$i] == $v2[$i]) {
|
||||
continue;
|
||||
}
|
||||
$i1 = $v1[$i];
|
||||
$i2 = $v2[$i];
|
||||
if (is_numeric($i1) && is_numeric($i2)) {
|
||||
$compare = ($i1 < $i2) ? -1 : 1;
|
||||
break;
|
||||
}
|
||||
// We use the position of '#' in the versions list
|
||||
// for numbers... (so take care of # in original string)
|
||||
if ($i1 == '#') {
|
||||
$i1 = '';
|
||||
} elseif (is_numeric($i1)) {
|
||||
$i1 = '#';
|
||||
}
|
||||
if ($i2 == '#') {
|
||||
$i2 = '';
|
||||
} elseif (is_numeric($i2)) {
|
||||
$i2 = '#';
|
||||
}
|
||||
if (isset($versions[$i1]) && isset($versions[$i2])) {
|
||||
$compare = ($versions[$i1] < $versions[$i2]) ? -1 : 1;
|
||||
} elseif (isset($versions[$i1])) {
|
||||
$compare = 1;
|
||||
} elseif (isset($versions[$i2])) {
|
||||
$compare = -1;
|
||||
} else {
|
||||
$compare = 0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// If previous loop didn't find anything, compare the "extra" segments
|
||||
if ($compare == 0) {
|
||||
if (count($v2) > count($v1)) {
|
||||
if (isset($versions[$v2[$i]])) {
|
||||
$compare = ($versions[$v2[$i]] < 4) ? 1 : -1;
|
||||
} else {
|
||||
$compare = -1;
|
||||
}
|
||||
} elseif (count($v2) < count($v1)) {
|
||||
if (isset($versions[$v1[$i]])) {
|
||||
$compare = ($versions[$v1[$i]] < 4) ? -1 : 1;
|
||||
} else {
|
||||
$compare = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Compare the versions
|
||||
if (func_num_args() > 2) {
|
||||
switch ($operator) {
|
||||
case '>':
|
||||
case 'gt':
|
||||
return (bool) ($compare > 0);
|
||||
break;
|
||||
case '>=':
|
||||
case 'ge':
|
||||
return (bool) ($compare >= 0);
|
||||
break;
|
||||
case '<=':
|
||||
case 'le':
|
||||
return (bool) ($compare <= 0);
|
||||
break;
|
||||
case '==':
|
||||
case '=':
|
||||
case 'eq':
|
||||
return (bool) ($compare == 0);
|
||||
break;
|
||||
case '<>':
|
||||
case '!=':
|
||||
case 'ne':
|
||||
return (bool) ($compare != 0);
|
||||
break;
|
||||
case '':
|
||||
case '<':
|
||||
case 'lt':
|
||||
return (bool) ($compare < 0);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return $compare;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
3723
xmlrpc/lib/xmlrpc.inc
Normal file
3723
xmlrpc/lib/xmlrpc.inc
Normal file
File diff suppressed because it is too large
Load diff
1077
xmlrpc/lib/xmlrpcs.inc
Normal file
1077
xmlrpc/lib/xmlrpcs.inc
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue