td class="message collapsing has-emoji"> a4345e5759 first commit 5 年之前 2608 f022c07ac9 goto server 5 年之前 2608_fsm ad01fc0d19 find places 5 年之前 2608_vm a4345e5759 first commit 5 年之前 2609 a4345e5759 first commit 5 年之前 2609_fsm a4345e5759 first commit 5 年之前 2609_vm a4345e5759 first commit 5 年之前 2610 f022c07ac9 goto server 5 年之前 2610_fsm a4345e5759 first commit 5 年之前 2610_vm a4345e5759 first commit 5 年之前 2611 a4345e5759 first commit 5 年之前 2612 a4345e5759 first commit 5 年之前 2612_fsm a4345e5759 first commit 5 年之前 2612_vm a4345e5759 first commit 5 年之前 2613 a4345e5759 first commit 5 年之前 2615 a4345e5759 first commit 5 年之前 2615_fsm a4345e5759 first commit 5 年之前 2615_vm a4345e5759 first commit 5 年之前 2616 a4345e5759 first commit 5 年之前 2616_fsm a4345e5759 first commit 5 年之前 2616_vm a4345e5759 first commit 5 年之前 2617 a4345e5759 first commit 5 年之前 2617_fsm a4345e5759 first commit 5 年之前 2617_vm a4345e5759 first commit 5 年之前 2618 a4345e5759 first commit 5 年之前 2618_fsm a4345e5759 first commit 5 年之前 2618_vm a4345e5759 first commit 5 年之前 2619 ad01fc0d19 find places 5 年之前 2619_fsm a4345e5759 first commit 5 年之前 2619_vm ad01fc0d19 find places 5 年之前 2620 f022c07ac9 goto server 5 年之前 2620_fsm a4345e5759 first commit 5 年之前 2650 a4345e5759 first commit 5 年之前 2651 a4345e5759 first commit 5 年之前 2652 a4345e5759 first commit 5 年之前 2653 a4345e5759 first commit 5 年之前 2654 a4345e5759 first commit 5 年之前 2655 a4345e5759 first commit 5 年之前 2656 f022c07ac9 goto server 5 年之前 2657 f022c07ac9 goto server 5 年之前 2658 f022c07ac9 goto server 5 年之前 2659 f022c07ac9 goto server 5 年之前 2660 a4345e5759 first commit 5 年之前 2661 a4345e5759 first commit 5 年之前 2662 f022c07ac9 goto server 5 年之前 2663 f022c07ac9 goto server 5 年之前 2664 f022c07ac9 goto server 5 年之前 2665 f022c07ac9 goto server 5 年之前 2666 f022c07ac9 goto server 5 年之前 2667 f022c07ac9 goto server 5 年之前 2668 a4345e5759 first commit 5 年之前 2669 a4345e5759 first commit 5 年之前 2670 a4345e5759 first commit 5 年之前 2673 f022c07ac9 goto server 5 年之前 2674 f022c07ac9 goto server 5 年之前 2675 a4345e5759 first commit 5 年之前 2678 f022c07ac9 goto server 5 年之前 2679 f022c07ac9 goto server 5 年之前 2680 a4345e5759 first commit 5 年之前 2681 a4345e5759 first commit 5 年之前 2682 a4345e5759 first commit 5 年之前 2683 a4345e5759 first commit 5 年之前 2684 a4345e5759 first commit 5 年之前 2685 a4345e5759 first commit 5 年之前 2686 a4345e5759 first commit 5 年之前 2687 a4345e5759 first commit 5 年之前 2688 a4345e5759 first commit 5 年之前 2689 a4345e5759 first commit 5 年之前 2690 a4345e5759 first commit 5 年之前 2691 a4345e5759 first commit 5 年之前 2692 a4345e5759 first commit 5 年之前 2693 a4345e5759 first commit 5 年之前 2696 ad01fc0d19 find places 5 年之前 2699 f022c07ac9 goto server 5 年之前 2701 f022c07ac9 goto server 5 年之前 2702 f022c07ac9 goto server 5 年之前 2703 ad01fc0d19 find places 5 年之前 2704 ad01fc0d19 find places 5 年之前 2753 a4345e5759 first commit 5 年之前 2753_fsm a4345e5759 first commit 5 年之前 2753_vm a4345e5759 first commit 5 年之前 2754 a4345e5759 first commit 5 年之前 2755 a4345e5759 first commit 5 年之前 2756 a4345e5759 first commit 5 年之前 2757 a4345e5759 first commit 5 年之前 2830 a4345e5759 first commit 5 年之前 2831 a4345e5759 first commit 5 年之前 2832 a4345e5759 first commit 5 年之前 2833 a4345e5759 first commit 5 年之前 2834 a4345e5759 first commit 5 年之前 2835 a4345e5759 first commit 5 年之前 2836 a4345e5759 first commit 5 年之前 2837 a4345e5759 first commit 5 年之前 2838 a4345e5759 first commit 5 年之前 2838_fsm a4345e5759 first commit 5 年之前 2838_vm a4345e5759 first commit 5 年之前 2839 a4345e5759 first commit 5 年之前 2840 ad01fc0d19 find places 5 年之前 2840_fsm ad01fc0d19 find places 5 年之前 2840_vm a4345e5759 first commit 5 年之前 2841 ad01fc0d19 find places 5 年之前 2995 a4345e5759 first commit 5 年之前 2996 a4345e5759 first commit 5 年之前 3079 a4345e5759 first commit 5 年之前 3079_fsm a4345e5759 first commit 5 年之前 3079_vm a4345e5759 first commit 5 年之前 3080 a4345e5759 first commit 5 年之前 3081 a4345e5759 first commit 5 年之前 3085 a4345e5759 first commit 5 年之前 3118 a4345e5759 first commit 5 年之前 3119 a4345e5759 first commit 5 年之前 3164 a4345e5759 first commit 5 年之前 3256 a4345e5759 first commit 5 年之前 3257 a4345e5759 first commit 5 年之前 3258 a4345e5759 first commit 5 年之前 3350 a4345e5759 first commit 5 年之前 3351 a4345e5759 first commit 5 年之前 3379 a4345e5759 first commit 5 年之前 3380 a4345e5759 first commit 5 年之前 3381 a4345e5759 first commit 5 年之前 3394 a4345e5759 first commit 5 年之前 3394_fsm a4345e5759 first commit 5 年之前 3394_vm a4345e5759 first commit 5 年之前 3395 a4345e5759 first commit 5 年之前 3429 a4345e5759 first commit 5 年之前 3430 a4345e5759 first commit 5 年之前 3431 a4345e5759 first commit 5 年之前 3433 a4345e5759 first commit 5 年之前 3439 a4345e5759 first commit 5 年之前 3440 a4345e5759 first commit 5 年之前 3455 f022c07ac9 goto server 5 年之前 3456 a4345e5759 first commit 5 年之前 3456_fsm a4345e5759 first commit 5 年之前 3456_vm a4345e5759 first commit 5 年之前 3466 a4345e5759 first commit 5 年之前 3467 a4345e5759 first commit 5 年之前 3468 a4345e5759 first commit 5 年之前 3501 a4345e5759 first commit 5 年之前 3502 a4345e5759 first commit 5 年之前 3503 a4345e5759 first commit 5 年之前 3534 a4345e5759 first commit 5 年之前 3541 a4345e5759 first commit 5 年之前 3541_fsm a4345e5759 first commit 5 年之前 3541_vm a4345e5759 first commit 5 年之前 3542 a4345e5759 first commit 5 年之前 3574 a4345e5759 first commit 5 年之前 3575 a4345e5759 first commit 5 年之前 3576 a4345e5759 first commit 5 年之前 3596 a4345e5759 first commit 5 年之前 3597 a4345e5759 first commit 5 年之前 3598 a4345e5759 first commit 5 年之前 3599 a4345e5759 first commit 5 年之前 3600 a4345e5759 first commit 5 年之前 3600_fsm a4345e5759 first commit 5 年之前 3600_vm a4345e5759 first commit 5 年之前 3601 a4345e5759 first commit 5 年之前 3601_fsm a4345e5759 first commit 5 年之前 3601_vm a4345e5759 first commit 5 年之前 3602 a4345e5759 first commit 5 年之前 3602_fsm a4345e5759 first commit 5 年之前 3602_vm a4345e5759 first commit 5 年之前 3603 a4345e5759 first commit 5 年之前 3603_fsm a4345e5759 first commit 5 年之前 3603_vm a4345e5759 first commit 5 年之前 3604 a4345e5759 first commit 5 年之前 3605 a4345e5759 first commit 5 年之前 3606 a4345e5759 first commit 5 年之前 3607 a4345e5759 first commit 5 年之前 3608 a4345e5759 first commit 5 年之前 3609 a4345e5759 first commit 5 年之前 3712 a4345e5759 first commit 5 年之前 3764 a4345e5759 first commit 5 年之前 3764_fsm a4345e5759 first commit 5 年之前 3764_vm a4345e5759 first commit 5 年之前 3766 a4345e5759 first commit 5 年之前 3767 a4345e5759 first commit 5 年之前 3997 a4345e5759 first commit 5 年之前 4143 a4345e5759 first commit 5 年之前 4144 a4345e5759 first commit 5 年之前 4145 a4345e5759 first commit 5 年之前 4146 a4345e5759 first commit 5 年之前 4147 a4345e5759 first commit 5 年之前 4148 a4345e5759 first commit 5 年之前 4149 a4345e5759 first commit 5 年之前 4150 a4345e5759 first commit 5 年之前 4151 a4345e5759 first commit 5 年之前 4152 a4345e5759 first commit 5 年之前 4153 a4345e5759 first commit 5 年之前 4154 a4345e5759 first commit 5 年之前 4155 a4345e5759 first commit 5 年之前 4156 a4345e5759 first commit 5 年之前 4157 a4345e5759 first commit 5 年之前 4158 a4345e5759 first commit 5 年之前 4159 a4345e5759 first commit 5 年之前 4160 a4345e5759 first commit 5 年之前 4161 a4345e5759 first commit 5 年之前 4162 a4345e5759 first commit 5 年之前 4163 a4345e5759 first commit 5 年之前 4164 a4345e5759 first commit 5 年之前 4165 a4345e5759 first commit 5 年之前 4166 a4345e5759 first commit 5 年之前 4167 a4345e5759 first commit 5 年之前 4168 a4345e5759 first commit 5 年之前 4169 a4345e5759 first commit 5 年之前 4170 a4345e5759 first commit 5 年之前 4171 a4345e5759 first commit 5 年之前 4172 a4345e5759 first commit 5 年之前 4173 a4345e5759 first commit 5 年之前 4174 a4345e5759 first commit 5 年之前 5002 ad01fc0d19 find places 5 年之前 548 a4345e5759 first commit 5 年之前 549 a4345e5759 first commit 5 年之前 6102 a4345e5759 first commit 5 年之前 6104 a4345e5759 first commit 5 年之前 6106 a4345e5759 first commit 5 年之前 6110 a4345e5759 first commit 5 年之前 6111 a4345e5759 first commit 5 年之前 6112 a4345e5759 first commit 5 年之前 6113 a4345e5759 first commit 5 年之前 6117 a4345e5759 first commit 5 年之前 826 a4345e5759 first commit 5 年之前 827 a4345e5759 first commit 5 年之前 828 a4345e5759 first commit 5 年之前 PG_VERSION a4345e5759 first commit 5 年之前 pg_filenode.map a4345e5759 first commit 5 年之前 pg_internal.init a4345e5759 first commit 5 年之前 tum/whitesports - Gogs: Simplico Git Service

