Skip to content

Commit

Permalink
Fix : Variables are undefined in some case
Browse files Browse the repository at this point in the history
  • Loading branch information
s-renier-taonix-fr authored and f3l1x committed Feb 13, 2023
1 parent 382aaf2 commit ae53073
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions src/nusoap.php
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty
break;
case is_object($val):
$this->debug("serialize_val: serialize object");
$pXml = "";
if (get_class($val) == 'soapval') {
$this->debug("serialize_val: serialize soapval object");
$pXml = $val->serialize($use);
Expand Down Expand Up @@ -586,6 +587,9 @@ function serialize_val($val, $name = false, $type = false, $name_ns = false, $ty
$this->debug("serialize_val: serialize array");
$i = 0;
if (is_array($val) && count($val) > 0) {
$array_types = array ();
$tt_ns = "";
$tt = "";
foreach ($val as $v) {
if (is_object($v) && get_class($v) == 'soapval') {
$tt_ns = $v->type_ns;
Expand Down Expand Up @@ -1339,6 +1343,7 @@ function schemaStartElement($parser, $name, $attrs)
}
}
}
$eAttrs = array ();
foreach ($attrs as $k => $v) {
// expand each attribute
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
Expand Down Expand Up @@ -1391,6 +1396,8 @@ function schemaStartElement($parser, $name, $attrs)
} elseif (isset($attrs['ref'])) {
$aname = $attrs['ref'];
$this->attributes[$attrs['ref']] = $attrs;
} else {
$aname = '';
}

if ($this->currentComplexType) { // This should *always* be
Expand Down Expand Up @@ -2612,9 +2619,9 @@ function connect($connection_timeout = 0, $response_timeout = 30)
*/
function send($data, $timeout = 0, $response_timeout = 30, $cookies = null)
{

$this->debug('entered send() with data of length: ' . strlen($data));


$respdata = "";
$this->tryagain = true;
$tries = 0;
while ($this->tryagain) {
Expand Down Expand Up @@ -3000,12 +3007,13 @@ function sendRequest($data, $cookies = null)
function getResponse()
{
$this->incoming_payload = '';
$header_array = array ();
$data = '';

if ($this->io_method() == 'socket') {
// loop until headers have been retrieved
$data = '';
$pos = 0;
while (!isset($lb)) {

// We might EOF during header read.
if (feof($this->fp)) {
$this->incoming_payload = $data;
Expand Down Expand Up @@ -3304,6 +3312,7 @@ function getResponse()
// decode content-encoding
if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
$header_data = "";
// if decoding works, use it. else assume data wasn't gzencoded
if (function_exists('gzinflate')) {
//$timer->setMarker('starting decoding of gzip/deflated content');
Expand Down Expand Up @@ -3347,7 +3356,7 @@ function getResponse()
//$timer->setMarker('finished decoding of gzip/deflated content');
//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
// set decoded payload
$this->incoming_payload = $header_data . $lb . $lb . $data;
$this->incoming_payload = $header_data . (isset ($lb) ? $lb : "") . (isset ($lb) ? $lb : "") . $data;
} else {
$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
Expand Down Expand Up @@ -4096,6 +4105,7 @@ function invoke_method()

$class = '';
$method = '';
$try_class = '';
if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
$try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
if (class_exists($try_class)) {
Expand All @@ -4111,7 +4121,6 @@ function invoke_method()
$method = array_pop($split);
$class = implode('\\', $split);
} else {
$try_class = '';
$this->debug("in invoke_method, no class to try");
}

Expand Down Expand Up @@ -4564,6 +4573,9 @@ function register($name, $in = array(), $out = array(), $namespace = false, $soa
$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
} else {
$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
$HTTPS = '';
$SERVER_NAME = '';
$SCRIPT_NAME = '';
}
if ($HTTPS == '1' || $HTTPS == 'on') {
$SCHEME = 'https';
Expand Down Expand Up @@ -4646,6 +4658,10 @@ function configureWSDL($serviceName, $namespace = false, $endpoint = false, $sty
$HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off';
} else {
$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
$SERVER_PORT = '';
$SERVER_NAME = '';
$SCRIPT_NAME = '';
$HTTPS = '';
}
// If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI)
$colon = strpos($SERVER_NAME, ":");
Expand Down Expand Up @@ -5057,6 +5073,7 @@ function start_element($parser, $name, $attrs)
}
}
// expand each attribute prefix to its namespace
$eAttrs = array ();
foreach ($attrs as $k => $v) {
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
Expand Down Expand Up @@ -5497,6 +5514,7 @@ function webDescription()
$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
} else {
$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
$PHP_SELF = '';
}

$b = '
Expand Down Expand Up @@ -6266,15 +6284,14 @@ function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle =
$this->debug("in serializeType: returning: $xml");
return $xml;
}
$cols = '';
if (isset($typeDef['multidimensional'])) {
$nv = array();
foreach ($value as $v) {
$cols = ',' . sizeof($v);
$nv = array_merge($nv, $v);
}
$value = $nv;
} else {
$cols = '';
}
if (is_array($value) && sizeof($value) >= 1) {
$rows = sizeof($value);
Expand Down Expand Up @@ -6544,7 +6561,9 @@ function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $
}

if (count($attrs) > 0) {
$eAttrs = array ();
foreach ($attrs as $n => $a) {
$aa = array ();
// expand each attribute
foreach ($a as $k => $v) {
$k = strpos($k, ':') ? $this->expandQname($k) : $k;
Expand Down

0 comments on commit ae53073

Please sign in to comment.