@@ -84,6 +84,9 @@ discard block |
||
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | + /** |
|
| 88 | + * @param integer $rowNumber |
|
| 89 | + */ |
|
| 87 | 90 | public static function fromQueryResult($adb, $result, $rowNumber) |
| 88 | 91 | { |
| 89 | 92 | return new WebserviceField($adb, $adb->query_result_rowdata($result, $rowNumber)); |
@@ -147,6 +150,9 @@ discard block |
||
| 147 | 150 | return $this->default; |
| 148 | 151 | } |
| 149 | 152 | |
| 153 | + /** |
|
| 154 | + * @return string |
|
| 155 | + */ |
|
| 150 | 156 | public function getColumnName() |
| 151 | 157 | { |
| 152 | 158 | return $this->columnName; |
@@ -203,6 +209,9 @@ discard block |
||
| 203 | 209 | return false; |
| 204 | 210 | } |
| 205 | 211 | |
| 212 | + /** |
|
| 213 | + * @param boolean $nullable |
|
| 214 | + */ |
|
| 206 | 215 | private function setNullable($nullable) |
| 207 | 216 | { |
| 208 | 217 | $this->nullable = $nullable; |
@@ -198,8 +198,9 @@ discard block |
||
| 198 | 198 | |
| 199 | 199 | public function isReadOnly() |
| 200 | 200 | { |
| 201 | - if ($this->readOnly == 1) |
|
| 202 | - return true; |
|
| 201 | + if ($this->readOnly == 1) { |
|
| 202 | + return true; |
|
| 203 | + } |
|
| 203 | 204 | return false; |
| 204 | 205 | } |
| 205 | 206 | |
@@ -307,8 +308,9 @@ discard block |
||
| 307 | 308 | $numRows = $this->pearDB->num_rows($result); |
| 308 | 309 | for ($i = 0; $i < $numRows; ++$i) { |
| 309 | 310 | $referenceType = $this->pearDB->query_result($result, $i, "type"); |
| 310 | - if (in_array($referenceType, $accessibleTypes)) |
|
| 311 | - array_push($referenceTypes, $referenceType); |
|
| 311 | + if (in_array($referenceType, $accessibleTypes)) { |
|
| 312 | + array_push($referenceTypes, $referenceType); |
|
| 313 | + } |
|
| 312 | 314 | } |
| 313 | 315 | } else { |
| 314 | 316 | $fieldModel = Vtiger_Field_Model::getInstanceFromFieldId($this->getFieldId()); |
@@ -425,21 +427,23 @@ discard block |
||
| 425 | 427 | $picklistValue = $this->pearDB->query_result($result, $i, $fieldName); |
| 426 | 428 | $picklistValue = decode_html($picklistValue); |
| 427 | 429 | $moduleName = getTabModuleName($this->getTabId()); |
| 428 | - if ($moduleName == 'Events') |
|
| 429 | - $moduleName = 'Calendar'; |
|
| 430 | + if ($moduleName == 'Events') { |
|
| 431 | + $moduleName = 'Calendar'; |
|
| 432 | + } |
|
| 430 | 433 | $elem["label"] = \includes\Language::translate($picklistValue, $moduleName); |
| 431 | 434 | $elem["value"] = $picklistValue; |
| 432 | 435 | array_push($options, $elem); |
| 433 | 436 | } |
| 434 | - }else { |
|
| 437 | + } else { |
|
| 435 | 438 | $user = VTWS_PreserveGlobal::getGlobal('current_user'); |
| 436 | 439 | $details = \includes\fields\Picklist::getRoleBasedPicklistValues($fieldName, $user->roleid); |
| 437 | 440 | for ($i = 0; $i < sizeof($details); ++$i) { |
| 438 | 441 | $elem = []; |
| 439 | 442 | $picklistValue = decode_html($details[$i]); |
| 440 | 443 | $moduleName = getTabModuleName($this->getTabId()); |
| 441 | - if ($moduleName == 'Events') |
|
| 442 | - $moduleName = 'Calendar'; |
|
| 444 | + if ($moduleName == 'Events') { |
|
| 445 | + $moduleName = 'Calendar'; |
|
| 446 | + } |
|
| 443 | 447 | $elem["label"] = \includes\Language::translate($picklistValue, $moduleName); |
| 444 | 448 | $elem["value"] = $picklistValue; |
| 445 | 449 | array_push($options, $elem); |
@@ -41,7 +41,7 @@ |
||
| 41 | 41 | module_name=?, summary=?, test=?, execution_condition=?, defaultworkflow=?, filtersavedinnew=?, |
| 42 | 42 | schtypeid=?, schtime=?, schdayofmonth=?, schdayofweek=?, schannualdates=?, nexttrigger_time=? where workflow_id=?", array($wf->moduleName, $wf->description, $wf->test, $wf->executionCondition, $wf->defaultworkflow, $wf->filtersavedinnew, |
| 43 | 43 | $wf->schtypeid, $wf->schtime, $wf->schdayofmonth, $wf->schdayofweek, $wf->schannualdates, $wf->nexttrigger_time, $wf->id)); |
| 44 | - }else { |
|
| 44 | + } else { |
|
| 45 | 45 | $workflowId = $adb->getUniqueID("com_vtiger_workflows"); |
| 46 | 46 | $workflow->id = $workflowId; |
| 47 | 47 | $wf = $workflow; |
@@ -19,6 +19,11 @@ |
||
| 19 | 19 | return false; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | + /** |
|
| 23 | + * @param Vtiger_Request $request |
|
| 24 | + * |
|
| 25 | + * @return Vtiger_Request |
|
| 26 | + */ |
|
| 22 | 27 | public function setLanguage($request) |
| 23 | 28 | { |
| 24 | 29 | if (!$request->get('lang')) { |
@@ -87,8 +87,9 @@ |
||
| 87 | 87 | public function process(Vtiger_Request $request) |
| 88 | 88 | { |
| 89 | 89 | $default_charset = AppConfig::main('default_charset'); |
| 90 | - if (empty($default_charset)) |
|
| 91 | - $default_charset = 'UTF-8'; |
|
| 90 | + if (empty($default_charset)) { |
|
| 91 | + $default_charset = 'UTF-8'; |
|
| 92 | + } |
|
| 92 | 93 | $mode = $request->getMode(); |
| 93 | 94 | if (!empty($mode) && $this->isMethodExposed($mode)) { |
| 94 | 95 | return $this->$mode($request); |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | /** |
| 212 | 212 | * Checks if this is a post request, and if it is, checks if the nonce is valid. |
| 213 | 213 | * @param bool $fatal Whether or not to fatally error out if there is a problem. |
| 214 | - * @return True if check passes or is not necessary, false if failure. |
|
| 214 | + * @return boolean|null if check passes or is not necessary, false if failure. |
|
| 215 | 215 | */ |
| 216 | 216 | function csrf_check($fatal = true) { |
| 217 | 217 | if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; |
@@ -281,6 +281,9 @@ discard block |
||
| 281 | 281 | } |
| 282 | 282 | return $ret; |
| 283 | 283 | } |
| 284 | +/** |
|
| 285 | + * @param integer $level |
|
| 286 | + */ |
|
| 284 | 287 | function csrf_flattenpost2($level, $key, $data) { |
| 285 | 288 | if(!is_array($data)) return array($key => $data); |
| 286 | 289 | $ret = array(); |
@@ -166,35 +166,35 @@ discard block |
||
| 166 | 166 | if (!$is_html) return $buffer; |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | - $count=1; |
|
| 169 | + $count = 1; |
|
| 170 | 170 | $tokens = csrf_get_tokens(); |
| 171 | 171 | $name = $GLOBALS['csrf']['input-name']; |
| 172 | 172 | $endslash = $GLOBALS['csrf']['xhtml'] ? ' /' : ''; |
| 173 | 173 | $input = "<input type='hidden' name='$name' value=\"$tokens\"$endslash>"; |
| 174 | 174 | $buffer = preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i', '$1' . $input, $buffer); |
| 175 | 175 | if ($GLOBALS['csrf']['frame-breaker'] && !$is_partial) { |
| 176 | - $buffer = preg_replace('/<\/head>/', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer,$count); |
|
| 176 | + $buffer = preg_replace('/<\/head>/', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer, $count); |
|
| 177 | 177 | } |
| 178 | 178 | if (($js = $GLOBALS['csrf']['rewrite-js']) && !$is_partial) { |
| 179 | 179 | global $dbconfig; |
| 180 | 180 | if (empty($dbconfig) || empty($dbconfig['db_name']) || $dbconfig['db_name'] == '_DBC_TYPE_') { |
| 181 | 181 | $buffer = preg_replace( |
| 182 | 182 | '/<\/head>/', |
| 183 | - '<script type="text/javascript">'. |
|
| 184 | - 'var csrfMagicToken = "'.$tokens.'";'. |
|
| 185 | - 'var csrfMagicName = "'.$name.'";</script>'. |
|
| 186 | - '<script src="../'.$js.'" type="text/javascript"></script></head>', |
|
| 187 | - $buffer,$count |
|
| 183 | + '<script type="text/javascript">' . |
|
| 184 | + 'var csrfMagicToken = "' . $tokens . '";' . |
|
| 185 | + 'var csrfMagicName = "' . $name . '";</script>' . |
|
| 186 | + '<script src="../' . $js . '" type="text/javascript"></script></head>', |
|
| 187 | + $buffer, $count |
|
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | } else { |
| 191 | 191 | $buffer = preg_replace( |
| 192 | 192 | '/<\/head>/', |
| 193 | - '<script type="text/javascript">'. |
|
| 194 | - 'var csrfMagicToken = "'.$tokens.'";'. |
|
| 195 | - 'var csrfMagicName = "'.$name.'";</script>'. |
|
| 196 | - '<script src="'.$js.'" type="text/javascript"></script></head>', |
|
| 197 | - $buffer,$count |
|
| 193 | + '<script type="text/javascript">' . |
|
| 194 | + 'var csrfMagicToken = "' . $tokens . '";' . |
|
| 195 | + 'var csrfMagicName = "' . $name . '";</script>' . |
|
| 196 | + '<script src="' . $js . '" type="text/javascript"></script></head>', |
|
| 197 | + $buffer, $count |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
@@ -276,17 +276,17 @@ discard block |
||
| 276 | 276 | |
| 277 | 277 | function csrf_flattenpost($data) { |
| 278 | 278 | $ret = array(); |
| 279 | - foreach($data as $n => $v) { |
|
| 279 | + foreach ($data as $n => $v) { |
|
| 280 | 280 | $ret = array_merge($ret, csrf_flattenpost2(1, $n, $v)); |
| 281 | 281 | } |
| 282 | 282 | return $ret; |
| 283 | 283 | } |
| 284 | 284 | function csrf_flattenpost2($level, $key, $data) { |
| 285 | - if(!is_array($data)) return array($key => $data); |
|
| 285 | + if (!is_array($data)) return array($key => $data); |
|
| 286 | 286 | $ret = array(); |
| 287 | - foreach($data as $n => $v) { |
|
| 288 | - $nk = $level >= 1 ? $key."[$n]" : "[$n]"; |
|
| 289 | - $ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v)); |
|
| 287 | + foreach ($data as $n => $v) { |
|
| 288 | + $nk = $level >= 1 ? $key . "[$n]" : "[$n]"; |
|
| 289 | + $ret = array_merge($ret, csrf_flattenpost2($level + 1, $nk, $v)); |
|
| 290 | 290 | } |
| 291 | 291 | return $ret; |
| 292 | 292 | } |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | $data = ''; |
| 301 | 301 | foreach (csrf_flattenpost($_POST) as $key => $value) { |
| 302 | 302 | if ($key == $GLOBALS['csrf']['input-name']) continue; |
| 303 | - $data .= '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($value).'" />'; |
|
| 303 | + $data .= '<input type="hidden" name="' . htmlspecialchars($key) . '" value="' . htmlspecialchars($value) . '" />'; |
|
| 304 | 304 | } |
| 305 | 305 | echo "<html><head><title>CSRF check failed</title></head> |
| 306 | 306 | <body> |
@@ -408,7 +408,7 @@ discard block |
||
| 408 | 408 | if (is_writable($dir)) { |
| 409 | 409 | $secret = csrf_generate_secret(); |
| 410 | 410 | $fh = fopen($file, 'w'); |
| 411 | - fwrite($fh, '<?php $secret = "'.$secret.'";' . PHP_EOL); |
|
| 411 | + fwrite($fh, '<?php $secret = "' . $secret . '";' . PHP_EOL); |
|
| 412 | 412 | fclose($fh); |
| 413 | 413 | return $secret; |
| 414 | 414 | } |
@@ -157,13 +157,16 @@ discard block |
||
| 157 | 157 | // Determine based on content type. |
| 158 | 158 | $headers = headers_list(); |
| 159 | 159 | foreach ($headers as $header) { |
| 160 | - if ($is_html) break; |
|
| 161 | - else if (stripos('Content-type', $header) !== false && stripos('/html', $header) === false) { |
|
| 160 | + if ($is_html) { |
|
| 161 | + break; |
|
| 162 | + } else if (stripos('Content-type', $header) !== false && stripos('/html', $header) === false) { |
|
| 162 | 163 | $is_html = false; |
| 163 | 164 | } |
| 164 | 165 | } |
| 165 | 166 | |
| 166 | - if (!$is_html) return $buffer; |
|
| 167 | + if (!$is_html) { |
|
| 168 | + return $buffer; |
|
| 169 | + } |
|
| 167 | 170 | } |
| 168 | 171 | } |
| 169 | 172 | $count=1; |
@@ -214,22 +217,30 @@ discard block |
||
| 214 | 217 | * @return True if check passes or is not necessary, false if failure. |
| 215 | 218 | */ |
| 216 | 219 | function csrf_check($fatal = true) { |
| 217 | - if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; |
|
| 220 | + if ($_SERVER['REQUEST_METHOD'] !== 'POST') { |
|
| 221 | + return true; |
|
| 222 | + } |
|
| 218 | 223 | csrf_start(); |
| 219 | 224 | $name = $GLOBALS['csrf']['input-name']; |
| 220 | 225 | $ok = false; |
| 221 | 226 | $tokens = ''; |
| 222 | 227 | do { |
| 223 | - if (!isset($_POST[$name])) break; |
|
| 228 | + if (!isset($_POST[$name])) { |
|
| 229 | + break; |
|
| 230 | + } |
|
| 224 | 231 | // we don't regenerate a token and check it because some token creation |
| 225 | 232 | // schemes are volatile. |
| 226 | 233 | $tokens = $_POST[$name]; |
| 227 | - if (!csrf_check_tokens($tokens)) break; |
|
| 234 | + if (!csrf_check_tokens($tokens)) { |
|
| 235 | + break; |
|
| 236 | + } |
|
| 228 | 237 | $ok = true; |
| 229 | 238 | } while (false); |
| 230 | 239 | if ($fatal && !$ok) { |
| 231 | 240 | $callback = $GLOBALS['csrf']['callback']; |
| 232 | - if (trim($tokens, 'A..Za..z0..9:;,') !== '') $tokens = 'hidden'; |
|
| 241 | + if (trim($tokens, 'A..Za..z0..9:;,') !== '') { |
|
| 242 | + $tokens = 'hidden'; |
|
| 243 | + } |
|
| 233 | 244 | $callback($tokens); |
| 234 | 245 | exit; |
| 235 | 246 | } |
@@ -256,15 +267,21 @@ discard block |
||
| 256 | 267 | csrf_start(); |
| 257 | 268 | |
| 258 | 269 | // These are "strong" algorithms that don't require per se a secret |
| 259 | - if (session_id()) return 'sid:' . csrf_hash(session_id()) . $ip; |
|
| 270 | + if (session_id()) { |
|
| 271 | + return 'sid:' . csrf_hash(session_id()) . $ip; |
|
| 272 | + } |
|
| 260 | 273 | if ($GLOBALS['csrf']['cookie']) { |
| 261 | 274 | $val = csrf_generate_secret(); |
| 262 | 275 | setcookie($GLOBALS['csrf']['cookie'], $val); |
| 263 | 276 | return 'cookie:' . csrf_hash($val) . $ip; |
| 264 | 277 | } |
| 265 | - if ($GLOBALS['csrf']['key']) return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip; |
|
| 278 | + if ($GLOBALS['csrf']['key']) { |
|
| 279 | + return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip; |
|
| 280 | + } |
|
| 266 | 281 | // These further algorithms require a server-side secret |
| 267 | - if (!$secret) return 'invalid'; |
|
| 282 | + if (!$secret) { |
|
| 283 | + return 'invalid'; |
|
| 284 | + } |
|
| 268 | 285 | if ($GLOBALS['csrf']['user'] !== false) { |
| 269 | 286 | return 'user:' . csrf_hash($GLOBALS['csrf']['user']); |
| 270 | 287 | } |
@@ -282,7 +299,9 @@ discard block |
||
| 282 | 299 | return $ret; |
| 283 | 300 | } |
| 284 | 301 | function csrf_flattenpost2($level, $key, $data) { |
| 285 | - if(!is_array($data)) return array($key => $data); |
|
| 302 | + if(!is_array($data)) { |
|
| 303 | + return array($key => $data); |
|
| 304 | + } |
|
| 286 | 305 | $ret = array(); |
| 287 | 306 | foreach($data as $n => $v) { |
| 288 | 307 | $nk = $level >= 1 ? $key."[$n]" : "[$n]"; |
@@ -299,7 +318,9 @@ discard block |
||
| 299 | 318 | header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); |
| 300 | 319 | $data = ''; |
| 301 | 320 | foreach (csrf_flattenpost($_POST) as $key => $value) { |
| 302 | - if ($key == $GLOBALS['csrf']['input-name']) continue; |
|
| 321 | + if ($key == $GLOBALS['csrf']['input-name']) { |
|
| 322 | + continue; |
|
| 323 | + } |
|
| 303 | 324 | $data .= '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($value).'" />'; |
| 304 | 325 | } |
| 305 | 326 | echo "<html><head><title>CSRF check failed</title></head> |
@@ -325,9 +346,13 @@ discard block |
||
| 325 | 346 | * instead of csrf_check_token() |
| 326 | 347 | */ |
| 327 | 348 | function csrf_check_tokens($tokens) { |
| 328 | - if (is_string($tokens)) $tokens = explode(';', $tokens); |
|
| 349 | + if (is_string($tokens)) { |
|
| 350 | + $tokens = explode(';', $tokens); |
|
| 351 | + } |
|
| 329 | 352 | foreach ($tokens as $token) { |
| 330 | - if (csrf_check_token($token)) return true; |
|
| 353 | + if (csrf_check_token($token)) { |
|
| 354 | + return true; |
|
| 355 | + } |
|
| 331 | 356 | } |
| 332 | 357 | return false; |
| 333 | 358 | } |
@@ -336,38 +361,62 @@ discard block |
||
| 336 | 361 | * Checks if a token is valid. |
| 337 | 362 | */ |
| 338 | 363 | function csrf_check_token($token) { |
| 339 | - if (strpos($token, ':') === false) return false; |
|
| 364 | + if (strpos($token, ':') === false) { |
|
| 365 | + return false; |
|
| 366 | + } |
|
| 340 | 367 | list($type, $value) = explode(':', $token, 2); |
| 341 | - if (strpos($value, ',') === false) return false; |
|
| 368 | + if (strpos($value, ',') === false) { |
|
| 369 | + return false; |
|
| 370 | + } |
|
| 342 | 371 | list($x, $time) = explode(',', $token, 2); |
| 343 | 372 | if ($GLOBALS['csrf']['expires']) { |
| 344 | - if (time() > $time + $GLOBALS['csrf']['expires']) return false; |
|
| 373 | + if (time() > $time + $GLOBALS['csrf']['expires']) { |
|
| 374 | + return false; |
|
| 375 | + } |
|
| 345 | 376 | } |
| 346 | 377 | switch ($type) { |
| 347 | 378 | case 'sid': |
| 348 | 379 | return $value === csrf_hash(session_id(), $time); |
| 349 | 380 | case 'cookie': |
| 350 | 381 | $n = $GLOBALS['csrf']['cookie']; |
| 351 | - if (!$n) return false; |
|
| 352 | - if (!isset($_COOKIE[$n])) return false; |
|
| 382 | + if (!$n) { |
|
| 383 | + return false; |
|
| 384 | + } |
|
| 385 | + if (!isset($_COOKIE[$n])) { |
|
| 386 | + return false; |
|
| 387 | + } |
|
| 353 | 388 | return $value === csrf_hash($_COOKIE[$n], $time); |
| 354 | 389 | case 'key': |
| 355 | - if (!$GLOBALS['csrf']['key']) return false; |
|
| 390 | + if (!$GLOBALS['csrf']['key']) { |
|
| 391 | + return false; |
|
| 392 | + } |
|
| 356 | 393 | return $value === csrf_hash($GLOBALS['csrf']['key'], $time); |
| 357 | 394 | // We could disable these 'weaker' checks if 'key' was set, but |
| 358 | 395 | // that doesn't make me feel good then about the cookie-based |
| 359 | 396 | // implementation. |
| 360 | 397 | case 'user': |
| 361 | - if (!csrf_get_secret()) return false; |
|
| 362 | - if ($GLOBALS['csrf']['user'] === false) return false; |
|
| 398 | + if (!csrf_get_secret()) { |
|
| 399 | + return false; |
|
| 400 | + } |
|
| 401 | + if ($GLOBALS['csrf']['user'] === false) { |
|
| 402 | + return false; |
|
| 403 | + } |
|
| 363 | 404 | return $value === csrf_hash($GLOBALS['csrf']['user'], $time); |
| 364 | 405 | case 'ip': |
| 365 | - if (!csrf_get_secret()) return false; |
|
| 406 | + if (!csrf_get_secret()) { |
|
| 407 | + return false; |
|
| 408 | + } |
|
| 366 | 409 | // do not allow IP-based checks if the username is set, or if |
| 367 | 410 | // the browser sent cookies |
| 368 | - if ($GLOBALS['csrf']['user'] !== false) return false; |
|
| 369 | - if (!empty($_COOKIE)) return false; |
|
| 370 | - if (!$GLOBALS['csrf']['allow-ip']) return false; |
|
| 411 | + if ($GLOBALS['csrf']['user'] !== false) { |
|
| 412 | + return false; |
|
| 413 | + } |
|
| 414 | + if (!empty($_COOKIE)) { |
|
| 415 | + return false; |
|
| 416 | + } |
|
| 417 | + if (!$GLOBALS['csrf']['allow-ip']) { |
|
| 418 | + return false; |
|
| 419 | + } |
|
| 371 | 420 | return $value === csrf_hash($_SERVER['IP_ADDRESS'], $time); |
| 372 | 421 | } |
| 373 | 422 | return false; |
@@ -397,7 +446,9 @@ discard block |
||
| 397 | 446 | * Retrieves the secret, and generates one if necessary. |
| 398 | 447 | */ |
| 399 | 448 | function csrf_get_secret() { |
| 400 | - if ($GLOBALS['csrf']['secret']) return $GLOBALS['csrf']['secret']; |
|
| 449 | + if ($GLOBALS['csrf']['secret']) { |
|
| 450 | + return $GLOBALS['csrf']['secret']; |
|
| 451 | + } |
|
| 401 | 452 | $dir = dirname(__FILE__); |
| 402 | 453 | $file = $dir . '/../../config/csrf_secret.php'; |
| 403 | 454 | $secret = ''; |
@@ -432,13 +483,21 @@ discard block |
||
| 432 | 483 | * from the current time. |
| 433 | 484 | */ |
| 434 | 485 | function csrf_hash($value, $time = null) { |
| 435 | - if (!$time) $time = time(); |
|
| 486 | + if (!$time) { |
|
| 487 | + $time = time(); |
|
| 488 | + } |
|
| 436 | 489 | return sha1(csrf_get_secret() . $value . $time) . ',' . $time; |
| 437 | 490 | } |
| 438 | 491 | |
| 439 | 492 | // Load user configuration |
| 440 | -if (function_exists('csrf_startup')) csrf_startup(); |
|
| 493 | +if (function_exists('csrf_startup')) { |
|
| 494 | + csrf_startup(); |
|
| 495 | +} |
|
| 441 | 496 | // Initialize our handler |
| 442 | -if ($GLOBALS['csrf']['rewrite']) ob_start('csrf_ob_handler'); |
|
| 497 | +if ($GLOBALS['csrf']['rewrite']) { |
|
| 498 | + ob_start('csrf_ob_handler'); |
|
| 499 | +} |
|
| 443 | 500 | // Perform check |
| 444 | -if (!$GLOBALS['csrf']['defer']) csrf_check(); |
|
| 501 | +if (!$GLOBALS['csrf']['defer']) { |
|
| 502 | + csrf_check(); |
|
| 503 | +} |
|
@@ -138,17 +138,17 @@ discard block |
||
| 138 | 138 | * inject our JavaScript library. |
| 139 | 139 | */ |
| 140 | 140 | function csrf_ob_handler($buffer, $flags) { |
| 141 | - // Even though the user told us to rewrite, we should do a quick heuristic |
|
| 142 | - // to check if the page is *actually* HTML. We don't begin rewriting until |
|
| 143 | - // we hit the first <html tag. |
|
| 144 | - static $is_html = false; |
|
| 145 | - static $is_partial = false; |
|
| 141 | + // Even though the user told us to rewrite, we should do a quick heuristic |
|
| 142 | + // to check if the page is *actually* HTML. We don't begin rewriting until |
|
| 143 | + // we hit the first <html tag. |
|
| 144 | + static $is_html = false; |
|
| 145 | + static $is_partial = false; |
|
| 146 | 146 | |
| 147 | - if (!$is_html) { |
|
| 148 | - // not HTML until proven otherwise |
|
| 149 | - if (stripos($buffer, '<html') !== false) { |
|
| 150 | - $is_html = true; |
|
| 151 | - } else { |
|
| 147 | + if (!$is_html) { |
|
| 148 | + // not HTML until proven otherwise |
|
| 149 | + if (stripos($buffer, '<html') !== false) { |
|
| 150 | + $is_html = true; |
|
| 151 | + } else { |
|
| 152 | 152 | |
| 153 | 153 | // Customized to take the partial HTML with form |
| 154 | 154 | $is_html = true; |
@@ -164,48 +164,48 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | if (!$is_html) return $buffer; |
| 167 | - } |
|
| 168 | - } |
|
| 169 | - $count=1; |
|
| 170 | - $tokens = csrf_get_tokens(); |
|
| 171 | - $name = $GLOBALS['csrf']['input-name']; |
|
| 172 | - $endslash = $GLOBALS['csrf']['xhtml'] ? ' /' : ''; |
|
| 173 | - $input = "<input type='hidden' name='$name' value=\"$tokens\"$endslash>"; |
|
| 174 | - $buffer = preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i', '$1' . $input, $buffer); |
|
| 175 | - if ($GLOBALS['csrf']['frame-breaker'] && !$is_partial) { |
|
| 176 | - $buffer = preg_replace('/<\/head>/', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer,$count); |
|
| 177 | - } |
|
| 178 | - if (($js = $GLOBALS['csrf']['rewrite-js']) && !$is_partial) { |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | + $count=1; |
|
| 170 | + $tokens = csrf_get_tokens(); |
|
| 171 | + $name = $GLOBALS['csrf']['input-name']; |
|
| 172 | + $endslash = $GLOBALS['csrf']['xhtml'] ? ' /' : ''; |
|
| 173 | + $input = "<input type='hidden' name='$name' value=\"$tokens\"$endslash>"; |
|
| 174 | + $buffer = preg_replace('#(<form[^>]*method\s*=\s*["\']post["\'][^>]*>)#i', '$1' . $input, $buffer); |
|
| 175 | + if ($GLOBALS['csrf']['frame-breaker'] && !$is_partial) { |
|
| 176 | + $buffer = preg_replace('/<\/head>/', '<script type="text/javascript">if (top != self) {top.location.href = self.location.href;}</script></head>', $buffer,$count); |
|
| 177 | + } |
|
| 178 | + if (($js = $GLOBALS['csrf']['rewrite-js']) && !$is_partial) { |
|
| 179 | 179 | global $dbconfig; |
| 180 | - if (empty($dbconfig) || empty($dbconfig['db_name']) || $dbconfig['db_name'] == '_DBC_TYPE_') { |
|
| 180 | + if (empty($dbconfig) || empty($dbconfig['db_name']) || $dbconfig['db_name'] == '_DBC_TYPE_') { |
|
| 181 | 181 | $buffer = preg_replace( |
| 182 | - '/<\/head>/', |
|
| 183 | - '<script type="text/javascript">'. |
|
| 184 | - 'var csrfMagicToken = "'.$tokens.'";'. |
|
| 185 | - 'var csrfMagicName = "'.$name.'";</script>'. |
|
| 186 | - '<script src="../'.$js.'" type="text/javascript"></script></head>', |
|
| 187 | - $buffer,$count |
|
| 182 | + '/<\/head>/', |
|
| 183 | + '<script type="text/javascript">'. |
|
| 184 | + 'var csrfMagicToken = "'.$tokens.'";'. |
|
| 185 | + 'var csrfMagicName = "'.$name.'";</script>'. |
|
| 186 | + '<script src="../'.$js.'" type="text/javascript"></script></head>', |
|
| 187 | + $buffer,$count |
|
| 188 | 188 | ); |
| 189 | 189 | |
| 190 | 190 | } else { |
| 191 | 191 | $buffer = preg_replace( |
| 192 | - '/<\/head>/', |
|
| 193 | - '<script type="text/javascript">'. |
|
| 194 | - 'var csrfMagicToken = "'.$tokens.'";'. |
|
| 195 | - 'var csrfMagicName = "'.$name.'";</script>'. |
|
| 196 | - '<script src="'.$js.'" type="text/javascript"></script></head>', |
|
| 197 | - $buffer,$count |
|
| 192 | + '/<\/head>/', |
|
| 193 | + '<script type="text/javascript">'. |
|
| 194 | + 'var csrfMagicToken = "'.$tokens.'";'. |
|
| 195 | + 'var csrfMagicName = "'.$name.'";</script>'. |
|
| 196 | + '<script src="'.$js.'" type="text/javascript"></script></head>', |
|
| 197 | + $buffer,$count |
|
| 198 | 198 | ); |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - $script = '<script type="text/javascript">CsrfMagic.end();</script>'; |
|
| 201 | + $script = '<script type="text/javascript">CsrfMagic.end();</script>'; |
|
| 202 | 202 | |
| 203 | - $buffer = preg_replace('/<\/body>/', $script . '</body>', $buffer, $count); |
|
| 204 | - if (!$count) { |
|
| 205 | - $buffer .= $script; |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - return $buffer; |
|
| 203 | + $buffer = preg_replace('/<\/body>/', $script . '</body>', $buffer, $count); |
|
| 204 | + if (!$count) { |
|
| 205 | + $buffer .= $script; |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + return $buffer; |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
@@ -214,26 +214,26 @@ discard block |
||
| 214 | 214 | * @return True if check passes or is not necessary, false if failure. |
| 215 | 215 | */ |
| 216 | 216 | function csrf_check($fatal = true) { |
| 217 | - if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; |
|
| 218 | - csrf_start(); |
|
| 219 | - $name = $GLOBALS['csrf']['input-name']; |
|
| 220 | - $ok = false; |
|
| 221 | - $tokens = ''; |
|
| 222 | - do { |
|
| 223 | - if (!isset($_POST[$name])) break; |
|
| 224 | - // we don't regenerate a token and check it because some token creation |
|
| 225 | - // schemes are volatile. |
|
| 226 | - $tokens = $_POST[$name]; |
|
| 227 | - if (!csrf_check_tokens($tokens)) break; |
|
| 228 | - $ok = true; |
|
| 229 | - } while (false); |
|
| 230 | - if ($fatal && !$ok) { |
|
| 231 | - $callback = $GLOBALS['csrf']['callback']; |
|
| 232 | - if (trim($tokens, 'A..Za..z0..9:;,') !== '') $tokens = 'hidden'; |
|
| 233 | - $callback($tokens); |
|
| 234 | - exit; |
|
| 235 | - } |
|
| 236 | - return $ok; |
|
| 217 | + if ($_SERVER['REQUEST_METHOD'] !== 'POST') return true; |
|
| 218 | + csrf_start(); |
|
| 219 | + $name = $GLOBALS['csrf']['input-name']; |
|
| 220 | + $ok = false; |
|
| 221 | + $tokens = ''; |
|
| 222 | + do { |
|
| 223 | + if (!isset($_POST[$name])) break; |
|
| 224 | + // we don't regenerate a token and check it because some token creation |
|
| 225 | + // schemes are volatile. |
|
| 226 | + $tokens = $_POST[$name]; |
|
| 227 | + if (!csrf_check_tokens($tokens)) break; |
|
| 228 | + $ok = true; |
|
| 229 | + } while (false); |
|
| 230 | + if ($fatal && !$ok) { |
|
| 231 | + $callback = $GLOBALS['csrf']['callback']; |
|
| 232 | + if (trim($tokens, 'A..Za..z0..9:;,') !== '') $tokens = 'hidden'; |
|
| 233 | + $callback($tokens); |
|
| 234 | + exit; |
|
| 235 | + } |
|
| 236 | + return $ok; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
@@ -241,67 +241,67 @@ discard block |
||
| 241 | 241 | * by semicolons. |
| 242 | 242 | */ |
| 243 | 243 | function csrf_get_tokens() { |
| 244 | - $has_cookies = !empty($_COOKIE); |
|
| 245 | - |
|
| 246 | - // $ip implements a composite key, which is sent if the user hasn't sent |
|
| 247 | - // any cookies. It may or may not be used, depending on whether or not |
|
| 248 | - // the cookies "stick" |
|
| 249 | - $secret = csrf_get_secret(); |
|
| 250 | - if (!$has_cookies && $secret) { |
|
| 251 | - $ip = ';ip:' . csrf_hash($_SERVER['IP_ADDRESS']); |
|
| 252 | - } else { |
|
| 253 | - $ip = ''; |
|
| 254 | - } |
|
| 255 | - csrf_start(); |
|
| 256 | - |
|
| 257 | - // These are "strong" algorithms that don't require per se a secret |
|
| 258 | - if (session_id()) return 'sid:' . csrf_hash(session_id()) . $ip; |
|
| 259 | - if ($GLOBALS['csrf']['cookie']) { |
|
| 260 | - $val = csrf_generate_secret(); |
|
| 261 | - setcookie($GLOBALS['csrf']['cookie'], $val); |
|
| 262 | - return 'cookie:' . csrf_hash($val) . $ip; |
|
| 263 | - } |
|
| 264 | - if ($GLOBALS['csrf']['key']) return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip; |
|
| 265 | - // These further algorithms require a server-side secret |
|
| 266 | - if (!$secret) return 'invalid'; |
|
| 267 | - if ($GLOBALS['csrf']['user'] !== false) { |
|
| 268 | - return 'user:' . csrf_hash($GLOBALS['csrf']['user']); |
|
| 269 | - } |
|
| 270 | - if ($GLOBALS['csrf']['allow-ip']) { |
|
| 271 | - return ltrim($ip, ';'); |
|
| 272 | - } |
|
| 273 | - return 'invalid'; |
|
| 244 | + $has_cookies = !empty($_COOKIE); |
|
| 245 | + |
|
| 246 | + // $ip implements a composite key, which is sent if the user hasn't sent |
|
| 247 | + // any cookies. It may or may not be used, depending on whether or not |
|
| 248 | + // the cookies "stick" |
|
| 249 | + $secret = csrf_get_secret(); |
|
| 250 | + if (!$has_cookies && $secret) { |
|
| 251 | + $ip = ';ip:' . csrf_hash($_SERVER['IP_ADDRESS']); |
|
| 252 | + } else { |
|
| 253 | + $ip = ''; |
|
| 254 | + } |
|
| 255 | + csrf_start(); |
|
| 256 | + |
|
| 257 | + // These are "strong" algorithms that don't require per se a secret |
|
| 258 | + if (session_id()) return 'sid:' . csrf_hash(session_id()) . $ip; |
|
| 259 | + if ($GLOBALS['csrf']['cookie']) { |
|
| 260 | + $val = csrf_generate_secret(); |
|
| 261 | + setcookie($GLOBALS['csrf']['cookie'], $val); |
|
| 262 | + return 'cookie:' . csrf_hash($val) . $ip; |
|
| 263 | + } |
|
| 264 | + if ($GLOBALS['csrf']['key']) return 'key:' . csrf_hash($GLOBALS['csrf']['key']) . $ip; |
|
| 265 | + // These further algorithms require a server-side secret |
|
| 266 | + if (!$secret) return 'invalid'; |
|
| 267 | + if ($GLOBALS['csrf']['user'] !== false) { |
|
| 268 | + return 'user:' . csrf_hash($GLOBALS['csrf']['user']); |
|
| 269 | + } |
|
| 270 | + if ($GLOBALS['csrf']['allow-ip']) { |
|
| 271 | + return ltrim($ip, ';'); |
|
| 272 | + } |
|
| 273 | + return 'invalid'; |
|
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | function csrf_flattenpost($data) { |
| 277 | - $ret = array(); |
|
| 278 | - foreach($data as $n => $v) { |
|
| 279 | - $ret = array_merge($ret, csrf_flattenpost2(1, $n, $v)); |
|
| 280 | - } |
|
| 281 | - return $ret; |
|
| 277 | + $ret = array(); |
|
| 278 | + foreach($data as $n => $v) { |
|
| 279 | + $ret = array_merge($ret, csrf_flattenpost2(1, $n, $v)); |
|
| 280 | + } |
|
| 281 | + return $ret; |
|
| 282 | 282 | } |
| 283 | 283 | function csrf_flattenpost2($level, $key, $data) { |
| 284 | - if(!is_array($data)) return array($key => $data); |
|
| 285 | - $ret = array(); |
|
| 286 | - foreach($data as $n => $v) { |
|
| 287 | - $nk = $level >= 1 ? $key."[$n]" : "[$n]"; |
|
| 288 | - $ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v)); |
|
| 289 | - } |
|
| 290 | - return $ret; |
|
| 284 | + if(!is_array($data)) return array($key => $data); |
|
| 285 | + $ret = array(); |
|
| 286 | + foreach($data as $n => $v) { |
|
| 287 | + $nk = $level >= 1 ? $key."[$n]" : "[$n]"; |
|
| 288 | + $ret = array_merge($ret, csrf_flattenpost2($level+1, $nk, $v)); |
|
| 289 | + } |
|
| 290 | + return $ret; |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | /** |
| 294 | 294 | * @param $tokens is safe for HTML consumption |
| 295 | 295 | */ |
| 296 | 296 | function csrf_callback($tokens) { |
| 297 | - // (yes, $tokens is safe to echo without escaping) |
|
| 298 | - header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); |
|
| 299 | - $data = ''; |
|
| 300 | - foreach (csrf_flattenpost($_POST) as $key => $value) { |
|
| 301 | - if ($key == $GLOBALS['csrf']['input-name']) continue; |
|
| 302 | - $data .= '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($value).'" />'; |
|
| 303 | - } |
|
| 304 | - echo "<html><head><title>CSRF check failed</title></head> |
|
| 297 | + // (yes, $tokens is safe to echo without escaping) |
|
| 298 | + header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden'); |
|
| 299 | + $data = ''; |
|
| 300 | + foreach (csrf_flattenpost($_POST) as $key => $value) { |
|
| 301 | + if ($key == $GLOBALS['csrf']['input-name']) continue; |
|
| 302 | + $data .= '<input type="hidden" name="'.htmlspecialchars($key).'" value="'.htmlspecialchars($value).'" />'; |
|
| 303 | + } |
|
| 304 | + echo "<html><head><title>CSRF check failed</title></head> |
|
| 305 | 305 | <body> |
| 306 | 306 | <p>CSRF check failed. Your form session may have expired, or you may not have |
| 307 | 307 | cookies enabled.</p> |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | * It is configurable by setting $GLOBALS['csrf']['callback'] in this file |
| 317 | 317 | */ |
| 318 | 318 | function vtResponseForIllegalAccess() { |
| 319 | - echo 'Invalid request - Response For Illegal Access'; |
|
| 319 | + echo 'Invalid request - Response For Illegal Access'; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | /** |
@@ -324,106 +324,106 @@ discard block |
||
| 324 | 324 | * instead of csrf_check_token() |
| 325 | 325 | */ |
| 326 | 326 | function csrf_check_tokens($tokens) { |
| 327 | - if (is_string($tokens)) $tokens = explode(';', $tokens); |
|
| 328 | - foreach ($tokens as $token) { |
|
| 329 | - if (csrf_check_token($token)) return true; |
|
| 330 | - } |
|
| 331 | - return false; |
|
| 327 | + if (is_string($tokens)) $tokens = explode(';', $tokens); |
|
| 328 | + foreach ($tokens as $token) { |
|
| 329 | + if (csrf_check_token($token)) return true; |
|
| 330 | + } |
|
| 331 | + return false; |
|
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | * Checks if a token is valid. |
| 336 | 336 | */ |
| 337 | 337 | function csrf_check_token($token) { |
| 338 | - if (strpos($token, ':') === false) return false; |
|
| 339 | - list($type, $value) = explode(':', $token, 2); |
|
| 340 | - if (strpos($value, ',') === false) return false; |
|
| 341 | - list($x, $time) = explode(',', $token, 2); |
|
| 342 | - if ($GLOBALS['csrf']['expires']) { |
|
| 343 | - if (time() > $time + $GLOBALS['csrf']['expires']) return false; |
|
| 344 | - } |
|
| 345 | - switch ($type) { |
|
| 346 | - case 'sid': |
|
| 347 | - return $value === csrf_hash(session_id(), $time); |
|
| 348 | - case 'cookie': |
|
| 349 | - $n = $GLOBALS['csrf']['cookie']; |
|
| 350 | - if (!$n) return false; |
|
| 351 | - if (!isset($_COOKIE[$n])) return false; |
|
| 352 | - return $value === csrf_hash($_COOKIE[$n], $time); |
|
| 353 | - case 'key': |
|
| 354 | - if (!$GLOBALS['csrf']['key']) return false; |
|
| 355 | - return $value === csrf_hash($GLOBALS['csrf']['key'], $time); |
|
| 356 | - // We could disable these 'weaker' checks if 'key' was set, but |
|
| 357 | - // that doesn't make me feel good then about the cookie-based |
|
| 358 | - // implementation. |
|
| 359 | - case 'user': |
|
| 360 | - if (!csrf_get_secret()) return false; |
|
| 361 | - if ($GLOBALS['csrf']['user'] === false) return false; |
|
| 362 | - return $value === csrf_hash($GLOBALS['csrf']['user'], $time); |
|
| 363 | - case 'ip': |
|
| 364 | - if (!csrf_get_secret()) return false; |
|
| 365 | - // do not allow IP-based checks if the username is set, or if |
|
| 366 | - // the browser sent cookies |
|
| 367 | - if ($GLOBALS['csrf']['user'] !== false) return false; |
|
| 368 | - if (!empty($_COOKIE)) return false; |
|
| 369 | - if (!$GLOBALS['csrf']['allow-ip']) return false; |
|
| 370 | - return $value === csrf_hash($_SERVER['IP_ADDRESS'], $time); |
|
| 371 | - } |
|
| 372 | - return false; |
|
| 338 | + if (strpos($token, ':') === false) return false; |
|
| 339 | + list($type, $value) = explode(':', $token, 2); |
|
| 340 | + if (strpos($value, ',') === false) return false; |
|
| 341 | + list($x, $time) = explode(',', $token, 2); |
|
| 342 | + if ($GLOBALS['csrf']['expires']) { |
|
| 343 | + if (time() > $time + $GLOBALS['csrf']['expires']) return false; |
|
| 344 | + } |
|
| 345 | + switch ($type) { |
|
| 346 | + case 'sid': |
|
| 347 | + return $value === csrf_hash(session_id(), $time); |
|
| 348 | + case 'cookie': |
|
| 349 | + $n = $GLOBALS['csrf']['cookie']; |
|
| 350 | + if (!$n) return false; |
|
| 351 | + if (!isset($_COOKIE[$n])) return false; |
|
| 352 | + return $value === csrf_hash($_COOKIE[$n], $time); |
|
| 353 | + case 'key': |
|
| 354 | + if (!$GLOBALS['csrf']['key']) return false; |
|
| 355 | + return $value === csrf_hash($GLOBALS['csrf']['key'], $time); |
|
| 356 | + // We could disable these 'weaker' checks if 'key' was set, but |
|
| 357 | + // that doesn't make me feel good then about the cookie-based |
|
| 358 | + // implementation. |
|
| 359 | + case 'user': |
|
| 360 | + if (!csrf_get_secret()) return false; |
|
| 361 | + if ($GLOBALS['csrf']['user'] === false) return false; |
|
| 362 | + return $value === csrf_hash($GLOBALS['csrf']['user'], $time); |
|
| 363 | + case 'ip': |
|
| 364 | + if (!csrf_get_secret()) return false; |
|
| 365 | + // do not allow IP-based checks if the username is set, or if |
|
| 366 | + // the browser sent cookies |
|
| 367 | + if ($GLOBALS['csrf']['user'] !== false) return false; |
|
| 368 | + if (!empty($_COOKIE)) return false; |
|
| 369 | + if (!$GLOBALS['csrf']['allow-ip']) return false; |
|
| 370 | + return $value === csrf_hash($_SERVER['IP_ADDRESS'], $time); |
|
| 371 | + } |
|
| 372 | + return false; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | 376 | * Sets a configuration value. |
| 377 | 377 | */ |
| 378 | 378 | function csrf_conf($key, $val) { |
| 379 | - if (!isset($GLOBALS['csrf'][$key])) { |
|
| 380 | - trigger_error('No such configuration ' . $key, E_USER_WARNING); |
|
| 381 | - return; |
|
| 382 | - } |
|
| 383 | - $GLOBALS['csrf'][$key] = $val; |
|
| 379 | + if (!isset($GLOBALS['csrf'][$key])) { |
|
| 380 | + trigger_error('No such configuration ' . $key, E_USER_WARNING); |
|
| 381 | + return; |
|
| 382 | + } |
|
| 383 | + $GLOBALS['csrf'][$key] = $val; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
| 387 | 387 | * Starts a session if we're allowed to. |
| 388 | 388 | */ |
| 389 | 389 | function csrf_start() { |
| 390 | - if ($GLOBALS['csrf']['auto-session'] && !session_id()) { |
|
| 391 | - session_start(); |
|
| 392 | - } |
|
| 390 | + if ($GLOBALS['csrf']['auto-session'] && !session_id()) { |
|
| 391 | + session_start(); |
|
| 392 | + } |
|
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | /** |
| 396 | 396 | * Retrieves the secret, and generates one if necessary. |
| 397 | 397 | */ |
| 398 | 398 | function csrf_get_secret() { |
| 399 | - if ($GLOBALS['csrf']['secret']) return $GLOBALS['csrf']['secret']; |
|
| 400 | - $dir = dirname(__FILE__); |
|
| 401 | - $file = $dir . '/../../config/csrf_secret.php'; |
|
| 402 | - $secret = ''; |
|
| 403 | - if (file_exists($file)) { |
|
| 404 | - include $file; |
|
| 405 | - return $secret; |
|
| 406 | - } |
|
| 407 | - if (is_writable($dir)) { |
|
| 408 | - $secret = csrf_generate_secret(); |
|
| 409 | - $fh = fopen($file, 'w'); |
|
| 410 | - fwrite($fh, '<?php $secret = "'.$secret.'";' . PHP_EOL); |
|
| 411 | - fclose($fh); |
|
| 412 | - return $secret; |
|
| 413 | - } |
|
| 414 | - return ''; |
|
| 399 | + if ($GLOBALS['csrf']['secret']) return $GLOBALS['csrf']['secret']; |
|
| 400 | + $dir = dirname(__FILE__); |
|
| 401 | + $file = $dir . '/../../config/csrf_secret.php'; |
|
| 402 | + $secret = ''; |
|
| 403 | + if (file_exists($file)) { |
|
| 404 | + include $file; |
|
| 405 | + return $secret; |
|
| 406 | + } |
|
| 407 | + if (is_writable($dir)) { |
|
| 408 | + $secret = csrf_generate_secret(); |
|
| 409 | + $fh = fopen($file, 'w'); |
|
| 410 | + fwrite($fh, '<?php $secret = "'.$secret.'";' . PHP_EOL); |
|
| 411 | + fclose($fh); |
|
| 412 | + return $secret; |
|
| 413 | + } |
|
| 414 | + return ''; |
|
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | /** |
| 418 | 418 | * Generates a random string as the hash of time, microtime, and mt_rand. |
| 419 | 419 | */ |
| 420 | 420 | function csrf_generate_secret($len = 32) { |
| 421 | - $r = ''; |
|
| 422 | - for ($i = 0; $i < 32; $i++) { |
|
| 423 | - $r .= chr(mt_rand(0, 255)); |
|
| 424 | - } |
|
| 425 | - $r .= time() . microtime(); |
|
| 426 | - return sha1($r); |
|
| 421 | + $r = ''; |
|
| 422 | + for ($i = 0; $i < 32; $i++) { |
|
| 423 | + $r .= chr(mt_rand(0, 255)); |
|
| 424 | + } |
|
| 425 | + $r .= time() . microtime(); |
|
| 426 | + return sha1($r); |
|
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
@@ -431,8 +431,8 @@ discard block |
||
| 431 | 431 | * from the current time. |
| 432 | 432 | */ |
| 433 | 433 | function csrf_hash($value, $time = null) { |
| 434 | - if (!$time) $time = time(); |
|
| 435 | - return sha1(csrf_get_secret() . $value . $time) . ',' . $time; |
|
| 434 | + if (!$time) $time = time(); |
|
| 435 | + return sha1(csrf_get_secret() . $value . $time) . ',' . $time; |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // Load user configuration |
@@ -405,6 +405,7 @@ discard block |
||
| 405 | 405 | * @param int The unique ID of the person who tagged the object with this tag. |
| 406 | 406 | * @param int The unique ID of the object in question. |
| 407 | 407 | * @param string A raw string from a web form containing tags. |
| 408 | + * @param string $tag |
|
| 408 | 409 | * |
| 409 | 410 | * @return boolean Returns true if successful, false otherwise. Does not operate as a transaction. |
| 410 | 411 | */ |
@@ -662,7 +663,7 @@ discard block |
||
| 662 | 663 | * @param string The raw string form of the tag to delete. See above for vtiger_notes. |
| 663 | 664 | * @param int Whether to skip the update portion for objects that haven't been tagged. (Default: 1) |
| 664 | 665 | * |
| 665 | - * @return string Returns the tag in normalized form. |
|
| 666 | + * @return boolean Returns the tag in normalized form. |
|
| 666 | 667 | */ |
| 667 | 668 | public function tag_object($tagger_id, $object_id, $tag_string, $module, $skip_updates = 1) { |
| 668 | 669 | if($tag_string == '') { |
@@ -1127,6 +1128,10 @@ discard block |
||
| 1127 | 1128 | * @param string The text to output |
| 1128 | 1129 | * @return boolean Always returns true |
| 1129 | 1130 | */ |
| 1131 | + |
|
| 1132 | + /** |
|
| 1133 | + * @param string $text |
|
| 1134 | + */ |
|
| 1130 | 1135 | public function debug_text($text) { |
| 1131 | 1136 | if ($this->_debug) { |
| 1132 | 1137 | echo "$text<br>\n"; |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | WHERE $where |
| 176 | 176 | ORDER BY object_id ASC |
| 177 | 177 | LIMIT $offset, $limit"; |
| 178 | - echo $sql; |
|
| 178 | + echo $sql; |
|
| 179 | 179 | $rs = $adb->pquery($sql, $params); |
| 180 | 180 | $retarr = array(); |
| 181 | 181 | while ($row = $adb->fetch_array($rs)) { |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | WHERE $where |
| 221 | 221 | ORDER BY object_id ASC |
| 222 | 222 | "; |
| 223 | - //echo $sql; |
|
| 223 | + //echo $sql; |
|
| 224 | 224 | $rs = $adb->pquery($sql, $params); |
| 225 | 225 | $retarr = array(); |
| 226 | 226 | while ($row = $adb->fetch_array($rs)) { |
@@ -970,7 +970,7 @@ discard block |
||
| 970 | 970 | $tagger_sql |
| 971 | 971 | GROUP BY tag |
| 972 | 972 | ORDER BY quantity DESC LIMIT 0, $max"; |
| 973 | - //echo $sql; |
|
| 973 | + //echo $sql; |
|
| 974 | 974 | $rs = $adb->pquery($sql, $params); |
| 975 | 975 | $retarr = array(); |
| 976 | 976 | while ($row = $adb->fetch_array($rs)) { |
@@ -427,7 +427,9 @@ discard block |
||
| 427 | 427 | if ($this->_block_multiuser_tag_on_object == 0) { |
| 428 | 428 | $tagger_sql = " && tagger_id = ? "; |
| 429 | 429 | array_push($params, $tagger_id); |
| 430 | - } else $tagger_sql = ""; |
|
| 430 | + } else { |
|
| 431 | + $tagger_sql = ""; |
|
| 432 | + } |
|
| 431 | 433 | $sql = "SELECT COUNT(*) as count |
| 432 | 434 | FROM ${prefix}freetagged_objects INNER JOIN ${prefix}freetags ON (tag_id = id) |
| 433 | 435 | WHERE 1=1 |
@@ -902,8 +904,9 @@ discard block |
||
| 902 | 904 | // by $step. |
| 903 | 905 | $cloud_html = ''; |
| 904 | 906 | $cloud_spans = array(); |
| 905 | - if($module =='') |
|
| 906 | - $module = 'All'; |
|
| 907 | + if($module =='') { |
|
| 908 | + $module = 'All'; |
|
| 909 | + } |
|
| 907 | 910 | if($module != 'All') { |
| 908 | 911 | foreach ($tag_list[0] as $tag => $qty) { |
| 909 | 912 | $size = $min_font_size + ($qty - $min_qty) * $step; |
@@ -978,8 +981,12 @@ discard block |
||
| 978 | 981 | $retarr[$row['tag']] = $row['quantity']; |
| 979 | 982 | $retarr1[$row['tag']] = $row['tag_id']; |
| 980 | 983 | } |
| 981 | - if($retarr) ksort($retarr); |
|
| 982 | - if($retarr1) ksort($retarr1); |
|
| 984 | + if($retarr) { |
|
| 985 | + ksort($retarr); |
|
| 986 | + } |
|
| 987 | + if($retarr1) { |
|
| 988 | + ksort($retarr1); |
|
| 989 | + } |
|
| 983 | 990 | $return_value[]=$retarr; |
| 984 | 991 | $return_value[]=$retarr1; |
| 985 | 992 | return $return_value; |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | * @access private |
| 66 | 66 | * @param string Whether to prevent multiple vtiger_users from tagging the same object. By default, set to block (ala Upcoming.org) |
| 67 | 67 | */ |
| 68 | - public $_block_multiuser_tag_on_object =0; |
|
| 68 | + public $_block_multiuser_tag_on_object = 0; |
|
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @access private |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | * @return An array of Object ID numbers that reference your original objects. |
| 152 | 152 | */ |
| 153 | 153 | public function get_objects_with_tag($tag, $offset = 0, $limit = 100, $tagger_id = NULL) { |
| 154 | - if(!isset($tag)) { |
|
| 154 | + if (!isset($tag)) { |
|
| 155 | 155 | return false; |
| 156 | 156 | } |
| 157 | 157 | $adb = PearDatabase::getInstance(); |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | $where = "tag = ? "; |
| 160 | 160 | $params = array($tag); |
| 161 | 161 | |
| 162 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 162 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 163 | 163 | $where .= "AND tagger_id = ? "; |
| 164 | 164 | array_push($params, $tagger_id); |
| 165 | 165 | } |
@@ -197,7 +197,7 @@ discard block |
||
| 197 | 197 | * @return An array of Object ID numbers that reference your original objects. |
| 198 | 198 | */ |
| 199 | 199 | public function get_objects_with_tag_all($tag, $tagger_id = NULL) { |
| 200 | - if(!isset($tag)) { |
|
| 200 | + if (!isset($tag)) { |
|
| 201 | 201 | return false; |
| 202 | 202 | } |
| 203 | 203 | $adb = PearDatabase::getInstance(); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $where = "tag = ? "; |
| 206 | 206 | $params = array($tag); |
| 207 | 207 | |
| 208 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 208 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 209 | 209 | $where .= "AND tagger_id = ? "; |
| 210 | 210 | array_push($params, $tagger_id); |
| 211 | 211 | } |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | return $retarr; |
| 250 | 250 | } |
| 251 | 251 | $params = array($tagArray); |
| 252 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 252 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 253 | 253 | $tagger_sql = "AND tagger_id = ?"; |
| 254 | 254 | array_push($params, $tagger_id); |
| 255 | 255 | } else { |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $sql = "SELECT ${prefix}freetagged_objects.object_id, tag, COUNT(DISTINCT tag) AS uniques |
| 271 | 271 | FROM ${prefix}freetagged_objects |
| 272 | 272 | INNER JOIN ${prefix}freetags ON (${prefix}freetagged_objects.tag_id = ${prefix}freetags.id) |
| 273 | - WHERE ${prefix}freetags.tag IN (". generateQuestionMarks($tagArray) .") |
|
| 273 | + WHERE ${prefix}freetags.tag IN (" . generateQuestionMarks($tagArray) . ") |
|
| 274 | 274 | $tagger_sql |
| 275 | 275 | GROUP BY ${prefix}freetagged_objects.object_id |
| 276 | 276 | HAVING uniques = $numTags |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | * @return An array of Object ID numbers that reference your original objects. |
| 301 | 301 | */ |
| 302 | 302 | public function get_objects_with_tag_id($tag_id, $offset = 0, $limit = 100, $tagger_id = NULL) { |
| 303 | - if(!isset($tag_id)) { |
|
| 303 | + if (!isset($tag_id)) { |
|
| 304 | 304 | return false; |
| 305 | 305 | } |
| 306 | 306 | $adb = PearDatabase::getInstance(); |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | $where = "id = ? "; |
| 309 | 309 | $params = array($tag_id); |
| 310 | 310 | |
| 311 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 311 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 312 | 312 | $where .= "AND tagger_id = ?"; |
| 313 | 313 | array_push($params, $tagger_id); |
| 314 | 314 | } |
@@ -349,19 +349,19 @@ discard block |
||
| 349 | 349 | * - 'tagger_id' => The unique ID of the person who tagged the object with this tag. |
| 350 | 350 | */ |
| 351 | 351 | public function get_tags_on_object($object_id, $offset = 0, $limit = 10, $tagger_id = NULL) { |
| 352 | - if(!isset($object_id)) { |
|
| 352 | + if (!isset($object_id)) { |
|
| 353 | 353 | return false; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | $where = "object_id = ? "; |
| 357 | 357 | $params = array($object_id); |
| 358 | 358 | |
| 359 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 359 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 360 | 360 | $where .= "AND tagger_id = ? "; |
| 361 | 361 | array_push($params, $tagger_id); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if($limit <= 0) { |
|
| 364 | + if ($limit <= 0) { |
|
| 365 | 365 | $limit_sql = ""; |
| 366 | 366 | } else { |
| 367 | 367 | $limit_sql = "LIMIT $offset, $limit"; |
@@ -406,7 +406,7 @@ discard block |
||
| 406 | 406 | */ |
| 407 | 407 | |
| 408 | 408 | public function safe_tag($tagger_id, $object_id, $tag, $module) { |
| 409 | - if(!isset($tagger_id)||!isset($object_id)||!isset($tag)) { |
|
| 409 | + if (!isset($tagger_id) || !isset($object_id) || !isset($tag)) { |
|
| 410 | 410 | die("safe_tag argument missing"); |
| 411 | 411 | return false; |
| 412 | 412 | } |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | |
| 434 | 434 | array_push($params, $object_id, $normalized_tag); |
| 435 | 435 | $rs = $adb->pquery($sql, $params); |
| 436 | - if($rs->fields['count'] > 0) { |
|
| 436 | + if ($rs->fields['count'] > 0) { |
|
| 437 | 437 | return true; |
| 438 | 438 | } |
| 439 | 439 | // Then see if a raw tag in this form exists. |
@@ -442,7 +442,7 @@ discard block |
||
| 442 | 442 | WHERE raw_tag = ? "; |
| 443 | 443 | $rs = $adb->pquery($sql, array($tag)); |
| 444 | 444 | $row = $adb->fetch_array($rs); |
| 445 | - if($row) { |
|
| 445 | + if ($row) { |
|
| 446 | 446 | $tag_id = $row['id']; |
| 447 | 447 | } else { |
| 448 | 448 | // Add new tag! |
@@ -452,7 +452,7 @@ discard block |
||
| 452 | 452 | $rs = $adb->pquery($sql, $params); |
| 453 | 453 | |
| 454 | 454 | } |
| 455 | - if(!($tag_id > 0)) { |
|
| 455 | + if (!($tag_id > 0)) { |
|
| 456 | 456 | return false; |
| 457 | 457 | } |
| 458 | 458 | $sql = "INSERT INTO ${prefix}freetagged_objects |
@@ -509,14 +509,14 @@ discard block |
||
| 509 | 509 | * @return string Returns the tag in normalized form. |
| 510 | 510 | */ |
| 511 | 511 | public function delete_object_tag($tagger_id, $object_id, $tag) { |
| 512 | - if(!isset($tagger_id)||!isset($object_id)||!isset($tag)) { |
|
| 512 | + if (!isset($tagger_id) || !isset($object_id) || !isset($tag)) { |
|
| 513 | 513 | die("delete_object_tag argument missing"); |
| 514 | 514 | return false; |
| 515 | 515 | } |
| 516 | 516 | $adb = PearDatabase::getInstance(); |
| 517 | 517 | $tag_id = $this->get_raw_tag_id($tag); |
| 518 | 518 | $prefix = $this->_table_prefix; |
| 519 | - if($tag_id > 0) { |
|
| 519 | + if ($tag_id > 0) { |
|
| 520 | 520 | |
| 521 | 521 | $sql = "DELETE FROM ${prefix}freetagged_objects |
| 522 | 522 | WHERE tagger_id = ? && object_id = ? && tag_id = ? LIMIT 1"; |
@@ -543,7 +543,7 @@ discard block |
||
| 543 | 543 | public function delete_all_object_tags($object_id) { |
| 544 | 544 | $adb = PearDatabase::getInstance(); |
| 545 | 545 | $prefix = $this->_table_prefix; |
| 546 | - if($object_id > 0) { |
|
| 546 | + if ($object_id > 0) { |
|
| 547 | 547 | $sql = "DELETE FROM ${prefix}freetagged_objects |
| 548 | 548 | WHERE object_id = ? "; |
| 549 | 549 | $rs = $adb->pquery($sql, array($object_id)); |
@@ -570,13 +570,13 @@ discard block |
||
| 570 | 570 | */ |
| 571 | 571 | |
| 572 | 572 | public function delete_all_object_tags_for_user($tagger_id, $object_id) { |
| 573 | - if(!isset($tagger_id)||!isset($object_id)) { |
|
| 573 | + if (!isset($tagger_id) || !isset($object_id)) { |
|
| 574 | 574 | die("delete_all_object_tags_for_user argument missing"); |
| 575 | 575 | return false; |
| 576 | 576 | } |
| 577 | 577 | $adb = PearDatabase::getInstance(); |
| 578 | 578 | $prefix = $this->_table_prefix; |
| 579 | - if($object_id > 0) { |
|
| 579 | + if ($object_id > 0) { |
|
| 580 | 580 | |
| 581 | 581 | $sql = "DELETE FROM ${prefix}freetagged_objects |
| 582 | 582 | WHERE tagger_id = ? && object_id = ?"; |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | * @return string Returns the tag in normalized form. |
| 601 | 601 | */ |
| 602 | 602 | public function get_tag_id($tag) { |
| 603 | - if(!isset($tag)) { |
|
| 603 | + if (!isset($tag)) { |
|
| 604 | 604 | die("get_tag_id argument missing"); |
| 605 | 605 | return false; |
| 606 | 606 | } |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | */ |
| 629 | 629 | |
| 630 | 630 | public function get_raw_tag_id($tag) { |
| 631 | - if(!isset($tag)) { |
|
| 631 | + if (!isset($tag)) { |
|
| 632 | 632 | die("get_tag_id argument missing"); |
| 633 | 633 | return false; |
| 634 | 634 | } |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | * @return string Returns the tag in normalized form. |
| 662 | 662 | */ |
| 663 | 663 | public function tag_object($tagger_id, $object_id, $tag_string, $module, $skip_updates = 1) { |
| 664 | - if($tag_string == '') { |
|
| 664 | + if ($tag_string == '') { |
|
| 665 | 665 | // If an empty string was passed, just return true, don't die. |
| 666 | 666 | // die("Empty tag string passed"); |
| 667 | 667 | return true; |
@@ -702,10 +702,10 @@ discard block |
||
| 702 | 702 | * @return boolean True if successful, false otherwise. |
| 703 | 703 | */ |
| 704 | 704 | public function _tag_object_array($tagger_id, $object_id, $tagArray, $module) { |
| 705 | - foreach($tagArray as $tag) { |
|
| 705 | + foreach ($tagArray as $tag) { |
|
| 706 | 706 | $tag = trim($tag); |
| 707 | - if(($tag != '') && (strlen($tag) <= $this->_MAX_TAG_LENGTH)) { |
|
| 708 | - if(get_magic_quotes_gpc()) { |
|
| 707 | + if (($tag != '') && (strlen($tag) <= $this->_MAX_TAG_LENGTH)) { |
|
| 708 | + if (get_magic_quotes_gpc()) { |
|
| 709 | 709 | $tag = addslashes($tag); |
| 710 | 710 | } |
| 711 | 711 | $this->safe_tag($tagger_id, $object_id, $tag, $module); |
@@ -731,12 +731,12 @@ discard block |
||
| 731 | 731 | return $newwords; |
| 732 | 732 | } |
| 733 | 733 | # Perform tag parsing |
| 734 | - if(get_magic_quotes_gpc()) { |
|
| 734 | + if (get_magic_quotes_gpc()) { |
|
| 735 | 735 | $query = stripslashes(trim($tag_string)); |
| 736 | 736 | } else { |
| 737 | 737 | $query = trim($tag_string); |
| 738 | 738 | } |
| 739 | - $words = preg_split('/(")/', $query,-1,PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE); |
|
| 739 | + $words = preg_split('/(")/', $query, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE); |
|
| 740 | 740 | $delim = 0; |
| 741 | 741 | foreach ($words as $key => $word) |
| 742 | 742 | { |
@@ -782,7 +782,7 @@ discard block |
||
| 782 | 782 | public function get_most_popular_tags($tagger_id = NULL, $offset = 0, $limit = 25) { |
| 783 | 783 | $adb = PearDatabase::getInstance(); |
| 784 | 784 | $params = array(); |
| 785 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 785 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 786 | 786 | $tagger_sql = "AND tagger_id = ?"; |
| 787 | 787 | array_push($params, $tagger_id); |
| 788 | 788 | } else { |
@@ -826,7 +826,7 @@ discard block |
||
| 826 | 826 | public function count_tags($tagger_id = NULL) { |
| 827 | 827 | $adb = PearDatabase::getInstance(); |
| 828 | 828 | $params = array(); |
| 829 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 829 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 830 | 830 | $tagger_sql = "AND tagger_id = ?"; |
| 831 | 831 | array_push($params, $tagger_id); |
| 832 | 832 | } else { |
@@ -870,11 +870,11 @@ discard block |
||
| 870 | 870 | * @return string Returns an HTML snippet that can be used directly as a tag cloud. |
| 871 | 871 | */ |
| 872 | 872 | |
| 873 | - public function get_tag_cloud_html($module="",$tagger_id = NULL,$obj_id= NULL,$num_tags = 100, $min_font_size = 10, $max_font_size = 20, $font_units = 'px', $span_class = '', $tag_page_url = '/tag/') { |
|
| 873 | + public function get_tag_cloud_html($module = "", $tagger_id = NULL, $obj_id = NULL, $num_tags = 100, $min_font_size = 10, $max_font_size = 20, $font_units = 'px', $span_class = '', $tag_page_url = '/tag/') { |
|
| 874 | 874 | global $theme; |
| 875 | - $theme_path="themes/".$theme."/"; |
|
| 876 | - $image_path=$theme_path."images/"; |
|
| 877 | - $tag_list = $this->get_tag_cloud_tags($num_tags, $tagger_id,$module,$obj_id); |
|
| 875 | + $theme_path = "themes/" . $theme . "/"; |
|
| 876 | + $image_path = $theme_path . "images/"; |
|
| 877 | + $tag_list = $this->get_tag_cloud_tags($num_tags, $tagger_id, $module, $obj_id); |
|
| 878 | 878 | if (count($tag_list[0])) { |
| 879 | 879 | // Get the maximum qty of tagged objects in the set |
| 880 | 880 | $max_qty = max(array_values($tag_list[0])); |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | if (0 == $spread) { // Divide by zero |
| 891 | 891 | $spread = 1; |
| 892 | 892 | } |
| 893 | - $step = ($max_font_size - $min_font_size)/($spread); |
|
| 893 | + $step = ($max_font_size - $min_font_size) / ($spread); |
|
| 894 | 894 | |
| 895 | 895 | // Since the original tag_list is alphabetically ordered, |
| 896 | 896 | // we can now create the tag cloud by just putting a span |
@@ -898,18 +898,18 @@ discard block |
||
| 898 | 898 | // by $step. |
| 899 | 899 | $cloud_html = ''; |
| 900 | 900 | $cloud_spans = array(); |
| 901 | - if($module =='') |
|
| 901 | + if ($module == '') |
|
| 902 | 902 | $module = 'All'; |
| 903 | - if($module != 'All') { |
|
| 903 | + if ($module != 'All') { |
|
| 904 | 904 | foreach ($tag_list[0] as $tag => $qty) { |
| 905 | 905 | $size = $min_font_size + ($qty - $min_qty) * $step; |
| 906 | - $cloud_span[] = '<span id="tag_'.$tag_list[1][$tag].'" class="' . $span_class . '" onMouseOver=$("tagspan_'.$tag_list[1][$tag].'").style.display="inline"; onMouseOut=$("tagspan_'.$tag_list[1][$tag].'").style.display="none";><a class="tagit" href="index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&search_tag=tag_search&query_string='. urlencode($tag) . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a><span class="'. $span_class .'" id="tagspan_'.$tag_list[1][$tag].'" style="display:none;cursor:pointer;" onClick="DeleteTag('.$tag_list[1][$tag].','.$obj_id.');"><img src="' . vtiger_imageurl('del_tag.gif', $theme) . '"></span></span>'; |
|
| 906 | + $cloud_span[] = '<span id="tag_' . $tag_list[1][$tag] . '" class="' . $span_class . '" onMouseOver=$("tagspan_' . $tag_list[1][$tag] . '").style.display="inline"; onMouseOut=$("tagspan_' . $tag_list[1][$tag] . '").style.display="none";><a class="tagit" href="index.php?module=Home&action=UnifiedSearch&search_module=' . $module . '&search_tag=tag_search&query_string=' . urlencode($tag) . '" style="font-size: ' . $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a><span class="' . $span_class . '" id="tagspan_' . $tag_list[1][$tag] . '" style="display:none;cursor:pointer;" onClick="DeleteTag(' . $tag_list[1][$tag] . ',' . $obj_id . ');"><img src="' . vtiger_imageurl('del_tag.gif', $theme) . '"></span></span>'; |
|
| 907 | 907 | |
| 908 | 908 | } |
| 909 | 909 | } else { |
| 910 | - foreach($tag_list[0] as $tag => $qty) { |
|
| 910 | + foreach ($tag_list[0] as $tag => $qty) { |
|
| 911 | 911 | $size = $min_font_size + ($qty - $min_qty) * $step; |
| 912 | - $cloud_span[] = '<span class="' . $span_class . '"><a class="tagit" href="index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&search_tag=tag_search&query_string='. urlencode($tag) . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a></span>'; |
|
| 912 | + $cloud_span[] = '<span class="' . $span_class . '"><a class="tagit" href="index.php?module=Home&action=UnifiedSearch&search_module=' . $module . '&search_tag=tag_search&query_string=' . urlencode($tag) . '" style="font-size: ' . $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a></span>'; |
|
| 913 | 913 | } |
| 914 | 914 | } |
| 915 | 915 | $cloud_html = join("\n ", $cloud_span); |
@@ -934,24 +934,24 @@ discard block |
||
| 934 | 934 | * values are numeric quantity of objects tagged with that tag. |
| 935 | 935 | */ |
| 936 | 936 | |
| 937 | - public function get_tag_cloud_tags($max = 100, $tagger_id = NULL,$module = "",$obj_id = NULL) { |
|
| 937 | + public function get_tag_cloud_tags($max = 100, $tagger_id = NULL, $module = "", $obj_id = NULL) { |
|
| 938 | 938 | $adb = PearDatabase::getInstance(); |
| 939 | 939 | $params = array(); |
| 940 | - if(isset($tagger_id) && ($tagger_id > 0)) { |
|
| 940 | + if (isset($tagger_id) && ($tagger_id > 0)) { |
|
| 941 | 941 | $tagger_sql = " && tagger_id = ?"; |
| 942 | 942 | array_push($params, $tagger_id); |
| 943 | 943 | } else { |
| 944 | 944 | $tagger_sql = ""; |
| 945 | 945 | } |
| 946 | 946 | |
| 947 | - if($module != "") { |
|
| 947 | + if ($module != "") { |
|
| 948 | 948 | $tagger_sql .= " && module = ?"; |
| 949 | 949 | array_push($params, $module); |
| 950 | 950 | } else { |
| 951 | 951 | $tagger_sql .= ""; |
| 952 | 952 | } |
| 953 | 953 | |
| 954 | - if(isset($obj_id) && $obj_id > 0) { |
|
| 954 | + if (isset($obj_id) && $obj_id > 0) { |
|
| 955 | 955 | $tagger_sql .= " && object_id = ?"; |
| 956 | 956 | array_push($params, $obj_id); |
| 957 | 957 | } else { |
@@ -974,10 +974,10 @@ discard block |
||
| 974 | 974 | $retarr[$row['tag']] = $row['quantity']; |
| 975 | 975 | $retarr1[$row['tag']] = $row['tag_id']; |
| 976 | 976 | } |
| 977 | - if($retarr) ksort($retarr); |
|
| 978 | - if($retarr1) ksort($retarr1); |
|
| 979 | - $return_value[]=$retarr; |
|
| 980 | - $return_value[]=$retarr1; |
|
| 977 | + if ($retarr) ksort($retarr); |
|
| 978 | + if ($retarr1) ksort($retarr1); |
|
| 979 | + $return_value[] = $retarr; |
|
| 980 | + $return_value[] = $retarr1; |
|
| 981 | 981 | return $return_value; |
| 982 | 982 | |
| 983 | 983 | } |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | |
| 1011 | 1011 | public function similar_tags($tag, $max = 100) { |
| 1012 | 1012 | $retarr = array(); |
| 1013 | - if(!isset($tag)) { |
|
| 1013 | + if (!isset($tag)) { |
|
| 1014 | 1014 | return $retarr; |
| 1015 | 1015 | } |
| 1016 | 1016 | $adb = PearDatabase::getInstance(); |
@@ -1099,7 +1099,7 @@ discard block |
||
| 1099 | 1099 | $sql = "SELECT matches.object_id, COUNT( matches.object_id ) AS num_common_tags |
| 1100 | 1100 | FROM ${prefix}freetagged_objects as matches |
| 1101 | 1101 | INNER JOIN ${prefix}freetags as tags ON ( tags.id = matches.tag_id ) |
| 1102 | - WHERE tags.tag IN (". generateQuestionMarks($tagArray) .") |
|
| 1102 | + WHERE tags.tag IN (" . generateQuestionMarks($tagArray) . ") |
|
| 1103 | 1103 | GROUP BY matches.object_id |
| 1104 | 1104 | HAVING num_common_tags >= ? |
| 1105 | 1105 | ORDER BY num_common_tags DESC |
@@ -1107,7 +1107,7 @@ discard block |
||
| 1107 | 1107 | |
| 1108 | 1108 | $rs = $adb->pquery($sql, array($tagArray, $threshold, $max_objects)); |
| 1109 | 1109 | while ($row = $adb->fetch_array($rs)) { |
| 1110 | - $retarr[] = array ( |
|
| 1110 | + $retarr[] = array( |
|
| 1111 | 1111 | 'object_id' => $row['object_id'], |
| 1112 | 1112 | 'strength' => ($row['num_common_tags'] / $numTags) |
| 1113 | 1113 | ); |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | /** |
| 307 | 307 | * gets the current debug data for this instance |
| 308 | 308 | * |
| 309 | - * @return debug data |
|
| 309 | + * @return string data |
|
| 310 | 310 | * @access public |
| 311 | 311 | */ |
| 312 | 312 | public function &getDebug() { |
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * gets the current debug data for this instance as an XML comment |
| 320 | 320 | * this may change the contents of the debug data |
| 321 | 321 | * |
| 322 | - * @return debug data as an XML comment |
|
| 322 | + * @return string data as an XML comment |
|
| 323 | 323 | * @access public |
| 324 | 324 | */ |
| 325 | 325 | public function &getDebugAsXMLComment() { |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | /** |
| 353 | 353 | * returns error string if present |
| 354 | 354 | * |
| 355 | - * @return mixed error string or false |
|
| 355 | + * @return string|false error string or false |
|
| 356 | 356 | * @access public |
| 357 | 357 | */ |
| 358 | 358 | public function getError(){ |
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | /** |
| 366 | 366 | * sets error string |
| 367 | 367 | * |
| 368 | - * @return boolean $string error string |
|
| 368 | + * @return boolean|null $string error string |
|
| 369 | 369 | * @access private |
| 370 | 370 | */ |
| 371 | 371 | public function setError($str){ |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | * returns false, if not prefixed |
| 801 | 801 | * |
| 802 | 802 | * @param string $str The prefixed string |
| 803 | - * @return mixed The prefix or false if there is no prefix |
|
| 803 | + * @return string|false The prefix or false if there is no prefix |
|
| 804 | 804 | * @access public |
| 805 | 805 | */ |
| 806 | 806 | public function getPrefix($str){ |
@@ -830,7 +830,7 @@ discard block |
||
| 830 | 830 | * or false if no prefixes registered for the given namespace |
| 831 | 831 | * |
| 832 | 832 | * @param string $ns The namespace |
| 833 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
| 833 | + * @return string The prefix, false if the namespace has no prefixes |
|
| 834 | 834 | * @access public |
| 835 | 835 | */ |
| 836 | 836 | public function getPrefixFromNamespace($ns) { |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | * |
| 897 | 897 | * @param int $timestamp Unix time stamp |
| 898 | 898 | * @param boolean $utc Whether the time stamp is UTC or local |
| 899 | -* @return mixed ISO 8601 date string or false |
|
| 899 | +* @return string|false ISO 8601 date string or false |
|
| 900 | 900 | * @access public |
| 901 | 901 | */ |
| 902 | 902 | function timestamp_to_iso8601($timestamp,$utc=true){ |
@@ -104,21 +104,21 @@ discard block |
||
| 104 | 104 | * @access private |
| 105 | 105 | */ |
| 106 | 106 | public $revision = '$Revision: 1.57 $'; |
| 107 | - /** |
|
| 108 | - * Current error string (manipulated by getError/setError) |
|
| 107 | + /** |
|
| 108 | + * Current error string (manipulated by getError/setError) |
|
| 109 | 109 | * |
| 110 | 110 | * @var string |
| 111 | 111 | * @access private |
| 112 | 112 | */ |
| 113 | 113 | public $error_str = ''; |
| 114 | - /** |
|
| 115 | - * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
|
| 114 | + /** |
|
| 115 | + * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
|
| 116 | 116 | * |
| 117 | 117 | * @var string |
| 118 | 118 | * @access private |
| 119 | 119 | */ |
| 120 | - public $debug_str = ''; |
|
| 121 | - /** |
|
| 120 | + public $debug_str = ''; |
|
| 121 | + /** |
|
| 122 | 122 | * toggles automatic encoding of special characters as entities |
| 123 | 123 | * (should always be true, I think) |
| 124 | 124 | * |
@@ -134,31 +134,31 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | public $debugLevel; |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * set schema version |
|
| 139 | - * |
|
| 140 | - * @var string |
|
| 141 | - * @access public |
|
| 142 | - */ |
|
| 137 | + /** |
|
| 138 | + * set schema version |
|
| 139 | + * |
|
| 140 | + * @var string |
|
| 141 | + * @access public |
|
| 142 | + */ |
|
| 143 | 143 | public $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * charset encoding for outgoing messages |
|
| 147 | - * |
|
| 148 | - * @var string |
|
| 149 | - * @access public |
|
| 150 | - */ |
|
| 151 | - public $soap_defencoding = 'UTF-8'; |
|
| 145 | + /** |
|
| 146 | + * charset encoding for outgoing messages |
|
| 147 | + * |
|
| 148 | + * @var string |
|
| 149 | + * @access public |
|
| 150 | + */ |
|
| 151 | + public $soap_defencoding = 'UTF-8'; |
|
| 152 | 152 | //var $soap_defencoding = 'UTF-8'; |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | - * namespaces in an array of prefix => uri |
|
| 156 | - * |
|
| 157 | - * this is "seeded" by a set of constants, but it may be altered by code |
|
| 158 | - * |
|
| 159 | - * @var array |
|
| 160 | - * @access public |
|
| 161 | - */ |
|
| 155 | + * namespaces in an array of prefix => uri |
|
| 156 | + * |
|
| 157 | + * this is "seeded" by a set of constants, but it may be altered by code |
|
| 158 | + * |
|
| 159 | + * @var array |
|
| 160 | + * @access public |
|
| 161 | + */ |
|
| 162 | 162 | public $namespaces = array( |
| 163 | 163 | 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
| 164 | 164 | 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
@@ -167,20 +167,20 @@ discard block |
||
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | - * namespaces used in the current context, e.g. during serialization |
|
| 171 | - * |
|
| 172 | - * @var array |
|
| 173 | - * @access private |
|
| 174 | - */ |
|
| 170 | + * namespaces used in the current context, e.g. during serialization |
|
| 171 | + * |
|
| 172 | + * @var array |
|
| 173 | + * @access private |
|
| 174 | + */ |
|
| 175 | 175 | public $usedNamespaces = array(); |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * XML Schema types in an array of uri => (array of xml type => php type) |
|
| 179 | - * is this legacy yet? |
|
| 180 | - * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
| 181 | - * @var array |
|
| 182 | - * @access public |
|
| 183 | - */ |
|
| 178 | + * XML Schema types in an array of uri => (array of xml type => php type) |
|
| 179 | + * is this legacy yet? |
|
| 180 | + * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
| 181 | + * @var array |
|
| 182 | + * @access public |
|
| 183 | + */ |
|
| 184 | 184 | public $typemap = array( |
| 185 | 185 | 'http://www.w3.org/2001/XMLSchema' => array( |
| 186 | 186 | 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
@@ -203,75 +203,75 @@ discard block |
||
| 203 | 203 | 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
| 204 | 204 | 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
| 205 | 205 | 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
| 206 | - 'http://xml.apache.org/xml-soap' => array('Map') |
|
| 206 | + 'http://xml.apache.org/xml-soap' => array('Map') |
|
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | - * XML entities to convert |
|
| 211 | - * |
|
| 212 | - * @var array |
|
| 213 | - * @access public |
|
| 214 | - * @deprecated |
|
| 215 | - * @see expandEntities |
|
| 216 | - */ |
|
| 210 | + * XML entities to convert |
|
| 211 | + * |
|
| 212 | + * @var array |
|
| 213 | + * @access public |
|
| 214 | + * @deprecated |
|
| 215 | + * @see expandEntities |
|
| 216 | + */ |
|
| 217 | 217 | public $xmlEntities = array('quot' => '"','amp' => '&', |
| 218 | 218 | 'lt' => '<','gt' => '>','apos' => "'"); |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * constructor |
|
| 222 | - * |
|
| 223 | - * @access public |
|
| 224 | - */ |
|
| 221 | + * constructor |
|
| 222 | + * |
|
| 223 | + * @access public |
|
| 224 | + */ |
|
| 225 | 225 | public function nusoap_base() { |
| 226 | 226 | $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | - * gets the global debug level, which applies to future instances |
|
| 231 | - * |
|
| 232 | - * @return integer Debug level 0-9, where 0 turns off |
|
| 233 | - * @access public |
|
| 234 | - */ |
|
| 230 | + * gets the global debug level, which applies to future instances |
|
| 231 | + * |
|
| 232 | + * @return integer Debug level 0-9, where 0 turns off |
|
| 233 | + * @access public |
|
| 234 | + */ |
|
| 235 | 235 | public function getGlobalDebugLevel() { |
| 236 | 236 | return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | - * sets the global debug level, which applies to future instances |
|
| 241 | - * |
|
| 242 | - * @param int $level Debug level 0-9, where 0 turns off |
|
| 243 | - * @access public |
|
| 244 | - */ |
|
| 240 | + * sets the global debug level, which applies to future instances |
|
| 241 | + * |
|
| 242 | + * @param int $level Debug level 0-9, where 0 turns off |
|
| 243 | + * @access public |
|
| 244 | + */ |
|
| 245 | 245 | public function setGlobalDebugLevel($level) { |
| 246 | 246 | $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | - * gets the debug level for this instance |
|
| 251 | - * |
|
| 252 | - * @return int Debug level 0-9, where 0 turns off |
|
| 253 | - * @access public |
|
| 254 | - */ |
|
| 250 | + * gets the debug level for this instance |
|
| 251 | + * |
|
| 252 | + * @return int Debug level 0-9, where 0 turns off |
|
| 253 | + * @access public |
|
| 254 | + */ |
|
| 255 | 255 | public function getDebugLevel() { |
| 256 | 256 | return $this->debugLevel; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | - * sets the debug level for this instance |
|
| 261 | - * |
|
| 262 | - * @param int $level Debug level 0-9, where 0 turns off |
|
| 263 | - * @access public |
|
| 264 | - */ |
|
| 260 | + * sets the debug level for this instance |
|
| 261 | + * |
|
| 262 | + * @param int $level Debug level 0-9, where 0 turns off |
|
| 263 | + * @access public |
|
| 264 | + */ |
|
| 265 | 265 | public function setDebugLevel($level) { |
| 266 | 266 | $this->debugLevel = $level; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | - * adds debug data to the instance debug string with formatting |
|
| 271 | - * |
|
| 272 | - * @param string $string debug data |
|
| 273 | - * @access private |
|
| 274 | - */ |
|
| 270 | + * adds debug data to the instance debug string with formatting |
|
| 271 | + * |
|
| 272 | + * @param string $string debug data |
|
| 273 | + * @access private |
|
| 274 | + */ |
|
| 275 | 275 | public function debug($string){ |
| 276 | 276 | if ($this->debugLevel > 0) { |
| 277 | 277 | $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | - * adds debug data to the instance debug string without formatting |
|
| 283 | - * |
|
| 284 | - * @param string $string debug data |
|
| 285 | - * @access public |
|
| 286 | - */ |
|
| 282 | + * adds debug data to the instance debug string without formatting |
|
| 283 | + * |
|
| 284 | + * @param string $string debug data |
|
| 285 | + * @access public |
|
| 286 | + */ |
|
| 287 | 287 | public function appendDebug($string){ |
| 288 | 288 | if ($this->debugLevel > 0) { |
| 289 | 289 | // it would be nice to use a memory stream here to use |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * clears the current debug data for this instance |
|
| 297 | - * |
|
| 298 | - * @access public |
|
| 299 | - */ |
|
| 296 | + * clears the current debug data for this instance |
|
| 297 | + * |
|
| 298 | + * @access public |
|
| 299 | + */ |
|
| 300 | 300 | public function clearDebug() { |
| 301 | 301 | // it would be nice to use a memory stream here to use |
| 302 | 302 | // memory more efficiently |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * gets the current debug data for this instance |
|
| 308 | - * |
|
| 309 | - * @return debug data |
|
| 310 | - * @access public |
|
| 311 | - */ |
|
| 307 | + * gets the current debug data for this instance |
|
| 308 | + * |
|
| 309 | + * @return debug data |
|
| 310 | + * @access public |
|
| 311 | + */ |
|
| 312 | 312 | public function &getDebug() { |
| 313 | 313 | // it would be nice to use a memory stream here to use |
| 314 | 314 | // memory more efficiently |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | - * gets the current debug data for this instance as an XML comment |
|
| 320 | - * this may change the contents of the debug data |
|
| 321 | - * |
|
| 322 | - * @return debug data as an XML comment |
|
| 323 | - * @access public |
|
| 324 | - */ |
|
| 319 | + * gets the current debug data for this instance as an XML comment |
|
| 320 | + * this may change the contents of the debug data |
|
| 321 | + * |
|
| 322 | + * @return debug data as an XML comment |
|
| 323 | + * @access public |
|
| 324 | + */ |
|
| 325 | 325 | public function &getDebugAsXMLComment() { |
| 326 | 326 | // it would be nice to use a memory stream here to use |
| 327 | 327 | // memory more efficiently |
@@ -329,32 +329,32 @@ discard block |
||
| 329 | 329 | $this->debug_str = str_replace('--', '- -', $this->debug_str); |
| 330 | 330 | } |
| 331 | 331 | $ret = "<!--\n" . $this->debug_str . "\n-->"; |
| 332 | - return $ret; |
|
| 332 | + return $ret; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | - * expands entities, e.g. changes '<' to '<'. |
|
| 337 | - * |
|
| 338 | - * @param string $val The string in which to expand entities. |
|
| 339 | - * @access private |
|
| 340 | - */ |
|
| 336 | + * expands entities, e.g. changes '<' to '<'. |
|
| 337 | + * |
|
| 338 | + * @param string $val The string in which to expand entities. |
|
| 339 | + * @access private |
|
| 340 | + */ |
|
| 341 | 341 | public function expandEntities($val) { |
| 342 | 342 | if ($this->charencoding) { |
| 343 | - $val = str_replace('&', '&', $val); |
|
| 344 | - $val = str_replace("'", ''', $val); |
|
| 345 | - $val = str_replace('"', '"', $val); |
|
| 346 | - $val = str_replace('<', '<', $val); |
|
| 347 | - $val = str_replace('>', '>', $val); |
|
| 348 | - } |
|
| 349 | - return $val; |
|
| 343 | + $val = str_replace('&', '&', $val); |
|
| 344 | + $val = str_replace("'", ''', $val); |
|
| 345 | + $val = str_replace('"', '"', $val); |
|
| 346 | + $val = str_replace('<', '<', $val); |
|
| 347 | + $val = str_replace('>', '>', $val); |
|
| 348 | + } |
|
| 349 | + return $val; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * returns error string if present |
|
| 354 | - * |
|
| 355 | - * @return mixed error string or false |
|
| 356 | - * @access public |
|
| 357 | - */ |
|
| 353 | + * returns error string if present |
|
| 354 | + * |
|
| 355 | + * @return mixed error string or false |
|
| 356 | + * @access public |
|
| 357 | + */ |
|
| 358 | 358 | public function getError(){ |
| 359 | 359 | if($this->error_str != ''){ |
| 360 | 360 | return $this->error_str; |
@@ -363,24 +363,24 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | - * sets error string |
|
| 367 | - * |
|
| 368 | - * @return boolean $string error string |
|
| 369 | - * @access private |
|
| 370 | - */ |
|
| 366 | + * sets error string |
|
| 367 | + * |
|
| 368 | + * @return boolean $string error string |
|
| 369 | + * @access private |
|
| 370 | + */ |
|
| 371 | 371 | public function setError($str){ |
| 372 | 372 | $this->error_str = $str; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | - * detect if array is a simple array or a struct (associative array) |
|
| 377 | - * |
|
| 378 | - * @param mixed $val The PHP array |
|
| 379 | - * @return string (arraySimple|arrayStruct) |
|
| 380 | - * @access private |
|
| 381 | - */ |
|
| 376 | + * detect if array is a simple array or a struct (associative array) |
|
| 377 | + * |
|
| 378 | + * @param mixed $val The PHP array |
|
| 379 | + * @return string (arraySimple|arrayStruct) |
|
| 380 | + * @access private |
|
| 381 | + */ |
|
| 382 | 382 | public function isArraySimpleOrStruct($val) { |
| 383 | - $keyList = array_keys($val); |
|
| 383 | + $keyList = array_keys($val); |
|
| 384 | 384 | foreach ($keyList as $keyListValue) { |
| 385 | 385 | if (!is_int($keyListValue)) { |
| 386 | 386 | return 'arrayStruct'; |
@@ -390,33 +390,33 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | - * serializes PHP values in accordance w/ section 5. Type information is |
|
| 394 | - * not serialized if $use == 'literal'. |
|
| 395 | - * |
|
| 396 | - * @param mixed $val The value to serialize |
|
| 397 | - * @param string $name The name (local part) of the XML element |
|
| 398 | - * @param string $type The XML schema type (local part) for the element |
|
| 399 | - * @param string $name_ns The namespace for the name of the XML element |
|
| 400 | - * @param string $type_ns The namespace for the type of the element |
|
| 401 | - * @param array $attributes The attributes to serialize as name=>value pairs |
|
| 402 | - * @param string $use The WSDL "use" (encoded|literal) |
|
| 403 | - * @param boolean $soapval Whether this is called from soapval. |
|
| 404 | - * @return string The serialized element, possibly with child elements |
|
| 405 | - * @access public |
|
| 406 | - */ |
|
| 393 | + * serializes PHP values in accordance w/ section 5. Type information is |
|
| 394 | + * not serialized if $use == 'literal'. |
|
| 395 | + * |
|
| 396 | + * @param mixed $val The value to serialize |
|
| 397 | + * @param string $name The name (local part) of the XML element |
|
| 398 | + * @param string $type The XML schema type (local part) for the element |
|
| 399 | + * @param string $name_ns The namespace for the name of the XML element |
|
| 400 | + * @param string $type_ns The namespace for the type of the element |
|
| 401 | + * @param array $attributes The attributes to serialize as name=>value pairs |
|
| 402 | + * @param string $use The WSDL "use" (encoded|literal) |
|
| 403 | + * @param boolean $soapval Whether this is called from soapval. |
|
| 404 | + * @return string The serialized element, possibly with child elements |
|
| 405 | + * @access public |
|
| 406 | + */ |
|
| 407 | 407 | public function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
| 408 | 408 | $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
| 409 | 409 | $this->appendDebug('value=' . $this->varDump($val)); |
| 410 | 410 | $this->appendDebug('attributes=' . $this->varDump($attributes)); |
| 411 | 411 | |
| 412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
| 413 | - $this->debug("serialize_val: serialize soapval"); |
|
| 414 | - $xml = $val->serialize($use); |
|
| 412 | + if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
| 413 | + $this->debug("serialize_val: serialize soapval"); |
|
| 414 | + $xml = $val->serialize($use); |
|
| 415 | 415 | $this->appendDebug($val->getDebug()); |
| 416 | 416 | $val->clearDebug(); |
| 417 | 417 | $this->debug("serialize_val of soapval returning $xml"); |
| 418 | 418 | return $xml; |
| 419 | - } |
|
| 419 | + } |
|
| 420 | 420 | // force valid name if necessary |
| 421 | 421 | if (is_numeric($name)) { |
| 422 | 422 | $name = '__numeric_' . $name; |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | } |
| 426 | 426 | // if name has ns, add ns prefix to name |
| 427 | 427 | $xmlns = ''; |
| 428 | - if($name_ns){ |
|
| 428 | + if($name_ns){ |
|
| 429 | 429 | $prefix = 'nu'.rand(1000,9999); |
| 430 | 430 | $name = $prefix.':'.$name; |
| 431 | 431 | $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | // if type is prefixed, create type prefix |
| 434 | 434 | if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
| 435 | 435 | // need to fix this. shouldn't default to xsd if no ns specified |
| 436 | - // w/o checking against typemap |
|
| 436 | + // w/o checking against typemap |
|
| 437 | 437 | $type_prefix = 'xsd'; |
| 438 | 438 | } elseif($type_ns){ |
| 439 | 439 | $type_prefix = 'ns'.rand(1000,9999); |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | // serialize null value |
| 450 | 450 | if (is_null($val)) { |
| 451 | - $this->debug("serialize_val: serialize null"); |
|
| 451 | + $this->debug("serialize_val: serialize null"); |
|
| 452 | 452 | if ($use == 'literal') { |
| 453 | 453 | $xml = "<$name$xmlns$atts/>"; |
| 454 | 454 | $this->debug("serialize_val returning $xml"); |
| 455 | - return $xml; |
|
| 456 | - } else { |
|
| 455 | + return $xml; |
|
| 456 | + } else { |
|
| 457 | 457 | if (isset($type) && isset($type_prefix)) { |
| 458 | 458 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 459 | 459 | } else { |
@@ -461,41 +461,41 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
| 463 | 463 | $this->debug("serialize_val returning $xml"); |
| 464 | - return $xml; |
|
| 465 | - } |
|
| 464 | + return $xml; |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | - // serialize if an xsd built-in primitive type |
|
| 468 | - if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
|
| 469 | - $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
| 470 | - if (is_bool($val)) { |
|
| 471 | - if ($type == 'boolean') { |
|
| 472 | - $val = $val ? 'true' : 'false'; |
|
| 473 | - } elseif (! $val) { |
|
| 474 | - $val = 0; |
|
| 475 | - } |
|
| 467 | + // serialize if an xsd built-in primitive type |
|
| 468 | + if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
|
| 469 | + $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
| 470 | + if (is_bool($val)) { |
|
| 471 | + if ($type == 'boolean') { |
|
| 472 | + $val = $val ? 'true' : 'false'; |
|
| 473 | + } elseif (! $val) { |
|
| 474 | + $val = 0; |
|
| 475 | + } |
|
| 476 | 476 | } else if (is_string($val)) { |
| 477 | 477 | $val = $this->expandEntities($val); |
| 478 | 478 | } |
| 479 | 479 | if ($use == 'literal') { |
| 480 | 480 | $xml = "<$name$xmlns$atts>$val</$name>"; |
| 481 | 481 | $this->debug("serialize_val returning $xml"); |
| 482 | - return $xml; |
|
| 483 | - } else { |
|
| 482 | + return $xml; |
|
| 483 | + } else { |
|
| 484 | 484 | $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
| 485 | 485 | $this->debug("serialize_val returning $xml"); |
| 486 | - return $xml; |
|
| 487 | - } |
|
| 488 | - } |
|
| 486 | + return $xml; |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | 489 | // detect type and serialize |
| 490 | 490 | $xml = ''; |
| 491 | 491 | switch(true) { |
| 492 | 492 | case (is_bool($val) || $type == 'boolean'): |
| 493 | 493 | $this->debug("serialize_val: serialize boolean"); |
| 494 | - if ($type == 'boolean') { |
|
| 495 | - $val = $val ? 'true' : 'false'; |
|
| 496 | - } elseif (! $val) { |
|
| 497 | - $val = 0; |
|
| 498 | - } |
|
| 494 | + if ($type == 'boolean') { |
|
| 495 | + $val = $val ? 'true' : 'false'; |
|
| 496 | + } elseif (! $val) { |
|
| 497 | + $val = 0; |
|
| 498 | + } |
|
| 499 | 499 | if ($use == 'literal') { |
| 500 | 500 | $xml .= "<$name$xmlns$atts>$val</$name>"; |
| 501 | 501 | } else { |
@@ -529,12 +529,12 @@ discard block |
||
| 529 | 529 | break; |
| 530 | 530 | case is_object($val): |
| 531 | 531 | $this->debug("serialize_val: serialize object"); |
| 532 | - if (get_class($val) == 'soapval') { |
|
| 533 | - $this->debug("serialize_val: serialize soapval object"); |
|
| 534 | - $pXml = $val->serialize($use); |
|
| 532 | + if (get_class($val) == 'soapval') { |
|
| 533 | + $this->debug("serialize_val: serialize soapval object"); |
|
| 534 | + $pXml = $val->serialize($use); |
|
| 535 | 535 | $this->appendDebug($val->getDebug()); |
| 536 | 536 | $val->clearDebug(); |
| 537 | - } else { |
|
| 537 | + } else { |
|
| 538 | 538 | if (! $name) { |
| 539 | 539 | $name = get_class($val); |
| 540 | 540 | $this->debug("In serialize_val, used class name $name as element name"); |
@@ -560,19 +560,19 @@ discard block |
||
| 560 | 560 | case (is_array($val) || $type): |
| 561 | 561 | // detect if struct or array |
| 562 | 562 | $valueType = $this->isArraySimpleOrStruct($val); |
| 563 | - if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
|
| 563 | + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
|
| 564 | 564 | $this->debug("serialize_val: serialize array"); |
| 565 | 565 | $i = 0; |
| 566 | 566 | if(is_array($val) && count($val)> 0){ |
| 567 | 567 | foreach($val as $v){ |
| 568 | - if(is_object($v) && get_class($v) == 'soapval'){ |
|
| 568 | + if(is_object($v) && get_class($v) == 'soapval'){ |
|
| 569 | 569 | $tt_ns = $v->type_ns; |
| 570 | 570 | $tt = $v->type; |
| 571 | 571 | } elseif (is_array($v)) { |
| 572 | 572 | $tt = $this->isArraySimpleOrStruct($v); |
| 573 | 573 | } else { |
| 574 | 574 | $tt = gettype($v); |
| 575 | - } |
|
| 575 | + } |
|
| 576 | 576 | $array_types[$tt] = 1; |
| 577 | 577 | $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
| 578 | 578 | ++$i; |
@@ -655,19 +655,19 @@ discard block |
||
| 655 | 655 | return $xml; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - /** |
|
| 659 | - * serializes a message |
|
| 660 | - * |
|
| 661 | - * @param string $body the XML of the SOAP body |
|
| 662 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 663 | - * @param array $namespaces optional the namespaces used in generating the body and headers |
|
| 664 | - * @param string $style optional (rpc|document) |
|
| 665 | - * @param string $use optional (encoded|literal) |
|
| 666 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 667 | - * @return string the message |
|
| 668 | - * @access public |
|
| 669 | - */ |
|
| 670 | - public function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
|
| 658 | + /** |
|
| 659 | + * serializes a message |
|
| 660 | + * |
|
| 661 | + * @param string $body the XML of the SOAP body |
|
| 662 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 663 | + * @param array $namespaces optional the namespaces used in generating the body and headers |
|
| 664 | + * @param string $style optional (rpc|document) |
|
| 665 | + * @param string $use optional (encoded|literal) |
|
| 666 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 667 | + * @return string the message |
|
| 668 | + * @access public |
|
| 669 | + */ |
|
| 670 | + public function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
|
| 671 | 671 | |
| 672 | 672 | $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
| 673 | 673 | $this->debug("headers:"); |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | $this->appendDebug($this->varDump($namespaces)); |
| 677 | 677 | |
| 678 | 678 | // serialize namespaces |
| 679 | - $ns_string = ''; |
|
| 679 | + $ns_string = ''; |
|
| 680 | 680 | foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
| 681 | 681 | $ns_string .= " xmlns:$k=\"$v\""; |
| 682 | 682 | } |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | $body. |
| 710 | 710 | "</SOAP-ENV:Body>". |
| 711 | 711 | "</SOAP-ENV:Envelope>"; |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | /** |
| 715 | 715 | * formats a string to be inserted into an HTML stream |
@@ -719,18 +719,18 @@ discard block |
||
| 719 | 719 | * @access public |
| 720 | 720 | * @deprecated |
| 721 | 721 | */ |
| 722 | - public function formatDump($str){ |
|
| 722 | + public function formatDump($str){ |
|
| 723 | 723 | $str = htmlspecialchars($str); |
| 724 | 724 | return nl2br($str); |
| 725 | - } |
|
| 725 | + } |
|
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * contracts (changes namespace to prefix) a qualified name |
|
| 729 | - * |
|
| 730 | - * @param string $qname qname |
|
| 731 | - * @return string contracted qname |
|
| 732 | - * @access private |
|
| 733 | - */ |
|
| 728 | + * contracts (changes namespace to prefix) a qualified name |
|
| 729 | + * |
|
| 730 | + * @param string $qname qname |
|
| 731 | + * @return string contracted qname |
|
| 732 | + * @access private |
|
| 733 | + */ |
|
| 734 | 734 | public function contractQname($qname){ |
| 735 | 735 | // get element namespace |
| 736 | 736 | if (strrpos($qname, ':')) { |
@@ -749,12 +749,12 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | - * expands (changes prefix to namespace) a qualified name |
|
| 753 | - * |
|
| 754 | - * @param string $qname qname |
|
| 755 | - * @return string expanded qname |
|
| 756 | - * @access private |
|
| 757 | - */ |
|
| 752 | + * expands (changes prefix to namespace) a qualified name |
|
| 753 | + * |
|
| 754 | + * @param string $qname qname |
|
| 755 | + * @return string expanded qname |
|
| 756 | + * @access private |
|
| 757 | + */ |
|
| 758 | 758 | public function expandQname($qname){ |
| 759 | 759 | // get element prefix |
| 760 | 760 | if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
@@ -772,14 +772,14 @@ discard block |
||
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - /** |
|
| 776 | - * returns the local part of a prefixed string |
|
| 777 | - * returns the original string, if not prefixed |
|
| 778 | - * |
|
| 779 | - * @param string $str The prefixed string |
|
| 780 | - * @return string The local part |
|
| 781 | - * @access public |
|
| 782 | - */ |
|
| 775 | + /** |
|
| 776 | + * returns the local part of a prefixed string |
|
| 777 | + * returns the original string, if not prefixed |
|
| 778 | + * |
|
| 779 | + * @param string $str The prefixed string |
|
| 780 | + * @return string The local part |
|
| 781 | + * @access public |
|
| 782 | + */ |
|
| 783 | 783 | public function getLocalPart($str){ |
| 784 | 784 | if($sstr = strrchr($str,':')){ |
| 785 | 785 | // get unqualified name |
@@ -790,13 +790,13 @@ discard block |
||
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | /** |
| 793 | - * returns the prefix part of a prefixed string |
|
| 794 | - * returns false, if not prefixed |
|
| 795 | - * |
|
| 796 | - * @param string $str The prefixed string |
|
| 797 | - * @return mixed The prefix or false if there is no prefix |
|
| 798 | - * @access public |
|
| 799 | - */ |
|
| 793 | + * returns the prefix part of a prefixed string |
|
| 794 | + * returns false, if not prefixed |
|
| 795 | + * |
|
| 796 | + * @param string $str The prefixed string |
|
| 797 | + * @return mixed The prefix or false if there is no prefix |
|
| 798 | + * @access public |
|
| 799 | + */ |
|
| 800 | 800 | public function getPrefix($str){ |
| 801 | 801 | if($pos = strrpos($str,':')){ |
| 802 | 802 | // get prefix |
@@ -806,12 +806,12 @@ discard block |
||
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | /** |
| 809 | - * pass it a prefix, it returns a namespace |
|
| 810 | - * |
|
| 811 | - * @param string $prefix The prefix |
|
| 812 | - * @return mixed The namespace, false if no namespace has the specified prefix |
|
| 813 | - * @access public |
|
| 814 | - */ |
|
| 809 | + * pass it a prefix, it returns a namespace |
|
| 810 | + * |
|
| 811 | + * @param string $prefix The prefix |
|
| 812 | + * @return mixed The namespace, false if no namespace has the specified prefix |
|
| 813 | + * @access public |
|
| 814 | + */ |
|
| 815 | 815 | public function getNamespaceFromPrefix($prefix){ |
| 816 | 816 | if (isset($this->namespaces[$prefix])) { |
| 817 | 817 | return $this->namespaces[$prefix]; |
@@ -820,17 +820,17 @@ discard block |
||
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | - * returns the prefix for a given namespace (or prefix) |
|
| 824 | - * or false if no prefixes registered for the given namespace |
|
| 825 | - * |
|
| 826 | - * @param string $ns The namespace |
|
| 827 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
| 828 | - * @access public |
|
| 829 | - */ |
|
| 823 | + * returns the prefix for a given namespace (or prefix) |
|
| 824 | + * or false if no prefixes registered for the given namespace |
|
| 825 | + * |
|
| 826 | + * @param string $ns The namespace |
|
| 827 | + * @return mixed The prefix, false if the namespace has no prefixes |
|
| 828 | + * @access public |
|
| 829 | + */ |
|
| 830 | 830 | public function getPrefixFromNamespace($ns) { |
| 831 | 831 | foreach ($this->namespaces as $p => $n) { |
| 832 | 832 | if ($ns == $n || $ns == $p) { |
| 833 | - $this->usedNamespaces[$p] = $n; |
|
| 833 | + $this->usedNamespaces[$p] = $n; |
|
| 834 | 834 | return $p; |
| 835 | 835 | } |
| 836 | 836 | } |
@@ -838,11 +838,11 @@ discard block |
||
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | /** |
| 841 | - * returns the time in ODBC canonical form with microseconds |
|
| 842 | - * |
|
| 843 | - * @return string The time in ODBC canonical form with microseconds |
|
| 844 | - * @access public |
|
| 845 | - */ |
|
| 841 | + * returns the time in ODBC canonical form with microseconds |
|
| 842 | + * |
|
| 843 | + * @return string The time in ODBC canonical form with microseconds |
|
| 844 | + * @access public |
|
| 845 | + */ |
|
| 846 | 846 | public function getmicrotime() { |
| 847 | 847 | if (function_exists('gettimeofday')) { |
| 848 | 848 | $tod = gettimeofday(); |
@@ -862,17 +862,17 @@ discard block |
||
| 862 | 862 | * @return string The output of var_dump |
| 863 | 863 | * @access public |
| 864 | 864 | */ |
| 865 | - public function varDump($data) { |
|
| 865 | + public function varDump($data) { |
|
| 866 | 866 | $ret_val = var_export($data, true); |
| 867 | 867 | return $ret_val; |
| 868 | 868 | } |
| 869 | 869 | |
| 870 | 870 | /** |
| 871 | - * represents the object as a string |
|
| 872 | - * |
|
| 873 | - * @return string |
|
| 874 | - * @access public |
|
| 875 | - */ |
|
| 871 | + * represents the object as a string |
|
| 872 | + * |
|
| 873 | + * @return string |
|
| 874 | + * @access public |
|
| 875 | + */ |
|
| 876 | 876 | public function __toString() { |
| 877 | 877 | return $this->varDump($this); |
| 878 | 878 | } |
@@ -183,26 +183,26 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | public $typemap = array( |
| 185 | 185 | 'http://www.w3.org/2001/XMLSchema' => array( |
| 186 | - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
| 187 | - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
| 188 | - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
| 186 | + 'string'=>'string', 'boolean'=>'boolean', 'float'=>'double', 'double'=>'double', 'decimal'=>'double', |
|
| 187 | + 'duration'=>'', 'dateTime'=>'string', 'time'=>'string', 'date'=>'string', 'gYearMonth'=>'', |
|
| 188 | + 'gYear'=>'', 'gMonthDay'=>'', 'gDay'=>'', 'gMonth'=>'', 'hexBinary'=>'string', 'base64Binary'=>'string', |
|
| 189 | 189 | // abstract "any" types |
| 190 | - 'anyType'=>'string','anySimpleType'=>'string', |
|
| 190 | + 'anyType'=>'string', 'anySimpleType'=>'string', |
|
| 191 | 191 | // derived datatypes |
| 192 | - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
| 193 | - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
| 194 | - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
| 195 | - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
| 192 | + 'normalizedString'=>'string', 'token'=>'string', 'language'=>'', 'NMTOKEN'=>'', 'NMTOKENS'=>'', 'Name'=>'', 'NCName'=>'', 'ID'=>'', |
|
| 193 | + 'IDREF'=>'', 'IDREFS'=>'', 'ENTITY'=>'', 'ENTITIES'=>'', 'integer'=>'integer', 'nonPositiveInteger'=>'integer', |
|
| 194 | + 'negativeInteger'=>'integer', 'long'=>'integer', 'int'=>'integer', 'short'=>'integer', 'byte'=>'integer', 'nonNegativeInteger'=>'integer', |
|
| 195 | + 'unsignedLong'=>'', 'unsignedInt'=>'', 'unsignedShort'=>'', 'unsignedByte'=>'', 'positiveInteger'=>''), |
|
| 196 | 196 | 'http://www.w3.org/2000/10/XMLSchema' => array( |
| 197 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 198 | - 'float'=>'double','dateTime'=>'string', |
|
| 199 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 197 | + 'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double', |
|
| 198 | + 'float'=>'double', 'dateTime'=>'string', |
|
| 199 | + 'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'), |
|
| 200 | 200 | 'http://www.w3.org/1999/XMLSchema' => array( |
| 201 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 202 | - 'float'=>'double','dateTime'=>'string', |
|
| 203 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 201 | + 'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double', |
|
| 202 | + 'float'=>'double', 'dateTime'=>'string', |
|
| 203 | + 'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'), |
|
| 204 | 204 | 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
| 205 | - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
|
| 205 | + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string', 'array'=>'array', 'Array'=>'array'), |
|
| 206 | 206 | 'http://xml.apache.org/xml-soap' => array('Map') |
| 207 | 207 | ); |
| 208 | 208 | |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | * @deprecated |
| 215 | 215 | * @see expandEntities |
| 216 | 216 | */ |
| 217 | - public $xmlEntities = array('quot' => '"','amp' => '&', |
|
| 218 | - 'lt' => '<','gt' => '>','apos' => "'"); |
|
| 217 | + public $xmlEntities = array('quot' => '"', 'amp' => '&', |
|
| 218 | + 'lt' => '<', 'gt' => '>', 'apos' => "'"); |
|
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * constructor |
@@ -272,9 +272,9 @@ discard block |
||
| 272 | 272 | * @param string $string debug data |
| 273 | 273 | * @access private |
| 274 | 274 | */ |
| 275 | - public function debug($string){ |
|
| 275 | + public function debug($string) { |
|
| 276 | 276 | if ($this->debugLevel > 0) { |
| 277 | - $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
| 277 | + $this->appendDebug($this->getmicrotime() . ' ' . get_class($this) . ": $string\n"); |
|
| 278 | 278 | } |
| 279 | 279 | } |
| 280 | 280 | |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param string $string debug data |
| 285 | 285 | * @access public |
| 286 | 286 | */ |
| 287 | - public function appendDebug($string){ |
|
| 287 | + public function appendDebug($string) { |
|
| 288 | 288 | if ($this->debugLevel > 0) { |
| 289 | 289 | // it would be nice to use a memory stream here to use |
| 290 | 290 | // memory more efficiently |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | * @return mixed error string or false |
| 356 | 356 | * @access public |
| 357 | 357 | */ |
| 358 | - public function getError(){ |
|
| 359 | - if($this->error_str != ''){ |
|
| 358 | + public function getError() { |
|
| 359 | + if ($this->error_str != '') { |
|
| 360 | 360 | return $this->error_str; |
| 361 | 361 | } |
| 362 | 362 | return false; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @return boolean $string error string |
| 369 | 369 | * @access private |
| 370 | 370 | */ |
| 371 | - public function setError($str){ |
|
| 371 | + public function setError($str) { |
|
| 372 | 372 | $this->error_str = $str; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -404,12 +404,12 @@ discard block |
||
| 404 | 404 | * @return string The serialized element, possibly with child elements |
| 405 | 405 | * @access public |
| 406 | 406 | */ |
| 407 | - public function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
|
| 407 | + public function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) { |
|
| 408 | 408 | $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
| 409 | 409 | $this->appendDebug('value=' . $this->varDump($val)); |
| 410 | 410 | $this->appendDebug('attributes=' . $this->varDump($attributes)); |
| 411 | 411 | |
| 412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
| 412 | + if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) { |
|
| 413 | 413 | $this->debug("serialize_val: serialize soapval"); |
| 414 | 414 | $xml = $val->serialize($use); |
| 415 | 415 | $this->appendDebug($val->getDebug()); |
@@ -420,30 +420,30 @@ discard block |
||
| 420 | 420 | // force valid name if necessary |
| 421 | 421 | if (is_numeric($name)) { |
| 422 | 422 | $name = '__numeric_' . $name; |
| 423 | - } elseif (! $name) { |
|
| 423 | + } elseif (!$name) { |
|
| 424 | 424 | $name = 'noname'; |
| 425 | 425 | } |
| 426 | 426 | // if name has ns, add ns prefix to name |
| 427 | 427 | $xmlns = ''; |
| 428 | - if($name_ns){ |
|
| 429 | - $prefix = 'nu'.rand(1000,9999); |
|
| 430 | - $name = $prefix.':'.$name; |
|
| 428 | + if ($name_ns) { |
|
| 429 | + $prefix = 'nu' . rand(1000, 9999); |
|
| 430 | + $name = $prefix . ':' . $name; |
|
| 431 | 431 | $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
| 432 | 432 | } |
| 433 | 433 | // if type is prefixed, create type prefix |
| 434 | - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
|
| 434 | + if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) { |
|
| 435 | 435 | // need to fix this. shouldn't default to xsd if no ns specified |
| 436 | 436 | // w/o checking against typemap |
| 437 | 437 | $type_prefix = 'xsd'; |
| 438 | - } elseif($type_ns){ |
|
| 439 | - $type_prefix = 'ns'.rand(1000,9999); |
|
| 438 | + } elseif ($type_ns) { |
|
| 439 | + $type_prefix = 'ns' . rand(1000, 9999); |
|
| 440 | 440 | $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
| 441 | 441 | } |
| 442 | 442 | // serialize attributes if present |
| 443 | 443 | $atts = ''; |
| 444 | - if($attributes){ |
|
| 445 | - foreach($attributes as $k => $v){ |
|
| 446 | - $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
| 444 | + if ($attributes) { |
|
| 445 | + foreach ($attributes as $k => $v) { |
|
| 446 | + $atts .= " $k=\"" . $this->expandEntities($v) . '"'; |
|
| 447 | 447 | } |
| 448 | 448 | } |
| 449 | 449 | // serialize null value |
@@ -465,12 +465,12 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | // serialize if an xsd built-in primitive type |
| 468 | - if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
|
| 468 | + if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) { |
|
| 469 | 469 | $this->debug("serialize_val: serialize xsd built-in primitive type"); |
| 470 | 470 | if (is_bool($val)) { |
| 471 | 471 | if ($type == 'boolean') { |
| 472 | 472 | $val = $val ? 'true' : 'false'; |
| 473 | - } elseif (! $val) { |
|
| 473 | + } elseif (!$val) { |
|
| 474 | 474 | $val = 0; |
| 475 | 475 | } |
| 476 | 476 | } else if (is_string($val)) { |
@@ -488,12 +488,12 @@ discard block |
||
| 488 | 488 | } |
| 489 | 489 | // detect type and serialize |
| 490 | 490 | $xml = ''; |
| 491 | - switch(true) { |
|
| 491 | + switch (true) { |
|
| 492 | 492 | case (is_bool($val) || $type == 'boolean'): |
| 493 | 493 | $this->debug("serialize_val: serialize boolean"); |
| 494 | 494 | if ($type == 'boolean') { |
| 495 | 495 | $val = $val ? 'true' : 'false'; |
| 496 | - } elseif (! $val) { |
|
| 496 | + } elseif (!$val) { |
|
| 497 | 497 | $val = 0; |
| 498 | 498 | } |
| 499 | 499 | if ($use == 'literal') { |
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
| 511 | 511 | } |
| 512 | 512 | break; |
| 513 | - case (is_float($val)|| is_double($val) || $type == 'float'): |
|
| 513 | + case (is_float($val) || is_double($val) || $type == 'float'): |
|
| 514 | 514 | $this->debug("serialize_val: serialize float"); |
| 515 | 515 | if ($use == 'literal') { |
| 516 | 516 | $xml .= "<$name$xmlns$atts>$val</$name>"; |
@@ -535,17 +535,17 @@ discard block |
||
| 535 | 535 | $this->appendDebug($val->getDebug()); |
| 536 | 536 | $val->clearDebug(); |
| 537 | 537 | } else { |
| 538 | - if (! $name) { |
|
| 538 | + if (!$name) { |
|
| 539 | 539 | $name = get_class($val); |
| 540 | 540 | $this->debug("In serialize_val, used class name $name as element name"); |
| 541 | 541 | } else { |
| 542 | 542 | $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val)); |
| 543 | 543 | } |
| 544 | - foreach(get_object_vars($val) as $k => $v){ |
|
| 545 | - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 544 | + foreach (get_object_vars($val) as $k => $v) { |
|
| 545 | + $pXml = isset($pXml) ? $pXml . $this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 546 | 546 | } |
| 547 | 547 | } |
| 548 | - if(isset($type) && isset($type_prefix)){ |
|
| 548 | + if (isset($type) && isset($type_prefix)) { |
|
| 549 | 549 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 550 | 550 | } else { |
| 551 | 551 | $type_str = ''; |
@@ -560,12 +560,12 @@ discard block |
||
| 560 | 560 | case (is_array($val) || $type): |
| 561 | 561 | // detect if struct or array |
| 562 | 562 | $valueType = $this->isArraySimpleOrStruct($val); |
| 563 | - if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
|
| 563 | + if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) { |
|
| 564 | 564 | $this->debug("serialize_val: serialize array"); |
| 565 | 565 | $i = 0; |
| 566 | - if(is_array($val) && count($val)> 0){ |
|
| 567 | - foreach($val as $v){ |
|
| 568 | - if(is_object($v) && get_class($v) == 'soapval'){ |
|
| 566 | + if (is_array($val) && count($val) > 0) { |
|
| 567 | + foreach ($val as $v) { |
|
| 568 | + if (is_object($v) && get_class($v) == 'soapval') { |
|
| 569 | 569 | $tt_ns = $v->type_ns; |
| 570 | 570 | $tt = $v->type; |
| 571 | 571 | } elseif (is_array($v)) { |
@@ -574,23 +574,23 @@ discard block |
||
| 574 | 574 | $tt = gettype($v); |
| 575 | 575 | } |
| 576 | 576 | $array_types[$tt] = 1; |
| 577 | - $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
| 577 | + $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use); |
|
| 578 | 578 | ++$i; |
| 579 | 579 | } |
| 580 | - if(count($array_types) > 1){ |
|
| 580 | + if (count($array_types) > 1) { |
|
| 581 | 581 | $array_typename = 'xsd:anyType'; |
| 582 | - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
| 582 | + } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) { |
|
| 583 | 583 | if ($tt == 'integer') { |
| 584 | 584 | $tt = 'int'; |
| 585 | 585 | } |
| 586 | - $array_typename = 'xsd:'.$tt; |
|
| 587 | - } elseif(isset($tt) && $tt == 'arraySimple'){ |
|
| 586 | + $array_typename = 'xsd:' . $tt; |
|
| 587 | + } elseif (isset($tt) && $tt == 'arraySimple') { |
|
| 588 | 588 | $array_typename = 'SOAP-ENC:Array'; |
| 589 | - } elseif(isset($tt) && $tt == 'arrayStruct'){ |
|
| 589 | + } elseif (isset($tt) && $tt == 'arrayStruct') { |
|
| 590 | 590 | $array_typename = 'unnamed_struct_use_soapval'; |
| 591 | 591 | } else { |
| 592 | 592 | // if type is prefixed, create type prefix |
| 593 | - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){ |
|
| 593 | + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) { |
|
| 594 | 594 | $array_typename = 'xsd:' . $tt; |
| 595 | 595 | } elseif ($tt_ns) { |
| 596 | 596 | $tt_prefix = 'ns' . rand(1000, 9999); |
@@ -606,7 +606,7 @@ discard block |
||
| 606 | 606 | } else if (isset($type) && isset($type_prefix)) { |
| 607 | 607 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 608 | 608 | } else { |
| 609 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
| 609 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"" . $array_typename . "[$array_type]\""; |
|
| 610 | 610 | } |
| 611 | 611 | // empty array |
| 612 | 612 | } else { |
@@ -618,11 +618,11 @@ discard block |
||
| 618 | 618 | $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
| 619 | 619 | } |
| 620 | 620 | } |
| 621 | - $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
| 621 | + $xml = "<$name$xmlns$type_str$atts>" . $xml . "</$name>"; |
|
| 622 | 622 | } else { |
| 623 | 623 | // got a struct |
| 624 | 624 | $this->debug("serialize_val: serialize struct"); |
| 625 | - if(isset($type) && isset($type_prefix)){ |
|
| 625 | + if (isset($type) && isset($type_prefix)) { |
|
| 626 | 626 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 627 | 627 | } else { |
| 628 | 628 | $type_str = ''; |
@@ -632,15 +632,15 @@ discard block |
||
| 632 | 632 | } else { |
| 633 | 633 | $xml .= "<$name$xmlns$type_str$atts>"; |
| 634 | 634 | } |
| 635 | - foreach($val as $k => $v){ |
|
| 635 | + foreach ($val as $k => $v) { |
|
| 636 | 636 | // Apache Map |
| 637 | 637 | if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') { |
| 638 | 638 | $xml .= '<item>'; |
| 639 | - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 640 | - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 639 | + $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use); |
|
| 640 | + $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use); |
|
| 641 | 641 | $xml .= '</item>'; |
| 642 | 642 | } else { |
| 643 | - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 643 | + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 644 | 644 | } |
| 645 | 645 | } |
| 646 | 646 | $xml .= "</$name>"; |
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | break; |
| 649 | 649 | default: |
| 650 | 650 | $this->debug("serialize_val: serialize unknown"); |
| 651 | - $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
| 651 | + $xml .= 'not detected, got ' . gettype($val) . ' for ' . $val; |
|
| 652 | 652 | break; |
| 653 | 653 | } |
| 654 | 654 | $this->debug("serialize_val returning $xml"); |
@@ -667,7 +667,7 @@ discard block |
||
| 667 | 667 | * @return string the message |
| 668 | 668 | * @access public |
| 669 | 669 | */ |
| 670 | - public function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
|
| 670 | + public function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') { |
|
| 671 | 671 | |
| 672 | 672 | $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
| 673 | 673 | $this->debug("headers:"); |
@@ -677,15 +677,15 @@ discard block |
||
| 677 | 677 | |
| 678 | 678 | // serialize namespaces |
| 679 | 679 | $ns_string = ''; |
| 680 | - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
|
| 680 | + foreach (array_merge($this->namespaces, $namespaces) as $k => $v) { |
|
| 681 | 681 | $ns_string .= " xmlns:$k=\"$v\""; |
| 682 | 682 | } |
| 683 | - if($encodingStyle) { |
|
| 683 | + if ($encodingStyle) { |
|
| 684 | 684 | $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | // serialize headers |
| 688 | - if($headers){ |
|
| 688 | + if ($headers) { |
|
| 689 | 689 | if (is_array($headers)) { |
| 690 | 690 | $xml = ''; |
| 691 | 691 | foreach ($headers as $k => $v) { |
@@ -698,16 +698,16 @@ discard block |
||
| 698 | 698 | $headers = $xml; |
| 699 | 699 | $this->debug("In serializeEnvelope, serialized array of headers to $headers"); |
| 700 | 700 | } |
| 701 | - $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
| 701 | + $headers = "<SOAP-ENV:Header>" . $headers . "</SOAP-ENV:Header>"; |
|
| 702 | 702 | } |
| 703 | 703 | // serialize envelope |
| 704 | 704 | return |
| 705 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
| 706 | - '<SOAP-ENV:Envelope'.$ns_string.">". |
|
| 707 | - $headers. |
|
| 708 | - "<SOAP-ENV:Body>". |
|
| 709 | - $body. |
|
| 710 | - "</SOAP-ENV:Body>". |
|
| 705 | + '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?' . ">" . |
|
| 706 | + '<SOAP-ENV:Envelope' . $ns_string . ">" . |
|
| 707 | + $headers . |
|
| 708 | + "<SOAP-ENV:Body>" . |
|
| 709 | + $body . |
|
| 710 | + "</SOAP-ENV:Body>" . |
|
| 711 | 711 | "</SOAP-ENV:Envelope>"; |
| 712 | 712 | } |
| 713 | 713 | |
@@ -719,7 +719,7 @@ discard block |
||
| 719 | 719 | * @access public |
| 720 | 720 | * @deprecated |
| 721 | 721 | */ |
| 722 | - public function formatDump($str){ |
|
| 722 | + public function formatDump($str) { |
|
| 723 | 723 | $str = htmlspecialchars($str); |
| 724 | 724 | return nl2br($str); |
| 725 | 725 | } |
@@ -731,7 +731,7 @@ discard block |
||
| 731 | 731 | * @return string contracted qname |
| 732 | 732 | * @access private |
| 733 | 733 | */ |
| 734 | - public function contractQname($qname){ |
|
| 734 | + public function contractQname($qname) { |
|
| 735 | 735 | // get element namespace |
| 736 | 736 | if (strrpos($qname, ':')) { |
| 737 | 737 | // get unqualified name |
@@ -755,15 +755,15 @@ discard block |
||
| 755 | 755 | * @return string expanded qname |
| 756 | 756 | * @access private |
| 757 | 757 | */ |
| 758 | - public function expandQname($qname){ |
|
| 758 | + public function expandQname($qname) { |
|
| 759 | 759 | // get element prefix |
| 760 | - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
|
| 760 | + if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) { |
|
| 761 | 761 | // get unqualified name |
| 762 | - $name = substr(strstr($qname,':'),1); |
|
| 762 | + $name = substr(strstr($qname, ':'), 1); |
|
| 763 | 763 | // get ns prefix |
| 764 | - $prefix = substr($qname,0,strpos($qname,':')); |
|
| 765 | - if(isset($this->namespaces[$prefix])){ |
|
| 766 | - return $this->namespaces[$prefix].':'.$name; |
|
| 764 | + $prefix = substr($qname, 0, strpos($qname, ':')); |
|
| 765 | + if (isset($this->namespaces[$prefix])) { |
|
| 766 | + return $this->namespaces[$prefix] . ':' . $name; |
|
| 767 | 767 | } else { |
| 768 | 768 | return $qname; |
| 769 | 769 | } |
@@ -780,10 +780,10 @@ discard block |
||
| 780 | 780 | * @return string The local part |
| 781 | 781 | * @access public |
| 782 | 782 | */ |
| 783 | - public function getLocalPart($str){ |
|
| 784 | - if($sstr = strrchr($str,':')){ |
|
| 783 | + public function getLocalPart($str) { |
|
| 784 | + if ($sstr = strrchr($str, ':')) { |
|
| 785 | 785 | // get unqualified name |
| 786 | - return substr( $sstr, 1 ); |
|
| 786 | + return substr($sstr, 1); |
|
| 787 | 787 | } else { |
| 788 | 788 | return $str; |
| 789 | 789 | } |
@@ -797,10 +797,10 @@ discard block |
||
| 797 | 797 | * @return mixed The prefix or false if there is no prefix |
| 798 | 798 | * @access public |
| 799 | 799 | */ |
| 800 | - public function getPrefix($str){ |
|
| 801 | - if($pos = strrpos($str,':')){ |
|
| 800 | + public function getPrefix($str) { |
|
| 801 | + if ($pos = strrpos($str, ':')) { |
|
| 802 | 802 | // get prefix |
| 803 | - return substr($str,0,$pos); |
|
| 803 | + return substr($str, 0, $pos); |
|
| 804 | 804 | } |
| 805 | 805 | return false; |
| 806 | 806 | } |
@@ -812,7 +812,7 @@ discard block |
||
| 812 | 812 | * @return mixed The namespace, false if no namespace has the specified prefix |
| 813 | 813 | * @access public |
| 814 | 814 | */ |
| 815 | - public function getNamespaceFromPrefix($prefix){ |
|
| 815 | + public function getNamespaceFromPrefix($prefix) { |
|
| 816 | 816 | if (isset($this->namespaces[$prefix])) { |
| 817 | 817 | return $this->namespaces[$prefix]; |
| 818 | 818 | } |
@@ -890,8 +890,8 @@ discard block |
||
| 890 | 890 | * @return mixed ISO 8601 date string or false |
| 891 | 891 | * @access public |
| 892 | 892 | */ |
| 893 | -function timestamp_to_iso8601($timestamp,$utc=true){ |
|
| 894 | - $datestr = date('Y-m-d\TH:i:sO',$timestamp); |
|
| 893 | +function timestamp_to_iso8601($timestamp, $utc = true) { |
|
| 894 | + $datestr = date('Y-m-d\TH:i:sO', $timestamp); |
|
| 895 | 895 | $pos = strrpos($datestr, "+"); |
| 896 | 896 | if ($pos === false) { |
| 897 | 897 | $pos = strrpos($datestr, "-"); |
@@ -901,20 +901,20 @@ discard block |
||
| 901 | 901 | $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
| 902 | 902 | } |
| 903 | 903 | } |
| 904 | - if($utc){ |
|
| 905 | - $pattern = '/'. |
|
| 906 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
| 907 | - '([0-9]{2})-'. // months MM- |
|
| 908 | - '([0-9]{2})'. // days DD |
|
| 909 | - 'T'. // separator T |
|
| 910 | - '([0-9]{2}):'. // hours hh: |
|
| 911 | - '([0-9]{2}):'. // minutes mm: |
|
| 912 | - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss... |
|
| 913 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
| 904 | + if ($utc) { |
|
| 905 | + $pattern = '/' . |
|
| 906 | + '([0-9]{4})-' . // centuries & years CCYY- |
|
| 907 | + '([0-9]{2})-' . // months MM- |
|
| 908 | + '([0-9]{2})' . // days DD |
|
| 909 | + 'T' . // separator T |
|
| 910 | + '([0-9]{2}):' . // hours hh: |
|
| 911 | + '([0-9]{2}):' . // minutes mm: |
|
| 912 | + '([0-9]{2})(\.[0-9]*)?' . // seconds ss.ss... |
|
| 913 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
| 914 | 914 | '/'; |
| 915 | 915 | |
| 916 | - if(preg_match($pattern,$datestr,$regs)){ |
|
| 917 | - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]); |
|
| 916 | + if (preg_match($pattern, $datestr, $regs)) { |
|
| 917 | + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]); |
|
| 918 | 918 | } |
| 919 | 919 | return false; |
| 920 | 920 | } else { |
@@ -929,27 +929,27 @@ discard block |
||
| 929 | 929 | * @return mixed Unix timestamp (int) or false |
| 930 | 930 | * @access public |
| 931 | 931 | */ |
| 932 | -function iso8601_to_timestamp($datestr){ |
|
| 933 | - $pattern = '/'. |
|
| 934 | - '([0-9]{4})-'. // centuries & years CCYY- |
|
| 935 | - '([0-9]{2})-'. // months MM- |
|
| 936 | - '([0-9]{2})'. // days DD |
|
| 937 | - 'T'. // separator T |
|
| 938 | - '([0-9]{2}):'. // hours hh: |
|
| 939 | - '([0-9]{2}):'. // minutes mm: |
|
| 940 | - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss... |
|
| 941 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
| 932 | +function iso8601_to_timestamp($datestr) { |
|
| 933 | + $pattern = '/' . |
|
| 934 | + '([0-9]{4})-' . // centuries & years CCYY- |
|
| 935 | + '([0-9]{2})-' . // months MM- |
|
| 936 | + '([0-9]{2})' . // days DD |
|
| 937 | + 'T' . // separator T |
|
| 938 | + '([0-9]{2}):' . // hours hh: |
|
| 939 | + '([0-9]{2}):' . // minutes mm: |
|
| 940 | + '([0-9]{2})(\.[0-9]+)?' . // seconds ss.ss... |
|
| 941 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?' . // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's |
|
| 942 | 942 | '/'; |
| 943 | - if(preg_match($pattern,$datestr,$regs)){ |
|
| 943 | + if (preg_match($pattern, $datestr, $regs)) { |
|
| 944 | 944 | // not utc |
| 945 | - if($regs[8] != 'Z'){ |
|
| 946 | - $op = substr($regs[8],0,1); |
|
| 947 | - $h = substr($regs[8],1,2); |
|
| 948 | - $m = substr($regs[8],strlen($regs[8])-2,2); |
|
| 949 | - if($op == '-'){ |
|
| 945 | + if ($regs[8] != 'Z') { |
|
| 946 | + $op = substr($regs[8], 0, 1); |
|
| 947 | + $h = substr($regs[8], 1, 2); |
|
| 948 | + $m = substr($regs[8], strlen($regs[8]) - 2, 2); |
|
| 949 | + if ($op == '-') { |
|
| 950 | 950 | $regs[4] = $regs[4] + $h; |
| 951 | 951 | $regs[5] = $regs[5] + $m; |
| 952 | - } elseif($op == '+'){ |
|
| 952 | + } elseif ($op == '+') { |
|
| 953 | 953 | $regs[4] = $regs[4] - $h; |
| 954 | 954 | $regs[5] = $regs[5] - $m; |
| 955 | 955 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
| 44 | 44 | * @param string $faultactor only used when msg routed between multiple actors |
| 45 | 45 | * @param string $faultstring human readable error message |
| 46 | - * @param mixed $faultdetail detail, typically a string or array of string |
|
| 46 | + * @param string $faultdetail detail, typically a string or array of string |
|
| 47 | 47 | */ |
| 48 | 48 | public function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
| 49 | 49 | parent::nusoap_base(); |
@@ -38,13 +38,13 @@ discard block |
||
| 38 | 38 | var $faultdetail; |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * constructor |
|
| 42 | - * |
|
| 43 | - * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
|
| 44 | - * @param string $faultactor only used when msg routed between multiple actors |
|
| 45 | - * @param string $faultstring human readable error message |
|
| 46 | - * @param mixed $faultdetail detail, typically a string or array of string |
|
| 47 | - */ |
|
| 41 | + * constructor |
|
| 42 | + * |
|
| 43 | + * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
|
| 44 | + * @param string $faultactor only used when msg routed between multiple actors |
|
| 45 | + * @param string $faultstring human readable error message |
|
| 46 | + * @param mixed $faultdetail detail, typically a string or array of string |
|
| 47 | + */ |
|
| 48 | 48 | public function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
| 49 | 49 | parent::nusoap_base(); |
| 50 | 50 | $this->faultcode = $faultcode; |
@@ -54,11 +54,11 @@ discard block |
||
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | - * serialize a fault |
|
| 58 | - * |
|
| 59 | - * @return string The serialization of the fault instance. |
|
| 60 | - * @access public |
|
| 61 | - */ |
|
| 57 | + * serialize a fault |
|
| 58 | + * |
|
| 59 | + * @return string The serialization of the fault instance. |
|
| 60 | + * @access public |
|
| 61 | + */ |
|
| 62 | 62 | public function serialize(){ |
| 63 | 63 | $ns_string = ''; |
| 64 | 64 | foreach($this->namespaces as $k => $v){ |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param string $faultstring human readable error message |
| 46 | 46 | * @param mixed $faultdetail detail, typically a string or array of string |
| 47 | 47 | */ |
| 48 | - public function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){ |
|
| 48 | + public function nusoap_fault($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') { |
|
| 49 | 49 | parent::nusoap_base(); |
| 50 | 50 | $this->faultcode = $faultcode; |
| 51 | 51 | $this->faultactor = $faultactor; |
@@ -59,22 +59,22 @@ discard block |
||
| 59 | 59 | * @return string The serialization of the fault instance. |
| 60 | 60 | * @access public |
| 61 | 61 | */ |
| 62 | - public function serialize(){ |
|
| 62 | + public function serialize() { |
|
| 63 | 63 | $ns_string = ''; |
| 64 | - foreach($this->namespaces as $k => $v){ |
|
| 64 | + foreach ($this->namespaces as $k => $v) { |
|
| 65 | 65 | $ns_string .= "\n xmlns:$k=\"$v\""; |
| 66 | 66 | } |
| 67 | 67 | $return_msg = |
| 68 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'. |
|
| 69 | - '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n". |
|
| 70 | - '<SOAP-ENV:Body>'. |
|
| 71 | - '<SOAP-ENV:Fault>'. |
|
| 72 | - $this->serialize_val($this->faultcode, 'faultcode'). |
|
| 73 | - $this->serialize_val($this->faultactor, 'faultactor'). |
|
| 74 | - $this->serialize_val($this->faultstring, 'faultstring'). |
|
| 75 | - $this->serialize_val($this->faultdetail, 'detail'). |
|
| 76 | - '</SOAP-ENV:Fault>'. |
|
| 77 | - '</SOAP-ENV:Body>'. |
|
| 68 | + '<?xml version="1.0" encoding="' . $this->soap_defencoding . '"?>' . |
|
| 69 | + '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"' . $ns_string . ">\n" . |
|
| 70 | + '<SOAP-ENV:Body>' . |
|
| 71 | + '<SOAP-ENV:Fault>' . |
|
| 72 | + $this->serialize_val($this->faultcode, 'faultcode') . |
|
| 73 | + $this->serialize_val($this->faultactor, 'faultactor') . |
|
| 74 | + $this->serialize_val($this->faultstring, 'faultstring') . |
|
| 75 | + $this->serialize_val($this->faultdetail, 'detail') . |
|
| 76 | + '</SOAP-ENV:Fault>' . |
|
| 77 | + '</SOAP-ENV:Body>' . |
|
| 78 | 78 | '</SOAP-ENV:Envelope>'; |
| 79 | 79 | return $return_msg; |
| 80 | 80 | } |
@@ -839,7 +839,7 @@ |
||
| 839 | 839 | * |
| 840 | 840 | * @param array $headers The HTTP headers |
| 841 | 841 | * @param string $data unprocessed request data from client |
| 842 | - * @return mixed value of the message, decoded into a PHP type |
|
| 842 | + * @return false|null value of the message, decoded into a PHP type |
|
| 843 | 843 | * @access private |
| 844 | 844 | */ |
| 845 | 845 | public function parseRequest($headers, $data) |
@@ -619,7 +619,7 @@ |
||
| 619 | 619 | $call_arg = array($class, $method); |
| 620 | 620 | } else { |
| 621 | 621 | $this->debug('in invoke_method, calling instance method using call_user_func_array()'); |
| 622 | - $instance = new $class (); |
|
| 622 | + $instance = new $class(); |
|
| 623 | 623 | $call_arg = array(&$instance, $method); |
| 624 | 624 | } |
| 625 | 625 | if (is_array($this->methodparams)) { |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | * |
| 64 | 64 | * @param string $name optional name |
| 65 | 65 | * @param mixed $type optional type name |
| 66 | - * @param mixed $value optional value |
|
| 66 | + * @param integer $value optional value |
|
| 67 | 67 | * @param mixed $element_ns optional namespace of value |
| 68 | 68 | * @param mixed $type_ns optional namespace of type |
| 69 | 69 | * @param mixed $attributes associative array of attributes to add to element serialization |
@@ -59,16 +59,16 @@ discard block |
||
| 59 | 59 | var $attributes; |
| 60 | 60 | |
| 61 | 61 | /** |
| 62 | - * constructor |
|
| 63 | - * |
|
| 64 | - * @param string $name optional name |
|
| 65 | - * @param mixed $type optional type name |
|
| 66 | - * @param mixed $value optional value |
|
| 67 | - * @param mixed $element_ns optional namespace of value |
|
| 68 | - * @param mixed $type_ns optional namespace of type |
|
| 69 | - * @param mixed $attributes associative array of attributes to add to element serialization |
|
| 70 | - * @access public |
|
| 71 | - */ |
|
| 62 | + * constructor |
|
| 63 | + * |
|
| 64 | + * @param string $name optional name |
|
| 65 | + * @param mixed $type optional type name |
|
| 66 | + * @param mixed $value optional value |
|
| 67 | + * @param mixed $element_ns optional namespace of value |
|
| 68 | + * @param mixed $type_ns optional namespace of type |
|
| 69 | + * @param mixed $attributes associative array of attributes to add to element serialization |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | 72 | public function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) { |
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->name = $name; |
@@ -77,25 +77,25 @@ discard block |
||
| 77 | 77 | $this->element_ns = $element_ns; |
| 78 | 78 | $this->type_ns = $type_ns; |
| 79 | 79 | $this->attributes = $attributes; |
| 80 | - } |
|
| 80 | + } |
|
| 81 | 81 | |
| 82 | 82 | /** |
| 83 | - * return serialized value |
|
| 84 | - * |
|
| 85 | - * @param string $use The WSDL use value (encoded|literal) |
|
| 86 | - * @return string XML data |
|
| 87 | - * @access public |
|
| 88 | - */ |
|
| 83 | + * return serialized value |
|
| 84 | + * |
|
| 85 | + * @param string $use The WSDL use value (encoded|literal) |
|
| 86 | + * @return string XML data |
|
| 87 | + * @access public |
|
| 88 | + */ |
|
| 89 | 89 | public function serialize($use='encoded') { |
| 90 | 90 | return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
| 91 | - } |
|
| 91 | + } |
|
| 92 | 92 | |
| 93 | 93 | /** |
| 94 | - * decodes a soapval object into a PHP native type |
|
| 95 | - * |
|
| 96 | - * @return mixed |
|
| 97 | - * @access public |
|
| 98 | - */ |
|
| 94 | + * decodes a soapval object into a PHP native type |
|
| 95 | + * |
|
| 96 | + * @return mixed |
|
| 97 | + * @access public |
|
| 98 | + */ |
|
| 99 | 99 | public function decode(){ |
| 100 | 100 | return $this->value; |
| 101 | 101 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param mixed $attributes associative array of attributes to add to element serialization |
| 70 | 70 | * @access public |
| 71 | 71 | */ |
| 72 | - public function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) { |
|
| 72 | + public function soapval($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false) { |
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->name = $name; |
| 75 | 75 | $this->type = $type; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return string XML data |
| 87 | 87 | * @access public |
| 88 | 88 | */ |
| 89 | - public function serialize($use='encoded') { |
|
| 89 | + public function serialize($use = 'encoded') { |
|
| 90 | 90 | return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return mixed |
| 97 | 97 | * @access public |
| 98 | 98 | */ |
| 99 | - public function decode(){ |
|
| 99 | + public function decode() { |
|
| 100 | 100 | return $this->value; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -88,6 +88,7 @@ discard block |
||
| 88 | 88 | * fetches the WSDL document and parses it |
| 89 | 89 | * |
| 90 | 90 | * @access public |
| 91 | + * @param string $wsdl |
|
| 91 | 92 | */ |
| 92 | 93 | public function fetchWSDL($wsdl) { |
| 93 | 94 | $this->debug("parse and process WSDL path=$wsdl"); |
@@ -882,7 +883,7 @@ discard block |
||
| 882 | 883 | /** |
| 883 | 884 | * serialize the parsed wsdl |
| 884 | 885 | * |
| 885 | - * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 886 | + * @param integer $debug whether to put debug=1 in endpoint URL |
|
| 886 | 887 | * @return string serialization of WSDL |
| 887 | 888 | * @access public |
| 888 | 889 | */ |
@@ -1105,7 +1106,7 @@ discard block |
||
| 1105 | 1106 | * @param string $direction (input|output) |
| 1106 | 1107 | * @param mixed $parameters parameter value(s) |
| 1107 | 1108 | * @param string $bindingType (soap|soap12) |
| 1108 | - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1109 | + * @return false|string parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1109 | 1110 | * @access public |
| 1110 | 1111 | */ |
| 1111 | 1112 | public function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') { |
@@ -1205,7 +1206,7 @@ discard block |
||
| 1205 | 1206 | * @param string $operation operation name |
| 1206 | 1207 | * @param string $direction (input|output) |
| 1207 | 1208 | * @param mixed $parameters parameter value(s) |
| 1208 | - * @return mixed parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1209 | + * @return false|string parameters serialized as XML or false on error (e.g. operation not found) |
|
| 1209 | 1210 | * @access public |
| 1210 | 1211 | * @deprecated |
| 1211 | 1212 | */ |
@@ -78,8 +78,9 @@ |
||
| 78 | 78 | $this->proxypassword = $proxypassword; |
| 79 | 79 | $this->timeout = $timeout; |
| 80 | 80 | $this->response_timeout = $response_timeout; |
| 81 | - if (is_array($curl_options)) |
|
| 82 | - $this->curl_options = $curl_options; |
|
| 81 | + if (is_array($curl_options)) { |
|
| 82 | + $this->curl_options = $curl_options; |
|
| 83 | + } |
|
| 83 | 84 | $this->use_curl = $use_curl; |
| 84 | 85 | $this->fetchWSDL($wsdl); |
| 85 | 86 | } |
@@ -47,13 +47,13 @@ discard block |
||
| 47 | 47 | public $proxypassword = ''; |
| 48 | 48 | public $timeout = 0; |
| 49 | 49 | public $response_timeout = 30; |
| 50 | - public $curl_options = array(); // User-specified cURL options |
|
| 51 | - public $use_curl = false; // whether to always try to use cURL |
|
| 50 | + public $curl_options = array(); // User-specified cURL options |
|
| 51 | + public $use_curl = false; // whether to always try to use cURL |
|
| 52 | 52 | // for HTTP authentication |
| 53 | - public $username = ''; // Username for HTTP authentication |
|
| 54 | - public $password = ''; // Password for HTTP authentication |
|
| 55 | - public $authtype = ''; // Type of HTTP authentication |
|
| 56 | - public $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 53 | + public $username = ''; // Username for HTTP authentication |
|
| 54 | + public $password = ''; // Password for HTTP authentication |
|
| 55 | + public $authtype = ''; // Type of HTTP authentication |
|
| 56 | + public $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * constructor |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param boolean $use_curl try to use cURL |
| 70 | 70 | * @access public |
| 71 | 71 | */ |
| 72 | - public function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ |
|
| 72 | + public function wsdl($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) { |
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); |
| 75 | 75 | $this->proxyhost = $proxyhost; |
@@ -103,10 +103,10 @@ discard block |
||
| 103 | 103 | // Schema imports |
| 104 | 104 | foreach ($this->schemas as $ns => $list) { |
| 105 | 105 | foreach ($list as $xs) { |
| 106 | - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 106 | + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 107 | 107 | foreach ($xs->imports as $ns2 => $list2) { |
| 108 | 108 | for ($ii = 0; $ii < count($list2); $ii++) { |
| 109 | - if (! $list2[$ii]['loaded']) { |
|
| 109 | + if (!$list2[$ii]['loaded']) { |
|
| 110 | 110 | /* |
| 111 | 111 | * Substituted with line below |
| 112 | 112 | * because of error "Warning: attempt to modify property of non-object" |
@@ -117,10 +117,10 @@ discard block |
||
| 117 | 117 | if ($url != '') { |
| 118 | 118 | $urlparts = parse_url($url); |
| 119 | 119 | if (!isset($urlparts['host'])) { |
| 120 | - $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') . |
|
| 121 | - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 120 | + $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . |
|
| 121 | + substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path']; |
|
| 122 | 122 | } |
| 123 | - if (! in_array($url, $imported_urls)) { |
|
| 123 | + if (!in_array($url, $imported_urls)) { |
|
| 124 | 124 | $this->parseWSDL($url); |
| 125 | 125 | $imported++; |
| 126 | 126 | $imported_urls[] = $url; |
@@ -134,19 +134,19 @@ discard block |
||
| 134 | 134 | } |
| 135 | 135 | } |
| 136 | 136 | // WSDL imports |
| 137 | - $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 137 | + $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
|
| 138 | 138 | foreach ($this->import as $ns => $list) { |
| 139 | 139 | for ($ii = 0; $ii < count($list); $ii++) { |
| 140 | - if (! $list[$ii]['loaded']) { |
|
| 140 | + if (!$list[$ii]['loaded']) { |
|
| 141 | 141 | $this->import[$ns][$ii]['loaded'] = true; |
| 142 | 142 | $url = $list[$ii]['location']; |
| 143 | 143 | if ($url != '') { |
| 144 | 144 | $urlparts = parse_url($url); |
| 145 | 145 | if (!isset($urlparts['host'])) { |
| 146 | 146 | $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') . |
| 147 | - substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
|
| 147 | + substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1) . $urlparts['path']; |
|
| 148 | 148 | } |
| 149 | - if (! in_array($url, $imported_urls)) { |
|
| 149 | + if (!in_array($url, $imported_urls)) { |
|
| 150 | 150 | $this->parseWSDL($url); |
| 151 | 151 | $imported++; |
| 152 | 152 | $imported_urls[] = $url; |
@@ -159,30 +159,28 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | // add new data to operation data |
| 162 | - foreach($this->bindings as $binding => $bindingData) { |
|
| 162 | + foreach ($this->bindings as $binding => $bindingData) { |
|
| 163 | 163 | if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { |
| 164 | - foreach($bindingData['operations'] as $operation => $data) { |
|
| 164 | + foreach ($bindingData['operations'] as $operation => $data) { |
|
| 165 | 165 | $this->debug('post-parse data gathering for ' . $operation); |
| 166 | 166 | $this->bindings[$binding]['operations'][$operation]['input'] = |
| 167 | 167 | isset($this->bindings[$binding]['operations'][$operation]['input']) ? |
| 168 | - array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : |
|
| 169 | - $this->portTypes[ $bindingData['portType'] ][$operation]['input']; |
|
| 168 | + array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : $this->portTypes[$bindingData['portType']][$operation]['input']; |
|
| 170 | 169 | $this->bindings[$binding]['operations'][$operation]['output'] = |
| 171 | 170 | isset($this->bindings[$binding]['operations'][$operation]['output']) ? |
| 172 | - array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : |
|
| 173 | - $this->portTypes[ $bindingData['portType'] ][$operation]['output']; |
|
| 174 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){ |
|
| 175 | - $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; |
|
| 171 | + array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : $this->portTypes[$bindingData['portType']][$operation]['output']; |
|
| 172 | + if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) { |
|
| 173 | + $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']]; |
|
| 176 | 174 | } |
| 177 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){ |
|
| 178 | - $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 175 | + if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) { |
|
| 176 | + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']]; |
|
| 179 | 177 | } |
| 180 | 178 | // Set operation style if necessary, but do not override one already provided |
| 181 | 179 | if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) { |
| 182 | 180 | $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
| 183 | 181 | } |
| 184 | 182 | $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
| 185 | - $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; |
|
| 183 | + $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : ''; |
|
| 186 | 184 | $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; |
| 187 | 185 | } |
| 188 | 186 | } |
@@ -213,8 +211,8 @@ discard block |
||
| 213 | 211 | $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
| 214 | 212 | $tr->request_method = 'GET'; |
| 215 | 213 | $tr->useSOAPAction = false; |
| 216 | - if($this->proxyhost && $this->proxyport){ |
|
| 217 | - $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 214 | + if ($this->proxyhost && $this->proxyport) { |
|
| 215 | + $tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); |
|
| 218 | 216 | } |
| 219 | 217 | if ($this->authtype != '') { |
| 220 | 218 | $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
@@ -223,8 +221,8 @@ discard block |
||
| 223 | 221 | $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout); |
| 224 | 222 | $this->appendDebug($tr->getDebug()); |
| 225 | 223 | // catch errors |
| 226 | - if($err = $tr->getError() ){ |
|
| 227 | - $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; |
|
| 224 | + if ($err = $tr->getError()) { |
|
| 225 | + $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: ' . $err; |
|
| 228 | 226 | $this->debug($errstr); |
| 229 | 227 | $this->setError($errstr); |
| 230 | 228 | unset($tr); |
@@ -283,7 +281,7 @@ discard block |
||
| 283 | 281 | xml_parser_free($this->parser); |
| 284 | 282 | $this->debug('Parsing WSDL done'); |
| 285 | 283 | // catch wsdl parse errors |
| 286 | - if($this->getError()){ |
|
| 284 | + if ($this->getError()) { |
|
| 287 | 285 | return false; |
| 288 | 286 | } |
| 289 | 287 | return true; |
@@ -320,8 +318,8 @@ discard block |
||
| 320 | 318 | // process attributes |
| 321 | 319 | if (count($attrs) > 0) { |
| 322 | 320 | // register namespace declarations |
| 323 | - foreach($attrs as $k => $v) { |
|
| 324 | - if (preg_match('/^xmlns/',$k)) { |
|
| 321 | + foreach ($attrs as $k => $v) { |
|
| 322 | + if (preg_match('/^xmlns/', $k)) { |
|
| 325 | 323 | if ($ns_prefix = substr(strrchr($k, ':'), 1)) { |
| 326 | 324 | $this->namespaces[$ns_prefix] = $v; |
| 327 | 325 | } else { |
@@ -334,7 +332,7 @@ discard block |
||
| 334 | 332 | } |
| 335 | 333 | } |
| 336 | 334 | // expand each attribute prefix to its namespace |
| 337 | - foreach($attrs as $k => $v) { |
|
| 335 | + foreach ($attrs as $k => $v) { |
|
| 338 | 336 | $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
| 339 | 337 | if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { |
| 340 | 338 | $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
@@ -441,8 +439,8 @@ discard block |
||
| 441 | 439 | case 'address': |
| 442 | 440 | $this->ports[$this->currentPort]['location'] = $attrs['location']; |
| 443 | 441 | $this->ports[$this->currentPort]['bindingType'] = $namespace; |
| 444 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 445 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 442 | + $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace; |
|
| 443 | + $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location']; |
|
| 446 | 444 | break; |
| 447 | 445 | } |
| 448 | 446 | break; |
@@ -452,13 +450,13 @@ discard block |
||
| 452 | 450 | case 'import': |
| 453 | 451 | if (isset($attrs['location'])) { |
| 454 | 452 | $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); |
| 455 | - $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')'); |
|
| 453 | + $this->debug('parsing import ' . $attrs['namespace'] . ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]) . ')'); |
|
| 456 | 454 | } else { |
| 457 | 455 | $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
| 458 | - if (! $this->getPrefixFromNamespace($attrs['namespace'])) { |
|
| 459 | - $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
|
| 456 | + if (!$this->getPrefixFromNamespace($attrs['namespace'])) { |
|
| 457 | + $this->namespaces['ns' . (count($this->namespaces) + 1)] = $attrs['namespace']; |
|
| 460 | 458 | } |
| 461 | - $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')'); |
|
| 459 | + $this->debug('parsing import ' . $attrs['namespace'] . ' - [no location] (' . count($this->import[$attrs['namespace']]) . ')'); |
|
| 462 | 460 | } |
| 463 | 461 | break; |
| 464 | 462 | //wait for schema |
@@ -509,7 +507,7 @@ discard block |
||
| 509 | 507 | * @param string $name element name |
| 510 | 508 | * @access private |
| 511 | 509 | */ |
| 512 | - public function end_element($parser, $name){ |
|
| 510 | + public function end_element($parser, $name) { |
|
| 513 | 511 | // unset schema status |
| 514 | 512 | if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { |
| 515 | 513 | $this->status = ""; |
@@ -592,15 +590,15 @@ discard block |
||
| 592 | 590 | } |
| 593 | 591 | $this->debug("getOperations for port '$portName' bindingType $bindingType"); |
| 594 | 592 | // loop thru ports |
| 595 | - foreach($this->ports as $port => $portData) { |
|
| 593 | + foreach ($this->ports as $port => $portData) { |
|
| 596 | 594 | $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']); |
| 597 | 595 | if ($portName == '' || $port == $portName) { |
| 598 | 596 | // binding type of port matches parameter |
| 599 | 597 | if ($portData['bindingType'] == $bindingType) { |
| 600 | 598 | $this->debug("getOperations found port $port bindingType $bindingType"); |
| 601 | 599 | // merge bindings |
| 602 | - if (isset($this->bindings[ $portData['binding'] ]['operations'])) { |
|
| 603 | - $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']); |
|
| 600 | + if (isset($this->bindings[$portData['binding']]['operations'])) { |
|
| 601 | + $ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']); |
|
| 604 | 602 | } |
| 605 | 603 | } |
| 606 | 604 | } |
@@ -627,15 +625,15 @@ discard block |
||
| 627 | 625 | $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
| 628 | 626 | } |
| 629 | 627 | // loop thru ports |
| 630 | - foreach($this->ports as $port => $portData) { |
|
| 628 | + foreach ($this->ports as $port => $portData) { |
|
| 631 | 629 | // binding type of port matches parameter |
| 632 | 630 | if ($portData['bindingType'] == $bindingType) { |
| 633 | 631 | // get binding |
| 634 | 632 | //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { |
| 635 | - foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) { |
|
| 633 | + foreach (array_keys($this->bindings[$portData['binding']]['operations']) as $bOperation) { |
|
| 636 | 634 | // note that we could/should also check the namespace here |
| 637 | 635 | if ($operation == $bOperation) { |
| 638 | - $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; |
|
| 636 | + $opData = $this->bindings[$portData['binding']]['operations'][$operation]; |
|
| 639 | 637 | return $opData; |
| 640 | 638 | } |
| 641 | 639 | } |
@@ -658,11 +656,11 @@ discard block |
||
| 658 | 656 | $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/'; |
| 659 | 657 | } |
| 660 | 658 | // loop thru ports |
| 661 | - foreach($this->ports as $port => $portData) { |
|
| 659 | + foreach ($this->ports as $port => $portData) { |
|
| 662 | 660 | // binding type of port matches parameter |
| 663 | 661 | if ($portData['bindingType'] == $bindingType) { |
| 664 | 662 | // loop through operations for the binding |
| 665 | - foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { |
|
| 663 | + foreach ($this->bindings[$portData['binding']]['operations'] as $bOperation => $opData) { |
|
| 666 | 664 | if ($opData['soapAction'] == $soapAction) { |
| 667 | 665 | return $opData; |
| 668 | 666 | } |
@@ -691,7 +689,7 @@ discard block |
||
| 691 | 689 | */ |
| 692 | 690 | public function getTypeDef($type, $ns) { |
| 693 | 691 | $this->debug("in getTypeDef: type=$type, ns=$ns"); |
| 694 | - if ((! $ns) && isset($this->namespaces['tns'])) { |
|
| 692 | + if ((!$ns) && isset($this->namespaces['tns'])) { |
|
| 695 | 693 | $ns = $this->namespaces['tns']; |
| 696 | 694 | $this->debug("in getTypeDef: type namespace forced to $ns"); |
| 697 | 695 | } |
@@ -749,7 +747,7 @@ discard block |
||
| 749 | 747 | * |
| 750 | 748 | * @access private |
| 751 | 749 | */ |
| 752 | - public function webDescription(){ |
|
| 750 | + public function webDescription() { |
|
| 753 | 751 | global $HTTP_SERVER_VARS; |
| 754 | 752 | |
| 755 | 753 | if (isset($_SERVER)) { |
@@ -761,7 +759,7 @@ discard block |
||
| 761 | 759 | } |
| 762 | 760 | |
| 763 | 761 | $b = ' |
| 764 | - <html><head><title>NuSOAP: '.$this->serviceName.'</title> |
|
| 762 | + <html><head><title>NuSOAP: '.$this->serviceName . '</title> |
|
| 765 | 763 | <style type="text/css"> |
| 766 | 764 | body { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; } |
| 767 | 765 | p { font-family: arial; color: #000000; margin-top: 0px; margin-bottom: 12px; } |
@@ -838,24 +836,24 @@ discard block |
||
| 838 | 836 | <body> |
| 839 | 837 | <div class=content> |
| 840 | 838 | <br><br> |
| 841 | - <div class=title>'.$this->serviceName.'</div> |
|
| 839 | + <div class=title>'.$this->serviceName . '</div> |
|
| 842 | 840 | <div class=nav> |
| 843 | - <p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service. |
|
| 841 | + <p>View the <a href="'.$PHP_SELF . '?wsdl">WSDL</a> for the service. |
|
| 844 | 842 | Click on an operation name to view it's details.</p> |
| 845 | 843 | <ul>'; |
| 846 | - foreach($this->getOperations() as $op => $data){ |
|
| 844 | + foreach ($this->getOperations() as $op => $data) { |
|
| 847 | 845 | $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>"; |
| 848 | 846 | // create hidden div |
| 849 | 847 | $b .= "<div id='$op' class='hidden'> |
| 850 | 848 | <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>"; |
| 851 | - foreach($data as $donnie => $marie){ // loop through opdata |
|
| 852 | - if($donnie == 'input' || $donnie == 'output'){ // show input/output data |
|
| 853 | - $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 854 | - foreach($marie as $captain => $tenille){ // loop through data |
|
| 855 | - if($captain == 'parts'){ // loop thru parts |
|
| 849 | + foreach ($data as $donnie => $marie) { // loop through opdata |
|
| 850 | + if ($donnie == 'input' || $donnie == 'output') { // show input/output data |
|
| 851 | + $b .= "<font color='white'>" . ucfirst($donnie) . ':</font><br>'; |
|
| 852 | + foreach ($marie as $captain => $tenille) { // loop through data |
|
| 853 | + if ($captain == 'parts') { // loop thru parts |
|
| 856 | 854 | $b .= " $captain:<br>"; |
| 857 | 855 | //if(is_array($tenille)){ |
| 858 | - foreach($tenille as $joanie => $chachi){ |
|
| 856 | + foreach ($tenille as $joanie => $chachi) { |
|
| 859 | 857 | $b .= " $joanie: $chachi<br>"; |
| 860 | 858 | } |
| 861 | 859 | //} |
@@ -864,7 +862,7 @@ discard block |
||
| 864 | 862 | } |
| 865 | 863 | } |
| 866 | 864 | } else { |
| 867 | - $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 865 | + $b .= "<font color='white'>" . ucfirst($donnie) . ":</font> $marie<br>"; |
|
| 868 | 866 | } |
| 869 | 867 | } |
| 870 | 868 | $b .= '</div>'; |
@@ -887,7 +885,7 @@ discard block |
||
| 887 | 885 | { |
| 888 | 886 | $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; |
| 889 | 887 | $xml .= "\n<definitions"; |
| 890 | - foreach($this->namespaces as $k => $v) { |
|
| 888 | + foreach ($this->namespaces as $k => $v) { |
|
| 891 | 889 | $xml .= " xmlns:$k=\"$v\""; |
| 892 | 890 | } |
| 893 | 891 | // 10.9.02 - add poulter fix for wsdl and tns declarations |
@@ -900,7 +898,7 @@ discard block |
||
| 900 | 898 | $xml .= '>'; |
| 901 | 899 | // imports |
| 902 | 900 | if (sizeof($this->import) > 0) { |
| 903 | - foreach($this->import as $ns => $list) { |
|
| 901 | + foreach ($this->import as $ns => $list) { |
|
| 904 | 902 | foreach ($list as $ii) { |
| 905 | 903 | if ($ii['location'] != '') { |
| 906 | 904 | $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />'; |
@@ -911,7 +909,7 @@ discard block |
||
| 911 | 909 | } |
| 912 | 910 | } |
| 913 | 911 | // types |
| 914 | - if (count($this->schemas)>=1) { |
|
| 912 | + if (count($this->schemas) >= 1) { |
|
| 915 | 913 | $xml .= "\n<types>\n"; |
| 916 | 914 | foreach ($this->schemas as $ns => $list) { |
| 917 | 915 | foreach ($list as $xs) { |
@@ -922,10 +920,10 @@ discard block |
||
| 922 | 920 | } |
| 923 | 921 | // messages |
| 924 | 922 | if (count($this->messages) >= 1) { |
| 925 | - foreach($this->messages as $msgName => $msgParts) { |
|
| 923 | + foreach ($this->messages as $msgName => $msgParts) { |
|
| 926 | 924 | $xml .= "\n<message name=\"" . $msgName . '">'; |
| 927 | - if(is_array($msgParts)){ |
|
| 928 | - foreach($msgParts as $partName => $partType) { |
|
| 925 | + if (is_array($msgParts)) { |
|
| 926 | + foreach ($msgParts as $partName => $partType) { |
|
| 929 | 927 | // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>'; |
| 930 | 928 | if (strpos($partType, ':')) { |
| 931 | 929 | $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
@@ -933,7 +931,7 @@ discard block |
||
| 933 | 931 | // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
| 934 | 932 | $typePrefix = 'xsd'; |
| 935 | 933 | } else { |
| 936 | - foreach($this->typemap as $ns => $types) { |
|
| 934 | + foreach ($this->typemap as $ns => $types) { |
|
| 937 | 935 | if (isset($types[$partType])) { |
| 938 | 936 | $typePrefix = $this->getPrefixFromNamespace($ns); |
| 939 | 937 | } |
@@ -963,13 +961,13 @@ discard block |
||
| 963 | 961 | if (count($this->bindings) >= 1) { |
| 964 | 962 | $binding_xml = ''; |
| 965 | 963 | $portType_xml = ''; |
| 966 | - foreach($this->bindings as $bindingName => $attrs) { |
|
| 964 | + foreach ($this->bindings as $bindingName => $attrs) { |
|
| 967 | 965 | $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">'; |
| 968 | 966 | $binding_xml .= "\n" . ' <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>'; |
| 969 | 967 | $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">'; |
| 970 | - foreach($attrs['operations'] as $opName => $opParts) { |
|
| 968 | + foreach ($attrs['operations'] as $opName => $opParts) { |
|
| 971 | 969 | $binding_xml .= "\n" . ' <operation name="' . $opName . '">'; |
| 972 | - $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>'; |
|
| 970 | + $binding_xml .= "\n" . ' <soap:operation soapAction="' . $opParts['soapAction'] . '" style="' . $opParts['style'] . '"/>'; |
|
| 973 | 971 | if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') { |
| 974 | 972 | $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"'; |
| 975 | 973 | } else { |
@@ -988,7 +986,7 @@ discard block |
||
| 988 | 986 | $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
| 989 | 987 | } |
| 990 | 988 | $portType_xml .= '>'; |
| 991 | - if(isset($opParts['documentation']) && $opParts['documentation'] != '') { |
|
| 989 | + if (isset($opParts['documentation']) && $opParts['documentation'] != '') { |
|
| 992 | 990 | $portType_xml .= "\n" . ' <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>'; |
| 993 | 991 | } |
| 994 | 992 | $portType_xml .= "\n" . ' <input message="tns:' . $opParts['input']['message'] . '"/>'; |
@@ -1003,7 +1001,7 @@ discard block |
||
| 1003 | 1001 | // services |
| 1004 | 1002 | $xml .= "\n<service name=\"" . $this->serviceName . '">'; |
| 1005 | 1003 | if (count($this->ports) >= 1) { |
| 1006 | - foreach($this->ports as $pName => $attrs) { |
|
| 1004 | + foreach ($this->ports as $pName => $attrs) { |
|
| 1007 | 1005 | $xml .= "\n" . ' <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">'; |
| 1008 | 1006 | $xml .= "\n" . ' <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>'; |
| 1009 | 1007 | $xml .= "\n" . ' </port>'; |
@@ -1118,7 +1116,7 @@ discard block |
||
| 1118 | 1116 | |
| 1119 | 1117 | // Get encoding style for output and set to current |
| 1120 | 1118 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
| 1121 | - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) { |
|
| 1119 | + if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) { |
|
| 1122 | 1120 | $encodingStyle = $opData['output']['encodingStyle']; |
| 1123 | 1121 | $enc_style = $encodingStyle; |
| 1124 | 1122 | } |
@@ -1213,7 +1211,7 @@ discard block |
||
| 1213 | 1211 | |
| 1214 | 1212 | // Get encoding style for output and set to current |
| 1215 | 1213 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
| 1216 | - if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) { |
|
| 1214 | + if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) { |
|
| 1217 | 1215 | $encodingStyle = $opData['output']['encodingStyle']; |
| 1218 | 1216 | $enc_style = $encodingStyle; |
| 1219 | 1217 | } |
@@ -1228,10 +1226,10 @@ discard block |
||
| 1228 | 1226 | if (is_array($parameters)) { |
| 1229 | 1227 | $parametersArrayType = $this->isArraySimpleOrStruct($parameters); |
| 1230 | 1228 | $this->debug('have ' . $parametersArrayType . ' parameters'); |
| 1231 | - foreach($opData[$direction]['parts'] as $name => $type) { |
|
| 1232 | - $this->debug('serializing part "'.$name.'" of type "'.$type.'"'); |
|
| 1229 | + foreach ($opData[$direction]['parts'] as $name => $type) { |
|
| 1230 | + $this->debug('serializing part "' . $name . '" of type "' . $type . '"'); |
|
| 1233 | 1231 | // Track encoding style |
| 1234 | - if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) { |
|
| 1232 | + if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) { |
|
| 1235 | 1233 | $encodingStyle = $opData[$direction]['encodingStyle']; |
| 1236 | 1234 | $enc_style = $encodingStyle; |
| 1237 | 1235 | } else { |
@@ -1271,11 +1269,11 @@ discard block |
||
| 1271 | 1269 | * @return string value serialized as an XML string |
| 1272 | 1270 | * @access private |
| 1273 | 1271 | */ |
| 1274 | - public function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false) |
|
| 1272 | + public function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false) |
|
| 1275 | 1273 | { |
| 1276 | 1274 | $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified")); |
| 1277 | 1275 | $this->appendDebug("value=" . $this->varDump($value)); |
| 1278 | - if($use == 'encoded' && $encodingStyle) { |
|
| 1276 | + if ($use == 'encoded' && $encodingStyle) { |
|
| 1279 | 1277 | $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"'; |
| 1280 | 1278 | } |
| 1281 | 1279 | |
@@ -1319,7 +1317,7 @@ discard block |
||
| 1319 | 1317 | $this->debug("in serializeType: expanded prefixed type: $uqType, $ns"); |
| 1320 | 1318 | } |
| 1321 | 1319 | |
| 1322 | - if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){ |
|
| 1320 | + if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') { |
|
| 1323 | 1321 | $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type'); |
| 1324 | 1322 | if ($unqualified && $use == 'literal') { |
| 1325 | 1323 | $elementNS = " xmlns=\"\""; |
@@ -1340,7 +1338,7 @@ discard block |
||
| 1340 | 1338 | return $this->serialize_val($value, $name, false, false, false, false, $use); |
| 1341 | 1339 | } |
| 1342 | 1340 | if ($uqType == 'boolean') { |
| 1343 | - if ((is_string($value) && $value == 'false') || (! $value)) { |
|
| 1341 | + if ((is_string($value) && $value == 'false') || (!$value)) { |
|
| 1344 | 1342 | $value = 'false'; |
| 1345 | 1343 | } else { |
| 1346 | 1344 | $value = 'true'; |
@@ -1370,7 +1368,7 @@ discard block |
||
| 1370 | 1368 | $this->debug('in serializeType: appears to be Apache SOAP type'); |
| 1371 | 1369 | if ($uqType == 'Map') { |
| 1372 | 1370 | $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap'); |
| 1373 | - if (! $tt_prefix) { |
|
| 1371 | + if (!$tt_prefix) { |
|
| 1374 | 1372 | $this->debug('in serializeType: Add namespace for Apache SOAP type'); |
| 1375 | 1373 | $tt_prefix = 'ns' . rand(1000, 9999); |
| 1376 | 1374 | $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap'; |
@@ -1378,11 +1376,11 @@ discard block |
||
| 1378 | 1376 | $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap'); |
| 1379 | 1377 | } |
| 1380 | 1378 | $contents = ''; |
| 1381 | - foreach($value as $k => $v) { |
|
| 1379 | + foreach ($value as $k => $v) { |
|
| 1382 | 1380 | $this->debug("serializing map element: key $k, value $v"); |
| 1383 | 1381 | $contents .= '<item>'; |
| 1384 | - $contents .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 1385 | - $contents .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 1382 | + $contents .= $this->serialize_val($k, 'key', false, false, false, false, $use); |
|
| 1383 | + $contents .= $this->serialize_val($v, 'value', false, false, false, false, $use); |
|
| 1386 | 1384 | $contents .= '</item>'; |
| 1387 | 1385 | } |
| 1388 | 1386 | if ($use == 'literal') { |
@@ -1404,7 +1402,7 @@ discard block |
||
| 1404 | 1402 | $ns = ''; |
| 1405 | 1403 | $uqType = $type; |
| 1406 | 1404 | } |
| 1407 | - if(!$typeDef = $this->getTypeDef($uqType, $ns)){ |
|
| 1405 | + if (!$typeDef = $this->getTypeDef($uqType, $ns)) { |
|
| 1408 | 1406 | $this->setError("$type ($uqType) is not a supported type."); |
| 1409 | 1407 | $this->debug("in serializeType: $type ($uqType) is not a supported type."); |
| 1410 | 1408 | return false; |
@@ -1421,7 +1419,7 @@ discard block |
||
| 1421 | 1419 | return false; |
| 1422 | 1420 | } |
| 1423 | 1421 | $phpType = $typeDef['phpType']; |
| 1424 | - $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') ); |
|
| 1422 | + $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '')); |
|
| 1425 | 1423 | // if php type == struct, map value to the <all> element names |
| 1426 | 1424 | if ($phpType == 'struct') { |
| 1427 | 1425 | if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') { |
@@ -1501,14 +1499,14 @@ discard block |
||
| 1501 | 1499 | ':arrayType="' . |
| 1502 | 1500 | $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) . |
| 1503 | 1501 | ':' . |
| 1504 | - $this->getLocalPart($typeDef['arrayType'])."[0]\"/>"; |
|
| 1502 | + $this->getLocalPart($typeDef['arrayType']) . "[0]\"/>"; |
|
| 1505 | 1503 | } |
| 1506 | 1504 | $this->debug("in serializeType: returning: $xml"); |
| 1507 | 1505 | return $xml; |
| 1508 | 1506 | } |
| 1509 | 1507 | if (isset($typeDef['multidimensional'])) { |
| 1510 | 1508 | $nv = array(); |
| 1511 | - foreach($value as $v) { |
|
| 1509 | + foreach ($value as $v) { |
|
| 1512 | 1510 | $cols = ',' . sizeof($v); |
| 1513 | 1511 | $nv = array_merge($nv, $v); |
| 1514 | 1512 | } |
@@ -1519,10 +1517,10 @@ discard block |
||
| 1519 | 1517 | if (is_array($value) && sizeof($value) >= 1) { |
| 1520 | 1518 | $rows = sizeof($value); |
| 1521 | 1519 | $contents = ''; |
| 1522 | - foreach($value as $k => $v) { |
|
| 1520 | + foreach ($value as $k => $v) { |
|
| 1523 | 1521 | $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); |
| 1524 | 1522 | //if (strpos($typeDef['arrayType'], ':') ) { |
| 1525 | - if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) { |
|
| 1523 | + if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) { |
|
| 1526 | 1524 | $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); |
| 1527 | 1525 | } else { |
| 1528 | 1526 | $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
@@ -1537,11 +1535,11 @@ discard block |
||
| 1537 | 1535 | .$contents |
| 1538 | 1536 | ."</$name>"; |
| 1539 | 1537 | } else { |
| 1540 | - $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '. |
|
| 1538 | + $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') . ':Array" ' . |
|
| 1541 | 1539 | $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') |
| 1542 | 1540 | .':arrayType="' |
| 1543 | 1541 | .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) |
| 1544 | - .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">" |
|
| 1542 | + .":" . $this->getLocalPart($typeDef['arrayType']) . "[$rows$cols]\">" |
|
| 1545 | 1543 | .$contents |
| 1546 | 1544 | ."</$name>"; |
| 1547 | 1545 | } |
@@ -1621,7 +1619,7 @@ discard block |
||
| 1621 | 1619 | $this->debug("no value provided for attribute $aName"); |
| 1622 | 1620 | } |
| 1623 | 1621 | if ($xname) { |
| 1624 | - $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; |
|
| 1622 | + $xml .= " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\""; |
|
| 1625 | 1623 | } |
| 1626 | 1624 | } |
| 1627 | 1625 | } else { |
@@ -1642,7 +1640,7 @@ discard block |
||
| 1642 | 1640 | * @return string value serialized as an XML string |
| 1643 | 1641 | * @access private |
| 1644 | 1642 | */ |
| 1645 | - public function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) { |
|
| 1643 | + public function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) { |
|
| 1646 | 1644 | $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType"); |
| 1647 | 1645 | $xml = ''; |
| 1648 | 1646 | if (isset($typeDef['extensionBase'])) { |
@@ -1669,7 +1667,7 @@ discard block |
||
| 1669 | 1667 | $xvalue = array(); |
| 1670 | 1668 | } |
| 1671 | 1669 | // toggle whether all elements are present - ideally should validate against schema |
| 1672 | - if (count($typeDef['elements']) != count($xvalue)){ |
|
| 1670 | + if (count($typeDef['elements']) != count($xvalue)) { |
|
| 1673 | 1671 | $optionals = true; |
| 1674 | 1672 | } |
| 1675 | 1673 | foreach ($typeDef['elements'] as $eName => $attrs) { |
@@ -1682,8 +1680,8 @@ discard block |
||
| 1682 | 1680 | // if user took advantage of a minOccurs=0, then only serialize named parameters |
| 1683 | 1681 | if (isset($optionals) |
| 1684 | 1682 | && (!isset($xvalue[$eName])) |
| 1685 | - && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
|
| 1686 | - ){ |
|
| 1683 | + && ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
|
| 1684 | + ) { |
|
| 1687 | 1685 | if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') { |
| 1688 | 1686 | $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']); |
| 1689 | 1687 | } |
@@ -1748,15 +1746,15 @@ discard block |
||
| 1748 | 1746 | * @see nusoap_xmlschema |
| 1749 | 1747 | * @access public |
| 1750 | 1748 | */ |
| 1751 | - public function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') { |
|
| 1749 | + public function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') { |
|
| 1752 | 1750 | if (count($elements) > 0) { |
| 1753 | 1751 | $eElements = array(); |
| 1754 | - foreach($elements as $n => $e){ |
|
| 1752 | + foreach ($elements as $n => $e) { |
|
| 1755 | 1753 | // expand each element |
| 1756 | 1754 | $ee = array(); |
| 1757 | 1755 | foreach ($e as $k => $v) { |
| 1758 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1759 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1756 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 1757 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 1760 | 1758 | $ee[$k] = $v; |
| 1761 | 1759 | } |
| 1762 | 1760 | $eElements[$n] = $ee; |
@@ -1765,11 +1763,11 @@ discard block |
||
| 1765 | 1763 | } |
| 1766 | 1764 | |
| 1767 | 1765 | if (count($attrs) > 0) { |
| 1768 | - foreach($attrs as $n => $a){ |
|
| 1766 | + foreach ($attrs as $n => $a) { |
|
| 1769 | 1767 | // expand each attribute |
| 1770 | 1768 | foreach ($a as $k => $v) { |
| 1771 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1772 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1769 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 1770 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 1773 | 1771 | $aa[$k] = $v; |
| 1774 | 1772 | } |
| 1775 | 1773 | $eAttrs[$n] = $aa; |
@@ -1777,11 +1775,11 @@ discard block |
||
| 1777 | 1775 | $attrs = $eAttrs; |
| 1778 | 1776 | } |
| 1779 | 1777 | |
| 1780 | - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1781 | - $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType; |
|
| 1778 | + $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1779 | + $arrayType = strpos($arrayType, ':') ? $this->expandQname($arrayType) : $arrayType; |
|
| 1782 | 1780 | |
| 1783 | 1781 | $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
| 1784 | - $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType); |
|
| 1782 | + $this->schemas[$typens][0]->addComplexType($name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType); |
|
| 1785 | 1783 | } |
| 1786 | 1784 | |
| 1787 | 1785 | /** |
@@ -1795,8 +1793,8 @@ discard block |
||
| 1795 | 1793 | * @see nusoap_xmlschema |
| 1796 | 1794 | * @access public |
| 1797 | 1795 | */ |
| 1798 | - public function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { |
|
| 1799 | - $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1796 | + public function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) { |
|
| 1797 | + $restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
|
| 1800 | 1798 | |
| 1801 | 1799 | $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
| 1802 | 1800 | $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration); |
@@ -1828,7 +1826,7 @@ discard block |
||
| 1828 | 1826 | * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
| 1829 | 1827 | * @access public |
| 1830 | 1828 | */ |
| 1831 | - public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){ |
|
| 1829 | + public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') { |
|
| 1832 | 1830 | if ($use == 'encoded' && $encodingStyle == '') { |
| 1833 | 1831 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
| 1834 | 1832 | } |
@@ -1852,7 +1850,7 @@ discard block |
||
| 1852 | 1850 | } |
| 1853 | 1851 | |
| 1854 | 1852 | // get binding |
| 1855 | - $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] = |
|
| 1853 | + $this->bindings[$this->serviceName . 'Binding']['operations'][$name] = |
|
| 1856 | 1854 | array( |
| 1857 | 1855 | 'name' => $name, |
| 1858 | 1856 | 'binding' => $this->serviceName . 'Binding', |
@@ -1876,29 +1874,29 @@ discard block |
||
| 1876 | 1874 | 'documentation' => $documentation); |
| 1877 | 1875 | // add portTypes |
| 1878 | 1876 | // add messages |
| 1879 | - if($in) |
|
| 1877 | + if ($in) |
|
| 1880 | 1878 | { |
| 1881 | - foreach($in as $pName => $pType) |
|
| 1879 | + foreach ($in as $pName => $pType) |
|
| 1882 | 1880 | { |
| 1883 | - if(strpos($pType,':')) { |
|
| 1884 | - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
|
| 1881 | + if (strpos($pType, ':')) { |
|
| 1882 | + $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType); |
|
| 1885 | 1883 | } |
| 1886 | - $this->messages[$name.'Request'][$pName] = $pType; |
|
| 1884 | + $this->messages[$name . 'Request'][$pName] = $pType; |
|
| 1887 | 1885 | } |
| 1888 | 1886 | } else { |
| 1889 | - $this->messages[$name.'Request']= '0'; |
|
| 1887 | + $this->messages[$name . 'Request'] = '0'; |
|
| 1890 | 1888 | } |
| 1891 | - if($out) |
|
| 1889 | + if ($out) |
|
| 1892 | 1890 | { |
| 1893 | - foreach($out as $pName => $pType) |
|
| 1891 | + foreach ($out as $pName => $pType) |
|
| 1894 | 1892 | { |
| 1895 | - if(strpos($pType,':')) { |
|
| 1896 | - $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType); |
|
| 1893 | + if (strpos($pType, ':')) { |
|
| 1894 | + $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)) . ":" . $this->getLocalPart($pType); |
|
| 1897 | 1895 | } |
| 1898 | - $this->messages[$name.'Response'][$pName] = $pType; |
|
| 1896 | + $this->messages[$name . 'Response'][$pName] = $pType; |
|
| 1899 | 1897 | } |
| 1900 | 1898 | } else { |
| 1901 | - $this->messages[$name.'Response']= '0'; |
|
| 1899 | + $this->messages[$name . 'Response'] = '0'; |
|
| 1902 | 1900 | } |
| 1903 | 1901 | return true; |
| 1904 | 1902 | } |
@@ -14,35 +14,35 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class wsdl extends nusoap_base { |
| 16 | 16 | // URL or filename of the root of this WSDL |
| 17 | - public $wsdl; |
|
| 18 | - // define internal arrays of bindings, ports, operations, messages, etc. |
|
| 19 | - public $schemas = array(); |
|
| 20 | - public $currentSchema; |
|
| 21 | - public $message = array(); |
|
| 22 | - public $complexTypes = array(); |
|
| 23 | - public $messages = array(); |
|
| 24 | - public $currentMessage; |
|
| 25 | - public $currentOperation; |
|
| 26 | - public $portTypes = array(); |
|
| 27 | - public $currentPortType; |
|
| 28 | - public $bindings = array(); |
|
| 29 | - public $currentBinding; |
|
| 30 | - public $ports = array(); |
|
| 31 | - public $currentPort; |
|
| 32 | - public $opData = array(); |
|
| 33 | - public $status = ''; |
|
| 34 | - public $documentation = false; |
|
| 35 | - public $endpoint = ''; |
|
| 36 | - // array of wsdl docs to import |
|
| 37 | - public $import = array(); |
|
| 38 | - // parser vars |
|
| 39 | - public $parser; |
|
| 40 | - public $position = 0; |
|
| 41 | - public $depth = 0; |
|
| 42 | - public $depth_array = array(); |
|
| 17 | + public $wsdl; |
|
| 18 | + // define internal arrays of bindings, ports, operations, messages, etc. |
|
| 19 | + public $schemas = array(); |
|
| 20 | + public $currentSchema; |
|
| 21 | + public $message = array(); |
|
| 22 | + public $complexTypes = array(); |
|
| 23 | + public $messages = array(); |
|
| 24 | + public $currentMessage; |
|
| 25 | + public $currentOperation; |
|
| 26 | + public $portTypes = array(); |
|
| 27 | + public $currentPortType; |
|
| 28 | + public $bindings = array(); |
|
| 29 | + public $currentBinding; |
|
| 30 | + public $ports = array(); |
|
| 31 | + public $currentPort; |
|
| 32 | + public $opData = array(); |
|
| 33 | + public $status = ''; |
|
| 34 | + public $documentation = false; |
|
| 35 | + public $endpoint = ''; |
|
| 36 | + // array of wsdl docs to import |
|
| 37 | + public $import = array(); |
|
| 38 | + // parser vars |
|
| 39 | + public $parser; |
|
| 40 | + public $position = 0; |
|
| 41 | + public $depth = 0; |
|
| 42 | + public $depth_array = array(); |
|
| 43 | 43 | // for getting wsdl |
| 44 | 44 | public $proxyhost = ''; |
| 45 | - public $proxyport = ''; |
|
| 45 | + public $proxyport = ''; |
|
| 46 | 46 | public $proxyusername = ''; |
| 47 | 47 | public $proxypassword = ''; |
| 48 | 48 | public $timeout = 0; |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | public $authtype = ''; // Type of HTTP authentication |
| 56 | 56 | public $certRequest = array(); // Certificate for HTTP SSL authentication |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * constructor |
|
| 60 | - * |
|
| 61 | - * @param string $wsdl WSDL document URL |
|
| 58 | + /** |
|
| 59 | + * constructor |
|
| 60 | + * |
|
| 61 | + * @param string $wsdl WSDL document URL |
|
| 62 | 62 | * @param string $proxyhost |
| 63 | 63 | * @param string $proxyport |
| 64 | 64 | * @param string $proxyusername |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @param integer $response_timeout set the response timeout |
| 68 | 68 | * @param array $curl_options user-specified cURL options |
| 69 | 69 | * @param boolean $use_curl try to use cURL |
| 70 | - * @access public |
|
| 71 | - */ |
|
| 72 | - public function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | + public function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ |
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); |
| 75 | - $this->proxyhost = $proxyhost; |
|
| 76 | - $this->proxyport = $proxyport; |
|
| 75 | + $this->proxyhost = $proxyhost; |
|
| 76 | + $this->proxyport = $proxyport; |
|
| 77 | 77 | $this->proxyusername = $proxyusername; |
| 78 | 78 | $this->proxypassword = $proxypassword; |
| 79 | 79 | $this->timeout = $timeout; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $this->curl_options = $curl_options; |
| 83 | 83 | $this->use_curl = $use_curl; |
| 84 | 84 | $this->fetchWSDL($wsdl); |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * fetches the WSDL document and parses it |
@@ -92,29 +92,29 @@ discard block |
||
| 92 | 92 | public function fetchWSDL($wsdl) { |
| 93 | 93 | $this->debug("parse and process WSDL path=$wsdl"); |
| 94 | 94 | $this->wsdl = $wsdl; |
| 95 | - // parse wsdl file |
|
| 96 | - if ($this->wsdl != "") { |
|
| 97 | - $this->parseWSDL($this->wsdl); |
|
| 98 | - } |
|
| 99 | - $imported_urls = array(); |
|
| 100 | - $imported = 1; |
|
| 101 | - while ($imported > 0) { |
|
| 102 | - $imported = 0; |
|
| 103 | - // Schema imports |
|
| 104 | - foreach ($this->schemas as $ns => $list) { |
|
| 105 | - foreach ($list as $xs) { |
|
| 95 | + // parse wsdl file |
|
| 96 | + if ($this->wsdl != "") { |
|
| 97 | + $this->parseWSDL($this->wsdl); |
|
| 98 | + } |
|
| 99 | + $imported_urls = array(); |
|
| 100 | + $imported = 1; |
|
| 101 | + while ($imported > 0) { |
|
| 102 | + $imported = 0; |
|
| 103 | + // Schema imports |
|
| 104 | + foreach ($this->schemas as $ns => $list) { |
|
| 105 | + foreach ($list as $xs) { |
|
| 106 | 106 | $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
| 107 | - foreach ($xs->imports as $ns2 => $list2) { |
|
| 107 | + foreach ($xs->imports as $ns2 => $list2) { |
|
| 108 | 108 | $countList2 = count($list2); |
| 109 | - for ($ii = 0; $ii < $countList2; $ii++) { |
|
| 110 | - if (! $list2[$ii]['loaded']) { |
|
| 111 | - /* |
|
| 109 | + for ($ii = 0; $ii < $countList2; $ii++) { |
|
| 110 | + if (! $list2[$ii]['loaded']) { |
|
| 111 | + /* |
|
| 112 | 112 | * Substituted with line below |
| 113 | 113 | * because of error "Warning: attempt to modify property of non-object" |
| 114 | 114 | * GitHub issue #1 |
| 115 | 115 | */ |
| 116 | - $list2[$ii]['loaded'] = true; |
|
| 117 | - $url = $list2[$ii]['location']; |
|
| 116 | + $list2[$ii]['loaded'] = true; |
|
| 117 | + $url = $list2[$ii]['location']; |
|
| 118 | 118 | if ($url != '') { |
| 119 | 119 | $urlparts = parse_url($url); |
| 120 | 120 | if (!isset($urlparts['host'])) { |
@@ -122,26 +122,26 @@ discard block |
||
| 122 | 122 | substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
| 123 | 123 | } |
| 124 | 124 | if (! in_array($url, $imported_urls)) { |
| 125 | - $this->parseWSDL($url); |
|
| 126 | - $imported++; |
|
| 127 | - $imported_urls[] = $url; |
|
| 128 | - } |
|
| 125 | + $this->parseWSDL($url); |
|
| 126 | + $imported++; |
|
| 127 | + $imported_urls[] = $url; |
|
| 128 | + } |
|
| 129 | 129 | } else { |
| 130 | 130 | $this->debug("Unexpected scenario: empty URL for unloaded import"); |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | - } |
|
| 135 | - } |
|
| 136 | - } |
|
| 137 | - // WSDL imports |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + } |
|
| 137 | + // WSDL imports |
|
| 138 | 138 | $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
| 139 | - foreach ($this->import as $ns => $list) { |
|
| 139 | + foreach ($this->import as $ns => $list) { |
|
| 140 | 140 | $countList = count($list); |
| 141 | - for ($ii = 0; $ii < $countList; $ii++) { |
|
| 142 | - if (! $list[$ii]['loaded']) { |
|
| 143 | - $this->import[$ns][$ii]['loaded'] = true; |
|
| 144 | - $url = $list[$ii]['location']; |
|
| 141 | + for ($ii = 0; $ii < $countList; $ii++) { |
|
| 142 | + if (! $list[$ii]['loaded']) { |
|
| 143 | + $this->import[$ns][$ii]['loaded'] = true; |
|
| 144 | + $url = $list[$ii]['location']; |
|
| 145 | 145 | if ($url != '') { |
| 146 | 146 | $urlparts = parse_url($url); |
| 147 | 147 | if (!isset($urlparts['host'])) { |
@@ -149,70 +149,70 @@ discard block |
||
| 149 | 149 | substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
| 150 | 150 | } |
| 151 | 151 | if (! in_array($url, $imported_urls)) { |
| 152 | - $this->parseWSDL($url); |
|
| 153 | - $imported++; |
|
| 154 | - $imported_urls[] = $url; |
|
| 155 | - } |
|
| 152 | + $this->parseWSDL($url); |
|
| 153 | + $imported++; |
|
| 154 | + $imported_urls[] = $url; |
|
| 155 | + } |
|
| 156 | 156 | } else { |
| 157 | 157 | $this->debug("Unexpected scenario: empty URL for unloaded import"); |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | - } |
|
| 161 | + } |
|
| 162 | 162 | } |
| 163 | - // add new data to operation data |
|
| 164 | - foreach($this->bindings as $binding => $bindingData) { |
|
| 165 | - if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { |
|
| 166 | - foreach($bindingData['operations'] as $operation => $data) { |
|
| 167 | - $this->debug('post-parse data gathering for ' . $operation); |
|
| 168 | - $this->bindings[$binding]['operations'][$operation]['input'] = |
|
| 163 | + // add new data to operation data |
|
| 164 | + foreach($this->bindings as $binding => $bindingData) { |
|
| 165 | + if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { |
|
| 166 | + foreach($bindingData['operations'] as $operation => $data) { |
|
| 167 | + $this->debug('post-parse data gathering for ' . $operation); |
|
| 168 | + $this->bindings[$binding]['operations'][$operation]['input'] = |
|
| 169 | 169 | isset($this->bindings[$binding]['operations'][$operation]['input']) ? |
| 170 | 170 | array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : |
| 171 | 171 | $this->portTypes[ $bindingData['portType'] ][$operation]['input']; |
| 172 | - $this->bindings[$binding]['operations'][$operation]['output'] = |
|
| 172 | + $this->bindings[$binding]['operations'][$operation]['output'] = |
|
| 173 | 173 | isset($this->bindings[$binding]['operations'][$operation]['output']) ? |
| 174 | 174 | array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : |
| 175 | 175 | $this->portTypes[ $bindingData['portType'] ][$operation]['output']; |
| 176 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){ |
|
| 176 | + if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){ |
|
| 177 | 177 | $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; |
| 178 | 178 | } |
| 179 | 179 | if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){ |
| 180 | - $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 181 | - } |
|
| 182 | - // Set operation style if necessary, but do not override one already provided |
|
| 180 | + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 181 | + } |
|
| 182 | + // Set operation style if necessary, but do not override one already provided |
|
| 183 | 183 | if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) { |
| 184 | - $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
|
| 185 | - } |
|
| 186 | - $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
|
| 187 | - $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; |
|
| 188 | - $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - } |
|
| 184 | + $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
|
| 185 | + } |
|
| 186 | + $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
|
| 187 | + $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; |
|
| 188 | + $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + } |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * parses the wsdl document |
|
| 196 | - * |
|
| 197 | - * @param string $wsdl path or URL |
|
| 198 | - * @access private |
|
| 199 | - */ |
|
| 200 | - public function parseWSDL($wsdl = '') { |
|
| 194 | + /** |
|
| 195 | + * parses the wsdl document |
|
| 196 | + * |
|
| 197 | + * @param string $wsdl path or URL |
|
| 198 | + * @access private |
|
| 199 | + */ |
|
| 200 | + public function parseWSDL($wsdl = '') { |
|
| 201 | 201 | $this->debug("parse WSDL at path=$wsdl"); |
| 202 | 202 | |
| 203 | - if ($wsdl == '') { |
|
| 204 | - $this->debug('no wsdl passed to parseWSDL()!!'); |
|
| 205 | - $this->setError('no wsdl passed to parseWSDL()!!'); |
|
| 206 | - return false; |
|
| 207 | - } |
|
| 203 | + if ($wsdl == '') { |
|
| 204 | + $this->debug('no wsdl passed to parseWSDL()!!'); |
|
| 205 | + $this->setError('no wsdl passed to parseWSDL()!!'); |
|
| 206 | + return false; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | - // parse $wsdl for url format |
|
| 210 | - $wsdl_props = parse_url($wsdl); |
|
| 209 | + // parse $wsdl for url format |
|
| 210 | + $wsdl_props = parse_url($wsdl); |
|
| 211 | 211 | |
| 212 | - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { |
|
| 213 | - $this->debug('getting WSDL http(s) URL ' . $wsdl); |
|
| 214 | - // get wsdl |
|
| 215 | - $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
|
| 212 | + if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { |
|
| 213 | + $this->debug('getting WSDL http(s) URL ' . $wsdl); |
|
| 214 | + // get wsdl |
|
| 215 | + $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
|
| 216 | 216 | $tr->request_method = 'GET'; |
| 217 | 217 | $tr->useSOAPAction = false; |
| 218 | 218 | if($this->proxyhost && $this->proxyport){ |
@@ -228,239 +228,239 @@ discard block |
||
| 228 | 228 | if($err = $tr->getError() ){ |
| 229 | 229 | $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; |
| 230 | 230 | $this->debug($errstr); |
| 231 | - $this->setError($errstr); |
|
| 231 | + $this->setError($errstr); |
|
| 232 | 232 | unset($tr); |
| 233 | - return false; |
|
| 233 | + return false; |
|
| 234 | 234 | } |
| 235 | 235 | unset($tr); |
| 236 | 236 | $this->debug("got WSDL URL"); |
| 237 | - } else { |
|
| 238 | - // $wsdl is not http(s), so treat it as a file URL or plain file path |
|
| 239 | - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { |
|
| 240 | - $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 241 | - } else { |
|
| 242 | - $path = $wsdl; |
|
| 243 | - } |
|
| 244 | - $this->debug('getting WSDL file ' . $path); |
|
| 245 | - if ($fp = @fopen($path, 'r')) { |
|
| 246 | - $wsdl_string = ''; |
|
| 247 | - while ($data = fread($fp, 32768)) { |
|
| 248 | - $wsdl_string .= $data; |
|
| 249 | - } |
|
| 250 | - fclose($fp); |
|
| 251 | - } else { |
|
| 252 | - $errstr = "Bad path to WSDL file $path"; |
|
| 253 | - $this->debug($errstr); |
|
| 254 | - $this->setError($errstr); |
|
| 255 | - return false; |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - $this->debug('Parse WSDL'); |
|
| 259 | - // end new code added |
|
| 260 | - // Create an XML parser. |
|
| 261 | - $this->parser = xml_parser_create(); |
|
| 262 | - // Set the options for parsing the XML data. |
|
| 263 | - // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 264 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 265 | - // Set the object for the parser. |
|
| 266 | - xml_set_object($this->parser, $this); |
|
| 267 | - // Set the element handlers for the parser. |
|
| 268 | - xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
| 269 | - xml_set_character_data_handler($this->parser, 'character_data'); |
|
| 270 | - // Parse the XML file. |
|
| 271 | - if (!xml_parse($this->parser, $wsdl_string, true)) { |
|
| 272 | - // Display an error message. |
|
| 273 | - $errstr = sprintf( |
|
| 237 | + } else { |
|
| 238 | + // $wsdl is not http(s), so treat it as a file URL or plain file path |
|
| 239 | + if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { |
|
| 240 | + $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 241 | + } else { |
|
| 242 | + $path = $wsdl; |
|
| 243 | + } |
|
| 244 | + $this->debug('getting WSDL file ' . $path); |
|
| 245 | + if ($fp = @fopen($path, 'r')) { |
|
| 246 | + $wsdl_string = ''; |
|
| 247 | + while ($data = fread($fp, 32768)) { |
|
| 248 | + $wsdl_string .= $data; |
|
| 249 | + } |
|
| 250 | + fclose($fp); |
|
| 251 | + } else { |
|
| 252 | + $errstr = "Bad path to WSDL file $path"; |
|
| 253 | + $this->debug($errstr); |
|
| 254 | + $this->setError($errstr); |
|
| 255 | + return false; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + $this->debug('Parse WSDL'); |
|
| 259 | + // end new code added |
|
| 260 | + // Create an XML parser. |
|
| 261 | + $this->parser = xml_parser_create(); |
|
| 262 | + // Set the options for parsing the XML data. |
|
| 263 | + // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 264 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 265 | + // Set the object for the parser. |
|
| 266 | + xml_set_object($this->parser, $this); |
|
| 267 | + // Set the element handlers for the parser. |
|
| 268 | + xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
| 269 | + xml_set_character_data_handler($this->parser, 'character_data'); |
|
| 270 | + // Parse the XML file. |
|
| 271 | + if (!xml_parse($this->parser, $wsdl_string, true)) { |
|
| 272 | + // Display an error message. |
|
| 273 | + $errstr = sprintf( |
|
| 274 | 274 | 'XML error parsing WSDL from %s on line %d: %s', |
| 275 | 275 | $wsdl, |
| 276 | - xml_get_current_line_number($this->parser), |
|
| 277 | - xml_error_string(xml_get_error_code($this->parser)) |
|
| 278 | - ); |
|
| 279 | - $this->debug($errstr); |
|
| 276 | + xml_get_current_line_number($this->parser), |
|
| 277 | + xml_error_string(xml_get_error_code($this->parser)) |
|
| 278 | + ); |
|
| 279 | + $this->debug($errstr); |
|
| 280 | 280 | $this->debug("XML payload:\n" . $wsdl_string); |
| 281 | - $this->setError($errstr); |
|
| 282 | - return false; |
|
| 283 | - } |
|
| 281 | + $this->setError($errstr); |
|
| 282 | + return false; |
|
| 283 | + } |
|
| 284 | 284 | // free the parser |
| 285 | - xml_parser_free($this->parser); |
|
| 286 | - $this->debug('Parsing WSDL done'); |
|
| 285 | + xml_parser_free($this->parser); |
|
| 286 | + $this->debug('Parsing WSDL done'); |
|
| 287 | 287 | // catch wsdl parse errors |
| 288 | 288 | if($this->getError()){ |
| 289 | 289 | return false; |
| 290 | 290 | } |
| 291 | - return true; |
|
| 292 | - } |
|
| 291 | + return true; |
|
| 292 | + } |
|
| 293 | 293 | |
| 294 | - /** |
|
| 295 | - * start-element handler |
|
| 296 | - * |
|
| 297 | - * @param string $parser XML parser object |
|
| 298 | - * @param string $name element name |
|
| 299 | - * @param string $attrs associative array of attributes |
|
| 300 | - * @access private |
|
| 301 | - */ |
|
| 302 | - public function start_element($parser, $name, $attrs) |
|
| 303 | - { |
|
| 304 | - if ($this->status == 'schema') { |
|
| 305 | - $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 306 | - $this->appendDebug($this->currentSchema->getDebug()); |
|
| 307 | - $this->currentSchema->clearDebug(); |
|
| 308 | - } elseif (preg_match('/schema$/', $name)) { |
|
| 309 | - $this->debug('Parsing WSDL schema'); |
|
| 310 | - $this->status = 'schema'; |
|
| 311 | - $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces); |
|
| 312 | - $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 313 | - $this->appendDebug($this->currentSchema->getDebug()); |
|
| 314 | - $this->currentSchema->clearDebug(); |
|
| 315 | - } else { |
|
| 316 | - // position in the total number of elements, starting from 0 |
|
| 317 | - $pos = $this->position++; |
|
| 318 | - $depth = $this->depth++; |
|
| 319 | - // set self as current value for this depth |
|
| 320 | - $this->depth_array[$depth] = $pos; |
|
| 321 | - $this->message[$pos] = array('cdata' => ''); |
|
| 322 | - // process attributes |
|
| 323 | - if (count($attrs) > 0) { |
|
| 294 | + /** |
|
| 295 | + * start-element handler |
|
| 296 | + * |
|
| 297 | + * @param string $parser XML parser object |
|
| 298 | + * @param string $name element name |
|
| 299 | + * @param string $attrs associative array of attributes |
|
| 300 | + * @access private |
|
| 301 | + */ |
|
| 302 | + public function start_element($parser, $name, $attrs) |
|
| 303 | + { |
|
| 304 | + if ($this->status == 'schema') { |
|
| 305 | + $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 306 | + $this->appendDebug($this->currentSchema->getDebug()); |
|
| 307 | + $this->currentSchema->clearDebug(); |
|
| 308 | + } elseif (preg_match('/schema$/', $name)) { |
|
| 309 | + $this->debug('Parsing WSDL schema'); |
|
| 310 | + $this->status = 'schema'; |
|
| 311 | + $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces); |
|
| 312 | + $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 313 | + $this->appendDebug($this->currentSchema->getDebug()); |
|
| 314 | + $this->currentSchema->clearDebug(); |
|
| 315 | + } else { |
|
| 316 | + // position in the total number of elements, starting from 0 |
|
| 317 | + $pos = $this->position++; |
|
| 318 | + $depth = $this->depth++; |
|
| 319 | + // set self as current value for this depth |
|
| 320 | + $this->depth_array[$depth] = $pos; |
|
| 321 | + $this->message[$pos] = array('cdata' => ''); |
|
| 322 | + // process attributes |
|
| 323 | + if (count($attrs) > 0) { |
|
| 324 | 324 | // register namespace declarations |
| 325 | - foreach($attrs as $k => $v) { |
|
| 326 | - if (preg_match('/^xmlns/',$k)) { |
|
| 327 | - if ($ns_prefix = substr(strrchr($k, ':'), 1)) { |
|
| 328 | - $this->namespaces[$ns_prefix] = $v; |
|
| 329 | - } else { |
|
| 330 | - $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; |
|
| 331 | - } |
|
| 332 | - if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { |
|
| 333 | - $this->XMLSchemaVersion = $v; |
|
| 334 | - $this->namespaces['xsi'] = $v . '-instance'; |
|
| 335 | - } |
|
| 336 | - } |
|
| 337 | - } |
|
| 338 | - // expand each attribute prefix to its namespace |
|
| 339 | - foreach($attrs as $k => $v) { |
|
| 340 | - $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 341 | - if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { |
|
| 342 | - $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 343 | - } |
|
| 344 | - $eAttrs[$k] = $v; |
|
| 345 | - } |
|
| 346 | - $attrs = $eAttrs; |
|
| 347 | - } else { |
|
| 348 | - $attrs = array(); |
|
| 349 | - } |
|
| 350 | - // get element prefix, namespace and name |
|
| 351 | - if (preg_match('/:/', $name)) { |
|
| 352 | - // get ns prefix |
|
| 353 | - $prefix = substr($name, 0, strpos($name, ':')); |
|
| 354 | - // get ns |
|
| 355 | - $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; |
|
| 356 | - // get unqualified name |
|
| 357 | - $name = substr(strstr($name, ':'), 1); |
|
| 358 | - } |
|
| 325 | + foreach($attrs as $k => $v) { |
|
| 326 | + if (preg_match('/^xmlns/',$k)) { |
|
| 327 | + if ($ns_prefix = substr(strrchr($k, ':'), 1)) { |
|
| 328 | + $this->namespaces[$ns_prefix] = $v; |
|
| 329 | + } else { |
|
| 330 | + $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; |
|
| 331 | + } |
|
| 332 | + if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { |
|
| 333 | + $this->XMLSchemaVersion = $v; |
|
| 334 | + $this->namespaces['xsi'] = $v . '-instance'; |
|
| 335 | + } |
|
| 336 | + } |
|
| 337 | + } |
|
| 338 | + // expand each attribute prefix to its namespace |
|
| 339 | + foreach($attrs as $k => $v) { |
|
| 340 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 341 | + if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { |
|
| 342 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 343 | + } |
|
| 344 | + $eAttrs[$k] = $v; |
|
| 345 | + } |
|
| 346 | + $attrs = $eAttrs; |
|
| 347 | + } else { |
|
| 348 | + $attrs = array(); |
|
| 349 | + } |
|
| 350 | + // get element prefix, namespace and name |
|
| 351 | + if (preg_match('/:/', $name)) { |
|
| 352 | + // get ns prefix |
|
| 353 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
| 354 | + // get ns |
|
| 355 | + $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; |
|
| 356 | + // get unqualified name |
|
| 357 | + $name = substr(strstr($name, ':'), 1); |
|
| 358 | + } |
|
| 359 | 359 | // process attributes, expanding any prefixes to namespaces |
| 360 | - // find status, register data |
|
| 361 | - switch ($this->status) { |
|
| 362 | - case 'message': |
|
| 363 | - if ($name == 'part') { |
|
| 364 | - if (isset($attrs['type'])) { |
|
| 365 | - $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); |
|
| 366 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
|
| 367 | - } |
|
| 368 | - if (isset($attrs['element'])) { |
|
| 369 | - $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); |
|
| 370 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 371 | - } |
|
| 372 | - } |
|
| 373 | - break; |
|
| 374 | - case 'portType': |
|
| 375 | - switch ($name) { |
|
| 376 | - case 'operation': |
|
| 377 | - $this->currentPortOperation = $attrs['name']; |
|
| 378 | - $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); |
|
| 379 | - if (isset($attrs['parameterOrder'])) { |
|
| 380 | - $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; |
|
| 381 | - } |
|
| 382 | - break; |
|
| 383 | - case 'documentation': |
|
| 384 | - $this->documentation = true; |
|
| 385 | - break; |
|
| 386 | - // merge input/output data |
|
| 387 | - default: |
|
| 388 | - $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; |
|
| 389 | - $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; |
|
| 390 | - break; |
|
| 360 | + // find status, register data |
|
| 361 | + switch ($this->status) { |
|
| 362 | + case 'message': |
|
| 363 | + if ($name == 'part') { |
|
| 364 | + if (isset($attrs['type'])) { |
|
| 365 | + $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); |
|
| 366 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
|
| 367 | + } |
|
| 368 | + if (isset($attrs['element'])) { |
|
| 369 | + $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); |
|
| 370 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 371 | + } |
|
| 391 | 372 | } |
| 392 | - break; |
|
| 373 | + break; |
|
| 374 | + case 'portType': |
|
| 375 | + switch ($name) { |
|
| 376 | + case 'operation': |
|
| 377 | + $this->currentPortOperation = $attrs['name']; |
|
| 378 | + $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); |
|
| 379 | + if (isset($attrs['parameterOrder'])) { |
|
| 380 | + $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; |
|
| 381 | + } |
|
| 382 | + break; |
|
| 383 | + case 'documentation': |
|
| 384 | + $this->documentation = true; |
|
| 385 | + break; |
|
| 386 | + // merge input/output data |
|
| 387 | + default: |
|
| 388 | + $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; |
|
| 389 | + $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; |
|
| 390 | + break; |
|
| 391 | + } |
|
| 392 | + break; |
|
| 393 | 393 | case 'binding': |
| 394 | - switch ($name) { |
|
| 395 | - case 'binding': |
|
| 396 | - // get ns prefix |
|
| 397 | - if (isset($attrs['style'])) { |
|
| 398 | - $this->bindings[$this->currentBinding]['prefix'] = $prefix; |
|
| 399 | - } |
|
| 400 | - $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); |
|
| 401 | - break; |
|
| 394 | + switch ($name) { |
|
| 395 | + case 'binding': |
|
| 396 | + // get ns prefix |
|
| 397 | + if (isset($attrs['style'])) { |
|
| 398 | + $this->bindings[$this->currentBinding]['prefix'] = $prefix; |
|
| 399 | + } |
|
| 400 | + $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); |
|
| 401 | + break; |
|
| 402 | 402 | case 'header': |
| 403 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; |
|
| 404 | - break; |
|
| 403 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; |
|
| 404 | + break; |
|
| 405 | 405 | case 'operation': |
| 406 | - if (isset($attrs['soapAction'])) { |
|
| 407 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; |
|
| 408 | - } |
|
| 409 | - if (isset($attrs['style'])) { |
|
| 410 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; |
|
| 411 | - } |
|
| 412 | - if (isset($attrs['name'])) { |
|
| 413 | - $this->currentOperation = $attrs['name']; |
|
| 414 | - $this->debug("current binding operation: $this->currentOperation"); |
|
| 415 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; |
|
| 416 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; |
|
| 417 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; |
|
| 418 | - } |
|
| 419 | - break; |
|
| 406 | + if (isset($attrs['soapAction'])) { |
|
| 407 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; |
|
| 408 | + } |
|
| 409 | + if (isset($attrs['style'])) { |
|
| 410 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; |
|
| 411 | + } |
|
| 412 | + if (isset($attrs['name'])) { |
|
| 413 | + $this->currentOperation = $attrs['name']; |
|
| 414 | + $this->debug("current binding operation: $this->currentOperation"); |
|
| 415 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; |
|
| 416 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; |
|
| 417 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; |
|
| 418 | + } |
|
| 419 | + break; |
|
| 420 | 420 | case 'input': |
| 421 | - $this->opStatus = 'input'; |
|
| 422 | - break; |
|
| 421 | + $this->opStatus = 'input'; |
|
| 422 | + break; |
|
| 423 | 423 | case 'output': |
| 424 | - $this->opStatus = 'output'; |
|
| 425 | - break; |
|
| 424 | + $this->opStatus = 'output'; |
|
| 425 | + break; |
|
| 426 | 426 | case 'body': |
| 427 | - if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) { |
|
| 428 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); |
|
| 429 | - } else { |
|
| 430 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; |
|
| 431 | - } |
|
| 432 | - break; |
|
| 427 | + if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) { |
|
| 428 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); |
|
| 429 | + } else { |
|
| 430 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; |
|
| 431 | + } |
|
| 432 | + break; |
|
| 433 | 433 | } |
| 434 | 434 | break; |
| 435 | 435 | case 'service': |
| 436 | 436 | switch ($name) { |
| 437 | - case 'port': |
|
| 438 | - $this->currentPort = $attrs['name']; |
|
| 439 | - $this->debug('current port: ' . $this->currentPort); |
|
| 440 | - $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
|
| 437 | + case 'port': |
|
| 438 | + $this->currentPort = $attrs['name']; |
|
| 439 | + $this->debug('current port: ' . $this->currentPort); |
|
| 440 | + $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
|
| 441 | 441 | |
| 442 | - break; |
|
| 443 | - case 'address': |
|
| 444 | - $this->ports[$this->currentPort]['location'] = $attrs['location']; |
|
| 445 | - $this->ports[$this->currentPort]['bindingType'] = $namespace; |
|
| 446 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 447 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 448 | - break; |
|
| 442 | + break; |
|
| 443 | + case 'address': |
|
| 444 | + $this->ports[$this->currentPort]['location'] = $attrs['location']; |
|
| 445 | + $this->ports[$this->currentPort]['bindingType'] = $namespace; |
|
| 446 | + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 447 | + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 448 | + break; |
|
| 449 | 449 | } |
| 450 | 450 | break; |
| 451 | 451 | } |
| 452 | 452 | // set status |
| 453 | 453 | switch ($name) { |
| 454 | 454 | case 'import': |
| 455 | - if (isset($attrs['location'])) { |
|
| 456 | - $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); |
|
| 457 | - $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')'); |
|
| 455 | + if (isset($attrs['location'])) { |
|
| 456 | + $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); |
|
| 457 | + $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')'); |
|
| 458 | 458 | } else { |
| 459 | - $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
|
| 459 | + $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
|
| 460 | 460 | if (! $this->getPrefixFromNamespace($attrs['namespace'])) { |
| 461 | 461 | $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
| 462 | 462 | } |
| 463 | - $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')'); |
|
| 463 | + $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')'); |
|
| 464 | 464 | } |
| 465 | 465 | break; |
| 466 | 466 | //wait for schema |
@@ -481,9 +481,9 @@ discard block |
||
| 481 | 481 | if (isset($attrs['name'])) { |
| 482 | 482 | // get binding name |
| 483 | 483 | if (strpos($attrs['name'], ':')) { |
| 484 | - $this->currentBinding = $this->getLocalPart($attrs['name']); |
|
| 484 | + $this->currentBinding = $this->getLocalPart($attrs['name']); |
|
| 485 | 485 | } else { |
| 486 | - $this->currentBinding = $attrs['name']; |
|
| 486 | + $this->currentBinding = $attrs['name']; |
|
| 487 | 487 | } |
| 488 | 488 | $this->status = 'binding'; |
| 489 | 489 | $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); |
@@ -505,20 +505,20 @@ discard block |
||
| 505 | 505 | } |
| 506 | 506 | |
| 507 | 507 | /** |
| 508 | - * end-element handler |
|
| 509 | - * |
|
| 510 | - * @param string $parser XML parser object |
|
| 511 | - * @param string $name element name |
|
| 512 | - * @access private |
|
| 513 | - */ |
|
| 508 | + * end-element handler |
|
| 509 | + * |
|
| 510 | + * @param string $parser XML parser object |
|
| 511 | + * @param string $name element name |
|
| 512 | + * @access private |
|
| 513 | + */ |
|
| 514 | 514 | public function end_element($parser, $name){ |
| 515 | 515 | // unset schema status |
| 516 | 516 | if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { |
| 517 | 517 | $this->status = ""; |
| 518 | - $this->appendDebug($this->currentSchema->getDebug()); |
|
| 519 | - $this->currentSchema->clearDebug(); |
|
| 518 | + $this->appendDebug($this->currentSchema->getDebug()); |
|
| 519 | + $this->currentSchema->clearDebug(); |
|
| 520 | 520 | $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; |
| 521 | - $this->debug('Parsing WSDL schema done'); |
|
| 521 | + $this->debug('Parsing WSDL schema done'); |
|
| 522 | 522 | } |
| 523 | 523 | if ($this->status == 'schema') { |
| 524 | 524 | $this->currentSchema->schemaEndElement($parser, $name); |
@@ -551,14 +551,14 @@ discard block |
||
| 551 | 551 | } |
| 552 | 552 | |
| 553 | 553 | /** |
| 554 | - * if authenticating, set user credentials here |
|
| 555 | - * |
|
| 556 | - * @param string $username |
|
| 557 | - * @param string $password |
|
| 558 | - * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 559 | - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 560 | - * @access public |
|
| 561 | - */ |
|
| 554 | + * if authenticating, set user credentials here |
|
| 555 | + * |
|
| 556 | + * @param string $username |
|
| 557 | + * @param string $password |
|
| 558 | + * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 559 | + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 560 | + * @access public |
|
| 561 | + */ |
|
| 562 | 562 | public function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { |
| 563 | 563 | $this->debug("setCredentials username=$username authtype=$authtype certRequest="); |
| 564 | 564 | $this->appendDebug($this->varDump($certRequest)); |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | // note that we could/should also check the namespace here |
| 639 | 639 | if ($operation == $bOperation) { |
| 640 | 640 | $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; |
| 641 | - return $opData; |
|
| 641 | + return $opData; |
|
| 642 | 642 | } |
| 643 | 643 | } |
| 644 | 644 | } |
@@ -666,7 +666,7 @@ discard block |
||
| 666 | 666 | // loop through operations for the binding |
| 667 | 667 | foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { |
| 668 | 668 | if ($opData['soapAction'] == $soapAction) { |
| 669 | - return $opData; |
|
| 669 | + return $opData; |
|
| 670 | 670 | } |
| 671 | 671 | } |
| 672 | 672 | } |
@@ -674,23 +674,23 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * returns an array of information about a given type |
|
| 678 | - * returns false if no type exists by the given name |
|
| 679 | - * |
|
| 680 | - * typeDef = array( |
|
| 681 | - * 'elements' => array(), // refs to elements array |
|
| 682 | - * 'restrictionBase' => '', |
|
| 683 | - * 'phpType' => '', |
|
| 684 | - * 'order' => '(sequence|all)', |
|
| 685 | - * 'attrs' => array() // refs to attributes array |
|
| 686 | - * ) |
|
| 687 | - * |
|
| 688 | - * @param string $type the type |
|
| 689 | - * @param string $ns namespace (not prefix) of the type |
|
| 690 | - * @return mixed |
|
| 691 | - * @access public |
|
| 692 | - * @see nusoap_xmlschema |
|
| 693 | - */ |
|
| 677 | + * returns an array of information about a given type |
|
| 678 | + * returns false if no type exists by the given name |
|
| 679 | + * |
|
| 680 | + * typeDef = array( |
|
| 681 | + * 'elements' => array(), // refs to elements array |
|
| 682 | + * 'restrictionBase' => '', |
|
| 683 | + * 'phpType' => '', |
|
| 684 | + * 'order' => '(sequence|all)', |
|
| 685 | + * 'attrs' => array() // refs to attributes array |
|
| 686 | + * ) |
|
| 687 | + * |
|
| 688 | + * @param string $type the type |
|
| 689 | + * @param string $ns namespace (not prefix) of the type |
|
| 690 | + * @return mixed |
|
| 691 | + * @access public |
|
| 692 | + * @see nusoap_xmlschema |
|
| 693 | + */ |
|
| 694 | 694 | public function getTypeDef($type, $ns) { |
| 695 | 695 | $this->debug("in getTypeDef: type=$type, ns=$ns"); |
| 696 | 696 | if ((! $ns) && isset($this->namespaces['tns'])) { |
@@ -747,13 +747,13 @@ discard block |
||
| 747 | 747 | return false; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - /** |
|
| 751 | - * prints html description of services |
|
| 752 | - * |
|
| 753 | - * @access private |
|
| 754 | - */ |
|
| 755 | - public function webDescription(){ |
|
| 756 | - global $HTTP_SERVER_VARS; |
|
| 750 | + /** |
|
| 751 | + * prints html description of services |
|
| 752 | + * |
|
| 753 | + * @access private |
|
| 754 | + */ |
|
| 755 | + public function webDescription(){ |
|
| 756 | + global $HTTP_SERVER_VARS; |
|
| 757 | 757 | |
| 758 | 758 | if (isset($_SERVER)) { |
| 759 | 759 | $PHP_SELF = $_SERVER['PHP_SELF']; |
@@ -847,29 +847,29 @@ discard block |
||
| 847 | 847 | Click on an operation name to view it's details.</p> |
| 848 | 848 | <ul>'; |
| 849 | 849 | foreach($this->getOperations() as $op => $data){ |
| 850 | - $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>"; |
|
| 851 | - // create hidden div |
|
| 852 | - $b .= "<div id='$op' class='hidden'> |
|
| 850 | + $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>"; |
|
| 851 | + // create hidden div |
|
| 852 | + $b .= "<div id='$op' class='hidden'> |
|
| 853 | 853 | <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>"; |
| 854 | - foreach($data as $donnie => $marie){ // loop through opdata |
|
| 854 | + foreach($data as $donnie => $marie){ // loop through opdata |
|
| 855 | 855 | if($donnie == 'input' || $donnie == 'output'){ // show input/output data |
| 856 | - $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 857 | - foreach($marie as $captain => $tenille){ // loop through data |
|
| 856 | + $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 857 | + foreach($marie as $captain => $tenille){ // loop through data |
|
| 858 | 858 | if($captain == 'parts'){ // loop thru parts |
| 859 | - $b .= " $captain:<br>"; |
|
| 860 | - //if(is_array($tenille)){ |
|
| 861 | - foreach($tenille as $joanie => $chachi){ |
|
| 859 | + $b .= " $captain:<br>"; |
|
| 860 | + //if(is_array($tenille)){ |
|
| 861 | + foreach($tenille as $joanie => $chachi){ |
|
| 862 | 862 | $b .= " $joanie: $chachi<br>"; |
| 863 | - } |
|
| 864 | - //} |
|
| 863 | + } |
|
| 864 | + //} |
|
| 865 | 865 | } else { |
| 866 | - $b .= " $captain: $tenille<br>"; |
|
| 866 | + $b .= " $captain: $tenille<br>"; |
|
| 867 | 867 | } |
| 868 | - } |
|
| 868 | + } |
|
| 869 | 869 | } else { |
| 870 | - $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 870 | + $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 871 | 871 | } |
| 872 | - } |
|
| 872 | + } |
|
| 873 | 873 | $b .= '</div>'; |
| 874 | 874 | } |
| 875 | 875 | $b .= ' |
@@ -877,15 +877,15 @@ discard block |
||
| 877 | 877 | </div> |
| 878 | 878 | </div></body></html>'; |
| 879 | 879 | return $b; |
| 880 | - } |
|
| 880 | + } |
|
| 881 | 881 | |
| 882 | 882 | /** |
| 883 | - * serialize the parsed wsdl |
|
| 884 | - * |
|
| 885 | - * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 886 | - * @return string serialization of WSDL |
|
| 887 | - * @access public |
|
| 888 | - */ |
|
| 883 | + * serialize the parsed wsdl |
|
| 884 | + * |
|
| 885 | + * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 886 | + * @return string serialization of WSDL |
|
| 887 | + * @access public |
|
| 888 | + */ |
|
| 889 | 889 | public function serialize($debug = 0) |
| 890 | 890 | { |
| 891 | 891 | $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; |
@@ -931,19 +931,19 @@ discard block |
||
| 931 | 931 | foreach($msgParts as $partName => $partType) { |
| 932 | 932 | // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>'; |
| 933 | 933 | if (strpos($partType, ':')) { |
| 934 | - $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
|
| 934 | + $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
|
| 935 | 935 | } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) { |
| 936 | - // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
|
| 937 | - $typePrefix = 'xsd'; |
|
| 936 | + // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
|
| 937 | + $typePrefix = 'xsd'; |
|
| 938 | 938 | } else { |
| 939 | - foreach($this->typemap as $ns => $types) { |
|
| 940 | - if (isset($types[$partType])) { |
|
| 941 | - $typePrefix = $this->getPrefixFromNamespace($ns); |
|
| 942 | - } |
|
| 943 | - } |
|
| 944 | - if (!isset($typePrefix)) { |
|
| 945 | - die("$partType has no namespace!"); |
|
| 946 | - } |
|
| 939 | + foreach($this->typemap as $ns => $types) { |
|
| 940 | + if (isset($types[$partType])) { |
|
| 941 | + $typePrefix = $this->getPrefixFromNamespace($ns); |
|
| 942 | + } |
|
| 943 | + } |
|
| 944 | + if (!isset($typePrefix)) { |
|
| 945 | + die("$partType has no namespace!"); |
|
| 946 | + } |
|
| 947 | 947 | } |
| 948 | 948 | $ns = $this->getNamespaceFromPrefix($typePrefix); |
| 949 | 949 | $localPart = $this->getLocalPart($partType); |
@@ -988,7 +988,7 @@ discard block |
||
| 988 | 988 | $binding_xml .= "\n" . ' </operation>'; |
| 989 | 989 | $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"'; |
| 990 | 990 | if (isset($opParts['parameterOrder'])) { |
| 991 | - $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 991 | + $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 992 | 992 | } |
| 993 | 993 | $portType_xml .= '>'; |
| 994 | 994 | if(isset($opParts['documentation']) && $opParts['documentation'] != '') { |
@@ -1283,34 +1283,34 @@ discard block |
||
| 1283 | 1283 | } |
| 1284 | 1284 | |
| 1285 | 1285 | // if a soapval has been supplied, let its type override the WSDL |
| 1286 | - if (is_object($value) && get_class($value) == 'soapval') { |
|
| 1287 | - if ($value->type_ns) { |
|
| 1288 | - $type = $value->type_ns . ':' . $value->type; |
|
| 1289 | - $forceType = true; |
|
| 1290 | - $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1291 | - } elseif ($value->type) { |
|
| 1292 | - $type = $value->type; |
|
| 1293 | - $forceType = true; |
|
| 1294 | - $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1295 | - } else { |
|
| 1296 | - $forceType = false; |
|
| 1297 | - $this->debug("in serializeType: soapval does not override type"); |
|
| 1298 | - } |
|
| 1299 | - $attrs = $value->attributes; |
|
| 1300 | - $value = $value->value; |
|
| 1301 | - $this->debug("in serializeType: soapval overrides value to $value"); |
|
| 1302 | - if ($attrs) { |
|
| 1303 | - if (!is_array($value)) { |
|
| 1304 | - $value['!'] = $value; |
|
| 1305 | - } |
|
| 1306 | - foreach ($attrs as $n => $v) { |
|
| 1307 | - $value['!' . $n] = $v; |
|
| 1308 | - } |
|
| 1309 | - $this->debug("in serializeType: soapval provides attributes"); |
|
| 1310 | - } |
|
| 1311 | - } else { |
|
| 1312 | - $forceType = false; |
|
| 1313 | - } |
|
| 1286 | + if (is_object($value) && get_class($value) == 'soapval') { |
|
| 1287 | + if ($value->type_ns) { |
|
| 1288 | + $type = $value->type_ns . ':' . $value->type; |
|
| 1289 | + $forceType = true; |
|
| 1290 | + $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1291 | + } elseif ($value->type) { |
|
| 1292 | + $type = $value->type; |
|
| 1293 | + $forceType = true; |
|
| 1294 | + $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1295 | + } else { |
|
| 1296 | + $forceType = false; |
|
| 1297 | + $this->debug("in serializeType: soapval does not override type"); |
|
| 1298 | + } |
|
| 1299 | + $attrs = $value->attributes; |
|
| 1300 | + $value = $value->value; |
|
| 1301 | + $this->debug("in serializeType: soapval overrides value to $value"); |
|
| 1302 | + if ($attrs) { |
|
| 1303 | + if (!is_array($value)) { |
|
| 1304 | + $value['!'] = $value; |
|
| 1305 | + } |
|
| 1306 | + foreach ($attrs as $n => $v) { |
|
| 1307 | + $value['!' . $n] = $v; |
|
| 1308 | + } |
|
| 1309 | + $this->debug("in serializeType: soapval provides attributes"); |
|
| 1310 | + } |
|
| 1311 | + } else { |
|
| 1312 | + $forceType = false; |
|
| 1313 | + } |
|
| 1314 | 1314 | |
| 1315 | 1315 | $xml = ''; |
| 1316 | 1316 | if (strpos($type, ':')) { |
@@ -1342,8 +1342,8 @@ discard block |
||
| 1342 | 1342 | // JBoss/Axis does this sometimes |
| 1343 | 1343 | return $this->serialize_val($value, $name, false, false, false, false, $use); |
| 1344 | 1344 | } |
| 1345 | - if ($uqType == 'boolean') { |
|
| 1346 | - if ((is_string($value) && $value == 'false') || (! $value)) { |
|
| 1345 | + if ($uqType == 'boolean') { |
|
| 1346 | + if ((is_string($value) && $value == 'false') || (! $value)) { |
|
| 1347 | 1347 | $value = 'false'; |
| 1348 | 1348 | } else { |
| 1349 | 1349 | $value = 'true'; |
@@ -1526,9 +1526,9 @@ discard block |
||
| 1526 | 1526 | $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); |
| 1527 | 1527 | //if (strpos($typeDef['arrayType'], ':') ) { |
| 1528 | 1528 | if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) { |
| 1529 | - $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); |
|
| 1529 | + $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); |
|
| 1530 | 1530 | } else { |
| 1531 | - $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
|
| 1531 | + $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
|
| 1532 | 1532 | } |
| 1533 | 1533 | } |
| 1534 | 1534 | } else { |
@@ -1684,7 +1684,7 @@ discard block |
||
| 1684 | 1684 | } |
| 1685 | 1685 | // if user took advantage of a minOccurs=0, then only serialize named parameters |
| 1686 | 1686 | if (isset($optionals) |
| 1687 | - && (!isset($xvalue[$eName])) |
|
| 1687 | + && (!isset($xvalue[$eName])) |
|
| 1688 | 1688 | && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
| 1689 | 1689 | ){ |
| 1690 | 1690 | if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') { |
@@ -1695,9 +1695,9 @@ discard block |
||
| 1695 | 1695 | } else { |
| 1696 | 1696 | // get value |
| 1697 | 1697 | if (isset($xvalue[$eName])) { |
| 1698 | - $v = $xvalue[$eName]; |
|
| 1698 | + $v = $xvalue[$eName]; |
|
| 1699 | 1699 | } else { |
| 1700 | - $v = null; |
|
| 1700 | + $v = null; |
|
| 1701 | 1701 | } |
| 1702 | 1702 | if (isset($attrs['form'])) { |
| 1703 | 1703 | $unqualified = ($attrs['form'] == 'unqualified'); |
@@ -1709,24 +1709,24 @@ discard block |
||
| 1709 | 1709 | foreach ($vv as $k => $v) { |
| 1710 | 1710 | if (isset($attrs['type']) || isset($attrs['ref'])) { |
| 1711 | 1711 | // serialize schema-defined type |
| 1712 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1712 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1713 | 1713 | } else { |
| 1714 | 1714 | // serialize generic type (can this ever really happen?) |
| 1715 | - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1716 | - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1715 | + $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1716 | + $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1717 | 1717 | } |
| 1718 | 1718 | } |
| 1719 | 1719 | } else { |
| 1720 | 1720 | if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') { |
| 1721 | 1721 | } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') { |
| 1722 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1722 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1723 | 1723 | } elseif (isset($attrs['type']) || isset($attrs['ref'])) { |
| 1724 | 1724 | // serialize schema-defined type |
| 1725 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1725 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1726 | 1726 | } else { |
| 1727 | 1727 | // serialize generic type (can this ever really happen?) |
| 1728 | - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1729 | - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1728 | + $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1729 | + $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1730 | 1730 | } |
| 1731 | 1731 | } |
| 1732 | 1732 | } |
@@ -1738,46 +1738,46 @@ discard block |
||
| 1738 | 1738 | } |
| 1739 | 1739 | |
| 1740 | 1740 | /** |
| 1741 | - * adds an XML Schema complex type to the WSDL types |
|
| 1742 | - * |
|
| 1743 | - * @param string $name |
|
| 1744 | - * @param string $typeClass (complexType|simpleType|attribute) |
|
| 1745 | - * @param string $phpType currently supported are array and struct (php assoc array) |
|
| 1746 | - * @param string $compositor (all|sequence|choice) |
|
| 1747 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1748 | - * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) |
|
| 1749 | - * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')) |
|
| 1750 | - * @param string $arrayType as namespace:name (xsd:string) |
|
| 1751 | - * @see nusoap_xmlschema |
|
| 1752 | - * @access public |
|
| 1753 | - */ |
|
| 1741 | + * adds an XML Schema complex type to the WSDL types |
|
| 1742 | + * |
|
| 1743 | + * @param string $name |
|
| 1744 | + * @param string $typeClass (complexType|simpleType|attribute) |
|
| 1745 | + * @param string $phpType currently supported are array and struct (php assoc array) |
|
| 1746 | + * @param string $compositor (all|sequence|choice) |
|
| 1747 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1748 | + * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) |
|
| 1749 | + * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')) |
|
| 1750 | + * @param string $arrayType as namespace:name (xsd:string) |
|
| 1751 | + * @see nusoap_xmlschema |
|
| 1752 | + * @access public |
|
| 1753 | + */ |
|
| 1754 | 1754 | public function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') { |
| 1755 | 1755 | if (count($elements) > 0) { |
| 1756 | 1756 | $eElements = array(); |
| 1757 | - foreach($elements as $n => $e){ |
|
| 1758 | - // expand each element |
|
| 1759 | - $ee = array(); |
|
| 1760 | - foreach ($e as $k => $v) { |
|
| 1761 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1762 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1763 | - $ee[$k] = $v; |
|
| 1764 | - } |
|
| 1765 | - $eElements[$n] = $ee; |
|
| 1766 | - } |
|
| 1767 | - $elements = $eElements; |
|
| 1757 | + foreach($elements as $n => $e){ |
|
| 1758 | + // expand each element |
|
| 1759 | + $ee = array(); |
|
| 1760 | + foreach ($e as $k => $v) { |
|
| 1761 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1762 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1763 | + $ee[$k] = $v; |
|
| 1764 | + } |
|
| 1765 | + $eElements[$n] = $ee; |
|
| 1766 | + } |
|
| 1767 | + $elements = $eElements; |
|
| 1768 | 1768 | } |
| 1769 | 1769 | |
| 1770 | 1770 | if (count($attrs) > 0) { |
| 1771 | - foreach($attrs as $n => $a){ |
|
| 1772 | - // expand each attribute |
|
| 1773 | - foreach ($a as $k => $v) { |
|
| 1774 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1775 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1776 | - $aa[$k] = $v; |
|
| 1777 | - } |
|
| 1778 | - $eAttrs[$n] = $aa; |
|
| 1779 | - } |
|
| 1780 | - $attrs = $eAttrs; |
|
| 1771 | + foreach($attrs as $n => $a){ |
|
| 1772 | + // expand each attribute |
|
| 1773 | + foreach ($a as $k => $v) { |
|
| 1774 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1775 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1776 | + $aa[$k] = $v; |
|
| 1777 | + } |
|
| 1778 | + $eAttrs[$n] = $aa; |
|
| 1779 | + } |
|
| 1780 | + $attrs = $eAttrs; |
|
| 1781 | 1781 | } |
| 1782 | 1782 | |
| 1783 | 1783 | $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
@@ -1788,16 +1788,16 @@ discard block |
||
| 1788 | 1788 | } |
| 1789 | 1789 | |
| 1790 | 1790 | /** |
| 1791 | - * adds an XML Schema simple type to the WSDL types |
|
| 1792 | - * |
|
| 1793 | - * @param string $name |
|
| 1794 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1795 | - * @param string $typeClass (should always be simpleType) |
|
| 1796 | - * @param string $phpType (should always be scalar) |
|
| 1797 | - * @param array $enumeration array of values |
|
| 1798 | - * @see nusoap_xmlschema |
|
| 1799 | - * @access public |
|
| 1800 | - */ |
|
| 1791 | + * adds an XML Schema simple type to the WSDL types |
|
| 1792 | + * |
|
| 1793 | + * @param string $name |
|
| 1794 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1795 | + * @param string $typeClass (should always be simpleType) |
|
| 1796 | + * @param string $phpType (should always be scalar) |
|
| 1797 | + * @param array $enumeration array of values |
|
| 1798 | + * @see nusoap_xmlschema |
|
| 1799 | + * @access public |
|
| 1800 | + */ |
|
| 1801 | 1801 | public function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { |
| 1802 | 1802 | $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
| 1803 | 1803 | |
@@ -1806,31 +1806,31 @@ discard block |
||
| 1806 | 1806 | } |
| 1807 | 1807 | |
| 1808 | 1808 | /** |
| 1809 | - * adds an element to the WSDL types |
|
| 1810 | - * |
|
| 1811 | - * @param array $attrs attributes that must include name and type |
|
| 1812 | - * @see nusoap_xmlschema |
|
| 1813 | - * @access public |
|
| 1814 | - */ |
|
| 1809 | + * adds an element to the WSDL types |
|
| 1810 | + * |
|
| 1811 | + * @param array $attrs attributes that must include name and type |
|
| 1812 | + * @see nusoap_xmlschema |
|
| 1813 | + * @access public |
|
| 1814 | + */ |
|
| 1815 | 1815 | public function addElement($attrs) { |
| 1816 | 1816 | $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
| 1817 | 1817 | $this->schemas[$typens][0]->addElement($attrs); |
| 1818 | 1818 | } |
| 1819 | 1819 | |
| 1820 | 1820 | /** |
| 1821 | - * register an operation with the server |
|
| 1822 | - * |
|
| 1823 | - * @param string $name operation (method) name |
|
| 1824 | - * @param array $in assoc array of input values: key = param name, value = param type |
|
| 1825 | - * @param array $out assoc array of output values: key = param name, value = param type |
|
| 1826 | - * @param string $namespace optional The namespace for the operation |
|
| 1827 | - * @param string $soapaction optional The soapaction for the operation |
|
| 1828 | - * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 1829 | - * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) |
|
| 1830 | - * @param string $documentation optional The description to include in the WSDL |
|
| 1831 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 1832 | - * @access public |
|
| 1833 | - */ |
|
| 1821 | + * register an operation with the server |
|
| 1822 | + * |
|
| 1823 | + * @param string $name operation (method) name |
|
| 1824 | + * @param array $in assoc array of input values: key = param name, value = param type |
|
| 1825 | + * @param array $out assoc array of output values: key = param name, value = param type |
|
| 1826 | + * @param string $namespace optional The namespace for the operation |
|
| 1827 | + * @param string $soapaction optional The soapaction for the operation |
|
| 1828 | + * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 1829 | + * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) |
|
| 1830 | + * @param string $documentation optional The description to include in the WSDL |
|
| 1831 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 1832 | + * @access public |
|
| 1833 | + */ |
|
| 1834 | 1834 | public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){ |
| 1835 | 1835 | if ($use == 'encoded' && $encodingStyle == '') { |
| 1836 | 1836 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
@@ -1889,8 +1889,8 @@ discard block |
||
| 1889 | 1889 | $this->messages[$name.'Request'][$pName] = $pType; |
| 1890 | 1890 | } |
| 1891 | 1891 | } else { |
| 1892 | - $this->messages[$name.'Request']= '0'; |
|
| 1893 | - } |
|
| 1892 | + $this->messages[$name.'Request']= '0'; |
|
| 1893 | + } |
|
| 1894 | 1894 | if($out) |
| 1895 | 1895 | { |
| 1896 | 1896 | foreach($out as $pName => $pType) |
@@ -1901,8 +1901,8 @@ discard block |
||
| 1901 | 1901 | $this->messages[$name.'Response'][$pName] = $pType; |
| 1902 | 1902 | } |
| 1903 | 1903 | } else { |
| 1904 | - $this->messages[$name.'Response']= '0'; |
|
| 1905 | - } |
|
| 1904 | + $this->messages[$name.'Response']= '0'; |
|
| 1905 | + } |
|
| 1906 | 1906 | return true; |
| 1907 | 1907 | } |
| 1908 | 1908 | } |