aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Michel Vedrine <vedrine@vedrine.org>2018-01-02 16:09:44 +0100
committerJean-Michel Vedrine <vedrine@vedrine.org>2018-01-02 16:09:44 +0100
commitf3b9667fd8fccdf100e760cdd196573aa041968c (patch)
tree11fc3b805d727a1f06cced3c6b0cb2d2f259c507
parent99656366553e3eada13f4f3990ab109e925a108a (diff)
Fix style of xmlrpc-utils
-rw-r--r--questiontype.php1
-rw-r--r--tests/parser_test.php2
-rw-r--r--xmlrpc-utils.php74
3 files changed, 39 insertions, 38 deletions
diff --git a/questiontype.php b/questiontype.php
index 347b427..d2d283d 100644
--- a/questiontype.php
+++ b/questiontype.php
@@ -27,7 +27,6 @@ defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/question/type/questiontypebase.php');
require_once($CFG->dirroot . '/question/type/algebra/question.php');
require_once($CFG->dirroot . '/question/type/algebra/parser.php');
-require_once($CFG->dirroot . '/question/type/algebra/xmlrpc-utils.php');
/**
* ALGEBRA QUESTION TYPE CLASS
diff --git a/tests/parser_test.php b/tests/parser_test.php
index ae6b219..5d5eaad 100644
--- a/tests/parser_test.php
+++ b/tests/parser_test.php
@@ -60,6 +60,6 @@ class qtype_algebra_parser_test extends advanced_testcase {
$expr = $p->parse('sin(4 x) + cos(5 y)');
$this->assertEquals('\sin \left( 4 x_{} \right) + \cos \left( 5 y_{} \right)', $expr->tex());
$expr = $p->parse('sin(6*x) + cos(7*y)');
- $this->assertEquals('\sin \left( 6 x_{} \right) + \cos \left( 7 y_{} \right)', $expr->tex());
+ $this->assertEquals('\sin \left( 6 x_{} \right) + \cos \left( 7 y_{} \right)', $expr->tex());
}
}
diff --git a/xmlrpc-utils.php b/xmlrpc-utils.php
index 46efb78..218a95a 100644
--- a/xmlrpc-utils.php
+++ b/xmlrpc-utils.php
@@ -19,13 +19,15 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+defined('MOODLE_INTERNAL') || die();
+
/**
* This file was part of, or distributed with, libXMLRPC - a C library for
* xml-encoded function calls.
* Author: Dan Libby (dan@libby.com)
* Epinions.com may be contacted at feedback@epinions-inc.com
* It was adapted to Moodle standards and coding style
-*/
+ */
/*
Copyright 2001 Epinions, Inc.
@@ -60,49 +62,47 @@ if (!extension_loaded('xmlrpc')) {
/* generic function to call an http server with post method */
function xu_query_http_post($request, $host, $uri, $port, $debug,
$timeout, $user, $pass, $secure = false) {
- $response_buf = "";
+ $responsebuf = "";
if ($host && $uri && $port) {
- $content_len = strlen($request);
+ $contentlen = strlen($request);
$fsockopen = $secure ? "fsockopen_ssl" : "fsockopen";
- $query_fd = $fsockopen($host, $port, $errno, $errstr, 10);
-
- if ($query_fd) {
+ $queryfd = $fsockopen($host, $port, $errno, $errstr, 10);
+ if ($queryfd) {
$auth = "";
if ($user) {
$auth = "Authorization: Basic " .
base64_encode($user . ":" . $pass) . "\r\n";
}
- $http_request =
- "POST $uri HTTP/1.0\r\n" .
+ $myhttprequest = "POST $uri HTTP/1.0\r\n" .
"User-Agent: xmlrpc-epi-php/0.2 (PHP)\r\n" .
"Host: $host:$port\r\n" .
$auth .
"Content-Type: text/xml\r\n" .
- "Content-Length: $content_len\r\n" .
+ "Content-Length: $contentlen\r\n" .
"\r\n" .
$request;
- fputs($query_fd, $http_request, strlen($http_request));
+ fputs($queryfd, $myhttprequest, strlen($myhttprequest));
- $header_parsed = false;
+ $headerparsed = false;
- $line = fgets($query_fd, 4096);
+ $line = fgets($queryfd, 4096);
while ($line) {
- if (!$header_parsed) {
+ if (!$headerparsed) {
if ($line === "\r\n" || $line === "\n") {
- $header_parsed = 1;
+ $headerparsed = 1;
}
} else {
- $response_buf .= $line;
+ $responsebuf .= $line;
}
- $line = fgets($query_fd, 4096);
+ $line = fgets($queryfd, 4096);
}
- fclose($query_fd);
+ fclose($queryfd);
} else {
debugging('Socket open faile', DEBUG_DEVELOPER);
}
@@ -110,27 +110,27 @@ function xu_query_http_post($request, $host, $uri, $port, $debug,
debugging('Missing param(s)', DEBUG_DEVELOPER);
}
- return $response_buf;
+ return $responsebuf;
}
function xu_fault_code($code, $string) {
- return array('faultCode' => $code,
- 'faultString' => $string);
+ return array('faultCode' => $code,
+ 'faultString' => $string);
}
function find_and_decode_xml($buf, $debug) {
if (strlen($buf)) {
- $xml_begin = substr($buf, strpos($buf, "<?xml"));
- if (strlen($xml_begin)) {
- $retval = xmlrpc_decode($xml_begin);
+ $xmlbegin = substr($buf, strpos($buf, "<?xml"));
+ if (strlen($xmlbegin)) {
+ $retval = xmlrpc_decode($xmlbegin);
} else {
debugging('xml start token not found', DEBUG_DEVELOPER);
}
- } else {
+ } else {
debugging('no data', DEBUG_DEVELOPER);
- }
- return $retval;
+ }
+ return $retval;
}
@@ -180,26 +180,28 @@ function xu_rpc_http_concise($params) {
$host = $uri = $port = $method = $args = $debug = null;
$timeout = $user = $pass = $secure = $debug = null;
- extract($params);
+ foreach ($params as $key => $value) {
+ $$key = $value;
+ }
// Default values.
- if(!$port) {
+ if (!$port) {
$port = 80;
}
- if(!$uri) {
+ if (!$uri) {
$uri = '/';
}
- if(!isset($output)) {
+ if (!isset($output)) {
$output = array('version' => 'xmlrpc');
}
- $response_buf = "";
+ $responsebuf = "";
if ($host && $uri && $port) {
- $request_xml = xmlrpc_encode_request($method, $args, $output);
- $response_buf = xu_query_http_post($request_xml, $host, $uri, $port, $debug,
+ $requestxml = xmlrpc_encode_request($method, $args, $output);
+ $responsebuf = xu_query_http_post($requestxml, $host, $uri, $port, $debug,
$timeout, $user, $pass, $secure);
- $retval = find_and_decode_xml($response_buf, $debug);
+ $retval = find_and_decode_xml($responsebuf, $debug);
}
return $retval;
}
@@ -225,8 +227,8 @@ function xu_rpc_http($method, $args, $host, $uri="/", $port=80, $debug=false,
function xu_is_fault($arg) {
- // The xmlrpc extension finally supports this.
- return is_array($arg) ? xmlrpc_is_fault($arg) : false;
+ // The xmlrpc extension finally supports this.
+ return is_array($arg) ? xmlrpc_is_fault($arg) : false;
}
/* Sets some http headers and prints xml */