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

📄 lib-xmlrpc.inc.php

📁 一个采用PHP开发的横幅广告管理与跟踪系统。当前它能够管理每个广告主拥有的多种任何尺寸横幅广告
💻 PHP
📖 第 1 页 / 共 4 页
字号:
<?php // $Revision: 2746 $

/************************************************************************/
/* phpAdsNew                                                            */
/* =========                                                            */
/*                                                                      */
/* Copyright (c) 1999,2000,2001 Edd Dumbill                             */
/* For more information visit: http://www.phpadsnew.com                 */
/************************************************************************/



/*********************************************************/
/* XML-RPC client code                                   */
/*********************************************************/

// Copyright (c) 1999,2000,2002 Edd Dumbill.
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
//
//    * Redistributions of source code must retain the above copyright
//      notice, this list of conditions and the following disclaimer.
//
//    * 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.
//
//    * Neither the name of the "XML-RPC for PHP" nor the names of its
//      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
// REGENTS 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.

// Disabled automatic loading of library.
// Niels Leenheer <niels@creatype.nl
/*
if (!function_exists('xml_parser_create')) {
// Win 32 fix. From: "Leo West" <lwest@imaginet.fr>
	if($WINDIR) {
		dl("php3_xml.dll");
	} else {
		dl("xml.so");
	}
}
*/

	// G. Giunta 2005/01/29: declare global these variables,
	// so that xmlrpc.inc will work even if included from within a function
	// NB: it will give warnings in PHP3, so we comment it out
	// Milosch: Next round, maybe we should explicitly request these via $GLOBALS where used.
	if (phpversion() >= '4')
	{
		global $xmlrpcI4;
		global $xmlrpcInt;
		global $xmlrpcDouble;
		global $xmlrpcBoolean;
		global $xmlrpcString;
		global $xmlrpcDateTime;
		global $xmlrpcBase64;
		global $xmlrpcArray;
		global $xmlrpcStruct;

		global $xmlrpcTypes;
		global $xmlrpc_valid_parents;
		global $xmlEntities;
		global $xmlrpcerr;
		global $xmlrpcstr;
		global $xmlrpc_defencoding;
		global $xmlrpc_internalencoding;
		global $xmlrpcName;
		global $xmlrpcVersion;
		global $xmlrpcerruser;
		global $xmlrpcerrxml;
		global $xmlrpc_backslash;
		global $_xh;
	}
	$xmlrpcI4='i4';
	$xmlrpcInt='int';
	$xmlrpcBoolean='boolean';
	$xmlrpcDouble='double';
	$xmlrpcString='string';
	$xmlrpcDateTime='dateTime.iso8601';
	$xmlrpcBase64='base64';
	$xmlrpcArray='array';
	$xmlrpcStruct='struct';

	$xmlrpcTypes=array(
		$xmlrpcI4       => 1,
		$xmlrpcInt      => 1,
		$xmlrpcBoolean  => 1,
		$xmlrpcString   => 1,
		$xmlrpcDouble   => 1,
		$xmlrpcDateTime => 1,
		$xmlrpcBase64   => 1,
		$xmlrpcArray    => 2,
		$xmlrpcStruct   => 3
	);

	$xmlrpc_valid_parents = array(
		'BOOLEAN' => array('VALUE'),
		'I4' => array('VALUE'),
		'INT' => array('VALUE'),
		'STRING' => array('VALUE'),
		'DOUBLE' => array('VALUE'),
		'DATETIME.ISO8601' => array('VALUE'),
		'BASE64' => array('VALUE'),
		'ARRAY' => array('VALUE'),
		'STRUCT' => array('VALUE'),
		'PARAM' => array('PARAMS'),
		'METHODNAME' => array('METHODCALL'),		
		'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
		'MEMBER' => array('STRUCT'),
		'NAME' => array('MEMBER'),
		'DATA' => array('ARRAY'),
		'FAULT' => array('METHODRESPONSE'),
		'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
	);

	$xmlEntities=array(
		'amp'  => '&',
		'quot' => '"',
		'lt'   => '<',
		'gt'   => '>',
		'apos' => "'"
	);

	$xmlrpcerr['unknown_method']=1;
	$xmlrpcstr['unknown_method']='Unknown method';
	$xmlrpcerr['invalid_return']=2;
	$xmlrpcstr['invalid_return']='Invalid return payload: enable debugging to examine incoming payload';
	$xmlrpcerr['incorrect_params']=3;
	$xmlrpcstr['incorrect_params']='Incorrect parameters passed to method';
	$xmlrpcerr['introspect_unknown']=4;
	$xmlrpcstr['introspect_unknown']="Can't introspect: method unknown";
	$xmlrpcerr['http_error']=5;
	$xmlrpcstr['http_error']="Didn't receive 200 OK from remote server.";
	$xmlrpcerr['no_data']=6;
	$xmlrpcstr['no_data']='No data received from server.';
	$xmlrpcerr['no_ssl']=7;
	$xmlrpcstr['no_ssl']='No SSL support compiled in.';
	$xmlrpcerr['curl_fail']=8;
	$xmlrpcstr['curl_fail']='CURL error';
	$xmlrpcerr['invalid_request']=15;
	$xmlrpcstr['invalid_request']='Invalid request payload';
	
	$xmlrpcerr['multicall_notstruct'] = 9;
	$xmlrpcstr['multicall_notstruct'] = 'system.multicall expected struct';
	$xmlrpcerr['multicall_nomethod']  = 10;
	$xmlrpcstr['multicall_nomethod']  = 'missing methodName';
	$xmlrpcerr['multicall_notstring'] = 11;
	$xmlrpcstr['multicall_notstring'] = 'methodName is not a string';
	$xmlrpcerr['multicall_recursion'] = 12;
	$xmlrpcstr['multicall_recursion'] = 'recursive system.multicall forbidden';
	$xmlrpcerr['multicall_noparams']  = 13;
	$xmlrpcstr['multicall_noparams']  = 'missing params';
	$xmlrpcerr['multicall_notarray']  = 14;
	$xmlrpcstr['multicall_notarray']  = 'params is not an array';

	// The charset encoding expected by the server for received messages and
	// by the client for received responses
	$xmlrpc_defencoding='UTF-8';
	// The encoding used by PHP.
	// String values received will be converted to this.
	$xmlrpc_internalencoding='ISO-8859-1';

	$xmlrpcName='XML-RPC for PHP';
	$xmlrpcVersion='1.2';

	// let user errors start at 800
	$xmlrpcerruser=800;
	// let XML parse errors start at 100
	$xmlrpcerrxml=100;

	// formulate backslashes for escaping regexp
	$xmlrpc_backslash=chr(92).chr(92);

	// used to store state during parsing
	// quick explanation of components:
	//   ac - used to accumulate values
	//   isf - used to indicate a fault
	//   lv - used to indicate "looking for a value": implements
	//        the logic to allow values with no types to be strings
	//   params - used to store parameters in method calls
	//   method - used to store method name
	//   stack - array with genealogy of xml elements names:
	//           used to validate nesting of xmlrpc elements

	$_xh=array();

	/**
	* To help correct communication of non-ascii chars inside strings, regardless
	* of the charset used when sending requests, parsing them, sending responses
	* and parsing responses, convert all non-ascii chars present in the message
	* into their equivalent 'charset entity'. Charset entities enumerated this way
	* are independent of the charset encoding used to transmit them, and all XML
	* parsers are bound to understand them.
	*/
	function xmlrpc_entity_decode($string)
	{
		$top=split('&', $string);
		$op='';
		$i=0;
		while($i<sizeof($top))
		{
			if (ereg("^([#a-zA-Z0-9]+);", $top[$i], $regs))
			{
				$op.=ereg_replace("^[#a-zA-Z0-9]+;",
				xmlrpc_lookup_entity($regs[1]),
				$top[$i]);
			}
			else
			{
				if ($i==0)
				{
					$op=$top[$i];
				}
				else
				{
					$op.='&' . $top[$i];
				}
			}
			$i++;
		}
		return $op;
	}

	function xmlrpc_lookup_entity($ent)
	{
		global $xmlEntities;

		if (isset($xmlEntities[strtolower($ent)]))
		{
			return $xmlEntities[strtolower($ent)];
		}
		if (ereg("^#([0-9]+)$", $ent, $regs))
		{
			return chr($regs[1]);
		}
		return '?';
	}

	/**
	 * These entities originate from HTML specs (1.1, proposed 2.0, etc),
	 * and are taken directly from php-4.3.1/ext/mbstring/html_entities.c.
	 * Until php provides functionality to translate these entities in its
	 * core library, use this function.
	 */
	function xmlrpc_html_entity_xlate($data = '')
	{
		$entities = array(
			"&nbsp;" => "&#160;",
			"&iexcl;" => "&#161;",
			"&cent;" => "&#162;",
			"&pound;" => "&#163;",
			"&curren;" => "&#164;",
			"&yen;" => "&#165;",
			"&brvbar;" => "&#166;",
			"&sect;" => "&#167;",
			"&uml;" => "&#168;",
			"&copy;" => "&#169;",
			"&ordf;" => "&#170;",
			"&laquo;" => "&#171;",
			"&not;" => "&#172;",
			"&shy;" => "&#173;",
			"&reg;" => "&#174;",
			"&macr;" => "&#175;",
			"&deg;" => "&#176;",
			"&plusmn;" => "&#177;",
			"&sup2;" => "&#178;",
			"&sup3;" => "&#179;",
			"&acute;" => "&#180;",
			"&micro;" => "&#181;",
			"&para;" => "&#182;",
			"&middot;" => "&#183;",
			"&cedil;" => "&#184;",
			"&sup1;" => "&#185;",
			"&ordm;" => "&#186;",
			"&raquo;" => "&#187;",
			"&frac14;" => "&#188;",
			"&frac12;" => "&#189;",
			"&frac34;" => "&#190;",
			"&iquest;" => "&#191;",
			"&Agrave;" => "&#192;",
			"&Aacute;" => "&#193;",
			"&Acirc;" => "&#194;",
			"&Atilde;" => "&#195;",
			"&Auml;" => "&#196;",
			"&Aring;" => "&#197;",
			"&AElig;" => "&#198;",
			"&Ccedil;" => "&#199;",
			"&Egrave;" => "&#200;",
			"&Eacute;" => "&#201;",
			"&Ecirc;" => "&#202;",
			"&Euml;" => "&#203;",
			"&Igrave;" => "&#204;",
			"&Iacute;" => "&#205;",
			"&Icirc;" => "&#206;",
			"&Iuml;" => "&#207;",
			"&ETH;" => "&#208;",
			"&Ntilde;" => "&#209;",
			"&Ograve;" => "&#210;",
			"&Oacute;" => "&#211;",
			"&Ocirc;" => "&#212;",
			"&Otilde;" => "&#213;",
			"&Ouml;" => "&#214;",
			"&times;" => "&#215;",
			"&Oslash;" => "&#216;",
			"&Ugrave;" => "&#217;",
			"&Uacute;" => "&#218;",
			"&Ucirc;" => "&#219;",
			"&Uuml;" => "&#220;",
			"&Yacute;" => "&#221;",
			"&THORN;" => "&#222;",
			"&szlig;" => "&#223;",
			"&agrave;" => "&#224;",
			"&aacute;" => "&#225;",
			"&acirc;" => "&#226;",
			"&atilde;" => "&#227;",
			"&auml;" => "&#228;",
			"&aring;" => "&#229;",
			"&aelig;" => "&#230;",
			"&ccedil;" => "&#231;",
			"&egrave;" => "&#232;",
			"&eacute;" => "&#233;",
			"&ecirc;" => "&#234;",
			"&euml;" => "&#235;",
			"&igrave;" => "&#236;",
			"&iacute;" => "&#237;",
			"&icirc;" => "&#238;",
			"&iuml;" => "&#239;",
			"&eth;" => "&#240;",
			"&ntilde;" => "&#241;",
			"&ograve;" => "&#242;",
			"&oacute;" => "&#243;",
			"&ocirc;" => "&#244;",
			"&otilde;" => "&#245;",
			"&ouml;" => "&#246;",
			"&divide;" => "&#247;",
			"&oslash;" => "&#248;",
			"&ugrave;" => "&#249;",
			"&uacute;" => "&#250;",
			"&ucirc;" => "&#251;",
			"&uuml;" => "&#252;",
			"&yacute;" => "&#253;",
			"&thorn;" => "&#254;",
			"&yuml;" => "&#255;",
			"&OElig;" => "&#338;",
			"&oelig;" => "&#339;",
			"&Scaron;" => "&#352;",
			"&scaron;" => "&#353;",
			"&Yuml;" => "&#376;",
			"&fnof;" => "&#402;",
			"&circ;" => "&#710;",
			"&tilde;" => "&#732;",
			"&Alpha;" => "&#913;",
			"&Beta;" => "&#914;",
			"&Gamma;" => "&#915;",
			"&Delta;" => "&#916;",
			"&Epsilon;" => "&#917;",
			"&Zeta;" => "&#918;",
			"&Eta;" => "&#919;",
			"&Theta;" => "&#920;",
			"&Iota;" => "&#921;",
			"&Kappa;" => "&#922;",
			"&Lambda;" => "&#923;",
			"&Mu;" => "&#924;",
			"&Nu;" => "&#925;",
			"&Xi;" => "&#926;",
			"&Omicron;" => "&#927;",
			"&Pi;" => "&#928;",
			"&Rho;" => "&#929;",
			"&Sigma;" => "&#931;",
			"&Tau;" => "&#932;",
			"&Upsilon;" => "&#933;",
			"&Phi;" => "&#934;",
			"&Chi;" => "&#935;",
			"&Psi;" => "&#936;",
			"&Omega;" => "&#937;",
			"&beta;" => "&#946;",
			"&gamma;" => "&#947;",
			"&delta;" => "&#948;",
			"&epsilon;" => "&#949;",
			"&zeta;" => "&#950;",
			"&eta;" => "&#951;",
			"&theta;" => "&#952;",
			"&iota;" => "&#953;",
			"&kappa;" => "&#954;",
			"&lambda;" => "&#955;",
			"&mu;" => "&#956;",
			"&nu;" => "&#957;",
			"&xi;" => "&#958;",
			"&omicron;" => "&#959;",
			"&pi;" => "&#960;",
			"&rho;" => "&#961;",
			"&sigmaf;" => "&#962;",
			"&sigma;" => "&#963;",
			"&tau;" => "&#964;",
			"&upsilon;" => "&#965;",
			"&phi;" => "&#966;",
			"&chi;" => "&#967;",
			"&psi;" => "&#968;",
			"&omega;" => "&#969;",
			"&thetasym;" => "&#977;",
			"&upsih;" => "&#978;",
			"&piv;" => "&#982;",
			"&ensp;" => "&#8194;",
			"&emsp;" => "&#8195;",
			"&thinsp;" => "&#8201;",
			"&zwnj;" => "&#8204;",
			"&zwj;" => "&#8205;",
			"&lrm;" => "&#8206;",
			"&rlm;" => "&#8207;",
			"&ndash;" => "&#8211;",
			"&mdash;" => "&#8212;",
			"&lsquo;" => "&#8216;",
			"&rsquo;" => "&#8217;",
			"&sbquo;" => "&#8218;",
			"&ldquo;" => "&#8220;",
			"&rdquo;" => "&#8221;",
			"&bdquo;" => "&#8222;",
			"&dagger;" => "&#8224;",
			"&Dagger;" => "&#8225;",
			"&bull;" => "&#8226;",
			"&hellip;" => "&#8230;",
			"&permil;" => "&#8240;",
			"&prime;" => "&#8242;",
			"&Prime;" => "&#8243;",
			"&lsaquo;" => "&#8249;",
			"&rsaquo;" => "&#8250;",
			"&oline;" => "&#8254;",
			"&frasl;" => "&#8260;",
			"&euro;" => "&#8364;",
			"&weierp;" => "&#8472;",
			"&image;" => "&#8465;",
			"&real;" => "&#8476;",
			"&trade;" => "&#8482;",
			"&alefsym;" => "&#8501;",
			"&larr;" => "&#8592;",
			"&uarr;" => "&#8593;",
			"&rarr;" => "&#8594;",
			"&darr;" => "&#8595;",
			"&harr;" => "&#8596;",
			"&crarr;" => "&#8629;",
			"&lArr;" => "&#8656;",
			"&uArr;" => "&#8657;",
			"&rArr;" => "&#8658;",
			"&dArr;" => "&#8659;",
			"&hArr;" => "&#8660;",
			"&forall;" => "&#8704;",
			"&part;" => "&#8706;",
			"&exist;" => "&#8707;",
			"&empty;" => "&#8709;",
			"&nabla;" => "&#8711;",
			"&isin;" => "&#8712;",
			"&notin;" => "&#8713;",
			"&ni;" => "&#8715;",
			"&prod;" => "&#8719;",
			"&sum;" => "&#8721;",
			"&minus;" => "&#8722;",
			"&lowast;" => "&#8727;",
			"&radic;" => "&#8730;",
			"&prop;" => "&#8733;",
			"&infin;" => "&#8734;",
			"&ang;" => "&#8736;",
			"&and;" => "&#8743;",
			"&or;" => "&#8744;",
			"&cap;" => "&#8745;",
			"&cup;" => "&#8746;",
			"&int;" => "&#8747;",
			"&there4;" => "&#8756;",
			"&sim;" => "&#8764;",
			"&cong;" => "&#8773;",
			"&asymp;" => "&#8776;",
			"&ne;" => "&#8800;",
			"&equiv;" => "&#8801;",
			"&le;" => "&#8804;",
			"&ge;" => "&#8805;",
			"&sub;" => "&#8834;",
			"&sup;" => "&#8835;",
			"&nsub;" => "&#8836;",
			"&sube;" => "&#8838;",
			"&supe;" => "&#8839;",
			"&oplus;" => "&#8853;",
			"&otimes;" => "&#8855;",
			"&perp;" => "&#8869;",
			"&sdot;" => "&#8901;",
			"&lceil;" => "&#8968;",
			"&rceil;" => "&#8969;",
			"&lfloor;" => "&#8970;",
			"&rfloor;" => "&#8971;",
			"&lang;" => "&#9001;",
			"&rang;" => "&#9002;",
			"&loz;" => "&#9674;",
			"&spades;" => "&#9824;",
			"&clubs;" => "&#9827;",
			"&hearts;" => "&#9829;",
			"&diams;" => "&#9830;");
		return strtr($data, $entities);
	}

	function xmlrpc_encode_entitites($data) 
	{
		$length = strlen($data);
		$escapeddata = "";
		for($position = 0; $position < $length; $position++)
		{
			$character = substr($data, $position, 1);
			$code = Ord($character);
			switch($code) {
				case 34:
				$character = "&quot;";
				break;
				case 38:
				$character = "&amp;";
				break;
				case 39:
				$character = "&apos;";
				break;
				case 60:
				$character = "&lt;";
				break;
				case 62:
				$character = "&gt;";
				break;
				default:
				if ($code < 32 || $code > 159)
					$character = ("&#".strval($code).";");
				break;
			}
			$escapeddata .= $character;
		}
		return $escapeddata;
	}

	function xmlrpc_se($parser, $name, $attrs)
	{
		global $_xh, $xmlrpcDateTime, $xmlrpcString, $xmlrpc_valid_parents;

		// if invalid xmlrpc already detected, skip all processing
		if ($_xh[$parser]['isf'] < 2)

⌨️ 快捷键说明

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