[ PHPXref.com ] [ Generated: Sun Jul 20 19:31:32 2008 ] [ phpAdsNew 2.0.8 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/libraries/ -> lib-xmlrpc.inc.php (source)

   1  <?php // $Revision: 2.0.2.8 $
   2  
   3  /************************************************************************/
   4  /* phpAdsNew                                                            */
   5  /* =========                                                            */
   6  /*                                                                      */
   7  /* Copyright (c) 1999,2000,2001 Edd Dumbill                             */
   8  /* For more information visit: http://www.phpadsnew.com                 */
   9  /************************************************************************/
  10  
  11  
  12  
  13  /*********************************************************/
  14  /* XML-RPC client code                                   */
  15  /*********************************************************/
  16  
  17  // Copyright (c) 1999,2000,2002 Edd Dumbill.
  18  // All rights reserved.
  19  //
  20  // Redistribution and use in source and binary forms, with or without
  21  // modification, are permitted provided that the following conditions
  22  // are met:
  23  //
  24  //    * Redistributions of source code must retain the above copyright
  25  //      notice, this list of conditions and the following disclaimer.
  26  //
  27  //    * Redistributions in binary form must reproduce the above
  28  //      copyright notice, this list of conditions and the following
  29  //      disclaimer in the documentation and/or other materials provided
  30  //      with the distribution.
  31  //
  32  //    * Neither the name of the "XML-RPC for PHP" nor the names of its
  33  //      contributors may be used to endorse or promote products derived
  34  //      from this software without specific prior written permission.
  35  //
  36  // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  37  // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  38  // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  39  // FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  40  // REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  41  // INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  42  // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  43  // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  44  // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  45  // STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  46  // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  47  // OF THE POSSIBILITY OF SUCH DAMAGE.
  48  
  49  // Disabled automatic loading of library.
  50  // Niels Leenheer <niels@creatype.nl
  51  /*
  52  if (!function_exists('xml_parser_create')) {
  53  // Win 32 fix. From: "Leo West" <lwest@imaginet.fr>
  54      if($WINDIR) {
  55          dl("php3_xml.dll");
  56      } else {
  57          dl("xml.so");
  58      }
  59  }
  60  */
  61  
  62      // G. Giunta 2005/01/29: declare global these variables,
  63      // so that xmlrpc.inc will work even if included from within a function
  64      // NB: it will give warnings in PHP3, so we comment it out
  65      // Milosch: Next round, maybe we should explicitly request these via $GLOBALS where used.
  66      if (phpversion() >= '4')
  67      {
  68          global $xmlrpcI4;
  69          global $xmlrpcInt;
  70          global $xmlrpcDouble;
  71          global $xmlrpcBoolean;
  72          global $xmlrpcString;
  73          global $xmlrpcDateTime;
  74          global $xmlrpcBase64;
  75          global $xmlrpcArray;
  76          global $xmlrpcStruct;
  77  
  78          global $xmlrpcTypes;
  79          global $xmlrpc_valid_parents;
  80          global $xmlEntities;
  81          global $xmlrpcerr;
  82          global $xmlrpcstr;
  83          global $xmlrpc_defencoding;
  84          global $xmlrpc_internalencoding;
  85          global $xmlrpcName;
  86          global $xmlrpcVersion;
  87          global $xmlrpcerruser;
  88          global $xmlrpcerrxml;
  89          global $xmlrpc_backslash;
  90          global $_xh;
  91      }
  92      $xmlrpcI4='i4';
  93      $xmlrpcInt='int';
  94      $xmlrpcBoolean='boolean';
  95      $xmlrpcDouble='double';
  96      $xmlrpcString='string';
  97      $xmlrpcDateTime='dateTime.iso8601';
  98      $xmlrpcBase64='base64';
  99      $xmlrpcArray='array';
 100      $xmlrpcStruct='struct';
 101  
 102      $xmlrpcTypes=array(
 103          $xmlrpcI4       => 1,
 104          $xmlrpcInt      => 1,
 105          $xmlrpcBoolean  => 1,
 106          $xmlrpcString   => 1,
 107          $xmlrpcDouble   => 1,
 108          $xmlrpcDateTime => 1,
 109          $xmlrpcBase64   => 1,
 110          $xmlrpcArray    => 2,
 111          $xmlrpcStruct   => 3
 112      );
 113  
 114      $xmlrpc_valid_parents = array(
 115          'BOOLEAN' => array('VALUE'),
 116          'I4' => array('VALUE'),
 117          'INT' => array('VALUE'),
 118          'STRING' => array('VALUE'),
 119          'DOUBLE' => array('VALUE'),
 120          'DATETIME.ISO8601' => array('VALUE'),
 121          'BASE64' => array('VALUE'),
 122          'ARRAY' => array('VALUE'),
 123          'STRUCT' => array('VALUE'),
 124          'PARAM' => array('PARAMS'),
 125          'METHODNAME' => array('METHODCALL'),        
 126          'PARAMS' => array('METHODCALL', 'METHODRESPONSE'),
 127          'MEMBER' => array('STRUCT'),
 128          'NAME' => array('MEMBER'),
 129          'DATA' => array('ARRAY'),
 130          'FAULT' => array('METHODRESPONSE'),
 131          'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
 132      );
 133  
 134      $xmlEntities=array(
 135          'amp'  => '&',
 136          'quot' => '"',
 137          'lt'   => '<',
 138          'gt'   => '>',
 139          'apos' => "'"
 140      );
 141  
 142      $xmlrpcerr['unknown_method']=1;
 143      $xmlrpcstr['unknown_method']='Unknown method';
 144      $xmlrpcerr['invalid_return']=2;
 145      $xmlrpcstr['invalid_return']='Invalid return payload: enable debugging to examine incoming payload';
 146      $xmlrpcerr['incorrect_params']=3;
 147      $xmlrpcstr['incorrect_params']='Incorrect parameters passed to method';
 148      $xmlrpcerr['introspect_unknown']=4;
 149      $xmlrpcstr['introspect_unknown']="Can't introspect: method unknown";
 150      $xmlrpcerr['http_error']=5;
 151      $xmlrpcstr['http_error']="Didn't receive 200 OK from remote server.";
 152      $xmlrpcerr['no_data']=6;
 153      $xmlrpcstr['no_data']='No data received from server.';
 154      $xmlrpcerr['no_ssl']=7;
 155      $xmlrpcstr['no_ssl']='No SSL support compiled in.';
 156      $xmlrpcerr['curl_fail']=8;
 157      $xmlrpcstr['curl_fail']='CURL error';
 158      $xmlrpcerr['invalid_request']=15;
 159      $xmlrpcstr['invalid_request']='Invalid request payload';
 160      
 161      $xmlrpcerr['multicall_notstruct'] = 9;
 162      $xmlrpcstr['multicall_notstruct'] = 'system.multicall expected struct';
 163      $xmlrpcerr['multicall_nomethod']  = 10;
 164      $xmlrpcstr['multicall_nomethod']  = 'missing methodName';
 165      $xmlrpcerr['multicall_notstring'] = 11;
 166      $xmlrpcstr['multicall_notstring'] = 'methodName is not a string';
 167      $xmlrpcerr['multicall_recursion'] = 12;
 168      $xmlrpcstr['multicall_recursion'] = 'recursive system.multicall forbidden';
 169      $xmlrpcerr['multicall_noparams']  = 13;
 170      $xmlrpcstr['multicall_noparams']  = 'missing params';
 171      $xmlrpcerr['multicall_notarray']  = 14;
 172      $xmlrpcstr['multicall_notarray']  = 'params is not an array';
 173  
 174      // The charset encoding expected by the server for received messages and
 175      // by the client for received responses
 176      $xmlrpc_defencoding='UTF-8';
 177      // The encoding used by PHP.
 178      // String values received will be converted to this.
 179      $xmlrpc_internalencoding='ISO-8859-1';
 180  
 181      $xmlrpcName='XML-RPC for PHP';
 182      $xmlrpcVersion='1.2';
 183  
 184      // let user errors start at 800
 185      $xmlrpcerruser=800;
 186      // let XML parse errors start at 100
 187      $xmlrpcerrxml=100;
 188  
 189      // formulate backslashes for escaping regexp
 190      $xmlrpc_backslash=chr(92).chr(92);
 191  
 192      // used to store state during parsing
 193      // quick explanation of components:
 194      //   ac - used to accumulate values
 195      //   isf - used to indicate a fault
 196      //   lv - used to indicate "looking for a value": implements
 197      //        the logic to allow values with no types to be strings
 198      //   params - used to store parameters in method calls
 199      //   method - used to store method name
 200      //   stack - array with genealogy of xml elements names:
 201      //           used to validate nesting of xmlrpc elements
 202  
 203      $_xh=array();
 204  
 205      /**
 206      * To help correct communication of non-ascii chars inside strings, regardless
 207      * of the charset used when sending requests, parsing them, sending responses
 208      * and parsing responses, convert all non-ascii chars present in the message
 209      * into their equivalent 'charset entity'. Charset entities enumerated this way
 210      * are independent of the charset encoding used to transmit them, and all XML
 211      * parsers are bound to understand them.
 212      */
 213  	function xmlrpc_entity_decode($string)
 214      {
 215          $top=split('&', $string);
 216          $op='';
 217          $i=0;
 218          while($i<sizeof($top))
 219          {
 220              if (ereg("^([#a-zA-Z0-9]+);", $top[$i], $regs))
 221              {
 222                  $op.=ereg_replace("^[#a-zA-Z0-9]+;",
 223                  xmlrpc_lookup_entity($regs[1]),
 224                  $top[$i]);
 225              }
 226              else
 227              {
 228                  if ($i==0)
 229                  {
 230                      $op=$top[$i];
 231                  }
 232                  else
 233                  {
 234                      $op.='&' . $top[$i];
 235                  }
 236              }
 237              $i++;
 238          }
 239          return $op;
 240      }
 241  
 242  	function xmlrpc_lookup_entity($ent)
 243      {
 244          global $xmlEntities;
 245  
 246          if (isset($xmlEntities[strtolower($ent)]))
 247          {
 248              return $xmlEntities[strtolower($ent)];
 249          }
 250          if (ereg("^#([0-9]+)$", $ent, $regs))
 251          {
 252              return chr($regs[1]);
 253          }
 254          return '?';
 255      }
 256  
 257      /**
 258       * These entities originate from HTML specs (1.1, proposed 2.0, etc),
 259       * and are taken directly from php-4.3.1/ext/mbstring/html_entities.c.
 260       * Until php provides functionality to translate these entities in its
 261       * core library, use this function.
 262       */
 263  	function xmlrpc_html_entity_xlate($data = '')
 264      {
 265          $entities = array(
 266              "&nbsp;" => "&#160;",
 267              "&iexcl;" => "&#161;",
 268              "&cent;" => "&#162;",
 269              "&pound;" => "&#163;",
 270              "&curren;" => "&#164;",
 271              "&yen;" => "&#165;",
 272              "&brvbar;" => "&#166;",
 273              "&sect;" => "&#167;",
 274              "&uml;" => "&#168;",
 275              "&copy;" => "&#169;",
 276              "&ordf;" => "&#170;",
 277              "&laquo;" => "&#171;",
 278              "&not;" => "&#172;",
 279              "&shy;" => "&#173;",
 280              "&reg;" => "&#174;",
 281              "&macr;" => "&#175;",
 282              "&deg;" => "&#176;",
 283              "&plusmn;" => "&#177;",
 284              "&sup2;" => "&#178;",
 285              "&sup3;" => "&#179;",
 286              "&acute;" => "&#180;",
 287              "&micro;" => "&#181;",
 288              "&para;" => "&#182;",
 289              "&middot;" => "&#183;",
 290              "&cedil;" => "&#184;",
 291              "&sup1;" => "&#185;",
 292              "&ordm;" => "&#186;",
 293              "&raquo;" => "&#187;",
 294              "&frac14;" => "&#188;",
 295              "&frac12;" => "&#189;",
 296              "&frac34;" => "&#190;",
 297              "&iquest;" => "&#191;",
 298              "&Agrave;" => "&#192;",
 299              "&Aacute;" => "&#193;",
 300              "&Acirc;" => "&#194;",
 301              "&Atilde;" => "&#195;",
 302              "&Auml;" => "&#196;",
 303              "&Aring;" => "&#197;",
 304              "&AElig;" => "&#198;",
 305              "&Ccedil;" => "&#199;",
 306              "&Egrave;" => "&#200;",
 307              "&Eacute;" => "&#201;",
 308              "&Ecirc;" => "&#202;",
 309              "&Euml;" => "&#203;",
 310              "&Igrave;" => "&#204;",
 311              "&Iacute;" => "&#205;",
 312              "&Icirc;" => "&#206;",
 313              "&Iuml;" => "&#207;",
 314              "&ETH;" => "&#208;",
 315              "&Ntilde;" => "&#209;",
 316              "&Ograve;" => "&#210;",
 317              "&Oacute;" => "&#211;",
 318              "&Ocirc;" => "&#212;",
 319              "&Otilde;" => "&#213;",
 320              "&Ouml;" => "&#214;",
 321              "&times;" => "&#215;",
 322              "&Oslash;" => "&#216;",
 323              "&Ugrave;" => "&#217;",
 324              "&Uacute;" => "&#218;",
 325              "&Ucirc;" => "&#219;",
 326              "&Uuml;" => "&#220;",
 327              "&Yacute;" => "&#221;",
 328              "&THORN;" => "&#222;",
 329              "&szlig;" => "&#223;",
 330              "&agrave;" => "&#224;",
 331              "&aacute;" => "&#225;",
 332              "&acirc;" => "&#226;",
 333              "&atilde;" => "&#227;",
 334              "&auml;" => "&#228;",
 335              "&aring;" => "&#229;",
 336              "&aelig;" => "&#230;",
 337              "&ccedil;" => "&#231;",
 338              "&egrave;" => "&#232;",
 339              "&eacute;" => "&#233;",
 340              "&ecirc;" => "&#234;",
 341              "&euml;" => "&#235;",
 342              "&igrave;" => "&#236;",
 343              "&iacute;" => "&#237;",
 344              "&icirc;" => "&#238;",
 345              "&iuml;" => "&#239;",
 346              "&eth;" => "&#240;",
 347              "&ntilde;" => "&#241;",
 348              "&ograve;" => "&#242;",
 349              "&oacute;" => "&#243;",
 350              "&ocirc;" => "&#244;",
 351              "&otilde;" => "&#245;",
 352              "&ouml;" => "&#246;",
 353              "&divide;" => "&#247;",
 354              "&oslash;" => "&#248;",
 355              "&ugrave;" => "&#249;",
 356              "&uacute;" => "&#250;",
 357              "&ucirc;" => "&#251;",
 358              "&uuml;" => "&#252;",
 359              "&yacute;" => "&#253;",
 360              "&thorn;" => "&#254;",
 361              "&yuml;" => "&#255;",
 362              "&OElig;" => "&#338;",
 363              "&oelig;" => "&#339;",
 364              "&Scaron;" => "&#352;",
 365              "&scaron;" => "&#353;",
 366              "&Yuml;" => "&#376;",
 367              "&fnof;" => "&#402;",
 368              "&circ;" => "&#710;",
 369              "&tilde;" => "&#732;",
 370              "&Alpha;" => "&#913;",
 371              "&Beta;" => "&#914;",
 372              "&Gamma;" => "&#915;",
 373              "&Delta;" => "&#916;",
 374              "&Epsilon;" => "&#917;",
 375              "&Zeta;" => "&#918;",
 376              "&Eta;" => "&#919;",
 377              "&Theta;" => "&#920;",
 378              "&Iota;" => "&#921;",
 379              "&Kappa;" => "&#922;",
 380              "&Lambda;" => "&#923;",
 381              "&Mu;" => "&#924;",
 382              "&Nu;" => "&#925;",
 383              "&Xi;" => "&#926;",
 384              "&Omicron;" => "&#927;",
 385              "&Pi;" => "&#928;",
 386              "&Rho;" => "&#929;",
 387              "&Sigma;" => "&#931;",
 388              "&Tau;" => "&#932;",
 389              "&Upsilon;" => "&#933;",
 390              "&Phi;" => "&#934;",
 391              "&Chi;" => "&#935;",
 392              "&Psi;" => "&#936;",
 393              "&Omega;" => "&#937;",
 394              "&beta;" => "&#946;",
 395              "&gamma;" => "&#947;",
 396              "&delta;" => "&#948;",
 397              "&epsilon;" => "&#949;",
 398              "&zeta;" => "&#950;",
 399              "&eta;" => "&#951;",
 400              "&theta;" => "&#952;",
 401              "&iota;" => "&#953;",
 402              "&kappa;" => "&#954;",
 403              "&lambda;" => "&#955;",
 404              "&mu;" => "&#956;",
 405              "&nu;" => "&#957;",
 406              "&xi;" => "&#958;",
 407              "&omicron;" => "&#959;",
 408              "&pi;" => "&#960;",
 409              "&rho;" => "&#961;",
 410              "&sigmaf;" => "&#962;",
 411              "&sigma;" => "&#963;",
 412              "&tau;" => "&#964;",
 413              "&upsilon;" => "&#965;",
 414              "&phi;" => "&#966;",
 415              "&chi;" => "&#967;",
 416              "&psi;" => "&#968;",
 417              "&omega;" => "&#969;",
 418              "&thetasym;" => "&#977;",
 419              "&upsih;" => "&#978;",
 420              "&piv;" => "&#982;",
 421              "&ensp;" => "&#8194;",
 422              "&emsp;" => "&#8195;",
 423              "&thinsp;" => "&#8201;",
 424              "&zwnj;" => "&#8204;",
 425              "&zwj;" => "&#8205;",
 426              "&lrm;" => "&#8206;",
 427              "&rlm;" => "&#8207;",
 428              "&ndash;" => "&#8211;",
 429              "&mdash;" => "&#8212;",
 430              "&lsquo;" => "&#8216;",
 431              "&rsquo;" => "&#8217;",
 432              "&sbquo;" => "&#8218;",
 433              "&ldquo;" => "&#8220;",
 434              "&rdquo;" => "&#8221;",
 435              "&bdquo;" => "&#8222;",
 436              "&dagger;" => "&#8224;",
 437              "&Dagger;" => "&#8225;",
 438              "&bull;" => "&#8226;",
 439              "&hellip;" => "&#8230;",
 440              "&permil;" => "&#8240;",
 441              "&prime;" => "&#8242;",
 442              "&Prime;" => "&#8243;",
 443              "&lsaquo;" => "&#8249;",
 444              "&rsaquo;" => "&#8250;",
 445              "&oline;" => "&#8254;",
 446              "&frasl;" => "&#8260;",
 447              "&euro;" => "&#8364;",
 448              "&weierp;" => "&#8472;",
 449              "&image;" => "&#8465;",
 450              "&real;" => "&#8476;",
 451              "&trade;" => "&#8482;",
 452              "&alefsym;" => "&#8501;",
 453              "&larr;" => "&#8592;",
 454              "&uarr;" => "&#8593;",
 455              "&rarr;" => "&#8594;",
 456              "&darr;" => "&#8595;",
 457              "&harr;" => "&#8596;",
 458              "&crarr;" => "&#8629;",
 459              "&lArr;" => "&#8656;",
 460              "&uArr;" => "&#8657;",
 461              "&rArr;" => "&#8658;",
 462              "&dArr;" => "&#8659;",
 463              "&hArr;" => "&#8660;",
 464              "&forall;" => "&#8704;",
 465              "&part;" => "&#8706;",
 466              "&exist;" => "&#8707;",
 467              "&empty;" => "&#8709;",
 468              "&nabla;" => "&#8711;",
 469              "&isin;" => "&#8712;",
 470              "&notin;" => "&#8713;",
 471              "&ni;" => "&#8715;",
 472              "&prod;" => "&#8719;",
 473              "&sum;" => "&#8721;",
 474              "&minus;" => "&#8722;",
 475              "&lowast;" => "&#8727;",
 476              "&radic;" => "&#8730;",
 477              "&prop;" => "&#8733;",
 478              "&infin;" => "&#8734;",
 479              "&ang;" => "&#8736;",
 480              "&and;" => "&#8743;",
 481              "&or;" => "&#8744;",
 482              "&cap;" => "&#8745;",
 483              "&cup;" => "&#8746;",
 484              "&int;" => "&#8747;",
 485              "&there4;" => "&#8756;",
 486              "&sim;" => "&#8764;",
 487              "&cong;" => "&#8773;",
 488              "&asymp;" => "&#8776;",
 489              "&ne;" => "&#8800;",
 490              "&equiv;" => "&#8801;",
 491              "&le;" => "&#8804;",
 492              "&ge;" => "&#8805;",
 493              "&sub;" => "&#8834;",
 494              "&sup;" => "&#8835;",
 495              "&nsub;" => "&#8836;",
 496              "&sube;" => "&#8838;",
 497              "&supe;" => "&#8839;",
 498              "&oplus;" => "&#8853;",
 499              "&otimes;" => "&#8855;",
 500              "&perp;" => "&#8869;",
 501              "&sdot;" => "&#8901;",
 502              "&lceil;" => "&#8968;",
 503              "&rceil;" => "&#8969;",
 504              "&lfloor;" => "&#8970;",
 505              "&rfloor;" => "&#8971;",
 506              "&lang;" => "&#9001;",
 507              "&rang;" => "&#9002;",
 508              "&loz;" => "&#9674;",
 509              "&spades;" => "&#9824;",
 510              "&clubs;" => "&#9827;",
 511              "&hearts;" => "&#9829;",
 512              "&diams;" => "&#9830;");
 513          return strtr($data, $entities);
 514      }
 515  
 516  	function xmlrpc_encode_entitites($data) 
 517      {
 518          $length = strlen($data);
 519          $escapeddata = "";
 520          for($position = 0; $position < $length; $position++)
 521          {
 522              $character = substr($data, $position, 1);
 523              $code = Ord($character);
 524              switch($code) {
 525                  case 34:
 526                  $character = "&quot;";
 527                  break;
 528                  case 38:
 529                  $character = "&amp;";
 530                  break;
 531                  case 39:
 532                  $character = "&apos;";
 533                  break;
 534                  case 60:
 535                  $character = "&lt;";
 536                  break;
 537                  case 62:
 538                  $character = "&gt;";
 539                  break;
 540                  default:
 541                  if ($code < 32 || $code > 159)
 542                      $character = ("&#".strval($code).";");
 543                  break;
 544              }
 545              $escapeddata .= $character;
 546          }
 547          return $escapeddata;
 548      }
 549  
 550  	function xmlrpc_se($parser, $name, $attrs)
 551      {
 552          global $_xh, $xmlrpcDateTime, $xmlrpcString, $xmlrpc_valid_parents;
 553  
 554          // if invalid xmlrpc already detected, skip all processing
 555          if ($_xh[$parser]['isf'] < 2)
 556          {
 557  
 558          // check for correct element nesting
 559          // top level element can only be of 2 types
 560          if (count($_xh[$parser]['stack']) == 0)
 561          {
 562              if ($name != 'METHODRESPONSE' && $name != 'METHODCALL')
 563              {
 564                  $_xh[$parser]['isf'] = 2;
 565                  $_xh[$parser]['isf_reason'] = 'missing top level xmlrpc element';
 566                  return;
 567              }
 568          }
 569          else
 570          {
 571              // not top level element: see if parent is OK
 572              if (!in_array($_xh[$parser]['stack'][0], $xmlrpc_valid_parents[$name]))
 573              {
 574                  $_xh[$parser]['isf'] = 2;
 575                  $_xh[$parser]['isf_reason'] = "xmlrpc element $name cannot be child of {$_xh[$parser]['stack'][0]}";
 576                  return;
 577              }
 578          }
 579  
 580          switch($name)
 581          {
 582              case 'STRUCT':
 583              case 'ARRAY':
 584                  //$_xh[$parser]['st'].='array(';
 585                  //$_xh[$parser]['cm']++;
 586                  // this last line turns quoting off
 587                  // this means if we get an empty array we'll
 588                  // simply get a bit of whitespace in the eval
 589                  //$_xh[$parser]['qt']=0;
 590  
 591                  // create an empty array to hold child values, and push it onto appropriate stack
 592                  $cur_val = array();
 593                  $cur_val['values'] = array();
 594                  $cur_val['type'] = $name;
 595                  array_unshift($_xh[$parser]['valuestack'], $cur_val);
 596                  break;
 597              case 'METHODNAME':
 598              case 'NAME':
 599                  //$_xh[$parser]['st'].='"';
 600                  $_xh[$parser]['ac']='';
 601                  break;
 602              case 'FAULT':
 603                  $_xh[$parser]['isf']=1;
 604                  break;
 605              case 'PARAM':
 606                  //$_xh[$parser]['st']='';
 607                  // clear value, so we can check later if no value will passed for this param/member
 608                  $_xh[$parser]['value']=null;
 609                  break;
 610              case 'VALUE':
 611                  //$_xh[$parser]['st'].='new xmlrpcval(';
 612                  // look for a value: if this is still true by the
 613                  // time we reach the end tag for value then the type is string
 614                  // by implication
 615                  $_xh[$parser]['vt']='value';
 616                  $_xh[$parser]['ac']='';
 617                  //$_xh[$parser]['qt']=0;
 618                  $_xh[$parser]['lv']=1;
 619                  break;
 620              case 'I4':
 621              case 'INT':
 622              case 'STRING':
 623              case 'BOOLEAN':
 624              case 'DOUBLE':
 625              case 'DATETIME.ISO8601':
 626              case 'BASE64':
 627                  if ($_xh[$parser]['vt']!='value')
 628                  {
 629                      //two data elements inside a value: an error occurred!
 630                      $_xh[$parser]['isf'] = 2;
 631                      $_xh[$parser]['isf_reason'] = "$name element following a {$_xh[$parser]['vt']} element inside a single value";
 632                      return;
 633                  }
 634  
 635                  // reset the accumulator
 636                  $_xh[$parser]['ac']='';
 637  
 638                  /*if ($name=='DATETIME.ISO8601' || $name=='STRING')
 639                  {
 640                      $_xh[$parser]['qt']=1;
 641                      if ($name=='DATETIME.ISO8601')
 642                      {
 643                          $_xh[$parser]['vt']=$xmlrpcDateTime;
 644                      }
 645                  }
 646                  elseif ($name=='BASE64')
 647                  {
 648                      $_xh[$parser]['qt']=2;
 649                  }
 650                  else
 651                  {
 652                      // No quoting is required here -- but
 653                      // at the end of the element we must check
 654                      // for data format errors.
 655                      $_xh[$parser]['qt']=0;
 656                  }*/
 657                  break;
 658              case 'MEMBER':
 659                  //$_xh[$parser]['ac']='';
 660                  // avoid warnings later on if no NAME is found before VALUE inside
 661                  // a struct member predefining member name as NULL
 662                  $_xh[$parser]['valuestack'][0]['name'] = '';
 663                  // clear value, so we can check later if no value will passed for this param/member
 664                  $_xh[$parser]['value']=null;
 665                  break;
 666              case 'DATA':
 667              case 'METHODCALL':
 668              case 'METHODRESPONSE':
 669              case 'PARAMS':
 670                  // valid elements that add little to processing
 671                  break;            
 672              default:
 673                  /// INVALID ELEMENT: RAISE ISF so that it is later recognized!!!
 674                  $_xh[$parser]['isf'] = 2;
 675                  $_xh[$parser]['isf_reason'] = "found not-xmlrpc xml element $name";
 676                  break;
 677          }
 678  
 679          // Save current element name to stack, to validate nesting
 680          array_unshift($_xh[$parser]['stack'], $name);
 681  
 682          if ($name!='VALUE')
 683          {
 684              $_xh[$parser]['lv']=0;
 685          }
 686          }
 687      }
 688  
 689  	function xmlrpc_ee($parser, $name)
 690      {
 691          global $_xh,$xmlrpcTypes,$xmlrpcString,$xmlrpcDateTime;
 692  
 693          if ($_xh[$parser]['isf'] < 2)
 694          {
 695  
 696          // push this element name from stack
 697          // NB: if XML validates, correct opening/closing is guaranteed and
 698          // we do not have to check for $name == $curr_elem.
 699          // we also checked for proper nesting at start of elements...
 700          $curr_elem = array_shift($_xh[$parser]['stack']);        
 701  
 702          switch($name)
 703          {
 704              case 'STRUCT':
 705              case 'ARRAY':
 706                  //if ($_xh[$parser]['cm'] && substr($_xh[$parser]['st'], -1) ==',')
 707                  //{
 708                  //    $_xh[$parser]['st']=substr($_xh[$parser]['st'],0,-1);
 709                  //}
 710                  //$_xh[$parser]['st'].=')';
 711  
 712                  // fetch out of stack array of values, and promote it to current value
 713                  $cur_val = array_shift($_xh[$parser]['valuestack']);
 714                  $_xh[$parser]['value'] = $cur_val['values'];
 715  
 716                  $_xh[$parser]['vt']=strtolower($name);
 717                  //$_xh[$parser]['cm']--;
 718                  break;
 719              case 'NAME':
 720                  //$_xh[$parser]['st'].= $_xh[$parser]['ac'] . '" => ';
 721                  $_xh[$parser]['valuestack'][0]['name'] = $_xh[$parser]['ac'];
 722                  break;
 723              case 'BOOLEAN':
 724              case 'I4':
 725              case 'INT':
 726              case 'STRING':
 727              case 'DOUBLE':
 728              case 'DATETIME.ISO8601':
 729              case 'BASE64':
 730                  $_xh[$parser]['vt']=strtolower($name);
 731                  //if ($_xh[$parser]['qt']==1)            
 732                  if ($name=='STRING')
 733                  {
 734                      // we use double quotes rather than single so backslashification works OK
 735                      //$_xh[$parser]['st'].='"'. $_xh[$parser]['ac'] . '"';
 736                      $_xh[$parser]['value']=$_xh[$parser]['ac'];
 737                  }
 738                  elseif ($name=='DATETIME.ISO8601')
 739                  {
 740                      $_xh[$parser]['vt']=$xmlrpcDateTime;
 741                      $_xh[$parser]['value']=$_xh[$parser]['ac'];
 742                  }
 743                  elseif ($name=='BASE64')
 744                  {
 745                      //$_xh[$parser]['st'].='base64_decode("'. $_xh[$parser]['ac'] . '")';
 746  
 747                      ///@todo check for failure of base64 decoding / catch warnings
 748                      $_xh[$parser]['value']=base64_decode($_xh[$parser]['ac']);
 749                  }
 750                  elseif ($name=='BOOLEAN')
 751                  {
 752                      // special case here: we translate boolean 1 or 0 into PHP
 753                      // constants true or false
 754                      // NB: this simple checks helps a lot sanitizing input, ie no
 755                      // security problems around here
 756                      if ($_xh[$parser]['ac']=='1')
 757                      {
 758                          //$_xh[$parser]['ac']='true';    
 759                          $_xh[