Actions.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. function deserializationAction(&$body)
  3. {
  4. $data = $body->getValue();
  5. //Get the method that is being called
  6. $description = xmlrpc_parse_method_descriptions($data);
  7. $target = $description['methodName'];
  8. $baseClassPath = $GLOBALS['amfphp']['classPath'];
  9. $lpos = strrpos($target, '.');
  10. $methodname = substr($target, $lpos + 1);
  11. $trunced = substr($target, 0, $lpos);
  12. $lpos = strrpos($trunced, ".");
  13. if ($lpos === false) {
  14. $classname = $trunced;
  15. $uriclasspath = $trunced . ".php";
  16. $classpath = $baseClassPath . $trunced . ".php";
  17. } else {
  18. $classname = substr($trunced, $lpos + 1);
  19. $classpath = $baseClassPath . str_replace(".", "/", $trunced) . ".php"; // removed to strip the basecp out of the equation here
  20. $uriclasspath = str_replace(".", "/", $trunced) . ".php"; // removed to strip the basecp out of the equation here
  21. }
  22. $body->methodName = $methodname;
  23. $body->className = $classname;
  24. $body->classPath = $classpath;
  25. $body->uriClassPath = $uriclasspath;
  26. $body->packageClassMethodName = $description['methodName'];
  27. }
  28. function executionAction(& $body)
  29. {
  30. $classConstruct = $body->getClassConstruct();
  31. $methodName = $body->methodName;
  32. $className = $body->className;
  33. $xmlrpc_server = xmlrpc_server_create();
  34. $lambdaFunc = 'return adapterMap(call_user_func_array (array(&$userData[0], $userData[1]), $args));';
  35. $func = create_function('$a,$args,$userData', $lambdaFunc);
  36. xmlrpc_server_register_method($xmlrpc_server,
  37. $body->packageClassMethodName,
  38. $func);
  39. $request_xml = $body->getValue();
  40. $args = array($xmlrpc_server, $request_xml, array(&$classConstruct, $methodName));
  41. $nullObj = NULL;
  42. $response = Executive::doMethodCall($body, $nullObj, 'xmlrpc_server_call_method', $args);
  43. //$response = xmlrpc_server_call_method();
  44. if($response !== "__amfphp_error")
  45. {
  46. $body->setResults($response);
  47. }
  48. else
  49. {
  50. return false;
  51. }
  52. }
  53. /**
  54. * Debug action
  55. */
  56. function debugAction(& $body)
  57. {
  58. if(count(NetDebug::getTraceStack()) != 0)
  59. {
  60. $previousResults = $body->getResults();
  61. $debugInfo = NetDebug::getTraceStack();
  62. $debugString = "<!-- " . implode("\n", $debugInfo) . "-->";
  63. $body->setResults($debugString . "\n" . $previousResults);
  64. }
  65. }
  66. /**
  67. * This won't ever be called unless there is an error
  68. */
  69. function serializationAction(& $body)
  70. {
  71. $request_xml = $body->getValue();
  72. $toSerialize = $body->getResults();
  73. $lambdaFunc = 'return $userData;';
  74. $func = create_function('$a,$b,$userData', $lambdaFunc);
  75. $xmlrpc_server = xmlrpc_server_create();
  76. $request_xml = $body->getValue();
  77. xmlrpc_server_register_method($xmlrpc_server,
  78. $body->packageClassMethodName,
  79. $func);
  80. $response = xmlrpc_server_call_method($xmlrpc_server, $request_xml, $toSerialize);
  81. $body->setResults($response);
  82. }
  83. ?>