暂无描述

class-IXR-introspectionserver.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. <?php
  2. /**
  3. * IXR_IntrospectionServer
  4. *
  5. * @package IXR
  6. * @since 1.5.0
  7. */
  8. class IXR_IntrospectionServer extends IXR_Server
  9. {
  10. var $signatures;
  11. var $help;
  12. /**
  13. * PHP5 constructor.
  14. */
  15. function __construct()
  16. {
  17. $this->setCallbacks();
  18. $this->setCapabilities();
  19. $this->capabilities['introspection'] = array(
  20. 'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
  21. 'specVersion' => 1
  22. );
  23. $this->addCallback(
  24. 'system.methodSignature',
  25. 'this:methodSignature',
  26. array('array', 'string'),
  27. 'Returns an array describing the return type and required parameters of a method'
  28. );
  29. $this->addCallback(
  30. 'system.getCapabilities',
  31. 'this:getCapabilities',
  32. array('struct'),
  33. 'Returns a struct describing the XML-RPC specifications supported by this server'
  34. );
  35. $this->addCallback(
  36. 'system.listMethods',
  37. 'this:listMethods',
  38. array('array'),
  39. 'Returns an array of available methods on this server'
  40. );
  41. $this->addCallback(
  42. 'system.methodHelp',
  43. 'this:methodHelp',
  44. array('string', 'string'),
  45. 'Returns a documentation string for the specified method'
  46. );
  47. }
  48. /**
  49. * PHP4 constructor.
  50. */
  51. public function IXR_IntrospectionServer() {
  52. self::__construct();
  53. }
  54. function addCallback($method, $callback, $args, $help)
  55. {
  56. $this->callbacks[$method] = $callback;
  57. $this->signatures[$method] = $args;
  58. $this->help[$method] = $help;
  59. }
  60. function call($methodname, $args)
  61. {
  62. // Make sure it's in an array
  63. if ($args && !is_array($args)) {
  64. $args = array($args);
  65. }
  66. // Over-rides default call method, adds signature check
  67. if (!$this->hasMethod($methodname)) {
  68. return new IXR_Error(-32601, 'server error. requested method "'.$this->message->methodName.'" not specified.');
  69. }
  70. $method = $this->callbacks[$methodname];
  71. $signature = $this->signatures[$methodname];
  72. $returnType = array_shift($signature);
  73. // Check the number of arguments
  74. if (count($args) != count($signature)) {
  75. return new IXR_Error(-32602, 'server error. wrong number of method parameters');
  76. }
  77. // Check the argument types
  78. $ok = true;
  79. $argsbackup = $args;
  80. for ($i = 0, $j = count($args); $i < $j; $i++) {
  81. $arg = array_shift($args);
  82. $type = array_shift($signature);
  83. switch ($type) {
  84. case 'int':
  85. case 'i4':
  86. if (is_array($arg) || !is_int($arg)) {
  87. $ok = false;
  88. }
  89. break;
  90. case 'base64':
  91. case 'string':
  92. if (!is_string($arg)) {
  93. $ok = false;
  94. }
  95. break;
  96. case 'boolean':
  97. if ($arg !== false && $arg !== true) {
  98. $ok = false;
  99. }
  100. break;
  101. case 'float':
  102. case 'double':
  103. if (!is_float($arg)) {
  104. $ok = false;
  105. }
  106. break;
  107. case 'date':
  108. case 'dateTime.iso8601':
  109. if (!is_a($arg, 'IXR_Date')) {
  110. $ok = false;
  111. }
  112. break;
  113. }
  114. if (!$ok) {
  115. return new IXR_Error(-32602, 'server error. invalid method parameters');
  116. }
  117. }
  118. // It passed the test - run the "real" method call
  119. return parent::call($methodname, $argsbackup);
  120. }
  121. function methodSignature($method)
  122. {
  123. if (!$this->hasMethod($method)) {
  124. return new IXR_Error(-32601, 'server error. requested method "'.$method.'" not specified.');
  125. }
  126. // We should be returning an array of types
  127. $types = $this->signatures[$method];
  128. $return = array();
  129. foreach ($types as $type) {
  130. switch ($type) {
  131. case 'string':
  132. $return[] = 'string';
  133. break;
  134. case 'int':
  135. case 'i4':
  136. $return[] = 42;
  137. break;
  138. case 'double':
  139. $return[] = 3.1415;
  140. break;
  141. case 'dateTime.iso8601':
  142. $return[] = new IXR_Date(time());
  143. break;
  144. case 'boolean':
  145. $return[] = true;
  146. break;
  147. case 'base64':
  148. $return[] = new IXR_Base64('base64');
  149. break;
  150. case 'array':
  151. $return[] = array('array');
  152. break;
  153. case 'struct':
  154. $return[] = array('struct' => 'struct');
  155. break;
  156. }
  157. }
  158. return $return;
  159. }
  160. function methodHelp($method)
  161. {
  162. return $this->help[$method];
  163. }
  164. }