Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal-3485117
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
drupal-3485117
Commits
c03800e0
Commit
c03800e0
authored
14 years ago
by
Dries Buytaert
Browse files
Options
Downloads
Patches
Plain Diff
- Patch
#861420
by sun: coder_format() on xmlrpc(s).inc.
parent
d79dff03
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
includes/xmlrpc.inc
+32
-17
32 additions, 17 deletions
includes/xmlrpc.inc
includes/xmlrpcs.inc
+21
-16
21 additions, 16 deletions
includes/xmlrpcs.inc
with
53 additions
and
33 deletions
includes/xmlrpc.inc
+
32
−
17
View file @
c03800e0
...
@@ -65,7 +65,7 @@ function xmlrpc_value_calculate_type($xmlrpc_value) {
...
@@ -65,7 +65,7 @@ function xmlrpc_value_calculate_type($xmlrpc_value) {
return
'double'
;
return
'double'
;
}
}
if
(
is_int
(
$xmlrpc_value
->
data
))
{
if
(
is_int
(
$xmlrpc_value
->
data
))
{
return
'int'
;
return
'int'
;
}
}
if
(
is_array
(
$xmlrpc_value
->
data
))
{
if
(
is_array
(
$xmlrpc_value
->
data
))
{
// empty or integer-indexed arrays are 'array', string-indexed arrays 'struct'
// empty or integer-indexed arrays are 'array', string-indexed arrays 'struct'
...
@@ -98,18 +98,18 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
...
@@ -98,18 +98,18 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
switch
(
$xmlrpc_value
->
type
)
{
switch
(
$xmlrpc_value
->
type
)
{
case
'boolean'
:
case
'boolean'
:
return
'<boolean>'
.
((
$xmlrpc_value
->
data
)
?
'1'
:
'0'
)
.
'</boolean>'
;
return
'<boolean>'
.
((
$xmlrpc_value
->
data
)
?
'1'
:
'0'
)
.
'</boolean>'
;
break
;
case
'int'
:
case
'int'
:
return
'<int>'
.
$xmlrpc_value
->
data
.
'</int>'
;
return
'<int>'
.
$xmlrpc_value
->
data
.
'</int>'
;
break
;
case
'double'
:
case
'double'
:
return
'<double>'
.
$xmlrpc_value
->
data
.
'</double>'
;
return
'<double>'
.
$xmlrpc_value
->
data
.
'</double>'
;
break
;
case
'string'
:
case
'string'
:
// Note: we don't escape apostrophes because of the many blogging clients
// Note: we don't escape apostrophes because of the many blogging clients
// that don't support numerical entities (and XML in general) properly.
// that don't support numerical entities (and XML in general) properly.
return
'<string>'
.
htmlspecialchars
(
$xmlrpc_value
->
data
)
.
'</string>'
;
return
'<string>'
.
htmlspecialchars
(
$xmlrpc_value
->
data
)
.
'</string>'
;
break
;
case
'array'
:
case
'array'
:
$return
=
'<array><data>'
.
"
\n
"
;
$return
=
'<array><data>'
.
"
\n
"
;
foreach
(
$xmlrpc_value
->
data
as
$item
)
{
foreach
(
$xmlrpc_value
->
data
as
$item
)
{
...
@@ -117,7 +117,7 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
...
@@ -117,7 +117,7 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
}
}
$return
.
=
'</data></array>'
;
$return
.
=
'</data></array>'
;
return
$return
;
return
$return
;
break
;
case
'struct'
:
case
'struct'
:
$return
=
'<struct>'
.
"
\n
"
;
$return
=
'<struct>'
.
"
\n
"
;
foreach
(
$xmlrpc_value
->
data
as
$name
=>
$value
)
{
foreach
(
$xmlrpc_value
->
data
as
$name
=>
$value
)
{
...
@@ -126,13 +126,12 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
...
@@ -126,13 +126,12 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
}
}
$return
.
=
'</struct>'
;
$return
.
=
'</struct>'
;
return
$return
;
return
$return
;
break
;
case
'date'
:
case
'date'
:
return
xmlrpc_date_get_xml
(
$xmlrpc_value
->
data
);
return
xmlrpc_date_get_xml
(
$xmlrpc_value
->
data
);
break
;
case
'base64'
:
case
'base64'
:
return
xmlrpc_base64_get_xml
(
$xmlrpc_value
->
data
);
return
xmlrpc_base64_get_xml
(
$xmlrpc_value
->
data
);
break
;
}
}
return
FALSE
;
return
FALSE
;
}
}
...
@@ -150,9 +149,12 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
...
@@ -150,9 +149,12 @@ function xmlrpc_value_get_xml($xmlrpc_value) {
*/
*/
function
xmlrpc_message
(
$message
)
{
function
xmlrpc_message
(
$message
)
{
$xmlrpc_message
=
new
stdClass
();
$xmlrpc_message
=
new
stdClass
();
$xmlrpc_message
->
array_structs
=
array
();
// The stack used to keep track of the current array/struct
// The stack used to keep track of the current array/struct
$xmlrpc_message
->
array_structs_types
=
array
();
// The stack used to keep track of if things are structs or array
$xmlrpc_message
->
array_structs
=
array
();
$xmlrpc_message
->
current_struct_name
=
array
();
// A stack as well
// The stack used to keep track of if things are structs or array
$xmlrpc_message
->
array_structs_types
=
array
();
// A stack as well
$xmlrpc_message
->
current_struct_name
=
array
();
$xmlrpc_message
->
message
=
$message
;
$xmlrpc_message
->
message
=
$message
;
return
$xmlrpc_message
;
return
$xmlrpc_message
;
}
}
...
@@ -238,11 +240,13 @@ function xmlrpc_message_tag_open($parser, $tag, $attr) {
...
@@ -238,11 +240,13 @@ function xmlrpc_message_tag_open($parser, $tag, $attr) {
case
'fault'
:
case
'fault'
:
$xmlrpc_message
->
messagetype
=
$tag
;
$xmlrpc_message
->
messagetype
=
$tag
;
break
;
break
;
// Deal with stacks of arrays and structs
// Deal with stacks of arrays and structs
case
'data'
:
case
'data'
:
$xmlrpc_message
->
array_structs_types
[]
=
'array'
;
$xmlrpc_message
->
array_structs_types
[]
=
'array'
;
$xmlrpc_message
->
array_structs
[]
=
array
();
$xmlrpc_message
->
array_structs
[]
=
array
();
break
;
break
;
case
'struct'
:
case
'struct'
:
$xmlrpc_message
->
array_structs_types
[]
=
'struct'
;
$xmlrpc_message
->
array_structs_types
[]
=
'struct'
;
$xmlrpc_message
->
array_structs
[]
=
array
();
$xmlrpc_message
->
array_structs
[]
=
array
();
...
@@ -272,19 +276,23 @@ function xmlrpc_message_tag_close($parser, $tag) {
...
@@ -272,19 +276,23 @@ function xmlrpc_message_tag_close($parser, $tag) {
$value
=
(
int
)
trim
(
$xmlrpc_message
->
current_tag_contents
);
$value
=
(
int
)
trim
(
$xmlrpc_message
->
current_tag_contents
);
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
case
'double'
:
case
'double'
:
$value
=
(
double
)
trim
(
$xmlrpc_message
->
current_tag_contents
);
$value
=
(
double
)
trim
(
$xmlrpc_message
->
current_tag_contents
);
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
case
'string'
:
case
'string'
:
$value
=
$xmlrpc_message
->
current_tag_contents
;
$value
=
$xmlrpc_message
->
current_tag_contents
;
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
case
'dateTime.iso8601'
:
case
'dateTime.iso8601'
:
$value
=
xmlrpc_date
(
trim
(
$xmlrpc_message
->
current_tag_contents
));
$value
=
xmlrpc_date
(
trim
(
$xmlrpc_message
->
current_tag_contents
));
// $value = $iso->getTimestamp();
// $value = $iso->getTimestamp();
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
case
'value'
:
case
'value'
:
// If no type is indicated, the type is string
// If no type is indicated, the type is string
// We take special care for empty values
// We take special care for empty values
...
@@ -294,41 +302,47 @@ function xmlrpc_message_tag_close($parser, $tag) {
...
@@ -294,41 +302,47 @@ function xmlrpc_message_tag_close($parser, $tag) {
}
}
unset
(
$xmlrpc_message
->
last_open
);
unset
(
$xmlrpc_message
->
last_open
);
break
;
break
;
case
'boolean'
:
case
'boolean'
:
$value
=
(
boolean
)
trim
(
$xmlrpc_message
->
current_tag_contents
);
$value
=
(
boolean
)
trim
(
$xmlrpc_message
->
current_tag_contents
);
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
case
'base64'
:
case
'base64'
:
$value
=
base64_decode
(
trim
(
$xmlrpc_message
->
current_tag_contents
));
$value
=
base64_decode
(
trim
(
$xmlrpc_message
->
current_tag_contents
));
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
// Deal with stacks of arrays and structs
// Deal with stacks of arrays and structs
case
'data'
:
case
'data'
:
case
'struct'
:
case
'struct'
:
$value
=
array_pop
(
$xmlrpc_message
->
array_structs
);
$value
=
array_pop
(
$xmlrpc_message
->
array_structs
);
array_pop
(
$xmlrpc_message
->
array_structs_types
);
array_pop
(
$xmlrpc_message
->
array_structs_types
);
$value_flag
=
TRUE
;
$value_flag
=
TRUE
;
break
;
break
;
case
'member'
:
case
'member'
:
array_pop
(
$xmlrpc_message
->
current_struct_name
);
array_pop
(
$xmlrpc_message
->
current_struct_name
);
break
;
break
;
case
'name'
:
case
'name'
:
$xmlrpc_message
->
current_struct_name
[]
=
trim
(
$xmlrpc_message
->
current_tag_contents
);
$xmlrpc_message
->
current_struct_name
[]
=
trim
(
$xmlrpc_message
->
current_tag_contents
);
break
;
break
;
case
'methodName'
:
case
'methodName'
:
$xmlrpc_message
->
methodname
=
trim
(
$xmlrpc_message
->
current_tag_contents
);
$xmlrpc_message
->
methodname
=
trim
(
$xmlrpc_message
->
current_tag_contents
);
break
;
break
;
}
}
if
(
$value_flag
)
{
if
(
$value_flag
)
{
if
(
count
(
$xmlrpc_message
->
array_structs
)
>
0
)
{
if
(
count
(
$xmlrpc_message
->
array_structs
)
>
0
)
{
// Add value to struct or array
// Add value to struct or array
if
(
$xmlrpc_message
->
array_structs_types
[
count
(
$xmlrpc_message
->
array_structs_types
)
-
1
]
==
'struct'
)
{
if
(
$xmlrpc_message
->
array_structs_types
[
count
(
$xmlrpc_message
->
array_structs_types
)
-
1
]
==
'struct'
)
{
// Add to struct
// Add to struct
$xmlrpc_message
->
array_structs
[
count
(
$xmlrpc_message
->
array_structs
)
-
1
][
$xmlrpc_message
->
current_struct_name
[
count
(
$xmlrpc_message
->
current_struct_name
)
-
1
]]
=
$value
;
$xmlrpc_message
->
array_structs
[
count
(
$xmlrpc_message
->
array_structs
)
-
1
][
$xmlrpc_message
->
current_struct_name
[
count
(
$xmlrpc_message
->
current_struct_name
)
-
1
]]
=
$value
;
}
}
else
{
else
{
// Add to array
// Add to array
$xmlrpc_message
->
array_structs
[
count
(
$xmlrpc_message
->
array_structs
)
-
1
][]
=
$value
;
$xmlrpc_message
->
array_structs
[
count
(
$xmlrpc_message
->
array_structs
)
-
1
][]
=
$value
;
}
}
}
}
else
{
else
{
...
@@ -611,3 +625,4 @@ function xmlrpc_error_msg() {
...
@@ -611,3 +625,4 @@ function xmlrpc_error_msg() {
function
xmlrpc_clear_error
()
{
function
xmlrpc_clear_error
()
{
xmlrpc_error
(
NULL
,
NULL
,
TRUE
);
xmlrpc_error
(
NULL
,
NULL
,
TRUE
);
}
}
This diff is collapsed.
Click to expand it.
includes/xmlrpcs.inc
+
21
−
16
View file @
c03800e0
...
@@ -16,29 +16,31 @@ function xmlrpc_server($callbacks) {
...
@@ -16,29 +16,31 @@ function xmlrpc_server($callbacks) {
$xmlrpc_server
=
new
stdClass
();
$xmlrpc_server
=
new
stdClass
();
// Define built-in XML-RPC method names
// Define built-in XML-RPC method names
$defaults
=
array
(
$defaults
=
array
(
'system.multicall'
=>
'xmlrpc_server_multicall'
,
'system.multicall'
=>
'xmlrpc_server_multicall'
,
array
(
array
(
'system.methodSignature'
,
'system.methodSignature'
,
'xmlrpc_server_method_signature'
,
'xmlrpc_server_method_signature'
,
array
(
'array'
,
'string'
),
array
(
'array'
,
'string'
),
'Returns an array describing the return type and required parameters of a method.'
'Returns an array describing the return type and required parameters of a method.'
,
),
),
array
(
array
(
'system.getCapabilities'
,
'system.getCapabilities'
,
'xmlrpc_server_get_capabilities'
,
'xmlrpc_server_get_capabilities'
,
array
(
'struct'
),
array
(
'struct'
),
'Returns a struct describing the XML-RPC specifications supported by this server.'
'Returns a struct describing the XML-RPC specifications supported by this server.'
,
),
),
array
(
array
(
'system.listMethods'
,
'system.listMethods'
,
'xmlrpc_server_list_methods'
,
'xmlrpc_server_list_methods'
,
array
(
'array'
),
array
(
'array'
),
'Returns an array of available methods on this server.'
),
'Returns an array of available methods on this server.'
,
),
array
(
array
(
'system.methodHelp'
,
'system.methodHelp'
,
'xmlrpc_server_method_help'
,
'xmlrpc_server_method_help'
,
array
(
'string'
,
'string'
),
array
(
'string'
,
'string'
),
'Returns a documentation string for the specified method.'
)
'Returns a documentation string for the specified method.'
,
),
);
);
// We build an array of all method names by combining the built-ins
// We build an array of all method names by combining the built-ins
// with those defined by modules implementing the _xmlrpc hook.
// with those defined by modules implementing the _xmlrpc hook.
...
@@ -86,9 +88,7 @@ function xmlrpc_server($callbacks) {
...
@@ -86,9 +88,7 @@ function xmlrpc_server($callbacks) {
<methodResponse>
<methodResponse>
<params>
<params>
<param>
<param>
<value>'
.
<value>'
.
xmlrpc_value_get_xml
(
$r
)
.
'</value>
xmlrpc_value_get_xml
(
$r
)
.
'</value>
</param>
</param>
</params>
</params>
</methodResponse>
</methodResponse>
...
@@ -181,23 +181,27 @@ function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
...
@@ -181,23 +181,27 @@ function xmlrpc_server_call($xmlrpc_server, $methodname, $args) {
$ok
=
FALSE
;
$ok
=
FALSE
;
}
}
break
;
break
;
case
'base64'
:
case
'base64'
:
case
'string'
:
case
'string'
:
if
(
!
is_string
(
$arg
))
{
if
(
!
is_string
(
$arg
))
{
$ok
=
FALSE
;
$ok
=
FALSE
;
}
}
break
;
break
;
case
'boolean'
:
case
'boolean'
:
if
(
$arg
!==
FALSE
&&
$arg
!==
TRUE
)
{
if
(
$arg
!==
FALSE
&&
$arg
!==
TRUE
)
{
$ok
=
FALSE
;
$ok
=
FALSE
;
}
}
break
;
break
;
case
'float'
:
case
'float'
:
case
'double'
:
case
'double'
:
if
(
!
is_float
(
$arg
))
{
if
(
!
is_float
(
$arg
))
{
$ok
=
FALSE
;
$ok
=
FALSE
;
}
}
break
;
break
;
case
'date'
:
case
'date'
:
case
'dateTime.iso8601'
:
case
'dateTime.iso8601'
:
if
(
!
$arg
->
is_date
)
{
if
(
!
$arg
->
is_date
)
{
...
@@ -239,7 +243,7 @@ function xmlrpc_server_multicall($methodcalls) {
...
@@ -239,7 +243,7 @@ function xmlrpc_server_multicall($methodcalls) {
if
(
is_object
(
$result
)
&&
!
empty
(
$result
->
is_error
))
{
if
(
is_object
(
$result
)
&&
!
empty
(
$result
->
is_error
))
{
$return
[]
=
array
(
$return
[]
=
array
(
'faultCode'
=>
$result
->
code
,
'faultCode'
=>
$result
->
code
,
'faultString'
=>
$result
->
message
'faultString'
=>
$result
->
message
,
);
);
}
}
else
{
else
{
...
@@ -249,7 +253,6 @@ function xmlrpc_server_multicall($methodcalls) {
...
@@ -249,7 +253,6 @@ function xmlrpc_server_multicall($methodcalls) {
return
$return
;
return
$return
;
}
}
/**
/**
* XML-RPC method system.listMethods maps to this function.
* XML-RPC method system.listMethods maps to this function.
*/
*/
...
@@ -267,20 +270,20 @@ function xmlrpc_server_get_capabilities() {
...
@@ -267,20 +270,20 @@ function xmlrpc_server_get_capabilities() {
return
array
(
return
array
(
'xmlrpc'
=>
array
(
'xmlrpc'
=>
array
(
'specUrl'
=>
'http://www.xmlrpc.com/spec'
,
'specUrl'
=>
'http://www.xmlrpc.com/spec'
,
'specVersion'
=>
1
'specVersion'
=>
1
,
),
),
'faults_interop'
=>
array
(
'faults_interop'
=>
array
(
'specUrl'
=>
'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php'
,
'specUrl'
=>
'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php'
,
'specVersion'
=>
20010516
'specVersion'
=>
20010516
,
),
),
'system.multicall'
=>
array
(
'system.multicall'
=>
array
(
'specUrl'
=>
'http://www.xmlrpc.com/discuss/msgReader$1208'
,
'specUrl'
=>
'http://www.xmlrpc.com/discuss/msgReader$1208'
,
'specVersion'
=>
1
'specVersion'
=>
1
,
),
),
'introspection'
=>
array
(
'introspection'
=>
array
(
'specUrl'
=>
'http://scripts.incutio.com/xmlrpc/introspection.html'
,
'specUrl'
=>
'http://scripts.incutio.com/xmlrpc/introspection.html'
,
'specVersion'
=>
1
'specVersion'
=>
1
,
)
)
,
);
);
}
}
...
@@ -289,6 +292,7 @@ function xmlrpc_server_get_capabilities() {
...
@@ -289,6 +292,7 @@ function xmlrpc_server_get_capabilities() {
*
*
* @param $methodname
* @param $methodname
* Name of method for which we return a method signature.
* Name of method for which we return a method signature.
*
* @return
* @return
* An array of types representing the method signature of the
* An array of types representing the method signature of the
* function that the methodname maps to. The methodSignature of
* function that the methodname maps to. The methodSignature of
...
@@ -321,3 +325,4 @@ function xmlrpc_server_method_help($method) {
...
@@ -321,3 +325,4 @@ function xmlrpc_server_method_help($method) {
$xmlrpc_server
=
xmlrpc_server_get
();
$xmlrpc_server
=
xmlrpc_server_get
();
return
$xmlrpc_server
->
help
[
$method
];
return
$xmlrpc_server
->
help
[
$method
];
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment