⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 action.php

📁 java开源项目源代码
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php/** * @version $Id: action.php,v 1.1 2008/03/30 14:47:59 tim_schofield Exp $ * @author Gaetano Giunta * @copyright (C) 2005-2008 G. Giunta * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt * * @todo switch params for http compression from 0,1,2 to values to be used directly * @todo use ob_start to catch debug info and echo it AFTER method call results? * @todo be smarter in creating client stub for proxy/auth cases: only set appropriate property of client obj **/?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head>  <title>XMLRPC Debugger</title>  <meta name="robots" content="index,nofollow" /><style type="text/css"><!--body {border-top: 1px solid gray; padding: 1em; font-family: Verdana, Arial, Helvetica; font-size: 8pt;}h3 {font-size: 9.5pt;}h2 {font-size: 12pt;}.dbginfo {padding: 1em; background-color: #EEEEEE; border: 1px dashed silver; font-family: monospace;}#response {padding: 1em; margin-top: 1em; background-color: #DDDDDD; border: 1px solid gray; white-space: pre; font-family: monospace;}table {padding: 2px; margin-top: 1em;}th {background-color: navy; color: white; padding: 0.5em;}td {padding: 0.5em; font-family: monospace;}td form {margin: 0;}.oddrow {background-color: #EEEEEE;}.evidence {color: blue;}#phpcode { background-color: #EEEEEE; padding: 1em; margin-top: 1em;}--></style></head><body><?php  include(getcwd().'/common.php');  if ($action)  {    // make sure the script waits long enough for the call to complete...    if ($timeout)      set_time_limit($timeout+10);    include('xmlrpc.inc');    if ($wstype == 1)    {      @include('jsonrpc.inc');      if (!class_exists('jsonrpc_client'))      {        die('Error: to debug the jsonrpc protocol the jsonrpc.inc file is needed');      }      $clientclass = 'jsonrpc_client';      $msgclass = 'jsonrpcmsg';      $protoname = 'JSONRPC';    }    else    {      $clientclass = 'xmlrpc_client';      $msgclass = 'xmlrpcmsg';      $protoname = 'XMLRPC';    }    if ($port != "")    {      $client =& new $clientclass($path, $host, $port);      $server = "$host:$port$path";    } else {      $client =& new $clientclass($path, $host);      $server = "$host$path";    }    if ($protocol == 2)    {      $server = 'https://'.$server;    }    else    {      $server = 'http://'.$server;    }    if ($proxy != '') {      $pproxy = split(':', $proxy);      if (count($pproxy) > 1)        $pport = $pproxy[1];      else        $pport = 8080;      $client->setProxy($pproxy[0], $pport, $proxyuser, $proxypwd);    }    if ($protocol == 2)    {      $client->setSSLVerifyPeer($verifypeer);      $client->setSSLVerifyHost($verifyhost);      if ($cainfo)      {        $client->setCaCertificate($cainfo);      }      $httpprotocol = 'https';    }    else if ($protocol == 1)      $httpprotocol = 'http11';    else      $httpprotocol = 'http';    if ($username)      $client->setCredentials($username, $password, $authtype);    $client->setDebug($debug);    switch ($requestcompression) {      case 0:        $client->request_compression = '';        break;      case 1:        $client->request_compression = 'gzip';        break;      case 2:        $client->request_compression = 'deflate';        break;    }    switch ($responsecompression) {      case 0:        $client->accepted_compression = '';        break;      case 1:        $client->accepted_compression = array('gzip');        break;      case 2:        $client->accepted_compression = array('deflate');        break;      case 3:        $client->accepted_compression = array('gzip', 'deflate');        break;    }    $cookies = explode(',', $clientcookies);    foreach ($cookies as $cookie)    {      if (strpos($cookie, '='))      {        $cookie = explode('=', $cookie);        $client->setCookie(trim($cookie[0]), trim(@$cookie[1]));      }    }    $msg = array();    switch ($action) {      case 'wrap':        @include('xmlrpc_wrappers.inc');        if (!function_exists('build_remote_method_wrapper_code'))        {          die('Error: to enable creation of method stubs the xmlrpc_wrappers.inc file is needed');        }        // fall thru intentionally      case 'describe':      case 'wrap':        $msg[0] =& new $msgclass('system.methodHelp', null, $id);        $msg[0]->addparam(new xmlrpcval($method));        $msg[1] =& new $msgclass('system.methodSignature', null, $id+1);        $msg[1]->addparam(new xmlrpcval($method));        $actionname = 'Description of method "'.$method.'"';        break;      case 'list':        $msg[0] =& new $msgclass('system.listMethods', null, $id);        $actionname = 'List of available methods';        break;      case 'execute':        if (!payload_is_safe($payload))          die("Tsk tsk tsk, please stop it or I will have to call in the cops!");        $msg[0] =& new $msgclass($method, null, $id);        // hack! build xml payload by hand        if ($wstype == 1)        {          $msg[0]->payload = "{\n".            '"method": "' . $method . "\",\n\"params\": [" .            $payload .            "\n],\n\"id\": ";            // fix: if user gave an empty string, use NULL, or we'll break json syntax            if ($id == "")            {                $msg[0]->payload .= "null\n}";            }            else            {              if (is_numeric($id) || $id == 'false' || $id == 'true' || $id == 'null')              {                $msg[0]->payload .= "$id\n}";              }              else              {                $msg[0]->payload .= "\"$id\"\n}";              }            }        }        else          $msg[0]->payload = $msg[0]->xml_header() .            '<methodName>' . $method . "</methodName>\n<params>" .            $payload .            "</params>\n" . $msg[0]->xml_footer();        $actionname = 'Execution of method '.$method;        break;      default: // give a warning        $actionname = '[ERROR: unknown action] "'.$action.'"';    }    // Before calling execute, echo out brief description of action taken + date and time ???    // this gives good user feedback for long-running methods...    echo '<h2>'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server)." ...</h2>\n";    flush();    $response = null;    // execute method(s)    if ($debug)      echo '<div class="dbginfo"><h2>Debug info:</h2>';  /// @todo use ob_start instead    $resp = array();    $mtime = explode(' ',microtime());    $time = (float)$mtime[0] + (float)$mtime[1];    foreach ($msg as $message)    {      // catch errors: for older xmlrpc libs, send does not return by ref      @$response =& $client->send($message, $timeout, $httpprotocol);      $resp[] = $response;      if (!$response || $response->faultCode())        break;    }    $mtime = explode(' ',microtime());    $time = (float)$mtime[0] + (float)$mtime[1] - $time;    if ($debug)      echo "</div>\n";    if ($response)    {    if ($response->faultCode())    {      // call failed! echo out error msg!      //echo '<h2>'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'</h2>';      echo "<h3>$protoname call FAILED!</h3>\n";      echo "<p>Fault code: [" . htmlspecialchars($response->faultCode()) .        "] Reason: '" . htmlspecialchars($response->faultString()) . "'</p>\n";      echo (strftime("%d/%b/%Y:%H:%M:%S\n"));    }    else    {      // call succeeded: parse results      //echo '<h2>'.htmlspecialchars($actionname).' on server '.htmlspecialchars($server).'</h2>';      printf ("<h3>%s call(s) OK (%.2f secs.)</h3>\n", $protoname, $time);      echo (strftime("%d/%b/%Y:%H:%M:%S\n"));      switch ($action)      {        case 'list':        $v = $response->value();        $max = $v->arraysize();

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -