Completed
Push — 1.11.x ( 3ebade...c47d58 )
by José
213:48 queued 162:56
created
main/inc/lib/events_email.class.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
                 // If the mail only need to be send once (we know that thanks to the events.conf), we log it in the table
126 126
                 if ($event_config[$event_name]["sending_mail_once"]) {
127
-                    $sql = 'INSERT INTO ' . Database::get_main_table(TABLE_EVENT_SENT) . ' (user_from, user_to, event_type_name)
127
+                    $sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_SENT).' (user_from, user_to, event_type_name)
128 128
                             VALUES ('.$event_data["user_id"].', '.$id.' ,"'.Database::escape_string($event_name).'")
129 129
                     ';
130 130
                     Database::query($sql);
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
         // Second, we send to people linked to the event
136 136
         // So, we get everyone
137 137
         $sql = 'SELECT u.user_id, u.language, u.email, u.firstname, u.lastname
138
-                FROM ' . Database::get_main_table(TABLE_EVENT_TYPE_REL_USER) . ' ue
138
+                FROM ' . Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' ue
139 139
                 INNER JOIN '.Database::get_main_table(TABLE_MAIN_USER).' u ON u.user_id = ue.user_id
140
-                WHERE event_type_name = "' . $event_name . '"';
140
+                WHERE event_type_name = "' . $event_name.'"';
141 141
         $result = Database::store_result(Database::query($sql), 'ASSOC');
142 142
         // for each of the linked users
143 143
         foreach ($result as $key => $value) {
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 
178 178
             // If the mail only need to be send once (we know that thanks to the events.conf, we log it in the table
179 179
             if ($event_config[$event_name]["sending_mail_once"]) {
180
-                $sql = 'INSERT INTO ' . Database::get_main_table(TABLE_EVENT_SENT) . '
180
+                $sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_SENT).'
181 181
                     (user_from, user_to, event_type_name)
182 182
                     VALUES ('.$event_data["user_id"].', '.$value["user_id"].' , "'.Database::escape_string($event_name).'");
183 183
                     ';
@@ -202,16 +202,16 @@  discard block
 block discarded – undo
202 202
         $current_language = api_get_interface_language();
203 203
 
204 204
         $sql = 'SELECT COUNT(*) as total
205
-                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE) . ' em
206
-                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE) . ' l
205
+                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' em
206
+                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE).' l
207 207
                 ON em.language_id = l.id
208 208
                 WHERE
209
-                    em.event_type_name = "' . $event_name . '" and
209
+                    em.event_type_name = "' . $event_name.'" and
210 210
                     l.dokeos_folder = "'.$current_language.'" and
211 211
                     em.activated = 1';
212 212
 
213 213
         $exists = Database::store_result(Database::query($sql), 'ASSOC');
214
-        if ($exists[0]["total"])  {
214
+        if ($exists[0]["total"]) {
215 215
             return true;
216 216
         } else {
217 217
             return false;
@@ -228,12 +228,12 @@  discard block
 block discarded – undo
228 228
     private static function getMessage($event_name, $language)
229 229
     {
230 230
         $sql = 'SELECT message, subject, l.dokeos_folder
231
-                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE) . ' em
232
-                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE) . ' l
231
+                FROM ' . Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' em
232
+                INNER JOIN ' . Database::get_main_table(TABLE_MAIN_LANGUAGE).' l
233 233
                 ON em.language_id = l.id
234 234
                 WHERE
235
-                    em.event_type_name = "' . $event_name . '" AND
236
-                    (l.dokeos_folder = "' . $language . '" OR l.dokeos_folder = "english") AND
235
+                    em.event_type_name = "' . $event_name.'" AND
236
+                    (l.dokeos_folder = "' . $language.'" OR l.dokeos_folder = "english") AND
237 237
                     em.message <> ""
238 238
                 ';
239 239
         return Database::store_result(Database::query($sql), 'ASSOC');
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
     private static function formatMessage(&$message, &$subject, $event_config, $event_name, &$event_data)
275 275
     {
276 276
         foreach ($event_config[$event_name]["available_keyvars"] as $key => $word) {
277
-            $message = str_replace('((' . $key . '))', $event_data[$word], $message);
278
-            $subject = str_replace('((' . $key . '))', $event_data[$word], $subject);
277
+            $message = str_replace('(('.$key.'))', $event_data[$word], $message);
278
+            $subject = str_replace('(('.$key.'))', $event_data[$word], $subject);
279 279
         }
280 280
     }
281 281
 }
Please login to merge, or discard this patch.
main/inc/lib/event_email_template.class.php 2 patches
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -12,10 +12,10 @@  discard block
 block discarded – undo
12 12
     /**
13 13
      * Constructor
14 14
      */
15
-	public function __construct()
15
+    public function __construct()
16 16
     {
17 17
         $this->table =  Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
18
-	}
18
+    }
19 19
 
20 20
     public function get_all($where_conditions = array())
21 21
     {
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
     /**
30 30
      * Displays the title + grid
31 31
      */
32
-	public function display()
32
+    public function display()
33 33
     {
34
-		// action links
35
-		$content = Display::actions(array(
34
+        // action links
35
+        $content = Display::actions(array(
36 36
                 array(
37 37
                     'url' => 'event_type.php' ,
38 38
                     'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
39
-                 )
39
+                    )
40 40
             )
41 41
         );
42 42
         $content .= Display::grid_html('event_email_template');
43 43
         return $content;
44
-	}
44
+    }
45 45
 
46 46
     public function get_status_list()
47 47
     {
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
                 'Height' => '250',
83 83
             )
84 84
         );
85
-	    $status_list = $this->get_status_list();
85
+        $status_list = $this->get_status_list();
86 86
         $form->addElement('select', 'status', get_lang('Status'), $status_list);
87 87
         if ($action == 'edit') {
88 88
             $form->addElement('text', 'created_at', get_lang('CreatedAt'));
@@ -99,17 +99,17 @@  discard block
 block discarded – undo
99 99
         $defaults = $this->get($id);
100 100
 
101 101
         if (!empty($defaults['created_at'])) {
102
-        	$defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
102
+            $defaults['created_at'] = api_convert_and_format_date($defaults['created_at']);
103 103
         }
104 104
         if (!empty($defaults['updated_at'])) {
105
-        	$defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
105
+            $defaults['updated_at'] = api_convert_and_format_date($defaults['updated_at']);
106 106
         }
107 107
         $form->setDefaults($defaults);
108 108
 
109 109
         // Setting the rules
110 110
         $form->addRule('name', get_lang('ThisFieldIsRequired'), 'required');
111 111
 
112
-		return $form;
112
+        return $form;
113 113
     }
114 114
 
115 115
     public function get_count()
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
      */
15 15
 	public function __construct()
16 16
     {
17
-        $this->table =  Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
17
+        $this->table = Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE);
18 18
 	}
19 19
 
20 20
     /**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 		// action links
39 39
 		$content = Display::actions(array(
40 40
                 array(
41
-                    'url' => 'event_type.php' ,
41
+                    'url' => 'event_type.php',
42 42
                     'content' => Display::return_icon('new_document.png', get_lang('Add'), array(), ICON_SIZE_MEDIUM)
43 43
                  )
44 44
             )
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
     public function get_count()
123 123
     {
124
-        $row = Database::select('count(*) as count', $this->table, array(),'first');
124
+        $row = Database::select('count(*) as count', $this->table, array(), 'first');
125 125
 
126 126
         return $row['count'];
127 127
     }
Please login to merge, or discard this patch.
main/inc/lib/myspace.lib.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2097,7 +2097,9 @@
 block discarded – undo
2097 2097
                 FROM $tbl_course course
2098 2098
                 WHERE course.code IN (".implode(',',$courses_code).")";
2099 2099
 
2100
-        if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC';
2100
+        if (!in_array($direction, array('ASC','DESC'))) {
2101
+            $direction = 'ASC';
2102
+        }
2101 2103
 
2102 2104
         $column = intval($column);
2103 2105
         $from = intval($from);
Please login to merge, or discard this patch.
Spacing   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
         $session_id  = intval($session_id);
135 135
 
136 136
         $sql = 'SELECT login_course_date, logout_course_date
137
-                FROM ' . $tbl_track_course . '
137
+                FROM ' . $tbl_track_course.'
138 138
                 WHERE
139 139
                     user_id = '.$user_id.' AND
140 140
                     c_id = '.$courseId.' AND
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         foreach ($course_list as $course_item) {
174 174
             $courseInfo = api_get_course_info($course_item['code']);
175 175
             $courseId = $courseInfo['real_id'];
176
-            $new_course_list[] =  '"'.$courseId.'"';
176
+            $new_course_list[] = '"'.$courseId.'"';
177 177
         }
178 178
         $course_list = implode(', ', $new_course_list);
179 179
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
             return false;
182 182
         }
183 183
         $sql = 'SELECT login_course_date, logout_course_date, c_id
184
-                FROM ' . $tbl_track_course . '
184
+                FROM ' . $tbl_track_course.'
185 185
                 WHERE
186 186
                     user_id = '.$user_id.' AND
187 187
                     c_id IN ('.$course_list.') AND
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
             // student score
260 260
             $avg_score = Tracking :: get_avg_student_score($user_id, $courseCode);
261 261
             if (is_numeric($avg_score)) {
262
-                $avg_score = round($avg_score,2);
262
+                $avg_score = round($avg_score, 2);
263 263
             } else {
264 264
                 $$avg_score = '-';
265 265
             }
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
 
296 296
         $t_head = '    <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
297 297
         //$t_head .= '  <caption>'.get_lang('CourseInformation').'</caption>';
298
-        $t_head .=      '<tr>';
298
+        $t_head .= '<tr>';
299 299
         $t_head .= '        <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
300 300
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
301 301
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 
314 314
         $addparams = array('view' => 'admin', 'display' => 'user');
315 315
 
316
-        $table = new SortableTable('tracking_user_overview', array('MySpace','get_number_of_users_tracking_overview'), array('MySpace','get_user_data_tracking_overview'), 0);
316
+        $table = new SortableTable('tracking_user_overview', array('MySpace', 'get_number_of_users_tracking_overview'), array('MySpace', 'get_user_data_tracking_overview'), 0);
317 317
         $table->additional_parameters = $addparams;
318 318
 
319 319
         $table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
         }
327 327
         $table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
328 328
         $table->set_header(4, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
329
-        $table->set_column_filter(4, array('MySpace','course_info_tracking_filter'));
329
+        $table->set_column_filter(4, array('MySpace', 'course_info_tracking_filter'));
330 330
         $table->display();
331 331
     }
332 332
 
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
         $table -> set_header(7, get_lang('Sessions'), false);
387 387
 
388 388
         if ($is_western_name_order) {
389
-            $csv_header[] = array (
389
+            $csv_header[] = array(
390 390
                 get_lang('FirstName'),
391 391
                 get_lang('LastName'),
392 392
                 get_lang('TimeSpentOnThePlatform'),
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
                 get_lang('NumberOfSessions')
397 397
             );
398 398
         } else {
399
-            $csv_header[] = array (
399
+            $csv_header[] = array(
400 400
                 get_lang('LastName'),
401 401
                 get_lang('FirstName'),
402 402
                 get_lang('TimeSpentOnThePlatform'),
@@ -536,9 +536,9 @@  discard block
 block discarded – undo
536 536
 
537 537
         if ($tracking_column != 3) {
538 538
             if ($tracking_direction == 'DESC') {
539
-                usort($all_datas, array('MySpace','rsort_users'));
539
+                usort($all_datas, array('MySpace', 'rsort_users'));
540 540
             } else {
541
-                usort($all_datas, array('MySpace','sort_users'));
541
+                usort($all_datas, array('MySpace', 'sort_users'));
542 542
             }
543 543
         }
544 544
 
@@ -597,7 +597,7 @@  discard block
 block discarded – undo
597 597
         /**
598 598
          * Column config
599 599
          */
600
-        $column_model   = array(
600
+        $column_model = array(
601 601
             array(
602 602
                 'name' => 'username',
603 603
                 'index' => 'username',
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 
639 639
         $action_links = '';
640 640
         // jqgrid will use this URL to do the selects
641
-        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from;
641
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_lp_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from;
642 642
 
643 643
         //Table Id
644 644
         $tableId = 'lpProgress';
@@ -660,11 +660,11 @@  discard block
 block discarded – undo
660 660
             true
661 661
         );
662 662
 
663
-        $return = '<script>$(function() {'. $table .
663
+        $return = '<script>$(function() {'.$table.
664 664
             'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
665 665
                 jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
666 666
                        caption:"",
667
-                       title:"' . get_lang('ExportExcel') . '",
667
+                       title:"' . get_lang('ExportExcel').'",
668 668
                        onClickButton : function () {
669 669
                            jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
670 670
                        }
@@ -714,7 +714,7 @@  discard block
 block discarded – undo
714 714
         /**
715 715
          * Column config
716 716
          */
717
-        $column_model   = array(
717
+        $column_model = array(
718 718
             array('name'=>'session', 'index'=>'session', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"),
719 719
             array('name'=>'exercise_id', 'index'=>'exercise_id', 'align'=>'left', 'search' => 'true'),
720 720
             array('name'=>'quiz_title', 'index'=>'quiz_title', 'align'=>'left', 'search' => 'true'),
@@ -731,7 +731,7 @@  discard block
 block discarded – undo
731 731
         //get dynamic column names
732 732
 
733 733
         // jqgrid will use this URL to do the selects
734
-        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id=' . $sessionId . '&course_id=' . $courseId  . '&exercise_id=' . $exerciseId . '&date_to=' . $date_to . '&date_from=' . $date_from;
734
+        $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_progress&session_id='.$sessionId.'&course_id='.$courseId.'&exercise_id='.$exerciseId.'&date_to='.$date_to.'&date_from='.$date_from;
735 735
 
736 736
         // Autowidth
737 737
         $extra_params['autowidth'] = 'true';
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
         $tableId = 'exerciseProgressOverview';
743 743
         $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), '', true);
744 744
 
745
-        $return = '<script>$(function() {'. $table .
745
+        $return = '<script>$(function() {'.$table.
746 746
             'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true});
747 747
                 jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{
748 748
                        caption:"",
749
-                       title:"' . get_lang('ExportExcel') . '",
749
+                       title:"' . get_lang('ExportExcel').'",
750 750
                        onClickButton : function () {
751 751
                            jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"});
752 752
                        }
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
                 // adding the fields that are checked to the session
807 807
                 $message = '';
808 808
                 foreach ($values as $field_ids => $value) {
809
-                    if ($value == 1 && strstr($field_ids,'extra_export_field')) {
809
+                    if ($value == 1 && strstr($field_ids, 'extra_export_field')) {
810 810
                         $_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids);
811 811
                     }
812 812
                 }
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
                 // Displaying a feedback message
822 822
                 if (!empty($_SESSION['additional_export_fields'])) {
823 823
                     Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false);
824
-                } else  {
824
+                } else {
825 825
                     Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false);
826 826
                 }
827 827
             } else {
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     {
850 850
         $t_head = '    <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
851 851
         //$t_head .= '  <caption>'.get_lang('CourseInformation').'</caption>';
852
-        $t_head .=      '<tr>';
852
+        $t_head .= '<tr>';
853 853
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
854 854
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
855 855
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>';
@@ -866,13 +866,13 @@  discard block
 block discarded – undo
866 866
 
867 867
         $addparams = array('view' => 'admin', 'display' => 'courseoverview');
868 868
 
869
-        $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1);
869
+        $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace', 'get_course_data_tracking_overview'), 1);
870 870
         $table->additional_parameters = $addparams;
871 871
 
872 872
         $table->set_header(0, '', false, null, array('style' => 'display: none'));
873 873
         $table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt'));
874 874
         $table->set_header(2, $t_head, false, array('style' => 'width:90%;border:0;padding:0;font-size:7.5pt;'), array('style' => 'width:90%;padding:0;font-size:7.5pt;'));
875
-        $table->set_column_filter(2, array('MySpace','course_tracking_filter'));
875
+        $table->set_column_filter(2, array('MySpace', 'course_tracking_filter'));
876 876
         $table->display();
877 877
     }
878 878
 
@@ -908,7 +908,7 @@  discard block
 block discarded – undo
908 908
         $sql .= " ORDER BY col$column $direction ";
909 909
         $sql .= " LIMIT $from,$number_of_items";
910 910
         $result = Database::query($sql);
911
-        $return = array ();
911
+        $return = array();
912 912
         while ($course = Database::fetch_row($result)) {
913 913
             $return[] = $course;
914 914
         }
@@ -961,18 +961,18 @@  discard block
 block discarded – undo
961 961
             $progress += $progress_tmp[0];
962 962
             $nb_progress_lp += $progress_tmp[1];
963 963
             $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true);
964
-            if(is_array($score_tmp)) {
964
+            if (is_array($score_tmp)) {
965 965
                 $score += $score_tmp[0];
966 966
                 $nb_score_lp += $score_tmp[1];
967 967
             }
968 968
             $nb_messages += Tracking::count_student_messages($row->user_id, $course_code);
969 969
             $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
970 970
             $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
971
-            if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
971
+            if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned
972 972
                 $last_login_date = $last_login_date_tmp;
973
-            } else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
973
+            } else if ($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned.
974 974
                 // Find the max and assign it to first_login_date
975
-                if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
975
+                if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
976 976
                     $last_login_date = $last_login_date_tmp;
977 977
                 }
978 978
             }
@@ -1110,7 +1110,7 @@  discard block
 block discarded – undo
1110 1110
                 $progress += $progress_tmp[0];
1111 1111
                 $nb_progress_lp += $progress_tmp[1];
1112 1112
                 $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true);
1113
-                if(is_array($score_tmp)) {
1113
+                if (is_array($score_tmp)) {
1114 1114
                     $score += $score_tmp[0];
1115 1115
                     $nb_score_lp += $score_tmp[1];
1116 1116
                 }
@@ -1118,11 +1118,11 @@  discard block
 block discarded – undo
1118 1118
                 $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code);
1119 1119
 
1120 1120
                 $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false);
1121
-                if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1121
+                if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1122 1122
                     $last_login_date = $last_login_date_tmp;
1123
-                } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1123
+                } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1124 1124
                     // Find the max and assign it to first_login_date
1125
-                    if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1125
+                    if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1126 1126
                         $last_login_date = $last_login_date_tmp;
1127 1127
                     }
1128 1128
                 }
@@ -1132,22 +1132,22 @@  discard block
 block discarded – undo
1132 1132
                 $total_score_possible += $exercise_results_tmp['score_possible'];
1133 1133
                 $total_questions_answered += $exercise_results_tmp['questions_answered'];
1134 1134
             }
1135
-            if($nb_progress_lp > 0) {
1135
+            if ($nb_progress_lp > 0) {
1136 1136
                 $avg_progress = round($progress / $nb_progress_lp, 2);
1137 1137
             } else {
1138 1138
                 $avg_progress = 0;
1139 1139
             }
1140
-            if($nb_score_lp > 0) {
1140
+            if ($nb_score_lp > 0) {
1141 1141
                 $avg_score = round($score / $nb_score_lp, 2);
1142 1142
             } else {
1143 1143
                 $avg_score = '-';
1144 1144
             }
1145
-            if($last_login_date) {
1145
+            if ($last_login_date) {
1146 1146
                 $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1147 1147
             } else {
1148 1148
                 $last_login_date = '-';
1149 1149
             }
1150
-            if($total_score_possible > 0) {
1150
+            if ($total_score_possible > 0) {
1151 1151
                 $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1152 1152
             } else {
1153 1153
                 $total_score_percentage = 0;
@@ -1183,7 +1183,7 @@  discard block
 block discarded – undo
1183 1183
     {
1184 1184
         $t_head = '    <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">';
1185 1185
         //$t_head .= '  <caption>'.get_lang('CourseInformation').'</caption>';
1186
-        $t_head .=      '<tr>';
1186
+        $t_head .= '<tr>';
1187 1187
         $t_head .= '        <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>';
1188 1188
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>';
1189 1189
         $t_head .= '        <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>';
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
 
1202 1202
         $addparams = array('view' => 'admin', 'display' => 'sessionoverview');
1203 1203
 
1204
-        $table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_sessions'), array('MySpace','get_session_data_tracking_overview'), 1);
1204
+        $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_sessions'), array('MySpace', 'get_session_data_tracking_overview'), 1);
1205 1205
         $table->additional_parameters = $addparams;
1206 1206
 
1207 1207
         $table->set_header(0, '', false, null, array('style' => 'display: none'));
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
         $sql .= " ORDER BY col$column $direction ";
1241 1241
         $sql .= " LIMIT $from,$number_of_items";
1242 1242
         $result = Database::query($sql);
1243
-        $return = array ();
1243
+        $return = array();
1244 1244
         while ($session = Database::fetch_row($result)) {
1245 1245
             $return[] = $session;
1246 1246
         }
@@ -1329,10 +1329,10 @@  discard block
 block discarded – undo
1329 1329
                 if ($last_login_date_tmp != false && $last_login_date == false) {
1330 1330
                     // TODO: To be cleaned.
1331 1331
                     $last_login_date = $last_login_date_tmp;
1332
-                } else if($last_login_date_tmp != false && $last_login_date != false) {
1332
+                } else if ($last_login_date_tmp != false && $last_login_date != false) {
1333 1333
                     // TODO: Repeated previous condition! To be cleaned.
1334 1334
                     // Find the max and assign it to first_login_date
1335
-                    if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1335
+                    if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1336 1336
                         $last_login_date = $last_login_date_tmp;
1337 1337
                     }
1338 1338
                 }
@@ -1342,27 +1342,27 @@  discard block
 block discarded – undo
1342 1342
                 $total_score_possible += $exercise_results_tmp['score_possible'];
1343 1343
                 $total_questions_answered += $exercise_results_tmp['questions_answered'];
1344 1344
             }
1345
-            if($nb_progress_lp > 0) {
1345
+            if ($nb_progress_lp > 0) {
1346 1346
                 $avg_progress = round($progress / $nb_progress_lp, 2);
1347 1347
             } else {
1348 1348
                 $avg_progress = 0;
1349 1349
             }
1350
-            if($nb_score_lp > 0) {
1350
+            if ($nb_score_lp > 0) {
1351 1351
                 $avg_score = round($score / $nb_score_lp, 2);
1352 1352
             } else {
1353 1353
                 $avg_score = '-';
1354 1354
             }
1355
-            if($last_login_date) {
1355
+            if ($last_login_date) {
1356 1356
                 $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1357 1357
             } else {
1358 1358
                 $last_login_date = '-';
1359 1359
             }
1360
-            if($total_score_possible > 0) {
1360
+            if ($total_score_possible > 0) {
1361 1361
                 $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1362 1362
             } else {
1363 1363
                 $total_score_percentage = 0;
1364 1364
             }
1365
-            if($total_score_percentage > 0) {
1365
+            if ($total_score_percentage > 0) {
1366 1366
                 $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)';
1367 1367
             } else {
1368 1368
                 $total_score = '-';
@@ -1473,7 +1473,7 @@  discard block
 block discarded – undo
1473 1473
                 $total_score_obtained = 0;
1474 1474
                 $total_score_possible = 0;
1475 1475
                 $total_questions_answered = 0;
1476
-                while($row_user = Database::fetch_object($result_users)) {
1476
+                while ($row_user = Database::fetch_object($result_users)) {
1477 1477
                     // get time spent in the course and session
1478 1478
                     $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id);
1479 1479
                     $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true);
@@ -1502,11 +1502,11 @@  discard block
 block discarded – undo
1502 1502
                         $session_id,
1503 1503
                         false
1504 1504
                     );
1505
-                    if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1505
+                    if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned.
1506 1506
                         $last_login_date = $last_login_date_tmp;
1507
-                    } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1507
+                    } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned.
1508 1508
                         // Find the max and assign it to first_login_date
1509
-                        if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1509
+                        if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) {
1510 1510
                             $last_login_date = $last_login_date_tmp;
1511 1511
                         }
1512 1512
                     }
@@ -1516,27 +1516,27 @@  discard block
 block discarded – undo
1516 1516
                     $total_score_possible += $exercise_results_tmp['score_possible'];
1517 1517
                     $total_questions_answered += $exercise_results_tmp['questions_answered'];
1518 1518
                 }
1519
-                if($nb_progress_lp > 0) {
1519
+                if ($nb_progress_lp > 0) {
1520 1520
                     $avg_progress = round($progress / $nb_progress_lp, 2);
1521 1521
                 } else {
1522 1522
                     $avg_progress = 0;
1523 1523
                 }
1524
-                if($nb_score_lp > 0) {
1524
+                if ($nb_score_lp > 0) {
1525 1525
                     $avg_score = round($score / $nb_score_lp, 2);
1526 1526
                 } else {
1527 1527
                     $avg_score = '-';
1528 1528
                 }
1529
-                if($last_login_date) {
1529
+                if ($last_login_date) {
1530 1530
                     $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get());
1531 1531
                 } else {
1532 1532
                     $last_login_date = '-';
1533 1533
                 }
1534
-                if($total_score_possible > 0) {
1534
+                if ($total_score_possible > 0) {
1535 1535
                     $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2);
1536 1536
                 } else {
1537 1537
                     $total_score_percentage = 0;
1538 1538
                 }
1539
-                if($total_score_percentage > 0) {
1539
+                if ($total_score_percentage > 0) {
1540 1540
                     $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)';
1541 1541
                 } else {
1542 1542
                     $total_score = '-';
@@ -1596,7 +1596,7 @@  discard block
 block discarded – undo
1596 1596
         while ($row = Database::fetch_array($result)) {
1597 1597
             $score_obtained += $row['exe_result'];
1598 1598
             $score_possible += $row['exe_weighting'];
1599
-            $questions_answered ++;
1599
+            $questions_answered++;
1600 1600
         }
1601 1601
 
1602 1602
         if ($score_possible != 0) {
@@ -1716,9 +1716,9 @@  discard block
 block discarded – undo
1716 1716
                     }
1717 1717
                 }
1718 1718
                 // time spent in the course
1719
-                $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course ($user[4], $courseId));
1719
+                $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $courseId));
1720 1720
                 // student progress in course
1721
-                $csv_row[] = round(Tracking::get_avg_student_progress ($user[4], $row[0]), 2);
1721
+                $csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2);
1722 1722
                 // student score
1723 1723
                 $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2);
1724 1724
                 // student tes score
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
                 // student messages
1727 1727
                 $csv_row[] = Tracking::count_student_messages($user[4], $row[0]);
1728 1728
                 // student assignments
1729
-                $csv_row[] = Tracking::count_student_assignments ($user[4], $row[0]);
1729
+                $csv_row[] = Tracking::count_student_assignments($user[4], $row[0]);
1730 1730
                 // student exercises results
1731 1731
                 $exercises_results = MySpace::exercises_results($user[4], $row[0]);
1732 1732
                 $csv_row[] = $exercises_results['score_obtained'];
@@ -1734,7 +1734,7 @@  discard block
 block discarded – undo
1734 1734
                 $csv_row[] = $exercises_results['questions_answered'];
1735 1735
                 $csv_row[] = $exercises_results['percentage'];
1736 1736
                 // first connection
1737
-                $csv_row[] = Tracking::get_first_connection_date_on_the_course ($user[4], $courseId);
1737
+                $csv_row[] = Tracking::get_first_connection_date_on_the_course($user[4], $courseId);
1738 1738
                 // last connection
1739 1739
                 $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo));
1740 1740
 
@@ -1768,9 +1768,9 @@  discard block
 block discarded – undo
1768 1768
         // get all courses with limit
1769 1769
         $sql = "SELECT course.code as col1, course.title as col2
1770 1770
                 FROM $tbl_course course
1771
-                WHERE course.code IN (".implode(',',$courses_code).")";
1771
+                WHERE course.code IN (".implode(',', $courses_code).")";
1772 1772
 
1773
-        if (!in_array($direction, array('ASC','DESC'))) $direction = 'ASC';
1773
+        if (!in_array($direction, array('ASC', 'DESC'))) $direction = 'ASC';
1774 1774
 
1775 1775
         $column = intval($column);
1776 1776
         $from = intval($from);
@@ -1839,7 +1839,7 @@  discard block
 block discarded – undo
1839 1839
             $table_row[] = $avg_assignments_in_course;
1840 1840
 
1841 1841
             //set the "from" value to know if I access the Reporting by the chamilo tab or the course link
1842
-            $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq=' .$course_code.'&from=myspace&id_session='.$session_id.'">
1842
+            $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq='.$course_code.'&from=myspace&id_session='.$session_id.'">
1843 1843
                              '.Display::return_icon('2rightarrow.png').'
1844 1844
                              </a>
1845 1845
                             </center>';
@@ -1848,7 +1848,7 @@  discard block
 block discarded – undo
1848 1848
                 $nb_students_in_course,
1849 1849
                 $avg_time_spent_in_course,
1850 1850
                 is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%',
1851
-                is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course ,
1851
+                is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course,
1852 1852
                 is_null($avg_score_in_exercise) ? null : $avg_score_in_exercise.'%',
1853 1853
                 $avg_messages_in_course,
1854 1854
                 $avg_assignments_in_course,
@@ -1916,7 +1916,7 @@  discard block
 block discarded – undo
1916 1916
         $sql .= " ORDER BY col$column $direction ";
1917 1917
         $sql .= " LIMIT $from,$number_of_items";
1918 1918
         $result = Database::query($sql);
1919
-        $return = array ();
1919
+        $return = array();
1920 1920
         while ($user = Database::fetch_row($result)) {
1921 1921
             $return[] = $user;
1922 1922
         }
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
                     $i++;
1972 1972
                 }
1973 1973
             }
1974
-            $username_array = array('username' => $desired_username , 'sufix' => $sufix);
1974
+            $username_array = array('username' => $desired_username, 'sufix' => $sufix);
1975 1975
             return $username_array;
1976 1976
         } else {
1977 1977
             $username_array = array('username' => $username, 'sufix' => '');
@@ -2246,7 +2246,7 @@  discard block
 block discarded – undo
2246 2246
         foreach ($users as $index => $user) {
2247 2247
             $userid = $user['id'];
2248 2248
             $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at)
2249
-                           VALUES ('$id_session','$userid', '" . api_get_utc_datetime() . "')";
2249
+                           VALUES ('$id_session','$userid', '".api_get_utc_datetime()."')";
2250 2250
             Database::query($sql_insert);
2251 2251
             $user['added_at_session'] = 1;
2252 2252
             $new_users[] = $user;
@@ -2280,10 +2280,10 @@  discard block
 block discarded – undo
2280 2280
                 );
2281 2281
                 $userInfo = api_get_user_info($user['id']);
2282 2282
 
2283
-                if (($user['added_at_platform'] == 1  && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
2283
+                if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) {
2284 2284
                     if ($user['added_at_platform'] == 1) {
2285 2285
                         $addedto = get_lang('UserCreatedPlatform');
2286
-                    } else  {
2286
+                    } else {
2287 2287
                         $addedto = '          ';
2288 2288
                     }
2289 2289
 
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
         global $current_tag;
2347 2347
         switch ($data) {
2348 2348
             case 'Contact' :
2349
-                $user = array ();
2349
+                $user = array();
2350 2350
                 break;
2351 2351
             default :
2352 2352
                 $current_tag = $data;
@@ -2393,9 +2393,9 @@  discard block
 block discarded – undo
2393 2393
         global $current_value;
2394 2394
         global $user;
2395 2395
         global $users;
2396
-        $users = array ();
2396
+        $users = array();
2397 2397
         $parser = xml_parser_create('UTF-8');
2398
-        xml_set_element_handler($parser, array('MySpace','element_start'), array('MySpace','element_end'));
2398
+        xml_set_element_handler($parser, array('MySpace', 'element_start'), array('MySpace', 'element_end'));
2399 2399
         xml_set_character_data_handler($parser, "character_data");
2400 2400
         xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false);
2401 2401
         xml_parse($parser, api_utf8_encode_xml(file_get_contents($file)));
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
             get_lang('SearchCourse'),
2442 2442
             $courseList,
2443 2443
             [
2444
-                'url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query([
2444
+                'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?'.http_build_query([
2445 2445
                     'a' => 'search_course_by_session_all',
2446 2446
                     'session_id' => $sessionId
2447 2447
                 ])
@@ -2460,7 +2460,7 @@  discard block
 block discarded – undo
2460 2460
                             course_id: $('#course_id').val() || 0
2461 2461
                         });
2462 2462
 
2463
-                        return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params;
2463
+                        return '" . api_get_path(WEB_AJAX_PATH)."session.ajax.php?' + params;
2464 2464
                     }
2465 2465
                 "
2466 2466
             ]
@@ -2491,7 +2491,7 @@  discard block
 block discarded – undo
2491 2491
                             course_id: $('#course_id').val()
2492 2492
                         });
2493 2493
 
2494
-                        return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params;
2494
+                        return '" . api_get_path(WEB_AJAX_PATH)."course.ajax.php?' + params;
2495 2495
                     }
2496 2496
                 "
2497 2497
             ]
@@ -2579,7 +2579,7 @@  discard block
 block discarded – undo
2579 2579
                     " : "
2580 2580
                         u.lastname AS col2,
2581 2581
                         u.firstname AS col3,
2582
-                " ) . "
2582
+                " )."
2583 2583
                 a.logout_course_date,
2584 2584
                 c.title,
2585 2585
                 c.code,
@@ -2590,7 +2590,7 @@  discard block
 block discarded – undo
2590 2590
 
2591 2591
         if (isset($_GET['session_id']) && !empty($_GET['session_id'])) {
2592 2592
             $sessionId = intval($_GET['session_id']);
2593
-            $sql .= " WHERE a.session_id = " . $sessionId;
2593
+            $sql .= " WHERE a.session_id = ".$sessionId;
2594 2594
         }
2595 2595
 
2596 2596
         $sql .= " ORDER BY col$column $orderDirection ";
@@ -2696,13 +2696,13 @@  discard block
 block discarded – undo
2696 2696
 function get_stats($user_id, $courseId, $start_date = null, $end_date = null)
2697 2697
 {
2698 2698
     // Database table definitions
2699
-    $tbl_track_course   = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
2699
+    $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
2700 2700
 
2701 2701
     $course_info = api_get_course_info_by_id($courseId);
2702 2702
     if (!empty($course_info)) {
2703 2703
         $strg_sd = '';
2704 2704
         $strg_ed = '';
2705
-        if ($start_date != null && $end_date != null){
2705
+        if ($start_date != null && $end_date != null) {
2706 2706
             $end_date = add_day_to($end_date);
2707 2707
             $strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'";
2708 2708
             $strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'";
@@ -2711,10 +2711,10 @@  discard block
 block discarded – undo
2711 2711
                 SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg,
2712 2712
                 SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total,
2713 2713
                 count(user_id) as times
2714
-                FROM ' . $tbl_track_course . '
2714
+                FROM ' . $tbl_track_course.'
2715 2715
                 WHERE
2716
-                    user_id = ' . intval($user_id) . ' AND
2717
-                    c_id = ' . intval($courseId) . ' '.$strg_sd.' '.$strg_ed.' '.'
2716
+                    user_id = ' . intval($user_id).' AND
2717
+                    c_id = ' . intval($courseId).' '.$strg_sd.' '.$strg_ed.' '.'
2718 2718
                 ORDER BY login_course_date ASC';
2719 2719
 
2720 2720
         $rs = Database::query($sql);
@@ -2732,7 +2732,7 @@  discard block
 block discarded – undo
2732 2732
 }
2733 2733
 
2734 2734
 function add_day_to($end_date) {
2735
-    $foo_date = strtotime( $end_date );
2735
+    $foo_date = strtotime($end_date);
2736 2736
     $foo_date = strtotime(" +1 day", $foo_date);
2737 2737
     $foo_date = date("Y-m-d", $foo_date);
2738 2738
     return $foo_date;
@@ -2746,7 +2746,7 @@  discard block
 block discarded – undo
2746 2746
  * @version OCT-22- 2010
2747 2747
  * @return array
2748 2748
  */
2749
-function convert_to_array($sql_result){
2749
+function convert_to_array($sql_result) {
2750 2750
     $result_to_print = '<table>';
2751 2751
     foreach ($sql_result as $key => $data) {
2752 2752
         $result_to_print .= '<tr><td>'.date('d-m-Y (H:i:s)', $data['login']).'</td><td>'.api_time_to_hms($data['logout'] - $data['login']).'</tr></td>'."\n";
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
  * @version OCT-22- 2010
2766 2766
  * @return string
2767 2767
  */
2768
-function convert_to_string($sql_result){
2768
+function convert_to_string($sql_result) {
2769 2769
     $result_to_print = '<table>';
2770 2770
     if (!empty($sql_result)) {
2771 2771
         foreach ($sql_result as $key => $data) {
@@ -2790,18 +2790,18 @@  discard block
 block discarded – undo
2790 2790
  */
2791 2791
 function grapher($sql_result, $start_date, $end_date, $type = "")
2792 2792
 {
2793
-    if (empty($start_date)) { $start_date =""; }
2794
-    if (empty($end_date)) { $end_date =""; }
2795
-    if ($type == ""){ $type = 'day'; }
2796
-    $main_year  = $main_month_year = $main_day = array();
2793
+    if (empty($start_date)) { $start_date = ""; }
2794
+    if (empty($end_date)) { $end_date = ""; }
2795
+    if ($type == "") { $type = 'day'; }
2796
+    $main_year = $main_month_year = $main_day = array();
2797 2797
     // get last 8 days/months
2798 2798
     $last_days      = 5;
2799 2799
     $last_months    = 3;
2800 2800
     for ($i = $last_days; $i >= 0; $i--) {
2801
-        $main_day[date ('d-m-Y', time () - $i * 3600 * 24)] = 0;
2801
+        $main_day[date('d-m-Y', time() - $i * 3600 * 24)] = 0;
2802 2802
     }
2803 2803
     for ($i = $last_months; $i >= 0; $i--) {
2804
-        $main_month_year[date ('m-Y', time () - $i * 30 * 3600 * 24)] = 0;
2804
+        $main_month_year[date('m-Y', time() - $i * 30 * 3600 * 24)] = 0;
2805 2805
     }
2806 2806
 
2807 2807
     $i = 0;
@@ -2837,7 +2837,7 @@  discard block
 block discarded – undo
2837 2837
         /* Create and populate the pData object */
2838 2838
         $myData = new pData();
2839 2839
         $myData->addPoints($main_date, 'Serie1');
2840
-        if (count($main_date)!= 1) {
2840
+        if (count($main_date) != 1) {
2841 2841
             $myData->addPoints($labels, 'Labels');
2842 2842
             $myData->setSerieDescription('Labels', 'Months');
2843 2843
             $myData->setAbscissa('Labels');
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
         $myData->setSerieWeight('Serie1', 1);
2846 2846
         $myData->setSerieDescription('Serie1', get_lang('MyResults'));
2847 2847
         $myData->setAxisName(0, get_lang('Minutes'));
2848
-        $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true);
2848
+        $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true);
2849 2849
 
2850 2850
         // Cache definition
2851 2851
         $cachePath = api_get_path(SYS_ARCHIVE_PATH);
@@ -2854,9 +2854,9 @@  discard block
 block discarded – undo
2854 2854
 
2855 2855
         if ($myCache->isInCache($chartHash)) {
2856 2856
             //if we already created the img
2857
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
2857
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
2858 2858
             $myCache->saveFromCache($chartHash, $imgPath);
2859
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
2859
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
2860 2860
         } else {
2861 2861
             /* Define width, height and angle */
2862 2862
             $mainWidth = 760;
@@ -2885,7 +2885,7 @@  discard block
 block discarded – undo
2885 2885
             /* Set the default font */
2886 2886
             $myPicture->setFontProperties(
2887 2887
                 array(
2888
-                    "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
2888
+                    "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
2889 2889
                     "FontSize" => 10)
2890 2890
             );
2891 2891
             /* Write the chart title */
@@ -2902,7 +2902,7 @@  discard block
 block discarded – undo
2902 2902
             /* Set the default font */
2903 2903
             $myPicture->setFontProperties(
2904 2904
                 array(
2905
-                    "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
2905
+                    "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
2906 2906
                     "FontSize" => 8
2907 2907
                 )
2908 2908
             );
@@ -2944,7 +2944,7 @@  discard block
 block discarded – undo
2944 2944
             /* Draw the line chart */
2945 2945
             $myPicture->setFontProperties(
2946 2946
                 array(
2947
-                    "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf',
2947
+                    "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf',
2948 2948
                     "FontSize" => 10
2949 2949
                 )
2950 2950
             );
@@ -2963,15 +2963,15 @@  discard block
 block discarded – undo
2963 2963
 
2964 2964
             /* Write and save into cache */
2965 2965
             $myCache->writeToCache($chartHash, $myPicture);
2966
-            $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash;
2966
+            $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash;
2967 2967
             $myCache->saveFromCache($chartHash, $imgPath);
2968
-            $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash;
2968
+            $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash;
2969 2969
         }
2970
-        $html = '<img src="' . $imgPath . '">';
2970
+        $html = '<img src="'.$imgPath.'">';
2971 2971
 
2972 2972
         return $html;
2973 2973
     } else {
2974
-        $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8');
2974
+        $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>', 'UTF-8');
2975 2975
 
2976 2976
         return $foo_img;
2977 2977
     }
Please login to merge, or discard this patch.
main/inc/lib/security.lib.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
             $rel_path = '/'.$rel_path;
92 92
         }
93 93
         $abs_path = $current_path.$rel_path;
94
-        $true_path=str_replace("\\", '/', realpath($abs_path));
94
+        $true_path = str_replace("\\", '/', realpath($abs_path));
95 95
         $found = strpos($true_path.'/', $checker_path);
96 96
         if ($found === 0) {
97 97
             return true;
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
         }
322 322
 
323 323
         if ($user_status == COURSEMANAGERLOWSECURITY) {
324
-            return $var;  // No filtering.
324
+            return $var; // No filtering.
325 325
         }
326 326
 
327 327
         static $purifier = array();
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
             }
345 345
 
346 346
             // Shows _target attribute in anchors
347
-            $config->set('Attr.AllowedFrameTargets', array('_blank','_top','_self', '_parent'));
347
+            $config->set('Attr.AllowedFrameTargets', array('_blank', '_top', '_self', '_parent'));
348 348
 
349 349
             if ($user_status == STUDENT) {
350 350
                 global $allowed_html_student;
Please login to merge, or discard this patch.
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -304,9 +304,9 @@  discard block
 block discarded – undo
304 304
      */
305 305
     public static function remove_XSS($var, $user_status = null, $filter_terms = false)
306 306
     {
307
-    	if ($filter_terms) {
308
-    		$var = self::filter_terms($var);
309
-    	}
307
+        if ($filter_terms) {
308
+            $var = self::filter_terms($var);
309
+        }
310 310
 
311 311
         if (empty($user_status)) {
312 312
             if (api_is_anonymous()) {
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
      */
402 402
     public static function filter_terms($text)
403 403
     {
404
-    	static $bad_terms = array();
404
+        static $bad_terms = array();
405 405
 
406 406
         if (empty($bad_terms)) {
407 407
             $list = api_get_setting('filter_terms');
@@ -422,14 +422,14 @@  discard block
 block discarded – undo
422 422
             }
423 423
         }
424 424
 
425
-    	$replace = '***';
426
-    	if (!empty($bad_terms)) {
427
-    		// Fast way
428
-    		$new_text = str_ireplace($bad_terms, $replace, $text, $count);
429
-    		$text = $new_text;
430
-    	}
425
+        $replace = '***';
426
+        if (!empty($bad_terms)) {
427
+            // Fast way
428
+            $new_text = str_ireplace($bad_terms, $replace, $text, $count);
429
+            $text = $new_text;
430
+        }
431 431
         
432
-		return $text;
432
+        return $text;
433 433
     }
434 434
 
435 435
 
Please login to merge, or discard this patch.
main/inc/lib/access_url_edit_users_to_url_functions.lib.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -43,22 +43,22 @@
 block discarded – undo
43 43
                    ' WHERE (username LIKE "'.$needle.'%" '.
44 44
                    ' OR firstname LIKE "'.$needle.'%" '.
45 45
                    ' OR lastname LIKE "'.$needle.'%") '.
46
-                    $order_clause .
46
+                    $order_clause.
47 47
                    ' LIMIT 11';
48 48
 
49 49
             $rs = Database::query($sql);
50
-            $i=0;
50
+            $i = 0;
51 51
 
52 52
             while ($user = Database :: fetch_array($rs)) {
53 53
                 $i++;
54
-                if ($i<=10) {
54
+                if ($i <= 10) {
55 55
                     $return .= '<a href="javascript: void(0);" onclick="javascript: add_user_to_url(\''.addslashes($user['user_id']).'\',\''.api_get_person_name(addslashes($user['firstname']), addslashes($user['lastname'])).' ('.addslashes($user['username']).')'.'\')">'.api_get_person_name($user['firstname'], $user['lastname']).' ('.$user['username'].')</a><br />';
56 56
                 } else {
57 57
                     $return .= '...<br />';
58 58
                 }
59 59
             }
60 60
         }
61
-        $xajax_response -> addAssign('ajax_list_users','innerHTML',api_utf8_encode($return));
61
+        $xajax_response -> addAssign('ajax_list_users', 'innerHTML', api_utf8_encode($return));
62 62
         return $xajax_response;
63 63
     }
64 64
 }
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -40,11 +40,11 @@
 block discarded – undo
40 40
             // search users where username or firstname or lastname begins likes $needle
41 41
             $order_clause = api_sort_by_first_name() ? ' ORDER BY firstname, lastname, username' : ' ORDER BY lastname, firstname, username';
42 42
             $sql = 'SELECT u.user_id, username, lastname, firstname FROM '.$tbl_user.' u '.
43
-                   ' WHERE (username LIKE "'.$needle.'%" '.
44
-                   ' OR firstname LIKE "'.$needle.'%" '.
45
-                   ' OR lastname LIKE "'.$needle.'%") '.
43
+                    ' WHERE (username LIKE "'.$needle.'%" '.
44
+                    ' OR firstname LIKE "'.$needle.'%" '.
45
+                    ' OR lastname LIKE "'.$needle.'%") '.
46 46
                     $order_clause .
47
-                   ' LIMIT 11';
47
+                    ' LIMIT 11';
48 48
 
49 49
             $rs = Database::query($sql);
50 50
             $i=0;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soapclient.php 3 patches
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -173,8 +173,9 @@  discard block
 block discarded – undo
173 173
 		}
174 174
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
175 175
 			$this->loadWSDL();
176
-			if ($this->getError())
177
-				return false;
176
+			if ($this->getError()) {
177
+							return false;
178
+			}
178 179
 		}
179 180
 		// serialize parameters
180 181
 		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
@@ -388,8 +389,9 @@  discard block
 block discarded – undo
388 389
 	function getOperationData($operation){
389 390
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
390 391
 			$this->loadWSDL();
391
-			if ($this->getError())
392
-				return false;
392
+			if ($this->getError()) {
393
+							return false;
394
+			}
393 395
 		}
394 396
 		if(isset($this->operations[$operation])){
395 397
 			return $this->operations[$operation];
Please login to merge, or discard this patch.
Indentation   +903 added lines, -903 removed lines patch added patch discarded remove patch
@@ -22,967 +22,967 @@
 block discarded – undo
22 22
 */
23 23
 class nusoap_client extends nusoap_base
24 24
 {
25
-	var $username = '';				// Username for HTTP authentication
26
-	var $password = '';				// Password for HTTP authentication
27
-	var $authtype = '';				// Type of HTTP authentication
28
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
29
-	var $requestHeaders = false;	// SOAP headers in request (text)
30
-	var $responseHeaders = '';		// SOAP headers from response (incomplete namespace resolution) (text)
31
-	var $responseHeader = NULL;		// SOAP Header from response (parsed)
32
-	var $document = '';				// SOAP body response portion (incomplete namespace resolution) (text)
33
-	var $endpoint;
34
-	var $forceEndpoint = '';		// overrides WSDL endpoint
25
+    var $username = '';				// Username for HTTP authentication
26
+    var $password = '';				// Password for HTTP authentication
27
+    var $authtype = '';				// Type of HTTP authentication
28
+    var $certRequest = array();		// Certificate for HTTP SSL authentication
29
+    var $requestHeaders = false;	// SOAP headers in request (text)
30
+    var $responseHeaders = '';		// SOAP headers from response (incomplete namespace resolution) (text)
31
+    var $responseHeader = NULL;		// SOAP Header from response (parsed)
32
+    var $document = '';				// SOAP body response portion (incomplete namespace resolution) (text)
33
+    var $endpoint;
34
+    var $forceEndpoint = '';		// overrides WSDL endpoint
35 35
     var $proxyhost = '';
36 36
     var $proxyport = '';
37
-	var $proxyusername = '';
38
-	var $proxypassword = '';
39
-	var $portName = '';				// port name to use in WSDL
37
+    var $proxyusername = '';
38
+    var $proxypassword = '';
39
+    var $portName = '';				// port name to use in WSDL
40 40
     var $xml_encoding = '';			// character set encoding of incoming (response) messages
41
-	var $http_encoding = false;
42
-	var $timeout = 0;				// HTTP connection timeout
43
-	var $response_timeout = 30;		// HTTP response timeout
44
-	var $endpointType = '';			// soap|wsdl, empty for WSDL initialization error
45
-	var $persistentConnection = false;
46
-	var $defaultRpcParams = false;	// This is no longer used
47
-	var $request = '';				// HTTP request
48
-	var $response = '';				// HTTP response
49
-	var $responseData = '';			// SOAP payload of response
50
-	var $cookies = array();			// Cookies from response or for request
41
+    var $http_encoding = false;
42
+    var $timeout = 0;				// HTTP connection timeout
43
+    var $response_timeout = 30;		// HTTP response timeout
44
+    var $endpointType = '';			// soap|wsdl, empty for WSDL initialization error
45
+    var $persistentConnection = false;
46
+    var $defaultRpcParams = false;	// This is no longer used
47
+    var $request = '';				// HTTP request
48
+    var $response = '';				// HTTP response
49
+    var $responseData = '';			// SOAP payload of response
50
+    var $cookies = array();			// Cookies from response or for request
51 51
     var $decode_utf8 = true;		// toggles whether the parser decodes element content w/ utf8_decode()
52
-	var $operations = array();		// WSDL operations, empty for WSDL initialization error
53
-	var $curl_options = array();	// User-specified cURL options
54
-	var $bindingType = '';			// WSDL operation binding type
55
-	var $use_curl = false;			// whether to always try to use cURL
52
+    var $operations = array();		// WSDL operations, empty for WSDL initialization error
53
+    var $curl_options = array();	// User-specified cURL options
54
+    var $bindingType = '';			// WSDL operation binding type
55
+    var $use_curl = false;			// whether to always try to use cURL
56 56
 
57
-	/*
57
+    /*
58 58
 	 * fault related variables
59 59
 	 */
60
-	/**
61
-	 * @var      fault
62
-	 * @access   public
63
-	 */
64
-	var $fault;
65
-	/**
66
-	 * @var      faultcode
67
-	 * @access   public
68
-	 */
69
-	var $faultcode;
70
-	/**
71
-	 * @var      faultstring
72
-	 * @access   public
73
-	 */
74
-	var $faultstring;
75
-	/**
76
-	 * @var      faultdetail
77
-	 * @access   public
78
-	 */
79
-	var $faultdetail;
80
-
81
-	/**
82
-	* constructor
83
-	*
84
-	* @param    mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
85
-	* @param    mixed $wsdl optional, set to 'wsdl' or true if using WSDL
86
-	* @param    string $proxyhost optional
87
-	* @param    string $proxyport optional
88
-	* @param	string $proxyusername optional
89
-	* @param	string $proxypassword optional
90
-	* @param	integer $timeout set the connection timeout
91
-	* @param	integer $response_timeout set the response timeout
92
-	* @param	string $portName optional portName in WSDL document
93
-	* @access   public
94
-	*/
95
-	function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
96
-		parent::__construct();
97
-		$this->endpoint = $endpoint;
98
-		$this->proxyhost = $proxyhost;
99
-		$this->proxyport = $proxyport;
100
-		$this->proxyusername = $proxyusername;
101
-		$this->proxypassword = $proxypassword;
102
-		$this->timeout = $timeout;
103
-		$this->response_timeout = $response_timeout;
104
-		$this->portName = $portName;
105
-
106
-		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
107
-		$this->appendDebug('endpoint=' . $this->varDump($endpoint));
108
-
109
-		// make values
110
-		if($wsdl){
111
-			if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
112
-				$this->wsdl = $endpoint;
113
-				$this->endpoint = $this->wsdl->wsdl;
114
-				$this->wsdlFile = $this->endpoint;
115
-				$this->debug('existing wsdl instance created from ' . $this->endpoint);
116
-				$this->checkWSDL();
117
-			} else {
118
-				$this->wsdlFile = $this->endpoint;
119
-				$this->wsdl = null;
120
-				$this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
121
-			}
122
-			$this->endpointType = 'wsdl';
123
-		} else {
124
-			$this->debug("instantiate SOAP with endpoint at $endpoint");
125
-			$this->endpointType = 'soap';
126
-		}
127
-	}
60
+    /**
61
+     * @var      fault
62
+     * @access   public
63
+     */
64
+    var $fault;
65
+    /**
66
+     * @var      faultcode
67
+     * @access   public
68
+     */
69
+    var $faultcode;
70
+    /**
71
+     * @var      faultstring
72
+     * @access   public
73
+     */
74
+    var $faultstring;
75
+    /**
76
+     * @var      faultdetail
77
+     * @access   public
78
+     */
79
+    var $faultdetail;
128 80
 
129
-	/**
130
-	* calls method, returns PHP native type
131
-	*
132
-	* @param    string $operation SOAP server URL or path
133
-	* @param    mixed $params An array, associative or simple, of the parameters
134
-	*			              for the method call, or a string that is the XML
135
-	*			              for the call.  For rpc style, this call will
136
-	*			              wrap the XML in a tag named after the method, as
137
-	*			              well as the SOAP Envelope and Body.  For document
138
-	*			              style, this will only wrap with the Envelope and Body.
139
-	*			              IMPORTANT: when using an array with document style,
140
-	*			              in which case there
141
-	*                         is really one parameter, the root of the fragment
142
-	*                         used in the call, which encloses what programmers
143
-	*                         normally think of parameters.  A parameter array
144
-	*                         *must* include the wrapper.
145
-	* @param	string $namespace optional method namespace (WSDL can override)
146
-	* @param	string $soapAction optional SOAPAction value (WSDL can override)
147
-	* @param	mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
148
-	* @param	boolean $rpcParams optional (no longer used)
149
-	* @param	string	$style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
150
-	* @param	string	$use optional (encoded|literal) the use when serializing parameters (WSDL can override)
151
-	* @return	mixed	response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
152
-	* @access   public
153
-	*/
154
-	function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
155
-		$this->operation = $operation;
156
-		$this->fault = false;
157
-		$this->setError('');
158
-		$this->request = '';
159
-		$this->response = '';
160
-		$this->responseData = '';
161
-		$this->faultstring = '';
162
-		$this->faultcode = '';
163
-		$this->opData = array();
164
-
165
-		$this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
166
-		$this->appendDebug('params=' . $this->varDump($params));
167
-		$this->appendDebug('headers=' . $this->varDump($headers));
168
-		if ($headers) {
169
-			$this->requestHeaders = $headers;
170
-		}
171
-		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
172
-			$this->loadWSDL();
173
-			if ($this->getError())
174
-				return false;
175
-		}
176
-		// serialize parameters
177
-		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
178
-			// use WSDL for operation
179
-			$this->opData = $opData;
180
-			$this->debug("found operation");
181
-			$this->appendDebug('opData=' . $this->varDump($opData));
182
-			if (isset($opData['soapAction'])) {
183
-				$soapAction = $opData['soapAction'];
184
-			}
185
-			if (! $this->forceEndpoint) {
186
-				$this->endpoint = $opData['endpoint'];
187
-			} else {
188
-				$this->endpoint = $this->forceEndpoint;
189
-			}
190
-			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] :	$namespace;
191
-			$style = $opData['style'];
192
-			$use = $opData['input']['use'];
193
-			// add ns to ns array
194
-			if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
195
-				$nsPrefix = 'ns' . rand(1000, 9999);
196
-				$this->wsdl->namespaces[$nsPrefix] = $namespace;
197
-			}
81
+    /**
82
+     * constructor
83
+     *
84
+     * @param    mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
85
+     * @param    mixed $wsdl optional, set to 'wsdl' or true if using WSDL
86
+     * @param    string $proxyhost optional
87
+     * @param    string $proxyport optional
88
+     * @param	string $proxyusername optional
89
+     * @param	string $proxypassword optional
90
+     * @param	integer $timeout set the connection timeout
91
+     * @param	integer $response_timeout set the response timeout
92
+     * @param	string $portName optional portName in WSDL document
93
+     * @access   public
94
+     */
95
+    function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
96
+        parent::__construct();
97
+        $this->endpoint = $endpoint;
98
+        $this->proxyhost = $proxyhost;
99
+        $this->proxyport = $proxyport;
100
+        $this->proxyusername = $proxyusername;
101
+        $this->proxypassword = $proxypassword;
102
+        $this->timeout = $timeout;
103
+        $this->response_timeout = $response_timeout;
104
+        $this->portName = $portName;
105
+
106
+        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
107
+        $this->appendDebug('endpoint=' . $this->varDump($endpoint));
108
+
109
+        // make values
110
+        if($wsdl){
111
+            if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
112
+                $this->wsdl = $endpoint;
113
+                $this->endpoint = $this->wsdl->wsdl;
114
+                $this->wsdlFile = $this->endpoint;
115
+                $this->debug('existing wsdl instance created from ' . $this->endpoint);
116
+                $this->checkWSDL();
117
+            } else {
118
+                $this->wsdlFile = $this->endpoint;
119
+                $this->wsdl = null;
120
+                $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
121
+            }
122
+            $this->endpointType = 'wsdl';
123
+        } else {
124
+            $this->debug("instantiate SOAP with endpoint at $endpoint");
125
+            $this->endpointType = 'soap';
126
+        }
127
+    }
128
+
129
+    /**
130
+     * calls method, returns PHP native type
131
+     *
132
+     * @param    string $operation SOAP server URL or path
133
+     * @param    mixed $params An array, associative or simple, of the parameters
134
+     *			              for the method call, or a string that is the XML
135
+     *			              for the call.  For rpc style, this call will
136
+     *			              wrap the XML in a tag named after the method, as
137
+     *			              well as the SOAP Envelope and Body.  For document
138
+     *			              style, this will only wrap with the Envelope and Body.
139
+     *			              IMPORTANT: when using an array with document style,
140
+     *			              in which case there
141
+     *                         is really one parameter, the root of the fragment
142
+     *                         used in the call, which encloses what programmers
143
+     *                         normally think of parameters.  A parameter array
144
+     *                         *must* include the wrapper.
145
+     * @param	string $namespace optional method namespace (WSDL can override)
146
+     * @param	string $soapAction optional SOAPAction value (WSDL can override)
147
+     * @param	mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array
148
+     * @param	boolean $rpcParams optional (no longer used)
149
+     * @param	string	$style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
150
+     * @param	string	$use optional (encoded|literal) the use when serializing parameters (WSDL can override)
151
+     * @return	mixed	response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
152
+     * @access   public
153
+     */
154
+    function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
155
+        $this->operation = $operation;
156
+        $this->fault = false;
157
+        $this->setError('');
158
+        $this->request = '';
159
+        $this->response = '';
160
+        $this->responseData = '';
161
+        $this->faultstring = '';
162
+        $this->faultcode = '';
163
+        $this->opData = array();
164
+
165
+        $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
166
+        $this->appendDebug('params=' . $this->varDump($params));
167
+        $this->appendDebug('headers=' . $this->varDump($headers));
168
+        if ($headers) {
169
+            $this->requestHeaders = $headers;
170
+        }
171
+        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
172
+            $this->loadWSDL();
173
+            if ($this->getError())
174
+                return false;
175
+        }
176
+        // serialize parameters
177
+        if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
178
+            // use WSDL for operation
179
+            $this->opData = $opData;
180
+            $this->debug("found operation");
181
+            $this->appendDebug('opData=' . $this->varDump($opData));
182
+            if (isset($opData['soapAction'])) {
183
+                $soapAction = $opData['soapAction'];
184
+            }
185
+            if (! $this->forceEndpoint) {
186
+                $this->endpoint = $opData['endpoint'];
187
+            } else {
188
+                $this->endpoint = $this->forceEndpoint;
189
+            }
190
+            $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] :	$namespace;
191
+            $style = $opData['style'];
192
+            $use = $opData['input']['use'];
193
+            // add ns to ns array
194
+            if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
195
+                $nsPrefix = 'ns' . rand(1000, 9999);
196
+                $this->wsdl->namespaces[$nsPrefix] = $namespace;
197
+            }
198 198
             $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
199
-			// serialize payload
200
-			if (is_string($params)) {
201
-				$this->debug("serializing param string for WSDL operation $operation");
202
-				$payload = $params;
203
-			} elseif (is_array($params)) {
204
-				$this->debug("serializing param array for WSDL operation $operation");
205
-				$payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
206
-			} else {
207
-				$this->debug('params must be array or string');
208
-				$this->setError('params must be array or string');
209
-				return false;
210
-			}
199
+            // serialize payload
200
+            if (is_string($params)) {
201
+                $this->debug("serializing param string for WSDL operation $operation");
202
+                $payload = $params;
203
+            } elseif (is_array($params)) {
204
+                $this->debug("serializing param array for WSDL operation $operation");
205
+                $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
206
+            } else {
207
+                $this->debug('params must be array or string');
208
+                $this->setError('params must be array or string');
209
+                return false;
210
+            }
211 211
             $usedNamespaces = $this->wsdl->usedNamespaces;
212
-			if (isset($opData['input']['encodingStyle'])) {
213
-				$encodingStyle = $opData['input']['encodingStyle'];
214
-			} else {
215
-				$encodingStyle = '';
216
-			}
217
-			$this->appendDebug($this->wsdl->getDebug());
218
-			$this->wsdl->clearDebug();
219
-			if ($errstr = $this->wsdl->getError()) {
220
-				$this->debug('got wsdl error: '.$errstr);
221
-				$this->setError('wsdl error: '.$errstr);
222
-				return false;
223
-			}
224
-		} elseif($this->endpointType == 'wsdl') {
225
-			// operation not in WSDL
226
-			$this->appendDebug($this->wsdl->getDebug());
227
-			$this->wsdl->clearDebug();
228
-			$this->setError('operation '.$operation.' not present in WSDL.');
229
-			$this->debug("operation '$operation' not present in WSDL.");
230
-			return false;
231
-		} else {
232
-			// no WSDL
233
-			//$this->namespaces['ns1'] = $namespace;
234
-			$nsPrefix = 'ns' . rand(1000, 9999);
235
-			// serialize
236
-			$payload = '';
237
-			if (is_string($params)) {
238
-				$this->debug("serializing param string for operation $operation");
239
-				$payload = $params;
240
-			} elseif (is_array($params)) {
241
-				$this->debug("serializing param array for operation $operation");
242
-				foreach($params as $k => $v){
243
-					$payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
244
-				}
245
-			} else {
246
-				$this->debug('params must be array or string');
247
-				$this->setError('params must be array or string');
248
-				return false;
249
-			}
250
-			$usedNamespaces = array();
251
-			if ($use == 'encoded') {
252
-				$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
253
-			} else {
254
-				$encodingStyle = '';
255
-			}
256
-		}
257
-		// wrap RPC calls with method element
258
-		if ($style == 'rpc') {
259
-			if ($use == 'literal') {
260
-				$this->debug("wrapping RPC request with literal method element");
261
-				if ($namespace) {
262
-					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
263
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
264
-								$payload .
265
-								"</$nsPrefix:$operation>";
266
-				} else {
267
-					$payload = "<$operation>" . $payload . "</$operation>";
268
-				}
269
-			} else {
270
-				$this->debug("wrapping RPC request with encoded method element");
271
-				if ($namespace) {
272
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
273
-								$payload .
274
-								"</$nsPrefix:$operation>";
275
-				} else {
276
-					$payload = "<$operation>" .
277
-								$payload .
278
-								"</$operation>";
279
-				}
280
-			}
281
-		}
282
-		// serialize envelope
283
-		$soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle);
284
-		$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
285
-		$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
286
-		// send
287
-		$return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
288
-		if($errstr = $this->getError()){
289
-			$this->debug('Error: '.$errstr);
290
-			return false;
291
-		} else {
292
-			$this->return = $return;
293
-			$this->debug('sent message successfully and got a(n) '.gettype($return));
294
-           	$this->appendDebug('return=' . $this->varDump($return));
295
-
296
-			// fault?
297
-			if(is_array($return) && isset($return['faultcode'])){
298
-				$this->debug('got fault');
299
-				$this->setError($return['faultcode'].': '.$return['faultstring']);
300
-				$this->fault = true;
301
-				foreach($return as $k => $v){
302
-					$this->$k = $v;
303
-					$this->debug("$k = $v<br>");
304
-				}
305
-				return $return;
306
-			} elseif ($style == 'document') {
307
-				// NOTE: if the response is defined to have multiple parts (i.e. unwrapped),
308
-				// we are only going to return the first part here...sorry about that
309
-				return $return;
310
-			} else {
311
-				// array of return values
312
-				if(is_array($return)){
313
-					// multiple 'out' parameters, which we return wrapped up
314
-					// in the array
315
-					if(sizeof($return) > 1){
316
-						return $return;
317
-					}
318
-					// single 'out' parameter (normally the return value)
319
-					$return = array_shift($return);
320
-					$this->debug('return shifted value: ');
321
-					$this->appendDebug($this->varDump($return));
322
-           			return $return;
323
-				// nothing returned (ie, echoVoid)
324
-				} else {
325
-					return "";
326
-				}
327
-			}
328
-		}
329
-	}
212
+            if (isset($opData['input']['encodingStyle'])) {
213
+                $encodingStyle = $opData['input']['encodingStyle'];
214
+            } else {
215
+                $encodingStyle = '';
216
+            }
217
+            $this->appendDebug($this->wsdl->getDebug());
218
+            $this->wsdl->clearDebug();
219
+            if ($errstr = $this->wsdl->getError()) {
220
+                $this->debug('got wsdl error: '.$errstr);
221
+                $this->setError('wsdl error: '.$errstr);
222
+                return false;
223
+            }
224
+        } elseif($this->endpointType == 'wsdl') {
225
+            // operation not in WSDL
226
+            $this->appendDebug($this->wsdl->getDebug());
227
+            $this->wsdl->clearDebug();
228
+            $this->setError('operation '.$operation.' not present in WSDL.');
229
+            $this->debug("operation '$operation' not present in WSDL.");
230
+            return false;
231
+        } else {
232
+            // no WSDL
233
+            //$this->namespaces['ns1'] = $namespace;
234
+            $nsPrefix = 'ns' . rand(1000, 9999);
235
+            // serialize
236
+            $payload = '';
237
+            if (is_string($params)) {
238
+                $this->debug("serializing param string for operation $operation");
239
+                $payload = $params;
240
+            } elseif (is_array($params)) {
241
+                $this->debug("serializing param array for operation $operation");
242
+                foreach($params as $k => $v){
243
+                    $payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
244
+                }
245
+            } else {
246
+                $this->debug('params must be array or string');
247
+                $this->setError('params must be array or string');
248
+                return false;
249
+            }
250
+            $usedNamespaces = array();
251
+            if ($use == 'encoded') {
252
+                $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
253
+            } else {
254
+                $encodingStyle = '';
255
+            }
256
+        }
257
+        // wrap RPC calls with method element
258
+        if ($style == 'rpc') {
259
+            if ($use == 'literal') {
260
+                $this->debug("wrapping RPC request with literal method element");
261
+                if ($namespace) {
262
+                    // http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
263
+                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
264
+                                $payload .
265
+                                "</$nsPrefix:$operation>";
266
+                } else {
267
+                    $payload = "<$operation>" . $payload . "</$operation>";
268
+                }
269
+            } else {
270
+                $this->debug("wrapping RPC request with encoded method element");
271
+                if ($namespace) {
272
+                    $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
273
+                                $payload .
274
+                                "</$nsPrefix:$operation>";
275
+                } else {
276
+                    $payload = "<$operation>" .
277
+                                $payload .
278
+                                "</$operation>";
279
+                }
280
+            }
281
+        }
282
+        // serialize envelope
283
+        $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle);
284
+        $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
285
+        $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
286
+        // send
287
+        $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
288
+        if($errstr = $this->getError()){
289
+            $this->debug('Error: '.$errstr);
290
+            return false;
291
+        } else {
292
+            $this->return = $return;
293
+            $this->debug('sent message successfully and got a(n) '.gettype($return));
294
+                $this->appendDebug('return=' . $this->varDump($return));
295
+
296
+            // fault?
297
+            if(is_array($return) && isset($return['faultcode'])){
298
+                $this->debug('got fault');
299
+                $this->setError($return['faultcode'].': '.$return['faultstring']);
300
+                $this->fault = true;
301
+                foreach($return as $k => $v){
302
+                    $this->$k = $v;
303
+                    $this->debug("$k = $v<br>");
304
+                }
305
+                return $return;
306
+            } elseif ($style == 'document') {
307
+                // NOTE: if the response is defined to have multiple parts (i.e. unwrapped),
308
+                // we are only going to return the first part here...sorry about that
309
+                return $return;
310
+            } else {
311
+                // array of return values
312
+                if(is_array($return)){
313
+                    // multiple 'out' parameters, which we return wrapped up
314
+                    // in the array
315
+                    if(sizeof($return) > 1){
316
+                        return $return;
317
+                    }
318
+                    // single 'out' parameter (normally the return value)
319
+                    $return = array_shift($return);
320
+                    $this->debug('return shifted value: ');
321
+                    $this->appendDebug($this->varDump($return));
322
+                        return $return;
323
+                // nothing returned (ie, echoVoid)
324
+                } else {
325
+                    return "";
326
+                }
327
+            }
328
+        }
329
+    }
330 330
 
331
-	/**
332
-	* check WSDL passed as an instance or pulled from an endpoint
333
-	*
334
-	* @access   private
335
-	*/
336
-	function checkWSDL() {
337
-		$this->appendDebug($this->wsdl->getDebug());
338
-		$this->wsdl->clearDebug();
339
-		$this->debug('checkWSDL');
340
-		// catch errors
341
-		if ($errstr = $this->wsdl->getError()) {
342
-			$this->appendDebug($this->wsdl->getDebug());
343
-			$this->wsdl->clearDebug();
344
-			$this->debug('got wsdl error: '.$errstr);
345
-			$this->setError('wsdl error: '.$errstr);
346
-		} elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
347
-			$this->appendDebug($this->wsdl->getDebug());
348
-			$this->wsdl->clearDebug();
349
-			$this->bindingType = 'soap';
350
-			$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
351
-		} elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
352
-			$this->appendDebug($this->wsdl->getDebug());
353
-			$this->wsdl->clearDebug();
354
-			$this->bindingType = 'soap12';
355
-			$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
356
-			$this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
357
-		} else {
358
-			$this->appendDebug($this->wsdl->getDebug());
359
-			$this->wsdl->clearDebug();
360
-			$this->debug('getOperations returned false');
361
-			$this->setError('no operations defined in the WSDL document!');
362
-		}
363
-	}
331
+    /**
332
+     * check WSDL passed as an instance or pulled from an endpoint
333
+     *
334
+     * @access   private
335
+     */
336
+    function checkWSDL() {
337
+        $this->appendDebug($this->wsdl->getDebug());
338
+        $this->wsdl->clearDebug();
339
+        $this->debug('checkWSDL');
340
+        // catch errors
341
+        if ($errstr = $this->wsdl->getError()) {
342
+            $this->appendDebug($this->wsdl->getDebug());
343
+            $this->wsdl->clearDebug();
344
+            $this->debug('got wsdl error: '.$errstr);
345
+            $this->setError('wsdl error: '.$errstr);
346
+        } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
347
+            $this->appendDebug($this->wsdl->getDebug());
348
+            $this->wsdl->clearDebug();
349
+            $this->bindingType = 'soap';
350
+            $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
351
+        } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
352
+            $this->appendDebug($this->wsdl->getDebug());
353
+            $this->wsdl->clearDebug();
354
+            $this->bindingType = 'soap12';
355
+            $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
356
+            $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
357
+        } else {
358
+            $this->appendDebug($this->wsdl->getDebug());
359
+            $this->wsdl->clearDebug();
360
+            $this->debug('getOperations returned false');
361
+            $this->setError('no operations defined in the WSDL document!');
362
+        }
363
+    }
364 364
 
365
-	/**
366
-	 * instantiate wsdl object and parse wsdl file
367
-	 *
368
-	 * @access	public
369
-	 */
370
-	function loadWSDL() {
371
-		$this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
372
-		$this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
373
-		$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
374
-		$this->wsdl->fetchWSDL($this->wsdlFile);
375
-		$this->checkWSDL();
376
-	}
365
+    /**
366
+     * instantiate wsdl object and parse wsdl file
367
+     *
368
+     * @access	public
369
+     */
370
+    function loadWSDL() {
371
+        $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
372
+        $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
373
+        $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
374
+        $this->wsdl->fetchWSDL($this->wsdlFile);
375
+        $this->checkWSDL();
376
+    }
377 377
 
378
-	/**
379
-	* get available data pertaining to an operation
380
-	*
381
-	* @param    string $operation operation name
382
-	* @return	array array of data pertaining to the operation
383
-	* @access   public
384
-	*/
385
-	function getOperationData($operation){
386
-		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
387
-			$this->loadWSDL();
388
-			if ($this->getError())
389
-				return false;
390
-		}
391
-		if(isset($this->operations[$operation])){
392
-			return $this->operations[$operation];
393
-		}
394
-		$this->debug("No data for operation: $operation");
395
-	}
378
+    /**
379
+     * get available data pertaining to an operation
380
+     *
381
+     * @param    string $operation operation name
382
+     * @return	array array of data pertaining to the operation
383
+     * @access   public
384
+     */
385
+    function getOperationData($operation){
386
+        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
387
+            $this->loadWSDL();
388
+            if ($this->getError())
389
+                return false;
390
+        }
391
+        if(isset($this->operations[$operation])){
392
+            return $this->operations[$operation];
393
+        }
394
+        $this->debug("No data for operation: $operation");
395
+    }
396 396
 
397 397
     /**
398
-    * send the SOAP message
399
-    *
400
-    * Note: if the operation has multiple return values
401
-    * the return value of this method will be an array
402
-    * of those values.
403
-    *
404
-	* @param    string $msg a SOAPx4 soapmsg object
405
-	* @param    string $soapaction SOAPAction value
406
-	* @param    integer $timeout set connection timeout in seconds
407
-	* @param	integer $response_timeout set response timeout in seconds
408
-	* @return	mixed native PHP types.
409
-	* @access   private
410
-	*/
411
-	function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
412
-		$this->checkCookies();
413
-		// detect transport
414
-		switch(true){
415
-			// http(s)
416
-			case preg_match('/^http/',$this->endpoint):
417
-				$this->debug('transporting via HTTP');
418
-				if($this->persistentConnection == true && is_object($this->persistentConnection)){
419
-					$http =& $this->persistentConnection;
420
-				} else {
421
-					$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
422
-					if ($this->persistentConnection) {
423
-						$http->usePersistentConnection();
424
-					}
425
-				}
426
-				$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
427
-				$http->setSOAPAction($soapaction);
428
-				if($this->proxyhost && $this->proxyport){
429
-					$http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
430
-				}
398
+     * send the SOAP message
399
+     *
400
+     * Note: if the operation has multiple return values
401
+     * the return value of this method will be an array
402
+     * of those values.
403
+     *
404
+     * @param    string $msg a SOAPx4 soapmsg object
405
+     * @param    string $soapaction SOAPAction value
406
+     * @param    integer $timeout set connection timeout in seconds
407
+     * @param	integer $response_timeout set response timeout in seconds
408
+     * @return	mixed native PHP types.
409
+     * @access   private
410
+     */
411
+    function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
412
+        $this->checkCookies();
413
+        // detect transport
414
+        switch(true){
415
+            // http(s)
416
+            case preg_match('/^http/',$this->endpoint):
417
+                $this->debug('transporting via HTTP');
418
+                if($this->persistentConnection == true && is_object($this->persistentConnection)){
419
+                    $http =& $this->persistentConnection;
420
+                } else {
421
+                    $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
422
+                    if ($this->persistentConnection) {
423
+                        $http->usePersistentConnection();
424
+                    }
425
+                }
426
+                $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
427
+                $http->setSOAPAction($soapaction);
428
+                if($this->proxyhost && $this->proxyport){
429
+                    $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
430
+                }
431 431
                 if($this->authtype != '') {
432
-					$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
433
-				}
434
-				if($this->http_encoding != ''){
435
-					$http->setEncoding($this->http_encoding);
436
-				}
437
-				$this->debug('sending message, length='.strlen($msg));
438
-				if(preg_match('/^http:/',$this->endpoint)){
439
-				//if(strpos($this->endpoint,'http:')){
440
-					$this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
441
-				} elseif(preg_match('/^https/',$this->endpoint)){
442
-				//} elseif(strpos($this->endpoint,'https:')){
443
-					//if(phpversion() == '4.3.0-dev'){
444
-						//$response = $http->send($msg,$timeout,$response_timeout);
445
-                   		//$this->request = $http->outgoing_payload;
446
-						//$this->response = $http->incoming_payload;
447
-					//} else
448
-					$this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
449
-				} else {
450
-					$this->setError('no http/s in endpoint url');
451
-				}
452
-				$this->request = $http->outgoing_payload;
453
-				$this->response = $http->incoming_payload;
454
-				$this->appendDebug($http->getDebug());
455
-				$this->UpdateCookies($http->incoming_cookies);
456
-
457
-				// save transport object if using persistent connections
458
-				if ($this->persistentConnection) {
459
-					$http->clearDebug();
460
-					if (!is_object($this->persistentConnection)) {
461
-						$this->persistentConnection = $http;
462
-					}
463
-				}
464
-
465
-				if($err = $http->getError()){
466
-					$this->setError('HTTP Error: '.$err);
467
-					return false;
468
-				} elseif($this->getError()){
469
-					return false;
470
-				} else {
471
-					$this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
472
-					return $this->parseResponse($http->incoming_headers, $this->responseData);
473
-				}
474
-			break;
475
-			default:
476
-				$this->setError('no transport found, or selected transport is not yet supported!');
477
-			return false;
478
-			break;
479
-		}
480
-	}
432
+                    $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
433
+                }
434
+                if($this->http_encoding != ''){
435
+                    $http->setEncoding($this->http_encoding);
436
+                }
437
+                $this->debug('sending message, length='.strlen($msg));
438
+                if(preg_match('/^http:/',$this->endpoint)){
439
+                //if(strpos($this->endpoint,'http:')){
440
+                    $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
441
+                } elseif(preg_match('/^https/',$this->endpoint)){
442
+                //} elseif(strpos($this->endpoint,'https:')){
443
+                    //if(phpversion() == '4.3.0-dev'){
444
+                        //$response = $http->send($msg,$timeout,$response_timeout);
445
+                            //$this->request = $http->outgoing_payload;
446
+                        //$this->response = $http->incoming_payload;
447
+                    //} else
448
+                    $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
449
+                } else {
450
+                    $this->setError('no http/s in endpoint url');
451
+                }
452
+                $this->request = $http->outgoing_payload;
453
+                $this->response = $http->incoming_payload;
454
+                $this->appendDebug($http->getDebug());
455
+                $this->UpdateCookies($http->incoming_cookies);
456
+
457
+                // save transport object if using persistent connections
458
+                if ($this->persistentConnection) {
459
+                    $http->clearDebug();
460
+                    if (!is_object($this->persistentConnection)) {
461
+                        $this->persistentConnection = $http;
462
+                    }
463
+                }
464
+
465
+                if($err = $http->getError()){
466
+                    $this->setError('HTTP Error: '.$err);
467
+                    return false;
468
+                } elseif($this->getError()){
469
+                    return false;
470
+                } else {
471
+                    $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
472
+                    return $this->parseResponse($http->incoming_headers, $this->responseData);
473
+                }
474
+            break;
475
+            default:
476
+                $this->setError('no transport found, or selected transport is not yet supported!');
477
+            return false;
478
+            break;
479
+        }
480
+    }
481 481
 
482
-	/**
483
-	* processes SOAP message returned from server
484
-	*
485
-	* @param	array	$headers	The HTTP headers
486
-	* @param	string	$data		unprocessed response data from server
487
-	* @return	mixed	value of the message, decoded into a PHP type
488
-	* @access   private
489
-	*/
482
+    /**
483
+     * processes SOAP message returned from server
484
+     *
485
+     * @param	array	$headers	The HTTP headers
486
+     * @param	string	$data		unprocessed response data from server
487
+     * @return	mixed	value of the message, decoded into a PHP type
488
+     * @access   private
489
+     */
490 490
     function parseResponse($headers, $data) {
491
-		$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
492
-		$this->appendDebug($this->varDump($headers));
493
-    	if (!isset($headers['content-type'])) {
494
-			$this->setError('Response not of type text/xml (no content-type header)');
495
-			return false;
496
-    	}
497
-		if (!strstr($headers['content-type'], 'text/xml')) {
498
-			$this->setError('Response not of type text/xml: ' . $headers['content-type']);
499
-			return false;
500
-		}
501
-		if (strpos($headers['content-type'], '=')) {
502
-			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
503
-			$this->debug('Got response encoding: ' . $enc);
504
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
505
-				$this->xml_encoding = strtoupper($enc);
506
-			} else {
507
-				$this->xml_encoding = 'US-ASCII';
508
-			}
509
-		} else {
510
-			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
511
-			$this->xml_encoding = 'ISO-8859-1';
512
-		}
513
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
514
-		$parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
515
-		// add parser debug data to our debug
516
-		$this->appendDebug($parser->getDebug());
517
-		// if parse errors
518
-		if($errstr = $parser->getError()){
519
-			$this->setError( $errstr);
520
-			// destroy the parser object
521
-			unset($parser);
522
-			return false;
523
-		} else {
524
-			// get SOAP headers
525
-			$this->responseHeaders = $parser->getHeaders();
526
-			// get SOAP headers
527
-			$this->responseHeader = $parser->get_soapheader();
528
-			// get decoded message
529
-			$return = $parser->get_soapbody();
491
+        $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
492
+        $this->appendDebug($this->varDump($headers));
493
+        if (!isset($headers['content-type'])) {
494
+            $this->setError('Response not of type text/xml (no content-type header)');
495
+            return false;
496
+        }
497
+        if (!strstr($headers['content-type'], 'text/xml')) {
498
+            $this->setError('Response not of type text/xml: ' . $headers['content-type']);
499
+            return false;
500
+        }
501
+        if (strpos($headers['content-type'], '=')) {
502
+            $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
503
+            $this->debug('Got response encoding: ' . $enc);
504
+            if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
505
+                $this->xml_encoding = strtoupper($enc);
506
+            } else {
507
+                $this->xml_encoding = 'US-ASCII';
508
+            }
509
+        } else {
510
+            // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
511
+            $this->xml_encoding = 'ISO-8859-1';
512
+        }
513
+        $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
514
+        $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
515
+        // add parser debug data to our debug
516
+        $this->appendDebug($parser->getDebug());
517
+        // if parse errors
518
+        if($errstr = $parser->getError()){
519
+            $this->setError( $errstr);
520
+            // destroy the parser object
521
+            unset($parser);
522
+            return false;
523
+        } else {
524
+            // get SOAP headers
525
+            $this->responseHeaders = $parser->getHeaders();
526
+            // get SOAP headers
527
+            $this->responseHeader = $parser->get_soapheader();
528
+            // get decoded message
529
+            $return = $parser->get_soapbody();
530 530
             // add document for doclit support
531 531
             $this->document = $parser->document;
532
-			// destroy the parser object
533
-			unset($parser);
534
-			// return decode message
535
-			return $return;
536
-		}
537
-	 }
538
-
539
-	/**
540
-	* sets user-specified cURL options
541
-	*
542
-	* @param	mixed $option The cURL option (always integer?)
543
-	* @param	mixed $value The cURL option value
544
-	* @access   public
545
-	*/
546
-	function setCurlOption($option, $value) {
547
-		$this->debug("setCurlOption option=$option, value=");
548
-		$this->appendDebug($this->varDump($value));
549
-		$this->curl_options[$option] = $value;
550
-	}
532
+            // destroy the parser object
533
+            unset($parser);
534
+            // return decode message
535
+            return $return;
536
+        }
537
+        }
551 538
 
552
-	/**
553
-	* sets the SOAP endpoint, which can override WSDL
554
-	*
555
-	* @param	string $endpoint The endpoint URL to use, or empty string or false to prevent override
556
-	* @access   public
557
-	*/
558
-	function setEndpoint($endpoint) {
559
-		$this->debug("setEndpoint(\"$endpoint\")");
560
-		$this->forceEndpoint = $endpoint;
561
-	}
539
+    /**
540
+     * sets user-specified cURL options
541
+     *
542
+     * @param	mixed $option The cURL option (always integer?)
543
+     * @param	mixed $value The cURL option value
544
+     * @access   public
545
+     */
546
+    function setCurlOption($option, $value) {
547
+        $this->debug("setCurlOption option=$option, value=");
548
+        $this->appendDebug($this->varDump($value));
549
+        $this->curl_options[$option] = $value;
550
+    }
562 551
 
563
-	/**
564
-	* set the SOAP headers
565
-	*
566
-	* @param	mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
567
-	* @access   public
568
-	*/
569
-	function setHeaders($headers){
570
-		$this->debug("setHeaders headers=");
571
-		$this->appendDebug($this->varDump($headers));
572
-		$this->requestHeaders = $headers;
573
-	}
552
+    /**
553
+     * sets the SOAP endpoint, which can override WSDL
554
+     *
555
+     * @param	string $endpoint The endpoint URL to use, or empty string or false to prevent override
556
+     * @access   public
557
+     */
558
+    function setEndpoint($endpoint) {
559
+        $this->debug("setEndpoint(\"$endpoint\")");
560
+        $this->forceEndpoint = $endpoint;
561
+    }
574 562
 
575
-	/**
576
-	* get the SOAP response headers (namespace resolution incomplete)
577
-	*
578
-	* @return	string
579
-	* @access   public
580
-	*/
581
-	function getHeaders(){
582
-		return $this->responseHeaders;
583
-	}
563
+    /**
564
+     * set the SOAP headers
565
+     *
566
+     * @param	mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
567
+     * @access   public
568
+     */
569
+    function setHeaders($headers){
570
+        $this->debug("setHeaders headers=");
571
+        $this->appendDebug($this->varDump($headers));
572
+        $this->requestHeaders = $headers;
573
+    }
584 574
 
585
-	/**
586
-	* get the SOAP response Header (parsed)
587
-	*
588
-	* @return	mixed
589
-	* @access   public
590
-	*/
591
-	function getHeader(){
592
-		return $this->responseHeader;
593
-	}
575
+    /**
576
+     * get the SOAP response headers (namespace resolution incomplete)
577
+     *
578
+     * @return	string
579
+     * @access   public
580
+     */
581
+    function getHeaders(){
582
+        return $this->responseHeaders;
583
+    }
594 584
 
595
-	/**
596
-	* set proxy info here
597
-	*
598
-	* @param    string $proxyhost
599
-	* @param    string $proxyport
600
-	* @param	string $proxyusername
601
-	* @param	string $proxypassword
602
-	* @access   public
603
-	*/
604
-	function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
605
-		$this->proxyhost = $proxyhost;
606
-		$this->proxyport = $proxyport;
607
-		$this->proxyusername = $proxyusername;
608
-		$this->proxypassword = $proxypassword;
609
-	}
585
+    /**
586
+     * get the SOAP response Header (parsed)
587
+     *
588
+     * @return	mixed
589
+     * @access   public
590
+     */
591
+    function getHeader(){
592
+        return $this->responseHeader;
593
+    }
610 594
 
611
-	/**
612
-	* if authenticating, set user credentials here
613
-	*
614
-	* @param    string $username
615
-	* @param    string $password
616
-	* @param	string $authtype (basic|digest|certificate|ntlm)
617
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
618
-	* @access   public
619
-	*/
620
-	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
621
-		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
622
-		$this->appendDebug($this->varDump($certRequest));
623
-		$this->username = $username;
624
-		$this->password = $password;
625
-		$this->authtype = $authtype;
626
-		$this->certRequest = $certRequest;
627
-	}
595
+    /**
596
+     * set proxy info here
597
+     *
598
+     * @param    string $proxyhost
599
+     * @param    string $proxyport
600
+     * @param	string $proxyusername
601
+     * @param	string $proxypassword
602
+     * @access   public
603
+     */
604
+    function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
605
+        $this->proxyhost = $proxyhost;
606
+        $this->proxyport = $proxyport;
607
+        $this->proxyusername = $proxyusername;
608
+        $this->proxypassword = $proxypassword;
609
+    }
628 610
 
629
-	/**
630
-	* use HTTP encoding
631
-	*
632
-	* @param    string $enc HTTP encoding
633
-	* @access   public
634
-	*/
635
-	function setHTTPEncoding($enc='gzip, deflate'){
636
-		$this->debug("setHTTPEncoding(\"$enc\")");
637
-		$this->http_encoding = $enc;
638
-	}
611
+    /**
612
+     * if authenticating, set user credentials here
613
+     *
614
+     * @param    string $username
615
+     * @param    string $password
616
+     * @param	string $authtype (basic|digest|certificate|ntlm)
617
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
618
+     * @access   public
619
+     */
620
+    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
621
+        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
622
+        $this->appendDebug($this->varDump($certRequest));
623
+        $this->username = $username;
624
+        $this->password = $password;
625
+        $this->authtype = $authtype;
626
+        $this->certRequest = $certRequest;
627
+    }
639 628
 
640
-	/**
641
-	* Set whether to try to use cURL connections if possible
642
-	*
643
-	* @param	boolean $use Whether to try to use cURL
644
-	* @access   public
645
-	*/
646
-	function setUseCURL($use) {
647
-		$this->debug("setUseCURL($use)");
648
-		$this->use_curl = $use;
649
-	}
629
+    /**
630
+     * use HTTP encoding
631
+     *
632
+     * @param    string $enc HTTP encoding
633
+     * @access   public
634
+     */
635
+    function setHTTPEncoding($enc='gzip, deflate'){
636
+        $this->debug("setHTTPEncoding(\"$enc\")");
637
+        $this->http_encoding = $enc;
638
+    }
650 639
 
651
-	/**
652
-	* use HTTP persistent connections if possible
653
-	*
654
-	* @access   public
655
-	*/
656
-	function useHTTPPersistentConnection(){
657
-		$this->debug("useHTTPPersistentConnection");
658
-		$this->persistentConnection = true;
659
-	}
640
+    /**
641
+     * Set whether to try to use cURL connections if possible
642
+     *
643
+     * @param	boolean $use Whether to try to use cURL
644
+     * @access   public
645
+     */
646
+    function setUseCURL($use) {
647
+        $this->debug("setUseCURL($use)");
648
+        $this->use_curl = $use;
649
+    }
660 650
 
661
-	/**
662
-	* gets the default RPC parameter setting.
663
-	* If true, default is that call params are like RPC even for document style.
664
-	* Each call() can override this value.
665
-	*
666
-	* This is no longer used.
667
-	*
668
-	* @return boolean
669
-	* @access public
670
-	* @deprecated
671
-	*/
672
-	function getDefaultRpcParams() {
673
-		return $this->defaultRpcParams;
674
-	}
651
+    /**
652
+     * use HTTP persistent connections if possible
653
+     *
654
+     * @access   public
655
+     */
656
+    function useHTTPPersistentConnection(){
657
+        $this->debug("useHTTPPersistentConnection");
658
+        $this->persistentConnection = true;
659
+    }
675 660
 
676
-	/**
677
-	* sets the default RPC parameter setting.
678
-	* If true, default is that call params are like RPC even for document style
679
-	* Each call() can override this value.
680
-	*
681
-	* This is no longer used.
682
-	*
683
-	* @param    boolean $rpcParams
684
-	* @access public
685
-	* @deprecated
686
-	*/
687
-	function setDefaultRpcParams($rpcParams) {
688
-		$this->defaultRpcParams = $rpcParams;
689
-	}
661
+    /**
662
+     * gets the default RPC parameter setting.
663
+     * If true, default is that call params are like RPC even for document style.
664
+     * Each call() can override this value.
665
+     *
666
+     * This is no longer used.
667
+     *
668
+     * @return boolean
669
+     * @access public
670
+     * @deprecated
671
+     */
672
+    function getDefaultRpcParams() {
673
+        return $this->defaultRpcParams;
674
+    }
690 675
 
691
-	/**
692
-	* dynamically creates an instance of a proxy class,
693
-	* allowing user to directly call methods from wsdl
694
-	*
695
-	* @return   object soap_proxy object
696
-	* @access   public
697
-	*/
698
-	function getProxy() {
699
-		$r = rand();
700
-		$evalStr = $this->_getProxyClassCode($r);
701
-		//$this->debug("proxy class: $evalStr");
702
-		if ($this->getError()) {
703
-			$this->debug("Error from _getProxyClassCode, so return NULL");
704
-			return null;
705
-		}
706
-		// eval the class
707
-		eval($evalStr);
708
-		// instantiate proxy object
709
-		eval("\$proxy = new nusoap_proxy_$r('');");
710
-		// transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
711
-		$proxy->endpointType = 'wsdl';
712
-		$proxy->wsdlFile = $this->wsdlFile;
713
-		$proxy->wsdl = $this->wsdl;
714
-		$proxy->operations = $this->operations;
715
-		$proxy->defaultRpcParams = $this->defaultRpcParams;
716
-		// transfer other state
717
-		$proxy->soap_defencoding = $this->soap_defencoding;
718
-		$proxy->username = $this->username;
719
-		$proxy->password = $this->password;
720
-		$proxy->authtype = $this->authtype;
721
-		$proxy->certRequest = $this->certRequest;
722
-		$proxy->requestHeaders = $this->requestHeaders;
723
-		$proxy->endpoint = $this->endpoint;
724
-		$proxy->forceEndpoint = $this->forceEndpoint;
725
-		$proxy->proxyhost = $this->proxyhost;
726
-		$proxy->proxyport = $this->proxyport;
727
-		$proxy->proxyusername = $this->proxyusername;
728
-		$proxy->proxypassword = $this->proxypassword;
729
-		$proxy->http_encoding = $this->http_encoding;
730
-		$proxy->timeout = $this->timeout;
731
-		$proxy->response_timeout = $this->response_timeout;
732
-		$proxy->persistentConnection = &$this->persistentConnection;
733
-		$proxy->decode_utf8 = $this->decode_utf8;
734
-		$proxy->curl_options = $this->curl_options;
735
-		$proxy->bindingType = $this->bindingType;
736
-		$proxy->use_curl = $this->use_curl;
737
-		return $proxy;
738
-	}
676
+    /**
677
+     * sets the default RPC parameter setting.
678
+     * If true, default is that call params are like RPC even for document style
679
+     * Each call() can override this value.
680
+     *
681
+     * This is no longer used.
682
+     *
683
+     * @param    boolean $rpcParams
684
+     * @access public
685
+     * @deprecated
686
+     */
687
+    function setDefaultRpcParams($rpcParams) {
688
+        $this->defaultRpcParams = $rpcParams;
689
+    }
690
+
691
+    /**
692
+     * dynamically creates an instance of a proxy class,
693
+     * allowing user to directly call methods from wsdl
694
+     *
695
+     * @return   object soap_proxy object
696
+     * @access   public
697
+     */
698
+    function getProxy() {
699
+        $r = rand();
700
+        $evalStr = $this->_getProxyClassCode($r);
701
+        //$this->debug("proxy class: $evalStr");
702
+        if ($this->getError()) {
703
+            $this->debug("Error from _getProxyClassCode, so return NULL");
704
+            return null;
705
+        }
706
+        // eval the class
707
+        eval($evalStr);
708
+        // instantiate proxy object
709
+        eval("\$proxy = new nusoap_proxy_$r('');");
710
+        // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice
711
+        $proxy->endpointType = 'wsdl';
712
+        $proxy->wsdlFile = $this->wsdlFile;
713
+        $proxy->wsdl = $this->wsdl;
714
+        $proxy->operations = $this->operations;
715
+        $proxy->defaultRpcParams = $this->defaultRpcParams;
716
+        // transfer other state
717
+        $proxy->soap_defencoding = $this->soap_defencoding;
718
+        $proxy->username = $this->username;
719
+        $proxy->password = $this->password;
720
+        $proxy->authtype = $this->authtype;
721
+        $proxy->certRequest = $this->certRequest;
722
+        $proxy->requestHeaders = $this->requestHeaders;
723
+        $proxy->endpoint = $this->endpoint;
724
+        $proxy->forceEndpoint = $this->forceEndpoint;
725
+        $proxy->proxyhost = $this->proxyhost;
726
+        $proxy->proxyport = $this->proxyport;
727
+        $proxy->proxyusername = $this->proxyusername;
728
+        $proxy->proxypassword = $this->proxypassword;
729
+        $proxy->http_encoding = $this->http_encoding;
730
+        $proxy->timeout = $this->timeout;
731
+        $proxy->response_timeout = $this->response_timeout;
732
+        $proxy->persistentConnection = &$this->persistentConnection;
733
+        $proxy->decode_utf8 = $this->decode_utf8;
734
+        $proxy->curl_options = $this->curl_options;
735
+        $proxy->bindingType = $this->bindingType;
736
+        $proxy->use_curl = $this->use_curl;
737
+        return $proxy;
738
+    }
739 739
 
740
-	/**
741
-	* dynamically creates proxy class code
742
-	*
743
-	* @return   string PHP/NuSOAP code for the proxy class
744
-	* @access   private
745
-	*/
746
-	function _getProxyClassCode($r) {
747
-		$this->debug("in getProxy endpointType=$this->endpointType");
748
-		$this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
749
-		if ($this->endpointType != 'wsdl') {
750
-			$evalStr = 'A proxy can only be created for a WSDL client';
751
-			$this->setError($evalStr);
752
-			$evalStr = "echo \"$evalStr\";";
753
-			return $evalStr;
754
-		}
755
-		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
756
-			$this->loadWSDL();
757
-			if ($this->getError()) {
758
-				return "echo \"" . $this->getError() . "\";";
759
-			}
760
-		}
761
-		$evalStr = '';
762
-		foreach ($this->operations as $operation => $opData) {
763
-			if ($operation != '') {
764
-				// create param string and param comment string
765
-				if (sizeof($opData['input']['parts']) > 0) {
766
-					$paramStr = '';
767
-					$paramArrayStr = '';
768
-					$paramCommentStr = '';
769
-					foreach ($opData['input']['parts'] as $name => $type) {
770
-						$paramStr .= "\$$name, ";
771
-						$paramArrayStr .= "'$name' => \$$name, ";
772
-						$paramCommentStr .= "$type \$$name, ";
773
-					}
774
-					$paramStr = substr($paramStr, 0, strlen($paramStr)-2);
775
-					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
776
-					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
777
-				} else {
778
-					$paramStr = '';
779
-					$paramArrayStr = '';
780
-					$paramCommentStr = 'void';
781
-				}
782
-				$opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
783
-				$evalStr .= "// $paramCommentStr
740
+    /**
741
+     * dynamically creates proxy class code
742
+     *
743
+     * @return   string PHP/NuSOAP code for the proxy class
744
+     * @access   private
745
+     */
746
+    function _getProxyClassCode($r) {
747
+        $this->debug("in getProxy endpointType=$this->endpointType");
748
+        $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
749
+        if ($this->endpointType != 'wsdl') {
750
+            $evalStr = 'A proxy can only be created for a WSDL client';
751
+            $this->setError($evalStr);
752
+            $evalStr = "echo \"$evalStr\";";
753
+            return $evalStr;
754
+        }
755
+        if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
756
+            $this->loadWSDL();
757
+            if ($this->getError()) {
758
+                return "echo \"" . $this->getError() . "\";";
759
+            }
760
+        }
761
+        $evalStr = '';
762
+        foreach ($this->operations as $operation => $opData) {
763
+            if ($operation != '') {
764
+                // create param string and param comment string
765
+                if (sizeof($opData['input']['parts']) > 0) {
766
+                    $paramStr = '';
767
+                    $paramArrayStr = '';
768
+                    $paramCommentStr = '';
769
+                    foreach ($opData['input']['parts'] as $name => $type) {
770
+                        $paramStr .= "\$$name, ";
771
+                        $paramArrayStr .= "'$name' => \$$name, ";
772
+                        $paramCommentStr .= "$type \$$name, ";
773
+                    }
774
+                    $paramStr = substr($paramStr, 0, strlen($paramStr)-2);
775
+                    $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
776
+                    $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
777
+                } else {
778
+                    $paramStr = '';
779
+                    $paramArrayStr = '';
780
+                    $paramCommentStr = 'void';
781
+                }
782
+                $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
783
+                $evalStr .= "// $paramCommentStr
784 784
 	function " . str_replace('.', '__', $operation) . "($paramStr) {
785 785
 		\$params = array($paramArrayStr);
786 786
 		return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
787 787
 	}
788 788
 	";
789
-				unset($paramStr);
790
-				unset($paramCommentStr);
791
-			}
792
-		}
793
-		$evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
789
+                unset($paramStr);
790
+                unset($paramCommentStr);
791
+            }
792
+        }
793
+        $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
794 794
 	'.$evalStr.'
795 795
 }';
796
-		return $evalStr;
797
-	}
796
+        return $evalStr;
797
+    }
798 798
 
799
-	/**
800
-	* dynamically creates proxy class code
801
-	*
802
-	* @return   string PHP/NuSOAP code for the proxy class
803
-	* @access   public
804
-	*/
805
-	function getProxyClassCode() {
806
-		$r = rand();
807
-		return $this->_getProxyClassCode($r);
808
-	}
799
+    /**
800
+     * dynamically creates proxy class code
801
+     *
802
+     * @return   string PHP/NuSOAP code for the proxy class
803
+     * @access   public
804
+     */
805
+    function getProxyClassCode() {
806
+        $r = rand();
807
+        return $this->_getProxyClassCode($r);
808
+    }
809 809
 
810
-	/**
811
-	* gets the HTTP body for the current request.
812
-	*
813
-	* @param string $soapmsg The SOAP payload
814
-	* @return string The HTTP body, which includes the SOAP payload
815
-	* @access private
816
-	*/
817
-	function getHTTPBody($soapmsg) {
818
-		return $soapmsg;
819
-	}
810
+    /**
811
+     * gets the HTTP body for the current request.
812
+     *
813
+     * @param string $soapmsg The SOAP payload
814
+     * @return string The HTTP body, which includes the SOAP payload
815
+     * @access private
816
+     */
817
+    function getHTTPBody($soapmsg) {
818
+        return $soapmsg;
819
+    }
820 820
 
821
-	/**
822
-	* gets the HTTP content type for the current request.
823
-	*
824
-	* Note: getHTTPBody must be called before this.
825
-	*
826
-	* @return string the HTTP content type for the current request.
827
-	* @access private
828
-	*/
829
-	function getHTTPContentType() {
830
-		return 'text/xml';
831
-	}
821
+    /**
822
+     * gets the HTTP content type for the current request.
823
+     *
824
+     * Note: getHTTPBody must be called before this.
825
+     *
826
+     * @return string the HTTP content type for the current request.
827
+     * @access private
828
+     */
829
+    function getHTTPContentType() {
830
+        return 'text/xml';
831
+    }
832 832
 
833
-	/**
834
-	* gets the HTTP content type charset for the current request.
835
-	* returns false for non-text content types.
836
-	*
837
-	* Note: getHTTPBody must be called before this.
838
-	*
839
-	* @return string the HTTP content type charset for the current request.
840
-	* @access private
841
-	*/
842
-	function getHTTPContentTypeCharset() {
843
-		return $this->soap_defencoding;
844
-	}
833
+    /**
834
+     * gets the HTTP content type charset for the current request.
835
+     * returns false for non-text content types.
836
+     *
837
+     * Note: getHTTPBody must be called before this.
838
+     *
839
+     * @return string the HTTP content type charset for the current request.
840
+     * @access private
841
+     */
842
+    function getHTTPContentTypeCharset() {
843
+        return $this->soap_defencoding;
844
+    }
845 845
 
846
-	/*
846
+    /*
847 847
 	* whether or not parser should decode utf8 element content
848 848
     *
849 849
     * @return   always returns true
850 850
     * @access   public
851 851
     */
852 852
     function decodeUTF8($bool){
853
-		$this->decode_utf8 = $bool;
854
-		return true;
853
+        $this->decode_utf8 = $bool;
854
+        return true;
855 855
     }
856 856
 
857
-	/**
858
-	 * adds a new Cookie into $this->cookies array
859
-	 *
860
-	 * @param	string $name Cookie Name
861
-	 * @param	string $value Cookie Value
862
-	 * @return	boolean if cookie-set was successful returns true, else false
863
-	 * @access	public
864
-	 */
865
-	function setCookie($name, $value) {
866
-		if (strlen($name) == 0) {
867
-			return false;
868
-		}
869
-		$this->cookies[] = array('name' => $name, 'value' => $value);
870
-		return true;
871
-	}
857
+    /**
858
+     * adds a new Cookie into $this->cookies array
859
+     *
860
+     * @param	string $name Cookie Name
861
+     * @param	string $value Cookie Value
862
+     * @return	boolean if cookie-set was successful returns true, else false
863
+     * @access	public
864
+     */
865
+    function setCookie($name, $value) {
866
+        if (strlen($name) == 0) {
867
+            return false;
868
+        }
869
+        $this->cookies[] = array('name' => $name, 'value' => $value);
870
+        return true;
871
+    }
872 872
 
873
-	/**
874
-	 * gets all Cookies
875
-	 *
876
-	 * @return   array with all internal cookies
877
-	 * @access   public
878
-	 */
879
-	function getCookies() {
880
-		return $this->cookies;
881
-	}
873
+    /**
874
+     * gets all Cookies
875
+     *
876
+     * @return   array with all internal cookies
877
+     * @access   public
878
+     */
879
+    function getCookies() {
880
+        return $this->cookies;
881
+    }
882 882
 
883
-	/**
884
-	 * checks all Cookies and delete those which are expired
885
-	 *
886
-	 * @return   boolean always return true
887
-	 * @access   private
888
-	 */
889
-	function checkCookies() {
890
-		if (sizeof($this->cookies) == 0) {
891
-			return true;
892
-		}
893
-		$this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
894
-		$curr_cookies = $this->cookies;
895
-		$this->cookies = array();
896
-		foreach ($curr_cookies as $cookie) {
897
-			if (! is_array($cookie)) {
898
-				$this->debug('Remove cookie that is not an array');
899
-				continue;
900
-			}
901
-			if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
902
-				if (strtotime($cookie['expires']) > time()) {
903
-					$this->cookies[] = $cookie;
904
-				} else {
905
-					$this->debug('Remove expired cookie ' . $cookie['name']);
906
-				}
907
-			} else {
908
-				$this->cookies[] = $cookie;
909
-			}
910
-		}
911
-		$this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
912
-		return true;
913
-	}
883
+    /**
884
+     * checks all Cookies and delete those which are expired
885
+     *
886
+     * @return   boolean always return true
887
+     * @access   private
888
+     */
889
+    function checkCookies() {
890
+        if (sizeof($this->cookies) == 0) {
891
+            return true;
892
+        }
893
+        $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
894
+        $curr_cookies = $this->cookies;
895
+        $this->cookies = array();
896
+        foreach ($curr_cookies as $cookie) {
897
+            if (! is_array($cookie)) {
898
+                $this->debug('Remove cookie that is not an array');
899
+                continue;
900
+            }
901
+            if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
902
+                if (strtotime($cookie['expires']) > time()) {
903
+                    $this->cookies[] = $cookie;
904
+                } else {
905
+                    $this->debug('Remove expired cookie ' . $cookie['name']);
906
+                }
907
+            } else {
908
+                $this->cookies[] = $cookie;
909
+            }
910
+        }
911
+        $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
912
+        return true;
913
+    }
914 914
 
915
-	/**
916
-	 * updates the current cookies with a new set
917
-	 *
918
-	 * @param	array $cookies new cookies with which to update current ones
919
-	 * @return	boolean always return true
920
-	 * @access	private
921
-	 */
922
-	function UpdateCookies($cookies) {
923
-		if (sizeof($this->cookies) == 0) {
924
-			// no existing cookies: take whatever is new
925
-			if (sizeof($cookies) > 0) {
926
-				$this->debug('Setting new cookie(s)');
927
-				$this->cookies = $cookies;
928
-			}
929
-			return true;
930
-		}
931
-		if (sizeof($cookies) == 0) {
932
-			// no new cookies: keep what we've got
933
-			return true;
934
-		}
935
-		// merge
936
-		foreach ($cookies as $newCookie) {
937
-			if (!is_array($newCookie)) {
938
-				continue;
939
-			}
940
-			if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
941
-				continue;
942
-			}
943
-			$newName = $newCookie['name'];
944
-
945
-			$found = false;
946
-			for ($i = 0; $i < count($this->cookies); $i++) {
947
-				$cookie = $this->cookies[$i];
948
-				if (!is_array($cookie)) {
949
-					continue;
950
-				}
951
-				if (!isset($cookie['name'])) {
952
-					continue;
953
-				}
954
-				if ($newName != $cookie['name']) {
955
-					continue;
956
-				}
957
-				$newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
958
-				$domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
959
-				if ($newDomain != $domain) {
960
-					continue;
961
-				}
962
-				$newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
963
-				$path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
964
-				if ($newPath != $path) {
965
-					continue;
966
-				}
967
-				$this->cookies[$i] = $newCookie;
968
-				$found = true;
969
-				$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
970
-				break;
971
-			}
972
-			if (! $found) {
973
-				$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
974
-				$this->cookies[] = $newCookie;
975
-			}
976
-		}
977
-		return true;
978
-	}
915
+    /**
916
+     * updates the current cookies with a new set
917
+     *
918
+     * @param	array $cookies new cookies with which to update current ones
919
+     * @return	boolean always return true
920
+     * @access	private
921
+     */
922
+    function UpdateCookies($cookies) {
923
+        if (sizeof($this->cookies) == 0) {
924
+            // no existing cookies: take whatever is new
925
+            if (sizeof($cookies) > 0) {
926
+                $this->debug('Setting new cookie(s)');
927
+                $this->cookies = $cookies;
928
+            }
929
+            return true;
930
+        }
931
+        if (sizeof($cookies) == 0) {
932
+            // no new cookies: keep what we've got
933
+            return true;
934
+        }
935
+        // merge
936
+        foreach ($cookies as $newCookie) {
937
+            if (!is_array($newCookie)) {
938
+                continue;
939
+            }
940
+            if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
941
+                continue;
942
+            }
943
+            $newName = $newCookie['name'];
944
+
945
+            $found = false;
946
+            for ($i = 0; $i < count($this->cookies); $i++) {
947
+                $cookie = $this->cookies[$i];
948
+                if (!is_array($cookie)) {
949
+                    continue;
950
+                }
951
+                if (!isset($cookie['name'])) {
952
+                    continue;
953
+                }
954
+                if ($newName != $cookie['name']) {
955
+                    continue;
956
+                }
957
+                $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN';
958
+                $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN';
959
+                if ($newDomain != $domain) {
960
+                    continue;
961
+                }
962
+                $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH';
963
+                $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH';
964
+                if ($newPath != $path) {
965
+                    continue;
966
+                }
967
+                $this->cookies[$i] = $newCookie;
968
+                $found = true;
969
+                $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
970
+                break;
971
+            }
972
+            if (! $found) {
973
+                $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
974
+                $this->cookies[] = $newCookie;
975
+            }
976
+        }
977
+        return true;
978
+    }
979 979
 }
980 980
 
981 981
 if (!extension_loaded('soap')) {
982
-	/**
983
-	 *	For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
984
-	 */
985
-	class soapclient extends nusoap_client {
986
-	}
982
+    /**
983
+     *	For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded.
984
+     */
985
+    class soapclient extends nusoap_client {
986
+    }
987 987
 }
988 988
 ?>
Please login to merge, or discard this patch.
Spacing   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -22,37 +22,37 @@  discard block
 block discarded – undo
22 22
 */
23 23
 class nusoap_client extends nusoap_base
24 24
 {
25
-	var $username = '';				// Username for HTTP authentication
26
-	var $password = '';				// Password for HTTP authentication
27
-	var $authtype = '';				// Type of HTTP authentication
28
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
29
-	var $requestHeaders = false;	// SOAP headers in request (text)
30
-	var $responseHeaders = '';		// SOAP headers from response (incomplete namespace resolution) (text)
31
-	var $responseHeader = NULL;		// SOAP Header from response (parsed)
32
-	var $document = '';				// SOAP body response portion (incomplete namespace resolution) (text)
25
+	var $username = ''; // Username for HTTP authentication
26
+	var $password = ''; // Password for HTTP authentication
27
+	var $authtype = ''; // Type of HTTP authentication
28
+	var $certRequest = array(); // Certificate for HTTP SSL authentication
29
+	var $requestHeaders = false; // SOAP headers in request (text)
30
+	var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text)
31
+	var $responseHeader = NULL; // SOAP Header from response (parsed)
32
+	var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text)
33 33
 	var $endpoint;
34
-	var $forceEndpoint = '';		// overrides WSDL endpoint
34
+	var $forceEndpoint = ''; // overrides WSDL endpoint
35 35
     var $proxyhost = '';
36 36
     var $proxyport = '';
37 37
 	var $proxyusername = '';
38 38
 	var $proxypassword = '';
39
-	var $portName = '';				// port name to use in WSDL
40
-    var $xml_encoding = '';			// character set encoding of incoming (response) messages
39
+	var $portName = ''; // port name to use in WSDL
40
+    var $xml_encoding = ''; // character set encoding of incoming (response) messages
41 41
 	var $http_encoding = false;
42
-	var $timeout = 0;				// HTTP connection timeout
43
-	var $response_timeout = 30;		// HTTP response timeout
44
-	var $endpointType = '';			// soap|wsdl, empty for WSDL initialization error
42
+	var $timeout = 0; // HTTP connection timeout
43
+	var $response_timeout = 30; // HTTP response timeout
44
+	var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error
45 45
 	var $persistentConnection = false;
46
-	var $defaultRpcParams = false;	// This is no longer used
47
-	var $request = '';				// HTTP request
48
-	var $response = '';				// HTTP response
49
-	var $responseData = '';			// SOAP payload of response
50
-	var $cookies = array();			// Cookies from response or for request
51
-    var $decode_utf8 = true;		// toggles whether the parser decodes element content w/ utf8_decode()
52
-	var $operations = array();		// WSDL operations, empty for WSDL initialization error
53
-	var $curl_options = array();	// User-specified cURL options
54
-	var $bindingType = '';			// WSDL operation binding type
55
-	var $use_curl = false;			// whether to always try to use cURL
46
+	var $defaultRpcParams = false; // This is no longer used
47
+	var $request = ''; // HTTP request
48
+	var $response = ''; // HTTP response
49
+	var $responseData = ''; // SOAP payload of response
50
+	var $cookies = array(); // Cookies from response or for request
51
+    var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode()
52
+	var $operations = array(); // WSDL operations, empty for WSDL initialization error
53
+	var $curl_options = array(); // User-specified cURL options
54
+	var $bindingType = ''; // WSDL operation binding type
55
+	var $use_curl = false; // whether to always try to use cURL
56 56
 
57 57
 	/*
58 58
 	 * fault related variables
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 	* @param	string $portName optional portName in WSDL document
93 93
 	* @access   public
94 94
 	*/
95
-	function __construct($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
95
+	function __construct($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') {
96 96
 		parent::__construct();
97 97
 		$this->endpoint = $endpoint;
98 98
 		$this->proxyhost = $proxyhost;
@@ -104,20 +104,20 @@  discard block
 block discarded – undo
104 104
 		$this->portName = $portName;
105 105
 
106 106
 		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
107
-		$this->appendDebug('endpoint=' . $this->varDump($endpoint));
107
+		$this->appendDebug('endpoint='.$this->varDump($endpoint));
108 108
 
109 109
 		// make values
110
-		if($wsdl){
110
+		if ($wsdl) {
111 111
 			if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
112 112
 				$this->wsdl = $endpoint;
113 113
 				$this->endpoint = $this->wsdl->wsdl;
114 114
 				$this->wsdlFile = $this->endpoint;
115
-				$this->debug('existing wsdl instance created from ' . $this->endpoint);
115
+				$this->debug('existing wsdl instance created from '.$this->endpoint);
116 116
 				$this->checkWSDL();
117 117
 			} else {
118 118
 				$this->wsdlFile = $this->endpoint;
119 119
 				$this->wsdl = null;
120
-				$this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
120
+				$this->debug('will use lazy evaluation of wsdl from '.$this->endpoint);
121 121
 			}
122 122
 			$this->endpointType = 'wsdl';
123 123
 		} else {
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	* @return	mixed	response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
152 152
 	* @access   public
153 153
 	*/
154
-	function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
154
+	function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') {
155 155
 		$this->operation = $operation;
156 156
 		$this->fault = false;
157 157
 		$this->setError('');
@@ -163,8 +163,8 @@  discard block
 block discarded – undo
163 163
 		$this->opData = array();
164 164
 
165 165
 		$this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
166
-		$this->appendDebug('params=' . $this->varDump($params));
167
-		$this->appendDebug('headers=' . $this->varDump($headers));
166
+		$this->appendDebug('params='.$this->varDump($params));
167
+		$this->appendDebug('headers='.$this->varDump($headers));
168 168
 		if ($headers) {
169 169
 			$this->requestHeaders = $headers;
170 170
 		}
@@ -174,25 +174,25 @@  discard block
 block discarded – undo
174 174
 				return false;
175 175
 		}
176 176
 		// serialize parameters
177
-		if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
177
+		if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) {
178 178
 			// use WSDL for operation
179 179
 			$this->opData = $opData;
180 180
 			$this->debug("found operation");
181
-			$this->appendDebug('opData=' . $this->varDump($opData));
181
+			$this->appendDebug('opData='.$this->varDump($opData));
182 182
 			if (isset($opData['soapAction'])) {
183 183
 				$soapAction = $opData['soapAction'];
184 184
 			}
185
-			if (! $this->forceEndpoint) {
185
+			if (!$this->forceEndpoint) {
186 186
 				$this->endpoint = $opData['endpoint'];
187 187
 			} else {
188 188
 				$this->endpoint = $this->forceEndpoint;
189 189
 			}
190
-			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] :	$namespace;
190
+			$namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace;
191 191
 			$style = $opData['style'];
192 192
 			$use = $opData['input']['use'];
193 193
 			// add ns to ns array
194
-			if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
195
-				$nsPrefix = 'ns' . rand(1000, 9999);
194
+			if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
195
+				$nsPrefix = 'ns'.rand(1000, 9999);
196 196
 				$this->wsdl->namespaces[$nsPrefix] = $namespace;
197 197
 			}
198 198
             $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace);
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 				$payload = $params;
203 203
 			} elseif (is_array($params)) {
204 204
 				$this->debug("serializing param array for WSDL operation $operation");
205
-				$payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType);
205
+				$payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType);
206 206
 			} else {
207 207
 				$this->debug('params must be array or string');
208 208
 				$this->setError('params must be array or string');
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 				$this->setError('wsdl error: '.$errstr);
222 222
 				return false;
223 223
 			}
224
-		} elseif($this->endpointType == 'wsdl') {
224
+		} elseif ($this->endpointType == 'wsdl') {
225 225
 			// operation not in WSDL
226 226
 			$this->appendDebug($this->wsdl->getDebug());
227 227
 			$this->wsdl->clearDebug();
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
 		} else {
232 232
 			// no WSDL
233 233
 			//$this->namespaces['ns1'] = $namespace;
234
-			$nsPrefix = 'ns' . rand(1000, 9999);
234
+			$nsPrefix = 'ns'.rand(1000, 9999);
235 235
 			// serialize
236 236
 			$payload = '';
237 237
 			if (is_string($params)) {
@@ -239,8 +239,8 @@  discard block
 block discarded – undo
239 239
 				$payload = $params;
240 240
 			} elseif (is_array($params)) {
241 241
 				$this->debug("serializing param array for operation $operation");
242
-				foreach($params as $k => $v){
243
-					$payload .= $this->serialize_val($v,$k,false,false,false,false,$use);
242
+				foreach ($params as $k => $v) {
243
+					$payload .= $this->serialize_val($v, $k, false, false, false, false, $use);
244 244
 				}
245 245
 			} else {
246 246
 				$this->debug('params must be array or string');
@@ -260,45 +260,45 @@  discard block
 block discarded – undo
260 260
 				$this->debug("wrapping RPC request with literal method element");
261 261
 				if ($namespace) {
262 262
 					// http://www.ws-i.org/Profiles/BasicProfile-1.1-2004-08-24.html R2735 says rpc/literal accessor elements should not be in a namespace
263
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
264
-								$payload .
263
+					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">".
264
+								$payload.
265 265
 								"</$nsPrefix:$operation>";
266 266
 				} else {
267
-					$payload = "<$operation>" . $payload . "</$operation>";
267
+					$payload = "<$operation>".$payload."</$operation>";
268 268
 				}
269 269
 			} else {
270 270
 				$this->debug("wrapping RPC request with encoded method element");
271 271
 				if ($namespace) {
272
-					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" .
273
-								$payload .
272
+					$payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">".
273
+								$payload.
274 274
 								"</$nsPrefix:$operation>";
275 275
 				} else {
276
-					$payload = "<$operation>" .
277
-								$payload .
276
+					$payload = "<$operation>".
277
+								$payload.
278 278
 								"</$operation>";
279 279
 				}
280 280
 			}
281 281
 		}
282 282
 		// serialize envelope
283
-		$soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle);
283
+		$soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle);
284 284
 		$this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
285
-		$this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
285
+		$this->debug('SOAP message length='.strlen($soapmsg).' contents (max 1000 bytes)='.substr($soapmsg, 0, 1000));
286 286
 		// send
287
-		$return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout);
288
-		if($errstr = $this->getError()){
287
+		$return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout);
288
+		if ($errstr = $this->getError()) {
289 289
 			$this->debug('Error: '.$errstr);
290 290
 			return false;
291 291
 		} else {
292 292
 			$this->return = $return;
293 293
 			$this->debug('sent message successfully and got a(n) '.gettype($return));
294
-           	$this->appendDebug('return=' . $this->varDump($return));
294
+           	$this->appendDebug('return='.$this->varDump($return));
295 295
 
296 296
 			// fault?
297
-			if(is_array($return) && isset($return['faultcode'])){
297
+			if (is_array($return) && isset($return['faultcode'])) {
298 298
 				$this->debug('got fault');
299 299
 				$this->setError($return['faultcode'].': '.$return['faultstring']);
300 300
 				$this->fault = true;
301
-				foreach($return as $k => $v){
301
+				foreach ($return as $k => $v) {
302 302
 					$this->$k = $v;
303 303
 					$this->debug("$k = $v<br>");
304 304
 				}
@@ -309,10 +309,10 @@  discard block
 block discarded – undo
309 309
 				return $return;
310 310
 			} else {
311 311
 				// array of return values
312
-				if(is_array($return)){
312
+				if (is_array($return)) {
313 313
 					// multiple 'out' parameters, which we return wrapped up
314 314
 					// in the array
315
-					if(sizeof($return) > 1){
315
+					if (sizeof($return) > 1) {
316 316
 						return $return;
317 317
 					}
318 318
 					// single 'out' parameter (normally the return value)
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 */
370 370
 	function loadWSDL() {
371 371
 		$this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
372
-		$this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
372
+		$this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
373 373
 		$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
374 374
 		$this->wsdl->fetchWSDL($this->wsdlFile);
375 375
 		$this->checkWSDL();
@@ -382,13 +382,13 @@  discard block
 block discarded – undo
382 382
 	* @return	array array of data pertaining to the operation
383 383
 	* @access   public
384 384
 	*/
385
-	function getOperationData($operation){
385
+	function getOperationData($operation) {
386 386
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
387 387
 			$this->loadWSDL();
388 388
 			if ($this->getError())
389 389
 				return false;
390 390
 		}
391
-		if(isset($this->operations[$operation])){
391
+		if (isset($this->operations[$operation])) {
392 392
 			return $this->operations[$operation];
393 393
 		}
394 394
 		$this->debug("No data for operation: $operation");
@@ -408,15 +408,15 @@  discard block
 block discarded – undo
408 408
 	* @return	mixed native PHP types.
409 409
 	* @access   private
410 410
 	*/
411
-	function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
411
+	function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) {
412 412
 		$this->checkCookies();
413 413
 		// detect transport
414
-		switch(true){
414
+		switch (true) {
415 415
 			// http(s)
416
-			case preg_match('/^http/',$this->endpoint):
416
+			case preg_match('/^http/', $this->endpoint):
417 417
 				$this->debug('transporting via HTTP');
418
-				if($this->persistentConnection == true && is_object($this->persistentConnection)){
419
-					$http =& $this->persistentConnection;
418
+				if ($this->persistentConnection == true && is_object($this->persistentConnection)) {
419
+					$http = & $this->persistentConnection;
420 420
 				} else {
421 421
 					$http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl);
422 422
 					if ($this->persistentConnection) {
@@ -425,27 +425,27 @@  discard block
 block discarded – undo
425 425
 				}
426 426
 				$http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset());
427 427
 				$http->setSOAPAction($soapaction);
428
-				if($this->proxyhost && $this->proxyport){
429
-					$http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
428
+				if ($this->proxyhost && $this->proxyport) {
429
+					$http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
430 430
 				}
431
-                if($this->authtype != '') {
431
+                if ($this->authtype != '') {
432 432
 					$http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
433 433
 				}
434
-				if($this->http_encoding != ''){
434
+				if ($this->http_encoding != '') {
435 435
 					$http->setEncoding($this->http_encoding);
436 436
 				}
437 437
 				$this->debug('sending message, length='.strlen($msg));
438
-				if(preg_match('/^http:/',$this->endpoint)){
438
+				if (preg_match('/^http:/', $this->endpoint)) {
439 439
 				//if(strpos($this->endpoint,'http:')){
440
-					$this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
441
-				} elseif(preg_match('/^https/',$this->endpoint)){
440
+					$this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies);
441
+				} elseif (preg_match('/^https/', $this->endpoint)) {
442 442
 				//} elseif(strpos($this->endpoint,'https:')){
443 443
 					//if(phpversion() == '4.3.0-dev'){
444 444
 						//$response = $http->send($msg,$timeout,$response_timeout);
445 445
                    		//$this->request = $http->outgoing_payload;
446 446
 						//$this->response = $http->incoming_payload;
447 447
 					//} else
448
-					$this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies);
448
+					$this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies);
449 449
 				} else {
450 450
 					$this->setError('no http/s in endpoint url');
451 451
 				}
@@ -462,13 +462,13 @@  discard block
 block discarded – undo
462 462
 					}
463 463
 				}
464 464
 
465
-				if($err = $http->getError()){
465
+				if ($err = $http->getError()) {
466 466
 					$this->setError('HTTP Error: '.$err);
467 467
 					return false;
468
-				} elseif($this->getError()){
468
+				} elseif ($this->getError()) {
469 469
 					return false;
470 470
 				} else {
471
-					$this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
471
+					$this->debug('got response, length='.strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
472 472
 					return $this->parseResponse($http->incoming_headers, $this->responseData);
473 473
 				}
474 474
 			break;
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 	* @access   private
489 489
 	*/
490 490
     function parseResponse($headers, $data) {
491
-		$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
491
+		$this->debug('Entering parseResponse() for data of length '.strlen($data).' headers:');
492 492
 		$this->appendDebug($this->varDump($headers));
493 493
     	if (!isset($headers['content-type'])) {
494 494
 			$this->setError('Response not of type text/xml (no content-type header)');
495 495
 			return false;
496 496
     	}
497 497
 		if (!strstr($headers['content-type'], 'text/xml')) {
498
-			$this->setError('Response not of type text/xml: ' . $headers['content-type']);
498
+			$this->setError('Response not of type text/xml: '.$headers['content-type']);
499 499
 			return false;
500 500
 		}
501 501
 		if (strpos($headers['content-type'], '=')) {
502 502
 			$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
503
-			$this->debug('Got response encoding: ' . $enc);
504
-			if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
503
+			$this->debug('Got response encoding: '.$enc);
504
+			if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
505 505
 				$this->xml_encoding = strtoupper($enc);
506 506
 			} else {
507 507
 				$this->xml_encoding = 'US-ASCII';
@@ -510,13 +510,13 @@  discard block
 block discarded – undo
510 510
 			// should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1
511 511
 			$this->xml_encoding = 'ISO-8859-1';
512 512
 		}
513
-		$this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
514
-		$parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8);
513
+		$this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
514
+		$parser = new nusoap_parser($data, $this->xml_encoding, $this->operation, $this->decode_utf8);
515 515
 		// add parser debug data to our debug
516 516
 		$this->appendDebug($parser->getDebug());
517 517
 		// if parse errors
518
-		if($errstr = $parser->getError()){
519
-			$this->setError( $errstr);
518
+		if ($errstr = $parser->getError()) {
519
+			$this->setError($errstr);
520 520
 			// destroy the parser object
521 521
 			unset($parser);
522 522
 			return false;
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	* @param	mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers
567 567
 	* @access   public
568 568
 	*/
569
-	function setHeaders($headers){
569
+	function setHeaders($headers) {
570 570
 		$this->debug("setHeaders headers=");
571 571
 		$this->appendDebug($this->varDump($headers));
572 572
 		$this->requestHeaders = $headers;
@@ -578,7 +578,7 @@  discard block
 block discarded – undo
578 578
 	* @return	string
579 579
 	* @access   public
580 580
 	*/
581
-	function getHeaders(){
581
+	function getHeaders() {
582 582
 		return $this->responseHeaders;
583 583
 	}
584 584
 
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
 	* @return	mixed
589 589
 	* @access   public
590 590
 	*/
591
-	function getHeader(){
591
+	function getHeader() {
592 592
 		return $this->responseHeader;
593 593
 	}
594 594
 
@@ -632,7 +632,7 @@  discard block
 block discarded – undo
632 632
 	* @param    string $enc HTTP encoding
633 633
 	* @access   public
634 634
 	*/
635
-	function setHTTPEncoding($enc='gzip, deflate'){
635
+	function setHTTPEncoding($enc = 'gzip, deflate') {
636 636
 		$this->debug("setHTTPEncoding(\"$enc\")");
637 637
 		$this->http_encoding = $enc;
638 638
 	}
@@ -653,7 +653,7 @@  discard block
 block discarded – undo
653 653
 	*
654 654
 	* @access   public
655 655
 	*/
656
-	function useHTTPPersistentConnection(){
656
+	function useHTTPPersistentConnection() {
657 657
 		$this->debug("useHTTPPersistentConnection");
658 658
 		$this->persistentConnection = true;
659 659
 	}
@@ -745,7 +745,7 @@  discard block
 block discarded – undo
745 745
 	*/
746 746
 	function _getProxyClassCode($r) {
747 747
 		$this->debug("in getProxy endpointType=$this->endpointType");
748
-		$this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
748
+		$this->appendDebug("wsdl=".$this->varDump($this->wsdl));
749 749
 		if ($this->endpointType != 'wsdl') {
750 750
 			$evalStr = 'A proxy can only be created for a WSDL client';
751 751
 			$this->setError($evalStr);
@@ -755,7 +755,7 @@  discard block
 block discarded – undo
755 755
 		if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
756 756
 			$this->loadWSDL();
757 757
 			if ($this->getError()) {
758
-				return "echo \"" . $this->getError() . "\";";
758
+				return "echo \"".$this->getError()."\";";
759 759
 			}
760 760
 		}
761 761
 		$evalStr = '';
@@ -771,9 +771,9 @@  discard block
 block discarded – undo
771 771
 						$paramArrayStr .= "'$name' => \$$name, ";
772 772
 						$paramCommentStr .= "$type \$$name, ";
773 773
 					}
774
-					$paramStr = substr($paramStr, 0, strlen($paramStr)-2);
775
-					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2);
776
-					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2);
774
+					$paramStr = substr($paramStr, 0, strlen($paramStr) - 2);
775
+					$paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2);
776
+					$paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2);
777 777
 				} else {
778 778
 					$paramStr = '';
779 779
 					$paramArrayStr = '';
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
 				}
782 782
 				$opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace'];
783 783
 				$evalStr .= "// $paramCommentStr
784
-	function " . str_replace('.', '__', $operation) . "($paramStr) {
784
+	function ".str_replace('.', '__', $operation)."($paramStr) {
785 785
 		\$params = array($paramArrayStr);
786 786
 		return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
787 787
 	}
@@ -849,7 +849,7 @@  discard block
 block discarded – undo
849 849
     * @return   always returns true
850 850
     * @access   public
851 851
     */
852
-    function decodeUTF8($bool){
852
+    function decodeUTF8($bool) {
853 853
 		$this->decode_utf8 = $bool;
854 854
 		return true;
855 855
     }
@@ -890,19 +890,19 @@  discard block
 block discarded – undo
890 890
 		if (sizeof($this->cookies) == 0) {
891 891
 			return true;
892 892
 		}
893
-		$this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
893
+		$this->debug('checkCookie: check '.sizeof($this->cookies).' cookies');
894 894
 		$curr_cookies = $this->cookies;
895 895
 		$this->cookies = array();
896 896
 		foreach ($curr_cookies as $cookie) {
897
-			if (! is_array($cookie)) {
897
+			if (!is_array($cookie)) {
898 898
 				$this->debug('Remove cookie that is not an array');
899 899
 				continue;
900 900
 			}
901
-			if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
901
+			if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
902 902
 				if (strtotime($cookie['expires']) > time()) {
903 903
 					$this->cookies[] = $cookie;
904 904
 				} else {
905
-					$this->debug('Remove expired cookie ' . $cookie['name']);
905
+					$this->debug('Remove expired cookie '.$cookie['name']);
906 906
 				}
907 907
 			} else {
908 908
 				$this->cookies[] = $cookie;
@@ -966,11 +966,11 @@  discard block
 block discarded – undo
966 966
 				}
967 967
 				$this->cookies[$i] = $newCookie;
968 968
 				$found = true;
969
-				$this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
969
+				$this->debug('Update cookie '.$newName.'='.$newCookie['value']);
970 970
 				break;
971 971
 			}
972
-			if (! $found) {
973
-				$this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
972
+			if (!$found) {
973
+				$this->debug('Add cookie '.$newName.'='.$newCookie['value']);
974 974
 				$this->cookies[] = $newCookie;
975 975
 			}
976 976
 		}
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.soap_transport_http.php 3 patches
Braces   +39 added lines, -29 removed lines patch added patch discarded remove patch
@@ -159,10 +159,12 @@  discard block
 block discarded – undo
159 159
 	* @access	private
160 160
 	*/
161 161
 	function io_method() {
162
-		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
163
-			return 'curl';
164
-		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
165
-			return 'socket';
162
+		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm')) {
163
+					return 'curl';
164
+		}
165
+		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm')) {
166
+					return 'socket';
167
+		}
166 168
 		return 'unknown';
167 169
 	}
168 170
 
@@ -246,30 +248,36 @@  discard block
 block discarded – undo
246 248
 			return false;
247 249
 		}
248 250
 		// Avoid warnings when PHP does not have these options
249
-		if (defined('CURLOPT_CONNECTIONTIMEOUT'))
250
-			$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
251
-		else
252
-			$CURLOPT_CONNECTIONTIMEOUT = 78;
253
-		if (defined('CURLOPT_HTTPAUTH'))
254
-			$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
255
-		else
256
-			$CURLOPT_HTTPAUTH = 107;
257
-		if (defined('CURLOPT_PROXYAUTH'))
258
-			$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
259
-		else
260
-			$CURLOPT_PROXYAUTH = 111;
261
-		if (defined('CURLAUTH_BASIC'))
262
-			$CURLAUTH_BASIC = CURLAUTH_BASIC;
263
-		else
264
-			$CURLAUTH_BASIC = 1;
265
-		if (defined('CURLAUTH_DIGEST'))
266
-			$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
267
-		else
268
-			$CURLAUTH_DIGEST = 2;
269
-		if (defined('CURLAUTH_NTLM'))
270
-			$CURLAUTH_NTLM = CURLAUTH_NTLM;
271
-		else
272
-			$CURLAUTH_NTLM = 8;
251
+		if (defined('CURLOPT_CONNECTIONTIMEOUT')) {
252
+					$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
253
+		} else {
254
+					$CURLOPT_CONNECTIONTIMEOUT = 78;
255
+		}
256
+		if (defined('CURLOPT_HTTPAUTH')) {
257
+					$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
258
+		} else {
259
+					$CURLOPT_HTTPAUTH = 107;
260
+		}
261
+		if (defined('CURLOPT_PROXYAUTH')) {
262
+					$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
263
+		} else {
264
+					$CURLOPT_PROXYAUTH = 111;
265
+		}
266
+		if (defined('CURLAUTH_BASIC')) {
267
+					$CURLAUTH_BASIC = CURLAUTH_BASIC;
268
+		} else {
269
+					$CURLAUTH_BASIC = 1;
270
+		}
271
+		if (defined('CURLAUTH_DIGEST')) {
272
+					$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
273
+		} else {
274
+					$CURLAUTH_DIGEST = 2;
275
+		}
276
+		if (defined('CURLAUTH_NTLM')) {
277
+					$CURLAUTH_NTLM = CURLAUTH_NTLM;
278
+		} else {
279
+					$CURLAUTH_NTLM = 8;
280
+		}
273 281
 
274 282
 		$this->debug('connect using cURL');
275 283
 		// init CURL
@@ -612,7 +620,9 @@  discard block
 block discarded – undo
612 620
 								'HTTP/1.0 200 Connection established');
613 621
 		foreach ($skipHeaders as $hd) {
614 622
 			$prefix = substr($data, 0, strlen($hd));
615
-			if ($prefix == $hd) return true;
623
+			if ($prefix == $hd) {
624
+			    return true;
625
+			}
616 626
 		}
617 627
 
618 628
 		return false;
Please login to merge, or discard this patch.
Indentation   +1262 added lines, -1262 removed lines patch added patch discarded remove patch
@@ -11,171 +11,171 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class soap_transport_http extends nusoap_base
13 13
 {
14
-	var $url = '';
15
-	var $uri = '';
16
-	var $digest_uri = '';
17
-	var $scheme = '';
18
-	var $host = '';
19
-	var $port = '';
20
-	var $path = '';
21
-	var $request_method = 'POST';
22
-	var $protocol_version = '1.0';
23
-	var $encoding = '';
24
-	var $outgoing_headers = array();
25
-	var $incoming_headers = array();
26
-	var $incoming_cookies = array();
27
-	var $outgoing_payload = '';
28
-	var $incoming_payload = '';
29
-	var $response_status_line;	// HTTP response status line
30
-	var $useSOAPAction = true;
31
-	var $persistentConnection = false;
32
-	var $ch = false;	// cURL handle
33
-	var $ch_options = array();	// cURL custom options
34
-	var $use_curl = false;		// force cURL use
35
-	var $proxy = null;			// proxy information (associative array)
36
-	var $username = '';
37
-	var $password = '';
38
-	var $authtype = '';
39
-	var $digestRequest = array();
40
-	var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
41
-								// cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
42
-								// sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
43
-								// sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
44
-								// passphrase: SSL key password/passphrase
45
-								// certpassword: SSL certificate password
46
-								// verifypeer: default is 1
47
-								// verifyhost: default is 1
48
-
49
-	/**
50
-	* constructor
51
-	*
52
-	* @param string $url The URL to which to connect
53
-	* @param array $curl_options User-specified cURL options
54
-	* @param boolean $use_curl Whether to try to force cURL use
55
-	* @access public
56
-	*/
57
-	function __construct($url, $curl_options = NULL, $use_curl = false){
58
-		parent::__construct();
59
-		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
60
-		$this->appendDebug($this->varDump($curl_options));
61
-		$this->setURL($url);
62
-		if (is_array($curl_options)) {
63
-			$this->ch_options = $curl_options;
64
-		}
65
-		$this->use_curl = $use_curl;
66
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
67
-		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
68
-	}
69
-
70
-	/**
71
-	* sets a cURL option
72
-	*
73
-	* @param	mixed $option The cURL option (always integer?)
74
-	* @param	mixed $value The cURL option value
75
-	* @access   private
76
-	*/
77
-	function setCurlOption($option, $value) {
78
-		$this->debug("setCurlOption option=$option, value=");
79
-		$this->appendDebug($this->varDump($value));
80
-		curl_setopt($this->ch, $option, $value);
81
-	}
82
-
83
-	/**
84
-	* sets an HTTP header
85
-	*
86
-	* @param string $name The name of the header
87
-	* @param string $value The value of the header
88
-	* @access private
89
-	*/
90
-	function setHeader($name, $value) {
91
-		$this->outgoing_headers[$name] = $value;
92
-		$this->debug("set header $name: $value");
93
-	}
94
-
95
-	/**
96
-	* unsets an HTTP header
97
-	*
98
-	* @param string $name The name of the header
99
-	* @access private
100
-	*/
101
-	function unsetHeader($name) {
102
-		if (isset($this->outgoing_headers[$name])) {
103
-			$this->debug("unset header $name");
104
-			unset($this->outgoing_headers[$name]);
105
-		}
106
-	}
107
-
108
-	/**
109
-	* sets the URL to which to connect
110
-	*
111
-	* @param string $url The URL to which to connect
112
-	* @access private
113
-	*/
114
-	function setURL($url) {
115
-		$this->url = $url;
116
-
117
-		$u = parse_url($url);
118
-		foreach($u as $k => $v){
119
-			$this->debug("parsed URL $k = $v");
120
-			$this->$k = $v;
121
-		}
122
-
123
-		// add any GET params to path
124
-		if(isset($u['query']) && $u['query'] != ''){
14
+    var $url = '';
15
+    var $uri = '';
16
+    var $digest_uri = '';
17
+    var $scheme = '';
18
+    var $host = '';
19
+    var $port = '';
20
+    var $path = '';
21
+    var $request_method = 'POST';
22
+    var $protocol_version = '1.0';
23
+    var $encoding = '';
24
+    var $outgoing_headers = array();
25
+    var $incoming_headers = array();
26
+    var $incoming_cookies = array();
27
+    var $outgoing_payload = '';
28
+    var $incoming_payload = '';
29
+    var $response_status_line;	// HTTP response status line
30
+    var $useSOAPAction = true;
31
+    var $persistentConnection = false;
32
+    var $ch = false;	// cURL handle
33
+    var $ch_options = array();	// cURL custom options
34
+    var $use_curl = false;		// force cURL use
35
+    var $proxy = null;			// proxy information (associative array)
36
+    var $username = '';
37
+    var $password = '';
38
+    var $authtype = '';
39
+    var $digestRequest = array();
40
+    var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
41
+                                // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
42
+                                // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
43
+                                // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
44
+                                // passphrase: SSL key password/passphrase
45
+                                // certpassword: SSL certificate password
46
+                                // verifypeer: default is 1
47
+                                // verifyhost: default is 1
48
+
49
+    /**
50
+     * constructor
51
+     *
52
+     * @param string $url The URL to which to connect
53
+     * @param array $curl_options User-specified cURL options
54
+     * @param boolean $use_curl Whether to try to force cURL use
55
+     * @access public
56
+     */
57
+    function __construct($url, $curl_options = NULL, $use_curl = false){
58
+        parent::__construct();
59
+        $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
60
+        $this->appendDebug($this->varDump($curl_options));
61
+        $this->setURL($url);
62
+        if (is_array($curl_options)) {
63
+            $this->ch_options = $curl_options;
64
+        }
65
+        $this->use_curl = $use_curl;
66
+        preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
67
+        $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
68
+    }
69
+
70
+    /**
71
+     * sets a cURL option
72
+     *
73
+     * @param	mixed $option The cURL option (always integer?)
74
+     * @param	mixed $value The cURL option value
75
+     * @access   private
76
+     */
77
+    function setCurlOption($option, $value) {
78
+        $this->debug("setCurlOption option=$option, value=");
79
+        $this->appendDebug($this->varDump($value));
80
+        curl_setopt($this->ch, $option, $value);
81
+    }
82
+
83
+    /**
84
+     * sets an HTTP header
85
+     *
86
+     * @param string $name The name of the header
87
+     * @param string $value The value of the header
88
+     * @access private
89
+     */
90
+    function setHeader($name, $value) {
91
+        $this->outgoing_headers[$name] = $value;
92
+        $this->debug("set header $name: $value");
93
+    }
94
+
95
+    /**
96
+     * unsets an HTTP header
97
+     *
98
+     * @param string $name The name of the header
99
+     * @access private
100
+     */
101
+    function unsetHeader($name) {
102
+        if (isset($this->outgoing_headers[$name])) {
103
+            $this->debug("unset header $name");
104
+            unset($this->outgoing_headers[$name]);
105
+        }
106
+    }
107
+
108
+    /**
109
+     * sets the URL to which to connect
110
+     *
111
+     * @param string $url The URL to which to connect
112
+     * @access private
113
+     */
114
+    function setURL($url) {
115
+        $this->url = $url;
116
+
117
+        $u = parse_url($url);
118
+        foreach($u as $k => $v){
119
+            $this->debug("parsed URL $k = $v");
120
+            $this->$k = $v;
121
+        }
122
+
123
+        // add any GET params to path
124
+        if(isset($u['query']) && $u['query'] != ''){
125 125
             $this->path .= '?' . $u['query'];
126
-		}
127
-
128
-		// set default port
129
-		if(!isset($u['port'])){
130
-			if($u['scheme'] == 'https'){
131
-				$this->port = 443;
132
-			} else {
133
-				$this->port = 80;
134
-			}
135
-		}
136
-
137
-		$this->uri = $this->path;
138
-		$this->digest_uri = $this->uri;
139
-
140
-		// build headers
141
-		if (!isset($u['port'])) {
142
-			$this->setHeader('Host', $this->host);
143
-		} else {
144
-			$this->setHeader('Host', $this->host.':'.$this->port);
145
-		}
146
-
147
-		if (isset($u['user']) && $u['user'] != '') {
148
-			$this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
149
-		}
150
-	}
151
-
152
-	/**
153
-	* gets the I/O method to use
154
-	*
155
-	* @return	string	I/O method to use (socket|curl|unknown)
156
-	* @access	private
157
-	*/
158
-	function io_method() {
159
-		if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
160
-			return 'curl';
161
-		if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
162
-			return 'socket';
163
-		return 'unknown';
164
-	}
165
-
166
-	/**
167
-	* establish an HTTP connection
168
-	*
169
-	* @param    integer $timeout set connection timeout in seconds
170
-	* @param	integer $response_timeout set response timeout in seconds
171
-	* @return	boolean true if connected, false if not
172
-	* @access   private
173
-	*/
174
-	function connect($connection_timeout=0,$response_timeout=30){
175
-	  	// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
176
-	  	// "regular" socket.
177
-	  	// TODO: disabled for now because OpenSSL must be *compiled* in (not just
178
-	  	//       loaded), and until PHP5 stream_get_wrappers is not available.
126
+        }
127
+
128
+        // set default port
129
+        if(!isset($u['port'])){
130
+            if($u['scheme'] == 'https'){
131
+                $this->port = 443;
132
+            } else {
133
+                $this->port = 80;
134
+            }
135
+        }
136
+
137
+        $this->uri = $this->path;
138
+        $this->digest_uri = $this->uri;
139
+
140
+        // build headers
141
+        if (!isset($u['port'])) {
142
+            $this->setHeader('Host', $this->host);
143
+        } else {
144
+            $this->setHeader('Host', $this->host.':'.$this->port);
145
+        }
146
+
147
+        if (isset($u['user']) && $u['user'] != '') {
148
+            $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : '');
149
+        }
150
+    }
151
+
152
+    /**
153
+     * gets the I/O method to use
154
+     *
155
+     * @return	string	I/O method to use (socket|curl|unknown)
156
+     * @access	private
157
+     */
158
+    function io_method() {
159
+        if ($this->use_curl || ($this->scheme == 'https') || ($this->scheme == 'http' && $this->authtype == 'ntlm') || ($this->scheme == 'http' && is_array($this->proxy) && $this->proxy['authtype'] == 'ntlm'))
160
+            return 'curl';
161
+        if (($this->scheme == 'http' || $this->scheme == 'ssl') && $this->authtype != 'ntlm' && (!is_array($this->proxy) || $this->proxy['authtype'] != 'ntlm'))
162
+            return 'socket';
163
+        return 'unknown';
164
+    }
165
+
166
+    /**
167
+     * establish an HTTP connection
168
+     *
169
+     * @param    integer $timeout set connection timeout in seconds
170
+     * @param	integer $response_timeout set response timeout in seconds
171
+     * @return	boolean true if connected, false if not
172
+     * @access   private
173
+     */
174
+    function connect($connection_timeout=0,$response_timeout=30){
175
+            // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
176
+            // "regular" socket.
177
+            // TODO: disabled for now because OpenSSL must be *compiled* in (not just
178
+            //       loaded), and until PHP5 stream_get_wrappers is not available.
179 179
 //	  	if ($this->scheme == 'https') {
180 180
 //		  	if (version_compare(phpversion(), '4.3.0') >= 0) {
181 181
 //		  		if (extension_loaded('openssl')) {
@@ -184,1120 +184,1120 @@  discard block
 block discarded – undo
184 184
 //		  		}
185 185
 //		  	}
186 186
 //		}
187
-		$this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
188
-	  if ($this->io_method() == 'socket') {
189
-		if (!is_array($this->proxy)) {
190
-			$host = $this->host;
191
-			$port = $this->port;
192
-		} else {
193
-			$host = $this->proxy['host'];
194
-			$port = $this->proxy['port'];
195
-		}
196
-
197
-		// use persistent connection
198
-		if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
199
-			if (!feof($this->fp)) {
200
-				$this->debug('Re-use persistent connection');
201
-				return true;
202
-			}
203
-			fclose($this->fp);
204
-			$this->debug('Closed persistent connection at EOF');
205
-		}
206
-
207
-		// munge host if using OpenSSL
208
-		if ($this->scheme == 'ssl') {
209
-			$host = 'ssl://' . $host;
210
-		}
211
-		$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
212
-
213
-		// open socket
214
-		if($connection_timeout > 0){
215
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
216
-		} else {
217
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
218
-		}
219
-
220
-		// test pointer
221
-		if(!$this->fp) {
222
-			$msg = 'Couldn\'t open socket connection to server ' . $this->url;
223
-			if ($this->errno) {
224
-				$msg .= ', Error ('.$this->errno.'): '.$this->error_str;
225
-			} else {
226
-				$msg .= ' prior to connect().  This is often a problem looking up the host name.';
227
-			}
228
-			$this->debug($msg);
229
-			$this->setError($msg);
230
-			return false;
231
-		}
232
-
233
-		// set response timeout
234
-		$this->debug('set response timeout to ' . $response_timeout);
235
-		socket_set_timeout( $this->fp, $response_timeout);
236
-
237
-		$this->debug('socket connected');
238
-		return true;
239
-	  } else if ($this->io_method() == 'curl') {
240
-		if (!extension_loaded('curl')) {
187
+        $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
188
+        if ($this->io_method() == 'socket') {
189
+        if (!is_array($this->proxy)) {
190
+            $host = $this->host;
191
+            $port = $this->port;
192
+        } else {
193
+            $host = $this->proxy['host'];
194
+            $port = $this->proxy['port'];
195
+        }
196
+
197
+        // use persistent connection
198
+        if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
199
+            if (!feof($this->fp)) {
200
+                $this->debug('Re-use persistent connection');
201
+                return true;
202
+            }
203
+            fclose($this->fp);
204
+            $this->debug('Closed persistent connection at EOF');
205
+        }
206
+
207
+        // munge host if using OpenSSL
208
+        if ($this->scheme == 'ssl') {
209
+            $host = 'ssl://' . $host;
210
+        }
211
+        $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
212
+
213
+        // open socket
214
+        if($connection_timeout > 0){
215
+            $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
216
+        } else {
217
+            $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
218
+        }
219
+
220
+        // test pointer
221
+        if(!$this->fp) {
222
+            $msg = 'Couldn\'t open socket connection to server ' . $this->url;
223
+            if ($this->errno) {
224
+                $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
225
+            } else {
226
+                $msg .= ' prior to connect().  This is often a problem looking up the host name.';
227
+            }
228
+            $this->debug($msg);
229
+            $this->setError($msg);
230
+            return false;
231
+        }
232
+
233
+        // set response timeout
234
+        $this->debug('set response timeout to ' . $response_timeout);
235
+        socket_set_timeout( $this->fp, $response_timeout);
236
+
237
+        $this->debug('socket connected');
238
+        return true;
239
+        } else if ($this->io_method() == 'curl') {
240
+        if (!extension_loaded('curl')) {
241 241
 //			$this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
242
-			$this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
243
-			return false;
244
-		}
245
-		// Avoid warnings when PHP does not have these options
246
-		if (defined('CURLOPT_CONNECTIONTIMEOUT'))
247
-			$CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
248
-		else
249
-			$CURLOPT_CONNECTIONTIMEOUT = 78;
250
-		if (defined('CURLOPT_HTTPAUTH'))
251
-			$CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
252
-		else
253
-			$CURLOPT_HTTPAUTH = 107;
254
-		if (defined('CURLOPT_PROXYAUTH'))
255
-			$CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
256
-		else
257
-			$CURLOPT_PROXYAUTH = 111;
258
-		if (defined('CURLAUTH_BASIC'))
259
-			$CURLAUTH_BASIC = CURLAUTH_BASIC;
260
-		else
261
-			$CURLAUTH_BASIC = 1;
262
-		if (defined('CURLAUTH_DIGEST'))
263
-			$CURLAUTH_DIGEST = CURLAUTH_DIGEST;
264
-		else
265
-			$CURLAUTH_DIGEST = 2;
266
-		if (defined('CURLAUTH_NTLM'))
267
-			$CURLAUTH_NTLM = CURLAUTH_NTLM;
268
-		else
269
-			$CURLAUTH_NTLM = 8;
270
-
271
-		$this->debug('connect using cURL');
272
-		// init CURL
273
-		$this->ch = curl_init();
274
-		// set url
275
-		$hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
276
-		// add path
277
-		$hostURL .= $this->path;
278
-		$this->setCurlOption(CURLOPT_URL, $hostURL);
279
-		// follow location headers (re-directs)
280
-		if (ini_get('safe_mode') || ini_get('open_basedir')) {
281
-			$this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
282
-			$this->debug('safe_mode = ');
283
-			$this->appendDebug($this->varDump(ini_get('safe_mode')));
284
-			$this->debug('open_basedir = ');
285
-			$this->appendDebug($this->varDump(ini_get('open_basedir')));
286
-		} else {
287
-			$this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
288
-		}
289
-		// ask for headers in the response output
290
-		$this->setCurlOption(CURLOPT_HEADER, 1);
291
-		// ask for the response output as the return value
292
-		$this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
293
-		// encode
294
-		// We manage this ourselves through headers and encoding
242
+            $this->setError('The PHP cURL Extension is required for HTTPS or NLTM.  You will need to re-build or update your PHP to include cURL or change php.ini to load the PHP cURL extension.');
243
+            return false;
244
+        }
245
+        // Avoid warnings when PHP does not have these options
246
+        if (defined('CURLOPT_CONNECTIONTIMEOUT'))
247
+            $CURLOPT_CONNECTIONTIMEOUT = CURLOPT_CONNECTIONTIMEOUT;
248
+        else
249
+            $CURLOPT_CONNECTIONTIMEOUT = 78;
250
+        if (defined('CURLOPT_HTTPAUTH'))
251
+            $CURLOPT_HTTPAUTH = CURLOPT_HTTPAUTH;
252
+        else
253
+            $CURLOPT_HTTPAUTH = 107;
254
+        if (defined('CURLOPT_PROXYAUTH'))
255
+            $CURLOPT_PROXYAUTH = CURLOPT_PROXYAUTH;
256
+        else
257
+            $CURLOPT_PROXYAUTH = 111;
258
+        if (defined('CURLAUTH_BASIC'))
259
+            $CURLAUTH_BASIC = CURLAUTH_BASIC;
260
+        else
261
+            $CURLAUTH_BASIC = 1;
262
+        if (defined('CURLAUTH_DIGEST'))
263
+            $CURLAUTH_DIGEST = CURLAUTH_DIGEST;
264
+        else
265
+            $CURLAUTH_DIGEST = 2;
266
+        if (defined('CURLAUTH_NTLM'))
267
+            $CURLAUTH_NTLM = CURLAUTH_NTLM;
268
+        else
269
+            $CURLAUTH_NTLM = 8;
270
+
271
+        $this->debug('connect using cURL');
272
+        // init CURL
273
+        $this->ch = curl_init();
274
+        // set url
275
+        $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host";
276
+        // add path
277
+        $hostURL .= $this->path;
278
+        $this->setCurlOption(CURLOPT_URL, $hostURL);
279
+        // follow location headers (re-directs)
280
+        if (ini_get('safe_mode') || ini_get('open_basedir')) {
281
+            $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
282
+            $this->debug('safe_mode = ');
283
+            $this->appendDebug($this->varDump(ini_get('safe_mode')));
284
+            $this->debug('open_basedir = ');
285
+            $this->appendDebug($this->varDump(ini_get('open_basedir')));
286
+        } else {
287
+            $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1);
288
+        }
289
+        // ask for headers in the response output
290
+        $this->setCurlOption(CURLOPT_HEADER, 1);
291
+        // ask for the response output as the return value
292
+        $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1);
293
+        // encode
294
+        // We manage this ourselves through headers and encoding
295 295
 //		if(function_exists('gzuncompress')){
296 296
 //			$this->setCurlOption(CURLOPT_ENCODING, 'deflate');
297 297
 //		}
298
-		// persistent connection
299
-		if ($this->persistentConnection) {
300
-			// I believe the following comment is now bogus, having applied to
301
-			// the code when it used CURLOPT_CUSTOMREQUEST to send the request.
302
-			// The way we send data, we cannot use persistent connections, since
303
-			// there will be some "junk" at the end of our request.
304
-			//$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
305
-			$this->persistentConnection = false;
306
-			$this->setHeader('Connection', 'close');
307
-		}
308
-		// set timeouts
309
-		if ($connection_timeout != 0) {
310
-			$this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
311
-		}
312
-		if ($response_timeout != 0) {
313
-			$this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
314
-		}
315
-
316
-		if ($this->scheme == 'https') {
317
-			$this->debug('set cURL SSL verify options');
318
-			// recent versions of cURL turn on peer/host checking by default,
319
-			// while PHP binaries are not compiled with a default location for the
320
-			// CA cert bundle, so disable peer/host checking.
321
-			//$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
322
-			$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
323
-			$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
324
-
325
-			// support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
326
-			if ($this->authtype == 'certificate') {
327
-				$this->debug('set cURL certificate options');
328
-				if (isset($this->certRequest['cainfofile'])) {
329
-					$this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
330
-				}
331
-				if (isset($this->certRequest['verifypeer'])) {
332
-					$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
333
-				} else {
334
-					$this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
335
-				}
336
-				if (isset($this->certRequest['verifyhost'])) {
337
-					$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
338
-				} else {
339
-					$this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
340
-				}
341
-				if (isset($this->certRequest['sslcertfile'])) {
342
-					$this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
343
-				}
344
-				if (isset($this->certRequest['sslkeyfile'])) {
345
-					$this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
346
-				}
347
-				if (isset($this->certRequest['passphrase'])) {
348
-					$this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
349
-				}
350
-				if (isset($this->certRequest['certpassword'])) {
351
-					$this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
352
-				}
353
-			}
354
-		}
355
-		if ($this->authtype && ($this->authtype != 'certificate')) {
356
-			if ($this->username) {
357
-				$this->debug('set cURL username/password');
358
-				$this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
359
-			}
360
-			if ($this->authtype == 'basic') {
361
-				$this->debug('set cURL for Basic authentication');
362
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
363
-			}
364
-			if ($this->authtype == 'digest') {
365
-				$this->debug('set cURL for digest authentication');
366
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
367
-			}
368
-			if ($this->authtype == 'ntlm') {
369
-				$this->debug('set cURL for NTLM authentication');
370
-				$this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
371
-			}
372
-		}
373
-		if (is_array($this->proxy)) {
374
-			$this->debug('set cURL proxy options');
375
-			if ($this->proxy['port'] != '') {
376
-				$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
377
-			} else {
378
-				$this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
379
-			}
380
-			if ($this->proxy['username'] || $this->proxy['password']) {
381
-				$this->debug('set cURL proxy authentication options');
382
-				$this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
383
-				if ($this->proxy['authtype'] == 'basic') {
384
-					$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
385
-				}
386
-				if ($this->proxy['authtype'] == 'ntlm') {
387
-					$this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
388
-				}
389
-			}
390
-		}
391
-		$this->debug('cURL connection set up');
392
-		return true;
393
-	  } else {
394
-		$this->setError('Unknown scheme ' . $this->scheme);
395
-		$this->debug('Unknown scheme ' . $this->scheme);
396
-		return false;
397
-	  }
398
-	}
399
-
400
-	/**
401
-	* sends the SOAP request and gets the SOAP response via HTTP[S]
402
-	*
403
-	* @param    string $data message data
404
-	* @param    integer $timeout set connection timeout in seconds
405
-	* @param	integer $response_timeout set response timeout in seconds
406
-	* @param	array $cookies cookies to send
407
-	* @return	string data
408
-	* @access   public
409
-	*/
410
-	function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
411
-
412
-		$this->debug('entered send() with data of length: '.strlen($data));
413
-
414
-		$this->tryagain = true;
415
-		$tries = 0;
416
-		while ($this->tryagain) {
417
-			$this->tryagain = false;
418
-			if ($tries++ < 2) {
419
-				// make connnection
420
-				if (!$this->connect($timeout, $response_timeout)){
421
-					return false;
422
-				}
423
-
424
-				// send request
425
-				if (!$this->sendRequest($data, $cookies)){
426
-					return false;
427
-				}
428
-
429
-				// get response
430
-				$respdata = $this->getResponse();
431
-			} else {
432
-				$this->setError("Too many tries to get an OK response ($this->response_status_line)");
433
-			}
434
-		}
435
-		$this->debug('end of send()');
436
-		return $respdata;
437
-	}
438
-
439
-
440
-	/**
441
-	* sends the SOAP request and gets the SOAP response via HTTPS using CURL
442
-	*
443
-	* @param    string $data message data
444
-	* @param    integer $timeout set connection timeout in seconds
445
-	* @param	integer $response_timeout set response timeout in seconds
446
-	* @param	array $cookies cookies to send
447
-	* @return	string data
448
-	* @access   public
449
-	* @deprecated
450
-	*/
451
-	function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
452
-		return $this->send($data, $timeout, $response_timeout, $cookies);
453
-	}
454
-
455
-	/**
456
-	* if authenticating, set user credentials here
457
-	*
458
-	* @param    string $username
459
-	* @param    string $password
460
-	* @param	string $authtype (basic|digest|certificate|ntlm)
461
-	* @param	array $digestRequest (keys must be nonce, nc, realm, qop)
462
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
463
-	* @access   public
464
-	*/
465
-	function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
466
-		$this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
467
-		$this->appendDebug($this->varDump($digestRequest));
468
-		$this->debug("certRequest=");
469
-		$this->appendDebug($this->varDump($certRequest));
470
-		// cf. RFC 2617
471
-		if ($authtype == 'basic') {
472
-			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
473
-		} elseif ($authtype == 'digest') {
474
-			if (isset($digestRequest['nonce'])) {
475
-				$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
476
-
477
-				// calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
478
-
479
-				// A1 = unq(username-value) ":" unq(realm-value) ":" passwd
480
-				$A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
481
-
482
-				// H(A1) = MD5(A1)
483
-				$HA1 = md5($A1);
484
-
485
-				// A2 = Method ":" digest-uri-value
486
-				$A2 = $this->request_method . ':' . $this->digest_uri;
487
-
488
-				// H(A2)
489
-				$HA2 =  md5($A2);
490
-
491
-				// KD(secret, data) = H(concat(secret, ":", data))
492
-				// if qop == auth:
493
-				// request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
494
-				//                              ":" nc-value
495
-				//                              ":" unq(cnonce-value)
496
-				//                              ":" unq(qop-value)
497
-				//                              ":" H(A2)
498
-				//                            ) <">
499
-				// if qop is missing,
500
-				// request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
501
-
502
-				$unhashedDigest = '';
503
-				$nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
504
-				$cnonce = $nonce;
505
-				if ($digestRequest['qop'] != '') {
506
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
507
-				} else {
508
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
509
-				}
510
-
511
-				$hashedDigest = md5($unhashedDigest);
512
-
513
-				$opaque = '';
514
-				if (isset($digestRequest['opaque'])) {
515
-					$opaque = ', opaque="' . $digestRequest['opaque'] . '"';
516
-				}
517
-
518
-				$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
519
-			}
520
-		} elseif ($authtype == 'certificate') {
521
-			$this->certRequest = $certRequest;
522
-			$this->debug('Authorization header not set for certificate');
523
-		} elseif ($authtype == 'ntlm') {
524
-			// do nothing
525
-			$this->debug('Authorization header not set for ntlm');
526
-		}
527
-		$this->username = $username;
528
-		$this->password = $password;
529
-		$this->authtype = $authtype;
530
-		$this->digestRequest = $digestRequest;
531
-	}
532
-
533
-	/**
534
-	* set the soapaction value
535
-	*
536
-	* @param    string $soapaction
537
-	* @access   public
538
-	*/
539
-	function setSOAPAction($soapaction) {
540
-		$this->setHeader('SOAPAction', '"' . $soapaction . '"');
541
-	}
542
-
543
-	/**
544
-	* use http encoding
545
-	*
546
-	* @param    string $enc encoding style. supported values: gzip, deflate, or both
547
-	* @access   public
548
-	*/
549
-	function setEncoding($enc='gzip, deflate') {
550
-		if (function_exists('gzdeflate')) {
551
-			$this->protocol_version = '1.1';
552
-			$this->setHeader('Accept-Encoding', $enc);
553
-			if (!isset($this->outgoing_headers['Connection'])) {
554
-				$this->setHeader('Connection', 'close');
555
-				$this->persistentConnection = false;
556
-			}
557
-			// deprecated as of PHP 5.3.0
558
-			//set_magic_quotes_runtime(0);
559
-			$this->encoding = $enc;
560
-		}
561
-	}
562
-
563
-	/**
564
-	* set proxy info here
565
-	*
566
-	* @param    string $proxyhost use an empty string to remove proxy
567
-	* @param    string $proxyport
568
-	* @param	string $proxyusername
569
-	* @param	string $proxypassword
570
-	* @param	string $proxyauthtype (basic|ntlm)
571
-	* @access   public
572
-	*/
573
-	function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
574
-		if ($proxyhost) {
575
-			$this->proxy = array(
576
-				'host' => $proxyhost,
577
-				'port' => $proxyport,
578
-				'username' => $proxyusername,
579
-				'password' => $proxypassword,
580
-				'authtype' => $proxyauthtype
581
-			);
582
-			if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
583
-				$this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
584
-			}
585
-		} else {
586
-			$this->debug('remove proxy');
587
-			$proxy = null;
588
-			unsetHeader('Proxy-Authorization');
589
-		}
590
-	}
591
-
592
-
593
-	/**
594
-	 * Test if the given string starts with a header that is to be skipped.
595
-	 * Skippable headers result from chunked transfer and proxy requests.
596
-	 *
597
-	 * @param	string $data The string to check.
598
-	 * @returns	boolean	Whether a skippable header was found.
599
-	 * @access	private
600
-	 */
601
-	function isSkippableCurlHeader(&$data) {
602
-		$skipHeaders = array(	'HTTP/1.1 100',
603
-								'HTTP/1.0 301',
604
-								'HTTP/1.1 301',
605
-								'HTTP/1.0 302',
606
-								'HTTP/1.1 302',
607
-								'HTTP/1.0 401',
608
-								'HTTP/1.1 401',
609
-								'HTTP/1.0 200 Connection established');
610
-		foreach ($skipHeaders as $hd) {
611
-			$prefix = substr($data, 0, strlen($hd));
612
-			if ($prefix == $hd) return true;
613
-		}
614
-
615
-		return false;
616
-	}
617
-
618
-	/**
619
-	* decode a string that is encoded w/ "chunked' transfer encoding
620
- 	* as defined in RFC2068 19.4.6
621
-	*
622
-	* @param    string $buffer
623
-	* @param    string $lb
624
-	* @returns	string
625
-	* @access   public
626
-	* @deprecated
627
-	*/
628
-	function decodeChunked($buffer, $lb){
629
-		// length := 0
630
-		$length = 0;
631
-		$new = '';
632
-
633
-		// read chunk-size, chunk-extension (if any) and CRLF
634
-		// get the position of the linebreak
635
-		$chunkend = strpos($buffer, $lb);
636
-		if ($chunkend == FALSE) {
637
-			$this->debug('no linebreak found in decodeChunked');
638
-			return $new;
639
-		}
640
-		$temp = substr($buffer,0,$chunkend);
641
-		$chunk_size = hexdec( trim($temp) );
642
-		$chunkstart = $chunkend + strlen($lb);
643
-		// while (chunk-size > 0) {
644
-		while ($chunk_size > 0) {
645
-			$this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
646
-			$chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
647
-
648
-			// Just in case we got a broken connection
649
-		  	if ($chunkend == FALSE) {
650
-		  	    $chunk = substr($buffer,$chunkstart);
651
-				// append chunk-data to entity-body
652
-		    	$new .= $chunk;
653
-		  	    $length += strlen($chunk);
654
-		  	    break;
655
-			}
656
-
657
-		  	// read chunk-data and CRLF
658
-		  	$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
659
-		  	// append chunk-data to entity-body
660
-		  	$new .= $chunk;
661
-		  	// length := length + chunk-size
662
-		  	$length += strlen($chunk);
663
-		  	// read chunk-size and CRLF
664
-		  	$chunkstart = $chunkend + strlen($lb);
665
-
666
-		  	$chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
667
-			if ($chunkend == FALSE) {
668
-				break; //Just in case we got a broken connection
669
-			}
670
-			$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
671
-			$chunk_size = hexdec( trim($temp) );
672
-			$chunkstart = $chunkend;
673
-		}
674
-		return $new;
675
-	}
676
-
677
-	/**
678
-	 * Writes the payload, including HTTP headers, to $this->outgoing_payload.
679
-	 *
680
-	 * @param	string $data HTTP body
681
-	 * @param	string $cookie_str data for HTTP Cookie header
682
-	 * @return	void
683
-	 * @access	private
684
-	 */
685
-	function buildPayload($data, $cookie_str = '') {
686
-		// Note: for cURL connections, $this->outgoing_payload is ignored,
687
-		// as is the Content-Length header, but these are still created as
688
-		// debugging guides.
689
-
690
-		// add content-length header
691
-		if ($this->request_method != 'GET') {
692
-			$this->setHeader('Content-Length', strlen($data));
693
-		}
694
-
695
-		// start building outgoing payload:
696
-		if ($this->proxy) {
697
-			$uri = $this->url;
698
-		} else {
699
-			$uri = $this->uri;
700
-		}
701
-		$req = "$this->request_method $uri HTTP/$this->protocol_version";
702
-		$this->debug("HTTP request: $req");
703
-		$this->outgoing_payload = "$req\r\n";
704
-
705
-		// loop thru headers, serializing
706
-		foreach($this->outgoing_headers as $k => $v){
707
-			$hdr = $k.': '.$v;
708
-			$this->debug("HTTP header: $hdr");
709
-			$this->outgoing_payload .= "$hdr\r\n";
710
-		}
711
-
712
-		// add any cookies
713
-		if ($cookie_str != '') {
714
-			$hdr = 'Cookie: '.$cookie_str;
715
-			$this->debug("HTTP header: $hdr");
716
-			$this->outgoing_payload .= "$hdr\r\n";
717
-		}
718
-
719
-		// header/body separator
720
-		$this->outgoing_payload .= "\r\n";
721
-
722
-		// add data
723
-		$this->outgoing_payload .= $data;
724
-	}
725
-
726
-	/**
727
-	* sends the SOAP request via HTTP[S]
728
-	*
729
-	* @param    string $data message data
730
-	* @param	array $cookies cookies to send
731
-	* @return	boolean	true if OK, false if problem
732
-	* @access   private
733
-	*/
734
-	function sendRequest($data, $cookies = NULL) {
735
-		// build cookie string
736
-		$cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
737
-
738
-		// build payload
739
-		$this->buildPayload($data, $cookie_str);
740
-
741
-	  if ($this->io_method() == 'socket') {
742
-		// send payload
743
-		if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
744
-			$this->setError('couldn\'t write message data to socket');
745
-			$this->debug('couldn\'t write message data to socket');
746
-			return false;
747
-		}
748
-		$this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
749
-		return true;
750
-	  } else if ($this->io_method() == 'curl') {
751
-		// set payload
752
-		// cURL does say this should only be the verb, and in fact it
753
-		// turns out that the URI and HTTP version are appended to this, which
754
-		// some servers refuse to work with (so we no longer use this method!)
755
-		//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
756
-		$curl_headers = array();
757
-		foreach($this->outgoing_headers as $k => $v){
758
-			if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
759
-				$this->debug("Skip cURL header $k: $v");
760
-			} else {
761
-				$curl_headers[] = "$k: $v";
762
-			}
763
-		}
764
-		if ($cookie_str != '') {
765
-			$curl_headers[] = 'Cookie: ' . $cookie_str;
766
-		}
767
-		$this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
768
-		$this->debug('set cURL HTTP headers');
769
-		if ($this->request_method == "POST") {
770
-	  		$this->setCurlOption(CURLOPT_POST, 1);
771
-	  		$this->setCurlOption(CURLOPT_POSTFIELDS, $data);
772
-			$this->debug('set cURL POST data');
773
-	  	} else {
774
-	  	}
775
-		// insert custom user-set cURL options
776
-		foreach ($this->ch_options as $key => $val) {
777
-			$this->setCurlOption($key, $val);
778
-		}
779
-
780
-		$this->debug('set cURL payload');
781
-		return true;
782
-	  }
783
-	}
784
-
785
-	/**
786
-	* gets the SOAP response via HTTP[S]
787
-	*
788
-	* @return	string the response (also sets member variables like incoming_payload)
789
-	* @access   private
790
-	*/
791
-	function getResponse(){
792
-		$this->incoming_payload = '';
793
-
794
-	  if ($this->io_method() == 'socket') {
795
-	    // loop until headers have been retrieved
796
-	    $data = '';
797
-	    while (!isset($lb)){
798
-
799
-			// We might EOF during header read.
800
-			if(feof($this->fp)) {
801
-				$this->incoming_payload = $data;
802
-				$this->debug('found no headers before EOF after length ' . strlen($data));
803
-				$this->debug("received before EOF:\n" . $data);
804
-				$this->setError('server failed to send headers');
805
-				return false;
806
-			}
807
-
808
-			$tmp = fgets($this->fp, 256);
809
-			$tmplen = strlen($tmp);
810
-			$this->debug("read line of $tmplen bytes: " . trim($tmp));
811
-
812
-			if ($tmplen == 0) {
813
-				$this->incoming_payload = $data;
814
-				$this->debug('socket read of headers timed out after length ' . strlen($data));
815
-				$this->debug("read before timeout: " . $data);
816
-				$this->setError('socket read of headers timed out');
817
-				return false;
818
-			}
819
-
820
-			$data .= $tmp;
821
-			$pos = strpos($data,"\r\n\r\n");
822
-			if($pos > 1){
823
-				$lb = "\r\n";
824
-			} else {
825
-				$pos = strpos($data,"\n\n");
826
-				if($pos > 1){
827
-					$lb = "\n";
828
-				}
829
-			}
830
-			// remove 100 headers
831
-			if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
832
-				unset($lb);
833
-				$data = '';
834
-			}//
835
-		}
836
-		// store header data
837
-		$this->incoming_payload .= $data;
838
-		$this->debug('found end of headers after length ' . strlen($data));
839
-		// process headers
840
-		$header_data = trim(substr($data,0,$pos));
841
-		$header_array = explode($lb,$header_data);
842
-		$this->incoming_headers = array();
843
-		$this->incoming_cookies = array();
844
-		foreach($header_array as $header_line){
845
-			$arr = explode(':',$header_line, 2);
846
-			if(count($arr) > 1){
847
-				$header_name = strtolower(trim($arr[0]));
848
-				$this->incoming_headers[$header_name] = trim($arr[1]);
849
-				if ($header_name == 'set-cookie') {
850
-					// TODO: allow multiple cookies from parseCookie
851
-					$cookie = $this->parseCookie(trim($arr[1]));
852
-					if ($cookie) {
853
-						$this->incoming_cookies[] = $cookie;
854
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
855
-					} else {
856
-						$this->debug('did not find cookie in ' . trim($arr[1]));
857
-					}
858
-    			}
859
-			} else if (isset($header_name)) {
860
-				// append continuation line to previous header
861
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
862
-			}
863
-		}
864
-
865
-		// loop until msg has been received
866
-		if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
867
-			$content_length =  2147483647;	// ignore any content-length header
868
-			$chunked = true;
869
-			$this->debug("want to read chunked content");
870
-		} elseif (isset($this->incoming_headers['content-length'])) {
871
-			$content_length = $this->incoming_headers['content-length'];
872
-			$chunked = false;
873
-			$this->debug("want to read content of length $content_length");
874
-		} else {
875
-			$content_length =  2147483647;
876
-			$chunked = false;
877
-			$this->debug("want to read content to EOF");
878
-		}
879
-		$data = '';
880
-		do {
881
-			if ($chunked) {
882
-				$tmp = fgets($this->fp, 256);
883
-				$tmplen = strlen($tmp);
884
-				$this->debug("read chunk line of $tmplen bytes");
885
-				if ($tmplen == 0) {
886
-					$this->incoming_payload = $data;
887
-					$this->debug('socket read of chunk length timed out after length ' . strlen($data));
888
-					$this->debug("read before timeout:\n" . $data);
889
-					$this->setError('socket read of chunk length timed out');
890
-					return false;
891
-				}
892
-				$content_length = hexdec(trim($tmp));
893
-				$this->debug("chunk length $content_length");
894
-			}
895
-			$strlen = 0;
896
-		    while (($strlen < $content_length) && (!feof($this->fp))) {
897
-		    	$readlen = min(8192, $content_length - $strlen);
898
-				$tmp = fread($this->fp, $readlen);
899
-				$tmplen = strlen($tmp);
900
-				$this->debug("read buffer of $tmplen bytes");
901
-				if (($tmplen == 0) && (!feof($this->fp))) {
902
-					$this->incoming_payload = $data;
903
-					$this->debug('socket read of body timed out after length ' . strlen($data));
904
-					$this->debug("read before timeout:\n" . $data);
905
-					$this->setError('socket read of body timed out');
906
-					return false;
907
-				}
908
-				$strlen += $tmplen;
909
-				$data .= $tmp;
910
-			}
911
-			if ($chunked && ($content_length > 0)) {
912
-				$tmp = fgets($this->fp, 256);
913
-				$tmplen = strlen($tmp);
914
-				$this->debug("read chunk terminator of $tmplen bytes");
915
-				if ($tmplen == 0) {
916
-					$this->incoming_payload = $data;
917
-					$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
918
-					$this->debug("read before timeout:\n" . $data);
919
-					$this->setError('socket read of chunk terminator timed out');
920
-					return false;
921
-				}
922
-			}
923
-		} while ($chunked && ($content_length > 0) && (!feof($this->fp)));
924
-		if (feof($this->fp)) {
925
-			$this->debug('read to EOF');
926
-		}
927
-		$this->debug('read body of length ' . strlen($data));
928
-		$this->incoming_payload .= $data;
929
-		$this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
930
-
931
-		// close filepointer
932
-		if(
933
-			(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
934
-			(! $this->persistentConnection) || feof($this->fp)){
935
-			fclose($this->fp);
936
-			$this->fp = false;
937
-			$this->debug('closed socket');
938
-		}
939
-
940
-		// connection was closed unexpectedly
941
-		if($this->incoming_payload == ''){
942
-			$this->setError('no response from server');
943
-			return false;
944
-		}
945
-
946
-		// decode transfer-encoding
298
+        // persistent connection
299
+        if ($this->persistentConnection) {
300
+            // I believe the following comment is now bogus, having applied to
301
+            // the code when it used CURLOPT_CUSTOMREQUEST to send the request.
302
+            // The way we send data, we cannot use persistent connections, since
303
+            // there will be some "junk" at the end of our request.
304
+            //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true);
305
+            $this->persistentConnection = false;
306
+            $this->setHeader('Connection', 'close');
307
+        }
308
+        // set timeouts
309
+        if ($connection_timeout != 0) {
310
+            $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout);
311
+        }
312
+        if ($response_timeout != 0) {
313
+            $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout);
314
+        }
315
+
316
+        if ($this->scheme == 'https') {
317
+            $this->debug('set cURL SSL verify options');
318
+            // recent versions of cURL turn on peer/host checking by default,
319
+            // while PHP binaries are not compiled with a default location for the
320
+            // CA cert bundle, so disable peer/host checking.
321
+            //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt');
322
+            $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0);
323
+            $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0);
324
+
325
+            // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo)
326
+            if ($this->authtype == 'certificate') {
327
+                $this->debug('set cURL certificate options');
328
+                if (isset($this->certRequest['cainfofile'])) {
329
+                    $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']);
330
+                }
331
+                if (isset($this->certRequest['verifypeer'])) {
332
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']);
333
+                } else {
334
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1);
335
+                }
336
+                if (isset($this->certRequest['verifyhost'])) {
337
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']);
338
+                } else {
339
+                    $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1);
340
+                }
341
+                if (isset($this->certRequest['sslcertfile'])) {
342
+                    $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']);
343
+                }
344
+                if (isset($this->certRequest['sslkeyfile'])) {
345
+                    $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']);
346
+                }
347
+                if (isset($this->certRequest['passphrase'])) {
348
+                    $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']);
349
+                }
350
+                if (isset($this->certRequest['certpassword'])) {
351
+                    $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']);
352
+                }
353
+            }
354
+        }
355
+        if ($this->authtype && ($this->authtype != 'certificate')) {
356
+            if ($this->username) {
357
+                $this->debug('set cURL username/password');
358
+                $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password");
359
+            }
360
+            if ($this->authtype == 'basic') {
361
+                $this->debug('set cURL for Basic authentication');
362
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC);
363
+            }
364
+            if ($this->authtype == 'digest') {
365
+                $this->debug('set cURL for digest authentication');
366
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST);
367
+            }
368
+            if ($this->authtype == 'ntlm') {
369
+                $this->debug('set cURL for NTLM authentication');
370
+                $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM);
371
+            }
372
+        }
373
+        if (is_array($this->proxy)) {
374
+            $this->debug('set cURL proxy options');
375
+            if ($this->proxy['port'] != '') {
376
+                $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']);
377
+            } else {
378
+                $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']);
379
+            }
380
+            if ($this->proxy['username'] || $this->proxy['password']) {
381
+                $this->debug('set cURL proxy authentication options');
382
+                $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']);
383
+                if ($this->proxy['authtype'] == 'basic') {
384
+                    $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC);
385
+                }
386
+                if ($this->proxy['authtype'] == 'ntlm') {
387
+                    $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM);
388
+                }
389
+            }
390
+        }
391
+        $this->debug('cURL connection set up');
392
+        return true;
393
+        } else {
394
+        $this->setError('Unknown scheme ' . $this->scheme);
395
+        $this->debug('Unknown scheme ' . $this->scheme);
396
+        return false;
397
+        }
398
+    }
399
+
400
+    /**
401
+     * sends the SOAP request and gets the SOAP response via HTTP[S]
402
+     *
403
+     * @param    string $data message data
404
+     * @param    integer $timeout set connection timeout in seconds
405
+     * @param	integer $response_timeout set response timeout in seconds
406
+     * @param	array $cookies cookies to send
407
+     * @return	string data
408
+     * @access   public
409
+     */
410
+    function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
411
+
412
+        $this->debug('entered send() with data of length: '.strlen($data));
413
+
414
+        $this->tryagain = true;
415
+        $tries = 0;
416
+        while ($this->tryagain) {
417
+            $this->tryagain = false;
418
+            if ($tries++ < 2) {
419
+                // make connnection
420
+                if (!$this->connect($timeout, $response_timeout)){
421
+                    return false;
422
+                }
423
+
424
+                // send request
425
+                if (!$this->sendRequest($data, $cookies)){
426
+                    return false;
427
+                }
428
+
429
+                // get response
430
+                $respdata = $this->getResponse();
431
+            } else {
432
+                $this->setError("Too many tries to get an OK response ($this->response_status_line)");
433
+            }
434
+        }
435
+        $this->debug('end of send()');
436
+        return $respdata;
437
+    }
438
+
439
+
440
+    /**
441
+     * sends the SOAP request and gets the SOAP response via HTTPS using CURL
442
+     *
443
+     * @param    string $data message data
444
+     * @param    integer $timeout set connection timeout in seconds
445
+     * @param	integer $response_timeout set response timeout in seconds
446
+     * @param	array $cookies cookies to send
447
+     * @return	string data
448
+     * @access   public
449
+     * @deprecated
450
+     */
451
+    function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
452
+        return $this->send($data, $timeout, $response_timeout, $cookies);
453
+    }
454
+
455
+    /**
456
+     * if authenticating, set user credentials here
457
+     *
458
+     * @param    string $username
459
+     * @param    string $password
460
+     * @param	string $authtype (basic|digest|certificate|ntlm)
461
+     * @param	array $digestRequest (keys must be nonce, nc, realm, qop)
462
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
463
+     * @access   public
464
+     */
465
+    function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
466
+        $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
467
+        $this->appendDebug($this->varDump($digestRequest));
468
+        $this->debug("certRequest=");
469
+        $this->appendDebug($this->varDump($certRequest));
470
+        // cf. RFC 2617
471
+        if ($authtype == 'basic') {
472
+            $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
473
+        } elseif ($authtype == 'digest') {
474
+            if (isset($digestRequest['nonce'])) {
475
+                $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
476
+
477
+                // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
478
+
479
+                // A1 = unq(username-value) ":" unq(realm-value) ":" passwd
480
+                $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
481
+
482
+                // H(A1) = MD5(A1)
483
+                $HA1 = md5($A1);
484
+
485
+                // A2 = Method ":" digest-uri-value
486
+                $A2 = $this->request_method . ':' . $this->digest_uri;
487
+
488
+                // H(A2)
489
+                $HA2 =  md5($A2);
490
+
491
+                // KD(secret, data) = H(concat(secret, ":", data))
492
+                // if qop == auth:
493
+                // request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
494
+                //                              ":" nc-value
495
+                //                              ":" unq(cnonce-value)
496
+                //                              ":" unq(qop-value)
497
+                //                              ":" H(A2)
498
+                //                            ) <">
499
+                // if qop is missing,
500
+                // request-digest  = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
501
+
502
+                $unhashedDigest = '';
503
+                $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
504
+                $cnonce = $nonce;
505
+                if ($digestRequest['qop'] != '') {
506
+                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
507
+                } else {
508
+                    $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
509
+                }
510
+
511
+                $hashedDigest = md5($unhashedDigest);
512
+
513
+                $opaque = '';
514
+                if (isset($digestRequest['opaque'])) {
515
+                    $opaque = ', opaque="' . $digestRequest['opaque'] . '"';
516
+                }
517
+
518
+                $this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
519
+            }
520
+        } elseif ($authtype == 'certificate') {
521
+            $this->certRequest = $certRequest;
522
+            $this->debug('Authorization header not set for certificate');
523
+        } elseif ($authtype == 'ntlm') {
524
+            // do nothing
525
+            $this->debug('Authorization header not set for ntlm');
526
+        }
527
+        $this->username = $username;
528
+        $this->password = $password;
529
+        $this->authtype = $authtype;
530
+        $this->digestRequest = $digestRequest;
531
+    }
532
+
533
+    /**
534
+     * set the soapaction value
535
+     *
536
+     * @param    string $soapaction
537
+     * @access   public
538
+     */
539
+    function setSOAPAction($soapaction) {
540
+        $this->setHeader('SOAPAction', '"' . $soapaction . '"');
541
+    }
542
+
543
+    /**
544
+     * use http encoding
545
+     *
546
+     * @param    string $enc encoding style. supported values: gzip, deflate, or both
547
+     * @access   public
548
+     */
549
+    function setEncoding($enc='gzip, deflate') {
550
+        if (function_exists('gzdeflate')) {
551
+            $this->protocol_version = '1.1';
552
+            $this->setHeader('Accept-Encoding', $enc);
553
+            if (!isset($this->outgoing_headers['Connection'])) {
554
+                $this->setHeader('Connection', 'close');
555
+                $this->persistentConnection = false;
556
+            }
557
+            // deprecated as of PHP 5.3.0
558
+            //set_magic_quotes_runtime(0);
559
+            $this->encoding = $enc;
560
+        }
561
+    }
562
+
563
+    /**
564
+     * set proxy info here
565
+     *
566
+     * @param    string $proxyhost use an empty string to remove proxy
567
+     * @param    string $proxyport
568
+     * @param	string $proxyusername
569
+     * @param	string $proxypassword
570
+     * @param	string $proxyauthtype (basic|ntlm)
571
+     * @access   public
572
+     */
573
+    function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
574
+        if ($proxyhost) {
575
+            $this->proxy = array(
576
+                'host' => $proxyhost,
577
+                'port' => $proxyport,
578
+                'username' => $proxyusername,
579
+                'password' => $proxypassword,
580
+                'authtype' => $proxyauthtype
581
+            );
582
+            if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
583
+                $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
584
+            }
585
+        } else {
586
+            $this->debug('remove proxy');
587
+            $proxy = null;
588
+            unsetHeader('Proxy-Authorization');
589
+        }
590
+    }
591
+
592
+
593
+    /**
594
+     * Test if the given string starts with a header that is to be skipped.
595
+     * Skippable headers result from chunked transfer and proxy requests.
596
+     *
597
+     * @param	string $data The string to check.
598
+     * @returns	boolean	Whether a skippable header was found.
599
+     * @access	private
600
+     */
601
+    function isSkippableCurlHeader(&$data) {
602
+        $skipHeaders = array(	'HTTP/1.1 100',
603
+                                'HTTP/1.0 301',
604
+                                'HTTP/1.1 301',
605
+                                'HTTP/1.0 302',
606
+                                'HTTP/1.1 302',
607
+                                'HTTP/1.0 401',
608
+                                'HTTP/1.1 401',
609
+                                'HTTP/1.0 200 Connection established');
610
+        foreach ($skipHeaders as $hd) {
611
+            $prefix = substr($data, 0, strlen($hd));
612
+            if ($prefix == $hd) return true;
613
+        }
614
+
615
+        return false;
616
+    }
617
+
618
+    /**
619
+     * decode a string that is encoded w/ "chunked' transfer encoding
620
+     * as defined in RFC2068 19.4.6
621
+     *
622
+     * @param    string $buffer
623
+     * @param    string $lb
624
+     * @returns	string
625
+     * @access   public
626
+     * @deprecated
627
+     */
628
+    function decodeChunked($buffer, $lb){
629
+        // length := 0
630
+        $length = 0;
631
+        $new = '';
632
+
633
+        // read chunk-size, chunk-extension (if any) and CRLF
634
+        // get the position of the linebreak
635
+        $chunkend = strpos($buffer, $lb);
636
+        if ($chunkend == FALSE) {
637
+            $this->debug('no linebreak found in decodeChunked');
638
+            return $new;
639
+        }
640
+        $temp = substr($buffer,0,$chunkend);
641
+        $chunk_size = hexdec( trim($temp) );
642
+        $chunkstart = $chunkend + strlen($lb);
643
+        // while (chunk-size > 0) {
644
+        while ($chunk_size > 0) {
645
+            $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
646
+            $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
647
+
648
+            // Just in case we got a broken connection
649
+                if ($chunkend == FALSE) {
650
+                    $chunk = substr($buffer,$chunkstart);
651
+                // append chunk-data to entity-body
652
+                $new .= $chunk;
653
+                    $length += strlen($chunk);
654
+                    break;
655
+            }
656
+
657
+                // read chunk-data and CRLF
658
+                $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
659
+                // append chunk-data to entity-body
660
+                $new .= $chunk;
661
+                // length := length + chunk-size
662
+                $length += strlen($chunk);
663
+                // read chunk-size and CRLF
664
+                $chunkstart = $chunkend + strlen($lb);
665
+
666
+                $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb);
667
+            if ($chunkend == FALSE) {
668
+                break; //Just in case we got a broken connection
669
+            }
670
+            $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
671
+            $chunk_size = hexdec( trim($temp) );
672
+            $chunkstart = $chunkend;
673
+        }
674
+        return $new;
675
+    }
676
+
677
+    /**
678
+     * Writes the payload, including HTTP headers, to $this->outgoing_payload.
679
+     *
680
+     * @param	string $data HTTP body
681
+     * @param	string $cookie_str data for HTTP Cookie header
682
+     * @return	void
683
+     * @access	private
684
+     */
685
+    function buildPayload($data, $cookie_str = '') {
686
+        // Note: for cURL connections, $this->outgoing_payload is ignored,
687
+        // as is the Content-Length header, but these are still created as
688
+        // debugging guides.
689
+
690
+        // add content-length header
691
+        if ($this->request_method != 'GET') {
692
+            $this->setHeader('Content-Length', strlen($data));
693
+        }
694
+
695
+        // start building outgoing payload:
696
+        if ($this->proxy) {
697
+            $uri = $this->url;
698
+        } else {
699
+            $uri = $this->uri;
700
+        }
701
+        $req = "$this->request_method $uri HTTP/$this->protocol_version";
702
+        $this->debug("HTTP request: $req");
703
+        $this->outgoing_payload = "$req\r\n";
704
+
705
+        // loop thru headers, serializing
706
+        foreach($this->outgoing_headers as $k => $v){
707
+            $hdr = $k.': '.$v;
708
+            $this->debug("HTTP header: $hdr");
709
+            $this->outgoing_payload .= "$hdr\r\n";
710
+        }
711
+
712
+        // add any cookies
713
+        if ($cookie_str != '') {
714
+            $hdr = 'Cookie: '.$cookie_str;
715
+            $this->debug("HTTP header: $hdr");
716
+            $this->outgoing_payload .= "$hdr\r\n";
717
+        }
718
+
719
+        // header/body separator
720
+        $this->outgoing_payload .= "\r\n";
721
+
722
+        // add data
723
+        $this->outgoing_payload .= $data;
724
+    }
725
+
726
+    /**
727
+     * sends the SOAP request via HTTP[S]
728
+     *
729
+     * @param    string $data message data
730
+     * @param	array $cookies cookies to send
731
+     * @return	boolean	true if OK, false if problem
732
+     * @access   private
733
+     */
734
+    function sendRequest($data, $cookies = NULL) {
735
+        // build cookie string
736
+        $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https')));
737
+
738
+        // build payload
739
+        $this->buildPayload($data, $cookie_str);
740
+
741
+        if ($this->io_method() == 'socket') {
742
+        // send payload
743
+        if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
744
+            $this->setError('couldn\'t write message data to socket');
745
+            $this->debug('couldn\'t write message data to socket');
746
+            return false;
747
+        }
748
+        $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
749
+        return true;
750
+        } else if ($this->io_method() == 'curl') {
751
+        // set payload
752
+        // cURL does say this should only be the verb, and in fact it
753
+        // turns out that the URI and HTTP version are appended to this, which
754
+        // some servers refuse to work with (so we no longer use this method!)
755
+        //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
756
+        $curl_headers = array();
757
+        foreach($this->outgoing_headers as $k => $v){
758
+            if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
759
+                $this->debug("Skip cURL header $k: $v");
760
+            } else {
761
+                $curl_headers[] = "$k: $v";
762
+            }
763
+        }
764
+        if ($cookie_str != '') {
765
+            $curl_headers[] = 'Cookie: ' . $cookie_str;
766
+        }
767
+        $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
768
+        $this->debug('set cURL HTTP headers');
769
+        if ($this->request_method == "POST") {
770
+                $this->setCurlOption(CURLOPT_POST, 1);
771
+                $this->setCurlOption(CURLOPT_POSTFIELDS, $data);
772
+            $this->debug('set cURL POST data');
773
+            } else {
774
+            }
775
+        // insert custom user-set cURL options
776
+        foreach ($this->ch_options as $key => $val) {
777
+            $this->setCurlOption($key, $val);
778
+        }
779
+
780
+        $this->debug('set cURL payload');
781
+        return true;
782
+        }
783
+    }
784
+
785
+    /**
786
+     * gets the SOAP response via HTTP[S]
787
+     *
788
+     * @return	string the response (also sets member variables like incoming_payload)
789
+     * @access   private
790
+     */
791
+    function getResponse(){
792
+        $this->incoming_payload = '';
793
+
794
+        if ($this->io_method() == 'socket') {
795
+        // loop until headers have been retrieved
796
+        $data = '';
797
+        while (!isset($lb)){
798
+
799
+            // We might EOF during header read.
800
+            if(feof($this->fp)) {
801
+                $this->incoming_payload = $data;
802
+                $this->debug('found no headers before EOF after length ' . strlen($data));
803
+                $this->debug("received before EOF:\n" . $data);
804
+                $this->setError('server failed to send headers');
805
+                return false;
806
+            }
807
+
808
+            $tmp = fgets($this->fp, 256);
809
+            $tmplen = strlen($tmp);
810
+            $this->debug("read line of $tmplen bytes: " . trim($tmp));
811
+
812
+            if ($tmplen == 0) {
813
+                $this->incoming_payload = $data;
814
+                $this->debug('socket read of headers timed out after length ' . strlen($data));
815
+                $this->debug("read before timeout: " . $data);
816
+                $this->setError('socket read of headers timed out');
817
+                return false;
818
+            }
819
+
820
+            $data .= $tmp;
821
+            $pos = strpos($data,"\r\n\r\n");
822
+            if($pos > 1){
823
+                $lb = "\r\n";
824
+            } else {
825
+                $pos = strpos($data,"\n\n");
826
+                if($pos > 1){
827
+                    $lb = "\n";
828
+                }
829
+            }
830
+            // remove 100 headers
831
+            if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
832
+                unset($lb);
833
+                $data = '';
834
+            }//
835
+        }
836
+        // store header data
837
+        $this->incoming_payload .= $data;
838
+        $this->debug('found end of headers after length ' . strlen($data));
839
+        // process headers
840
+        $header_data = trim(substr($data,0,$pos));
841
+        $header_array = explode($lb,$header_data);
842
+        $this->incoming_headers = array();
843
+        $this->incoming_cookies = array();
844
+        foreach($header_array as $header_line){
845
+            $arr = explode(':',$header_line, 2);
846
+            if(count($arr) > 1){
847
+                $header_name = strtolower(trim($arr[0]));
848
+                $this->incoming_headers[$header_name] = trim($arr[1]);
849
+                if ($header_name == 'set-cookie') {
850
+                    // TODO: allow multiple cookies from parseCookie
851
+                    $cookie = $this->parseCookie(trim($arr[1]));
852
+                    if ($cookie) {
853
+                        $this->incoming_cookies[] = $cookie;
854
+                        $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
855
+                    } else {
856
+                        $this->debug('did not find cookie in ' . trim($arr[1]));
857
+                    }
858
+                }
859
+            } else if (isset($header_name)) {
860
+                // append continuation line to previous header
861
+                $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
862
+            }
863
+        }
864
+
865
+        // loop until msg has been received
866
+        if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
867
+            $content_length =  2147483647;	// ignore any content-length header
868
+            $chunked = true;
869
+            $this->debug("want to read chunked content");
870
+        } elseif (isset($this->incoming_headers['content-length'])) {
871
+            $content_length = $this->incoming_headers['content-length'];
872
+            $chunked = false;
873
+            $this->debug("want to read content of length $content_length");
874
+        } else {
875
+            $content_length =  2147483647;
876
+            $chunked = false;
877
+            $this->debug("want to read content to EOF");
878
+        }
879
+        $data = '';
880
+        do {
881
+            if ($chunked) {
882
+                $tmp = fgets($this->fp, 256);
883
+                $tmplen = strlen($tmp);
884
+                $this->debug("read chunk line of $tmplen bytes");
885
+                if ($tmplen == 0) {
886
+                    $this->incoming_payload = $data;
887
+                    $this->debug('socket read of chunk length timed out after length ' . strlen($data));
888
+                    $this->debug("read before timeout:\n" . $data);
889
+                    $this->setError('socket read of chunk length timed out');
890
+                    return false;
891
+                }
892
+                $content_length = hexdec(trim($tmp));
893
+                $this->debug("chunk length $content_length");
894
+            }
895
+            $strlen = 0;
896
+            while (($strlen < $content_length) && (!feof($this->fp))) {
897
+                $readlen = min(8192, $content_length - $strlen);
898
+                $tmp = fread($this->fp, $readlen);
899
+                $tmplen = strlen($tmp);
900
+                $this->debug("read buffer of $tmplen bytes");
901
+                if (($tmplen == 0) && (!feof($this->fp))) {
902
+                    $this->incoming_payload = $data;
903
+                    $this->debug('socket read of body timed out after length ' . strlen($data));
904
+                    $this->debug("read before timeout:\n" . $data);
905
+                    $this->setError('socket read of body timed out');
906
+                    return false;
907
+                }
908
+                $strlen += $tmplen;
909
+                $data .= $tmp;
910
+            }
911
+            if ($chunked && ($content_length > 0)) {
912
+                $tmp = fgets($this->fp, 256);
913
+                $tmplen = strlen($tmp);
914
+                $this->debug("read chunk terminator of $tmplen bytes");
915
+                if ($tmplen == 0) {
916
+                    $this->incoming_payload = $data;
917
+                    $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
918
+                    $this->debug("read before timeout:\n" . $data);
919
+                    $this->setError('socket read of chunk terminator timed out');
920
+                    return false;
921
+                }
922
+            }
923
+        } while ($chunked && ($content_length > 0) && (!feof($this->fp)));
924
+        if (feof($this->fp)) {
925
+            $this->debug('read to EOF');
926
+        }
927
+        $this->debug('read body of length ' . strlen($data));
928
+        $this->incoming_payload .= $data;
929
+        $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
930
+
931
+        // close filepointer
932
+        if(
933
+            (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
934
+            (! $this->persistentConnection) || feof($this->fp)){
935
+            fclose($this->fp);
936
+            $this->fp = false;
937
+            $this->debug('closed socket');
938
+        }
939
+
940
+        // connection was closed unexpectedly
941
+        if($this->incoming_payload == ''){
942
+            $this->setError('no response from server');
943
+            return false;
944
+        }
945
+
946
+        // decode transfer-encoding
947 947
 //		if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
948 948
 //			if(!$data = $this->decodeChunked($data, $lb)){
949 949
 //				$this->setError('Decoding of chunked data failed');
950 950
 //				return false;
951 951
 //			}
952
-			//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
953
-			// set decoded payload
952
+            //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
953
+            // set decoded payload
954 954
 //			$this->incoming_payload = $header_data.$lb.$lb.$data;
955 955
 //		}
956 956
 
957
-	  } else if ($this->io_method() == 'curl') {
958
-		// send and receive
959
-		$this->debug('send and receive with cURL');
960
-		$this->incoming_payload = curl_exec($this->ch);
961
-		$data = $this->incoming_payload;
957
+        } else if ($this->io_method() == 'curl') {
958
+        // send and receive
959
+        $this->debug('send and receive with cURL');
960
+        $this->incoming_payload = curl_exec($this->ch);
961
+        $data = $this->incoming_payload;
962 962
 
963 963
         $cErr = curl_error($this->ch);
964
-		if ($cErr != '') {
965
-        	$err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
966
-        	// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
967
-			foreach(curl_getinfo($this->ch) as $k => $v){
968
-				$err .= "$k: $v<br>";
969
-			}
970
-			$this->debug($err);
971
-			$this->setError($err);
972
-			curl_close($this->ch);
973
-	    	return false;
974
-		} else {
975
-			//echo '<pre>';
976
-			//var_dump(curl_getinfo($this->ch));
977
-			//echo '</pre>';
978
-		}
979
-		// close curl
980
-		$this->debug('No cURL error, closing cURL');
981
-		curl_close($this->ch);
982
-
983
-		// try removing skippable headers
984
-		$savedata = $data;
985
-		while ($this->isSkippableCurlHeader($data)) {
986
-			$this->debug("Found HTTP header to skip");
987
-			if ($pos = strpos($data,"\r\n\r\n")) {
988
-				$data = ltrim(substr($data,$pos));
989
-			} elseif($pos = strpos($data,"\n\n") ) {
990
-				$data = ltrim(substr($data,$pos));
991
-			}
992
-		}
993
-
994
-		if ($data == '') {
995
-			// have nothing left; just remove 100 header(s)
996
-			$data = $savedata;
997
-			while (preg_match('/^HTTP\/1.1 100/',$data)) {
998
-				if ($pos = strpos($data,"\r\n\r\n")) {
999
-					$data = ltrim(substr($data,$pos));
1000
-				} elseif($pos = strpos($data,"\n\n") ) {
1001
-					$data = ltrim(substr($data,$pos));
1002
-				}
1003
-			}
1004
-		}
1005
-
1006
-		// separate content from HTTP headers
1007
-		if ($pos = strpos($data,"\r\n\r\n")) {
1008
-			$lb = "\r\n";
1009
-		} elseif( $pos = strpos($data,"\n\n")) {
1010
-			$lb = "\n";
1011
-		} else {
1012
-			$this->debug('no proper separation of headers and document');
1013
-			$this->setError('no proper separation of headers and document');
1014
-			return false;
1015
-		}
1016
-		$header_data = trim(substr($data,0,$pos));
1017
-		$header_array = explode($lb,$header_data);
1018
-		$data = ltrim(substr($data,$pos));
1019
-		$this->debug('found proper separation of headers and document');
1020
-		$this->debug('cleaned data, stringlen: '.strlen($data));
1021
-		// clean headers
1022
-		foreach ($header_array as $header_line) {
1023
-			$arr = explode(':',$header_line,2);
1024
-			if(count($arr) > 1){
1025
-				$header_name = strtolower(trim($arr[0]));
1026
-				$this->incoming_headers[$header_name] = trim($arr[1]);
1027
-				if ($header_name == 'set-cookie') {
1028
-					// TODO: allow multiple cookies from parseCookie
1029
-					$cookie = $this->parseCookie(trim($arr[1]));
1030
-					if ($cookie) {
1031
-						$this->incoming_cookies[] = $cookie;
1032
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1033
-					} else {
1034
-						$this->debug('did not find cookie in ' . trim($arr[1]));
1035
-					}
1036
-    			}
1037
-			} else if (isset($header_name)) {
1038
-				// append continuation line to previous header
1039
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1040
-			}
1041
-		}
1042
-	  }
1043
-
1044
-		$this->response_status_line = $header_array[0];
1045
-		$arr = explode(' ', $this->response_status_line, 3);
1046
-		$http_version = $arr[0];
1047
-		$http_status = intval($arr[1]);
1048
-		$http_reason = count($arr) > 2 ? $arr[2] : '';
1049
-
1050
- 		// see if we need to resend the request with http digest authentication
1051
- 		if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1052
- 			$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1053
- 			$this->setURL($this->incoming_headers['location']);
1054
-			$this->tryagain = true;
1055
-			return false;
1056
-		}
1057
-
1058
- 		// see if we need to resend the request with http digest authentication
1059
- 		if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1060
- 			$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1061
- 			if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1062
- 				$this->debug('Server wants digest authentication');
1063
- 				// remove "Digest " from our elements
1064
- 				$digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1065
-
1066
- 				// parse elements into array
1067
- 				$digestElements = explode(',', $digestString);
1068
- 				foreach ($digestElements as $val) {
1069
- 					$tempElement = explode('=', trim($val), 2);
1070
- 					$digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
1071
- 				}
1072
-
1073
-				// should have (at least) qop, realm, nonce
1074
- 				if (isset($digestRequest['nonce'])) {
1075
- 					$this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1076
- 					$this->tryagain = true;
1077
- 					return false;
1078
- 				}
1079
- 			}
1080
-			$this->debug('HTTP authentication failed');
1081
-			$this->setError('HTTP authentication failed');
1082
-			return false;
1083
- 		}
1084
-
1085
-		if (
1086
-			($http_status >= 300 && $http_status <= 307) ||
1087
-			($http_status >= 400 && $http_status <= 417) ||
1088
-			($http_status >= 501 && $http_status <= 505)
1089
-		   ) {
1090
-			$this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
1091
-			return false;
1092
-		}
1093
-
1094
-		// decode content-encoding
1095
-		if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1096
-			if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1097
-    			// if decoding works, use it. else assume data wasn't gzencoded
1098
-    			if(function_exists('gzinflate')){
1099
-					//$timer->setMarker('starting decoding of gzip/deflated content');
1100
-					// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1101
-					// this means there are no Zlib headers, although there should be
1102
-					$this->debug('The gzinflate function exists');
1103
-					$datalen = strlen($data);
1104
-					if ($this->incoming_headers['content-encoding'] == 'deflate') {
1105
-						if ($degzdata = @gzinflate($data)) {
1106
-	    					$data = $degzdata;
1107
-	    					$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1108
-	    					if (strlen($data) < $datalen) {
1109
-	    						// test for the case that the payload has been compressed twice
1110
-		    					$this->debug('The inflated payload is smaller than the gzipped one; try again');
1111
-								if ($degzdata = @gzinflate($data)) {
1112
-			    					$data = $degzdata;
1113
-			    					$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1114
-								}
1115
-	    					}
1116
-	    				} else {
1117
-	    					$this->debug('Error using gzinflate to inflate the payload');
1118
-	    					$this->setError('Error using gzinflate to inflate the payload');
1119
-	    				}
1120
-					} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1121
-						if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1122
-							$data = $degzdata;
1123
-	    					$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1124
-	    					if (strlen($data) < $datalen) {
1125
-	    						// test for the case that the payload has been compressed twice
1126
-		    					$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1127
-								if ($degzdata = @gzinflate(substr($data, 10))) {
1128
-			    					$data = $degzdata;
1129
-			    					$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1130
-								}
1131
-	    					}
1132
-	    				} else {
1133
-	    					$this->debug('Error using gzinflate to un-gzip the payload');
1134
-							$this->setError('Error using gzinflate to un-gzip the payload');
1135
-	    				}
1136
-					}
1137
-					//$timer->setMarker('finished decoding of gzip/deflated content');
1138
-					//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
1139
-					// set decoded payload
1140
-					$this->incoming_payload = $header_data.$lb.$lb.$data;
1141
-    			} else {
1142
-					$this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1143
-					$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1144
-				}
1145
-			} else {
1146
-				$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1147
-				$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1148
-			}
1149
-		} else {
1150
-			$this->debug('No Content-Encoding header');
1151
-		}
1152
-
1153
-		if(strlen($data) == 0){
1154
-			$this->debug('no data after headers!');
1155
-			$this->setError('no data present after HTTP headers');
1156
-			return false;
1157
-		}
1158
-
1159
-		return $data;
1160
-	}
1161
-
1162
-	/**
1163
-	 * sets the content-type for the SOAP message to be sent
1164
-	 *
1165
-	 * @param	string $type the content type, MIME style
1166
-	 * @param	mixed $charset character set used for encoding (or false)
1167
-	 * @access	public
1168
-	 */
1169
-	function setContentType($type, $charset = false) {
1170
-		$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1171
-	}
1172
-
1173
-	/**
1174
-	 * specifies that an HTTP persistent connection should be used
1175
-	 *
1176
-	 * @return	boolean whether the request was honored by this method.
1177
-	 * @access	public
1178
-	 */
1179
-	function usePersistentConnection(){
1180
-		if (isset($this->outgoing_headers['Accept-Encoding'])) {
1181
-			return false;
1182
-		}
1183
-		$this->protocol_version = '1.1';
1184
-		$this->persistentConnection = true;
1185
-		$this->setHeader('Connection', 'Keep-Alive');
1186
-		return true;
1187
-	}
1188
-
1189
-	/**
1190
-	 * parse an incoming Cookie into it's parts
1191
-	 *
1192
-	 * @param	string $cookie_str content of cookie
1193
-	 * @return	array with data of that cookie
1194
-	 * @access	private
1195
-	 */
1196
-	/*
964
+        if ($cErr != '') {
965
+            $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
966
+            // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
967
+            foreach(curl_getinfo($this->ch) as $k => $v){
968
+                $err .= "$k: $v<br>";
969
+            }
970
+            $this->debug($err);
971
+            $this->setError($err);
972
+            curl_close($this->ch);
973
+            return false;
974
+        } else {
975
+            //echo '<pre>';
976
+            //var_dump(curl_getinfo($this->ch));
977
+            //echo '</pre>';
978
+        }
979
+        // close curl
980
+        $this->debug('No cURL error, closing cURL');
981
+        curl_close($this->ch);
982
+
983
+        // try removing skippable headers
984
+        $savedata = $data;
985
+        while ($this->isSkippableCurlHeader($data)) {
986
+            $this->debug("Found HTTP header to skip");
987
+            if ($pos = strpos($data,"\r\n\r\n")) {
988
+                $data = ltrim(substr($data,$pos));
989
+            } elseif($pos = strpos($data,"\n\n") ) {
990
+                $data = ltrim(substr($data,$pos));
991
+            }
992
+        }
993
+
994
+        if ($data == '') {
995
+            // have nothing left; just remove 100 header(s)
996
+            $data = $savedata;
997
+            while (preg_match('/^HTTP\/1.1 100/',$data)) {
998
+                if ($pos = strpos($data,"\r\n\r\n")) {
999
+                    $data = ltrim(substr($data,$pos));
1000
+                } elseif($pos = strpos($data,"\n\n") ) {
1001
+                    $data = ltrim(substr($data,$pos));
1002
+                }
1003
+            }
1004
+        }
1005
+
1006
+        // separate content from HTTP headers
1007
+        if ($pos = strpos($data,"\r\n\r\n")) {
1008
+            $lb = "\r\n";
1009
+        } elseif( $pos = strpos($data,"\n\n")) {
1010
+            $lb = "\n";
1011
+        } else {
1012
+            $this->debug('no proper separation of headers and document');
1013
+            $this->setError('no proper separation of headers and document');
1014
+            return false;
1015
+        }
1016
+        $header_data = trim(substr($data,0,$pos));
1017
+        $header_array = explode($lb,$header_data);
1018
+        $data = ltrim(substr($data,$pos));
1019
+        $this->debug('found proper separation of headers and document');
1020
+        $this->debug('cleaned data, stringlen: '.strlen($data));
1021
+        // clean headers
1022
+        foreach ($header_array as $header_line) {
1023
+            $arr = explode(':',$header_line,2);
1024
+            if(count($arr) > 1){
1025
+                $header_name = strtolower(trim($arr[0]));
1026
+                $this->incoming_headers[$header_name] = trim($arr[1]);
1027
+                if ($header_name == 'set-cookie') {
1028
+                    // TODO: allow multiple cookies from parseCookie
1029
+                    $cookie = $this->parseCookie(trim($arr[1]));
1030
+                    if ($cookie) {
1031
+                        $this->incoming_cookies[] = $cookie;
1032
+                        $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1033
+                    } else {
1034
+                        $this->debug('did not find cookie in ' . trim($arr[1]));
1035
+                    }
1036
+                }
1037
+            } else if (isset($header_name)) {
1038
+                // append continuation line to previous header
1039
+                $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1040
+            }
1041
+        }
1042
+        }
1043
+
1044
+        $this->response_status_line = $header_array[0];
1045
+        $arr = explode(' ', $this->response_status_line, 3);
1046
+        $http_version = $arr[0];
1047
+        $http_status = intval($arr[1]);
1048
+        $http_reason = count($arr) > 2 ? $arr[2] : '';
1049
+
1050
+            // see if we need to resend the request with http digest authentication
1051
+            if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1052
+                $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1053
+                $this->setURL($this->incoming_headers['location']);
1054
+            $this->tryagain = true;
1055
+            return false;
1056
+        }
1057
+
1058
+            // see if we need to resend the request with http digest authentication
1059
+            if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1060
+                $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1061
+                if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1062
+                    $this->debug('Server wants digest authentication');
1063
+                    // remove "Digest " from our elements
1064
+                    $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
1065
+
1066
+                    // parse elements into array
1067
+                    $digestElements = explode(',', $digestString);
1068
+                    foreach ($digestElements as $val) {
1069
+                        $tempElement = explode('=', trim($val), 2);
1070
+                        $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
1071
+                    }
1072
+
1073
+                // should have (at least) qop, realm, nonce
1074
+                    if (isset($digestRequest['nonce'])) {
1075
+                        $this->setCredentials($this->username, $this->password, 'digest', $digestRequest);
1076
+                        $this->tryagain = true;
1077
+                        return false;
1078
+                    }
1079
+                }
1080
+            $this->debug('HTTP authentication failed');
1081
+            $this->setError('HTTP authentication failed');
1082
+            return false;
1083
+            }
1084
+
1085
+        if (
1086
+            ($http_status >= 300 && $http_status <= 307) ||
1087
+            ($http_status >= 400 && $http_status <= 417) ||
1088
+            ($http_status >= 501 && $http_status <= 505)
1089
+            ) {
1090
+            $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
1091
+            return false;
1092
+        }
1093
+
1094
+        // decode content-encoding
1095
+        if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1096
+            if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1097
+                // if decoding works, use it. else assume data wasn't gzencoded
1098
+                if(function_exists('gzinflate')){
1099
+                    //$timer->setMarker('starting decoding of gzip/deflated content');
1100
+                    // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1101
+                    // this means there are no Zlib headers, although there should be
1102
+                    $this->debug('The gzinflate function exists');
1103
+                    $datalen = strlen($data);
1104
+                    if ($this->incoming_headers['content-encoding'] == 'deflate') {
1105
+                        if ($degzdata = @gzinflate($data)) {
1106
+                            $data = $degzdata;
1107
+                            $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1108
+                            if (strlen($data) < $datalen) {
1109
+                                // test for the case that the payload has been compressed twice
1110
+                                $this->debug('The inflated payload is smaller than the gzipped one; try again');
1111
+                                if ($degzdata = @gzinflate($data)) {
1112
+                                    $data = $degzdata;
1113
+                                    $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1114
+                                }
1115
+                            }
1116
+                        } else {
1117
+                            $this->debug('Error using gzinflate to inflate the payload');
1118
+                            $this->setError('Error using gzinflate to inflate the payload');
1119
+                        }
1120
+                    } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1121
+                        if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1122
+                            $data = $degzdata;
1123
+                            $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1124
+                            if (strlen($data) < $datalen) {
1125
+                                // test for the case that the payload has been compressed twice
1126
+                                $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1127
+                                if ($degzdata = @gzinflate(substr($data, 10))) {
1128
+                                    $data = $degzdata;
1129
+                                    $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1130
+                                }
1131
+                            }
1132
+                        } else {
1133
+                            $this->debug('Error using gzinflate to un-gzip the payload');
1134
+                            $this->setError('Error using gzinflate to un-gzip the payload');
1135
+                        }
1136
+                    }
1137
+                    //$timer->setMarker('finished decoding of gzip/deflated content');
1138
+                    //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
1139
+                    // set decoded payload
1140
+                    $this->incoming_payload = $header_data.$lb.$lb.$data;
1141
+                } else {
1142
+                    $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1143
+                    $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1144
+                }
1145
+            } else {
1146
+                $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1147
+                $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1148
+            }
1149
+        } else {
1150
+            $this->debug('No Content-Encoding header');
1151
+        }
1152
+
1153
+        if(strlen($data) == 0){
1154
+            $this->debug('no data after headers!');
1155
+            $this->setError('no data present after HTTP headers');
1156
+            return false;
1157
+        }
1158
+
1159
+        return $data;
1160
+    }
1161
+
1162
+    /**
1163
+     * sets the content-type for the SOAP message to be sent
1164
+     *
1165
+     * @param	string $type the content type, MIME style
1166
+     * @param	mixed $charset character set used for encoding (or false)
1167
+     * @access	public
1168
+     */
1169
+    function setContentType($type, $charset = false) {
1170
+        $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1171
+    }
1172
+
1173
+    /**
1174
+     * specifies that an HTTP persistent connection should be used
1175
+     *
1176
+     * @return	boolean whether the request was honored by this method.
1177
+     * @access	public
1178
+     */
1179
+    function usePersistentConnection(){
1180
+        if (isset($this->outgoing_headers['Accept-Encoding'])) {
1181
+            return false;
1182
+        }
1183
+        $this->protocol_version = '1.1';
1184
+        $this->persistentConnection = true;
1185
+        $this->setHeader('Connection', 'Keep-Alive');
1186
+        return true;
1187
+    }
1188
+
1189
+    /**
1190
+     * parse an incoming Cookie into it's parts
1191
+     *
1192
+     * @param	string $cookie_str content of cookie
1193
+     * @return	array with data of that cookie
1194
+     * @access	private
1195
+     */
1196
+    /*
1197 1197
 	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1198 1198
 	 */
1199
-	function parseCookie($cookie_str) {
1200
-		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1201
-		$data = preg_split('/;/', $cookie_str);
1202
-		$value_str = $data[0];
1203
-
1204
-		$cookie_param = 'domain=';
1205
-		$start = strpos($cookie_str, $cookie_param);
1206
-		if ($start > 0) {
1207
-			$domain = substr($cookie_str, $start + strlen($cookie_param));
1208
-			$domain = substr($domain, 0, strpos($domain, ';'));
1209
-		} else {
1210
-			$domain = '';
1211
-		}
1212
-
1213
-		$cookie_param = 'expires=';
1214
-		$start = strpos($cookie_str, $cookie_param);
1215
-		if ($start > 0) {
1216
-			$expires = substr($cookie_str, $start + strlen($cookie_param));
1217
-			$expires = substr($expires, 0, strpos($expires, ';'));
1218
-		} else {
1219
-			$expires = '';
1220
-		}
1221
-
1222
-		$cookie_param = 'path=';
1223
-		$start = strpos($cookie_str, $cookie_param);
1224
-		if ( $start > 0 ) {
1225
-			$path = substr($cookie_str, $start + strlen($cookie_param));
1226
-			$path = substr($path, 0, strpos($path, ';'));
1227
-		} else {
1228
-			$path = '/';
1229
-		}
1230
-
1231
-		$cookie_param = ';secure;';
1232
-		if (strpos($cookie_str, $cookie_param) !== FALSE) {
1233
-			$secure = true;
1234
-		} else {
1235
-			$secure = false;
1236
-		}
1237
-
1238
-		$sep_pos = strpos($value_str, '=');
1239
-
1240
-		if ($sep_pos) {
1241
-			$name = substr($value_str, 0, $sep_pos);
1242
-			$value = substr($value_str, $sep_pos + 1);
1243
-			$cookie= array(	'name' => $name,
1244
-			                'value' => $value,
1245
-							'domain' => $domain,
1246
-							'path' => $path,
1247
-							'expires' => $expires,
1248
-							'secure' => $secure
1249
-							);
1250
-			return $cookie;
1251
-		}
1252
-		return false;
1253
-	}
1254
-
1255
-	/**
1256
-	 * sort out cookies for the current request
1257
-	 *
1258
-	 * @param	array $cookies array with all cookies
1259
-	 * @param	boolean $secure is the send-content secure or not?
1260
-	 * @return	string for Cookie-HTTP-Header
1261
-	 * @access	private
1262
-	 */
1263
-	function getCookiesForRequest($cookies, $secure=false) {
1264
-		$cookie_str = '';
1265
-		if ((! is_null($cookies)) && (is_array($cookies))) {
1266
-			foreach ($cookies as $cookie) {
1267
-				if (! is_array($cookie)) {
1268
-					continue;
1269
-				}
1270
-	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1271
-				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1272
-					if (strtotime($cookie['expires']) <= time()) {
1273
-						$this->debug('cookie has expired');
1274
-						continue;
1275
-					}
1276
-				}
1277
-				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1278
-					$domain = preg_quote($cookie['domain']);
1279
-					if (! preg_match("'.*$domain$'i", $this->host)) {
1280
-						$this->debug('cookie has different domain');
1281
-						continue;
1282
-					}
1283
-				}
1284
-				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1285
-					$path = preg_quote($cookie['path']);
1286
-					if (! preg_match("'^$path.*'i", $this->path)) {
1287
-						$this->debug('cookie is for a different path');
1288
-						continue;
1289
-					}
1290
-				}
1291
-				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1292
-					$this->debug('cookie is secure, transport is not');
1293
-					continue;
1294
-				}
1295
-				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1296
-	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1297
-			}
1298
-		}
1299
-		return $cookie_str;
1300
-  }
1199
+    function parseCookie($cookie_str) {
1200
+        $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1201
+        $data = preg_split('/;/', $cookie_str);
1202
+        $value_str = $data[0];
1203
+
1204
+        $cookie_param = 'domain=';
1205
+        $start = strpos($cookie_str, $cookie_param);
1206
+        if ($start > 0) {
1207
+            $domain = substr($cookie_str, $start + strlen($cookie_param));
1208
+            $domain = substr($domain, 0, strpos($domain, ';'));
1209
+        } else {
1210
+            $domain = '';
1211
+        }
1212
+
1213
+        $cookie_param = 'expires=';
1214
+        $start = strpos($cookie_str, $cookie_param);
1215
+        if ($start > 0) {
1216
+            $expires = substr($cookie_str, $start + strlen($cookie_param));
1217
+            $expires = substr($expires, 0, strpos($expires, ';'));
1218
+        } else {
1219
+            $expires = '';
1220
+        }
1221
+
1222
+        $cookie_param = 'path=';
1223
+        $start = strpos($cookie_str, $cookie_param);
1224
+        if ( $start > 0 ) {
1225
+            $path = substr($cookie_str, $start + strlen($cookie_param));
1226
+            $path = substr($path, 0, strpos($path, ';'));
1227
+        } else {
1228
+            $path = '/';
1229
+        }
1230
+
1231
+        $cookie_param = ';secure;';
1232
+        if (strpos($cookie_str, $cookie_param) !== FALSE) {
1233
+            $secure = true;
1234
+        } else {
1235
+            $secure = false;
1236
+        }
1237
+
1238
+        $sep_pos = strpos($value_str, '=');
1239
+
1240
+        if ($sep_pos) {
1241
+            $name = substr($value_str, 0, $sep_pos);
1242
+            $value = substr($value_str, $sep_pos + 1);
1243
+            $cookie= array(	'name' => $name,
1244
+                            'value' => $value,
1245
+                            'domain' => $domain,
1246
+                            'path' => $path,
1247
+                            'expires' => $expires,
1248
+                            'secure' => $secure
1249
+                            );
1250
+            return $cookie;
1251
+        }
1252
+        return false;
1253
+    }
1254
+
1255
+    /**
1256
+     * sort out cookies for the current request
1257
+     *
1258
+     * @param	array $cookies array with all cookies
1259
+     * @param	boolean $secure is the send-content secure or not?
1260
+     * @return	string for Cookie-HTTP-Header
1261
+     * @access	private
1262
+     */
1263
+    function getCookiesForRequest($cookies, $secure=false) {
1264
+        $cookie_str = '';
1265
+        if ((! is_null($cookies)) && (is_array($cookies))) {
1266
+            foreach ($cookies as $cookie) {
1267
+                if (! is_array($cookie)) {
1268
+                    continue;
1269
+                }
1270
+                $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1271
+                if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1272
+                    if (strtotime($cookie['expires']) <= time()) {
1273
+                        $this->debug('cookie has expired');
1274
+                        continue;
1275
+                    }
1276
+                }
1277
+                if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1278
+                    $domain = preg_quote($cookie['domain']);
1279
+                    if (! preg_match("'.*$domain$'i", $this->host)) {
1280
+                        $this->debug('cookie has different domain');
1281
+                        continue;
1282
+                    }
1283
+                }
1284
+                if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1285
+                    $path = preg_quote($cookie['path']);
1286
+                    if (! preg_match("'^$path.*'i", $this->path)) {
1287
+                        $this->debug('cookie is for a different path');
1288
+                        continue;
1289
+                    }
1290
+                }
1291
+                if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1292
+                    $this->debug('cookie is secure, transport is not');
1293
+                    continue;
1294
+                }
1295
+                $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1296
+                $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1297
+            }
1298
+        }
1299
+        return $cookie_str;
1300
+    }
1301 1301
 }
1302 1302
 
1303 1303
 
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -26,18 +26,18 @@  discard block
 block discarded – undo
26 26
 	var $incoming_cookies = array();
27 27
 	var $outgoing_payload = '';
28 28
 	var $incoming_payload = '';
29
-	var $response_status_line;	// HTTP response status line
29
+	var $response_status_line; // HTTP response status line
30 30
 	var $useSOAPAction = true;
31 31
 	var $persistentConnection = false;
32
-	var $ch = false;	// cURL handle
33
-	var $ch_options = array();	// cURL custom options
34
-	var $use_curl = false;		// force cURL use
35
-	var $proxy = null;			// proxy information (associative array)
32
+	var $ch = false; // cURL handle
33
+	var $ch_options = array(); // cURL custom options
34
+	var $use_curl = false; // force cURL use
35
+	var $proxy = null; // proxy information (associative array)
36 36
 	var $username = '';
37 37
 	var $password = '';
38 38
 	var $authtype = '';
39 39
 	var $digestRequest = array();
40
-	var $certRequest = array();	// keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
40
+	var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional)
41 41
 								// cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem'
42 42
 								// sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem'
43 43
 								// sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem'
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 	* @param boolean $use_curl Whether to try to force cURL use
55 55
 	* @access public
56 56
 	*/
57
-	function __construct($url, $curl_options = NULL, $use_curl = false){
57
+	function __construct($url, $curl_options = NULL, $use_curl = false) {
58 58
 		parent::__construct();
59 59
 		$this->debug("ctor url=$url use_curl=$use_curl curl_options:");
60 60
 		$this->appendDebug($this->varDump($curl_options));
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 			$this->ch_options = $curl_options;
64 64
 		}
65 65
 		$this->use_curl = $use_curl;
66
-		preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
66
+		preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
67 67
 		$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
68 68
 	}
69 69
 
@@ -115,19 +115,19 @@  discard block
 block discarded – undo
115 115
 		$this->url = $url;
116 116
 
117 117
 		$u = parse_url($url);
118
-		foreach($u as $k => $v){
118
+		foreach ($u as $k => $v) {
119 119
 			$this->debug("parsed URL $k = $v");
120 120
 			$this->$k = $v;
121 121
 		}
122 122
 
123 123
 		// add any GET params to path
124
-		if(isset($u['query']) && $u['query'] != ''){
125
-            $this->path .= '?' . $u['query'];
124
+		if (isset($u['query']) && $u['query'] != '') {
125
+            $this->path .= '?'.$u['query'];
126 126
 		}
127 127
 
128 128
 		// set default port
129
-		if(!isset($u['port'])){
130
-			if($u['scheme'] == 'https'){
129
+		if (!isset($u['port'])) {
130
+			if ($u['scheme'] == 'https') {
131 131
 				$this->port = 443;
132 132
 			} else {
133 133
 				$this->port = 80;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	* @return	boolean true if connected, false if not
172 172
 	* @access   private
173 173
 	*/
174
-	function connect($connection_timeout=0,$response_timeout=30){
174
+	function connect($connection_timeout = 0, $response_timeout = 30) {
175 175
 	  	// For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like
176 176
 	  	// "regular" socket.
177 177
 	  	// TODO: disabled for now because OpenSSL must be *compiled* in (not just
@@ -195,7 +195,7 @@  discard block
 block discarded – undo
195 195
 		}
196 196
 
197 197
 		// use persistent connection
198
-		if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
198
+		if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
199 199
 			if (!feof($this->fp)) {
200 200
 				$this->debug('Re-use persistent connection');
201 201
 				return true;
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 
207 207
 		// munge host if using OpenSSL
208 208
 		if ($this->scheme == 'ssl') {
209
-			$host = 'ssl://' . $host;
209
+			$host = 'ssl://'.$host;
210 210
 		}
211
-		$this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
211
+		$this->debug('calling fsockopen with host '.$host.' connection_timeout '.$connection_timeout);
212 212
 
213 213
 		// open socket
214
-		if($connection_timeout > 0){
215
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout);
214
+		if ($connection_timeout > 0) {
215
+			$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout);
216 216
 		} else {
217
-			$this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str);
217
+			$this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str);
218 218
 		}
219 219
 
220 220
 		// test pointer
221
-		if(!$this->fp) {
222
-			$msg = 'Couldn\'t open socket connection to server ' . $this->url;
221
+		if (!$this->fp) {
222
+			$msg = 'Couldn\'t open socket connection to server '.$this->url;
223 223
 			if ($this->errno) {
224 224
 				$msg .= ', Error ('.$this->errno.'): '.$this->error_str;
225 225
 			} else {
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 		}
232 232
 
233 233
 		// set response timeout
234
-		$this->debug('set response timeout to ' . $response_timeout);
235
-		socket_set_timeout( $this->fp, $response_timeout);
234
+		$this->debug('set response timeout to '.$response_timeout);
235
+		socket_set_timeout($this->fp, $response_timeout);
236 236
 
237 237
 		$this->debug('socket connected');
238 238
 		return true;
@@ -391,8 +391,8 @@  discard block
 block discarded – undo
391 391
 		$this->debug('cURL connection set up');
392 392
 		return true;
393 393
 	  } else {
394
-		$this->setError('Unknown scheme ' . $this->scheme);
395
-		$this->debug('Unknown scheme ' . $this->scheme);
394
+		$this->setError('Unknown scheme '.$this->scheme);
395
+		$this->debug('Unknown scheme '.$this->scheme);
396 396
 		return false;
397 397
 	  }
398 398
 	}
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
 	* @return	string data
408 408
 	* @access   public
409 409
 	*/
410
-	function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
410
+	function send($data, $timeout = 0, $response_timeout = 30, $cookies = NULL) {
411 411
 
412 412
 		$this->debug('entered send() with data of length: '.strlen($data));
413 413
 
@@ -417,12 +417,12 @@  discard block
 block discarded – undo
417 417
 			$this->tryagain = false;
418 418
 			if ($tries++ < 2) {
419 419
 				// make connnection
420
-				if (!$this->connect($timeout, $response_timeout)){
420
+				if (!$this->connect($timeout, $response_timeout)) {
421 421
 					return false;
422 422
 				}
423 423
 
424 424
 				// send request
425
-				if (!$this->sendRequest($data, $cookies)){
425
+				if (!$this->sendRequest($data, $cookies)) {
426 426
 					return false;
427 427
 				}
428 428
 
@@ -448,7 +448,7 @@  discard block
 block discarded – undo
448 448
 	* @access   public
449 449
 	* @deprecated
450 450
 	*/
451
-	function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
451
+	function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) {
452 452
 		return $this->send($data, $timeout, $response_timeout, $cookies);
453 453
 	}
454 454
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 		$this->appendDebug($this->varDump($certRequest));
470 470
 		// cf. RFC 2617
471 471
 		if ($authtype == 'basic') {
472
-			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
472
+			$this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':', '', $username).':'.$password));
473 473
 		} elseif ($authtype == 'digest') {
474 474
 			if (isset($digestRequest['nonce'])) {
475 475
 				$digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1;
@@ -477,16 +477,16 @@  discard block
 block discarded – undo
477 477
 				// calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html)
478 478
 
479 479
 				// A1 = unq(username-value) ":" unq(realm-value) ":" passwd
480
-				$A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password;
480
+				$A1 = $username.':'.(isset($digestRequest['realm']) ? $digestRequest['realm'] : '').':'.$password;
481 481
 
482 482
 				// H(A1) = MD5(A1)
483 483
 				$HA1 = md5($A1);
484 484
 
485 485
 				// A2 = Method ":" digest-uri-value
486
-				$A2 = $this->request_method . ':' . $this->digest_uri;
486
+				$A2 = $this->request_method.':'.$this->digest_uri;
487 487
 
488 488
 				// H(A2)
489
-				$HA2 =  md5($A2);
489
+				$HA2 = md5($A2);
490 490
 
491 491
 				// KD(secret, data) = H(concat(secret, ":", data))
492 492
 				// if qop == auth:
@@ -503,19 +503,19 @@  discard block
 block discarded – undo
503 503
 				$nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : '';
504 504
 				$cnonce = $nonce;
505 505
 				if ($digestRequest['qop'] != '') {
506
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
506
+					$unhashedDigest = $HA1.':'.$nonce.':'.sprintf("%08d", $digestRequest['nc']).':'.$cnonce.':'.$digestRequest['qop'].':'.$HA2;
507 507
 				} else {
508
-					$unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2;
508
+					$unhashedDigest = $HA1.':'.$nonce.':'.$HA2;
509 509
 				}
510 510
 
511 511
 				$hashedDigest = md5($unhashedDigest);
512 512
 
513 513
 				$opaque = '';
514 514
 				if (isset($digestRequest['opaque'])) {
515
-					$opaque = ', opaque="' . $digestRequest['opaque'] . '"';
515
+					$opaque = ', opaque="'.$digestRequest['opaque'].'"';
516 516
 				}
517 517
 
518
-				$this->setHeader('Authorization', 'Digest username="' . $username . '", realm="' . $digestRequest['realm'] . '", nonce="' . $nonce . '", uri="' . $this->digest_uri . $opaque . '", cnonce="' . $cnonce . '", nc=' . sprintf("%08x", $digestRequest['nc']) . ', qop="' . $digestRequest['qop'] . '", response="' . $hashedDigest . '"');
518
+				$this->setHeader('Authorization', 'Digest username="'.$username.'", realm="'.$digestRequest['realm'].'", nonce="'.$nonce.'", uri="'.$this->digest_uri.$opaque.'", cnonce="'.$cnonce.'", nc='.sprintf("%08x", $digestRequest['nc']).', qop="'.$digestRequest['qop'].'", response="'.$hashedDigest.'"');
519 519
 			}
520 520
 		} elseif ($authtype == 'certificate') {
521 521
 			$this->certRequest = $certRequest;
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 	* @access   public
538 538
 	*/
539 539
 	function setSOAPAction($soapaction) {
540
-		$this->setHeader('SOAPAction', '"' . $soapaction . '"');
540
+		$this->setHeader('SOAPAction', '"'.$soapaction.'"');
541 541
 	}
542 542
 
543 543
 	/**
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
 	* @param    string $enc encoding style. supported values: gzip, deflate, or both
547 547
 	* @access   public
548 548
 	*/
549
-	function setEncoding($enc='gzip, deflate') {
549
+	function setEncoding($enc = 'gzip, deflate') {
550 550
 		if (function_exists('gzdeflate')) {
551 551
 			$this->protocol_version = '1.1';
552 552
 			$this->setHeader('Accept-Encoding', $enc);
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
 	 * @access	private
600 600
 	 */
601 601
 	function isSkippableCurlHeader(&$data) {
602
-		$skipHeaders = array(	'HTTP/1.1 100',
602
+		$skipHeaders = array('HTTP/1.1 100',
603 603
 								'HTTP/1.0 301',
604 604
 								'HTTP/1.1 301',
605 605
 								'HTTP/1.0 302',
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	* @access   public
626 626
 	* @deprecated
627 627
 	*/
628
-	function decodeChunked($buffer, $lb){
628
+	function decodeChunked($buffer, $lb) {
629 629
 		// length := 0
630 630
 		$length = 0;
631 631
 		$new = '';
@@ -637,17 +637,17 @@  discard block
 block discarded – undo
637 637
 			$this->debug('no linebreak found in decodeChunked');
638 638
 			return $new;
639 639
 		}
640
-		$temp = substr($buffer,0,$chunkend);
641
-		$chunk_size = hexdec( trim($temp) );
640
+		$temp = substr($buffer, 0, $chunkend);
641
+		$chunk_size = hexdec(trim($temp));
642 642
 		$chunkstart = $chunkend + strlen($lb);
643 643
 		// while (chunk-size > 0) {
644 644
 		while ($chunk_size > 0) {
645 645
 			$this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
646
-			$chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size);
646
+			$chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size);
647 647
 
648 648
 			// Just in case we got a broken connection
649 649
 		  	if ($chunkend == FALSE) {
650
-		  	    $chunk = substr($buffer,$chunkstart);
650
+		  	    $chunk = substr($buffer, $chunkstart);
651 651
 				// append chunk-data to entity-body
652 652
 		    	$new .= $chunk;
653 653
 		  	    $length += strlen($chunk);
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 			}
656 656
 
657 657
 		  	// read chunk-data and CRLF
658
-		  	$chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart);
658
+		  	$chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart);
659 659
 		  	// append chunk-data to entity-body
660 660
 		  	$new .= $chunk;
661 661
 		  	// length := length + chunk-size
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 			if ($chunkend == FALSE) {
668 668
 				break; //Just in case we got a broken connection
669 669
 			}
670
-			$temp = substr($buffer,$chunkstart,$chunkend-$chunkstart);
671
-			$chunk_size = hexdec( trim($temp) );
670
+			$temp = substr($buffer, $chunkstart, $chunkend - $chunkstart);
671
+			$chunk_size = hexdec(trim($temp));
672 672
 			$chunkstart = $chunkend;
673 673
 		}
674 674
 		return $new;
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 		$this->outgoing_payload = "$req\r\n";
704 704
 
705 705
 		// loop thru headers, serializing
706
-		foreach($this->outgoing_headers as $k => $v){
706
+		foreach ($this->outgoing_headers as $k => $v) {
707 707
 			$hdr = $k.': '.$v;
708 708
 			$this->debug("HTTP header: $hdr");
709 709
 			$this->outgoing_payload .= "$hdr\r\n";
@@ -740,12 +740,12 @@  discard block
 block discarded – undo
740 740
 
741 741
 	  if ($this->io_method() == 'socket') {
742 742
 		// send payload
743
-		if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
743
+		if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
744 744
 			$this->setError('couldn\'t write message data to socket');
745 745
 			$this->debug('couldn\'t write message data to socket');
746 746
 			return false;
747 747
 		}
748
-		$this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
748
+		$this->debug('wrote data to socket, length = '.strlen($this->outgoing_payload));
749 749
 		return true;
750 750
 	  } else if ($this->io_method() == 'curl') {
751 751
 		// set payload
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 		// some servers refuse to work with (so we no longer use this method!)
755 755
 		//$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload);
756 756
 		$curl_headers = array();
757
-		foreach($this->outgoing_headers as $k => $v){
757
+		foreach ($this->outgoing_headers as $k => $v) {
758 758
 			if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
759 759
 				$this->debug("Skip cURL header $k: $v");
760 760
 			} else {
@@ -762,7 +762,7 @@  discard block
 block discarded – undo
762 762
 			}
763 763
 		}
764 764
 		if ($cookie_str != '') {
765
-			$curl_headers[] = 'Cookie: ' . $cookie_str;
765
+			$curl_headers[] = 'Cookie: '.$cookie_str;
766 766
 		}
767 767
 		$this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers);
768 768
 		$this->debug('set cURL HTTP headers');
@@ -788,62 +788,62 @@  discard block
 block discarded – undo
788 788
 	* @return	string the response (also sets member variables like incoming_payload)
789 789
 	* @access   private
790 790
 	*/
791
-	function getResponse(){
791
+	function getResponse() {
792 792
 		$this->incoming_payload = '';
793 793
 
794 794
 	  if ($this->io_method() == 'socket') {
795 795
 	    // loop until headers have been retrieved
796 796
 	    $data = '';
797
-	    while (!isset($lb)){
797
+	    while (!isset($lb)) {
798 798
 
799 799
 			// We might EOF during header read.
800
-			if(feof($this->fp)) {
800
+			if (feof($this->fp)) {
801 801
 				$this->incoming_payload = $data;
802
-				$this->debug('found no headers before EOF after length ' . strlen($data));
803
-				$this->debug("received before EOF:\n" . $data);
802
+				$this->debug('found no headers before EOF after length '.strlen($data));
803
+				$this->debug("received before EOF:\n".$data);
804 804
 				$this->setError('server failed to send headers');
805 805
 				return false;
806 806
 			}
807 807
 
808 808
 			$tmp = fgets($this->fp, 256);
809 809
 			$tmplen = strlen($tmp);
810
-			$this->debug("read line of $tmplen bytes: " . trim($tmp));
810
+			$this->debug("read line of $tmplen bytes: ".trim($tmp));
811 811
 
812 812
 			if ($tmplen == 0) {
813 813
 				$this->incoming_payload = $data;
814
-				$this->debug('socket read of headers timed out after length ' . strlen($data));
815
-				$this->debug("read before timeout: " . $data);
814
+				$this->debug('socket read of headers timed out after length '.strlen($data));
815
+				$this->debug("read before timeout: ".$data);
816 816
 				$this->setError('socket read of headers timed out');
817 817
 				return false;
818 818
 			}
819 819
 
820 820
 			$data .= $tmp;
821
-			$pos = strpos($data,"\r\n\r\n");
822
-			if($pos > 1){
821
+			$pos = strpos($data, "\r\n\r\n");
822
+			if ($pos > 1) {
823 823
 				$lb = "\r\n";
824 824
 			} else {
825
-				$pos = strpos($data,"\n\n");
826
-				if($pos > 1){
825
+				$pos = strpos($data, "\n\n");
826
+				if ($pos > 1) {
827 827
 					$lb = "\n";
828 828
 				}
829 829
 			}
830 830
 			// remove 100 headers
831
-			if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
831
+			if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
832 832
 				unset($lb);
833 833
 				$data = '';
834 834
 			}//
835 835
 		}
836 836
 		// store header data
837 837
 		$this->incoming_payload .= $data;
838
-		$this->debug('found end of headers after length ' . strlen($data));
838
+		$this->debug('found end of headers after length '.strlen($data));
839 839
 		// process headers
840
-		$header_data = trim(substr($data,0,$pos));
841
-		$header_array = explode($lb,$header_data);
840
+		$header_data = trim(substr($data, 0, $pos));
841
+		$header_array = explode($lb, $header_data);
842 842
 		$this->incoming_headers = array();
843 843
 		$this->incoming_cookies = array();
844
-		foreach($header_array as $header_line){
845
-			$arr = explode(':',$header_line, 2);
846
-			if(count($arr) > 1){
844
+		foreach ($header_array as $header_line) {
845
+			$arr = explode(':', $header_line, 2);
846
+			if (count($arr) > 1) {
847 847
 				$header_name = strtolower(trim($arr[0]));
848 848
 				$this->incoming_headers[$header_name] = trim($arr[1]);
849 849
 				if ($header_name == 'set-cookie') {
@@ -851,20 +851,20 @@  discard block
 block discarded – undo
851 851
 					$cookie = $this->parseCookie(trim($arr[1]));
852 852
 					if ($cookie) {
853 853
 						$this->incoming_cookies[] = $cookie;
854
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
854
+						$this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
855 855
 					} else {
856
-						$this->debug('did not find cookie in ' . trim($arr[1]));
856
+						$this->debug('did not find cookie in '.trim($arr[1]));
857 857
 					}
858 858
     			}
859 859
 			} else if (isset($header_name)) {
860 860
 				// append continuation line to previous header
861
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
861
+				$this->incoming_headers[$header_name] .= $lb.' '.$header_line;
862 862
 			}
863 863
 		}
864 864
 
865 865
 		// loop until msg has been received
866 866
 		if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
867
-			$content_length =  2147483647;	// ignore any content-length header
867
+			$content_length = 2147483647; // ignore any content-length header
868 868
 			$chunked = true;
869 869
 			$this->debug("want to read chunked content");
870 870
 		} elseif (isset($this->incoming_headers['content-length'])) {
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 			$chunked = false;
873 873
 			$this->debug("want to read content of length $content_length");
874 874
 		} else {
875
-			$content_length =  2147483647;
875
+			$content_length = 2147483647;
876 876
 			$chunked = false;
877 877
 			$this->debug("want to read content to EOF");
878 878
 		}
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 				$this->debug("read chunk line of $tmplen bytes");
885 885
 				if ($tmplen == 0) {
886 886
 					$this->incoming_payload = $data;
887
-					$this->debug('socket read of chunk length timed out after length ' . strlen($data));
888
-					$this->debug("read before timeout:\n" . $data);
887
+					$this->debug('socket read of chunk length timed out after length '.strlen($data));
888
+					$this->debug("read before timeout:\n".$data);
889 889
 					$this->setError('socket read of chunk length timed out');
890 890
 					return false;
891 891
 				}
@@ -900,8 +900,8 @@  discard block
 block discarded – undo
900 900
 				$this->debug("read buffer of $tmplen bytes");
901 901
 				if (($tmplen == 0) && (!feof($this->fp))) {
902 902
 					$this->incoming_payload = $data;
903
-					$this->debug('socket read of body timed out after length ' . strlen($data));
904
-					$this->debug("read before timeout:\n" . $data);
903
+					$this->debug('socket read of body timed out after length '.strlen($data));
904
+					$this->debug("read before timeout:\n".$data);
905 905
 					$this->setError('socket read of body timed out');
906 906
 					return false;
907 907
 				}
@@ -914,8 +914,8 @@  discard block
 block discarded – undo
914 914
 				$this->debug("read chunk terminator of $tmplen bytes");
915 915
 				if ($tmplen == 0) {
916 916
 					$this->incoming_payload = $data;
917
-					$this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
918
-					$this->debug("read before timeout:\n" . $data);
917
+					$this->debug('socket read of chunk terminator timed out after length '.strlen($data));
918
+					$this->debug("read before timeout:\n".$data);
919 919
 					$this->setError('socket read of chunk terminator timed out');
920 920
 					return false;
921 921
 				}
@@ -924,21 +924,21 @@  discard block
 block discarded – undo
924 924
 		if (feof($this->fp)) {
925 925
 			$this->debug('read to EOF');
926 926
 		}
927
-		$this->debug('read body of length ' . strlen($data));
927
+		$this->debug('read body of length '.strlen($data));
928 928
 		$this->incoming_payload .= $data;
929 929
 		$this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
930 930
 
931 931
 		// close filepointer
932
-		if(
932
+		if (
933 933
 			(isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') ||
934
-			(! $this->persistentConnection) || feof($this->fp)){
934
+			(!$this->persistentConnection) || feof($this->fp)) {
935 935
 			fclose($this->fp);
936 936
 			$this->fp = false;
937 937
 			$this->debug('closed socket');
938 938
 		}
939 939
 
940 940
 		// connection was closed unexpectedly
941
-		if($this->incoming_payload == ''){
941
+		if ($this->incoming_payload == '') {
942 942
 			$this->setError('no response from server');
943 943
 			return false;
944 944
 		}
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 		if ($cErr != '') {
965 965
         	$err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>';
966 966
         	// TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE
967
-			foreach(curl_getinfo($this->ch) as $k => $v){
967
+			foreach (curl_getinfo($this->ch) as $k => $v) {
968 968
 				$err .= "$k: $v<br>";
969 969
 			}
970 970
 			$this->debug($err);
@@ -984,44 +984,44 @@  discard block
 block discarded – undo
984 984
 		$savedata = $data;
985 985
 		while ($this->isSkippableCurlHeader($data)) {
986 986
 			$this->debug("Found HTTP header to skip");
987
-			if ($pos = strpos($data,"\r\n\r\n")) {
988
-				$data = ltrim(substr($data,$pos));
989
-			} elseif($pos = strpos($data,"\n\n") ) {
990
-				$data = ltrim(substr($data,$pos));
987
+			if ($pos = strpos($data, "\r\n\r\n")) {
988
+				$data = ltrim(substr($data, $pos));
989
+			} elseif ($pos = strpos($data, "\n\n")) {
990
+				$data = ltrim(substr($data, $pos));
991 991
 			}
992 992
 		}
993 993
 
994 994
 		if ($data == '') {
995 995
 			// have nothing left; just remove 100 header(s)
996 996
 			$data = $savedata;
997
-			while (preg_match('/^HTTP\/1.1 100/',$data)) {
998
-				if ($pos = strpos($data,"\r\n\r\n")) {
999
-					$data = ltrim(substr($data,$pos));
1000
-				} elseif($pos = strpos($data,"\n\n") ) {
1001
-					$data = ltrim(substr($data,$pos));
997
+			while (preg_match('/^HTTP\/1.1 100/', $data)) {
998
+				if ($pos = strpos($data, "\r\n\r\n")) {
999
+					$data = ltrim(substr($data, $pos));
1000
+				} elseif ($pos = strpos($data, "\n\n")) {
1001
+					$data = ltrim(substr($data, $pos));
1002 1002
 				}
1003 1003
 			}
1004 1004
 		}
1005 1005
 
1006 1006
 		// separate content from HTTP headers
1007
-		if ($pos = strpos($data,"\r\n\r\n")) {
1007
+		if ($pos = strpos($data, "\r\n\r\n")) {
1008 1008
 			$lb = "\r\n";
1009
-		} elseif( $pos = strpos($data,"\n\n")) {
1009
+		} elseif ($pos = strpos($data, "\n\n")) {
1010 1010
 			$lb = "\n";
1011 1011
 		} else {
1012 1012
 			$this->debug('no proper separation of headers and document');
1013 1013
 			$this->setError('no proper separation of headers and document');
1014 1014
 			return false;
1015 1015
 		}
1016
-		$header_data = trim(substr($data,0,$pos));
1017
-		$header_array = explode($lb,$header_data);
1018
-		$data = ltrim(substr($data,$pos));
1016
+		$header_data = trim(substr($data, 0, $pos));
1017
+		$header_array = explode($lb, $header_data);
1018
+		$data = ltrim(substr($data, $pos));
1019 1019
 		$this->debug('found proper separation of headers and document');
1020 1020
 		$this->debug('cleaned data, stringlen: '.strlen($data));
1021 1021
 		// clean headers
1022 1022
 		foreach ($header_array as $header_line) {
1023
-			$arr = explode(':',$header_line,2);
1024
-			if(count($arr) > 1){
1023
+			$arr = explode(':', $header_line, 2);
1024
+			if (count($arr) > 1) {
1025 1025
 				$header_name = strtolower(trim($arr[0]));
1026 1026
 				$this->incoming_headers[$header_name] = trim($arr[1]);
1027 1027
 				if ($header_name == 'set-cookie') {
@@ -1029,14 +1029,14 @@  discard block
 block discarded – undo
1029 1029
 					$cookie = $this->parseCookie(trim($arr[1]));
1030 1030
 					if ($cookie) {
1031 1031
 						$this->incoming_cookies[] = $cookie;
1032
-						$this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
1032
+						$this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
1033 1033
 					} else {
1034
-						$this->debug('did not find cookie in ' . trim($arr[1]));
1034
+						$this->debug('did not find cookie in '.trim($arr[1]));
1035 1035
 					}
1036 1036
     			}
1037 1037
 			} else if (isset($header_name)) {
1038 1038
 				// append continuation line to previous header
1039
-				$this->incoming_headers[$header_name] .= $lb . ' ' . $header_line;
1039
+				$this->incoming_headers[$header_name] .= $lb.' '.$header_line;
1040 1040
 			}
1041 1041
 		}
1042 1042
 	  }
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
 
1050 1050
  		// see if we need to resend the request with http digest authentication
1051 1051
  		if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
1052
- 			$this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
1052
+ 			$this->debug("Got $http_status $http_reason with Location: ".$this->incoming_headers['location']);
1053 1053
  			$this->setURL($this->incoming_headers['location']);
1054 1054
 			$this->tryagain = true;
1055 1055
 			return false;
@@ -1057,7 +1057,7 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
  		// see if we need to resend the request with http digest authentication
1059 1059
  		if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
1060
- 			$this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
1060
+ 			$this->debug("Got 401 $http_reason with WWW-Authenticate: ".$this->incoming_headers['www-authenticate']);
1061 1061
  			if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
1062 1062
  				$this->debug('Server wants digest authentication');
1063 1063
  				// remove "Digest " from our elements
@@ -1092,10 +1092,10 @@  discard block
 block discarded – undo
1092 1092
 		}
1093 1093
 
1094 1094
 		// decode content-encoding
1095
-		if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
1096
-			if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
1095
+		if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
1096
+			if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
1097 1097
     			// if decoding works, use it. else assume data wasn't gzencoded
1098
-    			if(function_exists('gzinflate')){
1098
+    			if (function_exists('gzinflate')) {
1099 1099
 					//$timer->setMarker('starting decoding of gzip/deflated content');
1100 1100
 					// IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress)
1101 1101
 					// this means there are no Zlib headers, although there should be
@@ -1104,13 +1104,13 @@  discard block
 block discarded – undo
1104 1104
 					if ($this->incoming_headers['content-encoding'] == 'deflate') {
1105 1105
 						if ($degzdata = @gzinflate($data)) {
1106 1106
 	    					$data = $degzdata;
1107
-	    					$this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
1107
+	    					$this->debug('The payload has been inflated to '.strlen($data).' bytes');
1108 1108
 	    					if (strlen($data) < $datalen) {
1109 1109
 	    						// test for the case that the payload has been compressed twice
1110 1110
 		    					$this->debug('The inflated payload is smaller than the gzipped one; try again');
1111 1111
 								if ($degzdata = @gzinflate($data)) {
1112 1112
 			    					$data = $degzdata;
1113
-			    					$this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
1113
+			    					$this->debug('The payload has been inflated again to '.strlen($data).' bytes');
1114 1114
 								}
1115 1115
 	    					}
1116 1116
 	    				} else {
@@ -1120,13 +1120,13 @@  discard block
 block discarded – undo
1120 1120
 					} elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
1121 1121
 						if ($degzdata = @gzinflate(substr($data, 10))) {	// do our best
1122 1122
 							$data = $degzdata;
1123
-	    					$this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
1123
+	    					$this->debug('The payload has been un-gzipped to '.strlen($data).' bytes');
1124 1124
 	    					if (strlen($data) < $datalen) {
1125 1125
 	    						// test for the case that the payload has been compressed twice
1126 1126
 		    					$this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
1127 1127
 								if ($degzdata = @gzinflate(substr($data, 10))) {
1128 1128
 			    					$data = $degzdata;
1129
-			    					$this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
1129
+			    					$this->debug('The payload has been un-gzipped again to '.strlen($data).' bytes');
1130 1130
 								}
1131 1131
 	    					}
1132 1132
 	    				} else {
@@ -1143,14 +1143,14 @@  discard block
 block discarded – undo
1143 1143
 					$this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
1144 1144
 				}
1145 1145
 			} else {
1146
-				$this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1147
-				$this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
1146
+				$this->debug('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
1147
+				$this->setError('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
1148 1148
 			}
1149 1149
 		} else {
1150 1150
 			$this->debug('No Content-Encoding header');
1151 1151
 		}
1152 1152
 
1153
-		if(strlen($data) == 0){
1153
+		if (strlen($data) == 0) {
1154 1154
 			$this->debug('no data after headers!');
1155 1155
 			$this->setError('no data present after HTTP headers');
1156 1156
 			return false;
@@ -1167,7 +1167,7 @@  discard block
 block discarded – undo
1167 1167
 	 * @access	public
1168 1168
 	 */
1169 1169
 	function setContentType($type, $charset = false) {
1170
-		$this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
1170
+		$this->setHeader('Content-Type', $type.($charset ? '; charset='.$charset : ''));
1171 1171
 	}
1172 1172
 
1173 1173
 	/**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 	 * @return	boolean whether the request was honored by this method.
1177 1177
 	 * @access	public
1178 1178
 	 */
1179
-	function usePersistentConnection(){
1179
+	function usePersistentConnection() {
1180 1180
 		if (isset($this->outgoing_headers['Accept-Encoding'])) {
1181 1181
 			return false;
1182 1182
 		}
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	 * TODO: allow a Set-Cookie string to be parsed into multiple cookies
1198 1198
 	 */
1199 1199
 	function parseCookie($cookie_str) {
1200
-		$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
1200
+		$cookie_str = str_replace('; ', ';', $cookie_str).';';
1201 1201
 		$data = preg_split('/;/', $cookie_str);
1202 1202
 		$value_str = $data[0];
1203 1203
 
@@ -1221,7 +1221,7 @@  discard block
 block discarded – undo
1221 1221
 
1222 1222
 		$cookie_param = 'path=';
1223 1223
 		$start = strpos($cookie_str, $cookie_param);
1224
-		if ( $start > 0 ) {
1224
+		if ($start > 0) {
1225 1225
 			$path = substr($cookie_str, $start + strlen($cookie_param));
1226 1226
 			$path = substr($path, 0, strpos($path, ';'));
1227 1227
 		} else {
@@ -1240,7 +1240,7 @@  discard block
 block discarded – undo
1240 1240
 		if ($sep_pos) {
1241 1241
 			$name = substr($value_str, 0, $sep_pos);
1242 1242
 			$value = substr($value_str, $sep_pos + 1);
1243
-			$cookie= array(	'name' => $name,
1243
+			$cookie = array('name' => $name,
1244 1244
 			                'value' => $value,
1245 1245
 							'domain' => $domain,
1246 1246
 							'path' => $path,
@@ -1260,40 +1260,40 @@  discard block
 block discarded – undo
1260 1260
 	 * @return	string for Cookie-HTTP-Header
1261 1261
 	 * @access	private
1262 1262
 	 */
1263
-	function getCookiesForRequest($cookies, $secure=false) {
1263
+	function getCookiesForRequest($cookies, $secure = false) {
1264 1264
 		$cookie_str = '';
1265
-		if ((! is_null($cookies)) && (is_array($cookies))) {
1265
+		if ((!is_null($cookies)) && (is_array($cookies))) {
1266 1266
 			foreach ($cookies as $cookie) {
1267
-				if (! is_array($cookie)) {
1267
+				if (!is_array($cookie)) {
1268 1268
 					continue;
1269 1269
 				}
1270 1270
 	    		$this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
1271
-				if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
1271
+				if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
1272 1272
 					if (strtotime($cookie['expires']) <= time()) {
1273 1273
 						$this->debug('cookie has expired');
1274 1274
 						continue;
1275 1275
 					}
1276 1276
 				}
1277
-				if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
1277
+				if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) {
1278 1278
 					$domain = preg_quote($cookie['domain']);
1279
-					if (! preg_match("'.*$domain$'i", $this->host)) {
1279
+					if (!preg_match("'.*$domain$'i", $this->host)) {
1280 1280
 						$this->debug('cookie has different domain');
1281 1281
 						continue;
1282 1282
 					}
1283 1283
 				}
1284
-				if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
1284
+				if ((isset($cookie['path'])) && (!empty($cookie['path']))) {
1285 1285
 					$path = preg_quote($cookie['path']);
1286
-					if (! preg_match("'^$path.*'i", $this->path)) {
1286
+					if (!preg_match("'^$path.*'i", $this->path)) {
1287 1287
 						$this->debug('cookie is for a different path');
1288 1288
 						continue;
1289 1289
 					}
1290 1290
 				}
1291
-				if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1291
+				if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
1292 1292
 					$this->debug('cookie is secure, transport is not');
1293 1293
 					continue;
1294 1294
 				}
1295
-				$cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; ';
1296
-	    		$this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
1295
+				$cookie_str .= $cookie['name'].'='.$cookie['value'].'; ';
1296
+	    		$this->debug('add cookie to Cookie-String: '.$cookie['name'].'='.$cookie['value']);
1297 1297
 			}
1298 1298
 		}
1299 1299
 		return $cookie_str;
Please login to merge, or discard this patch.
main/inc/lib/nusoap/nusoapmime.php 2 patches
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	* @access public
87 87
 	*/
88 88
 	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
-		if (! $cid) {
89
+		if (!$cid) {
90 90
 			$cid = md5(uniqid(time()));
91 91
 		}
92 92
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	* @access   private
222 222
 	*/
223 223
     function parseResponse($headers, $data) {
224
-		$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
224
+		$this->debug('Entering parseResponse() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
225 225
 		$this->responseAttachments = array();
226 226
 		if (strstr($headers['content-type'], 'multipart/related')) {
227 227
 			$this->debug('Decode multipart/related');
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
 			foreach ($headers as $k => $v) {
230 230
 				$input .= "$k: $v\r\n";
231 231
 			}
232
-			$params['input'] = $input . "\r\n" . $data;
232
+			$params['input'] = $input."\r\n".$data;
233 233
 			$params['include_bodies'] = true;
234 234
 			$params['decode_bodies'] = true;
235 235
 			$params['decode_headers'] = true;
@@ -238,11 +238,11 @@  discard block
 block discarded – undo
238 238
 
239 239
 			foreach ($structure->parts as $part) {
240 240
 				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
241
+					$this->debug('Have root part of type '.$part->headers['content-type']);
242 242
 					$root = $part->body;
243 243
 					$return = parent::parseResponse($part->headers, $part->body);
244 244
 				} else {
245
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
245
+					$this->debug('Have an attachment of type '.$part->headers['content-type']);
246 246
 					$info['data'] = $part->body;
247 247
 					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248 248
 					$info['contenttype'] = $part->headers['content-type'];
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 	* @access public
317 317
 	*/
318 318
 	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
-		if (! $cid) {
319
+		if (!$cid) {
320 320
 			$cid = md5(uniqid(time()));
321 321
 		}
322 322
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	* @access   private
452 452
 	*/
453 453
     function parseRequest($headers, $data) {
454
-		$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
454
+		$this->debug('Entering parseRequest() for payload of length '.strlen($data).' and type of '.$headers['content-type']);
455 455
 		$this->requestAttachments = array();
456 456
 		if (strstr($headers['content-type'], 'multipart/related')) {
457 457
 			$this->debug('Decode multipart/related');
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 			foreach ($headers as $k => $v) {
460 460
 				$input .= "$k: $v\r\n";
461 461
 			}
462
-			$params['input'] = $input . "\r\n" . $data;
462
+			$params['input'] = $input."\r\n".$data;
463 463
 			$params['include_bodies'] = true;
464 464
 			$params['decode_bodies'] = true;
465 465
 			$params['decode_headers'] = true;
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 
469 469
 			foreach ($structure->parts as $part) {
470 470
 				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
471
+					$this->debug('Have root part of type '.$part->headers['content-type']);
472 472
 					$return = parent::parseRequest($part->headers, $part->body);
473 473
 				} else {
474
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
474
+					$this->debug('Have an attachment of type '.$part->headers['content-type']);
475 475
 					$info['data'] = $part->body;
476 476
 					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477 477
 					$info['contenttype'] = $part->headers['content-type'];
Please login to merge, or discard this patch.
Indentation   +418 added lines, -418 removed lines patch added patch discarded remove patch
@@ -52,224 +52,224 @@  discard block
 block discarded – undo
52 52
 * @access   public
53 53
 */
54 54
 class nusoap_client_mime extends nusoap_client {
55
-	/**
56
-	 * @var array Each array element in the return is an associative array with keys
57
-	 * data, filename, contenttype, cid
58
-	 * @access private
59
-	 */
60
-	var $requestAttachments = array();
61
-	/**
62
-	 * @var array Each array element in the return is an associative array with keys
63
-	 * data, filename, contenttype, cid
64
-	 * @access private
65
-	 */
66
-	var $responseAttachments;
67
-	/**
68
-	 * @var string
69
-	 * @access private
70
-	 */
71
-	var $mimeContentType;
72
-
73
-	/**
74
-	* adds a MIME attachment to the current request.
75
-	*
76
-	* If the $data parameter contains an empty string, this method will read
77
-	* the contents of the file named by the $filename parameter.
78
-	*
79
-	* If the $cid parameter is false, this method will generate the cid.
80
-	*
81
-	* @param string $data The data of the attachment
82
-	* @param string $filename The filename of the attachment (default is empty string)
83
-	* @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
84
-	* @param string $cid The content-id (cid) of the attachment (default is false)
85
-	* @return string The content-id (cid) of the attachment
86
-	* @access public
87
-	*/
88
-	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
-		if (! $cid) {
90
-			$cid = md5(uniqid(time()));
91
-		}
92
-
93
-		$info['data'] = $data;
94
-		$info['filename'] = $filename;
95
-		$info['contenttype'] = $contenttype;
96
-		$info['cid'] = $cid;
97
-
98
-		$this->requestAttachments[] = $info;
99
-
100
-		return $cid;
101
-	}
102
-
103
-	/**
104
-	* clears the MIME attachments for the current request.
105
-	*
106
-	* @access public
107
-	*/
108
-	function clearAttachments() {
109
-		$this->requestAttachments = array();
110
-	}
111
-
112
-	/**
113
-	* gets the MIME attachments from the current response.
114
-	*
115
-	* Each array element in the return is an associative array with keys
116
-	* data, filename, contenttype, cid.  These keys correspond to the parameters
117
-	* for addAttachment.
118
-	*
119
-	* @return array The attachments.
120
-	* @access public
121
-	*/
122
-	function getAttachments() {
123
-		return $this->responseAttachments;
124
-	}
125
-
126
-	/**
127
-	* gets the HTTP body for the current request.
128
-	*
129
-	* @param string $soapmsg The SOAP payload
130
-	* @return string The HTTP body, which includes the SOAP payload
131
-	* @access private
132
-	*/
133
-	function getHTTPBody($soapmsg) {
134
-		if (count($this->requestAttachments) > 0) {
135
-			$params['content_type'] = 'multipart/related; type="text/xml"';
136
-			$mimeMessage = new Mail_mimePart('', $params);
137
-			unset($params);
138
-
139
-			$params['content_type'] = 'text/xml';
140
-			$params['encoding']     = '8bit';
141
-			$params['charset']      = $this->soap_defencoding;
142
-			$mimeMessage->addSubpart($soapmsg, $params);
143
-
144
-			foreach ($this->requestAttachments as $att) {
145
-				unset($params);
146
-
147
-				$params['content_type'] = $att['contenttype'];
148
-				$params['encoding']     = 'base64';
149
-				$params['disposition']  = 'attachment';
150
-				$params['dfilename']    = $att['filename'];
151
-				$params['cid']          = $att['cid'];
152
-
153
-				if ($att['data'] == '' && $att['filename'] <> '') {
154
-					if ($fd = fopen($att['filename'], 'rb')) {
155
-						$data = fread($fd, filesize($att['filename']));
156
-						fclose($fd);
157
-					} else {
158
-						$data = '';
159
-					}
160
-					$mimeMessage->addSubpart($data, $params);
161
-				} else {
162
-					$mimeMessage->addSubpart($att['data'], $params);
163
-				}
164
-			}
165
-
166
-			$output = $mimeMessage->encode();
167
-			$mimeHeaders = $output['headers'];
168
-
169
-			foreach ($mimeHeaders as $k => $v) {
170
-				$this->debug("MIME header $k: $v");
171
-				if (strtolower($k) == 'content-type') {
172
-					// PHP header() seems to strip leading whitespace starting
173
-					// the second line, so force everything to one line
174
-					$this->mimeContentType = str_replace("\r\n", " ", $v);
175
-				}
176
-			}
177
-
178
-			return $output['body'];
179
-		}
180
-
181
-		return parent::getHTTPBody($soapmsg);
182
-	}
183
-
184
-	/**
185
-	* gets the HTTP content type for the current request.
186
-	*
187
-	* Note: getHTTPBody must be called before this.
188
-	*
189
-	* @return string the HTTP content type for the current request.
190
-	* @access private
191
-	*/
192
-	function getHTTPContentType() {
193
-		if (count($this->requestAttachments) > 0) {
194
-			return $this->mimeContentType;
195
-		}
196
-		return parent::getHTTPContentType();
197
-	}
198
-
199
-	/**
200
-	* gets the HTTP content type charset for the current request.
201
-	* returns false for non-text content types.
202
-	*
203
-	* Note: getHTTPBody must be called before this.
204
-	*
205
-	* @return string the HTTP content type charset for the current request.
206
-	* @access private
207
-	*/
208
-	function getHTTPContentTypeCharset() {
209
-		if (count($this->requestAttachments) > 0) {
210
-			return false;
211
-		}
212
-		return parent::getHTTPContentTypeCharset();
213
-	}
214
-
215
-	/**
216
-	* processes SOAP message returned from server
217
-	*
218
-	* @param	array	$headers	The HTTP headers
219
-	* @param	string	$data		unprocessed response data from server
220
-	* @return	mixed	value of the message, decoded into a PHP type
221
-	* @access   private
222
-	*/
55
+    /**
56
+     * @var array Each array element in the return is an associative array with keys
57
+     * data, filename, contenttype, cid
58
+     * @access private
59
+     */
60
+    var $requestAttachments = array();
61
+    /**
62
+     * @var array Each array element in the return is an associative array with keys
63
+     * data, filename, contenttype, cid
64
+     * @access private
65
+     */
66
+    var $responseAttachments;
67
+    /**
68
+     * @var string
69
+     * @access private
70
+     */
71
+    var $mimeContentType;
72
+
73
+    /**
74
+     * adds a MIME attachment to the current request.
75
+     *
76
+     * If the $data parameter contains an empty string, this method will read
77
+     * the contents of the file named by the $filename parameter.
78
+     *
79
+     * If the $cid parameter is false, this method will generate the cid.
80
+     *
81
+     * @param string $data The data of the attachment
82
+     * @param string $filename The filename of the attachment (default is empty string)
83
+     * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
84
+     * @param string $cid The content-id (cid) of the attachment (default is false)
85
+     * @return string The content-id (cid) of the attachment
86
+     * @access public
87
+     */
88
+    function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
89
+        if (! $cid) {
90
+            $cid = md5(uniqid(time()));
91
+        }
92
+
93
+        $info['data'] = $data;
94
+        $info['filename'] = $filename;
95
+        $info['contenttype'] = $contenttype;
96
+        $info['cid'] = $cid;
97
+
98
+        $this->requestAttachments[] = $info;
99
+
100
+        return $cid;
101
+    }
102
+
103
+    /**
104
+     * clears the MIME attachments for the current request.
105
+     *
106
+     * @access public
107
+     */
108
+    function clearAttachments() {
109
+        $this->requestAttachments = array();
110
+    }
111
+
112
+    /**
113
+     * gets the MIME attachments from the current response.
114
+     *
115
+     * Each array element in the return is an associative array with keys
116
+     * data, filename, contenttype, cid.  These keys correspond to the parameters
117
+     * for addAttachment.
118
+     *
119
+     * @return array The attachments.
120
+     * @access public
121
+     */
122
+    function getAttachments() {
123
+        return $this->responseAttachments;
124
+    }
125
+
126
+    /**
127
+     * gets the HTTP body for the current request.
128
+     *
129
+     * @param string $soapmsg The SOAP payload
130
+     * @return string The HTTP body, which includes the SOAP payload
131
+     * @access private
132
+     */
133
+    function getHTTPBody($soapmsg) {
134
+        if (count($this->requestAttachments) > 0) {
135
+            $params['content_type'] = 'multipart/related; type="text/xml"';
136
+            $mimeMessage = new Mail_mimePart('', $params);
137
+            unset($params);
138
+
139
+            $params['content_type'] = 'text/xml';
140
+            $params['encoding']     = '8bit';
141
+            $params['charset']      = $this->soap_defencoding;
142
+            $mimeMessage->addSubpart($soapmsg, $params);
143
+
144
+            foreach ($this->requestAttachments as $att) {
145
+                unset($params);
146
+
147
+                $params['content_type'] = $att['contenttype'];
148
+                $params['encoding']     = 'base64';
149
+                $params['disposition']  = 'attachment';
150
+                $params['dfilename']    = $att['filename'];
151
+                $params['cid']          = $att['cid'];
152
+
153
+                if ($att['data'] == '' && $att['filename'] <> '') {
154
+                    if ($fd = fopen($att['filename'], 'rb')) {
155
+                        $data = fread($fd, filesize($att['filename']));
156
+                        fclose($fd);
157
+                    } else {
158
+                        $data = '';
159
+                    }
160
+                    $mimeMessage->addSubpart($data, $params);
161
+                } else {
162
+                    $mimeMessage->addSubpart($att['data'], $params);
163
+                }
164
+            }
165
+
166
+            $output = $mimeMessage->encode();
167
+            $mimeHeaders = $output['headers'];
168
+
169
+            foreach ($mimeHeaders as $k => $v) {
170
+                $this->debug("MIME header $k: $v");
171
+                if (strtolower($k) == 'content-type') {
172
+                    // PHP header() seems to strip leading whitespace starting
173
+                    // the second line, so force everything to one line
174
+                    $this->mimeContentType = str_replace("\r\n", " ", $v);
175
+                }
176
+            }
177
+
178
+            return $output['body'];
179
+        }
180
+
181
+        return parent::getHTTPBody($soapmsg);
182
+    }
183
+
184
+    /**
185
+     * gets the HTTP content type for the current request.
186
+     *
187
+     * Note: getHTTPBody must be called before this.
188
+     *
189
+     * @return string the HTTP content type for the current request.
190
+     * @access private
191
+     */
192
+    function getHTTPContentType() {
193
+        if (count($this->requestAttachments) > 0) {
194
+            return $this->mimeContentType;
195
+        }
196
+        return parent::getHTTPContentType();
197
+    }
198
+
199
+    /**
200
+     * gets the HTTP content type charset for the current request.
201
+     * returns false for non-text content types.
202
+     *
203
+     * Note: getHTTPBody must be called before this.
204
+     *
205
+     * @return string the HTTP content type charset for the current request.
206
+     * @access private
207
+     */
208
+    function getHTTPContentTypeCharset() {
209
+        if (count($this->requestAttachments) > 0) {
210
+            return false;
211
+        }
212
+        return parent::getHTTPContentTypeCharset();
213
+    }
214
+
215
+    /**
216
+     * processes SOAP message returned from server
217
+     *
218
+     * @param	array	$headers	The HTTP headers
219
+     * @param	string	$data		unprocessed response data from server
220
+     * @return	mixed	value of the message, decoded into a PHP type
221
+     * @access   private
222
+     */
223 223
     function parseResponse($headers, $data) {
224
-		$this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
225
-		$this->responseAttachments = array();
226
-		if (strstr($headers['content-type'], 'multipart/related')) {
227
-			$this->debug('Decode multipart/related');
228
-			$input = '';
229
-			foreach ($headers as $k => $v) {
230
-				$input .= "$k: $v\r\n";
231
-			}
232
-			$params['input'] = $input . "\r\n" . $data;
233
-			$params['include_bodies'] = true;
234
-			$params['decode_bodies'] = true;
235
-			$params['decode_headers'] = true;
236
-
237
-			$structure = Mail_mimeDecode::decode($params);
238
-
239
-			foreach ($structure->parts as $part) {
240
-				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
242
-					$root = $part->body;
243
-					$return = parent::parseResponse($part->headers, $part->body);
244
-				} else {
245
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
246
-					$info['data'] = $part->body;
247
-					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248
-					$info['contenttype'] = $part->headers['content-type'];
249
-					$info['cid'] = $part->headers['content-id'];
250
-					$this->responseAttachments[] = $info;
251
-				}
252
-			}
253
-
254
-			if (isset($return)) {
255
-				$this->responseData = $root;
256
-				return $return;
257
-			}
258
-
259
-			$this->setError('No root part found in multipart/related content');
260
-			return '';
261
-		}
262
-		$this->debug('Not multipart/related');
263
-		return parent::parseResponse($headers, $data);
264
-	}
224
+        $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
225
+        $this->responseAttachments = array();
226
+        if (strstr($headers['content-type'], 'multipart/related')) {
227
+            $this->debug('Decode multipart/related');
228
+            $input = '';
229
+            foreach ($headers as $k => $v) {
230
+                $input .= "$k: $v\r\n";
231
+            }
232
+            $params['input'] = $input . "\r\n" . $data;
233
+            $params['include_bodies'] = true;
234
+            $params['decode_bodies'] = true;
235
+            $params['decode_headers'] = true;
236
+
237
+            $structure = Mail_mimeDecode::decode($params);
238
+
239
+            foreach ($structure->parts as $part) {
240
+                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
241
+                    $this->debug('Have root part of type ' . $part->headers['content-type']);
242
+                    $root = $part->body;
243
+                    $return = parent::parseResponse($part->headers, $part->body);
244
+                } else {
245
+                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
246
+                    $info['data'] = $part->body;
247
+                    $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
248
+                    $info['contenttype'] = $part->headers['content-type'];
249
+                    $info['cid'] = $part->headers['content-id'];
250
+                    $this->responseAttachments[] = $info;
251
+                }
252
+            }
253
+
254
+            if (isset($return)) {
255
+                $this->responseData = $root;
256
+                return $return;
257
+            }
258
+
259
+            $this->setError('No root part found in multipart/related content');
260
+            return '';
261
+        }
262
+        $this->debug('Not multipart/related');
263
+        return parent::parseResponse($headers, $data);
264
+    }
265 265
 }
266 266
 
267 267
 /*
268 268
  *	For backwards compatiblity, define soapclientmime unless the PHP SOAP extension is loaded.
269 269
  */
270 270
 if (!extension_loaded('soap')) {
271
-	class soapclientmime extends nusoap_client_mime {
272
-	}
271
+    class soapclientmime extends nusoap_client_mime {
272
+    }
273 273
 }
274 274
 
275 275
 /**
@@ -282,214 +282,214 @@  discard block
 block discarded – undo
282 282
 * @access   public
283 283
 */
284 284
 class nusoap_server_mime extends nusoap_server {
285
-	/**
286
-	 * @var array Each array element in the return is an associative array with keys
287
-	 * data, filename, contenttype, cid
288
-	 * @access private
289
-	 */
290
-	var $requestAttachments = array();
291
-	/**
292
-	 * @var array Each array element in the return is an associative array with keys
293
-	 * data, filename, contenttype, cid
294
-	 * @access private
295
-	 */
296
-	var $responseAttachments;
297
-	/**
298
-	 * @var string
299
-	 * @access private
300
-	 */
301
-	var $mimeContentType;
302
-
303
-	/**
304
-	* adds a MIME attachment to the current response.
305
-	*
306
-	* If the $data parameter contains an empty string, this method will read
307
-	* the contents of the file named by the $filename parameter.
308
-	*
309
-	* If the $cid parameter is false, this method will generate the cid.
310
-	*
311
-	* @param string $data The data of the attachment
312
-	* @param string $filename The filename of the attachment (default is empty string)
313
-	* @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
314
-	* @param string $cid The content-id (cid) of the attachment (default is false)
315
-	* @return string The content-id (cid) of the attachment
316
-	* @access public
317
-	*/
318
-	function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
-		if (! $cid) {
320
-			$cid = md5(uniqid(time()));
321
-		}
322
-
323
-		$info['data'] = $data;
324
-		$info['filename'] = $filename;
325
-		$info['contenttype'] = $contenttype;
326
-		$info['cid'] = $cid;
327
-
328
-		$this->responseAttachments[] = $info;
329
-
330
-		return $cid;
331
-	}
332
-
333
-	/**
334
-	* clears the MIME attachments for the current response.
335
-	*
336
-	* @access public
337
-	*/
338
-	function clearAttachments() {
339
-		$this->responseAttachments = array();
340
-	}
341
-
342
-	/**
343
-	* gets the MIME attachments from the current request.
344
-	*
345
-	* Each array element in the return is an associative array with keys
346
-	* data, filename, contenttype, cid.  These keys correspond to the parameters
347
-	* for addAttachment.
348
-	*
349
-	* @return array The attachments.
350
-	* @access public
351
-	*/
352
-	function getAttachments() {
353
-		return $this->requestAttachments;
354
-	}
355
-
356
-	/**
357
-	* gets the HTTP body for the current response.
358
-	*
359
-	* @param string $soapmsg The SOAP payload
360
-	* @return string The HTTP body, which includes the SOAP payload
361
-	* @access private
362
-	*/
363
-	function getHTTPBody($soapmsg) {
364
-		if (count($this->responseAttachments) > 0) {
365
-			$params['content_type'] = 'multipart/related; type="text/xml"';
366
-			$mimeMessage = new Mail_mimePart('', $params);
367
-			unset($params);
368
-
369
-			$params['content_type'] = 'text/xml';
370
-			$params['encoding']     = '8bit';
371
-			$params['charset']      = $this->soap_defencoding;
372
-			$mimeMessage->addSubpart($soapmsg, $params);
373
-
374
-			foreach ($this->responseAttachments as $att) {
375
-				unset($params);
376
-
377
-				$params['content_type'] = $att['contenttype'];
378
-				$params['encoding']     = 'base64';
379
-				$params['disposition']  = 'attachment';
380
-				$params['dfilename']    = $att['filename'];
381
-				$params['cid']          = $att['cid'];
382
-
383
-				if ($att['data'] == '' && $att['filename'] <> '') {
384
-					if ($fd = fopen($att['filename'], 'rb')) {
385
-						$data = fread($fd, filesize($att['filename']));
386
-						fclose($fd);
387
-					} else {
388
-						$data = '';
389
-					}
390
-					$mimeMessage->addSubpart($data, $params);
391
-				} else {
392
-					$mimeMessage->addSubpart($att['data'], $params);
393
-				}
394
-			}
395
-
396
-			$output = $mimeMessage->encode();
397
-			$mimeHeaders = $output['headers'];
398
-
399
-			foreach ($mimeHeaders as $k => $v) {
400
-				$this->debug("MIME header $k: $v");
401
-				if (strtolower($k) == 'content-type') {
402
-					// PHP header() seems to strip leading whitespace starting
403
-					// the second line, so force everything to one line
404
-					$this->mimeContentType = str_replace("\r\n", " ", $v);
405
-				}
406
-			}
407
-
408
-			return $output['body'];
409
-		}
410
-
411
-		return parent::getHTTPBody($soapmsg);
412
-	}
413
-
414
-	/**
415
-	* gets the HTTP content type for the current response.
416
-	*
417
-	* Note: getHTTPBody must be called before this.
418
-	*
419
-	* @return string the HTTP content type for the current response.
420
-	* @access private
421
-	*/
422
-	function getHTTPContentType() {
423
-		if (count($this->responseAttachments) > 0) {
424
-			return $this->mimeContentType;
425
-		}
426
-		return parent::getHTTPContentType();
427
-	}
428
-
429
-	/**
430
-	* gets the HTTP content type charset for the current response.
431
-	* returns false for non-text content types.
432
-	*
433
-	* Note: getHTTPBody must be called before this.
434
-	*
435
-	* @return string the HTTP content type charset for the current response.
436
-	* @access private
437
-	*/
438
-	function getHTTPContentTypeCharset() {
439
-		if (count($this->responseAttachments) > 0) {
440
-			return false;
441
-		}
442
-		return parent::getHTTPContentTypeCharset();
443
-	}
444
-
445
-	/**
446
-	* processes SOAP message received from client
447
-	*
448
-	* @param	array	$headers	The HTTP headers
449
-	* @param	string	$data		unprocessed request data from client
450
-	* @return	mixed	value of the message, decoded into a PHP type
451
-	* @access   private
452
-	*/
285
+    /**
286
+     * @var array Each array element in the return is an associative array with keys
287
+     * data, filename, contenttype, cid
288
+     * @access private
289
+     */
290
+    var $requestAttachments = array();
291
+    /**
292
+     * @var array Each array element in the return is an associative array with keys
293
+     * data, filename, contenttype, cid
294
+     * @access private
295
+     */
296
+    var $responseAttachments;
297
+    /**
298
+     * @var string
299
+     * @access private
300
+     */
301
+    var $mimeContentType;
302
+
303
+    /**
304
+     * adds a MIME attachment to the current response.
305
+     *
306
+     * If the $data parameter contains an empty string, this method will read
307
+     * the contents of the file named by the $filename parameter.
308
+     *
309
+     * If the $cid parameter is false, this method will generate the cid.
310
+     *
311
+     * @param string $data The data of the attachment
312
+     * @param string $filename The filename of the attachment (default is empty string)
313
+     * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream)
314
+     * @param string $cid The content-id (cid) of the attachment (default is false)
315
+     * @return string The content-id (cid) of the attachment
316
+     * @access public
317
+     */
318
+    function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) {
319
+        if (! $cid) {
320
+            $cid = md5(uniqid(time()));
321
+        }
322
+
323
+        $info['data'] = $data;
324
+        $info['filename'] = $filename;
325
+        $info['contenttype'] = $contenttype;
326
+        $info['cid'] = $cid;
327
+
328
+        $this->responseAttachments[] = $info;
329
+
330
+        return $cid;
331
+    }
332
+
333
+    /**
334
+     * clears the MIME attachments for the current response.
335
+     *
336
+     * @access public
337
+     */
338
+    function clearAttachments() {
339
+        $this->responseAttachments = array();
340
+    }
341
+
342
+    /**
343
+     * gets the MIME attachments from the current request.
344
+     *
345
+     * Each array element in the return is an associative array with keys
346
+     * data, filename, contenttype, cid.  These keys correspond to the parameters
347
+     * for addAttachment.
348
+     *
349
+     * @return array The attachments.
350
+     * @access public
351
+     */
352
+    function getAttachments() {
353
+        return $this->requestAttachments;
354
+    }
355
+
356
+    /**
357
+     * gets the HTTP body for the current response.
358
+     *
359
+     * @param string $soapmsg The SOAP payload
360
+     * @return string The HTTP body, which includes the SOAP payload
361
+     * @access private
362
+     */
363
+    function getHTTPBody($soapmsg) {
364
+        if (count($this->responseAttachments) > 0) {
365
+            $params['content_type'] = 'multipart/related; type="text/xml"';
366
+            $mimeMessage = new Mail_mimePart('', $params);
367
+            unset($params);
368
+
369
+            $params['content_type'] = 'text/xml';
370
+            $params['encoding']     = '8bit';
371
+            $params['charset']      = $this->soap_defencoding;
372
+            $mimeMessage->addSubpart($soapmsg, $params);
373
+
374
+            foreach ($this->responseAttachments as $att) {
375
+                unset($params);
376
+
377
+                $params['content_type'] = $att['contenttype'];
378
+                $params['encoding']     = 'base64';
379
+                $params['disposition']  = 'attachment';
380
+                $params['dfilename']    = $att['filename'];
381
+                $params['cid']          = $att['cid'];
382
+
383
+                if ($att['data'] == '' && $att['filename'] <> '') {
384
+                    if ($fd = fopen($att['filename'], 'rb')) {
385
+                        $data = fread($fd, filesize($att['filename']));
386
+                        fclose($fd);
387
+                    } else {
388
+                        $data = '';
389
+                    }
390
+                    $mimeMessage->addSubpart($data, $params);
391
+                } else {
392
+                    $mimeMessage->addSubpart($att['data'], $params);
393
+                }
394
+            }
395
+
396
+            $output = $mimeMessage->encode();
397
+            $mimeHeaders = $output['headers'];
398
+
399
+            foreach ($mimeHeaders as $k => $v) {
400
+                $this->debug("MIME header $k: $v");
401
+                if (strtolower($k) == 'content-type') {
402
+                    // PHP header() seems to strip leading whitespace starting
403
+                    // the second line, so force everything to one line
404
+                    $this->mimeContentType = str_replace("\r\n", " ", $v);
405
+                }
406
+            }
407
+
408
+            return $output['body'];
409
+        }
410
+
411
+        return parent::getHTTPBody($soapmsg);
412
+    }
413
+
414
+    /**
415
+     * gets the HTTP content type for the current response.
416
+     *
417
+     * Note: getHTTPBody must be called before this.
418
+     *
419
+     * @return string the HTTP content type for the current response.
420
+     * @access private
421
+     */
422
+    function getHTTPContentType() {
423
+        if (count($this->responseAttachments) > 0) {
424
+            return $this->mimeContentType;
425
+        }
426
+        return parent::getHTTPContentType();
427
+    }
428
+
429
+    /**
430
+     * gets the HTTP content type charset for the current response.
431
+     * returns false for non-text content types.
432
+     *
433
+     * Note: getHTTPBody must be called before this.
434
+     *
435
+     * @return string the HTTP content type charset for the current response.
436
+     * @access private
437
+     */
438
+    function getHTTPContentTypeCharset() {
439
+        if (count($this->responseAttachments) > 0) {
440
+            return false;
441
+        }
442
+        return parent::getHTTPContentTypeCharset();
443
+    }
444
+
445
+    /**
446
+     * processes SOAP message received from client
447
+     *
448
+     * @param	array	$headers	The HTTP headers
449
+     * @param	string	$data		unprocessed request data from client
450
+     * @return	mixed	value of the message, decoded into a PHP type
451
+     * @access   private
452
+     */
453 453
     function parseRequest($headers, $data) {
454
-		$this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
455
-		$this->requestAttachments = array();
456
-		if (strstr($headers['content-type'], 'multipart/related')) {
457
-			$this->debug('Decode multipart/related');
458
-			$input = '';
459
-			foreach ($headers as $k => $v) {
460
-				$input .= "$k: $v\r\n";
461
-			}
462
-			$params['input'] = $input . "\r\n" . $data;
463
-			$params['include_bodies'] = true;
464
-			$params['decode_bodies'] = true;
465
-			$params['decode_headers'] = true;
466
-
467
-			$structure = Mail_mimeDecode::decode($params);
468
-
469
-			foreach ($structure->parts as $part) {
470
-				if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
-					$this->debug('Have root part of type ' . $part->headers['content-type']);
472
-					$return = parent::parseRequest($part->headers, $part->body);
473
-				} else {
474
-					$this->debug('Have an attachment of type ' . $part->headers['content-type']);
475
-					$info['data'] = $part->body;
476
-					$info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477
-					$info['contenttype'] = $part->headers['content-type'];
478
-					$info['cid'] = $part->headers['content-id'];
479
-					$this->requestAttachments[] = $info;
480
-				}
481
-			}
482
-
483
-			if (isset($return)) {
484
-				return $return;
485
-			}
486
-
487
-			$this->setError('No root part found in multipart/related content');
488
-			return;
489
-		}
490
-		$this->debug('Not multipart/related');
491
-		return parent::parseRequest($headers, $data);
492
-	}
454
+        $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']);
455
+        $this->requestAttachments = array();
456
+        if (strstr($headers['content-type'], 'multipart/related')) {
457
+            $this->debug('Decode multipart/related');
458
+            $input = '';
459
+            foreach ($headers as $k => $v) {
460
+                $input .= "$k: $v\r\n";
461
+            }
462
+            $params['input'] = $input . "\r\n" . $data;
463
+            $params['include_bodies'] = true;
464
+            $params['decode_bodies'] = true;
465
+            $params['decode_headers'] = true;
466
+
467
+            $structure = Mail_mimeDecode::decode($params);
468
+
469
+            foreach ($structure->parts as $part) {
470
+                if (!isset($part->disposition) && (strstr($part->headers['content-type'], 'text/xml'))) {
471
+                    $this->debug('Have root part of type ' . $part->headers['content-type']);
472
+                    $return = parent::parseRequest($part->headers, $part->body);
473
+                } else {
474
+                    $this->debug('Have an attachment of type ' . $part->headers['content-type']);
475
+                    $info['data'] = $part->body;
476
+                    $info['filename'] = isset($part->d_parameters['filename']) ? $part->d_parameters['filename'] : '';
477
+                    $info['contenttype'] = $part->headers['content-type'];
478
+                    $info['cid'] = $part->headers['content-id'];
479
+                    $this->requestAttachments[] = $info;
480
+                }
481
+            }
482
+
483
+            if (isset($return)) {
484
+                return $return;
485
+            }
486
+
487
+            $this->setError('No root part found in multipart/related content');
488
+            return;
489
+        }
490
+        $this->debug('Not multipart/related');
491
+        return parent::parseRequest($headers, $data);
492
+    }
493 493
 }
494 494
 
495 495
 /*
Please login to merge, or discard this patch.
main/inc/lib/nusoap/class.wsdl.php 3 patches
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,8 +78,9 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
Indentation   +1576 added lines, -1576 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 */
12 12
 class wsdl extends nusoap_base
13 13
 {
14
-	// URL or filename of the root of this WSDL
14
+    // URL or filename of the root of this WSDL
15 15
     var $wsdl;
16 16
     // define internal arrays of bindings, ports, operations, messages, etc.
17 17
     var $schemas = array();
@@ -38,142 +38,142 @@  discard block
 block discarded – undo
38 38
     var $position = 0;
39 39
     var $depth = 0;
40 40
     var $depth_array = array();
41
-	// for getting wsdl
42
-	var $proxyhost = '';
41
+    // for getting wsdl
42
+    var $proxyhost = '';
43 43
     var $proxyport = '';
44
-	var $proxyusername = '';
45
-	var $proxypassword = '';
46
-	var $timeout = 0;
47
-	var $response_timeout = 30;
48
-	var $curl_options = array();	// User-specified cURL options
49
-	var $use_curl = false;			// whether to always try to use cURL
50
-	// for HTTP authentication
51
-	var $username = '';				// Username for HTTP authentication
52
-	var $password = '';				// Password for HTTP authentication
53
-	var $authtype = '';				// Type of HTTP authentication
54
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
44
+    var $proxyusername = '';
45
+    var $proxypassword = '';
46
+    var $timeout = 0;
47
+    var $response_timeout = 30;
48
+    var $curl_options = array();	// User-specified cURL options
49
+    var $use_curl = false;			// whether to always try to use cURL
50
+    // for HTTP authentication
51
+    var $username = '';				// Username for HTTP authentication
52
+    var $password = '';				// Password for HTTP authentication
53
+    var $authtype = '';				// Type of HTTP authentication
54
+    var $certRequest = array();		// Certificate for HTTP SSL authentication
55 55
 
56 56
     /**
57 57
      * constructor
58 58
      *
59 59
      * @param string $wsdl WSDL document URL
60
-	 * @param string $proxyhost
61
-	 * @param string $proxyport
62
-	 * @param string $proxyusername
63
-	 * @param string $proxypassword
64
-	 * @param integer $timeout set the connection timeout
65
-	 * @param integer $response_timeout set the response timeout
66
-	 * @param array $curl_options user-specified cURL options
67
-	 * @param boolean $use_curl try to use cURL
60
+     * @param string $proxyhost
61
+     * @param string $proxyport
62
+     * @param string $proxyusername
63
+     * @param string $proxypassword
64
+     * @param integer $timeout set the connection timeout
65
+     * @param integer $response_timeout set the response timeout
66
+     * @param array $curl_options user-specified cURL options
67
+     * @param boolean $use_curl try to use cURL
68 68
      * @access public
69 69
      */
70 70
     function __construct($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
71
-		parent::__construct();
72
-		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
71
+        parent::__construct();
72
+        $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
73 73
         $this->proxyhost = $proxyhost;
74 74
         $this->proxyport = $proxyport;
75
-		$this->proxyusername = $proxyusername;
76
-		$this->proxypassword = $proxypassword;
77
-		$this->timeout = $timeout;
78
-		$this->response_timeout = $response_timeout;
79
-		if (is_array($curl_options))
80
-			$this->curl_options = $curl_options;
81
-		$this->use_curl = $use_curl;
82
-		$this->fetchWSDL($wsdl);
75
+        $this->proxyusername = $proxyusername;
76
+        $this->proxypassword = $proxypassword;
77
+        $this->timeout = $timeout;
78
+        $this->response_timeout = $response_timeout;
79
+        if (is_array($curl_options))
80
+            $this->curl_options = $curl_options;
81
+        $this->use_curl = $use_curl;
82
+        $this->fetchWSDL($wsdl);
83 83
     }
84 84
 
85
-	/**
86
-	 * fetches the WSDL document and parses it
87
-	 *
88
-	 * @access public
89
-	 */
90
-	function fetchWSDL($wsdl) {
91
-		$this->debug("parse and process WSDL path=$wsdl");
92
-		$this->wsdl = $wsdl;
85
+    /**
86
+     * fetches the WSDL document and parses it
87
+     *
88
+     * @access public
89
+     */
90
+    function fetchWSDL($wsdl) {
91
+        $this->debug("parse and process WSDL path=$wsdl");
92
+        $this->wsdl = $wsdl;
93 93
         // parse wsdl file
94 94
         if ($this->wsdl != "") {
95 95
             $this->parseWSDL($this->wsdl);
96 96
         }
97 97
         // imports
98 98
         // TODO: handle imports more properly, grabbing them in-line and nesting them
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
-					$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
107
-		            foreach ($xs->imports as $ns2 => $list2) {
108
-		                for ($ii = 0; $ii < count($list2); $ii++) {
109
-		                	if (! $list2[$ii]['loaded']) {
110
-		                		$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
111
-		                		$url = $list2[$ii]['location'];
112
-								if ($url != '') {
113
-									$urlparts = parse_url($url);
114
-									if (!isset($urlparts['host'])) {
115
-										$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
116
-												substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
117
-									}
118
-									if (! in_array($url, $imported_urls)) {
119
-					                	$this->parseWSDL($url);
120
-				                		$imported++;
121
-				                		$imported_urls[] = $url;
122
-				                	}
123
-								} else {
124
-									$this->debug("Unexpected scenario: empty URL for unloaded import");
125
-								}
126
-							}
127
-						}
128
-		            }
129
-    			}
130
-    		}
131
-    		// WSDL imports
132
-			$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
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
+                    $wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
107
+                    foreach ($xs->imports as $ns2 => $list2) {
108
+                        for ($ii = 0; $ii < count($list2); $ii++) {
109
+                            if (! $list2[$ii]['loaded']) {
110
+                                $this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
111
+                                $url = $list2[$ii]['location'];
112
+                                if ($url != '') {
113
+                                    $urlparts = parse_url($url);
114
+                                    if (!isset($urlparts['host'])) {
115
+                                        $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
116
+                                                substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
117
+                                    }
118
+                                    if (! in_array($url, $imported_urls)) {
119
+                                        $this->parseWSDL($url);
120
+                                        $imported++;
121
+                                        $imported_urls[] = $url;
122
+                                    }
123
+                                } else {
124
+                                    $this->debug("Unexpected scenario: empty URL for unloaded import");
125
+                                }
126
+                            }
127
+                        }
128
+                    }
129
+                }
130
+            }
131
+            // WSDL imports
132
+            $wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
133 133
             foreach ($this->import as $ns => $list) {
134 134
                 for ($ii = 0; $ii < count($list); $ii++) {
135
-                	if (! $list[$ii]['loaded']) {
136
-                		$this->import[$ns][$ii]['loaded'] = true;
137
-                		$url = $list[$ii]['location'];
138
-						if ($url != '') {
139
-							$urlparts = parse_url($url);
140
-							if (!isset($urlparts['host'])) {
141
-								$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
142
-										substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
143
-							}
144
-							if (! in_array($url, $imported_urls)) {
145
-			                	$this->parseWSDL($url);
146
-		                		$imported++;
147
-		                		$imported_urls[] = $url;
148
-		                	}
149
-						} else {
150
-							$this->debug("Unexpected scenario: empty URL for unloaded import");
151
-						}
152
-					}
153
-				}
135
+                    if (! $list[$ii]['loaded']) {
136
+                        $this->import[$ns][$ii]['loaded'] = true;
137
+                        $url = $list[$ii]['location'];
138
+                        if ($url != '') {
139
+                            $urlparts = parse_url($url);
140
+                            if (!isset($urlparts['host'])) {
141
+                                $url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
142
+                                        substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
143
+                            }
144
+                            if (! in_array($url, $imported_urls)) {
145
+                                $this->parseWSDL($url);
146
+                                $imported++;
147
+                                $imported_urls[] = $url;
148
+                            }
149
+                        } else {
150
+                            $this->debug("Unexpected scenario: empty URL for unloaded import");
151
+                        }
152
+                    }
153
+                }
154 154
             }
155
-		}
155
+        }
156 156
         // add new data to operation data
157 157
         foreach($this->bindings as $binding => $bindingData) {
158 158
             if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
159 159
                 foreach($bindingData['operations'] as $operation => $data) {
160 160
                     $this->debug('post-parse data gathering for ' . $operation);
161 161
                     $this->bindings[$binding]['operations'][$operation]['input'] =
162
-						isset($this->bindings[$binding]['operations'][$operation]['input']) ?
163
-						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
164
-						$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
162
+                        isset($this->bindings[$binding]['operations'][$operation]['input']) ?
163
+                        array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
164
+                        $this->portTypes[ $bindingData['portType'] ][$operation]['input'];
165 165
                     $this->bindings[$binding]['operations'][$operation]['output'] =
166
-						isset($this->bindings[$binding]['operations'][$operation]['output']) ?
167
-						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
168
-						$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
166
+                        isset($this->bindings[$binding]['operations'][$operation]['output']) ?
167
+                        array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
168
+                        $this->portTypes[ $bindingData['portType'] ][$operation]['output'];
169 169
                     if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
170
-						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
171
-					}
172
-					if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
173
-                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
170
+                        $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
171
+                    }
172
+                    if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
173
+                            $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
174 174
                     }
175 175
                     // Set operation style if necessary, but do not override one already provided
176
-					if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
176
+                    if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
177 177
                         $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
178 178
                     }
179 179
                     $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
                 }
183 183
             }
184 184
         }
185
-	}
185
+    }
186 186
 
187 187
     /**
188 188
      * parses the wsdl document
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @access private
192 192
      */
193 193
     function parseWSDL($wsdl = '') {
194
-		$this->debug("parse WSDL at path=$wsdl");
194
+        $this->debug("parse WSDL at path=$wsdl");
195 195
 
196 196
         if ($wsdl == '') {
197 197
             $this->debug('no wsdl passed to parseWSDL()!!');
@@ -204,38 +204,38 @@  discard block
 block discarded – undo
204 204
 
205 205
         if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
206 206
             $this->debug('getting WSDL http(s) URL ' . $wsdl);
207
-        	// get wsdl
208
-	        $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
209
-			$tr->request_method = 'GET';
210
-			$tr->useSOAPAction = false;
211
-			if($this->proxyhost && $this->proxyport){
212
-				$tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
213
-			}
214
-			if ($this->authtype != '') {
215
-				$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
216
-			}
217
-			$tr->setEncoding('gzip, deflate');
218
-			$wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
219
-			//$this->debug("WSDL request\n" . $tr->outgoing_payload);
220
-			//$this->debug("WSDL response\n" . $tr->incoming_payload);
221
-			$this->appendDebug($tr->getDebug());
222
-			// catch errors
223
-			if($err = $tr->getError() ){
224
-				$errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
225
-				$this->debug($errstr);
226
-	            $this->setError($errstr);
227
-				unset($tr);
228
-	            return false;
229
-			}
230
-			unset($tr);
231
-			$this->debug("got WSDL URL");
207
+            // get wsdl
208
+            $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
209
+            $tr->request_method = 'GET';
210
+            $tr->useSOAPAction = false;
211
+            if($this->proxyhost && $this->proxyport){
212
+                $tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
213
+            }
214
+            if ($this->authtype != '') {
215
+                $tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
216
+            }
217
+            $tr->setEncoding('gzip, deflate');
218
+            $wsdl_string = $tr->send('', $this->timeout, $this->response_timeout);
219
+            //$this->debug("WSDL request\n" . $tr->outgoing_payload);
220
+            //$this->debug("WSDL response\n" . $tr->incoming_payload);
221
+            $this->appendDebug($tr->getDebug());
222
+            // catch errors
223
+            if($err = $tr->getError() ){
224
+                $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
225
+                $this->debug($errstr);
226
+                $this->setError($errstr);
227
+                unset($tr);
228
+                return false;
229
+            }
230
+            unset($tr);
231
+            $this->debug("got WSDL URL");
232 232
         } else {
233 233
             // $wsdl is not http(s), so treat it as a file URL or plain file path
234
-        	if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
235
-        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
236
-        	} else {
237
-        		$path = $wsdl;
238
-        	}
234
+            if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
235
+                $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
236
+            } else {
237
+                $path = $wsdl;
238
+            }
239 239
             $this->debug('getting WSDL file ' . $path);
240 240
             if ($fp = @fopen($path, 'r')) {
241 241
                 $wsdl_string = '';
@@ -244,8 +244,8 @@  discard block
 block discarded – undo
244 244
                 }
245 245
                 fclose($fp);
246 246
             } else {
247
-            	$errstr = "Bad path to WSDL file $path";
248
-            	$this->debug($errstr);
247
+                $errstr = "Bad path to WSDL file $path";
248
+                $this->debug($errstr);
249 249
                 $this->setError($errstr);
250 250
                 return false;
251 251
             }
@@ -266,23 +266,23 @@  discard block
 block discarded – undo
266 266
         if (!xml_parse($this->parser, $wsdl_string, true)) {
267 267
             // Display an error message.
268 268
             $errstr = sprintf(
269
-				'XML error parsing WSDL from %s on line %d: %s',
270
-				$wsdl,
269
+                'XML error parsing WSDL from %s on line %d: %s',
270
+                $wsdl,
271 271
                 xml_get_current_line_number($this->parser),
272 272
                 xml_error_string(xml_get_error_code($this->parser))
273 273
                 );
274 274
             $this->debug($errstr);
275
-			$this->debug("XML payload:\n" . $wsdl_string);
275
+            $this->debug("XML payload:\n" . $wsdl_string);
276 276
             $this->setError($errstr);
277 277
             return false;
278 278
         }
279
-		// free the parser
279
+        // free the parser
280 280
         xml_parser_free($this->parser);
281 281
         $this->debug('Parsing WSDL done');
282
-		// catch wsdl parse errors
283
-		if($this->getError()){
284
-			return false;
285
-		}
282
+        // catch wsdl parse errors
283
+        if($this->getError()){
284
+            return false;
285
+        }
286 286
         return true;
287 287
     }
288 288
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
             $this->appendDebug($this->currentSchema->getDebug());
302 302
             $this->currentSchema->clearDebug();
303 303
         } elseif (preg_match('/schema$/', $name)) {
304
-        	$this->debug('Parsing WSDL schema');
304
+            $this->debug('Parsing WSDL schema');
305 305
             // $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
306 306
             $this->status = 'schema';
307 307
             $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces);
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
             $this->message[$pos] = array('cdata' => '');
318 318
             // process attributes
319 319
             if (count($attrs) > 0) {
320
-				// register namespace declarations
320
+                // register namespace declarations
321 321
                 foreach($attrs as $k => $v) {
322 322
                     if (preg_match('/^xmlns/',$k)) {
323 323
                         if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
@@ -352,417 +352,417 @@  discard block
 block discarded – undo
352 352
                 // get unqualified name
353 353
                 $name = substr(strstr($name, ':'), 1);
354 354
             }
355
-			// process attributes, expanding any prefixes to namespaces
355
+            // process attributes, expanding any prefixes to namespaces
356 356
             // find status, register data
357 357
             switch ($this->status) {
358 358
                 case 'message':
359 359
                     if ($name == 'part') {
360
-			            if (isset($attrs['type'])) {
361
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
362
-		                    $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
363
-            			}
364
-			            if (isset($attrs['element'])) {
365
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
366
-			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
367
-			            }
368
-        			}
369
-        			break;
370
-			    case 'portType':
371
-			        switch ($name) {
372
-			            case 'operation':
373
-			                $this->currentPortOperation = $attrs['name'];
374
-			                $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
375
-			                if (isset($attrs['parameterOrder'])) {
376
-			                	$this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
377
-			        		}
378
-			        		break;
379
-					    case 'documentation':
380
-					        $this->documentation = true;
381
-					        break;
382
-					    // merge input/output data
383
-					    default:
384
-					        $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
385
-					        $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
386
-					        break;
387
-					}
388
-			    	break;
389
-				case 'binding':
390
-				    switch ($name) {
391
-				        case 'binding':
392
-				            // get ns prefix
393
-				            if (isset($attrs['style'])) {
394
-				            $this->bindings[$this->currentBinding]['prefix'] = $prefix;
395
-					    	}
396
-					    	$this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
397
-					    	break;
398
-						case 'header':
399
-						    $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
400
-						    break;
401
-						case 'operation':
402
-						    if (isset($attrs['soapAction'])) {
403
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
404
-						    }
405
-						    if (isset($attrs['style'])) {
406
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
407
-						    }
408
-						    if (isset($attrs['name'])) {
409
-						        $this->currentOperation = $attrs['name'];
410
-						        $this->debug("current binding operation: $this->currentOperation");
411
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
412
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
413
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
414
-						    }
415
-						    break;
416
-						case 'input':
417
-						    $this->opStatus = 'input';
418
-						    break;
419
-						case 'output':
420
-						    $this->opStatus = 'output';
421
-						    break;
422
-						case 'body':
423
-						    if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
424
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
425
-						    } else {
426
-						        $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
427
-						    }
428
-						    break;
429
-					}
430
-					break;
431
-				case 'service':
432
-					switch ($name) {
433
-					    case 'port':
434
-					        $this->currentPort = $attrs['name'];
435
-					        $this->debug('current port: ' . $this->currentPort);
436
-					        $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
360
+                        if (isset($attrs['type'])) {
361
+                            $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
362
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
363
+                        }
364
+                        if (isset($attrs['element'])) {
365
+                            $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
366
+                            $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
367
+                        }
368
+                    }
369
+                    break;
370
+                case 'portType':
371
+                    switch ($name) {
372
+                        case 'operation':
373
+                            $this->currentPortOperation = $attrs['name'];
374
+                            $this->debug("portType $this->currentPortType operation: $this->currentPortOperation");
375
+                            if (isset($attrs['parameterOrder'])) {
376
+                                $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder'];
377
+                            }
378
+                            break;
379
+                        case 'documentation':
380
+                            $this->documentation = true;
381
+                            break;
382
+                        // merge input/output data
383
+                        default:
384
+                            $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : '';
385
+                            $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m;
386
+                            break;
387
+                    }
388
+                    break;
389
+                case 'binding':
390
+                    switch ($name) {
391
+                        case 'binding':
392
+                            // get ns prefix
393
+                            if (isset($attrs['style'])) {
394
+                            $this->bindings[$this->currentBinding]['prefix'] = $prefix;
395
+                            }
396
+                            $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs);
397
+                            break;
398
+                        case 'header':
399
+                            $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs;
400
+                            break;
401
+                        case 'operation':
402
+                            if (isset($attrs['soapAction'])) {
403
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction'];
404
+                            }
405
+                            if (isset($attrs['style'])) {
406
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style'];
407
+                            }
408
+                            if (isset($attrs['name'])) {
409
+                                $this->currentOperation = $attrs['name'];
410
+                                $this->debug("current binding operation: $this->currentOperation");
411
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name'];
412
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding;
413
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : '';
414
+                            }
415
+                            break;
416
+                        case 'input':
417
+                            $this->opStatus = 'input';
418
+                            break;
419
+                        case 'output':
420
+                            $this->opStatus = 'output';
421
+                            break;
422
+                        case 'body':
423
+                            if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) {
424
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs);
425
+                            } else {
426
+                                $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs;
427
+                            }
428
+                            break;
429
+                    }
430
+                    break;
431
+                case 'service':
432
+                    switch ($name) {
433
+                        case 'port':
434
+                            $this->currentPort = $attrs['name'];
435
+                            $this->debug('current port: ' . $this->currentPort);
436
+                            $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
437 437
 
438
-					        break;
439
-					    case 'address':
440
-					        $this->ports[$this->currentPort]['location'] = $attrs['location'];
441
-					        $this->ports[$this->currentPort]['bindingType'] = $namespace;
442
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
443
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
444
-					        break;
445
-					}
446
-					break;
447
-			}
448
-		// set status
449
-		switch ($name) {
450
-			case 'import':
451
-			    if (isset($attrs['location'])) {
438
+                            break;
439
+                        case 'address':
440
+                            $this->ports[$this->currentPort]['location'] = $attrs['location'];
441
+                            $this->ports[$this->currentPort]['bindingType'] = $namespace;
442
+                            $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
443
+                            $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
444
+                            break;
445
+                    }
446
+                    break;
447
+            }
448
+        // set status
449
+        switch ($name) {
450
+            case 'import':
451
+                if (isset($attrs['location'])) {
452 452
                     $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
453 453
                     $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
454
-				} else {
454
+                } else {
455 455
                     $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
456
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
457
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
458
-					}
456
+                    if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
457
+                        $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
458
+                    }
459 459
                     $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
460
-				}
461
-				break;
462
-			//wait for schema
463
-			//case 'types':
464
-			//	$this->status = 'schema';
465
-			//	break;
466
-			case 'message':
467
-				$this->status = 'message';
468
-				$this->messages[$attrs['name']] = array();
469
-				$this->currentMessage = $attrs['name'];
470
-				break;
471
-			case 'portType':
472
-				$this->status = 'portType';
473
-				$this->portTypes[$attrs['name']] = array();
474
-				$this->currentPortType = $attrs['name'];
475
-				break;
476
-			case "binding":
477
-				if (isset($attrs['name'])) {
478
-				// get binding name
479
-					if (strpos($attrs['name'], ':')) {
480
-			    		$this->currentBinding = $this->getLocalPart($attrs['name']);
481
-					} else {
482
-			    		$this->currentBinding = $attrs['name'];
483
-					}
484
-					$this->status = 'binding';
485
-					$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
486
-					$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
487
-				}
488
-				break;
489
-			case 'service':
490
-				$this->serviceName = $attrs['name'];
491
-				$this->status = 'service';
492
-				$this->debug('current service: ' . $this->serviceName);
493
-				break;
494
-			case 'definitions':
495
-				foreach ($attrs as $name => $value) {
496
-					$this->wsdl_info[$name] = $value;
497
-				}
498
-				break;
499
-			}
500
-		}
501
-	}
460
+                }
461
+                break;
462
+            //wait for schema
463
+            //case 'types':
464
+            //	$this->status = 'schema';
465
+            //	break;
466
+            case 'message':
467
+                $this->status = 'message';
468
+                $this->messages[$attrs['name']] = array();
469
+                $this->currentMessage = $attrs['name'];
470
+                break;
471
+            case 'portType':
472
+                $this->status = 'portType';
473
+                $this->portTypes[$attrs['name']] = array();
474
+                $this->currentPortType = $attrs['name'];
475
+                break;
476
+            case "binding":
477
+                if (isset($attrs['name'])) {
478
+                // get binding name
479
+                    if (strpos($attrs['name'], ':')) {
480
+                        $this->currentBinding = $this->getLocalPart($attrs['name']);
481
+                    } else {
482
+                        $this->currentBinding = $attrs['name'];
483
+                    }
484
+                    $this->status = 'binding';
485
+                    $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
486
+                    $this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
487
+                }
488
+                break;
489
+            case 'service':
490
+                $this->serviceName = $attrs['name'];
491
+                $this->status = 'service';
492
+                $this->debug('current service: ' . $this->serviceName);
493
+                break;
494
+            case 'definitions':
495
+                foreach ($attrs as $name => $value) {
496
+                    $this->wsdl_info[$name] = $value;
497
+                }
498
+                break;
499
+            }
500
+        }
501
+    }
502 502
 
503
-	/**
504
-	* end-element handler
505
-	*
506
-	* @param string $parser XML parser object
507
-	* @param string $name element name
508
-	* @access private
509
-	*/
510
-	function end_element($parser, $name){
511
-		// unset schema status
512
-		if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
513
-			$this->status = "";
503
+    /**
504
+     * end-element handler
505
+     *
506
+     * @param string $parser XML parser object
507
+     * @param string $name element name
508
+     * @access private
509
+     */
510
+    function end_element($parser, $name){
511
+        // unset schema status
512
+        if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
513
+            $this->status = "";
514 514
             $this->appendDebug($this->currentSchema->getDebug());
515 515
             $this->currentSchema->clearDebug();
516
-			$this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
517
-        	$this->debug('Parsing WSDL schema done');
518
-		}
519
-		if ($this->status == 'schema') {
520
-			$this->currentSchema->schemaEndElement($parser, $name);
521
-		} else {
522
-			// bring depth down a notch
523
-			$this->depth--;
524
-		}
525
-		// end documentation
526
-		if ($this->documentation) {
527
-			//TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
528
-			//$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
529
-			$this->documentation = false;
530
-		}
531
-	}
516
+            $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema;
517
+            $this->debug('Parsing WSDL schema done');
518
+        }
519
+        if ($this->status == 'schema') {
520
+            $this->currentSchema->schemaEndElement($parser, $name);
521
+        } else {
522
+            // bring depth down a notch
523
+            $this->depth--;
524
+        }
525
+        // end documentation
526
+        if ($this->documentation) {
527
+            //TODO: track the node to which documentation should be assigned; it can be a part, message, etc.
528
+            //$this->portTypes[$this->currentPortType][$this->currentPortOperation]['documentation'] = $this->documentation;
529
+            $this->documentation = false;
530
+        }
531
+    }
532 532
 
533
-	/**
534
-	 * element content handler
535
-	 *
536
-	 * @param string $parser XML parser object
537
-	 * @param string $data element content
538
-	 * @access private
539
-	 */
540
-	function character_data($parser, $data)
541
-	{
542
-		$pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
543
-		if (isset($this->message[$pos]['cdata'])) {
544
-			$this->message[$pos]['cdata'] .= $data;
545
-		}
546
-		if ($this->documentation) {
547
-			$this->documentation .= $data;
548
-		}
549
-	}
533
+    /**
534
+     * element content handler
535
+     *
536
+     * @param string $parser XML parser object
537
+     * @param string $data element content
538
+     * @access private
539
+     */
540
+    function character_data($parser, $data)
541
+    {
542
+        $pos = isset($this->depth_array[$this->depth]) ? $this->depth_array[$this->depth] : 0;
543
+        if (isset($this->message[$pos]['cdata'])) {
544
+            $this->message[$pos]['cdata'] .= $data;
545
+        }
546
+        if ($this->documentation) {
547
+            $this->documentation .= $data;
548
+        }
549
+    }
550 550
 
551
-	/**
552
-	* if authenticating, set user credentials here
553
-	*
554
-	* @param    string $username
555
-	* @param    string $password
556
-	* @param	string $authtype (basic|digest|certificate|ntlm)
557
-	* @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
558
-	* @access   public
559
-	*/
560
-	function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
561
-		$this->debug("setCredentials username=$username authtype=$authtype certRequest=");
562
-		$this->appendDebug($this->varDump($certRequest));
563
-		$this->username = $username;
564
-		$this->password = $password;
565
-		$this->authtype = $authtype;
566
-		$this->certRequest = $certRequest;
567
-	}
551
+    /**
552
+     * if authenticating, set user credentials here
553
+     *
554
+     * @param    string $username
555
+     * @param    string $password
556
+     * @param	string $authtype (basic|digest|certificate|ntlm)
557
+     * @param	array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs)
558
+     * @access   public
559
+     */
560
+    function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
561
+        $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
562
+        $this->appendDebug($this->varDump($certRequest));
563
+        $this->username = $username;
564
+        $this->password = $password;
565
+        $this->authtype = $authtype;
566
+        $this->certRequest = $certRequest;
567
+    }
568 568
 
569
-	function getBindingData($binding)
570
-	{
571
-		if (is_array($this->bindings[$binding])) {
572
-			return $this->bindings[$binding];
573
-		}
574
-	}
569
+    function getBindingData($binding)
570
+    {
571
+        if (is_array($this->bindings[$binding])) {
572
+            return $this->bindings[$binding];
573
+        }
574
+    }
575 575
 
576
-	/**
577
-	 * returns an assoc array of operation names => operation data
578
-	 *
579
-	 * @param string $portName WSDL port name
580
-	 * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
581
-	 * @return array
582
-	 * @access public
583
-	 */
584
-	function getOperations($portName = '', $bindingType = 'soap') {
585
-		$ops = array();
586
-		if ($bindingType == 'soap') {
587
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
588
-		} elseif ($bindingType == 'soap12') {
589
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
590
-		} else {
591
-			$this->debug("getOperations bindingType $bindingType may not be supported");
592
-		}
593
-		$this->debug("getOperations for port '$portName' bindingType $bindingType");
594
-		// loop thru ports
595
-		foreach($this->ports as $port => $portData) {
596
-			$this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
597
-			if ($portName == '' || $port == $portName) {
598
-				// binding type of port matches parameter
599
-				if ($portData['bindingType'] == $bindingType) {
600
-					$this->debug("getOperations found port $port bindingType $bindingType");
601
-					//$this->debug("port data: " . $this->varDump($portData));
602
-					//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
603
-					// merge bindings
604
-					if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
605
-						$ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
606
-					}
607
-				}
608
-			}
609
-		}
610
-		if (count($ops) == 0) {
611
-			$this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
612
-		}
613
-		return $ops;
614
-	}
576
+    /**
577
+     * returns an assoc array of operation names => operation data
578
+     *
579
+     * @param string $portName WSDL port name
580
+     * @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
581
+     * @return array
582
+     * @access public
583
+     */
584
+    function getOperations($portName = '', $bindingType = 'soap') {
585
+        $ops = array();
586
+        if ($bindingType == 'soap') {
587
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
588
+        } elseif ($bindingType == 'soap12') {
589
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
590
+        } else {
591
+            $this->debug("getOperations bindingType $bindingType may not be supported");
592
+        }
593
+        $this->debug("getOperations for port '$portName' bindingType $bindingType");
594
+        // loop thru ports
595
+        foreach($this->ports as $port => $portData) {
596
+            $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
597
+            if ($portName == '' || $port == $portName) {
598
+                // binding type of port matches parameter
599
+                if ($portData['bindingType'] == $bindingType) {
600
+                    $this->debug("getOperations found port $port bindingType $bindingType");
601
+                    //$this->debug("port data: " . $this->varDump($portData));
602
+                    //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
603
+                    // merge bindings
604
+                    if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
605
+                        $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
606
+                    }
607
+                }
608
+            }
609
+        }
610
+        if (count($ops) == 0) {
611
+            $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
612
+        }
613
+        return $ops;
614
+    }
615 615
 
616
-	/**
617
-	 * returns an associative array of data necessary for calling an operation
618
-	 *
619
-	 * @param string $operation name of operation
620
-	 * @param string $bindingType type of binding eg: soap, soap12
621
-	 * @return array
622
-	 * @access public
623
-	 */
624
-	function getOperationData($operation, $bindingType = 'soap')
625
-	{
626
-		if ($bindingType == 'soap') {
627
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
628
-		} elseif ($bindingType == 'soap12') {
629
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
630
-		}
631
-		// loop thru ports
632
-		foreach($this->ports as $port => $portData) {
633
-			// binding type of port matches parameter
634
-			if ($portData['bindingType'] == $bindingType) {
635
-				// get binding
636
-				//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
637
-				foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
638
-					// note that we could/should also check the namespace here
639
-					if ($operation == $bOperation) {
640
-						$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
641
-					    return $opData;
642
-					}
643
-				}
644
-			}
645
-		}
646
-	}
616
+    /**
617
+     * returns an associative array of data necessary for calling an operation
618
+     *
619
+     * @param string $operation name of operation
620
+     * @param string $bindingType type of binding eg: soap, soap12
621
+     * @return array
622
+     * @access public
623
+     */
624
+    function getOperationData($operation, $bindingType = 'soap')
625
+    {
626
+        if ($bindingType == 'soap') {
627
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
628
+        } elseif ($bindingType == 'soap12') {
629
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
630
+        }
631
+        // loop thru ports
632
+        foreach($this->ports as $port => $portData) {
633
+            // binding type of port matches parameter
634
+            if ($portData['bindingType'] == $bindingType) {
635
+                // get binding
636
+                //foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
637
+                foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
638
+                    // note that we could/should also check the namespace here
639
+                    if ($operation == $bOperation) {
640
+                        $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
641
+                        return $opData;
642
+                    }
643
+                }
644
+            }
645
+        }
646
+    }
647 647
 
648
-	/**
649
-	 * returns an associative array of data necessary for calling an operation
650
-	 *
651
-	 * @param string $soapAction soapAction for operation
652
-	 * @param string $bindingType type of binding eg: soap, soap12
653
-	 * @return array
654
-	 * @access public
655
-	 */
656
-	function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
657
-		if ($bindingType == 'soap') {
658
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
659
-		} elseif ($bindingType == 'soap12') {
660
-			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
661
-		}
662
-		// loop thru ports
663
-		foreach($this->ports as $port => $portData) {
664
-			// binding type of port matches parameter
665
-			if ($portData['bindingType'] == $bindingType) {
666
-				// loop through operations for the binding
667
-				foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
668
-					if ($opData['soapAction'] == $soapAction) {
669
-					    return $opData;
670
-					}
671
-				}
672
-			}
673
-		}
674
-	}
648
+    /**
649
+     * returns an associative array of data necessary for calling an operation
650
+     *
651
+     * @param string $soapAction soapAction for operation
652
+     * @param string $bindingType type of binding eg: soap, soap12
653
+     * @return array
654
+     * @access public
655
+     */
656
+    function getOperationDataForSoapAction($soapAction, $bindingType = 'soap') {
657
+        if ($bindingType == 'soap') {
658
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
659
+        } elseif ($bindingType == 'soap12') {
660
+            $bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
661
+        }
662
+        // loop thru ports
663
+        foreach($this->ports as $port => $portData) {
664
+            // binding type of port matches parameter
665
+            if ($portData['bindingType'] == $bindingType) {
666
+                // loop through operations for the binding
667
+                foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
668
+                    if ($opData['soapAction'] == $soapAction) {
669
+                        return $opData;
670
+                    }
671
+                }
672
+            }
673
+        }
674
+    }
675 675
 
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
-    */
694
-	function getTypeDef($type, $ns) {
695
-		$this->debug("in getTypeDef: type=$type, ns=$ns");
696
-		if ((! $ns) && isset($this->namespaces['tns'])) {
697
-			$ns = $this->namespaces['tns'];
698
-			$this->debug("in getTypeDef: type namespace forced to $ns");
699
-		}
700
-		if (!isset($this->schemas[$ns])) {
701
-			foreach ($this->schemas as $ns0 => $schema0) {
702
-				if (strcasecmp($ns, $ns0) == 0) {
703
-					$this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
704
-					$ns = $ns0;
705
-					break;
706
-				}
707
-			}
708
-		}
709
-		if (isset($this->schemas[$ns])) {
710
-			$this->debug("in getTypeDef: have schema for namespace $ns");
711
-			for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
712
-				$xs = &$this->schemas[$ns][$i];
713
-				$t = $xs->getTypeDef($type);
714
-				$this->appendDebug($xs->getDebug());
715
-				$xs->clearDebug();
716
-				if ($t) {
717
-					$this->debug("in getTypeDef: found type $type");
718
-					if (!isset($t['phpType'])) {
719
-						// get info for type to tack onto the element
720
-						$uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
721
-						$ns = substr($t['type'], 0, strrpos($t['type'], ':'));
722
-						$etype = $this->getTypeDef($uqType, $ns);
723
-						if ($etype) {
724
-							$this->debug("found type for [element] $type:");
725
-							$this->debug($this->varDump($etype));
726
-							if (isset($etype['phpType'])) {
727
-								$t['phpType'] = $etype['phpType'];
728
-							}
729
-							if (isset($etype['elements'])) {
730
-								$t['elements'] = $etype['elements'];
731
-							}
732
-							if (isset($etype['attrs'])) {
733
-								$t['attrs'] = $etype['attrs'];
734
-							}
735
-						} else {
736
-							$this->debug("did not find type for [element] $type");
737
-						}
738
-					}
739
-					return $t;
740
-				}
741
-			}
742
-			$this->debug("in getTypeDef: did not find type $type");
743
-		} else {
744
-			$this->debug("in getTypeDef: do not have schema for namespace $ns");
745
-		}
746
-		return false;
747
-	}
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
+     */
694
+    function getTypeDef($type, $ns) {
695
+        $this->debug("in getTypeDef: type=$type, ns=$ns");
696
+        if ((! $ns) && isset($this->namespaces['tns'])) {
697
+            $ns = $this->namespaces['tns'];
698
+            $this->debug("in getTypeDef: type namespace forced to $ns");
699
+        }
700
+        if (!isset($this->schemas[$ns])) {
701
+            foreach ($this->schemas as $ns0 => $schema0) {
702
+                if (strcasecmp($ns, $ns0) == 0) {
703
+                    $this->debug("in getTypeDef: replacing schema namespace $ns with $ns0");
704
+                    $ns = $ns0;
705
+                    break;
706
+                }
707
+            }
708
+        }
709
+        if (isset($this->schemas[$ns])) {
710
+            $this->debug("in getTypeDef: have schema for namespace $ns");
711
+            for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
712
+                $xs = &$this->schemas[$ns][$i];
713
+                $t = $xs->getTypeDef($type);
714
+                $this->appendDebug($xs->getDebug());
715
+                $xs->clearDebug();
716
+                if ($t) {
717
+                    $this->debug("in getTypeDef: found type $type");
718
+                    if (!isset($t['phpType'])) {
719
+                        // get info for type to tack onto the element
720
+                        $uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
721
+                        $ns = substr($t['type'], 0, strrpos($t['type'], ':'));
722
+                        $etype = $this->getTypeDef($uqType, $ns);
723
+                        if ($etype) {
724
+                            $this->debug("found type for [element] $type:");
725
+                            $this->debug($this->varDump($etype));
726
+                            if (isset($etype['phpType'])) {
727
+                                $t['phpType'] = $etype['phpType'];
728
+                            }
729
+                            if (isset($etype['elements'])) {
730
+                                $t['elements'] = $etype['elements'];
731
+                            }
732
+                            if (isset($etype['attrs'])) {
733
+                                $t['attrs'] = $etype['attrs'];
734
+                            }
735
+                        } else {
736
+                            $this->debug("did not find type for [element] $type");
737
+                        }
738
+                    }
739
+                    return $t;
740
+                }
741
+            }
742
+            $this->debug("in getTypeDef: did not find type $type");
743
+        } else {
744
+            $this->debug("in getTypeDef: do not have schema for namespace $ns");
745
+        }
746
+        return false;
747
+    }
748 748
 
749 749
     /**
750
-    * prints html description of services
751
-    *
752
-    * @access private
753
-    */
750
+     * prints html description of services
751
+     *
752
+     * @access private
753
+     */
754 754
     function webDescription(){
755
-    	global $HTTP_SERVER_VARS;
755
+        global $HTTP_SERVER_VARS;
756 756
 
757
-		if (isset($_SERVER)) {
758
-			$PHP_SELF = $_SERVER['PHP_SELF'];
759
-		} elseif (isset($HTTP_SERVER_VARS)) {
760
-			$PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
761
-		} else {
762
-			$this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
763
-		}
757
+        if (isset($_SERVER)) {
758
+            $PHP_SELF = $_SERVER['PHP_SELF'];
759
+        } elseif (isset($HTTP_SERVER_VARS)) {
760
+            $PHP_SELF = $HTTP_SERVER_VARS['PHP_SELF'];
761
+        } else {
762
+            $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
763
+        }
764 764
 
765
-		$b = '
765
+        $b = '
766 766
 		<html><head><title>NuSOAP: '.$this->serviceName.'</title>
767 767
 		<style type="text/css">
768 768
 		    body    { font-family: arial; color: #000000; background-color: #ffffff; margin: 0px 0px 0px 0px; }
@@ -845,1092 +845,1092 @@  discard block
 block discarded – undo
845 845
 				<p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
846 846
 				Click on an operation name to view it&apos;s details.</p>
847 847
 				<ul>';
848
-				foreach($this->getOperations() as $op => $data){
849
-				    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
850
-				    // create hidden div
851
-				    $b .= "<div id='$op' class='hidden'>
848
+                foreach($this->getOperations() as $op => $data){
849
+                    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
850
+                    // create hidden div
851
+                    $b .= "<div id='$op' class='hidden'>
852 852
 				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
853
-				    foreach($data as $donnie => $marie){ // loop through opdata
854
-						if($donnie == 'input' || $donnie == 'output'){ // show input/output data
855
-						    $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
856
-						    foreach($marie as $captain => $tenille){ // loop through data
857
-								if($captain == 'parts'){ // loop thru parts
858
-								    $b .= "&nbsp;&nbsp;$captain:<br>";
859
-					                //if(is_array($tenille)){
860
-								    	foreach($tenille as $joanie => $chachi){
861
-											$b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
862
-								    	}
863
-					        		//}
864
-								} else {
865
-								    $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
866
-								}
867
-						    }
868
-						} else {
869
-						    $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
870
-						}
871
-				    }
872
-					$b .= '</div>';
873
-				}
874
-				$b .= '
853
+                    foreach($data as $donnie => $marie){ // loop through opdata
854
+                        if($donnie == 'input' || $donnie == 'output'){ // show input/output data
855
+                            $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
856
+                            foreach($marie as $captain => $tenille){ // loop through data
857
+                                if($captain == 'parts'){ // loop thru parts
858
+                                    $b .= "&nbsp;&nbsp;$captain:<br>";
859
+                                    //if(is_array($tenille)){
860
+                                        foreach($tenille as $joanie => $chachi){
861
+                                            $b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
862
+                                        }
863
+                                    //}
864
+                                } else {
865
+                                    $b .= "&nbsp;&nbsp;$captain: $tenille<br>";
866
+                                }
867
+                            }
868
+                        } else {
869
+                            $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>";
870
+                        }
871
+                    }
872
+                    $b .= '</div>';
873
+                }
874
+                $b .= '
875 875
 				<ul>
876 876
 			</div>
877 877
 		</div></body></html>';
878
-		return $b;
878
+        return $b;
879 879
     }
880 880
 
881
-	/**
882
-	* serialize the parsed wsdl
883
-	*
884
-	* @param mixed $debug whether to put debug=1 in endpoint URL
885
-	* @return string serialization of WSDL
886
-	* @access public
887
-	*/
888
-	function serialize($debug = 0)
889
-	{
890
-		$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
891
-		$xml .= "\n<definitions";
892
-		foreach($this->namespaces as $k => $v) {
893
-			$xml .= " xmlns:$k=\"$v\"";
894
-		}
895
-		// 10.9.02 - add poulter fix for wsdl and tns declarations
896
-		if (isset($this->namespaces['wsdl'])) {
897
-			$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
898
-		}
899
-		if (isset($this->namespaces['tns'])) {
900
-			$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
901
-		}
902
-		$xml .= '>';
903
-		// imports
904
-		if (sizeof($this->import) > 0) {
905
-			foreach($this->import as $ns => $list) {
906
-				foreach ($list as $ii) {
907
-					if ($ii['location'] != '') {
908
-						$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
909
-					} else {
910
-						$xml .= '<import namespace="' . $ns . '" />';
911
-					}
912
-				}
913
-			}
914
-		}
915
-		// types
916
-		if (count($this->schemas)>=1) {
917
-			$xml .= "\n<types>\n";
918
-			foreach ($this->schemas as $ns => $list) {
919
-				foreach ($list as $xs) {
920
-					$xml .= $xs->serializeSchema();
921
-				}
922
-			}
923
-			$xml .= '</types>';
924
-		}
925
-		// messages
926
-		if (count($this->messages) >= 1) {
927
-			foreach($this->messages as $msgName => $msgParts) {
928
-				$xml .= "\n<message name=\"" . $msgName . '">';
929
-				if(is_array($msgParts)){
930
-					foreach($msgParts as $partName => $partType) {
931
-						// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
932
-						if (strpos($partType, ':')) {
933
-						    $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
934
-						} elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
935
-						    // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
936
-						    $typePrefix = 'xsd';
937
-						} else {
938
-						    foreach($this->typemap as $ns => $types) {
939
-						        if (isset($types[$partType])) {
940
-						            $typePrefix = $this->getPrefixFromNamespace($ns);
941
-						        }
942
-						    }
943
-						    if (!isset($typePrefix)) {
944
-						        die("$partType has no namespace!");
945
-						    }
946
-						}
947
-						$ns = $this->getNamespaceFromPrefix($typePrefix);
948
-						$localPart = $this->getLocalPart($partType);
949
-						$typeDef = $this->getTypeDef($localPart, $ns);
950
-						if ($typeDef['typeClass'] == 'element') {
951
-							$elementortype = 'element';
952
-							if (substr($localPart, -1) == '^') {
953
-								$localPart = substr($localPart, 0, -1);
954
-							}
955
-						} else {
956
-							$elementortype = 'type';
957
-						}
958
-						$xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
959
-					}
960
-				}
961
-				$xml .= '</message>';
962
-			}
963
-		}
964
-		// bindings & porttypes
965
-		if (count($this->bindings) >= 1) {
966
-			$binding_xml = '';
967
-			$portType_xml = '';
968
-			foreach($this->bindings as $bindingName => $attrs) {
969
-				$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
970
-				$binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
971
-				$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
972
-				foreach($attrs['operations'] as $opName => $opParts) {
973
-					$binding_xml .= "\n" . '  <operation name="' . $opName . '">';
974
-					$binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
975
-					if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
976
-						$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
977
-					} else {
978
-						$enc_style = '';
979
-					}
980
-					$binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
981
-					if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
982
-						$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
983
-					} else {
984
-						$enc_style = '';
985
-					}
986
-					$binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
987
-					$binding_xml .= "\n" . '  </operation>';
988
-					$portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
989
-					if (isset($opParts['parameterOrder'])) {
990
-					    $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
991
-					}
992
-					$portType_xml .= '>';
993
-					if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
994
-						$portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
995
-					}
996
-					$portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
997
-					$portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
998
-					$portType_xml .= "\n" . '  </operation>';
999
-				}
1000
-				$portType_xml .= "\n" . '</portType>';
1001
-				$binding_xml .= "\n" . '</binding>';
1002
-			}
1003
-			$xml .= $portType_xml . $binding_xml;
1004
-		}
1005
-		// services
1006
-		$xml .= "\n<service name=\"" . $this->serviceName . '">';
1007
-		if (count($this->ports) >= 1) {
1008
-			foreach($this->ports as $pName => $attrs) {
1009
-				$xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1010
-				$xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1011
-				$xml .= "\n" . '  </port>';
1012
-			}
1013
-		}
1014
-		$xml .= "\n" . '</service>';
1015
-		return $xml . "\n</definitions>";
1016
-	}
881
+    /**
882
+     * serialize the parsed wsdl
883
+     *
884
+     * @param mixed $debug whether to put debug=1 in endpoint URL
885
+     * @return string serialization of WSDL
886
+     * @access public
887
+     */
888
+    function serialize($debug = 0)
889
+    {
890
+        $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
891
+        $xml .= "\n<definitions";
892
+        foreach($this->namespaces as $k => $v) {
893
+            $xml .= " xmlns:$k=\"$v\"";
894
+        }
895
+        // 10.9.02 - add poulter fix for wsdl and tns declarations
896
+        if (isset($this->namespaces['wsdl'])) {
897
+            $xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
898
+        }
899
+        if (isset($this->namespaces['tns'])) {
900
+            $xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
901
+        }
902
+        $xml .= '>';
903
+        // imports
904
+        if (sizeof($this->import) > 0) {
905
+            foreach($this->import as $ns => $list) {
906
+                foreach ($list as $ii) {
907
+                    if ($ii['location'] != '') {
908
+                        $xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
909
+                    } else {
910
+                        $xml .= '<import namespace="' . $ns . '" />';
911
+                    }
912
+                }
913
+            }
914
+        }
915
+        // types
916
+        if (count($this->schemas)>=1) {
917
+            $xml .= "\n<types>\n";
918
+            foreach ($this->schemas as $ns => $list) {
919
+                foreach ($list as $xs) {
920
+                    $xml .= $xs->serializeSchema();
921
+                }
922
+            }
923
+            $xml .= '</types>';
924
+        }
925
+        // messages
926
+        if (count($this->messages) >= 1) {
927
+            foreach($this->messages as $msgName => $msgParts) {
928
+                $xml .= "\n<message name=\"" . $msgName . '">';
929
+                if(is_array($msgParts)){
930
+                    foreach($msgParts as $partName => $partType) {
931
+                        // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
932
+                        if (strpos($partType, ':')) {
933
+                            $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
934
+                        } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) {
935
+                            // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
936
+                            $typePrefix = 'xsd';
937
+                        } else {
938
+                            foreach($this->typemap as $ns => $types) {
939
+                                if (isset($types[$partType])) {
940
+                                    $typePrefix = $this->getPrefixFromNamespace($ns);
941
+                                }
942
+                            }
943
+                            if (!isset($typePrefix)) {
944
+                                die("$partType has no namespace!");
945
+                            }
946
+                        }
947
+                        $ns = $this->getNamespaceFromPrefix($typePrefix);
948
+                        $localPart = $this->getLocalPart($partType);
949
+                        $typeDef = $this->getTypeDef($localPart, $ns);
950
+                        if ($typeDef['typeClass'] == 'element') {
951
+                            $elementortype = 'element';
952
+                            if (substr($localPart, -1) == '^') {
953
+                                $localPart = substr($localPart, 0, -1);
954
+                            }
955
+                        } else {
956
+                            $elementortype = 'type';
957
+                        }
958
+                        $xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
959
+                    }
960
+                }
961
+                $xml .= '</message>';
962
+            }
963
+        }
964
+        // bindings & porttypes
965
+        if (count($this->bindings) >= 1) {
966
+            $binding_xml = '';
967
+            $portType_xml = '';
968
+            foreach($this->bindings as $bindingName => $attrs) {
969
+                $binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
970
+                $binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
971
+                $portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
972
+                foreach($attrs['operations'] as $opName => $opParts) {
973
+                    $binding_xml .= "\n" . '  <operation name="' . $opName . '">';
974
+                    $binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
975
+                    if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
976
+                        $enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
977
+                    } else {
978
+                        $enc_style = '';
979
+                    }
980
+                    $binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
981
+                    if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
982
+                        $enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
983
+                    } else {
984
+                        $enc_style = '';
985
+                    }
986
+                    $binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
987
+                    $binding_xml .= "\n" . '  </operation>';
988
+                    $portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
989
+                    if (isset($opParts['parameterOrder'])) {
990
+                        $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
991
+                    }
992
+                    $portType_xml .= '>';
993
+                    if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
994
+                        $portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
995
+                    }
996
+                    $portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
997
+                    $portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
998
+                    $portType_xml .= "\n" . '  </operation>';
999
+                }
1000
+                $portType_xml .= "\n" . '</portType>';
1001
+                $binding_xml .= "\n" . '</binding>';
1002
+            }
1003
+            $xml .= $portType_xml . $binding_xml;
1004
+        }
1005
+        // services
1006
+        $xml .= "\n<service name=\"" . $this->serviceName . '">';
1007
+        if (count($this->ports) >= 1) {
1008
+            foreach($this->ports as $pName => $attrs) {
1009
+                $xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1010
+                $xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1011
+                $xml .= "\n" . '  </port>';
1012
+            }
1013
+        }
1014
+        $xml .= "\n" . '</service>';
1015
+        return $xml . "\n</definitions>";
1016
+    }
1017 1017
 
1018
-	/**
1019
-	 * determine whether a set of parameters are unwrapped
1020
-	 * when they are expect to be wrapped, Microsoft-style.
1021
-	 *
1022
-	 * @param string $type the type (element name) of the wrapper
1023
-	 * @param array $parameters the parameter values for the SOAP call
1024
-	 * @return boolean whether they parameters are unwrapped (and should be wrapped)
1025
-	 * @access private
1026
-	 */
1027
-	function parametersMatchWrapped($type, &$parameters) {
1028
-		$this->debug("in parametersMatchWrapped type=$type, parameters=");
1029
-		$this->appendDebug($this->varDump($parameters));
1018
+    /**
1019
+     * determine whether a set of parameters are unwrapped
1020
+     * when they are expect to be wrapped, Microsoft-style.
1021
+     *
1022
+     * @param string $type the type (element name) of the wrapper
1023
+     * @param array $parameters the parameter values for the SOAP call
1024
+     * @return boolean whether they parameters are unwrapped (and should be wrapped)
1025
+     * @access private
1026
+     */
1027
+    function parametersMatchWrapped($type, &$parameters) {
1028
+        $this->debug("in parametersMatchWrapped type=$type, parameters=");
1029
+        $this->appendDebug($this->varDump($parameters));
1030 1030
 
1031
-		// split type into namespace:unqualified-type
1032
-		if (strpos($type, ':')) {
1033
-			$uqType = substr($type, strrpos($type, ':') + 1);
1034
-			$ns = substr($type, 0, strrpos($type, ':'));
1035
-			$this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1036
-			if ($this->getNamespaceFromPrefix($ns)) {
1037
-				$ns = $this->getNamespaceFromPrefix($ns);
1038
-				$this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1039
-			}
1040
-		} else {
1041
-			// TODO: should the type be compared to types in XSD, and the namespace
1042
-			// set to XSD if the type matches?
1043
-			$this->debug("in parametersMatchWrapped: No namespace for type $type");
1044
-			$ns = '';
1045
-			$uqType = $type;
1046
-		}
1031
+        // split type into namespace:unqualified-type
1032
+        if (strpos($type, ':')) {
1033
+            $uqType = substr($type, strrpos($type, ':') + 1);
1034
+            $ns = substr($type, 0, strrpos($type, ':'));
1035
+            $this->debug("in parametersMatchWrapped: got a prefixed type: $uqType, $ns");
1036
+            if ($this->getNamespaceFromPrefix($ns)) {
1037
+                $ns = $this->getNamespaceFromPrefix($ns);
1038
+                $this->debug("in parametersMatchWrapped: expanded prefixed type: $uqType, $ns");
1039
+            }
1040
+        } else {
1041
+            // TODO: should the type be compared to types in XSD, and the namespace
1042
+            // set to XSD if the type matches?
1043
+            $this->debug("in parametersMatchWrapped: No namespace for type $type");
1044
+            $ns = '';
1045
+            $uqType = $type;
1046
+        }
1047 1047
 
1048
-		// get the type information
1049
-		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1050
-			$this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1051
-			return false;
1052
-		}
1053
-		$this->debug("in parametersMatchWrapped: found typeDef=");
1054
-		$this->appendDebug($this->varDump($typeDef));
1055
-		if (substr($uqType, -1) == '^') {
1056
-			$uqType = substr($uqType, 0, -1);
1057
-		}
1058
-		$phpType = $typeDef['phpType'];
1059
-		$arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1060
-		$this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1048
+        // get the type information
1049
+        if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1050
+            $this->debug("in parametersMatchWrapped: $type ($uqType) is not a supported type.");
1051
+            return false;
1052
+        }
1053
+        $this->debug("in parametersMatchWrapped: found typeDef=");
1054
+        $this->appendDebug($this->varDump($typeDef));
1055
+        if (substr($uqType, -1) == '^') {
1056
+            $uqType = substr($uqType, 0, -1);
1057
+        }
1058
+        $phpType = $typeDef['phpType'];
1059
+        $arrayType = (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '');
1060
+        $this->debug("in parametersMatchWrapped: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: $arrayType");
1061 1061
 
1062
-		// we expect a complexType or element of complexType
1063
-		if ($phpType != 'struct') {
1064
-			$this->debug("in parametersMatchWrapped: not a struct");
1065
-			return false;
1066
-		}
1062
+        // we expect a complexType or element of complexType
1063
+        if ($phpType != 'struct') {
1064
+            $this->debug("in parametersMatchWrapped: not a struct");
1065
+            return false;
1066
+        }
1067 1067
 
1068
-		// see whether the parameter names match the elements
1069
-		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1070
-			$elements = 0;
1071
-			$matches = 0;
1072
-			foreach ($typeDef['elements'] as $name => $attrs) {
1073
-				if (isset($parameters[$name])) {
1074
-					$this->debug("in parametersMatchWrapped: have parameter named $name");
1075
-					$matches++;
1076
-				} else {
1077
-					$this->debug("in parametersMatchWrapped: do not have parameter named $name");
1078
-				}
1079
-				$elements++;
1080
-			}
1068
+        // see whether the parameter names match the elements
1069
+        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1070
+            $elements = 0;
1071
+            $matches = 0;
1072
+            foreach ($typeDef['elements'] as $name => $attrs) {
1073
+                if (isset($parameters[$name])) {
1074
+                    $this->debug("in parametersMatchWrapped: have parameter named $name");
1075
+                    $matches++;
1076
+                } else {
1077
+                    $this->debug("in parametersMatchWrapped: do not have parameter named $name");
1078
+                }
1079
+                $elements++;
1080
+            }
1081 1081
 
1082
-			$this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1083
-			if ($matches == 0) {
1084
-				return false;
1085
-			}
1086
-			return true;
1087
-		}
1082
+            $this->debug("in parametersMatchWrapped: $matches parameter names match $elements wrapped parameter names");
1083
+            if ($matches == 0) {
1084
+                return false;
1085
+            }
1086
+            return true;
1087
+        }
1088 1088
 
1089
-		// since there are no elements for the type, if the user passed no
1090
-		// parameters, the parameters match wrapped.
1091
-		$this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1092
-		return count($parameters) == 0;
1093
-	}
1089
+        // since there are no elements for the type, if the user passed no
1090
+        // parameters, the parameters match wrapped.
1091
+        $this->debug("in parametersMatchWrapped: no elements type $ns:$uqType");
1092
+        return count($parameters) == 0;
1093
+    }
1094 1094
 
1095
-	/**
1096
-	 * serialize PHP values according to a WSDL message definition
1097
-	 * contrary to the method name, this is not limited to RPC
1098
-	 *
1099
-	 * TODO
1100
-	 * - multi-ref serialization
1101
-	 * - validate PHP values against type definitions, return errors if invalid
1102
-	 *
1103
-	 * @param string $operation operation name
1104
-	 * @param string $direction (input|output)
1105
-	 * @param mixed $parameters parameter value(s)
1106
-	 * @param string $bindingType (soap|soap12)
1107
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1108
-	 * @access public
1109
-	 */
1110
-	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1111
-		$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1112
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1095
+    /**
1096
+     * serialize PHP values according to a WSDL message definition
1097
+     * contrary to the method name, this is not limited to RPC
1098
+     *
1099
+     * TODO
1100
+     * - multi-ref serialization
1101
+     * - validate PHP values against type definitions, return errors if invalid
1102
+     *
1103
+     * @param string $operation operation name
1104
+     * @param string $direction (input|output)
1105
+     * @param mixed $parameters parameter value(s)
1106
+     * @param string $bindingType (soap|soap12)
1107
+     * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1108
+     * @access public
1109
+     */
1110
+    function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1111
+        $this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1112
+        $this->appendDebug('parameters=' . $this->varDump($parameters));
1113 1113
 
1114
-		if ($direction != 'input' && $direction != 'output') {
1115
-			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1116
-			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1117
-			return false;
1118
-		}
1119
-		if (!$opData = $this->getOperationData($operation, $bindingType)) {
1120
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1121
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1122
-			return false;
1123
-		}
1124
-		$this->debug('in serializeRPCParameters: opData:');
1125
-		$this->appendDebug($this->varDump($opData));
1114
+        if ($direction != 'input' && $direction != 'output') {
1115
+            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1116
+            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1117
+            return false;
1118
+        }
1119
+        if (!$opData = $this->getOperationData($operation, $bindingType)) {
1120
+            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1121
+            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1122
+            return false;
1123
+        }
1124
+        $this->debug('in serializeRPCParameters: opData:');
1125
+        $this->appendDebug($this->varDump($opData));
1126 1126
 
1127
-		// Get encoding style for output and set to current
1128
-		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1129
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1130
-			$encodingStyle = $opData['output']['encodingStyle'];
1131
-			$enc_style = $encodingStyle;
1132
-		}
1127
+        // Get encoding style for output and set to current
1128
+        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1129
+        if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1130
+            $encodingStyle = $opData['output']['encodingStyle'];
1131
+            $enc_style = $encodingStyle;
1132
+        }
1133 1133
 
1134
-		// set input params
1135
-		$xml = '';
1136
-		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1137
-			$parts = &$opData[$direction]['parts'];
1138
-			$part_count = sizeof($parts);
1139
-			$style = $opData['style'];
1140
-			$use = $opData[$direction]['use'];
1141
-			$this->debug("have $part_count part(s) to serialize using $style/$use");
1142
-			if (is_array($parameters)) {
1143
-				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1144
-				$parameter_count = count($parameters);
1145
-				$this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1146
-				// check for Microsoft-style wrapped parameters
1147
-				if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1148
-					$this->debug('check whether the caller has wrapped the parameters');
1149
-					if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1150
-						// TODO: consider checking here for double-wrapping, when
1151
-						// service function wraps, then NuSOAP wraps again
1152
-						$this->debug("change simple array to associative with 'parameters' element");
1153
-						$parameters['parameters'] = $parameters[0];
1154
-						unset($parameters[0]);
1155
-					}
1156
-					if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1157
-						$this->debug('check whether caller\'s parameters match the wrapped ones');
1158
-						if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1159
-							$this->debug('wrap the parameters for the caller');
1160
-							$parameters = array('parameters' => $parameters);
1161
-							$parameter_count = 1;
1162
-						}
1163
-					}
1164
-				}
1165
-				foreach ($parts as $name => $type) {
1166
-					$this->debug("serializing part $name of type $type");
1167
-					// Track encoding style
1168
-					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1169
-						$encodingStyle = $opData[$direction]['encodingStyle'];
1170
-						$enc_style = $encodingStyle;
1171
-					} else {
1172
-						$enc_style = false;
1173
-					}
1174
-					// NOTE: add error handling here
1175
-					// if serializeType returns false, then catch global error and fault
1176
-					if ($parametersArrayType == 'arraySimple') {
1177
-						$p = array_shift($parameters);
1178
-						$this->debug('calling serializeType w/indexed param');
1179
-						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1180
-					} elseif (isset($parameters[$name])) {
1181
-						$this->debug('calling serializeType w/named param');
1182
-						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1183
-					} else {
1184
-						// TODO: only send nillable
1185
-						$this->debug('calling serializeType w/null param');
1186
-						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1187
-					}
1188
-				}
1189
-			} else {
1190
-				$this->debug('no parameters passed.');
1191
-			}
1192
-		}
1193
-		$this->debug("serializeRPCParameters returning: $xml");
1194
-		return $xml;
1195
-	}
1134
+        // set input params
1135
+        $xml = '';
1136
+        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1137
+            $parts = &$opData[$direction]['parts'];
1138
+            $part_count = sizeof($parts);
1139
+            $style = $opData['style'];
1140
+            $use = $opData[$direction]['use'];
1141
+            $this->debug("have $part_count part(s) to serialize using $style/$use");
1142
+            if (is_array($parameters)) {
1143
+                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1144
+                $parameter_count = count($parameters);
1145
+                $this->debug("have $parameter_count parameter(s) provided as $parametersArrayType to serialize");
1146
+                // check for Microsoft-style wrapped parameters
1147
+                if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
1148
+                    $this->debug('check whether the caller has wrapped the parameters');
1149
+                    if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
1150
+                        // TODO: consider checking here for double-wrapping, when
1151
+                        // service function wraps, then NuSOAP wraps again
1152
+                        $this->debug("change simple array to associative with 'parameters' element");
1153
+                        $parameters['parameters'] = $parameters[0];
1154
+                        unset($parameters[0]);
1155
+                    }
1156
+                    if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
1157
+                        $this->debug('check whether caller\'s parameters match the wrapped ones');
1158
+                        if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
1159
+                            $this->debug('wrap the parameters for the caller');
1160
+                            $parameters = array('parameters' => $parameters);
1161
+                            $parameter_count = 1;
1162
+                        }
1163
+                    }
1164
+                }
1165
+                foreach ($parts as $name => $type) {
1166
+                    $this->debug("serializing part $name of type $type");
1167
+                    // Track encoding style
1168
+                    if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1169
+                        $encodingStyle = $opData[$direction]['encodingStyle'];
1170
+                        $enc_style = $encodingStyle;
1171
+                    } else {
1172
+                        $enc_style = false;
1173
+                    }
1174
+                    // NOTE: add error handling here
1175
+                    // if serializeType returns false, then catch global error and fault
1176
+                    if ($parametersArrayType == 'arraySimple') {
1177
+                        $p = array_shift($parameters);
1178
+                        $this->debug('calling serializeType w/indexed param');
1179
+                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1180
+                    } elseif (isset($parameters[$name])) {
1181
+                        $this->debug('calling serializeType w/named param');
1182
+                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1183
+                    } else {
1184
+                        // TODO: only send nillable
1185
+                        $this->debug('calling serializeType w/null param');
1186
+                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1187
+                    }
1188
+                }
1189
+            } else {
1190
+                $this->debug('no parameters passed.');
1191
+            }
1192
+        }
1193
+        $this->debug("serializeRPCParameters returning: $xml");
1194
+        return $xml;
1195
+    }
1196 1196
 
1197
-	/**
1198
-	 * serialize a PHP value according to a WSDL message definition
1199
-	 *
1200
-	 * TODO
1201
-	 * - multi-ref serialization
1202
-	 * - validate PHP values against type definitions, return errors if invalid
1203
-	 *
1204
-	 * @param string $operation operation name
1205
-	 * @param string $direction (input|output)
1206
-	 * @param mixed $parameters parameter value(s)
1207
-	 * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1208
-	 * @access public
1209
-	 * @deprecated
1210
-	 */
1211
-	function serializeParameters($operation, $direction, $parameters)
1212
-	{
1213
-		$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1214
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1197
+    /**
1198
+     * serialize a PHP value according to a WSDL message definition
1199
+     *
1200
+     * TODO
1201
+     * - multi-ref serialization
1202
+     * - validate PHP values against type definitions, return errors if invalid
1203
+     *
1204
+     * @param string $operation operation name
1205
+     * @param string $direction (input|output)
1206
+     * @param mixed $parameters parameter value(s)
1207
+     * @return mixed parameters serialized as XML or false on error (e.g. operation not found)
1208
+     * @access public
1209
+     * @deprecated
1210
+     */
1211
+    function serializeParameters($operation, $direction, $parameters)
1212
+    {
1213
+        $this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1214
+        $this->appendDebug('parameters=' . $this->varDump($parameters));
1215 1215
 
1216
-		if ($direction != 'input' && $direction != 'output') {
1217
-			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1218
-			$this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1219
-			return false;
1220
-		}
1221
-		if (!$opData = $this->getOperationData($operation)) {
1222
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1223
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1224
-			return false;
1225
-		}
1226
-		$this->debug('opData:');
1227
-		$this->appendDebug($this->varDump($opData));
1216
+        if ($direction != 'input' && $direction != 'output') {
1217
+            $this->debug('The value of the \$direction argument needs to be either "input" or "output"');
1218
+            $this->setError('The value of the \$direction argument needs to be either "input" or "output"');
1219
+            return false;
1220
+        }
1221
+        if (!$opData = $this->getOperationData($operation)) {
1222
+            $this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1223
+            $this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1224
+            return false;
1225
+        }
1226
+        $this->debug('opData:');
1227
+        $this->appendDebug($this->varDump($opData));
1228 1228
 
1229
-		// Get encoding style for output and set to current
1230
-		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1231
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1232
-			$encodingStyle = $opData['output']['encodingStyle'];
1233
-			$enc_style = $encodingStyle;
1234
-		}
1229
+        // Get encoding style for output and set to current
1230
+        $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1231
+        if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1232
+            $encodingStyle = $opData['output']['encodingStyle'];
1233
+            $enc_style = $encodingStyle;
1234
+        }
1235 1235
 
1236
-		// set input params
1237
-		$xml = '';
1238
-		if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1236
+        // set input params
1237
+        $xml = '';
1238
+        if (isset($opData[$direction]['parts']) && sizeof($opData[$direction]['parts']) > 0) {
1239 1239
 
1240
-			$use = $opData[$direction]['use'];
1241
-			$this->debug("use=$use");
1242
-			$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1243
-			if (is_array($parameters)) {
1244
-				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1245
-				$this->debug('have ' . $parametersArrayType . ' parameters');
1246
-				foreach($opData[$direction]['parts'] as $name => $type) {
1247
-					$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1248
-					// Track encoding style
1249
-					if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1250
-						$encodingStyle = $opData[$direction]['encodingStyle'];
1251
-						$enc_style = $encodingStyle;
1252
-					} else {
1253
-						$enc_style = false;
1254
-					}
1255
-					// NOTE: add error handling here
1256
-					// if serializeType returns false, then catch global error and fault
1257
-					if ($parametersArrayType == 'arraySimple') {
1258
-						$p = array_shift($parameters);
1259
-						$this->debug('calling serializeType w/indexed param');
1260
-						$xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1261
-					} elseif (isset($parameters[$name])) {
1262
-						$this->debug('calling serializeType w/named param');
1263
-						$xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1264
-					} else {
1265
-						// TODO: only send nillable
1266
-						$this->debug('calling serializeType w/null param');
1267
-						$xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1268
-					}
1269
-				}
1270
-			} else {
1271
-				$this->debug('no parameters passed.');
1272
-			}
1273
-		}
1274
-		$this->debug("serializeParameters returning: $xml");
1275
-		return $xml;
1276
-	}
1240
+            $use = $opData[$direction]['use'];
1241
+            $this->debug("use=$use");
1242
+            $this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1243
+            if (is_array($parameters)) {
1244
+                $parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1245
+                $this->debug('have ' . $parametersArrayType . ' parameters');
1246
+                foreach($opData[$direction]['parts'] as $name => $type) {
1247
+                    $this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1248
+                    // Track encoding style
1249
+                    if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1250
+                        $encodingStyle = $opData[$direction]['encodingStyle'];
1251
+                        $enc_style = $encodingStyle;
1252
+                    } else {
1253
+                        $enc_style = false;
1254
+                    }
1255
+                    // NOTE: add error handling here
1256
+                    // if serializeType returns false, then catch global error and fault
1257
+                    if ($parametersArrayType == 'arraySimple') {
1258
+                        $p = array_shift($parameters);
1259
+                        $this->debug('calling serializeType w/indexed param');
1260
+                        $xml .= $this->serializeType($name, $type, $p, $use, $enc_style);
1261
+                    } elseif (isset($parameters[$name])) {
1262
+                        $this->debug('calling serializeType w/named param');
1263
+                        $xml .= $this->serializeType($name, $type, $parameters[$name], $use, $enc_style);
1264
+                    } else {
1265
+                        // TODO: only send nillable
1266
+                        $this->debug('calling serializeType w/null param');
1267
+                        $xml .= $this->serializeType($name, $type, null, $use, $enc_style);
1268
+                    }
1269
+                }
1270
+            } else {
1271
+                $this->debug('no parameters passed.');
1272
+            }
1273
+        }
1274
+        $this->debug("serializeParameters returning: $xml");
1275
+        return $xml;
1276
+    }
1277 1277
 
1278
-	/**
1279
-	 * serializes a PHP value according a given type definition
1280
-	 *
1281
-	 * @param string $name name of value (part or element)
1282
-	 * @param string $type XML schema type of value (type or element)
1283
-	 * @param mixed $value a native PHP value (parameter value)
1284
-	 * @param string $use use for part (encoded|literal)
1285
-	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1286
-	 * @param boolean $unqualified a kludge for what should be XML namespace form handling
1287
-	 * @return string value serialized as an XML string
1288
-	 * @access private
1289
-	 */
1290
-	function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1291
-	{
1292
-		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1293
-		$this->appendDebug("value=" . $this->varDump($value));
1294
-		if($use == 'encoded' && $encodingStyle) {
1295
-			$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1296
-		}
1278
+    /**
1279
+     * serializes a PHP value according a given type definition
1280
+     *
1281
+     * @param string $name name of value (part or element)
1282
+     * @param string $type XML schema type of value (type or element)
1283
+     * @param mixed $value a native PHP value (parameter value)
1284
+     * @param string $use use for part (encoded|literal)
1285
+     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1286
+     * @param boolean $unqualified a kludge for what should be XML namespace form handling
1287
+     * @return string value serialized as an XML string
1288
+     * @access private
1289
+     */
1290
+    function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1291
+    {
1292
+        $this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1293
+        $this->appendDebug("value=" . $this->varDump($value));
1294
+        if($use == 'encoded' && $encodingStyle) {
1295
+            $encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1296
+        }
1297 1297
 
1298
-		// if a soapval has been supplied, let its type override the WSDL
1299
-    	if (is_object($value) && get_class($value) == 'soapval') {
1300
-    		if ($value->type_ns) {
1301
-    			$type = $value->type_ns . ':' . $value->type;
1302
-		    	$forceType = true;
1303
-		    	$this->debug("in serializeType: soapval overrides type to $type");
1304
-    		} elseif ($value->type) {
1305
-	    		$type = $value->type;
1306
-		    	$forceType = true;
1307
-		    	$this->debug("in serializeType: soapval overrides type to $type");
1308
-	    	} else {
1309
-	    		$forceType = false;
1310
-		    	$this->debug("in serializeType: soapval does not override type");
1311
-	    	}
1312
-	    	$attrs = $value->attributes;
1313
-	    	$value = $value->value;
1314
-	    	$this->debug("in serializeType: soapval overrides value to $value");
1315
-	    	if ($attrs) {
1316
-	    		if (!is_array($value)) {
1317
-	    			$value['!'] = $value;
1318
-	    		}
1319
-	    		foreach ($attrs as $n => $v) {
1320
-	    			$value['!' . $n] = $v;
1321
-	    		}
1322
-		    	$this->debug("in serializeType: soapval provides attributes");
1323
-		    }
1298
+        // if a soapval has been supplied, let its type override the WSDL
1299
+        if (is_object($value) && get_class($value) == 'soapval') {
1300
+            if ($value->type_ns) {
1301
+                $type = $value->type_ns . ':' . $value->type;
1302
+                $forceType = true;
1303
+                $this->debug("in serializeType: soapval overrides type to $type");
1304
+            } elseif ($value->type) {
1305
+                $type = $value->type;
1306
+                $forceType = true;
1307
+                $this->debug("in serializeType: soapval overrides type to $type");
1308
+            } else {
1309
+                $forceType = false;
1310
+                $this->debug("in serializeType: soapval does not override type");
1311
+            }
1312
+            $attrs = $value->attributes;
1313
+            $value = $value->value;
1314
+            $this->debug("in serializeType: soapval overrides value to $value");
1315
+            if ($attrs) {
1316
+                if (!is_array($value)) {
1317
+                    $value['!'] = $value;
1318
+                }
1319
+                foreach ($attrs as $n => $v) {
1320
+                    $value['!' . $n] = $v;
1321
+                }
1322
+                $this->debug("in serializeType: soapval provides attributes");
1323
+            }
1324 1324
         } else {
1325
-        	$forceType = false;
1325
+            $forceType = false;
1326 1326
         }
1327 1327
 
1328
-		$xml = '';
1329
-		if (strpos($type, ':')) {
1330
-			$uqType = substr($type, strrpos($type, ':') + 1);
1331
-			$ns = substr($type, 0, strrpos($type, ':'));
1332
-			$this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1333
-			if ($this->getNamespaceFromPrefix($ns)) {
1334
-				$ns = $this->getNamespaceFromPrefix($ns);
1335
-				$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1336
-			}
1328
+        $xml = '';
1329
+        if (strpos($type, ':')) {
1330
+            $uqType = substr($type, strrpos($type, ':') + 1);
1331
+            $ns = substr($type, 0, strrpos($type, ':'));
1332
+            $this->debug("in serializeType: got a prefixed type: $uqType, $ns");
1333
+            if ($this->getNamespaceFromPrefix($ns)) {
1334
+                $ns = $this->getNamespaceFromPrefix($ns);
1335
+                $this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1336
+            }
1337 1337
 
1338
-			if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1339
-				$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1340
-				if ($unqualified && $use == 'literal') {
1341
-					$elementNS = " xmlns=\"\"";
1342
-				} else {
1343
-					$elementNS = '';
1344
-				}
1345
-				if (is_null($value)) {
1346
-					if ($use == 'literal') {
1347
-						// TODO: depends on minOccurs
1348
-						$xml = "<$name$elementNS/>";
1349
-					} else {
1350
-						// TODO: depends on nillable, which should be checked before calling this method
1351
-						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1352
-					}
1353
-					$this->debug("in serializeType: returning: $xml");
1354
-					return $xml;
1355
-				}
1356
-				if ($uqType == 'Array') {
1357
-					// JBoss/Axis does this sometimes
1358
-					return $this->serialize_val($value, $name, false, false, false, false, $use);
1359
-				}
1360
-		    	if ($uqType == 'boolean') {
1361
-		    		if ((is_string($value) && $value == 'false') || (! $value)) {
1362
-						$value = 'false';
1363
-					} else {
1364
-						$value = 'true';
1365
-					}
1366
-				}
1367
-				if ($uqType == 'string' && gettype($value) == 'string') {
1368
-					$value = $this->expandEntities($value);
1369
-				}
1370
-				if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1371
-					$value = sprintf("%.0lf", $value);
1372
-				}
1373
-				// it's a scalar
1374
-				// TODO: what about null/nil values?
1375
-				// check type isn't a custom type extending xmlschema namespace
1376
-				if (!$this->getTypeDef($uqType, $ns)) {
1377
-					if ($use == 'literal') {
1378
-						if ($forceType) {
1379
-							$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1380
-						} else {
1381
-							$xml = "<$name$elementNS>$value</$name>";
1382
-						}
1383
-					} else {
1384
-						$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1385
-					}
1386
-					$this->debug("in serializeType: returning: $xml");
1387
-					return $xml;
1388
-				}
1389
-				$this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1390
-			} else if ($ns == 'http://xml.apache.org/xml-soap') {
1391
-				$this->debug('in serializeType: appears to be Apache SOAP type');
1392
-				if ($uqType == 'Map') {
1393
-					$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1394
-					if (! $tt_prefix) {
1395
-						$this->debug('in serializeType: Add namespace for Apache SOAP type');
1396
-						$tt_prefix = 'ns' . rand(1000, 9999);
1397
-						$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1398
-						// force this to be added to usedNamespaces
1399
-						$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1400
-					}
1401
-					$contents = '';
1402
-					foreach($value as $k => $v) {
1403
-						$this->debug("serializing map element: key $k, value $v");
1404
-						$contents .= '<item>';
1405
-						$contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1406
-						$contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1407
-						$contents .= '</item>';
1408
-					}
1409
-					if ($use == 'literal') {
1410
-						if ($forceType) {
1411
-							$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1412
-						} else {
1413
-							$xml = "<$name>$contents</$name>";
1414
-						}
1415
-					} else {
1416
-						$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1417
-					}
1418
-					$this->debug("in serializeType: returning: $xml");
1419
-					return $xml;
1420
-				}
1421
-				$this->debug('in serializeType: Apache SOAP type, but only support Map');
1422
-			}
1423
-		} else {
1424
-			// TODO: should the type be compared to types in XSD, and the namespace
1425
-			// set to XSD if the type matches?
1426
-			$this->debug("in serializeType: No namespace for type $type");
1427
-			$ns = '';
1428
-			$uqType = $type;
1429
-		}
1430
-		if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1431
-			$this->setError("$type ($uqType) is not a supported type.");
1432
-			$this->debug("in serializeType: $type ($uqType) is not a supported type.");
1433
-			return false;
1434
-		} else {
1435
-			$this->debug("in serializeType: found typeDef");
1436
-			$this->appendDebug('typeDef=' . $this->varDump($typeDef));
1437
-			if (substr($uqType, -1) == '^') {
1438
-				$uqType = substr($uqType, 0, -1);
1439
-			}
1440
-		}
1441
-		if (!isset($typeDef['phpType'])) {
1442
-			$this->setError("$type ($uqType) has no phpType.");
1443
-			$this->debug("in serializeType: $type ($uqType) has no phpType.");
1444
-			return false;
1445
-		}
1446
-		$phpType = $typeDef['phpType'];
1447
-		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1448
-		// if php type == struct, map value to the <all> element names
1449
-		if ($phpType == 'struct') {
1450
-			if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1451
-				$elementName = $uqType;
1452
-				if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1453
-					$elementNS = " xmlns=\"$ns\"";
1454
-				} else {
1455
-					$elementNS = " xmlns=\"\"";
1456
-				}
1457
-			} else {
1458
-				$elementName = $name;
1459
-				if ($unqualified) {
1460
-					$elementNS = " xmlns=\"\"";
1461
-				} else {
1462
-					$elementNS = '';
1463
-				}
1464
-			}
1465
-			if (is_null($value)) {
1466
-				if ($use == 'literal') {
1467
-					// TODO: depends on minOccurs and nillable
1468
-					$xml = "<$elementName$elementNS/>";
1469
-				} else {
1470
-					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1471
-				}
1472
-				$this->debug("in serializeType: returning: $xml");
1473
-				return $xml;
1474
-			}
1475
-			if (is_object($value)) {
1476
-				$value = get_object_vars($value);
1477
-			}
1478
-			if (is_array($value)) {
1479
-				$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1480
-				if ($use == 'literal') {
1481
-					if ($forceType) {
1482
-						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1483
-					} else {
1484
-						$xml = "<$elementName$elementNS$elementAttrs>";
1485
-					}
1486
-				} else {
1487
-					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1488
-				}
1338
+            if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1339
+                $this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1340
+                if ($unqualified && $use == 'literal') {
1341
+                    $elementNS = " xmlns=\"\"";
1342
+                } else {
1343
+                    $elementNS = '';
1344
+                }
1345
+                if (is_null($value)) {
1346
+                    if ($use == 'literal') {
1347
+                        // TODO: depends on minOccurs
1348
+                        $xml = "<$name$elementNS/>";
1349
+                    } else {
1350
+                        // TODO: depends on nillable, which should be checked before calling this method
1351
+                        $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1352
+                    }
1353
+                    $this->debug("in serializeType: returning: $xml");
1354
+                    return $xml;
1355
+                }
1356
+                if ($uqType == 'Array') {
1357
+                    // JBoss/Axis does this sometimes
1358
+                    return $this->serialize_val($value, $name, false, false, false, false, $use);
1359
+                }
1360
+                if ($uqType == 'boolean') {
1361
+                    if ((is_string($value) && $value == 'false') || (! $value)) {
1362
+                        $value = 'false';
1363
+                    } else {
1364
+                        $value = 'true';
1365
+                    }
1366
+                }
1367
+                if ($uqType == 'string' && gettype($value) == 'string') {
1368
+                    $value = $this->expandEntities($value);
1369
+                }
1370
+                if (($uqType == 'long' || $uqType == 'unsignedLong') && gettype($value) == 'double') {
1371
+                    $value = sprintf("%.0lf", $value);
1372
+                }
1373
+                // it's a scalar
1374
+                // TODO: what about null/nil values?
1375
+                // check type isn't a custom type extending xmlschema namespace
1376
+                if (!$this->getTypeDef($uqType, $ns)) {
1377
+                    if ($use == 'literal') {
1378
+                        if ($forceType) {
1379
+                            $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1380
+                        } else {
1381
+                            $xml = "<$name$elementNS>$value</$name>";
1382
+                        }
1383
+                    } else {
1384
+                        $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1385
+                    }
1386
+                    $this->debug("in serializeType: returning: $xml");
1387
+                    return $xml;
1388
+                }
1389
+                $this->debug('custom type extends XML Schema or SOAP Encoding namespace (yuck)');
1390
+            } else if ($ns == 'http://xml.apache.org/xml-soap') {
1391
+                $this->debug('in serializeType: appears to be Apache SOAP type');
1392
+                if ($uqType == 'Map') {
1393
+                    $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1394
+                    if (! $tt_prefix) {
1395
+                        $this->debug('in serializeType: Add namespace for Apache SOAP type');
1396
+                        $tt_prefix = 'ns' . rand(1000, 9999);
1397
+                        $this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1398
+                        // force this to be added to usedNamespaces
1399
+                        $tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1400
+                    }
1401
+                    $contents = '';
1402
+                    foreach($value as $k => $v) {
1403
+                        $this->debug("serializing map element: key $k, value $v");
1404
+                        $contents .= '<item>';
1405
+                        $contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1406
+                        $contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1407
+                        $contents .= '</item>';
1408
+                    }
1409
+                    if ($use == 'literal') {
1410
+                        if ($forceType) {
1411
+                            $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1412
+                        } else {
1413
+                            $xml = "<$name>$contents</$name>";
1414
+                        }
1415
+                    } else {
1416
+                        $xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1417
+                    }
1418
+                    $this->debug("in serializeType: returning: $xml");
1419
+                    return $xml;
1420
+                }
1421
+                $this->debug('in serializeType: Apache SOAP type, but only support Map');
1422
+            }
1423
+        } else {
1424
+            // TODO: should the type be compared to types in XSD, and the namespace
1425
+            // set to XSD if the type matches?
1426
+            $this->debug("in serializeType: No namespace for type $type");
1427
+            $ns = '';
1428
+            $uqType = $type;
1429
+        }
1430
+        if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1431
+            $this->setError("$type ($uqType) is not a supported type.");
1432
+            $this->debug("in serializeType: $type ($uqType) is not a supported type.");
1433
+            return false;
1434
+        } else {
1435
+            $this->debug("in serializeType: found typeDef");
1436
+            $this->appendDebug('typeDef=' . $this->varDump($typeDef));
1437
+            if (substr($uqType, -1) == '^') {
1438
+                $uqType = substr($uqType, 0, -1);
1439
+            }
1440
+        }
1441
+        if (!isset($typeDef['phpType'])) {
1442
+            $this->setError("$type ($uqType) has no phpType.");
1443
+            $this->debug("in serializeType: $type ($uqType) has no phpType.");
1444
+            return false;
1445
+        }
1446
+        $phpType = $typeDef['phpType'];
1447
+        $this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1448
+        // if php type == struct, map value to the <all> element names
1449
+        if ($phpType == 'struct') {
1450
+            if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
1451
+                $elementName = $uqType;
1452
+                if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1453
+                    $elementNS = " xmlns=\"$ns\"";
1454
+                } else {
1455
+                    $elementNS = " xmlns=\"\"";
1456
+                }
1457
+            } else {
1458
+                $elementName = $name;
1459
+                if ($unqualified) {
1460
+                    $elementNS = " xmlns=\"\"";
1461
+                } else {
1462
+                    $elementNS = '';
1463
+                }
1464
+            }
1465
+            if (is_null($value)) {
1466
+                if ($use == 'literal') {
1467
+                    // TODO: depends on minOccurs and nillable
1468
+                    $xml = "<$elementName$elementNS/>";
1469
+                } else {
1470
+                    $xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1471
+                }
1472
+                $this->debug("in serializeType: returning: $xml");
1473
+                return $xml;
1474
+            }
1475
+            if (is_object($value)) {
1476
+                $value = get_object_vars($value);
1477
+            }
1478
+            if (is_array($value)) {
1479
+                $elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1480
+                if ($use == 'literal') {
1481
+                    if ($forceType) {
1482
+                        $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1483
+                    } else {
1484
+                        $xml = "<$elementName$elementNS$elementAttrs>";
1485
+                    }
1486
+                } else {
1487
+                    $xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1488
+                }
1489 1489
 
1490
-				if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1491
-					if (isset($value['!'])) {
1492
-						$xml .= $value['!'];
1493
-						$this->debug("in serializeType: serialized simpleContent for type $type");
1494
-					} else {
1495
-						$this->debug("in serializeType: no simpleContent to serialize for type $type");
1496
-					}
1497
-				} else {
1498
-					// complexContent
1499
-					$xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1500
-				}
1501
-				$xml .= "</$elementName>";
1502
-			} else {
1503
-				$this->debug("in serializeType: phpType is struct, but value is not an array");
1504
-				$this->setError("phpType is struct, but value is not an array: see debug output for details");
1505
-				$xml = '';
1506
-			}
1507
-		} elseif ($phpType == 'array') {
1508
-			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1509
-				$elementNS = " xmlns=\"$ns\"";
1510
-			} else {
1511
-				if ($unqualified) {
1512
-					$elementNS = " xmlns=\"\"";
1513
-				} else {
1514
-					$elementNS = '';
1515
-				}
1516
-			}
1517
-			if (is_null($value)) {
1518
-				if ($use == 'literal') {
1519
-					// TODO: depends on minOccurs
1520
-					$xml = "<$name$elementNS/>";
1521
-				} else {
1522
-					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1523
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1524
-						":Array\" " .
1525
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
-						':arrayType="' .
1527
-						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1528
-						':' .
1529
-						$this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1530
-				}
1531
-				$this->debug("in serializeType: returning: $xml");
1532
-				return $xml;
1533
-			}
1534
-			if (isset($typeDef['multidimensional'])) {
1535
-				$nv = array();
1536
-				foreach($value as $v) {
1537
-					$cols = ',' . sizeof($v);
1538
-					$nv = array_merge($nv, $v);
1539
-				}
1540
-				$value = $nv;
1541
-			} else {
1542
-				$cols = '';
1543
-			}
1544
-			if (is_array($value) && sizeof($value) >= 1) {
1545
-				$rows = sizeof($value);
1546
-				$contents = '';
1547
-				foreach($value as $k => $v) {
1548
-					//$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1549
-					//if (strpos($typeDef['arrayType'], ':') ) {
1550
-					if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1551
-					    $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1552
-					} else {
1553
-					    $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1554
-					}
1555
-				}
1556
-			} else {
1557
-				$rows = 0;
1558
-				$contents = null;
1559
-			}
1560
-			// TODO: for now, an empty value will be serialized as a zero element
1561
-			// array.  Revisit this when coding the handling of null/nil values.
1562
-			if ($use == 'literal') {
1563
-				$xml = "<$name$elementNS>"
1564
-					.$contents
1565
-					."</$name>";
1566
-			} else {
1567
-				$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1568
-					$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1569
-					.':arrayType="'
1570
-					.$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1571
-					.":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1572
-					.$contents
1573
-					."</$name>";
1574
-			}
1575
-		} elseif ($phpType == 'scalar') {
1576
-			if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1577
-				$elementNS = " xmlns=\"$ns\"";
1578
-			} else {
1579
-				if ($unqualified) {
1580
-					$elementNS = " xmlns=\"\"";
1581
-				} else {
1582
-					$elementNS = '';
1583
-				}
1584
-			}
1585
-			if ($use == 'literal') {
1586
-				if ($forceType) {
1587
-					$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1588
-				} else {
1589
-					$xml = "<$name$elementNS>$value</$name>";
1590
-				}
1591
-			} else {
1592
-				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1593
-			}
1594
-		}
1595
-		$this->debug("in serializeType: returning: $xml");
1596
-		return $xml;
1597
-	}
1490
+                if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
1491
+                    if (isset($value['!'])) {
1492
+                        $xml .= $value['!'];
1493
+                        $this->debug("in serializeType: serialized simpleContent for type $type");
1494
+                    } else {
1495
+                        $this->debug("in serializeType: no simpleContent to serialize for type $type");
1496
+                    }
1497
+                } else {
1498
+                    // complexContent
1499
+                    $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
1500
+                }
1501
+                $xml .= "</$elementName>";
1502
+            } else {
1503
+                $this->debug("in serializeType: phpType is struct, but value is not an array");
1504
+                $this->setError("phpType is struct, but value is not an array: see debug output for details");
1505
+                $xml = '';
1506
+            }
1507
+        } elseif ($phpType == 'array') {
1508
+            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1509
+                $elementNS = " xmlns=\"$ns\"";
1510
+            } else {
1511
+                if ($unqualified) {
1512
+                    $elementNS = " xmlns=\"\"";
1513
+                } else {
1514
+                    $elementNS = '';
1515
+                }
1516
+            }
1517
+            if (is_null($value)) {
1518
+                if ($use == 'literal') {
1519
+                    // TODO: depends on minOccurs
1520
+                    $xml = "<$name$elementNS/>";
1521
+                } else {
1522
+                    $xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1523
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1524
+                        ":Array\" " .
1525
+                        $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
+                        ':arrayType="' .
1527
+                        $this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1528
+                        ':' .
1529
+                        $this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1530
+                }
1531
+                $this->debug("in serializeType: returning: $xml");
1532
+                return $xml;
1533
+            }
1534
+            if (isset($typeDef['multidimensional'])) {
1535
+                $nv = array();
1536
+                foreach($value as $v) {
1537
+                    $cols = ',' . sizeof($v);
1538
+                    $nv = array_merge($nv, $v);
1539
+                }
1540
+                $value = $nv;
1541
+            } else {
1542
+                $cols = '';
1543
+            }
1544
+            if (is_array($value) && sizeof($value) >= 1) {
1545
+                $rows = sizeof($value);
1546
+                $contents = '';
1547
+                foreach($value as $k => $v) {
1548
+                    //$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1549
+                    //if (strpos($typeDef['arrayType'], ':') ) {
1550
+                    if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1551
+                        $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1552
+                    } else {
1553
+                        $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
1554
+                    }
1555
+                }
1556
+            } else {
1557
+                $rows = 0;
1558
+                $contents = null;
1559
+            }
1560
+            // TODO: for now, an empty value will be serialized as a zero element
1561
+            // array.  Revisit this when coding the handling of null/nil values.
1562
+            if ($use == 'literal') {
1563
+                $xml = "<$name$elementNS>"
1564
+                    .$contents
1565
+                    ."</$name>";
1566
+            } else {
1567
+                $xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').':Array" '.
1568
+                    $this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/')
1569
+                    .':arrayType="'
1570
+                    .$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType']))
1571
+                    .":".$this->getLocalPart($typeDef['arrayType'])."[$rows$cols]\">"
1572
+                    .$contents
1573
+                    ."</$name>";
1574
+            }
1575
+        } elseif ($phpType == 'scalar') {
1576
+            if (isset($typeDef['form']) && ($typeDef['form'] == 'qualified')) {
1577
+                $elementNS = " xmlns=\"$ns\"";
1578
+            } else {
1579
+                if ($unqualified) {
1580
+                    $elementNS = " xmlns=\"\"";
1581
+                } else {
1582
+                    $elementNS = '';
1583
+                }
1584
+            }
1585
+            if ($use == 'literal') {
1586
+                if ($forceType) {
1587
+                    $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1588
+                } else {
1589
+                    $xml = "<$name$elementNS>$value</$name>";
1590
+                }
1591
+            } else {
1592
+                $xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1593
+            }
1594
+        }
1595
+        $this->debug("in serializeType: returning: $xml");
1596
+        return $xml;
1597
+    }
1598 1598
 
1599
-	/**
1600
-	 * serializes the attributes for a complexType
1601
-	 *
1602
-	 * @param array $typeDef our internal representation of an XML schema type (or element)
1603
-	 * @param mixed $value a native PHP value (parameter value)
1604
-	 * @param string $ns the namespace of the type
1605
-	 * @param string $uqType the local part of the type
1606
-	 * @return string value serialized as an XML string
1607
-	 * @access private
1608
-	 */
1609
-	function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1610
-		$this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1611
-		$xml = '';
1612
-		if (isset($typeDef['extensionBase'])) {
1613
-			$nsx = $this->getPrefix($typeDef['extensionBase']);
1614
-			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1615
-			if ($this->getNamespaceFromPrefix($nsx)) {
1616
-				$nsx = $this->getNamespaceFromPrefix($nsx);
1617
-			}
1618
-			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1619
-				$this->debug("serialize attributes for extension base $nsx:$uqTypex");
1620
-				$xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1621
-			} else {
1622
-				$this->debug("extension base $nsx:$uqTypex is not a supported type");
1623
-			}
1624
-		}
1625
-		if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1626
-			$this->debug("serialize attributes for XML Schema type $ns:$uqType");
1627
-			if (is_array($value)) {
1628
-				$xvalue = $value;
1629
-			} elseif (is_object($value)) {
1630
-				$xvalue = get_object_vars($value);
1631
-			} else {
1632
-				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1633
-				$xvalue = array();
1634
-			}
1635
-			foreach ($typeDef['attrs'] as $aName => $attrs) {
1636
-				if (isset($xvalue['!' . $aName])) {
1637
-					$xname = '!' . $aName;
1638
-					$this->debug("value provided for attribute $aName with key $xname");
1639
-				} elseif (isset($xvalue[$aName])) {
1640
-					$xname = $aName;
1641
-					$this->debug("value provided for attribute $aName with key $xname");
1642
-				} elseif (isset($attrs['default'])) {
1643
-					$xname = '!' . $aName;
1644
-					$xvalue[$xname] = $attrs['default'];
1645
-					$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1646
-				} else {
1647
-					$xname = '';
1648
-					$this->debug("no value provided for attribute $aName");
1649
-				}
1650
-				if ($xname) {
1651
-					$xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1652
-				}
1653
-			}
1654
-		} else {
1655
-			$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1656
-		}
1657
-		return $xml;
1658
-	}
1599
+    /**
1600
+     * serializes the attributes for a complexType
1601
+     *
1602
+     * @param array $typeDef our internal representation of an XML schema type (or element)
1603
+     * @param mixed $value a native PHP value (parameter value)
1604
+     * @param string $ns the namespace of the type
1605
+     * @param string $uqType the local part of the type
1606
+     * @return string value serialized as an XML string
1607
+     * @access private
1608
+     */
1609
+    function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
1610
+        $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
1611
+        $xml = '';
1612
+        if (isset($typeDef['extensionBase'])) {
1613
+            $nsx = $this->getPrefix($typeDef['extensionBase']);
1614
+            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1615
+            if ($this->getNamespaceFromPrefix($nsx)) {
1616
+                $nsx = $this->getNamespaceFromPrefix($nsx);
1617
+            }
1618
+            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1619
+                $this->debug("serialize attributes for extension base $nsx:$uqTypex");
1620
+                $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
1621
+            } else {
1622
+                $this->debug("extension base $nsx:$uqTypex is not a supported type");
1623
+            }
1624
+        }
1625
+        if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
1626
+            $this->debug("serialize attributes for XML Schema type $ns:$uqType");
1627
+            if (is_array($value)) {
1628
+                $xvalue = $value;
1629
+            } elseif (is_object($value)) {
1630
+                $xvalue = get_object_vars($value);
1631
+            } else {
1632
+                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1633
+                $xvalue = array();
1634
+            }
1635
+            foreach ($typeDef['attrs'] as $aName => $attrs) {
1636
+                if (isset($xvalue['!' . $aName])) {
1637
+                    $xname = '!' . $aName;
1638
+                    $this->debug("value provided for attribute $aName with key $xname");
1639
+                } elseif (isset($xvalue[$aName])) {
1640
+                    $xname = $aName;
1641
+                    $this->debug("value provided for attribute $aName with key $xname");
1642
+                } elseif (isset($attrs['default'])) {
1643
+                    $xname = '!' . $aName;
1644
+                    $xvalue[$xname] = $attrs['default'];
1645
+                    $this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1646
+                } else {
1647
+                    $xname = '';
1648
+                    $this->debug("no value provided for attribute $aName");
1649
+                }
1650
+                if ($xname) {
1651
+                    $xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1652
+                }
1653
+            }
1654
+        } else {
1655
+            $this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
1656
+        }
1657
+        return $xml;
1658
+    }
1659 1659
 
1660
-	/**
1661
-	 * serializes the elements for a complexType
1662
-	 *
1663
-	 * @param array $typeDef our internal representation of an XML schema type (or element)
1664
-	 * @param mixed $value a native PHP value (parameter value)
1665
-	 * @param string $ns the namespace of the type
1666
-	 * @param string $uqType the local part of the type
1667
-	 * @param string $use use for part (encoded|literal)
1668
-	 * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1669
-	 * @return string value serialized as an XML string
1670
-	 * @access private
1671
-	 */
1672
-	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1673
-		$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1674
-		$xml = '';
1675
-		if (isset($typeDef['extensionBase'])) {
1676
-			$nsx = $this->getPrefix($typeDef['extensionBase']);
1677
-			$uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1678
-			if ($this->getNamespaceFromPrefix($nsx)) {
1679
-				$nsx = $this->getNamespaceFromPrefix($nsx);
1680
-			}
1681
-			if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1682
-				$this->debug("serialize elements for extension base $nsx:$uqTypex");
1683
-				$xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1684
-			} else {
1685
-				$this->debug("extension base $nsx:$uqTypex is not a supported type");
1686
-			}
1687
-		}
1688
-		if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1689
-			$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1690
-			if (is_array($value)) {
1691
-				$xvalue = $value;
1692
-			} elseif (is_object($value)) {
1693
-				$xvalue = get_object_vars($value);
1694
-			} else {
1695
-				$this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1696
-				$xvalue = array();
1697
-			}
1698
-			// toggle whether all elements are present - ideally should validate against schema
1699
-			if (count($typeDef['elements']) != count($xvalue)){
1700
-				$optionals = true;
1701
-			}
1702
-			foreach ($typeDef['elements'] as $eName => $attrs) {
1703
-				if (!isset($xvalue[$eName])) {
1704
-					if (isset($attrs['default'])) {
1705
-						$xvalue[$eName] = $attrs['default'];
1706
-						$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1707
-					}
1708
-				}
1709
-				// if user took advantage of a minOccurs=0, then only serialize named parameters
1710
-				if (isset($optionals)
1711
-				    && (!isset($xvalue[$eName]))
1712
-					&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1713
-					){
1714
-					if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1715
-						$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1716
-					}
1717
-					// do nothing
1718
-					$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1719
-				} else {
1720
-					// get value
1721
-					if (isset($xvalue[$eName])) {
1722
-					    $v = $xvalue[$eName];
1723
-					} else {
1724
-					    $v = null;
1725
-					}
1726
-					if (isset($attrs['form'])) {
1727
-						$unqualified = ($attrs['form'] == 'unqualified');
1728
-					} else {
1729
-						$unqualified = false;
1730
-					}
1731
-					if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1732
-						$vv = $v;
1733
-						foreach ($vv as $k => $v) {
1734
-							if (isset($attrs['type']) || isset($attrs['ref'])) {
1735
-								// serialize schema-defined type
1736
-							    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1737
-							} else {
1738
-								// serialize generic type (can this ever really happen?)
1739
-							    $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1740
-							    $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1741
-							}
1742
-						}
1743
-					} else {
1744
-						if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1745
-							// do nothing
1746
-						} elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1747
-							// TODO: serialize a nil correctly, but for now serialize schema-defined type
1748
-						    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1749
-						} elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1750
-							// serialize schema-defined type
1751
-						    $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1752
-						} else {
1753
-							// serialize generic type (can this ever really happen?)
1754
-						    $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1755
-						    $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1756
-						}
1757
-					}
1758
-				}
1759
-			}
1760
-		} else {
1761
-			$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1762
-		}
1763
-		return $xml;
1764
-	}
1660
+    /**
1661
+     * serializes the elements for a complexType
1662
+     *
1663
+     * @param array $typeDef our internal representation of an XML schema type (or element)
1664
+     * @param mixed $value a native PHP value (parameter value)
1665
+     * @param string $ns the namespace of the type
1666
+     * @param string $uqType the local part of the type
1667
+     * @param string $use use for part (encoded|literal)
1668
+     * @param string $encodingStyle SOAP encoding style for the value (if different than the enclosing style)
1669
+     * @return string value serialized as an XML string
1670
+     * @access private
1671
+     */
1672
+    function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1673
+        $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1674
+        $xml = '';
1675
+        if (isset($typeDef['extensionBase'])) {
1676
+            $nsx = $this->getPrefix($typeDef['extensionBase']);
1677
+            $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
1678
+            if ($this->getNamespaceFromPrefix($nsx)) {
1679
+                $nsx = $this->getNamespaceFromPrefix($nsx);
1680
+            }
1681
+            if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
1682
+                $this->debug("serialize elements for extension base $nsx:$uqTypex");
1683
+                $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
1684
+            } else {
1685
+                $this->debug("extension base $nsx:$uqTypex is not a supported type");
1686
+            }
1687
+        }
1688
+        if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
1689
+            $this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
1690
+            if (is_array($value)) {
1691
+                $xvalue = $value;
1692
+            } elseif (is_object($value)) {
1693
+                $xvalue = get_object_vars($value);
1694
+            } else {
1695
+                $this->debug("value is neither an array nor an object for XML Schema type $ns:$uqType");
1696
+                $xvalue = array();
1697
+            }
1698
+            // toggle whether all elements are present - ideally should validate against schema
1699
+            if (count($typeDef['elements']) != count($xvalue)){
1700
+                $optionals = true;
1701
+            }
1702
+            foreach ($typeDef['elements'] as $eName => $attrs) {
1703
+                if (!isset($xvalue[$eName])) {
1704
+                    if (isset($attrs['default'])) {
1705
+                        $xvalue[$eName] = $attrs['default'];
1706
+                        $this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1707
+                    }
1708
+                }
1709
+                // if user took advantage of a minOccurs=0, then only serialize named parameters
1710
+                if (isset($optionals)
1711
+                    && (!isset($xvalue[$eName]))
1712
+                    && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1713
+                    ){
1714
+                    if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1715
+                        $this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1716
+                    }
1717
+                    // do nothing
1718
+                    $this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
1719
+                } else {
1720
+                    // get value
1721
+                    if (isset($xvalue[$eName])) {
1722
+                        $v = $xvalue[$eName];
1723
+                    } else {
1724
+                        $v = null;
1725
+                    }
1726
+                    if (isset($attrs['form'])) {
1727
+                        $unqualified = ($attrs['form'] == 'unqualified');
1728
+                    } else {
1729
+                        $unqualified = false;
1730
+                    }
1731
+                    if (isset($attrs['maxOccurs']) && ($attrs['maxOccurs'] == 'unbounded' || $attrs['maxOccurs'] > 1) && isset($v) && is_array($v) && $this->isArraySimpleOrStruct($v) == 'arraySimple') {
1732
+                        $vv = $v;
1733
+                        foreach ($vv as $k => $v) {
1734
+                            if (isset($attrs['type']) || isset($attrs['ref'])) {
1735
+                                // serialize schema-defined type
1736
+                                $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1737
+                            } else {
1738
+                                // serialize generic type (can this ever really happen?)
1739
+                                $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1740
+                                $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1741
+                            }
1742
+                        }
1743
+                    } else {
1744
+                        if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
1745
+                            // do nothing
1746
+                        } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
1747
+                            // TODO: serialize a nil correctly, but for now serialize schema-defined type
1748
+                            $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1749
+                        } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
1750
+                            // serialize schema-defined type
1751
+                            $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
1752
+                        } else {
1753
+                            // serialize generic type (can this ever really happen?)
1754
+                            $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use");
1755
+                            $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use);
1756
+                        }
1757
+                    }
1758
+                }
1759
+            }
1760
+        } else {
1761
+            $this->debug("no elements to serialize for XML Schema type $ns:$uqType");
1762
+        }
1763
+        return $xml;
1764
+    }
1765 1765
 
1766
-	/**
1767
-	* adds an XML Schema complex type to the WSDL types
1768
-	*
1769
-	* @param string	$name
1770
-	* @param string $typeClass (complexType|simpleType|attribute)
1771
-	* @param string $phpType currently supported are array and struct (php assoc array)
1772
-	* @param string $compositor (all|sequence|choice)
1773
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1774
-	* @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1775
-	* @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1776
-	* @param string $arrayType as namespace:name (xsd:string)
1777
-	* @see nusoap_xmlschema
1778
-	* @access public
1779
-	*/
1780
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1781
-		if (count($elements) > 0) {
1782
-			$eElements = array();
1783
-	    	foreach($elements as $n => $e){
1784
-	            // expand each element
1785
-	            $ee = array();
1786
-	            foreach ($e as $k => $v) {
1787
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1788
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1789
-		            $ee[$k] = $v;
1790
-		    	}
1791
-	    		$eElements[$n] = $ee;
1792
-	    	}
1793
-	    	$elements = $eElements;
1794
-		}
1766
+    /**
1767
+     * adds an XML Schema complex type to the WSDL types
1768
+     *
1769
+     * @param string	$name
1770
+     * @param string $typeClass (complexType|simpleType|attribute)
1771
+     * @param string $phpType currently supported are array and struct (php assoc array)
1772
+     * @param string $compositor (all|sequence|choice)
1773
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1774
+     * @param array $elements e.g. array ( name => array(name=>'',type=>'') )
1775
+     * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]'))
1776
+     * @param string $arrayType as namespace:name (xsd:string)
1777
+     * @see nusoap_xmlschema
1778
+     * @access public
1779
+     */
1780
+    function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1781
+        if (count($elements) > 0) {
1782
+            $eElements = array();
1783
+            foreach($elements as $n => $e){
1784
+                // expand each element
1785
+                $ee = array();
1786
+                foreach ($e as $k => $v) {
1787
+                    $k = strpos($k,':') ? $this->expandQname($k) : $k;
1788
+                    $v = strpos($v,':') ? $this->expandQname($v) : $v;
1789
+                    $ee[$k] = $v;
1790
+                }
1791
+                $eElements[$n] = $ee;
1792
+            }
1793
+            $elements = $eElements;
1794
+        }
1795 1795
 
1796
-		if (count($attrs) > 0) {
1797
-	    	foreach($attrs as $n => $a){
1798
-	            // expand each attribute
1799
-	            foreach ($a as $k => $v) {
1800
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1801
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1802
-		            $aa[$k] = $v;
1803
-		    	}
1804
-	    		$eAttrs[$n] = $aa;
1805
-	    	}
1806
-	    	$attrs = $eAttrs;
1807
-		}
1796
+        if (count($attrs) > 0) {
1797
+            foreach($attrs as $n => $a){
1798
+                // expand each attribute
1799
+                foreach ($a as $k => $v) {
1800
+                    $k = strpos($k,':') ? $this->expandQname($k) : $k;
1801
+                    $v = strpos($v,':') ? $this->expandQname($v) : $v;
1802
+                    $aa[$k] = $v;
1803
+                }
1804
+                $eAttrs[$n] = $aa;
1805
+            }
1806
+            $attrs = $eAttrs;
1807
+        }
1808 1808
 
1809
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1810
-		$arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1809
+        $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1810
+        $arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1811 1811
 
1812
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1813
-		$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1814
-	}
1812
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1813
+        $this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1814
+    }
1815 1815
 
1816
-	/**
1817
-	* adds an XML Schema simple type to the WSDL types
1818
-	*
1819
-	* @param string $name
1820
-	* @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1821
-	* @param string $typeClass (should always be simpleType)
1822
-	* @param string $phpType (should always be scalar)
1823
-	* @param array $enumeration array of values
1824
-	* @see nusoap_xmlschema
1825
-	* @access public
1826
-	*/
1827
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1828
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1816
+    /**
1817
+     * adds an XML Schema simple type to the WSDL types
1818
+     *
1819
+     * @param string $name
1820
+     * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array)
1821
+     * @param string $typeClass (should always be simpleType)
1822
+     * @param string $phpType (should always be scalar)
1823
+     * @param array $enumeration array of values
1824
+     * @see nusoap_xmlschema
1825
+     * @access public
1826
+     */
1827
+    function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1828
+        $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1829 1829
 
1830
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1831
-		$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1832
-	}
1830
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1831
+        $this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
1832
+    }
1833 1833
 
1834
-	/**
1835
-	* adds an element to the WSDL types
1836
-	*
1837
-	* @param array $attrs attributes that must include name and type
1838
-	* @see nusoap_xmlschema
1839
-	* @access public
1840
-	*/
1841
-	function addElement($attrs) {
1842
-		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1843
-		$this->schemas[$typens][0]->addElement($attrs);
1844
-	}
1834
+    /**
1835
+     * adds an element to the WSDL types
1836
+     *
1837
+     * @param array $attrs attributes that must include name and type
1838
+     * @see nusoap_xmlschema
1839
+     * @access public
1840
+     */
1841
+    function addElement($attrs) {
1842
+        $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1843
+        $this->schemas[$typens][0]->addElement($attrs);
1844
+    }
1845 1845
 
1846
-	/**
1847
-	* register an operation with the server
1848
-	*
1849
-	* @param string $name operation (method) name
1850
-	* @param array $in assoc array of input values: key = param name, value = param type
1851
-	* @param array $out assoc array of output values: key = param name, value = param type
1852
-	* @param string $namespace optional The namespace for the operation
1853
-	* @param string $soapaction optional The soapaction for the operation
1854
-	* @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
1855
-	* @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1856
-	* @param string $documentation optional The description to include in the WSDL
1857
-	* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1858
-	* @access public
1859
-	*/
1860
-	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1861
-		if ($use == 'encoded' && $encodingStyle == '') {
1862
-			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1863
-		}
1846
+    /**
1847
+     * register an operation with the server
1848
+     *
1849
+     * @param string $name operation (method) name
1850
+     * @param array $in assoc array of input values: key = param name, value = param type
1851
+     * @param array $out assoc array of output values: key = param name, value = param type
1852
+     * @param string $namespace optional The namespace for the operation
1853
+     * @param string $soapaction optional The soapaction for the operation
1854
+     * @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
1855
+     * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now)
1856
+     * @param string $documentation optional The description to include in the WSDL
1857
+     * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1858
+     * @access public
1859
+     */
1860
+    function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1861
+        if ($use == 'encoded' && $encodingStyle == '') {
1862
+            $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1863
+        }
1864 1864
 
1865
-		if ($style == 'document') {
1866
-			$elements = array();
1867
-			foreach ($in as $n => $t) {
1868
-				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1869
-			}
1870
-			$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1871
-			$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1872
-			$in = array('parameters' => 'tns:' . $name . '^');
1865
+        if ($style == 'document') {
1866
+            $elements = array();
1867
+            foreach ($in as $n => $t) {
1868
+                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1869
+            }
1870
+            $this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1871
+            $this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1872
+            $in = array('parameters' => 'tns:' . $name . '^');
1873 1873
 
1874
-			$elements = array();
1875
-			foreach ($out as $n => $t) {
1876
-				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1877
-			}
1878
-			$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1879
-			$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1880
-			$out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1881
-		}
1874
+            $elements = array();
1875
+            foreach ($out as $n => $t) {
1876
+                $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1877
+            }
1878
+            $this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1879
+            $this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1880
+            $out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1881
+        }
1882 1882
 
1883
-		// get binding
1884
-		$this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1885
-		array(
1886
-		'name' => $name,
1887
-		'binding' => $this->serviceName . 'Binding',
1888
-		'endpoint' => $this->endpoint,
1889
-		'soapAction' => $soapaction,
1890
-		'style' => $style,
1891
-		'input' => array(
1892
-			'use' => $use,
1893
-			'namespace' => $namespace,
1894
-			'encodingStyle' => $encodingStyle,
1895
-			'message' => $name . 'Request',
1896
-			'parts' => $in),
1897
-		'output' => array(
1898
-			'use' => $use,
1899
-			'namespace' => $namespace,
1900
-			'encodingStyle' => $encodingStyle,
1901
-			'message' => $name . 'Response',
1902
-			'parts' => $out),
1903
-		'namespace' => $namespace,
1904
-		'transport' => 'http://schemas.xmlsoap.org/soap/http',
1905
-		'documentation' => $documentation);
1906
-		// add portTypes
1907
-		// add messages
1908
-		if($in)
1909
-		{
1910
-			foreach($in as $pName => $pType)
1911
-			{
1912
-				if(strpos($pType,':')) {
1913
-					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1914
-				}
1915
-				$this->messages[$name.'Request'][$pName] = $pType;
1916
-			}
1917
-		} else {
1883
+        // get binding
1884
+        $this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1885
+        array(
1886
+        'name' => $name,
1887
+        'binding' => $this->serviceName . 'Binding',
1888
+        'endpoint' => $this->endpoint,
1889
+        'soapAction' => $soapaction,
1890
+        'style' => $style,
1891
+        'input' => array(
1892
+            'use' => $use,
1893
+            'namespace' => $namespace,
1894
+            'encodingStyle' => $encodingStyle,
1895
+            'message' => $name . 'Request',
1896
+            'parts' => $in),
1897
+        'output' => array(
1898
+            'use' => $use,
1899
+            'namespace' => $namespace,
1900
+            'encodingStyle' => $encodingStyle,
1901
+            'message' => $name . 'Response',
1902
+            'parts' => $out),
1903
+        'namespace' => $namespace,
1904
+        'transport' => 'http://schemas.xmlsoap.org/soap/http',
1905
+        'documentation' => $documentation);
1906
+        // add portTypes
1907
+        // add messages
1908
+        if($in)
1909
+        {
1910
+            foreach($in as $pName => $pType)
1911
+            {
1912
+                if(strpos($pType,':')) {
1913
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1914
+                }
1915
+                $this->messages[$name.'Request'][$pName] = $pType;
1916
+            }
1917
+        } else {
1918 1918
             $this->messages[$name.'Request']= '0';
1919 1919
         }
1920
-		if($out)
1921
-		{
1922
-			foreach($out as $pName => $pType)
1923
-			{
1924
-				if(strpos($pType,':')) {
1925
-					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1926
-				}
1927
-				$this->messages[$name.'Response'][$pName] = $pType;
1928
-			}
1929
-		} else {
1920
+        if($out)
1921
+        {
1922
+            foreach($out as $pName => $pType)
1923
+            {
1924
+                if(strpos($pType,':')) {
1925
+                    $pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1926
+                }
1927
+                $this->messages[$name.'Response'][$pName] = $pType;
1928
+            }
1929
+        } else {
1930 1930
             $this->messages[$name.'Response']= '0';
1931 1931
         }
1932
-		return true;
1933
-	}
1932
+        return true;
1933
+    }
1934 1934
 }
1935 1935
 
1936 1936
 ?>
Please login to merge, or discard this patch.
Spacing   +205 added lines, -207 removed lines patch added patch discarded remove patch
@@ -45,13 +45,13 @@  discard block
 block discarded – undo
45 45
 	var $proxypassword = '';
46 46
 	var $timeout = 0;
47 47
 	var $response_timeout = 30;
48
-	var $curl_options = array();	// User-specified cURL options
49
-	var $use_curl = false;			// whether to always try to use cURL
48
+	var $curl_options = array(); // User-specified cURL options
49
+	var $use_curl = false; // whether to always try to use cURL
50 50
 	// for HTTP authentication
51
-	var $username = '';				// Username for HTTP authentication
52
-	var $password = '';				// Password for HTTP authentication
53
-	var $authtype = '';				// Type of HTTP authentication
54
-	var $certRequest = array();		// Certificate for HTTP SSL authentication
51
+	var $username = ''; // Username for HTTP authentication
52
+	var $password = ''; // Password for HTTP authentication
53
+	var $authtype = ''; // Type of HTTP authentication
54
+	var $certRequest = array(); // Certificate for HTTP SSL authentication
55 55
 
56 56
     /**
57 57
      * constructor
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	 * @param boolean $use_curl try to use cURL
68 68
      * @access public
69 69
      */
70
-    function __construct($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){
70
+    function __construct($wsdl = '', $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $curl_options = null, $use_curl = false) {
71 71
 		parent::__construct();
72 72
 		$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
73 73
         $this->proxyhost = $proxyhost;
@@ -103,19 +103,19 @@  discard block
 block discarded – undo
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
 		                		$this->schemas[$ns]->imports[$ns2][$ii]['loaded'] = true;
111 111
 		                		$url = $list2[$ii]['location'];
112 112
 								if ($url != '') {
113 113
 									$urlparts = parse_url($url);
114 114
 									if (!isset($urlparts['host'])) {
115
-										$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' .$wsdlparts['port'] : '') .
116
-												substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
115
+										$url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : '').
116
+												substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path'];
117 117
 									}
118
-									if (! in_array($url, $imported_urls)) {
118
+									if (!in_array($url, $imported_urls)) {
119 119
 					                	$this->parseWSDL($url);
120 120
 				                		$imported++;
121 121
 				                		$imported_urls[] = $url;
@@ -129,19 +129,19 @@  discard block
 block discarded – undo
129 129
     			}
130 130
     		}
131 131
     		// WSDL imports
132
-			$wsdlparts = parse_url($this->wsdl);	// this is bogusly simple!
132
+			$wsdlparts = parse_url($this->wsdl); // this is bogusly simple!
133 133
             foreach ($this->import as $ns => $list) {
134 134
                 for ($ii = 0; $ii < count($list); $ii++) {
135
-                	if (! $list[$ii]['loaded']) {
135
+                	if (!$list[$ii]['loaded']) {
136 136
                 		$this->import[$ns][$ii]['loaded'] = true;
137 137
                 		$url = $list[$ii]['location'];
138 138
 						if ($url != '') {
139 139
 							$urlparts = parse_url($url);
140 140
 							if (!isset($urlparts['host'])) {
141
-								$url = $wsdlparts['scheme'] . '://' . $wsdlparts['host'] . (isset($wsdlparts['port']) ? ':' . $wsdlparts['port'] : '') .
142
-										substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path'];
141
+								$url = $wsdlparts['scheme'].'://'.$wsdlparts['host'].(isset($wsdlparts['port']) ? ':'.$wsdlparts['port'] : '').
142
+										substr($wsdlparts['path'], 0, strrpos($wsdlparts['path'], '/') + 1).$urlparts['path'];
143 143
 							}
144
-							if (! in_array($url, $imported_urls)) {
144
+							if (!in_array($url, $imported_urls)) {
145 145
 			                	$this->parseWSDL($url);
146 146
 		                		$imported++;
147 147
 		                		$imported_urls[] = $url;
@@ -154,30 +154,28 @@  discard block
 block discarded – undo
154 154
             }
155 155
 		}
156 156
         // add new data to operation data
157
-        foreach($this->bindings as $binding => $bindingData) {
157
+        foreach ($this->bindings as $binding => $bindingData) {
158 158
             if (isset($bindingData['operations']) && is_array($bindingData['operations'])) {
159
-                foreach($bindingData['operations'] as $operation => $data) {
160
-                    $this->debug('post-parse data gathering for ' . $operation);
159
+                foreach ($bindingData['operations'] as $operation => $data) {
160
+                    $this->debug('post-parse data gathering for '.$operation);
161 161
                     $this->bindings[$binding]['operations'][$operation]['input'] =
162 162
 						isset($this->bindings[$binding]['operations'][$operation]['input']) ?
163
-						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) :
164
-						$this->portTypes[ $bindingData['portType'] ][$operation]['input'];
163
+						array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[$bindingData['portType']][$operation]['input']) : $this->portTypes[$bindingData['portType']][$operation]['input'];
165 164
                     $this->bindings[$binding]['operations'][$operation]['output'] =
166 165
 						isset($this->bindings[$binding]['operations'][$operation]['output']) ?
167
-						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) :
168
-						$this->portTypes[ $bindingData['portType'] ][$operation]['output'];
169
-                    if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){
170
-						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ];
166
+						array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[$bindingData['portType']][$operation]['output']) : $this->portTypes[$bindingData['portType']][$operation]['output'];
167
+                    if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']])) {
168
+						$this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['input']['message']];
171 169
 					}
172
-					if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){
173
-                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ];
170
+					if (isset($this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']])) {
171
+                   		$this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[$this->bindings[$binding]['operations'][$operation]['output']['message']];
174 172
                     }
175 173
                     // Set operation style if necessary, but do not override one already provided
176 174
 					if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) {
177 175
                         $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style'];
178 176
                     }
179 177
                     $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : '';
180
-                    $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : '';
178
+                    $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[$bindingData['portType']][$operation]['documentation']) ? $this->portTypes[$bindingData['portType']][$operation]['documentation'] : '';
181 179
                     $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : '';
182 180
                 }
183 181
             }
@@ -203,13 +201,13 @@  discard block
 block discarded – undo
203 201
         $wsdl_props = parse_url($wsdl);
204 202
 
205 203
         if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) {
206
-            $this->debug('getting WSDL http(s) URL ' . $wsdl);
204
+            $this->debug('getting WSDL http(s) URL '.$wsdl);
207 205
         	// get wsdl
208 206
 	        $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl);
209 207
 			$tr->request_method = 'GET';
210 208
 			$tr->useSOAPAction = false;
211
-			if($this->proxyhost && $this->proxyport){
212
-				$tr->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword);
209
+			if ($this->proxyhost && $this->proxyport) {
210
+				$tr->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword);
213 211
 			}
214 212
 			if ($this->authtype != '') {
215 213
 				$tr->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest);
@@ -220,8 +218,8 @@  discard block
 block discarded – undo
220 218
 			//$this->debug("WSDL response\n" . $tr->incoming_payload);
221 219
 			$this->appendDebug($tr->getDebug());
222 220
 			// catch errors
223
-			if($err = $tr->getError() ){
224
-				$errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
221
+			if ($err = $tr->getError()) {
222
+				$errstr = 'Getting '.$wsdl.' - HTTP ERROR: '.$err;
225 223
 				$this->debug($errstr);
226 224
 	            $this->setError($errstr);
227 225
 				unset($tr);
@@ -232,11 +230,11 @@  discard block
 block discarded – undo
232 230
         } else {
233 231
             // $wsdl is not http(s), so treat it as a file URL or plain file path
234 232
         	if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) {
235
-        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path'];
233
+        		$path = isset($wsdl_props['host']) ? ($wsdl_props['host'].':'.$wsdl_props['path']) : $wsdl_props['path'];
236 234
         	} else {
237 235
         		$path = $wsdl;
238 236
         	}
239
-            $this->debug('getting WSDL file ' . $path);
237
+            $this->debug('getting WSDL file '.$path);
240 238
             if ($fp = @fopen($path, 'r')) {
241 239
                 $wsdl_string = '';
242 240
                 while ($data = fread($fp, 32768)) {
@@ -272,7 +270,7 @@  discard block
 block discarded – undo
272 270
                 xml_error_string(xml_get_error_code($this->parser))
273 271
                 );
274 272
             $this->debug($errstr);
275
-			$this->debug("XML payload:\n" . $wsdl_string);
273
+			$this->debug("XML payload:\n".$wsdl_string);
276 274
             $this->setError($errstr);
277 275
             return false;
278 276
         }
@@ -280,7 +278,7 @@  discard block
 block discarded – undo
280 278
         xml_parser_free($this->parser);
281 279
         $this->debug('Parsing WSDL done');
282 280
 		// catch wsdl parse errors
283
-		if($this->getError()){
281
+		if ($this->getError()) {
284 282
 			return false;
285 283
 		}
286 284
         return true;
@@ -318,21 +316,21 @@  discard block
 block discarded – undo
318 316
             // process attributes
319 317
             if (count($attrs) > 0) {
320 318
 				// register namespace declarations
321
-                foreach($attrs as $k => $v) {
322
-                    if (preg_match('/^xmlns/',$k)) {
319
+                foreach ($attrs as $k => $v) {
320
+                    if (preg_match('/^xmlns/', $k)) {
323 321
                         if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
324 322
                             $this->namespaces[$ns_prefix] = $v;
325 323
                         } else {
326
-                            $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v;
324
+                            $this->namespaces['ns'.(count($this->namespaces) + 1)] = $v;
327 325
                         }
328 326
                         if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') {
329 327
                             $this->XMLSchemaVersion = $v;
330
-                            $this->namespaces['xsi'] = $v . '-instance';
328
+                            $this->namespaces['xsi'] = $v.'-instance';
331 329
                         }
332 330
                     }
333 331
                 }
334 332
                 // expand each attribute prefix to its namespace
335
-                foreach($attrs as $k => $v) {
333
+                foreach ($attrs as $k => $v) {
336 334
                     $k = strpos($k, ':') ? $this->expandQname($k) : $k;
337 335
                     if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') {
338 336
                         $v = strpos($v, ':') ? $this->expandQname($v) : $v;
@@ -358,12 +356,12 @@  discard block
 block discarded – undo
358 356
                 case 'message':
359 357
                     if ($name == 'part') {
360 358
 			            if (isset($attrs['type'])) {
361
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs));
359
+		                    $this->debug("msg ".$this->currentMessage.": found part (with type) $attrs[name]: ".implode(',', $attrs));
362 360
 		                    $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type'];
363 361
             			}
364 362
 			            if (isset($attrs['element'])) {
365
-		                    $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs));
366
-			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^';
363
+		                    $this->debug("msg ".$this->currentMessage.": found part (with element) $attrs[name]: ".implode(',', $attrs));
364
+			                $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'].'^';
367 365
 			            }
368 366
         			}
369 367
         			break;
@@ -432,15 +430,15 @@  discard block
 block discarded – undo
432 430
 					switch ($name) {
433 431
 					    case 'port':
434 432
 					        $this->currentPort = $attrs['name'];
435
-					        $this->debug('current port: ' . $this->currentPort);
433
+					        $this->debug('current port: '.$this->currentPort);
436 434
 					        $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']);
437 435
 
438 436
 					        break;
439 437
 					    case 'address':
440 438
 					        $this->ports[$this->currentPort]['location'] = $attrs['location'];
441 439
 					        $this->ports[$this->currentPort]['bindingType'] = $namespace;
442
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace;
443
-					        $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location'];
440
+					        $this->bindings[$this->ports[$this->currentPort]['binding']]['bindingType'] = $namespace;
441
+					        $this->bindings[$this->ports[$this->currentPort]['binding']]['endpoint'] = $attrs['location'];
444 442
 					        break;
445 443
 					}
446 444
 					break;
@@ -450,13 +448,13 @@  discard block
 block discarded – undo
450 448
 			case 'import':
451 449
 			    if (isset($attrs['location'])) {
452 450
                     $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false);
453
-                    $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')');
451
+                    $this->debug('parsing import '.$attrs['namespace'].' - '.$attrs['location'].' ('.count($this->import[$attrs['namespace']]).')');
454 452
 				} else {
455 453
                     $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
456
-					if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
457
-						$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
454
+					if (!$this->getPrefixFromNamespace($attrs['namespace'])) {
455
+						$this->namespaces['ns'.(count($this->namespaces) + 1)] = $attrs['namespace'];
458 456
 					}
459
-                    $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')');
457
+                    $this->debug('parsing import '.$attrs['namespace'].' - [no location] ('.count($this->import[$attrs['namespace']]).')');
460 458
 				}
461 459
 				break;
462 460
 			//wait for schema
@@ -483,13 +481,13 @@  discard block
 block discarded – undo
483 481
 					}
484 482
 					$this->status = 'binding';
485 483
 					$this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']);
486
-					$this->debug("current binding: $this->currentBinding of portType: " . $attrs['type']);
484
+					$this->debug("current binding: $this->currentBinding of portType: ".$attrs['type']);
487 485
 				}
488 486
 				break;
489 487
 			case 'service':
490 488
 				$this->serviceName = $attrs['name'];
491 489
 				$this->status = 'service';
492
-				$this->debug('current service: ' . $this->serviceName);
490
+				$this->debug('current service: '.$this->serviceName);
493 491
 				break;
494 492
 			case 'definitions':
495 493
 				foreach ($attrs as $name => $value) {
@@ -507,7 +505,7 @@  discard block
 block discarded – undo
507 505
 	* @param string $name element name
508 506
 	* @access private
509 507
 	*/
510
-	function end_element($parser, $name){
508
+	function end_element($parser, $name) {
511 509
 		// unset schema status
512 510
 		if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
513 511
 			$this->status = "";
@@ -592,8 +590,8 @@  discard block
 block discarded – undo
592 590
 		}
593 591
 		$this->debug("getOperations for port '$portName' bindingType $bindingType");
594 592
 		// loop thru ports
595
-		foreach($this->ports as $port => $portData) {
596
-			$this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
593
+		foreach ($this->ports as $port => $portData) {
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) {
@@ -601,8 +599,8 @@  discard block
 block discarded – undo
601 599
 					//$this->debug("port data: " . $this->varDump($portData));
602 600
 					//$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
603 601
 					// merge bindings
604
-					if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
605
-						$ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
602
+					if (isset($this->bindings[$portData['binding']]['operations'])) {
603
+						$ops = array_merge($ops, $this->bindings[$portData['binding']]['operations']);
606 604
 					}
607 605
 				}
608 606
 			}
@@ -629,15 +627,15 @@  discard block
 block discarded – undo
629 627
 			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
630 628
 		}
631 629
 		// loop thru ports
632
-		foreach($this->ports as $port => $portData) {
630
+		foreach ($this->ports as $port => $portData) {
633 631
 			// binding type of port matches parameter
634 632
 			if ($portData['bindingType'] == $bindingType) {
635 633
 				// get binding
636 634
 				//foreach($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
637
-				foreach(array_keys($this->bindings[ $portData['binding'] ]['operations']) as $bOperation) {
635
+				foreach (array_keys($this->bindings[$portData['binding']]['operations']) as $bOperation) {
638 636
 					// note that we could/should also check the namespace here
639 637
 					if ($operation == $bOperation) {
640
-						$opData = $this->bindings[ $portData['binding'] ]['operations'][$operation];
638
+						$opData = $this->bindings[$portData['binding']]['operations'][$operation];
641 639
 					    return $opData;
642 640
 					}
643 641
 				}
@@ -660,11 +658,11 @@  discard block
 block discarded – undo
660 658
 			$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
661 659
 		}
662 660
 		// loop thru ports
663
-		foreach($this->ports as $port => $portData) {
661
+		foreach ($this->ports as $port => $portData) {
664 662
 			// binding type of port matches parameter
665 663
 			if ($portData['bindingType'] == $bindingType) {
666 664
 				// loop through operations for the binding
667
-				foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) {
665
+				foreach ($this->bindings[$portData['binding']]['operations'] as $bOperation => $opData) {
668 666
 					if ($opData['soapAction'] == $soapAction) {
669 667
 					    return $opData;
670 668
 					}
@@ -693,7 +691,7 @@  discard block
 block discarded – undo
693 691
     */
694 692
 	function getTypeDef($type, $ns) {
695 693
 		$this->debug("in getTypeDef: type=$type, ns=$ns");
696
-		if ((! $ns) && isset($this->namespaces['tns'])) {
694
+		if ((!$ns) && isset($this->namespaces['tns'])) {
697 695
 			$ns = $this->namespaces['tns'];
698 696
 			$this->debug("in getTypeDef: type namespace forced to $ns");
699 697
 		}
@@ -751,7 +749,7 @@  discard block
 block discarded – undo
751 749
     *
752 750
     * @access private
753 751
     */
754
-    function webDescription(){
752
+    function webDescription() {
755 753
     	global $HTTP_SERVER_VARS;
756 754
 
757 755
 		if (isset($_SERVER)) {
@@ -845,19 +843,19 @@  discard block
 block discarded – undo
845 843
 				<p>View the <a href="'.$PHP_SELF.'?wsdl">WSDL</a> for the service.
846 844
 				Click on an operation name to view it&apos;s details.</p>
847 845
 				<ul>';
848
-				foreach($this->getOperations() as $op => $data){
846
+				foreach ($this->getOperations() as $op => $data) {
849 847
 				    $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>";
850 848
 				    // create hidden div
851 849
 				    $b .= "<div id='$op' class='hidden'>
852 850
 				    <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>";
853
-				    foreach($data as $donnie => $marie){ // loop through opdata
854
-						if($donnie == 'input' || $donnie == 'output'){ // show input/output data
851
+				    foreach ($data as $donnie => $marie) { // loop through opdata
852
+						if ($donnie == 'input' || $donnie == 'output') { // show input/output data
855 853
 						    $b .= "<font color='white'>".ucfirst($donnie).':</font><br>';
856
-						    foreach($marie as $captain => $tenille){ // loop through data
857
-								if($captain == 'parts'){ // loop thru parts
854
+						    foreach ($marie as $captain => $tenille) { // loop through data
855
+								if ($captain == 'parts') { // loop thru parts
858 856
 								    $b .= "&nbsp;&nbsp;$captain:<br>";
859 857
 					                //if(is_array($tenille)){
860
-								    	foreach($tenille as $joanie => $chachi){
858
+								    	foreach ($tenille as $joanie => $chachi) {
861 859
 											$b .= "&nbsp;&nbsp;&nbsp;&nbsp;$joanie: $chachi<br>";
862 860
 								    	}
863 861
 					        		//}
@@ -889,31 +887,31 @@  discard block
 block discarded – undo
889 887
 	{
890 888
 		$xml = '<?xml version="1.0" encoding="ISO-8859-1"?>';
891 889
 		$xml .= "\n<definitions";
892
-		foreach($this->namespaces as $k => $v) {
890
+		foreach ($this->namespaces as $k => $v) {
893 891
 			$xml .= " xmlns:$k=\"$v\"";
894 892
 		}
895 893
 		// 10.9.02 - add poulter fix for wsdl and tns declarations
896 894
 		if (isset($this->namespaces['wsdl'])) {
897
-			$xml .= " xmlns=\"" . $this->namespaces['wsdl'] . "\"";
895
+			$xml .= " xmlns=\"".$this->namespaces['wsdl']."\"";
898 896
 		}
899 897
 		if (isset($this->namespaces['tns'])) {
900
-			$xml .= " targetNamespace=\"" . $this->namespaces['tns'] . "\"";
898
+			$xml .= " targetNamespace=\"".$this->namespaces['tns']."\"";
901 899
 		}
902 900
 		$xml .= '>';
903 901
 		// imports
904 902
 		if (sizeof($this->import) > 0) {
905
-			foreach($this->import as $ns => $list) {
903
+			foreach ($this->import as $ns => $list) {
906 904
 				foreach ($list as $ii) {
907 905
 					if ($ii['location'] != '') {
908
-						$xml .= '<import location="' . $ii['location'] . '" namespace="' . $ns . '" />';
906
+						$xml .= '<import location="'.$ii['location'].'" namespace="'.$ns.'" />';
909 907
 					} else {
910
-						$xml .= '<import namespace="' . $ns . '" />';
908
+						$xml .= '<import namespace="'.$ns.'" />';
911 909
 					}
912 910
 				}
913 911
 			}
914 912
 		}
915 913
 		// types
916
-		if (count($this->schemas)>=1) {
914
+		if (count($this->schemas) >= 1) {
917 915
 			$xml .= "\n<types>\n";
918 916
 			foreach ($this->schemas as $ns => $list) {
919 917
 				foreach ($list as $xs) {
@@ -924,10 +922,10 @@  discard block
 block discarded – undo
924 922
 		}
925 923
 		// messages
926 924
 		if (count($this->messages) >= 1) {
927
-			foreach($this->messages as $msgName => $msgParts) {
928
-				$xml .= "\n<message name=\"" . $msgName . '">';
929
-				if(is_array($msgParts)){
930
-					foreach($msgParts as $partName => $partType) {
925
+			foreach ($this->messages as $msgName => $msgParts) {
926
+				$xml .= "\n<message name=\"".$msgName.'">';
927
+				if (is_array($msgParts)) {
928
+					foreach ($msgParts as $partName => $partType) {
931 929
 						// print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>';
932 930
 						if (strpos($partType, ':')) {
933 931
 						    $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType));
@@ -935,7 +933,7 @@  discard block
 block discarded – undo
935 933
 						    // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>';
936 934
 						    $typePrefix = 'xsd';
937 935
 						} else {
938
-						    foreach($this->typemap as $ns => $types) {
936
+						    foreach ($this->typemap as $ns => $types) {
939 937
 						        if (isset($types[$partType])) {
940 938
 						            $typePrefix = $this->getPrefixFromNamespace($ns);
941 939
 						        }
@@ -955,7 +953,7 @@  discard block
 block discarded – undo
955 953
 						} else {
956 954
 							$elementortype = 'type';
957 955
 						}
958
-						$xml .= "\n" . '  <part name="' . $partName . '" ' . $elementortype . '="' . $typePrefix . ':' . $localPart . '" />';
956
+						$xml .= "\n".'  <part name="'.$partName.'" '.$elementortype.'="'.$typePrefix.':'.$localPart.'" />';
959 957
 					}
960 958
 				}
961 959
 				$xml .= '</message>';
@@ -965,54 +963,54 @@  discard block
 block discarded – undo
965 963
 		if (count($this->bindings) >= 1) {
966 964
 			$binding_xml = '';
967 965
 			$portType_xml = '';
968
-			foreach($this->bindings as $bindingName => $attrs) {
969
-				$binding_xml .= "\n<binding name=\"" . $bindingName . '" type="tns:' . $attrs['portType'] . '">';
970
-				$binding_xml .= "\n" . '  <soap:binding style="' . $attrs['style'] . '" transport="' . $attrs['transport'] . '"/>';
971
-				$portType_xml .= "\n<portType name=\"" . $attrs['portType'] . '">';
972
-				foreach($attrs['operations'] as $opName => $opParts) {
973
-					$binding_xml .= "\n" . '  <operation name="' . $opName . '">';
974
-					$binding_xml .= "\n" . '    <soap:operation soapAction="' . $opParts['soapAction'] . '" style="'. $opParts['style'] . '"/>';
966
+			foreach ($this->bindings as $bindingName => $attrs) {
967
+				$binding_xml .= "\n<binding name=\"".$bindingName.'" type="tns:'.$attrs['portType'].'">';
968
+				$binding_xml .= "\n".'  <soap:binding style="'.$attrs['style'].'" transport="'.$attrs['transport'].'"/>';
969
+				$portType_xml .= "\n<portType name=\"".$attrs['portType'].'">';
970
+				foreach ($attrs['operations'] as $opName => $opParts) {
971
+					$binding_xml .= "\n".'  <operation name="'.$opName.'">';
972
+					$binding_xml .= "\n".'    <soap:operation soapAction="'.$opParts['soapAction'].'" style="'.$opParts['style'].'"/>';
975 973
 					if (isset($opParts['input']['encodingStyle']) && $opParts['input']['encodingStyle'] != '') {
976
-						$enc_style = ' encodingStyle="' . $opParts['input']['encodingStyle'] . '"';
974
+						$enc_style = ' encodingStyle="'.$opParts['input']['encodingStyle'].'"';
977 975
 					} else {
978 976
 						$enc_style = '';
979 977
 					}
980
-					$binding_xml .= "\n" . '    <input><soap:body use="' . $opParts['input']['use'] . '" namespace="' . $opParts['input']['namespace'] . '"' . $enc_style . '/></input>';
978
+					$binding_xml .= "\n".'    <input><soap:body use="'.$opParts['input']['use'].'" namespace="'.$opParts['input']['namespace'].'"'.$enc_style.'/></input>';
981 979
 					if (isset($opParts['output']['encodingStyle']) && $opParts['output']['encodingStyle'] != '') {
982
-						$enc_style = ' encodingStyle="' . $opParts['output']['encodingStyle'] . '"';
980
+						$enc_style = ' encodingStyle="'.$opParts['output']['encodingStyle'].'"';
983 981
 					} else {
984 982
 						$enc_style = '';
985 983
 					}
986
-					$binding_xml .= "\n" . '    <output><soap:body use="' . $opParts['output']['use'] . '" namespace="' . $opParts['output']['namespace'] . '"' . $enc_style . '/></output>';
987
-					$binding_xml .= "\n" . '  </operation>';
988
-					$portType_xml .= "\n" . '  <operation name="' . $opParts['name'] . '"';
984
+					$binding_xml .= "\n".'    <output><soap:body use="'.$opParts['output']['use'].'" namespace="'.$opParts['output']['namespace'].'"'.$enc_style.'/></output>';
985
+					$binding_xml .= "\n".'  </operation>';
986
+					$portType_xml .= "\n".'  <operation name="'.$opParts['name'].'"';
989 987
 					if (isset($opParts['parameterOrder'])) {
990
-					    $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"';
988
+					    $portType_xml .= ' parameterOrder="'.$opParts['parameterOrder'].'"';
991 989
 					}
992 990
 					$portType_xml .= '>';
993
-					if(isset($opParts['documentation']) && $opParts['documentation'] != '') {
994
-						$portType_xml .= "\n" . '    <documentation>' . htmlspecialchars($opParts['documentation']) . '</documentation>';
991
+					if (isset($opParts['documentation']) && $opParts['documentation'] != '') {
992
+						$portType_xml .= "\n".'    <documentation>'.htmlspecialchars($opParts['documentation']).'</documentation>';
995 993
 					}
996
-					$portType_xml .= "\n" . '    <input message="tns:' . $opParts['input']['message'] . '"/>';
997
-					$portType_xml .= "\n" . '    <output message="tns:' . $opParts['output']['message'] . '"/>';
998
-					$portType_xml .= "\n" . '  </operation>';
994
+					$portType_xml .= "\n".'    <input message="tns:'.$opParts['input']['message'].'"/>';
995
+					$portType_xml .= "\n".'    <output message="tns:'.$opParts['output']['message'].'"/>';
996
+					$portType_xml .= "\n".'  </operation>';
999 997
 				}
1000
-				$portType_xml .= "\n" . '</portType>';
1001
-				$binding_xml .= "\n" . '</binding>';
998
+				$portType_xml .= "\n".'</portType>';
999
+				$binding_xml .= "\n".'</binding>';
1002 1000
 			}
1003
-			$xml .= $portType_xml . $binding_xml;
1001
+			$xml .= $portType_xml.$binding_xml;
1004 1002
 		}
1005 1003
 		// services
1006
-		$xml .= "\n<service name=\"" . $this->serviceName . '">';
1004
+		$xml .= "\n<service name=\"".$this->serviceName.'">';
1007 1005
 		if (count($this->ports) >= 1) {
1008
-			foreach($this->ports as $pName => $attrs) {
1009
-				$xml .= "\n" . '  <port name="' . $pName . '" binding="tns:' . $attrs['binding'] . '">';
1010
-				$xml .= "\n" . '    <soap:address location="' . $attrs['location'] . ($debug ? '?debug=1' : '') . '"/>';
1011
-				$xml .= "\n" . '  </port>';
1006
+			foreach ($this->ports as $pName => $attrs) {
1007
+				$xml .= "\n".'  <port name="'.$pName.'" binding="tns:'.$attrs['binding'].'">';
1008
+				$xml .= "\n".'    <soap:address location="'.$attrs['location'].($debug ? '?debug=1' : '').'"/>';
1009
+				$xml .= "\n".'  </port>';
1012 1010
 			}
1013 1011
 		}
1014
-		$xml .= "\n" . '</service>';
1015
-		return $xml . "\n</definitions>";
1012
+		$xml .= "\n".'</service>';
1013
+		return $xml."\n</definitions>";
1016 1014
 	}
1017 1015
 
1018 1016
 	/**
@@ -1109,7 +1107,7 @@  discard block
 block discarded – undo
1109 1107
 	 */
1110 1108
 	function serializeRPCParameters($operation, $direction, $parameters, $bindingType = 'soap') {
1111 1109
 		$this->debug("in serializeRPCParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion, bindingType=$bindingType");
1112
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1110
+		$this->appendDebug('parameters='.$this->varDump($parameters));
1113 1111
 
1114 1112
 		if ($direction != 'input' && $direction != 'output') {
1115 1113
 			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
@@ -1117,8 +1115,8 @@  discard block
 block discarded – undo
1117 1115
 			return false;
1118 1116
 		}
1119 1117
 		if (!$opData = $this->getOperationData($operation, $bindingType)) {
1120
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1121
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation . ' bindingType: ' . $bindingType);
1118
+			$this->debug('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
1119
+			$this->setError('Unable to retrieve WSDL data for operation: '.$operation.' bindingType: '.$bindingType);
1122 1120
 			return false;
1123 1121
 		}
1124 1122
 		$this->debug('in serializeRPCParameters: opData:');
@@ -1126,7 +1124,7 @@  discard block
 block discarded – undo
1126 1124
 
1127 1125
 		// Get encoding style for output and set to current
1128 1126
 		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1129
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1127
+		if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1130 1128
 			$encodingStyle = $opData['output']['encodingStyle'];
1131 1129
 			$enc_style = $encodingStyle;
1132 1130
 		}
@@ -1211,7 +1209,7 @@  discard block
 block discarded – undo
1211 1209
 	function serializeParameters($operation, $direction, $parameters)
1212 1210
 	{
1213 1211
 		$this->debug("in serializeParameters: operation=$operation, direction=$direction, XMLSchemaVersion=$this->XMLSchemaVersion");
1214
-		$this->appendDebug('parameters=' . $this->varDump($parameters));
1212
+		$this->appendDebug('parameters='.$this->varDump($parameters));
1215 1213
 
1216 1214
 		if ($direction != 'input' && $direction != 'output') {
1217 1215
 			$this->debug('The value of the \$direction argument needs to be either "input" or "output"');
@@ -1219,8 +1217,8 @@  discard block
 block discarded – undo
1219 1217
 			return false;
1220 1218
 		}
1221 1219
 		if (!$opData = $this->getOperationData($operation)) {
1222
-			$this->debug('Unable to retrieve WSDL data for operation: ' . $operation);
1223
-			$this->setError('Unable to retrieve WSDL data for operation: ' . $operation);
1220
+			$this->debug('Unable to retrieve WSDL data for operation: '.$operation);
1221
+			$this->setError('Unable to retrieve WSDL data for operation: '.$operation);
1224 1222
 			return false;
1225 1223
 		}
1226 1224
 		$this->debug('opData:');
@@ -1228,7 +1226,7 @@  discard block
 block discarded – undo
1228 1226
 
1229 1227
 		// Get encoding style for output and set to current
1230 1228
 		$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1231
-		if(($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1229
+		if (($direction == 'input') && isset($opData['output']['encodingStyle']) && ($opData['output']['encodingStyle'] != $encodingStyle)) {
1232 1230
 			$encodingStyle = $opData['output']['encodingStyle'];
1233 1231
 			$enc_style = $encodingStyle;
1234 1232
 		}
@@ -1239,14 +1237,14 @@  discard block
 block discarded – undo
1239 1237
 
1240 1238
 			$use = $opData[$direction]['use'];
1241 1239
 			$this->debug("use=$use");
1242
-			$this->debug('got ' . count($opData[$direction]['parts']) . ' part(s)');
1240
+			$this->debug('got '.count($opData[$direction]['parts']).' part(s)');
1243 1241
 			if (is_array($parameters)) {
1244 1242
 				$parametersArrayType = $this->isArraySimpleOrStruct($parameters);
1245
-				$this->debug('have ' . $parametersArrayType . ' parameters');
1246
-				foreach($opData[$direction]['parts'] as $name => $type) {
1243
+				$this->debug('have '.$parametersArrayType.' parameters');
1244
+				foreach ($opData[$direction]['parts'] as $name => $type) {
1247 1245
 					$this->debug('serializing part "'.$name.'" of type "'.$type.'"');
1248 1246
 					// Track encoding style
1249
-					if(isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1247
+					if (isset($opData[$direction]['encodingStyle']) && $encodingStyle != $opData[$direction]['encodingStyle']) {
1250 1248
 						$encodingStyle = $opData[$direction]['encodingStyle'];
1251 1249
 						$enc_style = $encodingStyle;
1252 1250
 					} else {
@@ -1287,18 +1285,18 @@  discard block
 block discarded – undo
1287 1285
 	 * @return string value serialized as an XML string
1288 1286
 	 * @access private
1289 1287
 	 */
1290
-	function serializeType($name, $type, $value, $use='encoded', $encodingStyle=false, $unqualified=false)
1288
+	function serializeType($name, $type, $value, $use = 'encoded', $encodingStyle = false, $unqualified = false)
1291 1289
 	{
1292
-		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=" . ($unqualified ? "unqualified" : "qualified"));
1293
-		$this->appendDebug("value=" . $this->varDump($value));
1294
-		if($use == 'encoded' && $encodingStyle) {
1295
-			$encodingStyle = ' SOAP-ENV:encodingStyle="' . $encodingStyle . '"';
1290
+		$this->debug("in serializeType: name=$name, type=$type, use=$use, encodingStyle=$encodingStyle, unqualified=".($unqualified ? "unqualified" : "qualified"));
1291
+		$this->appendDebug("value=".$this->varDump($value));
1292
+		if ($use == 'encoded' && $encodingStyle) {
1293
+			$encodingStyle = ' SOAP-ENV:encodingStyle="'.$encodingStyle.'"';
1296 1294
 		}
1297 1295
 
1298 1296
 		// if a soapval has been supplied, let its type override the WSDL
1299 1297
     	if (is_object($value) && get_class($value) == 'soapval') {
1300 1298
     		if ($value->type_ns) {
1301
-    			$type = $value->type_ns . ':' . $value->type;
1299
+    			$type = $value->type_ns.':'.$value->type;
1302 1300
 		    	$forceType = true;
1303 1301
 		    	$this->debug("in serializeType: soapval overrides type to $type");
1304 1302
     		} elseif ($value->type) {
@@ -1317,7 +1315,7 @@  discard block
 block discarded – undo
1317 1315
 	    			$value['!'] = $value;
1318 1316
 	    		}
1319 1317
 	    		foreach ($attrs as $n => $v) {
1320
-	    			$value['!' . $n] = $v;
1318
+	    			$value['!'.$n] = $v;
1321 1319
 	    		}
1322 1320
 		    	$this->debug("in serializeType: soapval provides attributes");
1323 1321
 		    }
@@ -1335,7 +1333,7 @@  discard block
 block discarded – undo
1335 1333
 				$this->debug("in serializeType: expanded prefixed type: $uqType, $ns");
1336 1334
 			}
1337 1335
 
1338
-			if($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/'){
1336
+			if ($ns == $this->XMLSchemaVersion || $ns == 'http://schemas.xmlsoap.org/soap/encoding/') {
1339 1337
 				$this->debug('in serializeType: type namespace indicates XML Schema or SOAP Encoding type');
1340 1338
 				if ($unqualified && $use == 'literal') {
1341 1339
 					$elementNS = " xmlns=\"\"";
@@ -1348,7 +1346,7 @@  discard block
 block discarded – undo
1348 1346
 						$xml = "<$name$elementNS/>";
1349 1347
 					} else {
1350 1348
 						// TODO: depends on nillable, which should be checked before calling this method
1351
-						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1349
+						$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>";
1352 1350
 					}
1353 1351
 					$this->debug("in serializeType: returning: $xml");
1354 1352
 					return $xml;
@@ -1358,7 +1356,7 @@  discard block
 block discarded – undo
1358 1356
 					return $this->serialize_val($value, $name, false, false, false, false, $use);
1359 1357
 				}
1360 1358
 		    	if ($uqType == 'boolean') {
1361
-		    		if ((is_string($value) && $value == 'false') || (! $value)) {
1359
+		    		if ((is_string($value) && $value == 'false') || (!$value)) {
1362 1360
 						$value = 'false';
1363 1361
 					} else {
1364 1362
 						$value = 'true';
@@ -1376,12 +1374,12 @@  discard block
 block discarded – undo
1376 1374
 				if (!$this->getTypeDef($uqType, $ns)) {
1377 1375
 					if ($use == 'literal') {
1378 1376
 						if ($forceType) {
1379
-							$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1377
+							$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>";
1380 1378
 						} else {
1381 1379
 							$xml = "<$name$elementNS>$value</$name>";
1382 1380
 						}
1383 1381
 					} else {
1384
-						$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1382
+						$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>";
1385 1383
 					}
1386 1384
 					$this->debug("in serializeType: returning: $xml");
1387 1385
 					return $xml;
@@ -1391,29 +1389,29 @@  discard block
 block discarded – undo
1391 1389
 				$this->debug('in serializeType: appears to be Apache SOAP type');
1392 1390
 				if ($uqType == 'Map') {
1393 1391
 					$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1394
-					if (! $tt_prefix) {
1392
+					if (!$tt_prefix) {
1395 1393
 						$this->debug('in serializeType: Add namespace for Apache SOAP type');
1396
-						$tt_prefix = 'ns' . rand(1000, 9999);
1394
+						$tt_prefix = 'ns'.rand(1000, 9999);
1397 1395
 						$this->namespaces[$tt_prefix] = 'http://xml.apache.org/xml-soap';
1398 1396
 						// force this to be added to usedNamespaces
1399 1397
 						$tt_prefix = $this->getPrefixFromNamespace('http://xml.apache.org/xml-soap');
1400 1398
 					}
1401 1399
 					$contents = '';
1402
-					foreach($value as $k => $v) {
1400
+					foreach ($value as $k => $v) {
1403 1401
 						$this->debug("serializing map element: key $k, value $v");
1404 1402
 						$contents .= '<item>';
1405
-						$contents .= $this->serialize_val($k,'key',false,false,false,false,$use);
1406
-						$contents .= $this->serialize_val($v,'value',false,false,false,false,$use);
1403
+						$contents .= $this->serialize_val($k, 'key', false, false, false, false, $use);
1404
+						$contents .= $this->serialize_val($v, 'value', false, false, false, false, $use);
1407 1405
 						$contents .= '</item>';
1408 1406
 					}
1409 1407
 					if ($use == 'literal') {
1410 1408
 						if ($forceType) {
1411
-							$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\">$contents</$name>";
1409
+							$xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\">$contents</$name>";
1412 1410
 						} else {
1413 1411
 							$xml = "<$name>$contents</$name>";
1414 1412
 						}
1415 1413
 					} else {
1416
-						$xml = "<$name xsi:type=\"" . $tt_prefix . ":$uqType\"$encodingStyle>$contents</$name>";
1414
+						$xml = "<$name xsi:type=\"".$tt_prefix.":$uqType\"$encodingStyle>$contents</$name>";
1417 1415
 					}
1418 1416
 					$this->debug("in serializeType: returning: $xml");
1419 1417
 					return $xml;
@@ -1427,13 +1425,13 @@  discard block
 block discarded – undo
1427 1425
 			$ns = '';
1428 1426
 			$uqType = $type;
1429 1427
 		}
1430
-		if(!$typeDef = $this->getTypeDef($uqType, $ns)){
1428
+		if (!$typeDef = $this->getTypeDef($uqType, $ns)) {
1431 1429
 			$this->setError("$type ($uqType) is not a supported type.");
1432 1430
 			$this->debug("in serializeType: $type ($uqType) is not a supported type.");
1433 1431
 			return false;
1434 1432
 		} else {
1435 1433
 			$this->debug("in serializeType: found typeDef");
1436
-			$this->appendDebug('typeDef=' . $this->varDump($typeDef));
1434
+			$this->appendDebug('typeDef='.$this->varDump($typeDef));
1437 1435
 			if (substr($uqType, -1) == '^') {
1438 1436
 				$uqType = substr($uqType, 0, -1);
1439 1437
 			}
@@ -1444,7 +1442,7 @@  discard block
 block discarded – undo
1444 1442
 			return false;
1445 1443
 		}
1446 1444
 		$phpType = $typeDef['phpType'];
1447
-		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
1445
+		$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: ".(isset($typeDef['arrayType']) ? $typeDef['arrayType'] : ''));
1448 1446
 		// if php type == struct, map value to the <all> element names
1449 1447
 		if ($phpType == 'struct') {
1450 1448
 			if (isset($typeDef['typeClass']) && $typeDef['typeClass'] == 'element') {
@@ -1467,7 +1465,7 @@  discard block
 block discarded – undo
1467 1465
 					// TODO: depends on minOccurs and nillable
1468 1466
 					$xml = "<$elementName$elementNS/>";
1469 1467
 				} else {
1470
-					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
1468
+					$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"/>";
1471 1469
 				}
1472 1470
 				$this->debug("in serializeType: returning: $xml");
1473 1471
 				return $xml;
@@ -1479,12 +1477,12 @@  discard block
 block discarded – undo
1479 1477
 				$elementAttrs = $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
1480 1478
 				if ($use == 'literal') {
1481 1479
 					if ($forceType) {
1482
-						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">";
1480
+						$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">";
1483 1481
 					} else {
1484 1482
 						$xml = "<$elementName$elementNS$elementAttrs>";
1485 1483
 					}
1486 1484
 				} else {
1487
-					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
1485
+					$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>";
1488 1486
 				}
1489 1487
 
1490 1488
 				if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
@@ -1519,13 +1517,13 @@  discard block
 block discarded – undo
1519 1517
 					// TODO: depends on minOccurs
1520 1518
 					$xml = "<$name$elementNS/>";
1521 1519
 				} else {
1522
-					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"" .
1523
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1524
-						":Array\" " .
1525
-						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/') .
1526
-						':arrayType="' .
1527
-						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])) .
1528
-						':' .
1520
+					$xml = "<$name$elementNS xsi:nil=\"true\" xsi:type=\"".
1521
+						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
1522
+						":Array\" ".
1523
+						$this->getPrefixFromNamespace('http://schemas.xmlsoap.org/soap/encoding/').
1524
+						':arrayType="'.
1525
+						$this->getPrefixFromNamespace($this->getPrefix($typeDef['arrayType'])).
1526
+						':'.
1529 1527
 						$this->getLocalPart($typeDef['arrayType'])."[0]\"/>";
1530 1528
 				}
1531 1529
 				$this->debug("in serializeType: returning: $xml");
@@ -1533,8 +1531,8 @@  discard block
 block discarded – undo
1533 1531
 			}
1534 1532
 			if (isset($typeDef['multidimensional'])) {
1535 1533
 				$nv = array();
1536
-				foreach($value as $v) {
1537
-					$cols = ',' . sizeof($v);
1534
+				foreach ($value as $v) {
1535
+					$cols = ','.sizeof($v);
1538 1536
 					$nv = array_merge($nv, $v);
1539 1537
 				}
1540 1538
 				$value = $nv;
@@ -1544,10 +1542,10 @@  discard block
 block discarded – undo
1544 1542
 			if (is_array($value) && sizeof($value) >= 1) {
1545 1543
 				$rows = sizeof($value);
1546 1544
 				$contents = '';
1547
-				foreach($value as $k => $v) {
1545
+				foreach ($value as $k => $v) {
1548 1546
 					//$this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]");
1549 1547
 					//if (strpos($typeDef['arrayType'], ':') ) {
1550
-					if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1548
+					if (!in_array($typeDef['arrayType'], $this->typemap['http://www.w3.org/2001/XMLSchema'])) {
1551 1549
 					    $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use);
1552 1550
 					} else {
1553 1551
 					    $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use);
@@ -1584,12 +1582,12 @@  discard block
 block discarded – undo
1584 1582
 			}
1585 1583
 			if ($use == 'literal') {
1586 1584
 				if ($forceType) {
1587
-					$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\">$value</$name>";
1585
+					$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\">$value</$name>";
1588 1586
 				} else {
1589 1587
 					$xml = "<$name$elementNS>$value</$name>";
1590 1588
 				}
1591 1589
 			} else {
1592
-				$xml = "<$name$elementNS xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>$value</$name>";
1590
+				$xml = "<$name$elementNS xsi:type=\"".$this->getPrefixFromNamespace($ns).":$uqType\"$encodingStyle>$value</$name>";
1593 1591
 			}
1594 1592
 		}
1595 1593
 		$this->debug("in serializeType: returning: $xml");
@@ -1633,22 +1631,22 @@  discard block
 block discarded – undo
1633 1631
 				$xvalue = array();
1634 1632
 			}
1635 1633
 			foreach ($typeDef['attrs'] as $aName => $attrs) {
1636
-				if (isset($xvalue['!' . $aName])) {
1637
-					$xname = '!' . $aName;
1634
+				if (isset($xvalue['!'.$aName])) {
1635
+					$xname = '!'.$aName;
1638 1636
 					$this->debug("value provided for attribute $aName with key $xname");
1639 1637
 				} elseif (isset($xvalue[$aName])) {
1640 1638
 					$xname = $aName;
1641 1639
 					$this->debug("value provided for attribute $aName with key $xname");
1642 1640
 				} elseif (isset($attrs['default'])) {
1643
-					$xname = '!' . $aName;
1641
+					$xname = '!'.$aName;
1644 1642
 					$xvalue[$xname] = $attrs['default'];
1645
-					$this->debug('use default value of ' . $xvalue[$aName] . ' for attribute ' . $aName);
1643
+					$this->debug('use default value of '.$xvalue[$aName].' for attribute '.$aName);
1646 1644
 				} else {
1647 1645
 					$xname = '';
1648 1646
 					$this->debug("no value provided for attribute $aName");
1649 1647
 				}
1650 1648
 				if ($xname) {
1651
-					$xml .=  " $aName=\"" . $this->expandEntities($xvalue[$xname]) . "\"";
1649
+					$xml .= " $aName=\"".$this->expandEntities($xvalue[$xname])."\"";
1652 1650
 				}
1653 1651
 			}
1654 1652
 		} else {
@@ -1669,7 +1667,7 @@  discard block
 block discarded – undo
1669 1667
 	 * @return string value serialized as an XML string
1670 1668
 	 * @access private
1671 1669
 	 */
1672
-	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
1670
+	function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use = 'encoded', $encodingStyle = false) {
1673 1671
 		$this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
1674 1672
 		$xml = '';
1675 1673
 		if (isset($typeDef['extensionBase'])) {
@@ -1696,23 +1694,23 @@  discard block
 block discarded – undo
1696 1694
 				$xvalue = array();
1697 1695
 			}
1698 1696
 			// toggle whether all elements are present - ideally should validate against schema
1699
-			if (count($typeDef['elements']) != count($xvalue)){
1697
+			if (count($typeDef['elements']) != count($xvalue)) {
1700 1698
 				$optionals = true;
1701 1699
 			}
1702 1700
 			foreach ($typeDef['elements'] as $eName => $attrs) {
1703 1701
 				if (!isset($xvalue[$eName])) {
1704 1702
 					if (isset($attrs['default'])) {
1705 1703
 						$xvalue[$eName] = $attrs['default'];
1706
-						$this->debug('use default value of ' . $xvalue[$eName] . ' for element ' . $eName);
1704
+						$this->debug('use default value of '.$xvalue[$eName].' for element '.$eName);
1707 1705
 					}
1708 1706
 				}
1709 1707
 				// if user took advantage of a minOccurs=0, then only serialize named parameters
1710 1708
 				if (isset($optionals)
1711 1709
 				    && (!isset($xvalue[$eName]))
1712
-					&& ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1713
-					){
1710
+					&& ((!isset($attrs['nillable'])) || $attrs['nillable'] != 'true')
1711
+					) {
1714 1712
 					if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') {
1715
-						$this->debug("apparent error: no value provided for element $eName with minOccurs=" . $attrs['minOccurs']);
1713
+						$this->debug("apparent error: no value provided for element $eName with minOccurs=".$attrs['minOccurs']);
1716 1714
 					}
1717 1715
 					// do nothing
1718 1716
 					$this->debug("no value provided for complexType element $eName and element is not nillable, so serialize nothing");
@@ -1777,15 +1775,15 @@  discard block
 block discarded – undo
1777 1775
 	* @see nusoap_xmlschema
1778 1776
 	* @access public
1779 1777
 	*/
1780
-	function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') {
1778
+	function addComplexType($name, $typeClass = 'complexType', $phpType = 'array', $compositor = '', $restrictionBase = '', $elements = array(), $attrs = array(), $arrayType = '') {
1781 1779
 		if (count($elements) > 0) {
1782 1780
 			$eElements = array();
1783
-	    	foreach($elements as $n => $e){
1781
+	    	foreach ($elements as $n => $e) {
1784 1782
 	            // expand each element
1785 1783
 	            $ee = array();
1786 1784
 	            foreach ($e as $k => $v) {
1787
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1788
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1785
+		            $k = strpos($k, ':') ? $this->expandQname($k) : $k;
1786
+		            $v = strpos($v, ':') ? $this->expandQname($v) : $v;
1789 1787
 		            $ee[$k] = $v;
1790 1788
 		    	}
1791 1789
 	    		$eElements[$n] = $ee;
@@ -1794,11 +1792,11 @@  discard block
 block discarded – undo
1794 1792
 		}
1795 1793
 
1796 1794
 		if (count($attrs) > 0) {
1797
-	    	foreach($attrs as $n => $a){
1795
+	    	foreach ($attrs as $n => $a) {
1798 1796
 	            // expand each attribute
1799 1797
 	            foreach ($a as $k => $v) {
1800
-		            $k = strpos($k,':') ? $this->expandQname($k) : $k;
1801
-		            $v = strpos($v,':') ? $this->expandQname($v) : $v;
1798
+		            $k = strpos($k, ':') ? $this->expandQname($k) : $k;
1799
+		            $v = strpos($v, ':') ? $this->expandQname($v) : $v;
1802 1800
 		            $aa[$k] = $v;
1803 1801
 		    	}
1804 1802
 	    		$eAttrs[$n] = $aa;
@@ -1806,11 +1804,11 @@  discard block
 block discarded – undo
1806 1804
 	    	$attrs = $eAttrs;
1807 1805
 		}
1808 1806
 
1809
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1810
-		$arrayType = strpos($arrayType,':') ? $this->expandQname($arrayType) : $arrayType;
1807
+		$restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1808
+		$arrayType = strpos($arrayType, ':') ? $this->expandQname($arrayType) : $arrayType;
1811 1809
 
1812 1810
 		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1813
-		$this->schemas[$typens][0]->addComplexType($name,$typeClass,$phpType,$compositor,$restrictionBase,$elements,$attrs,$arrayType);
1811
+		$this->schemas[$typens][0]->addComplexType($name, $typeClass, $phpType, $compositor, $restrictionBase, $elements, $attrs, $arrayType);
1814 1812
 	}
1815 1813
 
1816 1814
 	/**
@@ -1824,8 +1822,8 @@  discard block
 block discarded – undo
1824 1822
 	* @see nusoap_xmlschema
1825 1823
 	* @access public
1826 1824
 	*/
1827
-	function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) {
1828
-		$restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1825
+	function addSimpleType($name, $restrictionBase = '', $typeClass = 'simpleType', $phpType = 'scalar', $enumeration = array()) {
1826
+		$restrictionBase = strpos($restrictionBase, ':') ? $this->expandQname($restrictionBase) : $restrictionBase;
1829 1827
 
1830 1828
 		$typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns'];
1831 1829
 		$this->schemas[$typens][0]->addSimpleType($name, $restrictionBase, $typeClass, $phpType, $enumeration);
@@ -1857,7 +1855,7 @@  discard block
 block discarded – undo
1857 1855
 	* @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded)
1858 1856
 	* @access public
1859 1857
 	*/
1860
-	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){
1858
+	function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = '') {
1861 1859
 		if ($use == 'encoded' && $encodingStyle == '') {
1862 1860
 			$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
1863 1861
 		}
@@ -1867,24 +1865,24 @@  discard block
 block discarded – undo
1867 1865
 			foreach ($in as $n => $t) {
1868 1866
 				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1869 1867
 			}
1870
-			$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
1871
-			$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
1872
-			$in = array('parameters' => 'tns:' . $name . '^');
1868
+			$this->addComplexType($name.'RequestType', 'complexType', 'struct', 'all', '', $elements);
1869
+			$this->addElement(array('name' => $name, 'type' => $name.'RequestType'));
1870
+			$in = array('parameters' => 'tns:'.$name.'^');
1873 1871
 
1874 1872
 			$elements = array();
1875 1873
 			foreach ($out as $n => $t) {
1876 1874
 				$elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
1877 1875
 			}
1878
-			$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1879
-			$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
1880
-			$out = array('parameters' => 'tns:' . $name . 'Response' . '^');
1876
+			$this->addComplexType($name.'ResponseType', 'complexType', 'struct', 'all', '', $elements);
1877
+			$this->addElement(array('name' => $name.'Response', 'type' => $name.'ResponseType', 'form' => 'qualified'));
1878
+			$out = array('parameters' => 'tns:'.$name.'Response'.'^');
1881 1879
 		}
1882 1880
 
1883 1881
 		// get binding
1884
-		$this->bindings[ $this->serviceName . 'Binding' ]['operations'][$name] =
1882
+		$this->bindings[$this->serviceName.'Binding']['operations'][$name] =
1885 1883
 		array(
1886 1884
 		'name' => $name,
1887
-		'binding' => $this->serviceName . 'Binding',
1885
+		'binding' => $this->serviceName.'Binding',
1888 1886
 		'endpoint' => $this->endpoint,
1889 1887
 		'soapAction' => $soapaction,
1890 1888
 		'style' => $style,
@@ -1892,42 +1890,42 @@  discard block
 block discarded – undo
1892 1890
 			'use' => $use,
1893 1891
 			'namespace' => $namespace,
1894 1892
 			'encodingStyle' => $encodingStyle,
1895
-			'message' => $name . 'Request',
1893
+			'message' => $name.'Request',
1896 1894
 			'parts' => $in),
1897 1895
 		'output' => array(
1898 1896
 			'use' => $use,
1899 1897
 			'namespace' => $namespace,
1900 1898
 			'encodingStyle' => $encodingStyle,
1901
-			'message' => $name . 'Response',
1899
+			'message' => $name.'Response',
1902 1900
 			'parts' => $out),
1903 1901
 		'namespace' => $namespace,
1904 1902
 		'transport' => 'http://schemas.xmlsoap.org/soap/http',
1905 1903
 		'documentation' => $documentation);
1906 1904
 		// add portTypes
1907 1905
 		// add messages
1908
-		if($in)
1906
+		if ($in)
1909 1907
 		{
1910
-			foreach($in as $pName => $pType)
1908
+			foreach ($in as $pName => $pType)
1911 1909
 			{
1912
-				if(strpos($pType,':')) {
1910
+				if (strpos($pType, ':')) {
1913 1911
 					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1914 1912
 				}
1915 1913
 				$this->messages[$name.'Request'][$pName] = $pType;
1916 1914
 			}
1917 1915
 		} else {
1918
-            $this->messages[$name.'Request']= '0';
1916
+            $this->messages[$name.'Request'] = '0';
1919 1917
         }
1920
-		if($out)
1918
+		if ($out)
1921 1919
 		{
1922
-			foreach($out as $pName => $pType)
1920
+			foreach ($out as $pName => $pType)
1923 1921
 			{
1924
-				if(strpos($pType,':')) {
1922
+				if (strpos($pType, ':')) {
1925 1923
 					$pType = $this->getNamespaceFromPrefix($this->getPrefix($pType)).":".$this->getLocalPart($pType);
1926 1924
 				}
1927 1925
 				$this->messages[$name.'Response'][$pName] = $pType;
1928 1926
 			}
1929 1927
 		} else {
1930
-            $this->messages[$name.'Response']= '0';
1928
+            $this->messages[$name.'Response'] = '0';
1931 1929
         }
1932 1930
 		return true;
1933 1931
 	}
Please login to merge, or discard this patch.