forked from extern/egroupware
Somewhat fork of the xml-rpc classes. Major optimization and some redefinition in the global vars.
This commit is contained in:
parent
46a11b91da
commit
a936811004
@ -43,10 +43,10 @@
|
||||
|
||||
function serializeDebug()
|
||||
{
|
||||
global $_xmlrpc_debuginfo;
|
||||
if ($_xmlrpc_debuginfo != '')
|
||||
// global $_xmlrpc_debuginfo;
|
||||
if ($GLOBALS['_xmlrpc_debuginfo'] != '')
|
||||
{
|
||||
return "<!-- DEBUG INFO:\n\n" . $_xmlrpc_debuginfo . "\n-->\n";
|
||||
return "<!-- DEBUG INFO:\n\n" . $GLOBALS['_xmlrpc_debuginfo'] . "\n-->\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -104,21 +104,21 @@
|
||||
|
||||
function parseRequest($data='')
|
||||
{
|
||||
global $_xh,$HTTP_RAW_POST_DATA;
|
||||
global $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding, $_xmlrpcs_dmap;
|
||||
global $HTTP_RAW_POST_DATA;
|
||||
// global $_xh, $xmlrpcerr, $xmlrpcstr, $xmlrpcerrxml, $xmlrpc_defencoding, $_xmlrpcs_dmap;
|
||||
|
||||
if ($data == '')
|
||||
{
|
||||
$data = $HTTP_RAW_POST_DATA;
|
||||
}
|
||||
$parser = xml_parser_create($xmlrpc_defencoding);
|
||||
$parser = xml_parser_create($GLOBALS['xmlrpc_defencoding']);
|
||||
|
||||
$_xh[$parser] = array();
|
||||
$_xh[$parser]['st'] = '';
|
||||
$_xh[$parser]['cm'] = 0;
|
||||
$_xh[$parser]['isf'] = 0;
|
||||
$_xh[$parser]['params'] = array();
|
||||
$_xh[$parser]['method'] = '';
|
||||
$GLOBALS['_xh'][$parser] = array();
|
||||
$GLOBALS['_xh'][$parser]['st'] = '';
|
||||
$GLOBALS['_xh'][$parser]['cm'] = 0;
|
||||
$GLOBALS['_xh'][$parser]['isf'] = 0;
|
||||
$GLOBALS['_xh'][$parser]['params'] = array();
|
||||
$GLOBALS['_xh'][$parser]['method'] = '';
|
||||
|
||||
// decompose incoming XML into request structure
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
|
||||
@ -129,7 +129,7 @@
|
||||
{
|
||||
// return XML error as a faultCode
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0,
|
||||
$xmlrpcerrxml + xml_get_error_code($parser),
|
||||
$GLOBALS['xmlrpcerrxml'] + xml_get_error_code($parser),
|
||||
sprintf('XML error: %s at line %d',
|
||||
xml_error_string(xml_get_error_code($parser)),
|
||||
xml_get_current_line_number($parser))
|
||||
@ -139,32 +139,34 @@
|
||||
else
|
||||
{
|
||||
xml_parser_free($parser);
|
||||
$m = CreateObject('phpgwapi.xmlrpcmsg',$_xh[$parser]['method']);
|
||||
$m = CreateObject('phpgwapi.xmlrpcmsg',$GLOBALS['_xh'][$parser]['method']);
|
||||
// now add parameters in
|
||||
for($i=0; $i<sizeof($_xh[$parser]['params']); $i++)
|
||||
for($i=0; $i<sizeof($GLOBALS['_xh'][$parser]['params']); $i++)
|
||||
{
|
||||
//print "<!-- " . $_xh[$parser]['params'][$i]. "-->\n";
|
||||
$plist .= "$i - " . $_xh[$parser]['params'][$i]. " \n";
|
||||
$code = '$m->addParam(' . $_xh[$parser]['params'][$i] . ');';
|
||||
//print "<!-- " . $GLOBALS['_xh'][$parser]['params'][$i]. "-->\n";
|
||||
$plist .= "$i - " . $GLOBALS['_xh'][$parser]['params'][$i]. " \n";
|
||||
$code = '$m->addParam(' . $GLOBALS['_xh'][$parser]['params'][$i] . ');';
|
||||
$code = ereg_replace(',,',",'',",$code);
|
||||
eval($code);
|
||||
}
|
||||
// uncomment this to really see what the server's getting!
|
||||
// xmlrpc_debugmsg($plist);
|
||||
// now to deal with the method
|
||||
$methName = $_xh[$parser]['method'];
|
||||
$methName = $GLOBALS['_xh'][$parser]['method'];
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap = $_xmlrpcs_dmap; $sysCall=1;
|
||||
$dmap = $GLOBALS['_xmlrpcs_dmap'];
|
||||
$sysCall=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dmap = $this->dmap; $sysCall=0;
|
||||
$dmap = $this->dmap;
|
||||
$sysCall=0;
|
||||
}
|
||||
if(!isset($dmap[$methName]['function']))
|
||||
{
|
||||
/* these params are xmlrcpvals, need extract */
|
||||
$params = $_xh[$parser]['params'];
|
||||
$params = $GLOBALS['_xh'][$parser]['params'];
|
||||
$code = "\$obj = ExecMethod('" . $methName . "',\$params);";
|
||||
/* echo $code; */
|
||||
/* _debug_array($params); */
|
||||
@ -200,7 +202,7 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$params = $_xh[$parser]['params'];
|
||||
$params = $GLOBALS['_xh'][$parser]['params'];
|
||||
$code = '$r =' . "ExecMethod('" . $dmap[$methName]['function'] . "'" . ',$params);';
|
||||
}
|
||||
eval($code);
|
||||
@ -208,14 +210,14 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$r= CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'),$xmlrpcerr['incorrect_params'],$xmlrpcstr['incorrect_params'].': ' . $sr[1]
|
||||
$r= CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'),$GLOBALS['xmlrpcerr']['incorrect_params'],$GLOBALS['xmlrpcstr']['incorrect_params'].': ' . $sr[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// else prepare error response
|
||||
$r= CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'),$xmlrpcerr['unknown_method'],$xmlrpcstr['unknown_method']);
|
||||
$r= CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'),$GLOBALS['xmlrpcerr']['unknown_method'],$GLOBALS['xmlrpcstr']['unknown_method']);
|
||||
}
|
||||
}
|
||||
return $r;
|
||||
|
@ -39,34 +39,34 @@
|
||||
|
||||
function xml_header()
|
||||
{
|
||||
return "<?xml version=\"1.0\"?>\n<methodCall>\n";
|
||||
return '<?xml version="1.0"?>'."\n".'<methodCall>'."\n";
|
||||
}
|
||||
|
||||
function xml_footer()
|
||||
{
|
||||
return "</methodCall>\n";
|
||||
return '</methodCall>'."\n";
|
||||
}
|
||||
|
||||
function createPayload()
|
||||
{
|
||||
$this->payload=$this->xml_header();
|
||||
$this->payload.="<methodName>" . $this->methodname . "</methodName>\n";
|
||||
$this->payload.='<methodName>' . $this->methodname . '</methodName>'."\n";
|
||||
// if (sizeof($this->params)) {
|
||||
$this->payload.="<params>\n";
|
||||
$this->payload.='<params>'."\n";
|
||||
for($i=0; $i<sizeof($this->params); $i++)
|
||||
{
|
||||
$p=$this->params[$i];
|
||||
$this->payload.="<param>\n" . $p->serialize() . "</param>\n";
|
||||
$this->payload.='<param>'."\n" . $p->serialize() . '</param>'."\n";
|
||||
}
|
||||
$this->payload.="</params>\n";
|
||||
$this->payload.='</params>'."\n";
|
||||
// }
|
||||
$this->payload.=$this->xml_footer();
|
||||
$this->payload=str_replace("\n", "\r\n", $this->payload);
|
||||
}
|
||||
|
||||
function method($meth="")
|
||||
function method($meth='')
|
||||
{
|
||||
if ($meth!="")
|
||||
if ($meth!='')
|
||||
{
|
||||
$this->methodname=$meth;
|
||||
}
|
||||
@ -85,7 +85,7 @@
|
||||
|
||||
function parseResponseFile($fp)
|
||||
{
|
||||
$ipd="";
|
||||
$ipd='';
|
||||
|
||||
while($data=fread($fp, 32768))
|
||||
{
|
||||
@ -94,39 +94,36 @@
|
||||
return $this->parseResponse($ipd);
|
||||
}
|
||||
|
||||
function parseResponse($data="")
|
||||
function parseResponse($data='')
|
||||
{
|
||||
global $_xh,$xmlrpcerr,$xmlrpcstr;
|
||||
global $xmlrpc_defencoding;
|
||||
$parser = xml_parser_create($GLOBALS['xmlrpc_defencoding']);
|
||||
|
||||
$parser = xml_parser_create($xmlrpc_defencoding);
|
||||
|
||||
$_xh[$parser] = array();
|
||||
$_xh[$parser]['st'] = '';
|
||||
$_xh[$parser]['cm'] = 0;
|
||||
$_xh[$parser]['isf'] = 0;
|
||||
$_xh[$parser]['ac'] = '';
|
||||
$_xh[$parser]['qt'] = '';
|
||||
$GLOBALS['_xh'][$parser] = array();
|
||||
$GLOBALS['_xh'][$parser]['st'] = '';
|
||||
$GLOBALS['_xh'][$parser]['cm'] = 0;
|
||||
$GLOBALS['_xh'][$parser]['isf'] = 0;
|
||||
$GLOBALS['_xh'][$parser]['ac'] = '';
|
||||
$GLOBALS['_xh'][$parser]['qt'] = '';
|
||||
|
||||
xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, true);
|
||||
xml_set_element_handler($parser, "xmlrpc_se", "xmlrpc_ee");
|
||||
xml_set_character_data_handler($parser, "xmlrpc_cd");
|
||||
xml_set_default_handler($parser, "xmlrpc_dh");
|
||||
$xmlrpc_value = CreateObject('phpgwapi.xmlrpcval');
|
||||
// $xmlrpc_value = CreateObject('phpgwapi.xmlrpcval');
|
||||
|
||||
$hdrfnd=0;
|
||||
if ($this->debug)
|
||||
{
|
||||
print "<PRE>---GOT---\n" . htmlspecialchars($data) . "\n---END---\n</PRE>";
|
||||
print '<PRE>---GOT---'."\n" . htmlspecialchars($data) . "\n".'---END---'."\n".'</PRE>';
|
||||
}
|
||||
// see if we got an HTTP 200 OK, else bomb
|
||||
// but only do this if we're using the HTTP protocol.
|
||||
if (ereg("^HTTP",$data) && !ereg("^HTTP/[0-9\.]+ 200 ", $data))
|
||||
{
|
||||
$errstr= substr($data, 0, strpos($data, "\n")-1);
|
||||
error_log("HTTP error, got response: " .$errstr);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0, $xmlrpcerr['http_error'],
|
||||
$xmlrpcstr['http_error'] . " (" . $errstr . ")");
|
||||
error_log('HTTP error, got response: ' .$errstr);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0, $GLOBALS['xmlrpcerr']['http_error'],
|
||||
$GLOBALS['xmlrpcstr']['http_error'] . ' (' . $errstr . ')');
|
||||
xml_parser_free($parser);
|
||||
return $r;
|
||||
}
|
||||
@ -142,7 +139,7 @@
|
||||
// thanks to Peter Kocks <peter.kocks@baygate.com>
|
||||
if((xml_get_current_line_number($parser)) == 1)
|
||||
{
|
||||
$errstr = "XML error at line 1, check URL";
|
||||
$errstr = 'XML error at line 1, check URL';
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -151,33 +148,33 @@
|
||||
xml_get_current_line_number($parser));
|
||||
}
|
||||
error_log($errstr);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'), $xmlrpcerr['invalid_return'],$xmlrpcstr['invalid_return']);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'), $GLOBALS['xmlrpcerr']['invalid_return'],$GLOBALS['xmlrpcstr']['invalid_return']);
|
||||
xml_parser_free($parser);
|
||||
return $r;
|
||||
}
|
||||
xml_parser_free($parser);
|
||||
if ($this->debug)
|
||||
{
|
||||
print "<PRE>---EVALING---[" .
|
||||
strlen($_xh[$parser]['st']) . " chars]---\n" .
|
||||
htmlspecialchars($_xh[$parser]['st']) . ";\n---END---</PRE>";
|
||||
print '<PRE>---EVALING---[' .
|
||||
strlen($GLOBALS['_xh'][$parser]['st']) . ' chars]---'."\n" .
|
||||
htmlspecialchars($GLOBALS['_xh'][$parser]['st']) . ';'."\n".'---END---</PRE>';
|
||||
}
|
||||
if (strlen($_xh[$parser]['st']) == 0)
|
||||
if (strlen($GLOBALS['_xh'][$parser]['st']) == 0)
|
||||
{
|
||||
// then something odd has happened
|
||||
// and it's time to generate a client side error
|
||||
// indicating something odd went on
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'), $xmlrpcerr['invalid_return'],$xmlrpcstr['invalid_return']);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',CreateObject('phpgwapi.xmlrpcval'), $GLOBALS['xmlrpcerr']['invalid_return'],$GLOBALS['xmlrpcstr']['invalid_return']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$code = '$v=' . $_xh[$parser]['st'] . '; $allOK=1;';
|
||||
$code = '$v=' . $GLOBALS['_xh'][$parser]['st'] . '; $allOK=1;';
|
||||
$code = ereg_replace(',,',",'',",$code);
|
||||
eval($code);
|
||||
if ($_xh[$parser]['isf'])
|
||||
if ($GLOBALS['_xh'][$parser]['isf'])
|
||||
{
|
||||
$f = $v->structmem("faultCode");
|
||||
$fs = $v->structmem("faultString");
|
||||
$f = $v->structmem('faultCode');
|
||||
$fs = $v->structmem('faultString');
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',$v, $f->scalarval(), $fs->scalarval());
|
||||
}
|
||||
else
|
||||
@ -185,7 +182,7 @@
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',$v);
|
||||
}
|
||||
}
|
||||
$r->hdrs=split("\r?\n", $_xh[$parser]['ha'][1]);
|
||||
$r->hdrs=split("\r?\n", $GLOBALS['_xh'][$parser]['ha'][1]);
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
|
@ -66,29 +66,29 @@
|
||||
|
||||
function serialize()
|
||||
{
|
||||
$rs="<methodResponse>\n";
|
||||
$rs='<methodResponse>'."\n";
|
||||
if ($this->fn)
|
||||
{
|
||||
$rs .= "<fault>
|
||||
$rs .= '<fault>
|
||||
<value>
|
||||
<struct>
|
||||
<member>
|
||||
<name>faultCode</name>
|
||||
<value><int>" . $this->fn . "</int></value>
|
||||
<value><int>' . $this->fn . '</int></value>
|
||||
</member>
|
||||
<member>
|
||||
<name>faultString</name>
|
||||
<value><string>" . $this->fs . "</string></value>
|
||||
<value><string>' . $this->fs . '</string></value>
|
||||
</member>
|
||||
</struct>
|
||||
</value>
|
||||
</fault>";
|
||||
</fault>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$rs .= "<params>\n<param>\n" . @$this->xv->serialize() . "</param>\n</params>";
|
||||
$rs .= '<params>'."\n".'<param>'."\n".@$this->xv->serialize().'</param>'."\n".'</params>';
|
||||
}
|
||||
$rs.="\n</methodResponse>";
|
||||
$rs.="\n".'</methodResponse>';
|
||||
return $rs;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
function xmlrpcval($val=-1, $type='')
|
||||
{
|
||||
global $xmlrpcTypes;
|
||||
$this->me = array();
|
||||
$this->mytype = 0;
|
||||
if ($val!=-1 || $type!='')
|
||||
@ -34,15 +33,15 @@
|
||||
{
|
||||
$type='string';
|
||||
}
|
||||
if ($xmlrpcTypes[$type]==1)
|
||||
if ($GLOBALS['xmlrpcTypes'][$type]==1)
|
||||
{
|
||||
$this->addScalar($val,$type);
|
||||
}
|
||||
elseif ($xmlrpcTypes[$type]==2)
|
||||
elseif ($GLOBALS['xmlrpcTypes'][$type]==2)
|
||||
{
|
||||
$this->addArray($val);
|
||||
}
|
||||
elseif ($xmlrpcTypes[$type]==3)
|
||||
elseif ($GLOBALS['xmlrpcTypes'][$type]==3)
|
||||
{
|
||||
$this->addStruct($val);
|
||||
}
|
||||
@ -51,25 +50,23 @@
|
||||
|
||||
function addScalar($val, $type='string')
|
||||
{
|
||||
global $xmlrpcTypes, $xmlrpcBoolean;
|
||||
|
||||
if ($this->mytype==1)
|
||||
{
|
||||
echo "<B>xmlrpcval</B>: scalar can have only one value<BR>";
|
||||
echo '<B>xmlrpcval</B>: scalar can have only one value<BR>';
|
||||
return 0;
|
||||
}
|
||||
$typeof=$xmlrpcTypes[$type];
|
||||
$typeof=$GLOBALS['xmlrpcTypes'][$type];
|
||||
if ($typeof!=1)
|
||||
{
|
||||
echo "<B>xmlrpcval</B>: not a scalar type (${typeof})<BR>";
|
||||
echo '<B>xmlrpcval</B>: not a scalar type ('.$typeof.')<BR>';
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ($type==$xmlrpcBoolean)
|
||||
if ($type==xmlrpcBoolean)
|
||||
{
|
||||
if (strcasecmp($val,"true")==0 ||
|
||||
if (strcasecmp($val,'true')==0 ||
|
||||
$val==1 || ($val==true &&
|
||||
strcasecmp($val,"false")))
|
||||
strcasecmp($val,'false')))
|
||||
{
|
||||
$val=1;
|
||||
}
|
||||
@ -82,9 +79,9 @@
|
||||
if ($this->mytype==2)
|
||||
{
|
||||
// we're adding to an array here
|
||||
$ar=$this->me["array"];
|
||||
$ar=$this->me['array'];
|
||||
$ar[] = CreateObject('phpgwapi.xmlrpcval',$val, $type);
|
||||
$this->me["array"]=$ar;
|
||||
$this->me['array']=$ar;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -97,28 +94,27 @@
|
||||
|
||||
function addArray($vals)
|
||||
{
|
||||
global $xmlrpcTypes;
|
||||
if ($this->mytype!=0)
|
||||
{
|
||||
echo "<B>xmlrpcval</B>: already initialized as a [" . $this->kindOf() . "]<BR>";
|
||||
echo '<B>xmlrpcval</B>: already initialized as a [' . $this->kindOf() . ']<BR>';
|
||||
return 0;
|
||||
}
|
||||
|
||||
$this->mytype=$xmlrpcTypes["array"];
|
||||
$this->me["array"]=$vals;
|
||||
$this->mytype=$GLOBALS['xmlrpcTypes']['array'];
|
||||
$this->me['array']=$vals;
|
||||
return 1;
|
||||
}
|
||||
|
||||
function addStruct($vals)
|
||||
{
|
||||
global $xmlrpcTypes;
|
||||
// global $xmlrpcTypes;
|
||||
if ($this->mytype!=0)
|
||||
{
|
||||
echo "<B>xmlrpcval</B>: already initialized as a [" . $this->kindOf() . "]<BR>";
|
||||
echo '<B>xmlrpcval</B>: already initialized as a [' . $this->kindOf() . ']<BR>';
|
||||
return 0;
|
||||
}
|
||||
$this->mytype=$xmlrpcTypes["struct"];
|
||||
$this->me["struct"]=$vals;
|
||||
$this->mytype=$GLOBALS['xmlrpcTypes']['struct'];
|
||||
$this->me['struct']=$vals;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -127,12 +123,12 @@
|
||||
reset($ar);
|
||||
while (list($key,$val) = each($ar))
|
||||
{
|
||||
echo "$key => $val<br>";
|
||||
echo $key.' => '.$val.'<br>';
|
||||
if ($key == 'array')
|
||||
{
|
||||
while (list($key2,$val2) = each($val))
|
||||
{
|
||||
echo "-- $key2 => $val2<br>";
|
||||
echo '-- '.$key2.' => '.$val2.'<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -143,64 +139,62 @@
|
||||
switch($this->mytype)
|
||||
{
|
||||
case 3:
|
||||
return "struct";
|
||||
return 'struct';
|
||||
break;
|
||||
case 2:
|
||||
return "array";
|
||||
return 'array';
|
||||
break;
|
||||
case 1:
|
||||
return "scalar";
|
||||
return 'scalar';
|
||||
break;
|
||||
default:
|
||||
return "undef";
|
||||
return 'undef';
|
||||
}
|
||||
}
|
||||
|
||||
function serializedata($typ, $val)
|
||||
{
|
||||
$rs='';
|
||||
global $xmlrpcTypes, $xmlrpcBase64, $xmlrpcString,$xmlrpcBoolean;
|
||||
|
||||
if($typ)
|
||||
{
|
||||
switch($xmlrpcTypes[$typ])
|
||||
switch($GLOBALS['xmlrpcTypes'][$typ])
|
||||
{
|
||||
case 3:
|
||||
// struct
|
||||
$rs.="<struct>\n";
|
||||
$rs .= '<struct>'."\n";
|
||||
reset($val);
|
||||
while(list($key2, $val2)=each($val))
|
||||
{
|
||||
$rs .= "<member><name>${key2}</name>\n";
|
||||
$rs .= $this->serializeval($val2);
|
||||
$rs .= "</member>\n";
|
||||
$rs .= '<member><name>'.$key2.'</name>'."\n".$this->serializeval($val2).'</member>'."\n";
|
||||
}
|
||||
$rs.="</struct>";
|
||||
$rs .= '</struct>';
|
||||
break;
|
||||
case 2:
|
||||
// array
|
||||
$rs.="<array>\n<data>\n";
|
||||
$rs .= '<array>'."\n".'<data>'."\n";
|
||||
for($i=0; $i<sizeof($val); $i++)
|
||||
{
|
||||
$rs .= $this->serializeval($val[$i]);
|
||||
}
|
||||
$rs.="</data>\n</array>";
|
||||
$rs .= '</data>'."\n".'</array>';
|
||||
break;
|
||||
case 1:
|
||||
$rs .= '<'.$typ.'>';
|
||||
switch ($typ)
|
||||
{
|
||||
case $xmlrpcBase64:
|
||||
$rs.="<${typ}>" . base64_encode($val) . "</${typ}>";
|
||||
case xmlrpcBase64:
|
||||
$rs.= base64_encode($val);
|
||||
break;
|
||||
case $xmlrpcBoolean:
|
||||
$rs.="<${typ}>" . ($val ? "1" : "0") . "</${typ}>";
|
||||
break;
|
||||
case $xmlrpcString:
|
||||
$rs.="<${typ}>" . htmlspecialchars($val). "</${typ}>";
|
||||
case xmlrpcBoolean:
|
||||
$rs.= ($val ? '1' : '0');
|
||||
break;
|
||||
case xmlrpcString:
|
||||
$rs.= htmlspecialchars($val);
|
||||
break;
|
||||
default:
|
||||
$rs.="<${typ}>${val}</${typ}>";
|
||||
$rs.= $val;
|
||||
}
|
||||
$rs .= '</'.$typ.'>';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -216,37 +210,35 @@
|
||||
|
||||
function serializeval($o)
|
||||
{
|
||||
global $xmlrpcTypes;
|
||||
$rs="";
|
||||
$rs='';
|
||||
$ar=$o->me;
|
||||
reset($ar);
|
||||
list($typ, $val) = each($ar);
|
||||
$rs.="<value>";
|
||||
$rs.='<value>';
|
||||
$rs.=$this->serializedata($typ, $val);
|
||||
$rs.="</value>\n";
|
||||
$rs.='</value>'."\n";
|
||||
return $rs;
|
||||
}
|
||||
|
||||
function structmem($m)
|
||||
{
|
||||
$nv=$this->me["struct"][$m];
|
||||
$nv=$this->me['struct'][$m];
|
||||
return $nv;
|
||||
}
|
||||
|
||||
function structreset()
|
||||
{
|
||||
reset($this->me["struct"]);
|
||||
reset($this->me['struct']);
|
||||
}
|
||||
|
||||
function structeach()
|
||||
{
|
||||
return each($this->me["struct"]);
|
||||
return each($this->me['struct']);
|
||||
}
|
||||
|
||||
function getval()
|
||||
{
|
||||
// UNSTABLE
|
||||
global $xmlrpcBoolean, $xmlrpcBase64;
|
||||
reset($this->me);
|
||||
list($a,$b)=each($this->me);
|
||||
// contributed by I Sofer, 2001-03-24
|
||||
@ -284,7 +276,6 @@
|
||||
|
||||
function scalarval()
|
||||
{
|
||||
global $xmlrpcBoolean, $xmlrpcBase64;
|
||||
reset($this->me);
|
||||
list($a,$b)=each($this->me);
|
||||
return $b;
|
||||
@ -292,19 +283,18 @@
|
||||
|
||||
function scalartyp()
|
||||
{
|
||||
global $xmlrpcI4, $xmlrpcInt;
|
||||
reset($this->me);
|
||||
list($a,$b)=each($this->me);
|
||||
if ($a==$xmlrpcI4)
|
||||
if ($a==xmlrpcI4)
|
||||
{
|
||||
$a=$xmlrpcInt;
|
||||
$a=xmlrpcInt;
|
||||
}
|
||||
return $a;
|
||||
}
|
||||
|
||||
function arraymem($m)
|
||||
{
|
||||
$nv=$this->me["array"][$m];
|
||||
$nv=$this->me['array'][$m];
|
||||
return $nv;
|
||||
}
|
||||
|
||||
|
@ -31,29 +31,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
$xmlrpcI4 = 'i4';
|
||||
$xmlrpcInt = 'int';
|
||||
$xmlrpcBoolean = 'boolean';
|
||||
$xmlrpcDouble = 'double';
|
||||
$xmlrpcString = 'string';
|
||||
$xmlrpcDateTime = 'dateTime.iso8601';
|
||||
$xmlrpcBase64 = 'base64';
|
||||
$xmlrpcArray = 'array';
|
||||
$xmlrpcStruct = 'struct';
|
||||
define('xmlrpcI4','i4');
|
||||
define('xmlrpcInt','int');
|
||||
define('xmlrpcBoolean','boolean');
|
||||
define('xmlrpcDouble','double');
|
||||
define('xmlrpcString','string');
|
||||
define('xmlrpcDateTime','dateTime.iso8601');
|
||||
define('xmlrpcBase64','base64');
|
||||
define('xmlrpcArray','array');
|
||||
define('xmlrpcStruct','struct');
|
||||
|
||||
$xmlrpcTypes = array(
|
||||
$xmlrpcI4 => 1,
|
||||
$xmlrpcInt => 1,
|
||||
$xmlrpcBoolean => 1,
|
||||
$xmlrpcString => 1,
|
||||
$xmlrpcDouble => 1,
|
||||
$xmlrpcDateTime => 1,
|
||||
$xmlrpcBase64 => 1,
|
||||
$xmlrpcArray => 2,
|
||||
$xmlrpcStruct => 3
|
||||
$GLOBALS['xmlrpcTypes'] = array(
|
||||
xmlrpcI4 => 1,
|
||||
xmlrpcInt => 1,
|
||||
xmlrpcBoolean => 1,
|
||||
xmlrpcString => 1,
|
||||
xmlrpcDouble => 1,
|
||||
xmlrpcDateTime => 1,
|
||||
xmlrpcBase64 => 1,
|
||||
xmlrpcArray => 2,
|
||||
xmlrpcStruct => 3
|
||||
);
|
||||
|
||||
$xmlEntities=array(
|
||||
$GLOBALS['xmlEntities']=array(
|
||||
'amp' => '&',
|
||||
'quot' => '"',
|
||||
'lt' => '<',
|
||||
@ -61,29 +61,29 @@
|
||||
'apos' => "'"
|
||||
);
|
||||
|
||||
$xmlrpcerr['unknown_method'] = 1;
|
||||
$xmlrpcstr['unknown_method'] = 'Unknown method';
|
||||
$xmlrpcerr['invalid_return'] = 2;
|
||||
$xmlrpcstr['invalid_return'] = 'Invalid return payload: enabling 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.";
|
||||
$GLOBALS['xmlrpcerr']['unknown_method'] = 1;
|
||||
$GLOBALS['xmlrpcstr']['unknown_method'] = 'Unknown method';
|
||||
$GLOBALS['xmlrpcerr']['invalid_return'] = 2;
|
||||
$GLOBALS['xmlrpcstr']['invalid_return'] = 'Invalid return payload: enabling debugging to examine incoming payload';
|
||||
$GLOBALS['xmlrpcerr']['incorrect_params'] = 3;
|
||||
$GLOBALS['xmlrpcstr']['incorrect_params'] = 'Incorrect parameters passed to method';
|
||||
$GLOBALS['xmlrpcerr']['introspect_unknown'] = 4;
|
||||
$GLOBALS['xmlrpcstr']['introspect_unknown'] = "Can't introspect: method unknown";
|
||||
$GLOBALS['xmlrpcerr']['http_error'] = 5;
|
||||
$GLOBALS['xmlrpcstr']['http_error'] = "Didn't receive 200 OK from remote server.";
|
||||
|
||||
$xmlrpc_defencoding = 'UTF-8';
|
||||
$GLOBALS['xmlrpc_defencoding'] = 'UTF-8';
|
||||
|
||||
$xmlrpcName = 'XML-RPC for PHP';
|
||||
$xmlrpcVersion = '1.0b9';
|
||||
$GLOBALS['xmlrpcName'] = 'XML-RPC for PHP';
|
||||
$GLOBALS['xmlrpcVersion'] = '1.0b9';
|
||||
|
||||
// let user errors start at 800
|
||||
$xmlrpcerruser = 800;
|
||||
$GLOBALS['xmlrpcerruser'] = 800;
|
||||
// let XML parse errors start at 100
|
||||
$xmlrpcerrxml = 100;
|
||||
$GLOBALS['xmlrpcerrxml'] = 100;
|
||||
|
||||
// formulate backslashes for escaping regexp
|
||||
$xmlrpc_backslash = chr(92) . chr(92);
|
||||
$GLOBALS['xmlrpc_backslash'] = chr(92) . chr(92);
|
||||
|
||||
// used to store state during parsing
|
||||
// quick explanation of components:
|
||||
@ -97,11 +97,11 @@
|
||||
// params - used to store parameters in method calls
|
||||
// method - used to store method name
|
||||
|
||||
$_xh=array();
|
||||
$GLOBALS['_xh']=array();
|
||||
|
||||
function xmlrpc_entity_decode($string)
|
||||
{
|
||||
$top = split("&", $string);
|
||||
$top = split('&', $string);
|
||||
$op = '';
|
||||
$i = 0;
|
||||
while($i<sizeof($top))
|
||||
@ -129,11 +129,9 @@
|
||||
|
||||
function xmlrpc_lookup_entity($ent)
|
||||
{
|
||||
global $xmlEntities;
|
||||
|
||||
if (isset($xmlEntities[strtolower($ent)]))
|
||||
if (isset($GLOBALS['xmlEntities'][strtolower($ent)]))
|
||||
{
|
||||
return $xmlEntities[strtolower($ent)];
|
||||
return $GLOBALS['xmlEntities'][strtolower($ent)];
|
||||
}
|
||||
if (ereg("^#([0-9]+)$", $ent, $regs))
|
||||
{
|
||||
@ -144,35 +142,33 @@
|
||||
|
||||
function xmlrpc_se($parser, $name, $attrs)
|
||||
{
|
||||
global $_xh, $xmlrpcDateTime, $xmlrpcString;
|
||||
|
||||
switch($name)
|
||||
{
|
||||
case 'STRUCT':
|
||||
case 'ARRAY':
|
||||
$_xh[$parser]['st'] .= 'array(';
|
||||
$_xh[$parser]['cm']++;
|
||||
$GLOBALS['_xh'][$parser]['st'] .= 'array(';
|
||||
$GLOBALS['_xh'][$parser]['cm']++;
|
||||
// this last line turns quoting off
|
||||
// this means if we get an empty array we'll
|
||||
// simply get a bit of whitespace in the eval
|
||||
$_xh[$parser]['qt']=0;
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
break;
|
||||
case 'NAME':
|
||||
$_xh[$parser]['st'] .= "'";
|
||||
$_xh[$parser]['ac'] = '';
|
||||
$GLOBALS['_xh'][$parser]['st'] .= "'";
|
||||
$GLOBALS['_xh'][$parser]['ac'] = '';
|
||||
break;
|
||||
case 'FAULT':
|
||||
$_xh[$parser]['isf'] = 1;
|
||||
$GLOBALS['_xh'][$parser]['isf'] = 1;
|
||||
break;
|
||||
case 'PARAM':
|
||||
$_xh[$parser]['st'] = '';
|
||||
$GLOBALS['_xh'][$parser]['st'] = '';
|
||||
break;
|
||||
case 'VALUE':
|
||||
$_xh[$parser]['st'] .= " CreateObject('phpgwapi.xmlrpcval',";
|
||||
$_xh[$parser]['vt'] = $xmlrpcString;
|
||||
$_xh[$parser]['ac'] = '';
|
||||
$_xh[$parser]['qt'] = 0;
|
||||
$_xh[$parser]['lv'] = 1;
|
||||
$GLOBALS['_xh'][$parser]['st'] .= " CreateObject('phpgwapi.xmlrpcval',";
|
||||
$GLOBALS['_xh'][$parser]['vt'] = xmlrpcString;
|
||||
$GLOBALS['_xh'][$parser]['ac'] = '';
|
||||
$GLOBALS['_xh'][$parser]['qt'] = 0;
|
||||
$GLOBALS['_xh'][$parser]['lv'] = 1;
|
||||
// look for a value: if this is still 1 by the
|
||||
// time we reach the first data segment then the type is string
|
||||
// by implication and we need to add in a quote
|
||||
@ -184,30 +180,30 @@
|
||||
case 'DOUBLE':
|
||||
case 'DATETIME.ISO8601':
|
||||
case 'BASE64':
|
||||
$_xh[$parser]['ac']=''; // reset the accumulator
|
||||
$GLOBALS['_xh'][$parser]['ac']=''; // reset the accumulator
|
||||
|
||||
if ($name=='DATETIME.ISO8601' || $name=='STRING')
|
||||
{
|
||||
$_xh[$parser]['qt']=1;
|
||||
$GLOBALS['_xh'][$parser]['qt']=1;
|
||||
if ($name=='DATETIME.ISO8601')
|
||||
{
|
||||
$_xh[$parser]['vt']=$xmlrpcDateTime;
|
||||
$GLOBALS['_xh'][$parser]['vt']=xmlrpcDateTime;
|
||||
}
|
||||
}
|
||||
elseif($name=='BASE64')
|
||||
{
|
||||
$_xh[$parser]['qt']=2;
|
||||
$GLOBALS['_xh'][$parser]['qt']=2;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No quoting is required here -- but
|
||||
// at the end of the element we must check
|
||||
// for data format errors.
|
||||
$_xh[$parser]['qt']=0;
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
}
|
||||
break;
|
||||
case 'MEMBER':
|
||||
$_xh[$parser]['ac']='';
|
||||
$GLOBALS['_xh'][$parser]['ac']='';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -215,41 +211,39 @@
|
||||
|
||||
if ($name!='VALUE')
|
||||
{
|
||||
$_xh[$parser]['lv']=0;
|
||||
$GLOBALS['_xh'][$parser]['lv']=0;
|
||||
}
|
||||
}
|
||||
|
||||
function xmlrpc_ee($parser, $name)
|
||||
{
|
||||
global $_xh,$xmlrpcTypes,$xmlrpcString;
|
||||
|
||||
switch($name)
|
||||
{
|
||||
case 'STRUCT':
|
||||
case 'ARRAY':
|
||||
if ($_xh[$parser]['cm'] && substr($_xh[$parser]['st'], -1) ==',')
|
||||
if ($GLOBALS['_xh'][$parser]['cm'] && substr($GLOBALS['_xh'][$parser]['st'], -1) ==',')
|
||||
{
|
||||
$_xh[$parser]['st']=substr($_xh[$parser]['st'],0,-1);
|
||||
$GLOBALS['_xh'][$parser]['st']=substr($GLOBALS['_xh'][$parser]['st'],0,-1);
|
||||
}
|
||||
$_xh[$parser]['st'].=")";
|
||||
$_xh[$parser]['vt']=strtolower($name);
|
||||
$_xh[$parser]['cm']--;
|
||||
$GLOBALS['_xh'][$parser]['st'].=')';
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
$GLOBALS['_xh'][$parser]['cm']--;
|
||||
break;
|
||||
case 'NAME':
|
||||
$_xh[$parser]['st'].= $_xh[$parser]['ac'] . "' => ";
|
||||
$GLOBALS['_xh'][$parser]['st'].= $GLOBALS['_xh'][$parser]['ac'] . "' => ";
|
||||
break;
|
||||
case 'BOOLEAN':
|
||||
// special case here: we translate boolean 1 or 0 into PHP
|
||||
// constants true or false
|
||||
if ($_xh[$parser]['ac']=='1')
|
||||
if ($GLOBALS['_xh'][$parser]['ac']=='1')
|
||||
{
|
||||
$_xh[$parser]['ac']='True';
|
||||
$GLOBALS['_xh'][$parser]['ac']='True';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_xh[$parser]['ac']='false';
|
||||
$GLOBALS['_xh'][$parser]['ac']='false';
|
||||
}
|
||||
$_xh[$parser]['vt']=strtolower($name);
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
// Drop through intentionally.
|
||||
case 'I4':
|
||||
case 'INT':
|
||||
@ -257,138 +251,137 @@
|
||||
case 'DOUBLE':
|
||||
case 'DATETIME.ISO8601':
|
||||
case 'BASE64':
|
||||
if ($_xh[$parser]['qt']==1)
|
||||
if ($GLOBALS['_xh'][$parser]['qt']==1)
|
||||
{
|
||||
// we use double quotes rather than single so backslashification works OK
|
||||
$_xh[$parser]['st'].="\"". $_xh[$parser]['ac'] . "\"";
|
||||
$GLOBALS['_xh'][$parser]['st'].='"'. $GLOBALS['_xh'][$parser]['ac'] . '"';
|
||||
}
|
||||
elseif ($_xh[$parser]['qt']==2)
|
||||
elseif ($GLOBALS['_xh'][$parser]['qt']==2)
|
||||
{
|
||||
$_xh[$parser]['st'].="base64_decode('". $_xh[$parser]['ac'] . "')";
|
||||
$GLOBALS['_xh'][$parser]['st'].="base64_decode('". $GLOBALS['_xh'][$parser]['ac'] . "')";
|
||||
}
|
||||
else if ($name=='BOOLEAN')
|
||||
{
|
||||
$_xh[$parser]['st'].=$_xh[$parser]['ac'];
|
||||
$GLOBALS['_xh'][$parser]['st'].=$GLOBALS['_xh'][$parser]['ac'];
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have an I4, INT or a DOUBLE
|
||||
// we must check that only 0123456789-.<space> are characters here
|
||||
if (!ereg("^\-?[0123456789 \t\.]+$", $_xh[$parser]['ac']))
|
||||
if (!ereg("^\-?[0123456789 \t\.]+$", $GLOBALS['_xh'][$parser]['ac']))
|
||||
{
|
||||
// TODO: find a better way of throwing an error
|
||||
// than this!
|
||||
error_log("XML-RPC: non numeric value received in INT or DOUBLE");
|
||||
$_xh[$parser]['st'].="ERROR_NON_NUMERIC_FOUND";
|
||||
error_log('XML-RPC: non numeric value received in INT or DOUBLE');
|
||||
$GLOBALS['_xh'][$parser]['st'].='ERROR_NON_NUMERIC_FOUND';
|
||||
}
|
||||
else
|
||||
{
|
||||
// it's ok, add it on
|
||||
$_xh[$parser]['st'].=$_xh[$parser]['ac'];
|
||||
$GLOBALS['_xh'][$parser]['st'].=$GLOBALS['_xh'][$parser]['ac'];
|
||||
}
|
||||
}
|
||||
$_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
|
||||
$_xh[$parser]['lv']=3; // indicate we've found a value
|
||||
$GLOBALS['_xh'][$parser]['ac']=""; $GLOBALS['_xh'][$parser]['qt']=0;
|
||||
$GLOBALS['_xh'][$parser]['lv']=3; // indicate we've found a value
|
||||
break;
|
||||
case 'VALUE':
|
||||
// deal with a string value
|
||||
if (strlen($_xh[$parser]['ac'])>0 &&
|
||||
$_xh[$parser]['vt']==$xmlrpcString)
|
||||
if (strlen($GLOBALS['_xh'][$parser]['ac'])>0 &&
|
||||
$GLOBALS['_xh'][$parser]['vt']==xmlrpcString)
|
||||
{
|
||||
$_xh[$parser]['st'].="\"". $_xh[$parser]['ac'] . "\"";
|
||||
$GLOBALS['_xh'][$parser]['st'].='"'. $GLOBALS['_xh'][$parser]['ac'] . '"';
|
||||
}
|
||||
// This if() detects if no scalar was inside <VALUE></VALUE>
|
||||
// and pads an empty "".
|
||||
if($_xh[$parser]['st'][strlen($_xh[$parser]['st'])-1] == '(')
|
||||
if($GLOBALS['_xh'][$parser]['st'][strlen($GLOBALS['_xh'][$parser]['st'])-1] == '(')
|
||||
{
|
||||
$_xh[$parser]['st'].= '""';
|
||||
$GLOBALS['_xh'][$parser]['st'].= '""';
|
||||
}
|
||||
$_xh[$parser]['st'].=", '" . $_xh[$parser]['vt'] . "')";
|
||||
if ($_xh[$parser]['cm'])
|
||||
$GLOBALS['_xh'][$parser]['st'].=", '" . $GLOBALS['_xh'][$parser]['vt'] . "')";
|
||||
if ($GLOBALS['_xh'][$parser]['cm'])
|
||||
{
|
||||
$_xh[$parser]['st'].=",";
|
||||
$GLOBALS['_xh'][$parser]['st'].=",";
|
||||
}
|
||||
break;
|
||||
case 'MEMBER':
|
||||
$_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
|
||||
break;
|
||||
$GLOBALS['_xh'][$parser]['ac']="";
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
break;
|
||||
case 'DATA':
|
||||
$_xh[$parser]['ac']=""; $_xh[$parser]['qt']=0;
|
||||
$GLOBALS['_xh'][$parser]['ac']="";
|
||||
$GLOBALS['_xh'][$parser]['qt']=0;
|
||||
break;
|
||||
case 'PARAM':
|
||||
$_xh[$parser]['params'][]=$_xh[$parser]['st'];
|
||||
$GLOBALS['_xh'][$parser]['params'][]=$GLOBALS['_xh'][$parser]['st'];
|
||||
break;
|
||||
case 'METHODNAME':
|
||||
$_xh[$parser]['method']=ereg_replace("^[\n\r\t ]+", "", $_xh[$parser]['ac']);
|
||||
$GLOBALS['_xh'][$parser]['method']=ereg_replace("^[\n\r\t ]+", "", $GLOBALS['_xh'][$parser]['ac']);
|
||||
break;
|
||||
case 'BOOLEAN':
|
||||
// special case here: we translate boolean 1 or 0 into PHP
|
||||
// constants true or false
|
||||
if ($_xh[$parser]['ac']=='1')
|
||||
if ($GLOBALS['_xh'][$parser]['ac']=='1')
|
||||
{
|
||||
$_xh[$parser]['ac']="True";
|
||||
$GLOBALS['_xh'][$parser]['ac']='True';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_xh[$parser]['ac']="false";
|
||||
$GLOBALS['_xh'][$parser]['ac']='false';
|
||||
}
|
||||
$_xh[$parser]['vt']=strtolower($name);
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// if it's a valid type name, set the type
|
||||
if (isset($xmlrpcTypes[strtolower($name)]))
|
||||
if (isset($GLOBALS['xmlrpcTypes'][strtolower($name)]))
|
||||
{
|
||||
$_xh[$parser]['vt']=strtolower($name);
|
||||
$GLOBALS['_xh'][$parser]['vt']=strtolower($name);
|
||||
}
|
||||
}
|
||||
|
||||
function xmlrpc_cd($parser, $data)
|
||||
{
|
||||
global $_xh, $xmlrpc_backslash;
|
||||
|
||||
//if (ereg("^[\n\r \t]+$", $data)) return;
|
||||
// print "adding [${data}]\n";
|
||||
|
||||
if ($_xh[$parser]['lv']!=3)
|
||||
if ($GLOBALS['_xh'][$parser]['lv']!=3)
|
||||
{
|
||||
// "lookforvalue==3" means that we've found an entire value
|
||||
// and should discard any further character data
|
||||
if ($_xh[$parser]['lv']==1)
|
||||
if ($GLOBALS['_xh'][$parser]['lv']==1)
|
||||
{
|
||||
// if we've found text and we're just in a <value> then
|
||||
// turn quoting on, as this will be a string
|
||||
$_xh[$parser]['qt']=1;
|
||||
$GLOBALS['_xh'][$parser]['qt']=1;
|
||||
// and say we've found a value
|
||||
$_xh[$parser]['lv']=2;
|
||||
$GLOBALS['_xh'][$parser]['lv']=2;
|
||||
}
|
||||
if (isset($_xh[$parser]['qt']) && $_xh[$parser]['qt'])
|
||||
if (isset($GLOBALS['_xh'][$parser]['qt']) && $GLOBALS['_xh'][$parser]['qt'])
|
||||
{
|
||||
// quoted string: replace characters that eval would
|
||||
// do special things with
|
||||
$_xh[$parser]['ac'].=str_replace('$', '\$',
|
||||
$GLOBALS['_xh'][$parser]['ac'].=str_replace('$', '\$',
|
||||
str_replace('"', '\"',
|
||||
str_replace(chr(92),$xmlrpc_backslash, $data)));
|
||||
str_replace(chr(92),xmlrpc_backslash, $data)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$_xh[$parser]['ac'].=$data;
|
||||
$GLOBALS['_xh'][$parser]['ac'].=$data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function xmlrpc_dh($parser, $data)
|
||||
{
|
||||
global $_xh;
|
||||
if (substr($data, 0, 1) == "&" && substr($data, -1, 1) == ";")
|
||||
if (substr($data, 0, 1) == '&' && substr($data, -1, 1) == ';')
|
||||
{
|
||||
if ($_xh[$parser]['lv']==1)
|
||||
if ($GLOBALS['_xh'][$parser]['lv']==1)
|
||||
{
|
||||
$_xh[$parser]['qt']=1;
|
||||
$_xh[$parser]['lv']=2;
|
||||
$GLOBALS['_xh'][$parser]['qt']=1;
|
||||
$GLOBALS['_xh'][$parser]['lv']=2;
|
||||
}
|
||||
$_xh[$parser]['ac'].=$data;
|
||||
$GLOBALS['_xh'][$parser]['ac'].=$data;
|
||||
}
|
||||
}
|
||||
|
||||
@ -495,12 +488,6 @@
|
||||
****************************************************************/
|
||||
function xmlrpc_encode($php_val)
|
||||
{
|
||||
global $xmlrpcInt;
|
||||
global $xmlrpcDouble;
|
||||
global $xmlrpcString;
|
||||
global $xmlrpcArray;
|
||||
global $xmlrpcStruct;
|
||||
|
||||
$type = gettype($php_val);
|
||||
$xmlrpc_val = CreateObject('phpgwapi.xmlrpcval');
|
||||
|
||||
@ -516,18 +503,18 @@
|
||||
$xmlrpc_val->addStruct($arr);
|
||||
break;
|
||||
case "integer":
|
||||
$xmlrpc_val->addScalar($php_val, $xmlrpcInt);
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcInt);
|
||||
break;
|
||||
case "double":
|
||||
$xmlrpc_val->addScalar($php_val, $xmlrpcDouble);
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcDouble);
|
||||
break;
|
||||
case "string":
|
||||
$xmlrpc_val->addScalar($php_val, $xmlrpcString);
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcString);
|
||||
break;
|
||||
// <G_Giunta_2001-02-29>
|
||||
// Add support for encoding/decoding of booleans, since they are supported in PHP
|
||||
case "boolean":
|
||||
$xmlrpc_val->addScalar($php_val, $xmlrpcBoolean);
|
||||
$xmlrpc_val->addScalar($php_val, xmlrpcBoolean);
|
||||
break;
|
||||
// </G_Giunta_2001-02-29>
|
||||
case "unknown type":
|
||||
@ -539,12 +526,10 @@
|
||||
}
|
||||
|
||||
// listMethods: either a string, or nothing
|
||||
$_xmlrpcs_listMethods_sig = array(array($xmlrpcArray, $xmlrpcString), array($xmlrpcArray));
|
||||
$_xmlrpcs_listMethods_doc = 'This method lists all the methods that the XML-RPC server knows how to dispatch';
|
||||
$GLOBALS['_xmlrpcs_listMethods_sig'] = array(array(xmlrpcArray, xmlrpcString), array(xmlrpcArray));
|
||||
$GLOBALS['_xmlrpcs_listMethods_doc'] = 'This method lists all the methods that the XML-RPC server knows how to dispatch';
|
||||
function _xmlrpcs_listMethods($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$v = CreateObject('phpgwapi.xmlrpcval');
|
||||
$dmap = $server->dmap;
|
||||
$outAr = array();
|
||||
@ -552,7 +537,7 @@
|
||||
{
|
||||
$outAr[] = CreateObject('phpgwapi.xmlrpcval',$key, 'string');
|
||||
}
|
||||
$dmap = $_xmlrpcs_dmap;
|
||||
$dmap = $GLOBALS['_xmlrpcs_dmap'];
|
||||
for(reset($dmap); list($key, $val) = each($dmap); )
|
||||
{
|
||||
$outAr[] = CreateObject('phpgwapi.xmlrpcval',$key, 'string');
|
||||
@ -561,17 +546,15 @@
|
||||
return CreateObject('phpgwapi.xmlrpcresp',$v);
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodSignature_sig=array(array($xmlrpcArray, $xmlrpcString));
|
||||
$_xmlrpcs_methodSignature_doc='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
|
||||
$GLOBALS['_xmlrpcs_methodSignature_sig']=array(array(xmlrpcArray, xmlrpcString));
|
||||
$GLOBALS['_xmlrpcs_methodSignature_doc']='Returns an array of known signatures (an array of arrays) for the method name passed. If no signatures are known, returns a none-array (test for type != array to detect missing signature)';
|
||||
function _xmlrpcs_methodSignature($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName = $m->getParam(0);
|
||||
$methName = $methName->scalarval();
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap = $_xmlrpcs_dmap;
|
||||
$dmap = $GLOBALS['_xmlrpcs_dmap'];
|
||||
$sysCall = 1;
|
||||
}
|
||||
else
|
||||
@ -605,26 +588,26 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0,$xmlrpcerr['introspect_unknown'],$xmlrpcstr['introspect_unknown']);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0,$GLOBALS['xmlrpcerr']['introspect_unknown'],$GLOBALS['xmlrpcstr']['introspect_unknown']);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_methodHelp_sig = array(array($xmlrpcString, $xmlrpcString));
|
||||
$_xmlrpcs_methodHelp_doc = 'Returns help text if defined for the method passed, otherwise returns an empty string';
|
||||
$GLOBALS['_xmlrpcs_methodHelp_sig'] = array(array(xmlrpcString, xmlrpcString));
|
||||
$GLOBALS['_xmlrpcs_methodHelp_doc'] = 'Returns help text if defined for the method passed, otherwise returns an empty string';
|
||||
function _xmlrpcs_methodHelp($server, $m)
|
||||
{
|
||||
global $xmlrpcerr, $xmlrpcstr, $_xmlrpcs_dmap;
|
||||
|
||||
$methName = $m->getParam(0);
|
||||
$methName = $methName->scalarval();
|
||||
if (ereg("^system\.", $methName))
|
||||
{
|
||||
$dmap = $_xmlrpcs_dmap; $sysCall=1;
|
||||
$dmap = $GLOBALS['_xmlrpcs_dmap'];
|
||||
$sysCall=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$dmap = $server->dmap; $sysCall=0;
|
||||
$dmap = $server->dmap;
|
||||
$sysCall=0;
|
||||
}
|
||||
// print "<!-- ${methName} -->\n";
|
||||
if (isset($dmap[$methName]))
|
||||
@ -640,34 +623,33 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0,$xmlrpcerr['introspect_unknown'],$xmlrpcstr['introspect_unknown']);
|
||||
$r = CreateObject('phpgwapi.xmlrpcresp',0,$GLOBALS['xmlrpcerr']['introspect_unknown'],$GLOBALS['xmlrpcstr']['introspect_unknown']);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
$_xmlrpcs_dmap=array(
|
||||
$GLOBALS['_xmlrpcs_dmap']=array(
|
||||
'system.listMethods' => array(
|
||||
'function' => '_xmlrpcs_listMethods',
|
||||
'signature' => $_xmlrpcs_listMethods_sig,
|
||||
'docstring' => $_xmlrpcs_listMethods_doc
|
||||
'signature' => $GLOBALS['_xmlrpcs_listMethods_sig'],
|
||||
'docstring' => $GLOBALS['_xmlrpcs_listMethods_doc']
|
||||
),
|
||||
'system.methodHelp' => array(
|
||||
'function' => '_xmlrpcs_methodHelp',
|
||||
'signature' => $_xmlrpcs_methodHelp_sig,
|
||||
'docstring' => $_xmlrpcs_methodHelp_doc
|
||||
'signature' => $GLOBALS['_xmlrpcs_methodHelp_sig'],
|
||||
'docstring' => $GLOBALS['_xmlrpcs_methodHelp_doc']
|
||||
),
|
||||
'system.methodSignature' => array(
|
||||
'function' => '_xmlrpcs_methodSignature',
|
||||
'signature' => $_xmlrpcs_methodSignature_sig,
|
||||
'docstring' => $_xmlrpcs_methodSignature_doc
|
||||
'signature' => $GLOBALS['_xmlrpcs_methodSignature_sig'],
|
||||
'docstring' => $GLOBALS['_xmlrpcs_methodSignature_doc']
|
||||
)
|
||||
);
|
||||
|
||||
$_xmlrpc_debuginfo = '';
|
||||
$GLOBALS['_xmlrpc_debuginfo'] = '';
|
||||
function xmlrpc_debugmsg($m)
|
||||
{
|
||||
global $_xmlrpc_debuginfo;
|
||||
$_xmlrpc_debuginfo = $_xmlrpc_debuginfo . $m . "\n";
|
||||
$GLOBALS['_xmlrpc_debuginfo'] .= $m . "\n";
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user