@@ -634,7 +634,6 @@ discard block |
||
| 634 | 634 | * @param int $sessionId The session ID |
| 635 | 635 | * @param int $courseId The course ID |
| 636 | 636 | * @param int $exerciseId The quiz ID |
| 637 | - * @param int $answer Answer status (0 = incorrect, 1 = correct, 2 = both) |
|
| 638 | 637 | * @return string HTML array of results formatted for gridJS |
| 639 | 638 | * @author César Perales <[email protected]>, Beeznest Team |
| 640 | 639 | */ |
@@ -1222,6 +1221,7 @@ discard block |
||
| 1222 | 1221 | * @param int Number of items to select |
| 1223 | 1222 | * @param string Column to order on |
| 1224 | 1223 | * @param string Order direction |
| 1224 | + * @param integer $number_of_items |
|
| 1225 | 1225 | * @return array Results |
| 1226 | 1226 | */ |
| 1227 | 1227 | public static function get_course_data_tracking_overview($from, $number_of_items, $column, $direction) |
@@ -1556,6 +1556,7 @@ discard block |
||
| 1556 | 1556 | * @param int Number of items to select |
| 1557 | 1557 | * @param string Column to order on |
| 1558 | 1558 | * @param string Order direction |
| 1559 | + * @param integer $number_of_items |
|
| 1559 | 1560 | * @return array Results |
| 1560 | 1561 | */ |
| 1561 | 1562 | public static function get_session_data_tracking_overview($from, $number_of_items, $column, $direction) |
@@ -1576,7 +1577,6 @@ discard block |
||
| 1576 | 1577 | /** |
| 1577 | 1578 | * Fills in session reporting data |
| 1578 | 1579 | * |
| 1579 | - * @param integer $user_id the id of the user |
|
| 1580 | 1580 | * @param array $url_params additonal url parameters |
| 1581 | 1581 | * @param array $row the row information (the other columns) |
| 1582 | 1582 | * @return string html code |
@@ -2206,6 +2206,7 @@ discard block |
||
| 2206 | 2206 | * @author Patrick Cool <[email protected]>, Ghent University, Belgium |
| 2207 | 2207 | * @version Dokeos 1.8.6 |
| 2208 | 2208 | * @since October 2008 |
| 2209 | + * @param integer $number_of_items |
|
| 2209 | 2210 | */ |
| 2210 | 2211 | public static function get_user_data_tracking_overview($from, $number_of_items, $column, $direction) |
| 2211 | 2212 | { |
@@ -2308,7 +2309,6 @@ discard block |
||
| 2308 | 2309 | /** |
| 2309 | 2310 | * Checks if there are repeted users in a given array |
| 2310 | 2311 | * @param array $usernames list of the usernames in the uploaded file |
| 2311 | - * @param array $user_array['username'] and $user_array['sufix'] where sufix is the number part in a login i.e -> jmontoya2 |
|
| 2312 | 2312 | * @return array with the $usernames array and the $user_array array |
| 2313 | 2313 | * @author Julio Montoya Armas |
| 2314 | 2314 | */ |
@@ -25,7 +25,7 @@ discard block |
||
| 25 | 25 | array('url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=course', 'content' => get_lang('DisplayCourseOverview')), |
| 26 | 26 | array('url' => api_get_path(WEB_CODE_PATH).'tracking/question_course_report.php?view=admin', 'content' => get_lang('LPQuestionListResults')), |
| 27 | 27 | array('url' => api_get_path(WEB_CODE_PATH).'tracking/course_session_report.php?view=admin', 'content' => get_lang('LPExerciseResultsBySession')), |
| 28 | - ['url' => api_get_path(WEB_CODE_PATH) . 'mySpace/admin_view.php?display=accessoverview', 'content' => get_lang('DisplayAccessOverview') . ' (' . get_lang('Beta') . ')'] |
|
| 28 | + ['url' => api_get_path(WEB_CODE_PATH).'mySpace/admin_view.php?display=accessoverview', 'content' => get_lang('DisplayAccessOverview').' ('.get_lang('Beta').')'] |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | 31 | return Display :: actions($actions, null); |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | public static function getTopMenu() |
| 35 | 35 | { |
| 36 | 36 | $menu_items = array(); |
| 37 | - $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'),'',ICON_SIZE_MEDIUM),api_get_path(WEB_CODE_PATH)."auth/my_progress.php" ); |
|
| 37 | + $menu_items[] = Display::url(Display::return_icon('stats.png', get_lang('MyStats'), '', ICON_SIZE_MEDIUM), api_get_path(WEB_CODE_PATH)."auth/my_progress.php"); |
|
| 38 | 38 | $menu_items[] = Display::url(Display::return_icon('teacher.png', get_lang('TeacherInterface'), array(), 32), api_get_path(WEB_CODE_PATH).'mySpace/?view=teacher'); |
| 39 | 39 | $menu_items[] = Display::url(Display::return_icon('star_na.png', get_lang('AdminInterface'), array(), 32), '#'); |
| 40 | 40 | $menu_items[] = Display::url(Display::return_icon('quiz.png', get_lang('ExamTracking'), array(), 32), api_get_path(WEB_CODE_PATH).'tracking/exams.php'); |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | $session_id = intval($session_id); |
| 105 | 105 | |
| 106 | 106 | $sql = 'SELECT login_course_date, logout_course_date |
| 107 | - FROM ' . $tbl_track_course . ' |
|
| 107 | + FROM ' . $tbl_track_course.' |
|
| 108 | 108 | WHERE |
| 109 | 109 | user_id = '.$user_id.' AND |
| 110 | 110 | c_id = '.$courseId.' AND |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | foreach ($course_list as $course_item) { |
| 144 | 144 | $courseInfo = api_get_course_info($course_item['code']); |
| 145 | 145 | $courseId = $courseInfo['real_id']; |
| 146 | - $new_course_list[] = '"'.$courseId.'"'; |
|
| 146 | + $new_course_list[] = '"'.$courseId.'"'; |
|
| 147 | 147 | } |
| 148 | 148 | $course_list = implode(', ', $new_course_list); |
| 149 | 149 | |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | return false; |
| 152 | 152 | } |
| 153 | 153 | $sql = 'SELECT login_course_date, logout_course_date, c_id |
| 154 | - FROM ' . $tbl_track_course . ' |
|
| 154 | + FROM ' . $tbl_track_course.' |
|
| 155 | 155 | WHERE |
| 156 | 156 | user_id = '.$user_id.' AND |
| 157 | 157 | c_id IN ('.$course_list.') AND |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | // student score |
| 230 | 230 | $avg_score = Tracking :: get_avg_student_score($user_id, $courseCode); |
| 231 | 231 | if (is_numeric($avg_score)) { |
| 232 | - $avg_score = round($avg_score,2); |
|
| 232 | + $avg_score = round($avg_score, 2); |
|
| 233 | 233 | } else { |
| 234 | 234 | $$avg_score = '-'; |
| 235 | 235 | } |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">'; |
| 267 | 267 | //$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>'; |
| 268 | - $t_head .= '<tr>'; |
|
| 268 | + $t_head .= '<tr>'; |
|
| 269 | 269 | $t_head .= ' <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>'; |
| 270 | 270 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>'; |
| 271 | 271 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>'; |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | |
| 284 | 284 | $addparams = array('view' => 'admin', 'display' => 'user'); |
| 285 | 285 | |
| 286 | - $table = new SortableTable('tracking_user_overview', array('MySpace','get_number_of_users_tracking_overview'), array('MySpace','get_user_data_tracking_overview'), 0); |
|
| 286 | + $table = new SortableTable('tracking_user_overview', array('MySpace', 'get_number_of_users_tracking_overview'), array('MySpace', 'get_user_data_tracking_overview'), 0); |
|
| 287 | 287 | $table->additional_parameters = $addparams; |
| 288 | 288 | |
| 289 | 289 | $table->set_header(0, get_lang('OfficialCode'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); |
@@ -296,7 +296,7 @@ discard block |
||
| 296 | 296 | } |
| 297 | 297 | $table->set_header(3, get_lang('LoginName'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); |
| 298 | 298 | $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;')); |
| 299 | - $table->set_column_filter(4, array('MySpace','course_info_tracking_filter')); |
|
| 299 | + $table->set_column_filter(4, array('MySpace', 'course_info_tracking_filter')); |
|
| 300 | 300 | $table->display(); |
| 301 | 301 | } |
| 302 | 302 | |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | $table -> set_header(7, get_lang('Sessions'), false); |
| 342 | 342 | |
| 343 | 343 | if ($is_western_name_order) { |
| 344 | - $csv_header[] = array ( |
|
| 344 | + $csv_header[] = array( |
|
| 345 | 345 | get_lang('FirstName', ''), |
| 346 | 346 | get_lang('LastName', ''), |
| 347 | 347 | get_lang('TimeSpentOnThePlatform', ''), |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | get_lang('NumberOfSessions', '') |
| 352 | 352 | ); |
| 353 | 353 | } else { |
| 354 | - $csv_header[] = array ( |
|
| 354 | + $csv_header[] = array( |
|
| 355 | 355 | get_lang('LastName', ''), |
| 356 | 356 | get_lang('FirstName', ''), |
| 357 | 357 | get_lang('TimeSpentOnThePlatform', ''), |
@@ -491,9 +491,9 @@ discard block |
||
| 491 | 491 | |
| 492 | 492 | if ($tracking_column != 3) { |
| 493 | 493 | if ($tracking_direction == 'DESC') { |
| 494 | - usort($all_datas, array('MySpace','rsort_users')); |
|
| 494 | + usort($all_datas, array('MySpace', 'rsort_users')); |
|
| 495 | 495 | } else { |
| 496 | - usort($all_datas, array('MySpace','sort_users')); |
|
| 496 | + usort($all_datas, array('MySpace', 'sort_users')); |
|
| 497 | 497 | } |
| 498 | 498 | } |
| 499 | 499 | |
@@ -552,7 +552,7 @@ discard block |
||
| 552 | 552 | /** |
| 553 | 553 | * Column config |
| 554 | 554 | */ |
| 555 | - $column_model = array( |
|
| 555 | + $column_model = array( |
|
| 556 | 556 | array( |
| 557 | 557 | 'name' => 'username', |
| 558 | 558 | 'index' => 'username', |
@@ -593,7 +593,7 @@ discard block |
||
| 593 | 593 | |
| 594 | 594 | $action_links = ''; |
| 595 | 595 | // jqgrid will use this URL to do the selects |
| 596 | - $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; |
|
| 596 | + $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; |
|
| 597 | 597 | |
| 598 | 598 | //Table Id |
| 599 | 599 | $tableId = 'lpProgress'; |
@@ -615,11 +615,11 @@ discard block |
||
| 615 | 615 | true |
| 616 | 616 | ); |
| 617 | 617 | |
| 618 | - $return = '<script>$(function() {'. $table . |
|
| 618 | + $return = '<script>$(function() {'.$table. |
|
| 619 | 619 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
| 620 | 620 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
| 621 | 621 | caption:"", |
| 622 | - title:"' . get_lang('ExportExcel') . '", |
|
| 622 | + title:"' . get_lang('ExportExcel').'", |
|
| 623 | 623 | onClickButton : function () { |
| 624 | 624 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
| 625 | 625 | } |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | /** |
| 670 | 670 | * Column config |
| 671 | 671 | */ |
| 672 | - $column_model = array( |
|
| 672 | + $column_model = array( |
|
| 673 | 673 | array('name'=>'session', 'index'=>'session', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), |
| 674 | 674 | array('name'=>'exercise_id', 'index'=>'exercise_id', 'align'=>'left', 'search' => 'true'), |
| 675 | 675 | array('name'=>'quiz_title', 'index'=>'quiz_title', 'align'=>'left', 'search' => 'true'), |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | //get dynamic column names |
| 687 | 687 | |
| 688 | 688 | // jqgrid will use this URL to do the selects |
| 689 | - $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; |
|
| 689 | + $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; |
|
| 690 | 690 | |
| 691 | 691 | // Autowidth |
| 692 | 692 | $extra_params['autowidth'] = 'true'; |
@@ -697,11 +697,11 @@ discard block |
||
| 697 | 697 | $tableId = 'exerciseProgressOverview'; |
| 698 | 698 | $table = Display::grid_js($tableId, $url, $columns, $column_model, $extra_params, array(), '', true); |
| 699 | 699 | |
| 700 | - $return = '<script>$(function() {'. $table . |
|
| 700 | + $return = '<script>$(function() {'.$table. |
|
| 701 | 701 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
| 702 | 702 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
| 703 | 703 | caption:"", |
| 704 | - title:"' . get_lang('ExportExcel') . '", |
|
| 704 | + title:"' . get_lang('ExportExcel').'", |
|
| 705 | 705 | onClickButton : function () { |
| 706 | 706 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
| 707 | 707 | } |
@@ -787,8 +787,8 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | $column[] = $title; |
| 789 | 789 | $column_model[] = array( |
| 790 | - 'name' => 'exer' . $i, |
|
| 791 | - 'index' => 'exer' . $i, |
|
| 790 | + 'name' => 'exer'.$i, |
|
| 791 | + 'index' => 'exer'.$i, |
|
| 792 | 792 | 'align' => 'center', |
| 793 | 793 | 'search' => 'true', |
| 794 | 794 | 'wrap_cell' => "true" |
@@ -800,7 +800,7 @@ discard block |
||
| 800 | 800 | |
| 801 | 801 | //end get dynamic column names |
| 802 | 802 | // jqgrid will use this URL to do the selects |
| 803 | - $url = api_get_path(WEB_AJAX_PATH) . 'model.ajax.php?a=get_exercise_grade&session_id=' . $sessionId . '&course_id=' . $courseId; |
|
| 803 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_exercise_grade&session_id='.$sessionId.'&course_id='.$courseId; |
|
| 804 | 804 | |
| 805 | 805 | // Autowidth |
| 806 | 806 | $extra_params['autowidth'] = 'true'; |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | $tableId = 'exerciseGradeOverview'; |
| 812 | 812 | $table = Display::grid_js($tableId, $url, $column, $column_model, $extra_params, array(), '', true); |
| 813 | 813 | |
| 814 | - $return = '<script>$(function() {' . $table . |
|
| 815 | - 'jQuery("#' . $tableId . '").jqGrid("navGrid","#' . $tableId . '_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
|
| 816 | - jQuery("#' . $tableId . '").jqGrid("navButtonAdd","#' . $tableId . '_pager",{ |
|
| 814 | + $return = '<script>$(function() {'.$table. |
|
| 815 | + 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
|
| 816 | + jQuery("#' . $tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
|
| 817 | 817 | caption:"", |
| 818 | - title:"' . get_lang('ExportExcel') . '", |
|
| 818 | + title:"' . get_lang('ExportExcel').'", |
|
| 819 | 819 | onClickButton : function () { |
| 820 | - jQuery("#' . $tableId . '").jqGrid("excelExport",{"url":"' . $url . '&export_format=xls"}); |
|
| 820 | + jQuery("#' . $tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
|
| 821 | 821 | } |
| 822 | 822 | }); |
| 823 | 823 | });</script>'; |
@@ -850,10 +850,10 @@ discard block |
||
| 850 | 850 | /** |
| 851 | 851 | * Column config |
| 852 | 852 | */ |
| 853 | - $column_model = array( |
|
| 854 | - array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), |
|
| 855 | - array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'), |
|
| 856 | - array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'), |
|
| 853 | + $column_model = array( |
|
| 854 | + array('name'=>'username', 'index'=>'username', 'align'=>'left', 'search' => 'true', 'wrap_cell' => "true"), |
|
| 855 | + array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left', 'search' => 'true'), |
|
| 856 | + array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left', 'search' => 'true'), |
|
| 857 | 857 | ); |
| 858 | 858 | //get dinamic column names |
| 859 | 859 | foreach ($questions as $question_id => $question) { |
@@ -869,7 +869,7 @@ discard block |
||
| 869 | 869 | $action_links = ''; |
| 870 | 870 | |
| 871 | 871 | // jqgrid will use this URL to do the selects |
| 872 | - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id=' . $sessionId . '&course_id=' . $courseId . '&survey_id=' . $surveyId . '&date_to=' . $date_to . '&date_from=' . $date_from; |
|
| 872 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_survey_overview&session_id='.$sessionId.'&course_id='.$courseId.'&survey_id='.$surveyId.'&date_to='.$date_to.'&date_from='.$date_from; |
|
| 873 | 873 | |
| 874 | 874 | // Table Id |
| 875 | 875 | $tableId = 'lpProgress'; |
@@ -891,11 +891,11 @@ discard block |
||
| 891 | 891 | true |
| 892 | 892 | ); |
| 893 | 893 | |
| 894 | - $return = '<script>$(function() {'. $table . |
|
| 894 | + $return = '<script>$(function() {'.$table. |
|
| 895 | 895 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
| 896 | 896 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
| 897 | 897 | caption:"", |
| 898 | - title:"' . get_lang('ExportExcel') . '", |
|
| 898 | + title:"' . get_lang('ExportExcel').'", |
|
| 899 | 899 | onClickButton : function () { |
| 900 | 900 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
| 901 | 901 | } |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | * Display a sortable table that contains an overview off all the progress of the user in a session |
| 911 | 911 | * @author César Perales <[email protected]>, Beeznest Team |
| 912 | 912 | */ |
| 913 | - static function display_tracking_progress_overview($sessionId = 0, $courseId = 0, $date_from, $date_to) |
|
| 913 | + static function display_tracking_progress_overview($sessionId = 0, $courseId = 0, $date_from, $date_to) |
|
| 914 | 914 | { |
| 915 | 915 | //The order is important you need to check the the $column variable in the model.ajax.php file |
| 916 | 916 | $columns = array( |
@@ -960,55 +960,55 @@ discard block |
||
| 960 | 960 | ); |
| 961 | 961 | |
| 962 | 962 | //Column config |
| 963 | - $column_model = array( |
|
| 964 | - array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left'), |
|
| 965 | - array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left'), |
|
| 966 | - array('name'=>'username', 'index'=>'username', 'align'=>'left'), |
|
| 963 | + $column_model = array( |
|
| 964 | + array('name'=>'lastname', 'index'=>'lastname', 'align'=>'left'), |
|
| 965 | + array('name'=>'firstname', 'index'=>'firstname', 'align'=>'left'), |
|
| 966 | + array('name'=>'username', 'index'=>'username', 'align'=>'left'), |
|
| 967 | 967 | #array('name'=>'profile', 'index'=>'username', 'align'=>'left'), |
| 968 | - array('name'=>'total', 'index'=>'total', 'align'=>'left'), |
|
| 969 | - array('name'=>'courses', 'index'=>'courses', 'align'=>'left', 'sortable' => 'false'), |
|
| 970 | - array('name'=>'lessons', 'index'=>'lessons', 'align'=>'left', 'sortable' => 'false'), |
|
| 971 | - array('name'=>'exercises', 'index'=>'exercises', 'align'=>'left', 'sortable' => 'false'), |
|
| 972 | - array('name'=>'forums', 'index'=>'forums', 'align'=>'left', 'sortable' => 'false'), |
|
| 973 | - array('name'=>'homeworks', 'index'=>'homeworks', 'align'=>'left', 'sortable' => 'false'), |
|
| 974 | - array('name'=>'wikis', 'index'=>'wikis', 'align'=>'left', 'sortable' => 'false'), |
|
| 975 | - array('name'=>'surveys', 'index'=>'surveys', 'align'=>'left', 'sortable' => 'false'), |
|
| 968 | + array('name'=>'total', 'index'=>'total', 'align'=>'left'), |
|
| 969 | + array('name'=>'courses', 'index'=>'courses', 'align'=>'left', 'sortable' => 'false'), |
|
| 970 | + array('name'=>'lessons', 'index'=>'lessons', 'align'=>'left', 'sortable' => 'false'), |
|
| 971 | + array('name'=>'exercises', 'index'=>'exercises', 'align'=>'left', 'sortable' => 'false'), |
|
| 972 | + array('name'=>'forums', 'index'=>'forums', 'align'=>'left', 'sortable' => 'false'), |
|
| 973 | + array('name'=>'homeworks', 'index'=>'homeworks', 'align'=>'left', 'sortable' => 'false'), |
|
| 974 | + array('name'=>'wikis', 'index'=>'wikis', 'align'=>'left', 'sortable' => 'false'), |
|
| 975 | + array('name'=>'surveys', 'index'=>'surveys', 'align'=>'left', 'sortable' => 'false'), |
|
| 976 | 976 | //Lessons |
| 977 | - array('name'=>'lessons_total', 'index'=>'lessons_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 978 | - array('name'=>'lessons_done', 'index'=>'lessons_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 979 | - array('name'=>'lessons_left', 'index'=>'lessons_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 980 | - array('name'=>'lessons_progress', 'index'=>'lessons_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 977 | + array('name'=>'lessons_total', 'index'=>'lessons_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 978 | + array('name'=>'lessons_done', 'index'=>'lessons_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 979 | + array('name'=>'lessons_left', 'index'=>'lessons_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 980 | + array('name'=>'lessons_progress', 'index'=>'lessons_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 981 | 981 | //Exercises |
| 982 | - array('name'=>'exercises_total', 'index'=>'exercises_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 983 | - array('name'=>'exercises_done', 'index'=>'exercises_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 984 | - array('name'=>'exercises_left', 'index'=>'exercises_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 985 | - array('name'=>'exercises_progress', 'index'=>'exercises_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 982 | + array('name'=>'exercises_total', 'index'=>'exercises_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 983 | + array('name'=>'exercises_done', 'index'=>'exercises_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 984 | + array('name'=>'exercises_left', 'index'=>'exercises_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 985 | + array('name'=>'exercises_progress', 'index'=>'exercises_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 986 | 986 | //Assignments |
| 987 | - array('name'=>'forums_total', 'index'=>'forums_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 988 | - array('name'=>'forums_done', 'index'=>'forums_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 989 | - array('name'=>'forums_left', 'index'=>'forums_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 990 | - array('name'=>'forums_progress', 'index'=>'forums_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 987 | + array('name'=>'forums_total', 'index'=>'forums_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 988 | + array('name'=>'forums_done', 'index'=>'forums_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 989 | + array('name'=>'forums_left', 'index'=>'forums_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 990 | + array('name'=>'forums_progress', 'index'=>'forums_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 991 | 991 | //Assignments |
| 992 | - array('name'=>'assigments_total', 'index'=>'assigments_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 993 | - array('name'=>'assigments_done', 'index'=>'assigments_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 994 | - array('name'=>'assigments_left', 'index'=>'assigments_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 995 | - array('name'=>'assigments_progress', 'index'=>'assigments_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 992 | + array('name'=>'assigments_total', 'index'=>'assigments_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 993 | + array('name'=>'assigments_done', 'index'=>'assigments_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 994 | + array('name'=>'assigments_left', 'index'=>'assigments_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 995 | + array('name'=>'assigments_progress', 'index'=>'assigments_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 996 | 996 | //Assignments |
| 997 | - array('name'=>'wiki_total', 'index'=>'wiki_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 998 | - array('name'=>'wiki_revisions', 'index'=>'wiki_revisions', 'align'=>'center', 'sortable' => 'false'), |
|
| 999 | - array('name'=>'wiki_read', 'index'=>'wiki_read', 'align'=>'center', 'sortable' => 'false'), |
|
| 1000 | - array('name'=>'wiki_unread', 'index'=>'wiki_unread', 'align'=>'center', 'sortable' => 'false'), |
|
| 1001 | - array('name'=>'wiki_progress', 'index'=>'wiki_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 997 | + array('name'=>'wiki_total', 'index'=>'wiki_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 998 | + array('name'=>'wiki_revisions', 'index'=>'wiki_revisions', 'align'=>'center', 'sortable' => 'false'), |
|
| 999 | + array('name'=>'wiki_read', 'index'=>'wiki_read', 'align'=>'center', 'sortable' => 'false'), |
|
| 1000 | + array('name'=>'wiki_unread', 'index'=>'wiki_unread', 'align'=>'center', 'sortable' => 'false'), |
|
| 1001 | + array('name'=>'wiki_progress', 'index'=>'wiki_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 1002 | 1002 | //Surveys |
| 1003 | - array('name'=>'surveys_total', 'index'=>'surveys_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 1004 | - array('name'=>'surveys_done', 'index'=>'surveys_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 1005 | - array('name'=>'surveys_left', 'index'=>'surveys_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 1006 | - array('name'=>'surveys_progress', 'index'=>'surveys_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 1003 | + array('name'=>'surveys_total', 'index'=>'surveys_total', 'align'=>'center', 'sortable' => 'false'), |
|
| 1004 | + array('name'=>'surveys_done', 'index'=>'surveys_done', 'align'=>'center', 'sortable' => 'false'), |
|
| 1005 | + array('name'=>'surveys_left', 'index'=>'surveys_left', 'align'=>'center', 'sortable' => 'false'), |
|
| 1006 | + array('name'=>'surveys_progress', 'index'=>'surveys_progress', 'align'=>'center', 'sortable' => 'false'), |
|
| 1007 | 1007 | ); |
| 1008 | 1008 | |
| 1009 | 1009 | $action_links = ''; |
| 1010 | 1010 | // jqgrid will use this URL to do the selects |
| 1011 | - $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id=' . $sessionId . '&course_id=' . $courseId . '&date_to=' . $date_to . '&date_from=' . $date_from; |
|
| 1011 | + $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_session_progress&session_id='.$sessionId.'&course_id='.$courseId.'&date_to='.$date_to.'&date_from='.$date_from; |
|
| 1012 | 1012 | |
| 1013 | 1013 | //Table Id |
| 1014 | 1014 | $tableId = 'progressOverview'; |
@@ -1068,11 +1068,11 @@ discard block |
||
| 1068 | 1068 | true |
| 1069 | 1069 | ); |
| 1070 | 1070 | |
| 1071 | - $return = '<script>$(function() {'. $table . |
|
| 1071 | + $return = '<script>$(function() {'.$table. |
|
| 1072 | 1072 | 'jQuery("#'.$tableId.'").jqGrid("navGrid","#'.$tableId.'_pager",{view:false, edit:false, add:false, del:false, search:false, excel:true}); |
| 1073 | 1073 | jQuery("#'.$tableId.'").jqGrid("navButtonAdd","#'.$tableId.'_pager",{ |
| 1074 | 1074 | caption:"", |
| 1075 | - title:"' . get_lang('ExportExcel') . '", |
|
| 1075 | + title:"' . get_lang('ExportExcel').'", |
|
| 1076 | 1076 | onClickButton : function () { |
| 1077 | 1077 | jQuery("#'.$tableId.'").jqGrid("excelExport",{"url":"'.$url.'&export_format=xls"}); |
| 1078 | 1078 | } |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | // adding the fields that are checked to the session |
| 1133 | 1133 | $message = ''; |
| 1134 | 1134 | foreach ($values as $field_ids => $value) { |
| 1135 | - if ($value == 1 && strstr($field_ids,'extra_export_field')) { |
|
| 1135 | + if ($value == 1 && strstr($field_ids, 'extra_export_field')) { |
|
| 1136 | 1136 | $_SESSION['additional_export_fields'][] = str_replace('extra_export_field', '', $field_ids); |
| 1137 | 1137 | } |
| 1138 | 1138 | } |
@@ -1147,7 +1147,7 @@ discard block |
||
| 1147 | 1147 | // Displaying a feedback message |
| 1148 | 1148 | if (!empty($_SESSION['additional_export_fields'])) { |
| 1149 | 1149 | Display::display_confirmation_message(get_lang('FollowingFieldsWillAlsoBeExported').': <br /><ul>'.$message.'</ul>', false); |
| 1150 | - } else { |
|
| 1150 | + } else { |
|
| 1151 | 1151 | Display::display_confirmation_message(get_lang('NoAdditionalFieldsWillBeExported'), false); |
| 1152 | 1152 | } |
| 1153 | 1153 | } else { |
@@ -1175,7 +1175,7 @@ discard block |
||
| 1175 | 1175 | { |
| 1176 | 1176 | $t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">'; |
| 1177 | 1177 | //$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>'; |
| 1178 | - $t_head .= '<tr>'; |
|
| 1178 | + $t_head .= '<tr>'; |
|
| 1179 | 1179 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>'; |
| 1180 | 1180 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>'; |
| 1181 | 1181 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgCourseScore'), 6, true).'</span></th>'; |
@@ -1192,13 +1192,13 @@ discard block |
||
| 1192 | 1192 | |
| 1193 | 1193 | $addparams = array('view' => 'admin', 'display' => 'courseoverview'); |
| 1194 | 1194 | |
| 1195 | - $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace','get_course_data_tracking_overview'), 1); |
|
| 1195 | + $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_courses'), array('MySpace', 'get_course_data_tracking_overview'), 1); |
|
| 1196 | 1196 | $table->additional_parameters = $addparams; |
| 1197 | 1197 | |
| 1198 | 1198 | $table->set_header(0, '', false, null, array('style' => 'display: none')); |
| 1199 | 1199 | $table->set_header(1, get_lang('Course'), true, array('style' => 'font-size:8pt'), array('style' => 'font-size:8pt')); |
| 1200 | 1200 | $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;')); |
| 1201 | - $table->set_column_filter(2, array('MySpace','course_tracking_filter')); |
|
| 1201 | + $table->set_column_filter(2, array('MySpace', 'course_tracking_filter')); |
|
| 1202 | 1202 | $table->display(); |
| 1203 | 1203 | } |
| 1204 | 1204 | |
@@ -1234,7 +1234,7 @@ discard block |
||
| 1234 | 1234 | $sql .= " ORDER BY col$column $direction "; |
| 1235 | 1235 | $sql .= " LIMIT $from,$number_of_items"; |
| 1236 | 1236 | $result = Database::query($sql); |
| 1237 | - $return = array (); |
|
| 1237 | + $return = array(); |
|
| 1238 | 1238 | while ($course = Database::fetch_row($result)) { |
| 1239 | 1239 | $return[] = $course; |
| 1240 | 1240 | } |
@@ -1287,18 +1287,18 @@ discard block |
||
| 1287 | 1287 | $progress += $progress_tmp[0]; |
| 1288 | 1288 | $nb_progress_lp += $progress_tmp[1]; |
| 1289 | 1289 | $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true); |
| 1290 | - if(is_array($score_tmp)) { |
|
| 1290 | + if (is_array($score_tmp)) { |
|
| 1291 | 1291 | $score += $score_tmp[0]; |
| 1292 | 1292 | $nb_score_lp += $score_tmp[1]; |
| 1293 | 1293 | } |
| 1294 | 1294 | $nb_messages += Tracking::count_student_messages($row->user_id, $course_code); |
| 1295 | 1295 | $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); |
| 1296 | 1296 | $last_login_date_tmp = Tracking :: get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false); |
| 1297 | - if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned |
|
| 1297 | + if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned |
|
| 1298 | 1298 | $last_login_date = $last_login_date_tmp; |
| 1299 | - } else if($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1299 | + } else if ($last_login_date_tmp != false && $last_login_date != false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1300 | 1300 | // Find the max and assign it to first_login_date |
| 1301 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1301 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1302 | 1302 | $last_login_date = $last_login_date_tmp; |
| 1303 | 1303 | } |
| 1304 | 1304 | } |
@@ -1308,27 +1308,27 @@ discard block |
||
| 1308 | 1308 | $total_score_possible += $exercise_results_tmp['score_possible']; |
| 1309 | 1309 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
| 1310 | 1310 | } |
| 1311 | - if($nb_progress_lp > 0) { |
|
| 1311 | + if ($nb_progress_lp > 0) { |
|
| 1312 | 1312 | $avg_progress = round($progress / $nb_progress_lp, 2); |
| 1313 | 1313 | } else { |
| 1314 | 1314 | $avg_progress = 0; |
| 1315 | 1315 | } |
| 1316 | - if($nb_score_lp > 0) { |
|
| 1316 | + if ($nb_score_lp > 0) { |
|
| 1317 | 1317 | $avg_score = round($score / $nb_score_lp, 2); |
| 1318 | 1318 | } else { |
| 1319 | 1319 | $avg_score = '-'; |
| 1320 | 1320 | } |
| 1321 | - if($last_login_date) { |
|
| 1321 | + if ($last_login_date) { |
|
| 1322 | 1322 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
| 1323 | 1323 | } else { |
| 1324 | 1324 | $last_login_date = '-'; |
| 1325 | 1325 | } |
| 1326 | - if($total_score_possible > 0) { |
|
| 1326 | + if ($total_score_possible > 0) { |
|
| 1327 | 1327 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
| 1328 | 1328 | } else { |
| 1329 | 1329 | $total_score_percentage = 0; |
| 1330 | 1330 | } |
| 1331 | - if($total_score_percentage > 0) { |
|
| 1331 | + if ($total_score_percentage > 0) { |
|
| 1332 | 1332 | $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; |
| 1333 | 1333 | } else { |
| 1334 | 1334 | $total_score = '-'; |
@@ -1436,7 +1436,7 @@ discard block |
||
| 1436 | 1436 | $progress += $progress_tmp[0]; |
| 1437 | 1437 | $nb_progress_lp += $progress_tmp[1]; |
| 1438 | 1438 | $score_tmp = Tracking :: get_avg_student_score($row->user_id, $course_code, array(), null, true); |
| 1439 | - if(is_array($score_tmp)) { |
|
| 1439 | + if (is_array($score_tmp)) { |
|
| 1440 | 1440 | $score += $score_tmp[0]; |
| 1441 | 1441 | $nb_score_lp += $score_tmp[1]; |
| 1442 | 1442 | } |
@@ -1444,11 +1444,11 @@ discard block |
||
| 1444 | 1444 | $nb_assignments += Tracking::count_student_assignments($row->user_id, $course_code); |
| 1445 | 1445 | |
| 1446 | 1446 | $last_login_date_tmp = Tracking::get_last_connection_date_on_the_course($row->user_id, $courseInfo, null, false); |
| 1447 | - if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
| 1447 | + if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
| 1448 | 1448 | $last_login_date = $last_login_date_tmp; |
| 1449 | - } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1449 | + } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1450 | 1450 | // Find the max and assign it to first_login_date |
| 1451 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1451 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1452 | 1452 | $last_login_date = $last_login_date_tmp; |
| 1453 | 1453 | } |
| 1454 | 1454 | } |
@@ -1458,22 +1458,22 @@ discard block |
||
| 1458 | 1458 | $total_score_possible += $exercise_results_tmp['score_possible']; |
| 1459 | 1459 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
| 1460 | 1460 | } |
| 1461 | - if($nb_progress_lp > 0) { |
|
| 1461 | + if ($nb_progress_lp > 0) { |
|
| 1462 | 1462 | $avg_progress = round($progress / $nb_progress_lp, 2); |
| 1463 | 1463 | } else { |
| 1464 | 1464 | $avg_progress = 0; |
| 1465 | 1465 | } |
| 1466 | - if($nb_score_lp > 0) { |
|
| 1466 | + if ($nb_score_lp > 0) { |
|
| 1467 | 1467 | $avg_score = round($score / $nb_score_lp, 2); |
| 1468 | 1468 | } else { |
| 1469 | 1469 | $avg_score = '-'; |
| 1470 | 1470 | } |
| 1471 | - if($last_login_date) { |
|
| 1471 | + if ($last_login_date) { |
|
| 1472 | 1472 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
| 1473 | 1473 | } else { |
| 1474 | 1474 | $last_login_date = '-'; |
| 1475 | 1475 | } |
| 1476 | - if($total_score_possible > 0) { |
|
| 1476 | + if ($total_score_possible > 0) { |
|
| 1477 | 1477 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
| 1478 | 1478 | } else { |
| 1479 | 1479 | $total_score_percentage = 0; |
@@ -1509,7 +1509,7 @@ discard block |
||
| 1509 | 1509 | { |
| 1510 | 1510 | $t_head = ' <table style="width: 100%;border:0;padding:0;border-collapse:collapse;table-layout: fixed">'; |
| 1511 | 1511 | //$t_head .= ' <caption>'.get_lang('CourseInformation').'</caption>'; |
| 1512 | - $t_head .= '<tr>'; |
|
| 1512 | + $t_head .= '<tr>'; |
|
| 1513 | 1513 | $t_head .= ' <th width="155px" style="border-left:0;border-bottom:0"><span>'.get_lang('Course').'</span></th>'; |
| 1514 | 1514 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgTimeSpentInTheCourse'), 6, true).'</span></th>'; |
| 1515 | 1515 | $t_head .= ' <th style="padding:0;border-bottom:0"><span>'.cut(get_lang('AvgStudentsProgress'), 6, true).'</span></th>'; |
@@ -1527,7 +1527,7 @@ discard block |
||
| 1527 | 1527 | |
| 1528 | 1528 | $addparams = array('view' => 'admin', 'display' => 'sessionoverview'); |
| 1529 | 1529 | |
| 1530 | - $table = new SortableTable('tracking_session_overview', array('MySpace','get_total_number_sessions'), array('MySpace','get_session_data_tracking_overview'), 1); |
|
| 1530 | + $table = new SortableTable('tracking_session_overview', array('MySpace', 'get_total_number_sessions'), array('MySpace', 'get_session_data_tracking_overview'), 1); |
|
| 1531 | 1531 | $table->additional_parameters = $addparams; |
| 1532 | 1532 | |
| 1533 | 1533 | $table->set_header(0, '', false, null, array('style' => 'display: none')); |
@@ -1566,7 +1566,7 @@ discard block |
||
| 1566 | 1566 | $sql .= " ORDER BY col$column $direction "; |
| 1567 | 1567 | $sql .= " LIMIT $from,$number_of_items"; |
| 1568 | 1568 | $result = Database::query($sql); |
| 1569 | - $return = array (); |
|
| 1569 | + $return = array(); |
|
| 1570 | 1570 | while ($session = Database::fetch_row($result)) { |
| 1571 | 1571 | $return[] = $session; |
| 1572 | 1572 | } |
@@ -1655,10 +1655,10 @@ discard block |
||
| 1655 | 1655 | if ($last_login_date_tmp != false && $last_login_date == false) { |
| 1656 | 1656 | // TODO: To be cleaned. |
| 1657 | 1657 | $last_login_date = $last_login_date_tmp; |
| 1658 | - } else if($last_login_date_tmp != false && $last_login_date != false) { |
|
| 1658 | + } else if ($last_login_date_tmp != false && $last_login_date != false) { |
|
| 1659 | 1659 | // TODO: Repeated previous condition! To be cleaned. |
| 1660 | 1660 | // Find the max and assign it to first_login_date |
| 1661 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1661 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1662 | 1662 | $last_login_date = $last_login_date_tmp; |
| 1663 | 1663 | } |
| 1664 | 1664 | } |
@@ -1668,27 +1668,27 @@ discard block |
||
| 1668 | 1668 | $total_score_possible += $exercise_results_tmp['score_possible']; |
| 1669 | 1669 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
| 1670 | 1670 | } |
| 1671 | - if($nb_progress_lp > 0) { |
|
| 1671 | + if ($nb_progress_lp > 0) { |
|
| 1672 | 1672 | $avg_progress = round($progress / $nb_progress_lp, 2); |
| 1673 | 1673 | } else { |
| 1674 | 1674 | $avg_progress = 0; |
| 1675 | 1675 | } |
| 1676 | - if($nb_score_lp > 0) { |
|
| 1676 | + if ($nb_score_lp > 0) { |
|
| 1677 | 1677 | $avg_score = round($score / $nb_score_lp, 2); |
| 1678 | 1678 | } else { |
| 1679 | 1679 | $avg_score = '-'; |
| 1680 | 1680 | } |
| 1681 | - if($last_login_date) { |
|
| 1681 | + if ($last_login_date) { |
|
| 1682 | 1682 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
| 1683 | 1683 | } else { |
| 1684 | 1684 | $last_login_date = '-'; |
| 1685 | 1685 | } |
| 1686 | - if($total_score_possible > 0) { |
|
| 1686 | + if ($total_score_possible > 0) { |
|
| 1687 | 1687 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
| 1688 | 1688 | } else { |
| 1689 | 1689 | $total_score_percentage = 0; |
| 1690 | 1690 | } |
| 1691 | - if($total_score_percentage > 0) { |
|
| 1691 | + if ($total_score_percentage > 0) { |
|
| 1692 | 1692 | $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; |
| 1693 | 1693 | } else { |
| 1694 | 1694 | $total_score = '-'; |
@@ -1799,7 +1799,7 @@ discard block |
||
| 1799 | 1799 | $total_score_obtained = 0; |
| 1800 | 1800 | $total_score_possible = 0; |
| 1801 | 1801 | $total_questions_answered = 0; |
| 1802 | - while($row_user = Database::fetch_object($result_users)) { |
|
| 1802 | + while ($row_user = Database::fetch_object($result_users)) { |
|
| 1803 | 1803 | // get time spent in the course and session |
| 1804 | 1804 | $time_spent += Tracking::get_time_spent_on_the_course($row_user->user_id, $courseId, $session_id); |
| 1805 | 1805 | $progress_tmp = Tracking::get_avg_student_progress($row_user->user_id, $row->code, array(), $session_id, true); |
@@ -1828,11 +1828,11 @@ discard block |
||
| 1828 | 1828 | $session_id, |
| 1829 | 1829 | false |
| 1830 | 1830 | ); |
| 1831 | - if($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
| 1831 | + if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: To be cleaned. |
|
| 1832 | 1832 | $last_login_date = $last_login_date_tmp; |
| 1833 | - } else if($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1833 | + } else if ($last_login_date_tmp != false && $last_login_date == false) { // TODO: Repeated previous condition. To be cleaned. |
|
| 1834 | 1834 | // Find the max and assign it to first_login_date |
| 1835 | - if(strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1835 | + if (strtotime($last_login_date_tmp) > strtotime($last_login_date)) { |
|
| 1836 | 1836 | $last_login_date = $last_login_date_tmp; |
| 1837 | 1837 | } |
| 1838 | 1838 | } |
@@ -1842,27 +1842,27 @@ discard block |
||
| 1842 | 1842 | $total_score_possible += $exercise_results_tmp['score_possible']; |
| 1843 | 1843 | $total_questions_answered += $exercise_results_tmp['questions_answered']; |
| 1844 | 1844 | } |
| 1845 | - if($nb_progress_lp > 0) { |
|
| 1845 | + if ($nb_progress_lp > 0) { |
|
| 1846 | 1846 | $avg_progress = round($progress / $nb_progress_lp, 2); |
| 1847 | 1847 | } else { |
| 1848 | 1848 | $avg_progress = 0; |
| 1849 | 1849 | } |
| 1850 | - if($nb_score_lp > 0) { |
|
| 1850 | + if ($nb_score_lp > 0) { |
|
| 1851 | 1851 | $avg_score = round($score / $nb_score_lp, 2); |
| 1852 | 1852 | } else { |
| 1853 | 1853 | $avg_score = '-'; |
| 1854 | 1854 | } |
| 1855 | - if($last_login_date) { |
|
| 1855 | + if ($last_login_date) { |
|
| 1856 | 1856 | $last_login_date = api_convert_and_format_date($last_login_date, DATE_FORMAT_SHORT, date_default_timezone_get()); |
| 1857 | 1857 | } else { |
| 1858 | 1858 | $last_login_date = '-'; |
| 1859 | 1859 | } |
| 1860 | - if($total_score_possible > 0) { |
|
| 1860 | + if ($total_score_possible > 0) { |
|
| 1861 | 1861 | $total_score_percentage = round($total_score_obtained / $total_score_possible * 100, 2); |
| 1862 | 1862 | } else { |
| 1863 | 1863 | $total_score_percentage = 0; |
| 1864 | 1864 | } |
| 1865 | - if($total_score_percentage > 0) { |
|
| 1865 | + if ($total_score_percentage > 0) { |
|
| 1866 | 1866 | $total_score = $total_score_obtained.'/'.$total_score_possible.' ('.$total_score_percentage.' %)'; |
| 1867 | 1867 | } else { |
| 1868 | 1868 | $total_score = '-'; |
@@ -1912,7 +1912,7 @@ discard block |
||
| 1912 | 1912 | FROM '.Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES)." |
| 1913 | 1913 | WHERE c_id = ' . $courseId . ' |
| 1914 | 1914 | AND exe_user_id = '".intval($user_id)."'"; |
| 1915 | - if($session_id !== false) { |
|
| 1915 | + if ($session_id !== false) { |
|
| 1916 | 1916 | $sql .= " AND session_id = '".$session_id."' "; |
| 1917 | 1917 | } |
| 1918 | 1918 | $result = Database::query($sql); |
@@ -1922,7 +1922,7 @@ discard block |
||
| 1922 | 1922 | while ($row = Database::fetch_array($result)) { |
| 1923 | 1923 | $score_obtained += $row['exe_result']; |
| 1924 | 1924 | $score_possible += $row['exe_weighting']; |
| 1925 | - $questions_answered ++; |
|
| 1925 | + $questions_answered++; |
|
| 1926 | 1926 | } |
| 1927 | 1927 | |
| 1928 | 1928 | if ($score_possible != 0) { |
@@ -2043,9 +2043,9 @@ discard block |
||
| 2043 | 2043 | } |
| 2044 | 2044 | } |
| 2045 | 2045 | // time spent in the course |
| 2046 | - $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course ($user[4], $courseId)); |
|
| 2046 | + $csv_row[] = api_time_to_hms(Tracking::get_time_spent_on_the_course($user[4], $courseId)); |
|
| 2047 | 2047 | // student progress in course |
| 2048 | - $csv_row[] = round(Tracking::get_avg_student_progress ($user[4], $row[0]), 2); |
|
| 2048 | + $csv_row[] = round(Tracking::get_avg_student_progress($user[4], $row[0]), 2); |
|
| 2049 | 2049 | // student score |
| 2050 | 2050 | $csv_row[] = round(Tracking::get_avg_student_score($user[4], $row[0]), 2); |
| 2051 | 2051 | // student tes score |
@@ -2053,7 +2053,7 @@ discard block |
||
| 2053 | 2053 | // student messages |
| 2054 | 2054 | $csv_row[] = Tracking::count_student_messages($user[4], $row[0]); |
| 2055 | 2055 | // student assignments |
| 2056 | - $csv_row[] = Tracking::count_student_assignments ($user[4], $row[0]); |
|
| 2056 | + $csv_row[] = Tracking::count_student_assignments($user[4], $row[0]); |
|
| 2057 | 2057 | // student exercises results |
| 2058 | 2058 | $exercises_results = MySpace::exercises_results($user[4], $row[0]); |
| 2059 | 2059 | $csv_row[] = $exercises_results['score_obtained']; |
@@ -2061,7 +2061,7 @@ discard block |
||
| 2061 | 2061 | $csv_row[] = $exercises_results['questions_answered']; |
| 2062 | 2062 | $csv_row[] = $exercises_results['percentage']; |
| 2063 | 2063 | // first connection |
| 2064 | - $csv_row[] = Tracking::get_first_connection_date_on_the_course ($user[4], $courseId); |
|
| 2064 | + $csv_row[] = Tracking::get_first_connection_date_on_the_course($user[4], $courseId); |
|
| 2065 | 2065 | // last connection |
| 2066 | 2066 | $csv_row[] = strip_tags(Tracking::get_last_connection_date_on_the_course($user[4], $courseInfo)); |
| 2067 | 2067 | |
@@ -2095,9 +2095,9 @@ discard block |
||
| 2095 | 2095 | // get all courses with limit |
| 2096 | 2096 | $sql = "SELECT course.code as col1, course.title as col2 |
| 2097 | 2097 | FROM $tbl_course course |
| 2098 | - WHERE course.code IN (".implode(',',$courses_code).")"; |
|
| 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'))) $direction = 'ASC'; |
|
| 2101 | 2101 | |
| 2102 | 2102 | $column = intval($column); |
| 2103 | 2103 | $from = intval($from); |
@@ -2166,7 +2166,7 @@ discard block |
||
| 2166 | 2166 | $table_row[] = $avg_assignments_in_course; |
| 2167 | 2167 | |
| 2168 | 2168 | //set the "from" value to know if I access the Reporting by the chamilo tab or the course link |
| 2169 | - $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq=' .$course_code.'&from=myspace&id_session='.$session_id.'"> |
|
| 2169 | + $table_row[] = '<center><a href="../../tracking/courseLog.php?cidReq='.$course_code.'&from=myspace&id_session='.$session_id.'"> |
|
| 2170 | 2170 | <img src="'.api_get_path(WEB_IMG_PATH).'icons/22/2rightarrow.png" border="0" /></a> |
| 2171 | 2171 | </center>'; |
| 2172 | 2172 | $csv_content[] = array( |
@@ -2174,7 +2174,7 @@ discard block |
||
| 2174 | 2174 | $nb_students_in_course, |
| 2175 | 2175 | $avg_time_spent_in_course, |
| 2176 | 2176 | is_null($avg_progress_in_course) ? null : $avg_progress_in_course.'%', |
| 2177 | - is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course , |
|
| 2177 | + is_null($avg_score_in_course) ? null : is_numeric($avg_score_in_course) ? $avg_score_in_course.'%' : $avg_score_in_course, |
|
| 2178 | 2178 | is_null($avg_score_in_exercise) ? null : $avg_score_in_exercise.'%', |
| 2179 | 2179 | $avg_messages_in_course, |
| 2180 | 2180 | $avg_assignments_in_course, |
@@ -2242,7 +2242,7 @@ discard block |
||
| 2242 | 2242 | $sql .= " ORDER BY col$column $direction "; |
| 2243 | 2243 | $sql .= " LIMIT $from,$number_of_items"; |
| 2244 | 2244 | $result = Database::query($sql); |
| 2245 | - $return = array (); |
|
| 2245 | + $return = array(); |
|
| 2246 | 2246 | while ($user = Database::fetch_row($result)) { |
| 2247 | 2247 | $return[] = $user; |
| 2248 | 2248 | } |
@@ -2297,7 +2297,7 @@ discard block |
||
| 2297 | 2297 | $i++; |
| 2298 | 2298 | } |
| 2299 | 2299 | } |
| 2300 | - $username_array = array('username' => $desired_username , 'sufix' => $sufix); |
|
| 2300 | + $username_array = array('username' => $desired_username, 'sufix' => $sufix); |
|
| 2301 | 2301 | return $username_array; |
| 2302 | 2302 | } else { |
| 2303 | 2303 | $username_array = array('username' => $username, 'sufix' => ''); |
@@ -2571,7 +2571,7 @@ discard block |
||
| 2571 | 2571 | foreach ($users as $index => $user) { |
| 2572 | 2572 | $userid = $user['id']; |
| 2573 | 2573 | $sql_insert = "INSERT IGNORE INTO $tbl_session_rel_user(session_id, user_id, registered_at) |
| 2574 | - VALUES ('$id_session','$userid', '" . api_get_utc_datetime() . "')"; |
|
| 2574 | + VALUES ('$id_session','$userid', '".api_get_utc_datetime()."')"; |
|
| 2575 | 2575 | Database::query($sql_insert); |
| 2576 | 2576 | $user['added_at_session'] = 1; |
| 2577 | 2577 | $new_users[] = $user; |
@@ -2605,10 +2605,10 @@ discard block |
||
| 2605 | 2605 | ); |
| 2606 | 2606 | $userInfo = api_get_user_info($user['id']); |
| 2607 | 2607 | |
| 2608 | - if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { |
|
| 2608 | + if (($user['added_at_platform'] == 1 && $user['added_at_session'] == 1) || $user['added_at_session'] == 1) { |
|
| 2609 | 2609 | if ($user['added_at_platform'] == 1) { |
| 2610 | 2610 | $addedto = get_lang('UserCreatedPlatform'); |
| 2611 | - } else { |
|
| 2611 | + } else { |
|
| 2612 | 2612 | $addedto = ' '; |
| 2613 | 2613 | } |
| 2614 | 2614 | |
@@ -2671,7 +2671,7 @@ discard block |
||
| 2671 | 2671 | global $current_tag; |
| 2672 | 2672 | switch ($data) { |
| 2673 | 2673 | case 'Contact' : |
| 2674 | - $user = array (); |
|
| 2674 | + $user = array(); |
|
| 2675 | 2675 | break; |
| 2676 | 2676 | default : |
| 2677 | 2677 | $current_tag = $data; |
@@ -2718,9 +2718,9 @@ discard block |
||
| 2718 | 2718 | global $current_value; |
| 2719 | 2719 | global $user; |
| 2720 | 2720 | global $users; |
| 2721 | - $users = array (); |
|
| 2721 | + $users = array(); |
|
| 2722 | 2722 | $parser = xml_parser_create('UTF-8'); |
| 2723 | - xml_set_element_handler($parser, array('MySpace','element_start'), array('MySpace','element_end')); |
|
| 2723 | + xml_set_element_handler($parser, array('MySpace', 'element_start'), array('MySpace', 'element_end')); |
|
| 2724 | 2724 | xml_set_character_data_handler($parser, "character_data"); |
| 2725 | 2725 | xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, false); |
| 2726 | 2726 | xml_parse($parser, api_utf8_encode_xml(file_get_contents($file))); |
@@ -2766,7 +2766,7 @@ discard block |
||
| 2766 | 2766 | get_lang('SearchCourse'), |
| 2767 | 2767 | $courseList, |
| 2768 | 2768 | [ |
| 2769 | - 'url' => api_get_path(WEB_AJAX_PATH) . 'course.ajax.php?' . http_build_query([ |
|
| 2769 | + 'url' => api_get_path(WEB_AJAX_PATH).'course.ajax.php?'.http_build_query([ |
|
| 2770 | 2770 | 'a' => 'search_course_by_session_all', |
| 2771 | 2771 | 'session_id' => $sessionId |
| 2772 | 2772 | ]) |
@@ -2785,7 +2785,7 @@ discard block |
||
| 2785 | 2785 | course_id: $('#course_id').val() || 0 |
| 2786 | 2786 | }); |
| 2787 | 2787 | |
| 2788 | - return '" . api_get_path(WEB_AJAX_PATH) . "session.ajax.php?' + params; |
|
| 2788 | + return '" . api_get_path(WEB_AJAX_PATH)."session.ajax.php?' + params; |
|
| 2789 | 2789 | } |
| 2790 | 2790 | " |
| 2791 | 2791 | ] |
@@ -2816,7 +2816,7 @@ discard block |
||
| 2816 | 2816 | course_id: $('#course_id').val() |
| 2817 | 2817 | }); |
| 2818 | 2818 | |
| 2819 | - return '" . api_get_path(WEB_AJAX_PATH) . "course.ajax.php?' + params; |
|
| 2819 | + return '" . api_get_path(WEB_AJAX_PATH)."course.ajax.php?' + params; |
|
| 2820 | 2820 | } |
| 2821 | 2821 | " |
| 2822 | 2822 | ] |
@@ -2842,8 +2842,8 @@ discard block |
||
| 2842 | 2842 | if ($form->validate()) { |
| 2843 | 2843 | $table = new SortableTable( |
| 2844 | 2844 | 'tracking_access_overview', |
| 2845 | - ['MySpace','getNumberOfRrackingAccessOverview'], |
|
| 2846 | - ['MySpace','getUserDataAccessTrackingOverview'], |
|
| 2845 | + ['MySpace', 'getNumberOfRrackingAccessOverview'], |
|
| 2846 | + ['MySpace', 'getUserDataAccessTrackingOverview'], |
|
| 2847 | 2847 | 0 |
| 2848 | 2848 | ); |
| 2849 | 2849 | $table->additional_parameters = $form->exportValues(); |
@@ -2904,7 +2904,7 @@ discard block |
||
| 2904 | 2904 | " : " |
| 2905 | 2905 | u.lastname AS col2, |
| 2906 | 2906 | u.firstname AS col3, |
| 2907 | - " ) . " |
|
| 2907 | + " )." |
|
| 2908 | 2908 | a.logout_course_date, |
| 2909 | 2909 | c.title, |
| 2910 | 2910 | c.code, |
@@ -2915,7 +2915,7 @@ discard block |
||
| 2915 | 2915 | |
| 2916 | 2916 | if (isset($_GET['session_id']) && !empty($_GET['session_id'])) { |
| 2917 | 2917 | $sessionId = intval($_GET['session_id']); |
| 2918 | - $sql .= " WHERE a.session_id = " . $sessionId; |
|
| 2918 | + $sql .= " WHERE a.session_id = ".$sessionId; |
|
| 2919 | 2919 | } |
| 2920 | 2920 | |
| 2921 | 2921 | $sql .= " ORDER BY col$column $orderDirection "; |
@@ -2976,14 +2976,14 @@ discard block |
||
| 2976 | 2976 | function get_stats($user_id, $courseId, $start_date = null, $end_date = null) |
| 2977 | 2977 | { |
| 2978 | 2978 | // Database table definitions |
| 2979 | - $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
| 2979 | + $tbl_track_course = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); |
|
| 2980 | 2980 | |
| 2981 | 2981 | $course_info = api_get_course_info_by_id($courseId); |
| 2982 | 2982 | if (!empty($course_info)) { |
| 2983 | 2983 | $strg_sd = ""; |
| 2984 | 2984 | $strg_ed = ""; |
| 2985 | - if ($start_date != null && $end_date != null){ |
|
| 2986 | - $end_date = add_day_to( $end_date ); |
|
| 2985 | + if ($start_date != null && $end_date != null) { |
|
| 2986 | + $end_date = add_day_to($end_date); |
|
| 2987 | 2987 | $strg_sd = "AND login_course_date BETWEEN '$start_date' AND '$end_date'"; |
| 2988 | 2988 | $strg_ed = "AND logout_course_date BETWEEN '$start_date' AND '$end_date'"; |
| 2989 | 2989 | } |
@@ -2991,10 +2991,10 @@ discard block |
||
| 2991 | 2991 | SEC_TO_TIME(avg(time_to_sec(timediff(logout_course_date,login_course_date)))) as avrg, |
| 2992 | 2992 | SEC_TO_TIME(sum(time_to_sec(timediff(logout_course_date,login_course_date)))) as total, |
| 2993 | 2993 | count(user_id) as times |
| 2994 | - FROM ' . $tbl_track_course . ' |
|
| 2994 | + FROM ' . $tbl_track_course.' |
|
| 2995 | 2995 | WHERE |
| 2996 | - user_id = ' . intval($user_id) . ' AND |
|
| 2997 | - c_id = ' . intval($courseId) . ' '.$strg_sd.' '.$strg_ed.' '.' |
|
| 2996 | + user_id = ' . intval($user_id).' AND |
|
| 2997 | + c_id = ' . intval($courseId).' '.$strg_sd.' '.$strg_ed.' '.' |
|
| 2998 | 2998 | ORDER BY login_course_date ASC'; |
| 2999 | 2999 | |
| 3000 | 3000 | $rs = Database::query($sql); |
@@ -3012,7 +3012,7 @@ discard block |
||
| 3012 | 3012 | } |
| 3013 | 3013 | |
| 3014 | 3014 | function add_day_to($end_date) { |
| 3015 | - $foo_date = strtotime( $end_date ); |
|
| 3015 | + $foo_date = strtotime($end_date); |
|
| 3016 | 3016 | $foo_date = strtotime(" +1 day", $foo_date); |
| 3017 | 3017 | $foo_date = date("Y-m-d", $foo_date); |
| 3018 | 3018 | return $foo_date; |
@@ -3072,7 +3072,7 @@ discard block |
||
| 3072 | 3072 | * @version OCT-22- 2010 |
| 3073 | 3073 | * @return array |
| 3074 | 3074 | */ |
| 3075 | -function convert_to_array($sql_result){ |
|
| 3075 | +function convert_to_array($sql_result) { |
|
| 3076 | 3076 | $result_to_print = '<table>'; |
| 3077 | 3077 | foreach ($sql_result as $key => $data) { |
| 3078 | 3078 | $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"; |
@@ -3091,7 +3091,7 @@ discard block |
||
| 3091 | 3091 | * @version OCT-22- 2010 |
| 3092 | 3092 | * @return string |
| 3093 | 3093 | */ |
| 3094 | -function convert_to_string($sql_result){ |
|
| 3094 | +function convert_to_string($sql_result) { |
|
| 3095 | 3095 | $result_to_print = '<table>'; |
| 3096 | 3096 | if (!empty($sql_result)) { |
| 3097 | 3097 | foreach ($sql_result as $key => $data) { |
@@ -3116,18 +3116,18 @@ discard block |
||
| 3116 | 3116 | */ |
| 3117 | 3117 | function grapher($sql_result, $start_date, $end_date, $type = "") |
| 3118 | 3118 | { |
| 3119 | - if (empty($start_date)) { $start_date =""; } |
|
| 3120 | - if (empty($end_date)) { $end_date =""; } |
|
| 3121 | - if ($type == ""){ $type = 'day'; } |
|
| 3122 | - $main_year = $main_month_year = $main_day = array(); |
|
| 3119 | + if (empty($start_date)) { $start_date = ""; } |
|
| 3120 | + if (empty($end_date)) { $end_date = ""; } |
|
| 3121 | + if ($type == "") { $type = 'day'; } |
|
| 3122 | + $main_year = $main_month_year = $main_day = array(); |
|
| 3123 | 3123 | // get last 8 days/months |
| 3124 | 3124 | $last_days = 5; |
| 3125 | 3125 | $last_months = 3; |
| 3126 | 3126 | for ($i = $last_days; $i >= 0; $i--) { |
| 3127 | - $main_day[date ('d-m-Y', mktime () - $i * 3600 * 24)] = 0; |
|
| 3127 | + $main_day[date('d-m-Y', mktime() - $i * 3600 * 24)] = 0; |
|
| 3128 | 3128 | } |
| 3129 | 3129 | for ($i = $last_months; $i >= 0; $i--) { |
| 3130 | - $main_month_year[date ('m-Y', mktime () - $i * 30 * 3600 * 24)] = 0; |
|
| 3130 | + $main_month_year[date('m-Y', mktime() - $i * 30 * 3600 * 24)] = 0; |
|
| 3131 | 3131 | } |
| 3132 | 3132 | |
| 3133 | 3133 | $i = 0; |
@@ -3163,7 +3163,7 @@ discard block |
||
| 3163 | 3163 | /* Create and populate the pData object */ |
| 3164 | 3164 | $myData = new pData(); |
| 3165 | 3165 | $myData->addPoints($main_date, 'Serie1'); |
| 3166 | - if (count($main_date)!= 1) { |
|
| 3166 | + if (count($main_date) != 1) { |
|
| 3167 | 3167 | $myData->addPoints($labels, 'Labels'); |
| 3168 | 3168 | $myData->setSerieDescription('Labels', 'Months'); |
| 3169 | 3169 | $myData->setAbscissa('Labels'); |
@@ -3171,7 +3171,7 @@ discard block |
||
| 3171 | 3171 | $myData->setSerieWeight('Serie1', 1); |
| 3172 | 3172 | $myData->setSerieDescription('Serie1', get_lang('MyResults')); |
| 3173 | 3173 | $myData->setAxisName(0, get_lang('Minutes')); |
| 3174 | - $myData->loadPalette(api_get_path(SYS_CODE_PATH) . 'palettes/pchart/default.color', true); |
|
| 3174 | + $myData->loadPalette(api_get_path(SYS_CODE_PATH).'palettes/pchart/default.color', true); |
|
| 3175 | 3175 | |
| 3176 | 3176 | // Cache definition |
| 3177 | 3177 | $cachePath = api_get_path(SYS_ARCHIVE_PATH); |
@@ -3180,9 +3180,9 @@ discard block |
||
| 3180 | 3180 | |
| 3181 | 3181 | if ($myCache->isInCache($chartHash)) { |
| 3182 | 3182 | //if we already created the img |
| 3183 | - $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
| 3183 | + $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
| 3184 | 3184 | $myCache->saveFromCache($chartHash, $imgPath); |
| 3185 | - $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
| 3185 | + $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
| 3186 | 3186 | } else { |
| 3187 | 3187 | /* Define width, height and angle */ |
| 3188 | 3188 | $mainWidth = 760; |
@@ -3211,7 +3211,7 @@ discard block |
||
| 3211 | 3211 | /* Set the default font */ |
| 3212 | 3212 | $myPicture->setFontProperties( |
| 3213 | 3213 | array( |
| 3214 | - "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
| 3214 | + "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
| 3215 | 3215 | "FontSize" => 10) |
| 3216 | 3216 | ); |
| 3217 | 3217 | /* Write the chart title */ |
@@ -3228,7 +3228,7 @@ discard block |
||
| 3228 | 3228 | /* Set the default font */ |
| 3229 | 3229 | $myPicture->setFontProperties( |
| 3230 | 3230 | array( |
| 3231 | - "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
| 3231 | + "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
| 3232 | 3232 | "FontSize" => 8 |
| 3233 | 3233 | ) |
| 3234 | 3234 | ); |
@@ -3270,7 +3270,7 @@ discard block |
||
| 3270 | 3270 | /* Draw the line chart */ |
| 3271 | 3271 | $myPicture->setFontProperties( |
| 3272 | 3272 | array( |
| 3273 | - "FontName" => api_get_path(SYS_FONTS_PATH) . 'opensans/OpenSans-Regular.ttf', |
|
| 3273 | + "FontName" => api_get_path(SYS_FONTS_PATH).'opensans/OpenSans-Regular.ttf', |
|
| 3274 | 3274 | "FontSize" => 10 |
| 3275 | 3275 | ) |
| 3276 | 3276 | ); |
@@ -3289,15 +3289,15 @@ discard block |
||
| 3289 | 3289 | |
| 3290 | 3290 | /* Write and save into cache */ |
| 3291 | 3291 | $myCache->writeToCache($chartHash, $myPicture); |
| 3292 | - $imgPath = api_get_path(SYS_ARCHIVE_PATH) . $chartHash; |
|
| 3292 | + $imgPath = api_get_path(SYS_ARCHIVE_PATH).$chartHash; |
|
| 3293 | 3293 | $myCache->saveFromCache($chartHash, $imgPath); |
| 3294 | - $imgPath = api_get_path(WEB_ARCHIVE_PATH) . $chartHash; |
|
| 3294 | + $imgPath = api_get_path(WEB_ARCHIVE_PATH).$chartHash; |
|
| 3295 | 3295 | } |
| 3296 | - $html = '<img src="' . $imgPath . '">'; |
|
| 3296 | + $html = '<img src="'.$imgPath.'">'; |
|
| 3297 | 3297 | |
| 3298 | 3298 | return $html; |
| 3299 | 3299 | } else { |
| 3300 | - $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>','UTF-8'); |
|
| 3300 | + $foo_img = api_convert_encoding('<div id="messages" class="warning-message">'.get_lang('GraphicNotAvailable').'</div>', 'UTF-8'); |
|
| 3301 | 3301 | |
| 3302 | 3302 | return $foo_img; |
| 3303 | 3303 | } |
@@ -2097,7 +2097,9 @@ |
||
| 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); |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | - * @return bool |
|
| 41 | + * @return false|null |
|
| 42 | 42 | */ |
| 43 | 43 | public function create_user_folder() |
| 44 | 44 | { |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | ) { |
| 72 | 72 | mkdir($this->store_path.$this->session_id.'/'.$this->exercise_id.'/'.$this->question_id.'/'.$this->user_id, $directoryPermissions); |
| 73 | 73 | } |
| 74 | - } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * Setting parameters: course id, session id, etc |
@@ -119,24 +119,24 @@ discard block |
||
| 119 | 119 | $this->question_id = 0; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - $this->can_edit = false; |
|
| 122 | + $this->can_edit = false; |
|
| 123 | 123 | |
| 124 | - if (api_is_allowed_to_edit()) { |
|
| 125 | - $this->can_edit = true; |
|
| 126 | - } else { |
|
| 127 | - if ($this->user_id == api_get_user_id()) { |
|
| 128 | - $this->can_edit = true; |
|
| 129 | - } |
|
| 130 | - } |
|
| 124 | + if (api_is_allowed_to_edit()) { |
|
| 125 | + $this->can_edit = true; |
|
| 126 | + } else { |
|
| 127 | + if ($this->user_id == api_get_user_id()) { |
|
| 128 | + $this->can_edit = true; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - // Settings the params array |
|
| 133 | - $this->params = $params; |
|
| 134 | - $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
| 135 | - $this->create_user_folder(); |
|
| 136 | - $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
| 137 | - $this->filename = $this->generate_filename(); |
|
| 138 | - $this->store_filename = $this->store_path.$this->filename; |
|
| 139 | - } |
|
| 132 | + // Settings the params array |
|
| 133 | + $this->params = $params; |
|
| 134 | + $this->store_path = api_get_path(SYS_COURSE_PATH).$this->course_info['path'].'/exercises/'; |
|
| 135 | + $this->create_user_folder(); |
|
| 136 | + $this->store_path = $this->store_path.implode('/', array($this->session_id, $this->exercise_id, $this->question_id, $this->user_id)).'/'; |
|
| 137 | + $this->filename = $this->generate_filename(); |
|
| 138 | + $this->store_filename = $this->store_path.$this->filename; |
|
| 139 | + } |
|
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * Generates the filename with the next format: |
@@ -187,30 +187,30 @@ discard block |
||
| 187 | 187 | return $delete_found; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - /** |
|
| 191 | - * |
|
| 192 | - * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
| 190 | + /** |
|
| 191 | + * |
|
| 192 | + * Tricky stuff to deal with the feedback = 0 in exercises (all question per page) |
|
| 193 | 193 | * @param int $exe_id |
| 194 | - */ |
|
| 194 | + */ |
|
| 195 | 195 | public function replace_with_real_exe($exe_id) |
| 196 | 196 | { |
| 197 | - $filename = null; |
|
| 198 | - //@ugly fix |
|
| 199 | - foreach($this->available_extensions as $extension) { |
|
| 200 | - $items = explode('-', $this->filename); |
|
| 201 | - $items[5] = 'temp_exe'; |
|
| 202 | - $filename = implode('-', $items); |
|
| 203 | - if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
| 204 | - $old_name = $this->store_path.$filename.'.'.$extension; |
|
| 205 | - $items = explode('-', $this->filename); |
|
| 206 | - $items[5] = $exe_id; |
|
| 207 | - $filename = $filename = implode('-', $items); |
|
| 208 | - $new_name = $this->store_path.$filename.'.'.$extension; |
|
| 209 | - rename($old_name, $new_name); |
|
| 210 | - break; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - } |
|
| 197 | + $filename = null; |
|
| 198 | + //@ugly fix |
|
| 199 | + foreach($this->available_extensions as $extension) { |
|
| 200 | + $items = explode('-', $this->filename); |
|
| 201 | + $items[5] = 'temp_exe'; |
|
| 202 | + $filename = implode('-', $items); |
|
| 203 | + if (is_file($this->store_path.$filename.'.'.$extension)) { |
|
| 204 | + $old_name = $this->store_path.$filename.'.'.$extension; |
|
| 205 | + $items = explode('-', $this->filename); |
|
| 206 | + $items[5] = $exe_id; |
|
| 207 | + $filename = $filename = implode('-', $items); |
|
| 208 | + $new_name = $this->store_path.$filename.'.'.$extension; |
|
| 209 | + rename($old_name, $new_name); |
|
| 210 | + break; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | 216 | * @param bool $load_from_database |
@@ -218,24 +218,24 @@ discard block |
||
| 218 | 218 | */ |
| 219 | 219 | public function load_filename_if_exists($load_from_database = false) |
| 220 | 220 | { |
| 221 | - $filename = null; |
|
| 222 | - //@ugly fix |
|
| 223 | - foreach($this->available_extensions as $extension) { |
|
| 224 | - if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
| 225 | - $filename = $this->filename.'.'.$extension; |
|
| 226 | - break; |
|
| 227 | - } |
|
| 228 | - } |
|
| 221 | + $filename = null; |
|
| 222 | + //@ugly fix |
|
| 223 | + foreach($this->available_extensions as $extension) { |
|
| 224 | + if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
|
| 225 | + $filename = $this->filename.'.'.$extension; |
|
| 226 | + break; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - // temp_exe |
|
| 231 | - if ($load_from_database) { |
|
| 230 | + // temp_exe |
|
| 231 | + if ($load_from_database) { |
|
| 232 | 232 | |
| 233 | - //Load the real filename just if exists |
|
| 234 | - if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
| 233 | + //Load the real filename just if exists |
|
| 234 | + if (isset($this->params['exe_id']) && isset($this->params['user_id']) && |
|
| 235 | 235 | isset($this->params['question_id']) && isset($this->params['session_id']) && isset($this->params['course_id']) |
| 236 | 236 | ) { |
| 237 | - $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
| 238 | - $sql = "SELECT filename FROM $attempt_table |
|
| 237 | + $attempt_table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ATTEMPT); |
|
| 238 | + $sql = "SELECT filename FROM $attempt_table |
|
| 239 | 239 | WHERE |
| 240 | 240 | exe_id = ".$this->params['exe_id']." AND |
| 241 | 241 | user_id = ".$this->params['user_id']." AND |
@@ -243,107 +243,107 @@ discard block |
||
| 243 | 243 | session_id = ".$this->params['session_id']." AND |
| 244 | 244 | course_code = '".$this->course_info['code']."' |
| 245 | 245 | LIMIT 1"; |
| 246 | - $result = Database::query($sql); |
|
| 247 | - $result = Database::fetch_row($result,'ASSOC'); |
|
| 246 | + $result = Database::query($sql); |
|
| 247 | + $result = Database::fetch_row($result,'ASSOC'); |
|
| 248 | 248 | |
| 249 | - if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
| 250 | - $filename = $result[0]; |
|
| 251 | - } |
|
| 252 | - } |
|
| 253 | - } |
|
| 249 | + if (isset($result) && isset($result[0]) && !empty($result[0])) { |
|
| 250 | + $filename = $result[0]; |
|
| 251 | + } |
|
| 252 | + } |
|
| 253 | + } |
|
| 254 | 254 | |
| 255 | - if (is_file($this->store_path.$filename)) { |
|
| 256 | - return $this->store_path.$filename; |
|
| 257 | - } |
|
| 255 | + if (is_file($this->store_path.$filename)) { |
|
| 256 | + return $this->store_path.$filename; |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - return null; |
|
| 260 | - } |
|
| 259 | + return null; |
|
| 260 | + } |
|
| 261 | 261 | |
| 262 | - /** |
|
| 263 | - * |
|
| 264 | - * Get the URL of the file |
|
| 265 | - * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
| 262 | + /** |
|
| 263 | + * |
|
| 264 | + * Get the URL of the file |
|
| 265 | + * path courses/XXX/exercises/(session_id)/(exercise_id)/(question_id)/(user_id)/ |
|
| 266 | 266 | * @param int $force_download |
| 267 | - * |
|
| 268 | - * @return string |
|
| 269 | - */ |
|
| 267 | + * |
|
| 268 | + * @return string |
|
| 269 | + */ |
|
| 270 | 270 | public function get_public_url($force_download = 0) |
| 271 | 271 | { |
| 272 | - $params = $this->get_params(); |
|
| 273 | - $filename = basename($this->load_filename_if_exists()); |
|
| 272 | + $params = $this->get_params(); |
|
| 273 | + $filename = basename($this->load_filename_if_exists()); |
|
| 274 | 274 | $url = api_get_path(WEB_COURSE_PATH).$this->course_info['path'].'/exercises/'.$params['session_id'].'/'.$params['exercise_id'].'/'.$params['question_id'].'/'.$params['user_id'].'/'.$filename; |
| 275 | - return $url; |
|
| 276 | - } |
|
| 275 | + return $url; |
|
| 276 | + } |
|
| 277 | 277 | |
| 278 | - /** |
|
| 279 | - * Uploads the nanogong wav file |
|
| 278 | + /** |
|
| 279 | + * Uploads the nanogong wav file |
|
| 280 | 280 | * @param bool |
| 281 | - */ |
|
| 282 | - public function upload_file($is_nano = false) |
|
| 283 | - { |
|
| 284 | - if (!empty($_FILES)) { |
|
| 285 | - $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
| 286 | - |
|
| 287 | - if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
| 288 | - return 0; |
|
| 289 | - } |
|
| 281 | + */ |
|
| 282 | + public function upload_file($is_nano = false) |
|
| 283 | + { |
|
| 284 | + if (!empty($_FILES)) { |
|
| 285 | + $upload_ok = process_uploaded_file($_FILES['file'], false); |
|
| 290 | 286 | |
| 291 | - if ($upload_ok) { |
|
| 292 | - // Check if there is enough space to save the file |
|
| 293 | - if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
| 294 | - return 0; |
|
| 295 | - } |
|
| 287 | + if (!is_uploaded_file($_FILES['file']['tmp_name'])) { |
|
| 288 | + return 0; |
|
| 289 | + } |
|
| 296 | 290 | |
| 297 | - //first we delete everything before uploading the file |
|
| 298 | - $this->delete_files(); |
|
| 291 | + if ($upload_ok) { |
|
| 292 | + // Check if there is enough space to save the file |
|
| 293 | + if (!DocumentManager::enough_space($_FILES['file']['size'], DocumentManager::get_course_quota())) { |
|
| 294 | + return 0; |
|
| 295 | + } |
|
| 299 | 296 | |
| 300 | - //Reload the filename variable |
|
| 301 | - $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
| 302 | - $file_name = strtolower($file_name); |
|
| 303 | - $file_info = pathinfo($file_name); |
|
| 297 | + //first we delete everything before uploading the file |
|
| 298 | + $this->delete_files(); |
|
| 304 | 299 | |
| 305 | - if ($is_nano == true) { |
|
| 306 | - $file_info['extension'] = 'wav'; |
|
| 307 | - } |
|
| 300 | + //Reload the filename variable |
|
| 301 | + $file_name = add_ext_on_mime($_FILES['file']['name'], $_FILES['file']['type']); |
|
| 302 | + $file_name = strtolower($file_name); |
|
| 303 | + $file_info = pathinfo($file_name); |
|
| 308 | 304 | |
| 309 | - $file_name = $this->filename.'.'.$file_info['extension']; |
|
| 305 | + if ($is_nano == true) { |
|
| 306 | + $file_info['extension'] = 'wav'; |
|
| 307 | + } |
|
| 310 | 308 | |
| 311 | - if (in_array($file_info['extension'], $this->available_extensions)) { |
|
| 312 | - if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
| 313 | - $this->store_filename = $this->store_path.$file_name; |
|
| 314 | - return 1; |
|
| 315 | - } |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - } |
|
| 309 | + $file_name = $this->filename.'.'.$file_info['extension']; |
|
| 310 | + |
|
| 311 | + if (in_array($file_info['extension'], $this->available_extensions)) { |
|
| 312 | + if (move_uploaded_file($_FILES['file']['tmp_name'], $this->store_path.$file_name)) { |
|
| 313 | + $this->store_filename = $this->store_path.$file_name; |
|
| 314 | + return 1; |
|
| 315 | + } |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - return 0; |
|
| 321 | - } |
|
| 320 | + return 0; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * Show the audio file + a button to download |
|
| 323 | + /** |
|
| 324 | + * Show the audio file + a button to download |
|
| 325 | 325 | * @param bool |
| 326 | - */ |
|
| 327 | - public function show_audio_file($show_delete_button = false) |
|
| 328 | - { |
|
| 329 | - $html = ''; |
|
| 330 | - $file_path = $this->load_filename_if_exists(); |
|
| 331 | - |
|
| 332 | - if (!empty($file_path)) { |
|
| 333 | - $url = $this->get_public_url(true); |
|
| 334 | - $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
| 335 | - $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
| 336 | - |
|
| 337 | - if ($show_delete_button) { |
|
| 338 | - $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
| 339 | - } |
|
| 326 | + */ |
|
| 327 | + public function show_audio_file($show_delete_button = false) |
|
| 328 | + { |
|
| 329 | + $html = ''; |
|
| 330 | + $file_path = $this->load_filename_if_exists(); |
|
| 331 | + |
|
| 332 | + if (!empty($file_path)) { |
|
| 333 | + $url = $this->get_public_url(true); |
|
| 334 | + $actions = Display::url(Display::return_icon('save.png', get_lang('Download'), array(), ICON_SIZE_SMALL), $url, array('target'=>'_blank')); |
|
| 335 | + $download_button = Display::url(get_lang('Download'), $url, array('class' =>'btn btn-default')); |
|
| 340 | 336 | |
| 341 | - $basename = basename($file_path); |
|
| 342 | - $path_info = pathinfo($basename); |
|
| 337 | + if ($show_delete_button) { |
|
| 338 | + $actions .= ' '.Display::url(Display::return_icon('delete.png', get_lang('Delete'), array(), ICON_SIZE_SMALL), "#", array('onclick'=>'delete_file();')); |
|
| 339 | + } |
|
| 343 | 340 | |
| 344 | - if ($path_info['extension'] == 'wav') { |
|
| 341 | + $basename = basename($file_path); |
|
| 342 | + $path_info = pathinfo($basename); |
|
| 345 | 343 | |
| 346 | - $html .= '<script> |
|
| 344 | + if ($path_info['extension'] == 'wav') { |
|
| 345 | + |
|
| 346 | + $html .= '<script> |
|
| 347 | 347 | $(document).ready( function() { |
| 348 | 348 | var java_enabled = navigator.javaEnabled(); |
| 349 | 349 | |
@@ -357,56 +357,56 @@ discard block |
||
| 357 | 357 | }); |
| 358 | 358 | </script>'; |
| 359 | 359 | |
| 360 | - $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
| 361 | - $html .= '<div class="action_player">'.$actions.'</div>'; |
|
| 362 | - $html .= '<div class="nanogong_player">'; |
|
| 363 | - $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
| 364 | - $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
| 365 | - $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
| 366 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
| 367 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
| 368 | - $html .= '<param name="Color" value="#FFFFFF" />'; |
|
| 360 | + $html .= '<div id="nanogong_player_id" class="nanogong_player_container">'; |
|
| 361 | + $html .= '<div class="action_player">'.$actions.'</div>'; |
|
| 362 | + $html .= '<div class="nanogong_player">'; |
|
| 363 | + $html .= '<applet id="nanogong_player" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" ALIGN="middle">'; |
|
| 364 | + $html .= '<param name="ShowRecordButton" value="false" />'; // default true |
|
| 365 | + $html .= '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
| 366 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
| 367 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
| 368 | + $html .= '<param name="Color" value="#FFFFFF" />'; |
|
| 369 | 369 | $html .= '<param name="ShowSpeedButton" value="false" />'; |
| 370 | - //echo '<param name="StartTime" value="10.5" />'; |
|
| 371 | - //echo '<param name="EndTime" value="65" />'; |
|
| 372 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 373 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 374 | - //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
| 375 | - //echo '<param name="SamplingRate" value="32000" />'; |
|
| 376 | - //echo '<param name="MaxDuration" value="60" />'; |
|
| 377 | - $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
| 378 | - $html .= '</applet>'; |
|
| 379 | - $html .= '</div>'; |
|
| 380 | - $html .= '</div>'; |
|
| 370 | + //echo '<param name="StartTime" value="10.5" />'; |
|
| 371 | + //echo '<param name="EndTime" value="65" />'; |
|
| 372 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 373 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 374 | + //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
| 375 | + //echo '<param name="SamplingRate" value="32000" />'; |
|
| 376 | + //echo '<param name="MaxDuration" value="60" />'; |
|
| 377 | + $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
| 378 | + $html .= '</applet>'; |
|
| 379 | + $html .= '</div>'; |
|
| 380 | + $html .= '</div>'; |
|
| 381 | 381 | $html .= '<div id="nanogong_warning">'.Display::return_message(get_lang('BrowserDoesNotSupportNanogongPlayer'), 'warning').$download_button.'</div>'; |
| 382 | 382 | |
| 383 | - } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
| 384 | - $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
| 385 | - $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
| 386 | - $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
| 383 | + } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
| 384 | + $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
|
| 385 | + $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
|
| 386 | + $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
|
| 387 | 387 | |
| 388 | - $html .= '<div class="nanogong_player"></div>'; |
|
| 389 | - $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
| 388 | + $html .= '<div class="nanogong_player"></div>'; |
|
| 389 | + $html .= '<br /><div class="action_player">'.$actions.'</div><br /><br /><br />'; |
|
| 390 | 390 | |
| 391 | 391 | $params = array( |
| 392 | 392 | 'url' => $url, |
| 393 | 393 | 'extension' =>$path_info['extension'], |
| 394 | 394 | 'count'=> 1 |
| 395 | - ); |
|
| 395 | + ); |
|
| 396 | 396 | $jquery = DocumentManager::generate_jplayer_jquery($params); |
| 397 | - $html .= '<script> |
|
| 397 | + $html .= '<script> |
|
| 398 | 398 | $(document).ready( function() { |
| 399 | 399 | //Experimental changes to preview mp3, ogg files |
| 400 | 400 | '.$jquery.' |
| 401 | 401 | }); |
| 402 | 402 | </script>'; |
| 403 | - $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
| 404 | - } |
|
| 405 | - } |
|
| 403 | + $html .= DocumentManager::generate_media_preview(1, 'advanced'); |
|
| 404 | + } |
|
| 405 | + } |
|
| 406 | 406 | return $html; |
| 407 | - } |
|
| 407 | + } |
|
| 408 | 408 | |
| 409 | - /* |
|
| 409 | + /* |
|
| 410 | 410 | var filename = document.getElementById("audio_title").value+".wav"; |
| 411 | 411 | var filename = filename.replace(/\s/g, "_");//replace spaces by _ |
| 412 | 412 | var filename = encodeURIComponent(filename); |
@@ -416,19 +416,19 @@ discard block |
||
| 416 | 416 | var urlnanogong="'.$url.'?filename="+filename+"&filepath="+filepath+"&dir="+dir+"&course_code="+course_code; |
| 417 | 417 | */ |
| 418 | 418 | |
| 419 | - /** |
|
| 420 | - * Returns the nanogong javascript code |
|
| 421 | - * @return string |
|
| 422 | - */ |
|
| 419 | + /** |
|
| 420 | + * Returns the nanogong javascript code |
|
| 421 | + * @return string |
|
| 422 | + */ |
|
| 423 | 423 | public function return_js() |
| 424 | 424 | { |
| 425 | - $params = $this->get_params(true); |
|
| 426 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
| 427 | - $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
| 425 | + $params = $this->get_params(true); |
|
| 426 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params.'&is_nano=1'; |
|
| 427 | + $url_load_file = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=show_audio&'.$params; |
|
| 428 | 428 | |
| 429 | - $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
| 429 | + $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
|
| 430 | 430 | |
| 431 | - $js = '<script language="javascript"> |
|
| 431 | + $js = '<script language="javascript"> |
|
| 432 | 432 | |
| 433 | 433 | //lang vars |
| 434 | 434 | |
@@ -544,77 +544,77 @@ discard block |
||
| 544 | 544 | return false; |
| 545 | 545 | } |
| 546 | 546 | </script>'; |
| 547 | - return $js; |
|
| 548 | - } |
|
| 547 | + return $js; |
|
| 548 | + } |
|
| 549 | 549 | |
| 550 | - /** |
|
| 551 | - * Returns the HTML form to upload a nano file or upload a file |
|
| 550 | + /** |
|
| 551 | + * Returns the HTML form to upload a nano file or upload a file |
|
| 552 | 552 | * @param string |
| 553 | - */ |
|
| 554 | - public function return_form($message = null) |
|
| 553 | + */ |
|
| 554 | + public function return_form($message = null) |
|
| 555 | 555 | { |
| 556 | 556 | |
| 557 | - $params = $this->get_params(true); |
|
| 558 | - $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
| 557 | + $params = $this->get_params(true); |
|
| 558 | + $url = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=save_file&'.$params; |
|
| 559 | 559 | |
| 560 | - //check browser support and load form |
|
| 561 | - $array_browser = api_browser_support('check_browser'); |
|
| 560 | + //check browser support and load form |
|
| 561 | + $array_browser = api_browser_support('check_browser'); |
|
| 562 | 562 | |
| 563 | - $preview_file = $this->show_audio_file(true, true); |
|
| 563 | + $preview_file = $this->show_audio_file(true, true); |
|
| 564 | 564 | |
| 565 | 565 | $preview_file = Display::div( |
| 566 | 566 | $preview_file, |
| 567 | 567 | array('id' => 'preview', 'style' => 'text-align:center; padding-left: 25px;') |
| 568 | 568 | ); |
| 569 | 569 | |
| 570 | - $html = '<center>'; |
|
| 570 | + $html = '<center>'; |
|
| 571 | 571 | |
| 572 | - //Use normal upload file |
|
| 573 | - $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
| 574 | - $html .='<br />'; |
|
| 572 | + //Use normal upload file |
|
| 573 | + $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
| 574 | + $html .='<br />'; |
|
| 575 | 575 | |
| 576 | - $html .= '<div id="nanogong_div">'; |
|
| 576 | + $html .= '<div id="nanogong_div">'; |
|
| 577 | 577 | |
| 578 | - $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
| 579 | - //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
| 580 | - // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
| 578 | + $html .= '<applet id="nanogong" archive="'.api_get_path(WEB_LIBRARY_PATH).'nanogong/nanogong.jar" code="gong.NanoGong" width="250" height="95" align="middle">'; |
|
| 579 | + //echo '<param name="ShowRecordButton" value="false" />'; // default true |
|
| 580 | + // echo '<param name="ShowSaveButton" value="false" />'; //you can save in local computer | (default true) |
|
| 581 | 581 | $html .= '<param name="ShowSpeedButton" value="false" />'; // default true |
| 582 | - //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
| 583 | - $html .= '<param name="ShowTime" value="true" />'; // default false |
|
| 584 | - $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
| 585 | - //echo '<param name="StartTime" value="10.5" />'; |
|
| 586 | - //echo '<param name="EndTime" value="65" />'; |
|
| 587 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 588 | - //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 582 | + //echo '<param name="ShowAudioLevel" value="false" />'; // it displays the audiometer | (default true) |
|
| 583 | + $html .= '<param name="ShowTime" value="true" />'; // default false |
|
| 584 | + $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
|
| 585 | + //echo '<param name="StartTime" value="10.5" />'; |
|
| 586 | + //echo '<param name="EndTime" value="65" />'; |
|
| 587 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 588 | + //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 589 | 589 | |
| 590 | - //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
| 591 | - //echo '<param name="MaxDuration" value="60" />'; |
|
| 592 | - //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
| 593 | - $html .= '</applet>'; |
|
| 590 | + //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
|
| 591 | + //echo '<param name="MaxDuration" value="60" />'; |
|
| 592 | + //echo '<param name="SoundFileURL" value="http://somewhere.com/mysoundfile.wav" />';//load a file |(default "") |
|
| 593 | + $html .= '</applet>'; |
|
| 594 | 594 | |
| 595 | - $html .= '<br /><br /><br />'; |
|
| 595 | + $html .= '<br /><br /><br />'; |
|
| 596 | 596 | |
| 597 | 597 | $html .= '<form name="form_nanogong_advanced">'; |
| 598 | - $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
| 599 | - $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
| 600 | - $html .= '</form></div>'; |
|
| 598 | + $html .= '<input type="hidden" name="is_nano" value="1">'; |
|
| 599 | + $html .= '<a href="#" class="btn btn-default" onclick="send_voice()" />'.get_lang('SendRecord').'</a>'; |
|
| 600 | + $html .= '</form></div>'; |
|
| 601 | 601 | |
| 602 | 602 | $html .= Display::url(get_lang('ProblemsRecordingUploadYourOwnAudioFile'), 'javascript:void(0)', array('onclick' => 'show_simple_upload_form();')); |
| 603 | 603 | |
| 604 | - $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
| 605 | - //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
| 606 | - $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
| 607 | - $html .= '<input type="file" name="file">'; |
|
| 608 | - $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
| 609 | - $html .= '</form>'; |
|
| 604 | + $html .= '<br /><br /><div id="no_nanogong_div">'; |
|
| 605 | + //$html .= Display::return_message(get_lang('BrowserNotSupportNanogongSend'), 'warning'); |
|
| 606 | + $html .= '<form id="form_nanogong_simple" class="form-search" action="'.$url.'" name="form_nanogong" method="POST" enctype="multipart/form-data">'; |
|
| 607 | + $html .= '<input type="file" name="file">'; |
|
| 608 | + $html .= '<a href="#" class="btn btn-default" onclick="upload_file()" /><em class="fa fa-upload"></em> '.get_lang('UploadFile').'</a>'; |
|
| 609 | + $html .= '</form>'; |
|
| 610 | 610 | $html .= '</div>'; |
| 611 | - $html .= '</center>'; |
|
| 612 | - $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
| 613 | - $html .= '<div id="messages">'.$message.'</div>'; |
|
| 614 | - $html .= $preview_file; |
|
| 611 | + $html .= '</center>'; |
|
| 612 | + $html .= '<div style="display:none" id="status_ok" class="confirmation-message"></div><div style="display:none" id="status_warning" class="warning-message"></div>'; |
|
| 613 | + $html .= '<div id="messages">'.$message.'</div>'; |
|
| 614 | + $html .= $preview_file; |
|
| 615 | 615 | |
| 616 | - return $html; |
|
| 617 | - } |
|
| 616 | + return $html; |
|
| 617 | + } |
|
| 618 | 618 | |
| 619 | 619 | /** |
| 620 | 620 | * @param bool $return_as_query |
@@ -622,15 +622,15 @@ discard block |
||
| 622 | 622 | */ |
| 623 | 623 | public function get_params($return_as_query = false) |
| 624 | 624 | { |
| 625 | - if (empty($this->params)) { |
|
| 626 | - return false; |
|
| 627 | - } |
|
| 628 | - if ($return_as_query) { |
|
| 629 | - return http_build_query($this->params); |
|
| 630 | - } |
|
| 625 | + if (empty($this->params)) { |
|
| 626 | + return false; |
|
| 627 | + } |
|
| 628 | + if ($return_as_query) { |
|
| 629 | + return http_build_query($this->params); |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - return $this->params; |
|
| 633 | - } |
|
| 632 | + return $this->params; |
|
| 633 | + } |
|
| 634 | 634 | |
| 635 | 635 | /** |
| 636 | 636 | * @param $attribute |
@@ -638,18 +638,18 @@ discard block |
||
| 638 | 638 | */ |
| 639 | 639 | public function get_param_value($attribute) |
| 640 | 640 | { |
| 641 | - if (isset($this->params[$attribute])) { |
|
| 642 | - return $this->params[$attribute]; |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - |
|
| 646 | - /** |
|
| 647 | - * Show a button to load the form |
|
| 648 | - * @return string |
|
| 649 | - */ |
|
| 641 | + if (isset($this->params[$attribute])) { |
|
| 642 | + return $this->params[$attribute]; |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + |
|
| 646 | + /** |
|
| 647 | + * Show a button to load the form |
|
| 648 | + * @return string |
|
| 649 | + */ |
|
| 650 | 650 | public function show_button() |
| 651 | 651 | { |
| 652 | - $params_string = $this->get_params(true); |
|
| 652 | + $params_string = $this->get_params(true); |
|
| 653 | 653 | |
| 654 | 654 | $url = api_get_path(WEB_AJAX_PATH) |
| 655 | 655 | . 'nanogong.ajax.php?a=show_form&' |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | 'data-title' => get_lang('RecordAnswer') |
| 665 | 665 | ] |
| 666 | 666 | ); |
| 667 | - $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
| 668 | - return $html; |
|
| 669 | - } |
|
| 667 | + $html .= '<br /><br />'.Display::return_message(get_lang('UseTheMessageBelowToAddSomeComments')); |
|
| 668 | + return $html; |
|
| 669 | + } |
|
| 670 | 670 | } |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | if (api_is_allowed_to_edit()) { |
| 125 | 125 | $this->can_edit = true; |
| 126 | 126 | } else { |
| 127 | - if ($this->user_id == api_get_user_id()) { |
|
| 127 | + if ($this->user_id == api_get_user_id()) { |
|
| 128 | 128 | $this->can_edit = true; |
| 129 | 129 | } |
| 130 | 130 | } |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | { |
| 197 | 197 | $filename = null; |
| 198 | 198 | //@ugly fix |
| 199 | - foreach($this->available_extensions as $extension) { |
|
| 199 | + foreach ($this->available_extensions as $extension) { |
|
| 200 | 200 | $items = explode('-', $this->filename); |
| 201 | 201 | $items[5] = 'temp_exe'; |
| 202 | 202 | $filename = implode('-', $items); |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | { |
| 221 | 221 | $filename = null; |
| 222 | 222 | //@ugly fix |
| 223 | - foreach($this->available_extensions as $extension) { |
|
| 223 | + foreach ($this->available_extensions as $extension) { |
|
| 224 | 224 | if (is_file($this->store_path.$this->filename.'.'.$extension)) { |
| 225 | 225 | $filename = $this->filename.'.'.$extension; |
| 226 | 226 | break; |
@@ -244,7 +244,7 @@ discard block |
||
| 244 | 244 | course_code = '".$this->course_info['code']."' |
| 245 | 245 | LIMIT 1"; |
| 246 | 246 | $result = Database::query($sql); |
| 247 | - $result = Database::fetch_row($result,'ASSOC'); |
|
| 247 | + $result = Database::fetch_row($result, 'ASSOC'); |
|
| 248 | 248 | |
| 249 | 249 | if (isset($result) && isset($result[0]) && !empty($result[0])) { |
| 250 | 250 | $filename = $result[0]; |
@@ -369,18 +369,18 @@ discard block |
||
| 369 | 369 | $html .= '<param name="ShowSpeedButton" value="false" />'; |
| 370 | 370 | //echo '<param name="StartTime" value="10.5" />'; |
| 371 | 371 | //echo '<param name="EndTime" value="65" />'; |
| 372 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 372 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />'; // ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 373 | 373 | //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
| 374 | 374 | //Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
| 375 | 375 | //echo '<param name="SamplingRate" value="32000" />'; |
| 376 | 376 | //echo '<param name="MaxDuration" value="60" />'; |
| 377 | - $html .= '<param name="SoundFileURL" value="'.$url.'" />';//load a file |(default "") |
|
| 377 | + $html .= '<param name="SoundFileURL" value="'.$url.'" />'; //load a file |(default "") |
|
| 378 | 378 | $html .= '</applet>'; |
| 379 | 379 | $html .= '</div>'; |
| 380 | 380 | $html .= '</div>'; |
| 381 | 381 | $html .= '<div id="nanogong_warning">'.Display::return_message(get_lang('BrowserDoesNotSupportNanogongPlayer'), 'warning').$download_button.'</div>'; |
| 382 | 382 | |
| 383 | - } elseif(in_array($path_info['extension'],array('mp3', 'ogg','wav'))) { |
|
| 383 | + } elseif (in_array($path_info['extension'], array('mp3', 'ogg', 'wav'))) { |
|
| 384 | 384 | $js_path = api_get_path(WEB_LIBRARY_PATH).'javascript/'; |
| 385 | 385 | $html .= '<link rel="stylesheet" href="'.$js_path.'jquery-jplayer/skin/blue.monday/css/jplayer.blue.monday.css" type="text/css">'; |
| 386 | 386 | $html .= '<script type="text/javascript" src="'.$js_path.'jquery-jplayer/jplayer/jquery.jplayer.min.js"></script>'; |
@@ -428,7 +428,7 @@ discard block |
||
| 428 | 428 | |
| 429 | 429 | $url_delete = api_get_path(WEB_AJAX_PATH).'nanogong.ajax.php?a=delete&'.$params; |
| 430 | 430 | |
| 431 | - $js = '<script language="javascript"> |
|
| 431 | + $js = '<script language="javascript"> |
|
| 432 | 432 | |
| 433 | 433 | //lang vars |
| 434 | 434 | |
@@ -570,8 +570,8 @@ discard block |
||
| 570 | 570 | $html = '<center>'; |
| 571 | 571 | |
| 572 | 572 | //Use normal upload file |
| 573 | - $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'),'', ICON_SIZE_BIG); |
|
| 574 | - $html .='<br />'; |
|
| 573 | + $html .= Display::return_icon('microphone.png', get_lang('PressRecordButton'), '', ICON_SIZE_BIG); |
|
| 574 | + $html .= '<br />'; |
|
| 575 | 575 | |
| 576 | 576 | $html .= '<div id="nanogong_div">'; |
| 577 | 577 | |
@@ -584,7 +584,7 @@ discard block |
||
| 584 | 584 | $html .= '<param name="Color" value="#FFFFFF" />'; // default #FFFFFF |
| 585 | 585 | //echo '<param name="StartTime" value="10.5" />'; |
| 586 | 586 | //echo '<param name="EndTime" value="65" />'; |
| 587 | - $html .= '<param name="AudioFormat" value="ImaADPCM" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 587 | + $html .= '<param name="AudioFormat" value="ImaADPCM" />'; // ImaADPCM (more speed), Speex (more compression)|(default Speex) |
|
| 588 | 588 | //$html .= '<param name="AudioFormat" value="Speex" />';// ImaADPCM (more speed), Speex (more compression)|(default Speex) |
| 589 | 589 | |
| 590 | 590 | //echo '<param name="SamplingRate" value="32000" />';//Quality for ImaADPCM (low 8000, medium 11025, normal 22050, hight 44100) OR Quality for Speex (low 8000, medium 16000, normal 32000, hight 44100) | (default 44100) |
@@ -219,7 +219,7 @@ |
||
| 219 | 219 | * @param array $user_list recipients: user list of ids |
| 220 | 220 | * @param string $title |
| 221 | 221 | * @param string $content |
| 222 | - * @param array $sender_info |
|
| 222 | + * @param array $senderInfo |
|
| 223 | 223 | * result of api_get_user_info() or GroupPortalManager:get_group_data() |
| 224 | 224 | */ |
| 225 | 225 | public function save_notification( |
@@ -355,7 +355,7 @@ discard block |
||
| 355 | 355 | $newMessageText = ''; |
| 356 | 356 | $linkToNewMessage = Display::url( |
| 357 | 357 | get_lang('SeeMessage'), |
| 358 | - api_get_path(WEB_CODE_PATH) . 'messages/inbox.php' |
|
| 358 | + api_get_path(WEB_CODE_PATH).'messages/inbox.php' |
|
| 359 | 359 | ); |
| 360 | 360 | break; |
| 361 | 361 | case self::NOTIFICATION_TYPE_MESSAGE: |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | } |
| 371 | 371 | $linkToNewMessage = Display::url( |
| 372 | 372 | get_lang('SeeMessage'), |
| 373 | - api_get_path(WEB_CODE_PATH) . 'messages/inbox.php' |
|
| 373 | + api_get_path(WEB_CODE_PATH).'messages/inbox.php' |
|
| 374 | 374 | ); |
| 375 | 375 | break; |
| 376 | 376 | case self::NOTIFICATION_TYPE_INVITATION: |
@@ -385,7 +385,7 @@ discard block |
||
| 385 | 385 | } |
| 386 | 386 | $linkToNewMessage = Display::url( |
| 387 | 387 | get_lang('SeeInvitation'), |
| 388 | - api_get_path(WEB_CODE_PATH) . 'social/invitations.php' |
|
| 388 | + api_get_path(WEB_CODE_PATH).'social/invitations.php' |
|
| 389 | 389 | ); |
| 390 | 390 | break; |
| 391 | 391 | case self::NOTIFICATION_TYPE_GROUP: |
@@ -306,7 +306,7 @@ discard block |
||
| 306 | 306 | /** |
| 307 | 307 | * gets the current debug data for this instance |
| 308 | 308 | * |
| 309 | - * @return debug data |
|
| 309 | + * @return string data |
|
| 310 | 310 | * @access public |
| 311 | 311 | */ |
| 312 | 312 | function &getDebug() {
|
@@ -319,7 +319,7 @@ discard block |
||
| 319 | 319 | * gets the current debug data for this instance as an XML comment |
| 320 | 320 | * this may change the contents of the debug data |
| 321 | 321 | * |
| 322 | - * @return debug data as an XML comment |
|
| 322 | + * @return string data as an XML comment |
|
| 323 | 323 | * @access public |
| 324 | 324 | */ |
| 325 | 325 | function &getDebugAsXMLComment() {
|
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | /** |
| 353 | 353 | * returns error string if present |
| 354 | 354 | * |
| 355 | - * @return mixed error string or false |
|
| 355 | + * @return string|false error string or false |
|
| 356 | 356 | * @access public |
| 357 | 357 | */ |
| 358 | 358 | function getError(){
|
@@ -365,7 +365,7 @@ discard block |
||
| 365 | 365 | /** |
| 366 | 366 | * sets error string |
| 367 | 367 | * |
| 368 | - * @return boolean $string error string |
|
| 368 | + * @return boolean|null $string error string |
|
| 369 | 369 | * @access private |
| 370 | 370 | */ |
| 371 | 371 | function setError($str){
|
@@ -801,7 +801,7 @@ discard block |
||
| 801 | 801 | * returns false, if not prefixed |
| 802 | 802 | * |
| 803 | 803 | * @param string $str The prefixed string |
| 804 | - * @return mixed The prefix or false if there is no prefix |
|
| 804 | + * @return string|false The prefix or false if there is no prefix |
|
| 805 | 805 | * @access public |
| 806 | 806 | */ |
| 807 | 807 | function getPrefix($str){
|
@@ -832,7 +832,7 @@ discard block |
||
| 832 | 832 | * or false if no prefixes registered for the given namespace |
| 833 | 833 | * |
| 834 | 834 | * @param string $ns The namespace |
| 835 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
| 835 | + * @return string The prefix, false if the namespace has no prefixes |
|
| 836 | 836 | * @access public |
| 837 | 837 | */ |
| 838 | 838 | function getPrefixFromNamespace($ns) {
|
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | * |
| 899 | 899 | * @param int $timestamp Unix time stamp |
| 900 | 900 | * @param boolean $utc Whether the time stamp is UTC or local |
| 901 | -* @return mixed ISO 8601 date string or false |
|
| 901 | +* @return string|false ISO 8601 date string or false |
|
| 902 | 902 | * @access public |
| 903 | 903 | */ |
| 904 | 904 | function timestamp_to_iso8601($timestamp,$utc=true){
|
@@ -83,810 +83,810 @@ discard block |
||
| 83 | 83 | * @access public |
| 84 | 84 | */ |
| 85 | 85 | class nusoap_base {
|
| 86 | - /** |
|
| 87 | - * Identification for HTTP headers. |
|
| 88 | - * |
|
| 89 | - * @var string |
|
| 90 | - * @access private |
|
| 91 | - */ |
|
| 92 | - var $title = 'NuSOAP'; |
|
| 93 | - /** |
|
| 94 | - * Version for HTTP headers. |
|
| 95 | - * |
|
| 96 | - * @var string |
|
| 97 | - * @access private |
|
| 98 | - */ |
|
| 99 | - var $version = '0.9.5'; |
|
| 100 | - /** |
|
| 101 | - * CVS revision for HTTP headers. |
|
| 102 | - * |
|
| 103 | - * @var string |
|
| 104 | - * @access private |
|
| 105 | - */ |
|
| 106 | - var $revision = '$Revision: 1.56 $'; |
|
| 86 | + /** |
|
| 87 | + * Identification for HTTP headers. |
|
| 88 | + * |
|
| 89 | + * @var string |
|
| 90 | + * @access private |
|
| 91 | + */ |
|
| 92 | + var $title = 'NuSOAP'; |
|
| 93 | + /** |
|
| 94 | + * Version for HTTP headers. |
|
| 95 | + * |
|
| 96 | + * @var string |
|
| 97 | + * @access private |
|
| 98 | + */ |
|
| 99 | + var $version = '0.9.5'; |
|
| 100 | + /** |
|
| 101 | + * CVS revision for HTTP headers. |
|
| 102 | + * |
|
| 103 | + * @var string |
|
| 104 | + * @access private |
|
| 105 | + */ |
|
| 106 | + var $revision = '$Revision: 1.56 $'; |
|
| 107 | 107 | /** |
| 108 | 108 | * Current error string (manipulated by getError/setError) |
| 109 | - * |
|
| 110 | - * @var string |
|
| 111 | - * @access private |
|
| 112 | - */ |
|
| 113 | - var $error_str = ''; |
|
| 109 | + * |
|
| 110 | + * @var string |
|
| 111 | + * @access private |
|
| 112 | + */ |
|
| 113 | + var $error_str = ''; |
|
| 114 | 114 | /** |
| 115 | 115 | * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
| 116 | - * |
|
| 117 | - * @var string |
|
| 118 | - * @access private |
|
| 119 | - */ |
|
| 116 | + * |
|
| 117 | + * @var string |
|
| 118 | + * @access private |
|
| 119 | + */ |
|
| 120 | 120 | var $debug_str = ''; |
| 121 | 121 | /** |
| 122 | - * toggles automatic encoding of special characters as entities |
|
| 123 | - * (should always be true, I think) |
|
| 124 | - * |
|
| 125 | - * @var boolean |
|
| 126 | - * @access private |
|
| 127 | - */ |
|
| 128 | - var $charencoding = true; |
|
| 129 | - /** |
|
| 130 | - * the debug level for this instance |
|
| 131 | - * |
|
| 132 | - * @var integer |
|
| 133 | - * @access private |
|
| 134 | - */ |
|
| 135 | - var $debugLevel; |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * set schema version |
|
| 139 | - * |
|
| 140 | - * @var string |
|
| 141 | - * @access public |
|
| 142 | - */ |
|
| 143 | - var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
|
| 144 | - |
|
| 145 | - /** |
|
| 146 | - * charset encoding for outgoing messages |
|
| 147 | - * |
|
| 148 | - * @var string |
|
| 149 | - * @access public |
|
| 150 | - */ |
|
| 122 | + * toggles automatic encoding of special characters as entities |
|
| 123 | + * (should always be true, I think) |
|
| 124 | + * |
|
| 125 | + * @var boolean |
|
| 126 | + * @access private |
|
| 127 | + */ |
|
| 128 | + var $charencoding = true; |
|
| 129 | + /** |
|
| 130 | + * the debug level for this instance |
|
| 131 | + * |
|
| 132 | + * @var integer |
|
| 133 | + * @access private |
|
| 134 | + */ |
|
| 135 | + var $debugLevel; |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * set schema version |
|
| 139 | + * |
|
| 140 | + * @var string |
|
| 141 | + * @access public |
|
| 142 | + */ |
|
| 143 | + var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
|
| 144 | + |
|
| 145 | + /** |
|
| 146 | + * charset encoding for outgoing messages |
|
| 147 | + * |
|
| 148 | + * @var string |
|
| 149 | + * @access public |
|
| 150 | + */ |
|
| 151 | 151 | var $soap_defencoding = 'ISO-8859-1'; |
| 152 | - //var $soap_defencoding = 'UTF-8'; |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * namespaces in an array of prefix => uri |
|
| 156 | - * |
|
| 157 | - * this is "seeded" by a set of constants, but it may be altered by code |
|
| 158 | - * |
|
| 159 | - * @var array |
|
| 160 | - * @access public |
|
| 161 | - */ |
|
| 162 | - var $namespaces = array( |
|
| 163 | - 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
|
| 164 | - 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
| 165 | - 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
| 166 | - 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' |
|
| 167 | - ); |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * namespaces used in the current context, e.g. during serialization |
|
| 171 | - * |
|
| 172 | - * @var array |
|
| 173 | - * @access private |
|
| 174 | - */ |
|
| 175 | - var $usedNamespaces = array(); |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * XML Schema types in an array of uri => (array of xml type => php type) |
|
| 179 | - * is this legacy yet? |
|
| 180 | - * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
| 181 | - * @var array |
|
| 182 | - * @access public |
|
| 183 | - */ |
|
| 184 | - var $typemap = array( |
|
| 185 | - 'http://www.w3.org/2001/XMLSchema' => array( |
|
| 186 | - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
| 187 | - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
| 188 | - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
| 189 | - // abstract "any" types |
|
| 190 | - 'anyType'=>'string','anySimpleType'=>'string', |
|
| 191 | - // derived datatypes |
|
| 192 | - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
| 193 | - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
| 194 | - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
| 195 | - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
| 196 | - 'http://www.w3.org/2000/10/XMLSchema' => array( |
|
| 197 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 198 | - 'float'=>'double','dateTime'=>'string', |
|
| 199 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 200 | - 'http://www.w3.org/1999/XMLSchema' => array( |
|
| 201 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 202 | - 'float'=>'double','dateTime'=>'string', |
|
| 203 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 204 | - 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
|
|
| 205 | - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
|
|
| 152 | + //var $soap_defencoding = 'UTF-8'; |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * namespaces in an array of prefix => uri |
|
| 156 | + * |
|
| 157 | + * this is "seeded" by a set of constants, but it may be altered by code |
|
| 158 | + * |
|
| 159 | + * @var array |
|
| 160 | + * @access public |
|
| 161 | + */ |
|
| 162 | + var $namespaces = array( |
|
| 163 | + 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
|
| 164 | + 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
|
| 165 | + 'xsi' => 'http://www.w3.org/2001/XMLSchema-instance', |
|
| 166 | + 'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/' |
|
| 167 | + ); |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * namespaces used in the current context, e.g. during serialization |
|
| 171 | + * |
|
| 172 | + * @var array |
|
| 173 | + * @access private |
|
| 174 | + */ |
|
| 175 | + var $usedNamespaces = array(); |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * XML Schema types in an array of uri => (array of xml type => php type) |
|
| 179 | + * is this legacy yet? |
|
| 180 | + * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
| 181 | + * @var array |
|
| 182 | + * @access public |
|
| 183 | + */ |
|
| 184 | + var $typemap = array( |
|
| 185 | + 'http://www.w3.org/2001/XMLSchema' => array( |
|
| 186 | + 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
| 187 | + 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
| 188 | + 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
| 189 | + // abstract "any" types |
|
| 190 | + 'anyType'=>'string','anySimpleType'=>'string', |
|
| 191 | + // derived datatypes |
|
| 192 | + 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
| 193 | + 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
| 194 | + 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
| 195 | + 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
| 196 | + 'http://www.w3.org/2000/10/XMLSchema' => array( |
|
| 197 | + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 198 | + 'float'=>'double','dateTime'=>'string', |
|
| 199 | + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 200 | + 'http://www.w3.org/1999/XMLSchema' => array( |
|
| 201 | + 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 202 | + 'float'=>'double','dateTime'=>'string', |
|
| 203 | + 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 204 | + 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
|
|
| 205 | + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
|
|
| 206 | 206 | 'http://xml.apache.org/xml-soap' => array('Map')
|
| 207 | - ); |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * XML entities to convert |
|
| 211 | - * |
|
| 212 | - * @var array |
|
| 213 | - * @access public |
|
| 214 | - * @deprecated |
|
| 215 | - * @see expandEntities |
|
| 216 | - */ |
|
| 217 | - var $xmlEntities = array('quot' => '"','amp' => '&',
|
|
| 218 | - 'lt' => '<','gt' => '>','apos' => "'"); |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * constructor |
|
| 222 | - * |
|
| 223 | - * @access public |
|
| 224 | - */ |
|
| 225 | - function nusoap_base() {
|
|
| 226 | - $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - /** |
|
| 230 | - * gets the global debug level, which applies to future instances |
|
| 231 | - * |
|
| 232 | - * @return integer Debug level 0-9, where 0 turns off |
|
| 233 | - * @access public |
|
| 234 | - */ |
|
| 235 | - function getGlobalDebugLevel() {
|
|
| 236 | - return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
| 237 | - } |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * sets the global debug level, which applies to future instances |
|
| 241 | - * |
|
| 242 | - * @param int $level Debug level 0-9, where 0 turns off |
|
| 243 | - * @access public |
|
| 244 | - */ |
|
| 245 | - function setGlobalDebugLevel($level) {
|
|
| 246 | - $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - /** |
|
| 250 | - * gets the debug level for this instance |
|
| 251 | - * |
|
| 252 | - * @return int Debug level 0-9, where 0 turns off |
|
| 253 | - * @access public |
|
| 254 | - */ |
|
| 255 | - function getDebugLevel() {
|
|
| 256 | - return $this->debugLevel; |
|
| 257 | - } |
|
| 258 | - |
|
| 259 | - /** |
|
| 260 | - * sets the debug level for this instance |
|
| 261 | - * |
|
| 262 | - * @param int $level Debug level 0-9, where 0 turns off |
|
| 263 | - * @access public |
|
| 264 | - */ |
|
| 265 | - function setDebugLevel($level) {
|
|
| 266 | - $this->debugLevel = $level; |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - /** |
|
| 270 | - * adds debug data to the instance debug string with formatting |
|
| 271 | - * |
|
| 272 | - * @param string $string debug data |
|
| 273 | - * @access private |
|
| 274 | - */ |
|
| 275 | - function debug($string){
|
|
| 276 | - if ($this->debugLevel > 0) {
|
|
| 277 | - $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
| 278 | - } |
|
| 279 | - } |
|
| 280 | - |
|
| 281 | - /** |
|
| 282 | - * adds debug data to the instance debug string without formatting |
|
| 283 | - * |
|
| 284 | - * @param string $string debug data |
|
| 285 | - * @access public |
|
| 286 | - */ |
|
| 287 | - function appendDebug($string){
|
|
| 288 | - if ($this->debugLevel > 0) {
|
|
| 289 | - // it would be nice to use a memory stream here to use |
|
| 290 | - // memory more efficiently |
|
| 291 | - $this->debug_str .= $string; |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - /** |
|
| 296 | - * clears the current debug data for this instance |
|
| 297 | - * |
|
| 298 | - * @access public |
|
| 299 | - */ |
|
| 300 | - function clearDebug() {
|
|
| 301 | - // it would be nice to use a memory stream here to use |
|
| 302 | - // memory more efficiently |
|
| 303 | - $this->debug_str = ''; |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * gets the current debug data for this instance |
|
| 308 | - * |
|
| 309 | - * @return debug data |
|
| 310 | - * @access public |
|
| 311 | - */ |
|
| 312 | - function &getDebug() {
|
|
| 313 | - // it would be nice to use a memory stream here to use |
|
| 314 | - // memory more efficiently |
|
| 315 | - return $this->debug_str; |
|
| 316 | - } |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * gets the current debug data for this instance as an XML comment |
|
| 320 | - * this may change the contents of the debug data |
|
| 321 | - * |
|
| 322 | - * @return debug data as an XML comment |
|
| 323 | - * @access public |
|
| 324 | - */ |
|
| 325 | - function &getDebugAsXMLComment() {
|
|
| 326 | - // it would be nice to use a memory stream here to use |
|
| 327 | - // memory more efficiently |
|
| 328 | - while (strpos($this->debug_str, '--')) {
|
|
| 329 | - $this->debug_str = str_replace('--', '- -', $this->debug_str);
|
|
| 330 | - } |
|
| 331 | - $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
| 332 | - return $ret; |
|
| 333 | - } |
|
| 334 | - |
|
| 335 | - /** |
|
| 336 | - * expands entities, e.g. changes '<' to '<'. |
|
| 337 | - * |
|
| 338 | - * @param string $val The string in which to expand entities. |
|
| 339 | - * @access private |
|
| 340 | - */ |
|
| 341 | - function expandEntities($val) {
|
|
| 342 | - if ($this->charencoding) {
|
|
| 343 | - $val = str_replace('&', '&', $val);
|
|
| 344 | - $val = str_replace("'", ''', $val);
|
|
| 345 | - $val = str_replace('"', '"', $val);
|
|
| 346 | - $val = str_replace('<', '<', $val);
|
|
| 347 | - $val = str_replace('>', '>', $val);
|
|
| 348 | - } |
|
| 349 | - return $val; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - /** |
|
| 353 | - * returns error string if present |
|
| 354 | - * |
|
| 355 | - * @return mixed error string or false |
|
| 356 | - * @access public |
|
| 357 | - */ |
|
| 358 | - function getError(){
|
|
| 359 | - if($this->error_str != ''){
|
|
| 360 | - return $this->error_str; |
|
| 361 | - } |
|
| 362 | - return false; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - /** |
|
| 366 | - * sets error string |
|
| 367 | - * |
|
| 368 | - * @return boolean $string error string |
|
| 369 | - * @access private |
|
| 370 | - */ |
|
| 371 | - function setError($str){
|
|
| 372 | - $this->error_str = $str; |
|
| 373 | - } |
|
| 374 | - |
|
| 375 | - /** |
|
| 376 | - * detect if array is a simple array or a struct (associative array) |
|
| 377 | - * |
|
| 378 | - * @param mixed $val The PHP array |
|
| 379 | - * @return string (arraySimple|arrayStruct) |
|
| 380 | - * @access private |
|
| 381 | - */ |
|
| 382 | - function isArraySimpleOrStruct($val) {
|
|
| 207 | + ); |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * XML entities to convert |
|
| 211 | + * |
|
| 212 | + * @var array |
|
| 213 | + * @access public |
|
| 214 | + * @deprecated |
|
| 215 | + * @see expandEntities |
|
| 216 | + */ |
|
| 217 | + var $xmlEntities = array('quot' => '"','amp' => '&',
|
|
| 218 | + 'lt' => '<','gt' => '>','apos' => "'"); |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * constructor |
|
| 222 | + * |
|
| 223 | + * @access public |
|
| 224 | + */ |
|
| 225 | + function nusoap_base() {
|
|
| 226 | + $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + /** |
|
| 230 | + * gets the global debug level, which applies to future instances |
|
| 231 | + * |
|
| 232 | + * @return integer Debug level 0-9, where 0 turns off |
|
| 233 | + * @access public |
|
| 234 | + */ |
|
| 235 | + function getGlobalDebugLevel() {
|
|
| 236 | + return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
|
| 237 | + } |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * sets the global debug level, which applies to future instances |
|
| 241 | + * |
|
| 242 | + * @param int $level Debug level 0-9, where 0 turns off |
|
| 243 | + * @access public |
|
| 244 | + */ |
|
| 245 | + function setGlobalDebugLevel($level) {
|
|
| 246 | + $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + /** |
|
| 250 | + * gets the debug level for this instance |
|
| 251 | + * |
|
| 252 | + * @return int Debug level 0-9, where 0 turns off |
|
| 253 | + * @access public |
|
| 254 | + */ |
|
| 255 | + function getDebugLevel() {
|
|
| 256 | + return $this->debugLevel; |
|
| 257 | + } |
|
| 258 | + |
|
| 259 | + /** |
|
| 260 | + * sets the debug level for this instance |
|
| 261 | + * |
|
| 262 | + * @param int $level Debug level 0-9, where 0 turns off |
|
| 263 | + * @access public |
|
| 264 | + */ |
|
| 265 | + function setDebugLevel($level) {
|
|
| 266 | + $this->debugLevel = $level; |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + /** |
|
| 270 | + * adds debug data to the instance debug string with formatting |
|
| 271 | + * |
|
| 272 | + * @param string $string debug data |
|
| 273 | + * @access private |
|
| 274 | + */ |
|
| 275 | + function debug($string){
|
|
| 276 | + if ($this->debugLevel > 0) {
|
|
| 277 | + $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
|
| 278 | + } |
|
| 279 | + } |
|
| 280 | + |
|
| 281 | + /** |
|
| 282 | + * adds debug data to the instance debug string without formatting |
|
| 283 | + * |
|
| 284 | + * @param string $string debug data |
|
| 285 | + * @access public |
|
| 286 | + */ |
|
| 287 | + function appendDebug($string){
|
|
| 288 | + if ($this->debugLevel > 0) {
|
|
| 289 | + // it would be nice to use a memory stream here to use |
|
| 290 | + // memory more efficiently |
|
| 291 | + $this->debug_str .= $string; |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + /** |
|
| 296 | + * clears the current debug data for this instance |
|
| 297 | + * |
|
| 298 | + * @access public |
|
| 299 | + */ |
|
| 300 | + function clearDebug() {
|
|
| 301 | + // it would be nice to use a memory stream here to use |
|
| 302 | + // memory more efficiently |
|
| 303 | + $this->debug_str = ''; |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * gets the current debug data for this instance |
|
| 308 | + * |
|
| 309 | + * @return debug data |
|
| 310 | + * @access public |
|
| 311 | + */ |
|
| 312 | + function &getDebug() {
|
|
| 313 | + // it would be nice to use a memory stream here to use |
|
| 314 | + // memory more efficiently |
|
| 315 | + return $this->debug_str; |
|
| 316 | + } |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * gets the current debug data for this instance as an XML comment |
|
| 320 | + * this may change the contents of the debug data |
|
| 321 | + * |
|
| 322 | + * @return debug data as an XML comment |
|
| 323 | + * @access public |
|
| 324 | + */ |
|
| 325 | + function &getDebugAsXMLComment() {
|
|
| 326 | + // it would be nice to use a memory stream here to use |
|
| 327 | + // memory more efficiently |
|
| 328 | + while (strpos($this->debug_str, '--')) {
|
|
| 329 | + $this->debug_str = str_replace('--', '- -', $this->debug_str);
|
|
| 330 | + } |
|
| 331 | + $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
| 332 | + return $ret; |
|
| 333 | + } |
|
| 334 | + |
|
| 335 | + /** |
|
| 336 | + * expands entities, e.g. changes '<' to '<'. |
|
| 337 | + * |
|
| 338 | + * @param string $val The string in which to expand entities. |
|
| 339 | + * @access private |
|
| 340 | + */ |
|
| 341 | + function expandEntities($val) {
|
|
| 342 | + if ($this->charencoding) {
|
|
| 343 | + $val = str_replace('&', '&', $val);
|
|
| 344 | + $val = str_replace("'", ''', $val);
|
|
| 345 | + $val = str_replace('"', '"', $val);
|
|
| 346 | + $val = str_replace('<', '<', $val);
|
|
| 347 | + $val = str_replace('>', '>', $val);
|
|
| 348 | + } |
|
| 349 | + return $val; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + /** |
|
| 353 | + * returns error string if present |
|
| 354 | + * |
|
| 355 | + * @return mixed error string or false |
|
| 356 | + * @access public |
|
| 357 | + */ |
|
| 358 | + function getError(){
|
|
| 359 | + if($this->error_str != ''){
|
|
| 360 | + return $this->error_str; |
|
| 361 | + } |
|
| 362 | + return false; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + /** |
|
| 366 | + * sets error string |
|
| 367 | + * |
|
| 368 | + * @return boolean $string error string |
|
| 369 | + * @access private |
|
| 370 | + */ |
|
| 371 | + function setError($str){
|
|
| 372 | + $this->error_str = $str; |
|
| 373 | + } |
|
| 374 | + |
|
| 375 | + /** |
|
| 376 | + * detect if array is a simple array or a struct (associative array) |
|
| 377 | + * |
|
| 378 | + * @param mixed $val The PHP array |
|
| 379 | + * @return string (arraySimple|arrayStruct) |
|
| 380 | + * @access private |
|
| 381 | + */ |
|
| 382 | + function isArraySimpleOrStruct($val) {
|
|
| 383 | 383 | $keyList = array_keys($val); |
| 384 | - foreach ($keyList as $keyListValue) {
|
|
| 385 | - if (!is_int($keyListValue)) {
|
|
| 386 | - return 'arrayStruct'; |
|
| 387 | - } |
|
| 388 | - } |
|
| 389 | - return 'arraySimple'; |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - /** |
|
| 393 | - * serializes PHP values in accordance w/ section 5. Type information is |
|
| 394 | - * not serialized if $use == 'literal'. |
|
| 395 | - * |
|
| 396 | - * @param mixed $val The value to serialize |
|
| 397 | - * @param string $name The name (local part) of the XML element |
|
| 398 | - * @param string $type The XML schema type (local part) for the element |
|
| 399 | - * @param string $name_ns The namespace for the name of the XML element |
|
| 400 | - * @param string $type_ns The namespace for the type of the element |
|
| 401 | - * @param array $attributes The attributes to serialize as name=>value pairs |
|
| 402 | - * @param string $use The WSDL "use" (encoded|literal) |
|
| 403 | - * @param boolean $soapval Whether this is called from soapval. |
|
| 404 | - * @return string The serialized element, possibly with child elements |
|
| 405 | - * @access public |
|
| 406 | - */ |
|
| 407 | - function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
|
|
| 408 | - $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
|
|
| 409 | - $this->appendDebug('value=' . $this->varDump($val));
|
|
| 410 | - $this->appendDebug('attributes=' . $this->varDump($attributes));
|
|
| 411 | - |
|
| 412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
|
|
| 413 | - $this->debug("serialize_val: serialize soapval");
|
|
| 414 | - $xml = $val->serialize($use); |
|
| 415 | - $this->appendDebug($val->getDebug()); |
|
| 416 | - $val->clearDebug(); |
|
| 417 | - $this->debug("serialize_val of soapval returning $xml");
|
|
| 418 | - return $xml; |
|
| 384 | + foreach ($keyList as $keyListValue) {
|
|
| 385 | + if (!is_int($keyListValue)) {
|
|
| 386 | + return 'arrayStruct'; |
|
| 387 | + } |
|
| 419 | 388 | } |
| 420 | - // force valid name if necessary |
|
| 421 | - if (is_numeric($name)) {
|
|
| 422 | - $name = '__numeric_' . $name; |
|
| 423 | - } elseif (! $name) {
|
|
| 424 | - $name = 'noname'; |
|
| 425 | - } |
|
| 426 | - // if name has ns, add ns prefix to name |
|
| 427 | - $xmlns = ''; |
|
| 389 | + return 'arraySimple'; |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + /** |
|
| 393 | + * serializes PHP values in accordance w/ section 5. Type information is |
|
| 394 | + * not serialized if $use == 'literal'. |
|
| 395 | + * |
|
| 396 | + * @param mixed $val The value to serialize |
|
| 397 | + * @param string $name The name (local part) of the XML element |
|
| 398 | + * @param string $type The XML schema type (local part) for the element |
|
| 399 | + * @param string $name_ns The namespace for the name of the XML element |
|
| 400 | + * @param string $type_ns The namespace for the type of the element |
|
| 401 | + * @param array $attributes The attributes to serialize as name=>value pairs |
|
| 402 | + * @param string $use The WSDL "use" (encoded|literal) |
|
| 403 | + * @param boolean $soapval Whether this is called from soapval. |
|
| 404 | + * @return string The serialized element, possibly with child elements |
|
| 405 | + * @access public |
|
| 406 | + */ |
|
| 407 | + function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
|
|
| 408 | + $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
|
|
| 409 | + $this->appendDebug('value=' . $this->varDump($val));
|
|
| 410 | + $this->appendDebug('attributes=' . $this->varDump($attributes));
|
|
| 411 | + |
|
| 412 | + if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
|
|
| 413 | + $this->debug("serialize_val: serialize soapval");
|
|
| 414 | + $xml = $val->serialize($use); |
|
| 415 | + $this->appendDebug($val->getDebug()); |
|
| 416 | + $val->clearDebug(); |
|
| 417 | + $this->debug("serialize_val of soapval returning $xml");
|
|
| 418 | + return $xml; |
|
| 419 | + } |
|
| 420 | + // force valid name if necessary |
|
| 421 | + if (is_numeric($name)) {
|
|
| 422 | + $name = '__numeric_' . $name; |
|
| 423 | + } elseif (! $name) {
|
|
| 424 | + $name = 'noname'; |
|
| 425 | + } |
|
| 426 | + // if name has ns, add ns prefix to name |
|
| 427 | + $xmlns = ''; |
|
| 428 | 428 | if($name_ns){
|
| 429 | - $prefix = 'nu'.rand(1000,9999); |
|
| 430 | - $name = $prefix.':'.$name; |
|
| 431 | - $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
|
| 432 | - } |
|
| 433 | - // if type is prefixed, create type prefix |
|
| 434 | - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
|
|
| 435 | - // need to fix this. shouldn't default to xsd if no ns specified |
|
| 436 | - // w/o checking against typemap |
|
| 437 | - $type_prefix = 'xsd'; |
|
| 438 | - } elseif($type_ns){
|
|
| 439 | - $type_prefix = 'ns'.rand(1000,9999); |
|
| 440 | - $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
|
| 441 | - } |
|
| 442 | - // serialize attributes if present |
|
| 443 | - $atts = ''; |
|
| 444 | - if($attributes){
|
|
| 445 | - foreach($attributes as $k => $v){
|
|
| 446 | - $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
| 447 | - } |
|
| 448 | - } |
|
| 449 | - // serialize null value |
|
| 450 | - if (is_null($val)) {
|
|
| 451 | - $this->debug("serialize_val: serialize null");
|
|
| 452 | - if ($use == 'literal') {
|
|
| 453 | - // TODO: depends on minOccurs |
|
| 454 | - $xml = "<$name$xmlns$atts/>"; |
|
| 455 | - $this->debug("serialize_val returning $xml");
|
|
| 456 | - return $xml; |
|
| 457 | - } else {
|
|
| 458 | - if (isset($type) && isset($type_prefix)) {
|
|
| 459 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 460 | - } else {
|
|
| 461 | - $type_str = ''; |
|
| 462 | - } |
|
| 463 | - $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
|
| 464 | - $this->debug("serialize_val returning $xml");
|
|
| 465 | - return $xml; |
|
| 466 | - } |
|
| 467 | - } |
|
| 429 | + $prefix = 'nu'.rand(1000,9999); |
|
| 430 | + $name = $prefix.':'.$name; |
|
| 431 | + $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
|
| 432 | + } |
|
| 433 | + // if type is prefixed, create type prefix |
|
| 434 | + if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
|
|
| 435 | + // need to fix this. shouldn't default to xsd if no ns specified |
|
| 436 | + // w/o checking against typemap |
|
| 437 | + $type_prefix = 'xsd'; |
|
| 438 | + } elseif($type_ns){
|
|
| 439 | + $type_prefix = 'ns'.rand(1000,9999); |
|
| 440 | + $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
|
| 441 | + } |
|
| 442 | + // serialize attributes if present |
|
| 443 | + $atts = ''; |
|
| 444 | + if($attributes){
|
|
| 445 | + foreach($attributes as $k => $v){
|
|
| 446 | + $atts .= " $k=\"".$this->expandEntities($v).'"'; |
|
| 447 | + } |
|
| 448 | + } |
|
| 449 | + // serialize null value |
|
| 450 | + if (is_null($val)) {
|
|
| 451 | + $this->debug("serialize_val: serialize null");
|
|
| 452 | + if ($use == 'literal') {
|
|
| 453 | + // TODO: depends on minOccurs |
|
| 454 | + $xml = "<$name$xmlns$atts/>"; |
|
| 455 | + $this->debug("serialize_val returning $xml");
|
|
| 456 | + return $xml; |
|
| 457 | + } else {
|
|
| 458 | + if (isset($type) && isset($type_prefix)) {
|
|
| 459 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 460 | + } else {
|
|
| 461 | + $type_str = ''; |
|
| 462 | + } |
|
| 463 | + $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
|
| 464 | + $this->debug("serialize_val returning $xml");
|
|
| 465 | + return $xml; |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | 468 | // serialize if an xsd built-in primitive type |
| 469 | 469 | if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
|
| 470 | - $this->debug("serialize_val: serialize xsd built-in primitive type");
|
|
| 471 | - if (is_bool($val)) {
|
|
| 472 | - if ($type == 'boolean') {
|
|
| 473 | - $val = $val ? 'true' : 'false'; |
|
| 474 | - } elseif (! $val) {
|
|
| 475 | - $val = 0; |
|
| 476 | - } |
|
| 477 | - } else if (is_string($val)) {
|
|
| 478 | - $val = $this->expandEntities($val); |
|
| 479 | - } |
|
| 480 | - if ($use == 'literal') {
|
|
| 481 | - $xml = "<$name$xmlns$atts>$val</$name>"; |
|
| 482 | - $this->debug("serialize_val returning $xml");
|
|
| 483 | - return $xml; |
|
| 484 | - } else {
|
|
| 485 | - $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
|
| 486 | - $this->debug("serialize_val returning $xml");
|
|
| 487 | - return $xml; |
|
| 488 | - } |
|
| 470 | + $this->debug("serialize_val: serialize xsd built-in primitive type");
|
|
| 471 | + if (is_bool($val)) {
|
|
| 472 | + if ($type == 'boolean') {
|
|
| 473 | + $val = $val ? 'true' : 'false'; |
|
| 474 | + } elseif (! $val) {
|
|
| 475 | + $val = 0; |
|
| 476 | + } |
|
| 477 | + } else if (is_string($val)) {
|
|
| 478 | + $val = $this->expandEntities($val); |
|
| 479 | + } |
|
| 480 | + if ($use == 'literal') {
|
|
| 481 | + $xml = "<$name$xmlns$atts>$val</$name>"; |
|
| 482 | + $this->debug("serialize_val returning $xml");
|
|
| 483 | + return $xml; |
|
| 484 | + } else {
|
|
| 485 | + $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
|
| 486 | + $this->debug("serialize_val returning $xml");
|
|
| 487 | + return $xml; |
|
| 488 | + } |
|
| 489 | 489 | } |
| 490 | - // detect type and serialize |
|
| 491 | - $xml = ''; |
|
| 492 | - switch(true) {
|
|
| 493 | - case (is_bool($val) || $type == 'boolean'): |
|
| 494 | - $this->debug("serialize_val: serialize boolean");
|
|
| 495 | - if ($type == 'boolean') {
|
|
| 496 | - $val = $val ? 'true' : 'false'; |
|
| 497 | - } elseif (! $val) {
|
|
| 498 | - $val = 0; |
|
| 499 | - } |
|
| 500 | - if ($use == 'literal') {
|
|
| 501 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 502 | - } else {
|
|
| 503 | - $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>"; |
|
| 504 | - } |
|
| 505 | - break; |
|
| 506 | - case (is_int($val) || is_long($val) || $type == 'int'): |
|
| 507 | - $this->debug("serialize_val: serialize int");
|
|
| 508 | - if ($use == 'literal') {
|
|
| 509 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 510 | - } else {
|
|
| 511 | - $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
|
| 512 | - } |
|
| 513 | - break; |
|
| 514 | - case (is_float($val)|| is_double($val) || $type == 'float'): |
|
| 515 | - $this->debug("serialize_val: serialize float");
|
|
| 516 | - if ($use == 'literal') {
|
|
| 517 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 518 | - } else {
|
|
| 519 | - $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>"; |
|
| 520 | - } |
|
| 521 | - break; |
|
| 522 | - case (is_string($val) || $type == 'string'): |
|
| 523 | - $this->debug("serialize_val: serialize string");
|
|
| 524 | - $val = $this->expandEntities($val); |
|
| 525 | - if ($use == 'literal') {
|
|
| 526 | - $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 527 | - } else {
|
|
| 528 | - $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>"; |
|
| 529 | - } |
|
| 530 | - break; |
|
| 531 | - case is_object($val): |
|
| 532 | - $this->debug("serialize_val: serialize object");
|
|
| 533 | - if (get_class($val) == 'soapval') {
|
|
| 534 | - $this->debug("serialize_val: serialize soapval object");
|
|
| 535 | - $pXml = $val->serialize($use); |
|
| 536 | - $this->appendDebug($val->getDebug()); |
|
| 537 | - $val->clearDebug(); |
|
| 538 | - } else {
|
|
| 539 | - if (! $name) {
|
|
| 540 | - $name = get_class($val); |
|
| 541 | - $this->debug("In serialize_val, used class name $name as element name");
|
|
| 542 | - } else {
|
|
| 543 | - $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
|
|
| 544 | - } |
|
| 545 | - foreach(get_object_vars($val) as $k => $v){
|
|
| 546 | - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 547 | - } |
|
| 548 | - } |
|
| 549 | - if(isset($type) && isset($type_prefix)){
|
|
| 550 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 551 | - } else {
|
|
| 552 | - $type_str = ''; |
|
| 553 | - } |
|
| 554 | - if ($use == 'literal') {
|
|
| 555 | - $xml .= "<$name$xmlns$atts>$pXml</$name>"; |
|
| 556 | - } else {
|
|
| 557 | - $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>"; |
|
| 558 | - } |
|
| 559 | - break; |
|
| 560 | - break; |
|
| 561 | - case (is_array($val) || $type): |
|
| 562 | - // detect if struct or array |
|
| 563 | - $valueType = $this->isArraySimpleOrStruct($val); |
|
| 490 | + // detect type and serialize |
|
| 491 | + $xml = ''; |
|
| 492 | + switch(true) {
|
|
| 493 | + case (is_bool($val) || $type == 'boolean'): |
|
| 494 | + $this->debug("serialize_val: serialize boolean");
|
|
| 495 | + if ($type == 'boolean') {
|
|
| 496 | + $val = $val ? 'true' : 'false'; |
|
| 497 | + } elseif (! $val) {
|
|
| 498 | + $val = 0; |
|
| 499 | + } |
|
| 500 | + if ($use == 'literal') {
|
|
| 501 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 502 | + } else {
|
|
| 503 | + $xml .= "<$name$xmlns xsi:type=\"xsd:boolean\"$atts>$val</$name>"; |
|
| 504 | + } |
|
| 505 | + break; |
|
| 506 | + case (is_int($val) || is_long($val) || $type == 'int'): |
|
| 507 | + $this->debug("serialize_val: serialize int");
|
|
| 508 | + if ($use == 'literal') {
|
|
| 509 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 510 | + } else {
|
|
| 511 | + $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
|
| 512 | + } |
|
| 513 | + break; |
|
| 514 | + case (is_float($val)|| is_double($val) || $type == 'float'): |
|
| 515 | + $this->debug("serialize_val: serialize float");
|
|
| 516 | + if ($use == 'literal') {
|
|
| 517 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 518 | + } else {
|
|
| 519 | + $xml .= "<$name$xmlns xsi:type=\"xsd:float\"$atts>$val</$name>"; |
|
| 520 | + } |
|
| 521 | + break; |
|
| 522 | + case (is_string($val) || $type == 'string'): |
|
| 523 | + $this->debug("serialize_val: serialize string");
|
|
| 524 | + $val = $this->expandEntities($val); |
|
| 525 | + if ($use == 'literal') {
|
|
| 526 | + $xml .= "<$name$xmlns$atts>$val</$name>"; |
|
| 527 | + } else {
|
|
| 528 | + $xml .= "<$name$xmlns xsi:type=\"xsd:string\"$atts>$val</$name>"; |
|
| 529 | + } |
|
| 530 | + break; |
|
| 531 | + case is_object($val): |
|
| 532 | + $this->debug("serialize_val: serialize object");
|
|
| 533 | + if (get_class($val) == 'soapval') {
|
|
| 534 | + $this->debug("serialize_val: serialize soapval object");
|
|
| 535 | + $pXml = $val->serialize($use); |
|
| 536 | + $this->appendDebug($val->getDebug()); |
|
| 537 | + $val->clearDebug(); |
|
| 538 | + } else {
|
|
| 539 | + if (! $name) {
|
|
| 540 | + $name = get_class($val); |
|
| 541 | + $this->debug("In serialize_val, used class name $name as element name");
|
|
| 542 | + } else {
|
|
| 543 | + $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
|
|
| 544 | + } |
|
| 545 | + foreach(get_object_vars($val) as $k => $v){
|
|
| 546 | + $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 547 | + } |
|
| 548 | + } |
|
| 549 | + if(isset($type) && isset($type_prefix)){
|
|
| 550 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 551 | + } else {
|
|
| 552 | + $type_str = ''; |
|
| 553 | + } |
|
| 554 | + if ($use == 'literal') {
|
|
| 555 | + $xml .= "<$name$xmlns$atts>$pXml</$name>"; |
|
| 556 | + } else {
|
|
| 557 | + $xml .= "<$name$xmlns$type_str$atts>$pXml</$name>"; |
|
| 558 | + } |
|
| 559 | + break; |
|
| 560 | + break; |
|
| 561 | + case (is_array($val) || $type): |
|
| 562 | + // detect if struct or array |
|
| 563 | + $valueType = $this->isArraySimpleOrStruct($val); |
|
| 564 | 564 | if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
|
| 565 | - $this->debug("serialize_val: serialize array");
|
|
| 566 | - $i = 0; |
|
| 567 | - if(is_array($val) && count($val)> 0){
|
|
| 568 | - foreach($val as $v){
|
|
| 569 | - if(is_object($v) && get_class($v) == 'soapval'){
|
|
| 570 | - $tt_ns = $v->type_ns; |
|
| 571 | - $tt = $v->type; |
|
| 572 | - } elseif (is_array($v)) {
|
|
| 573 | - $tt = $this->isArraySimpleOrStruct($v); |
|
| 574 | - } else {
|
|
| 575 | - $tt = gettype($v); |
|
| 576 | - } |
|
| 577 | - $array_types[$tt] = 1; |
|
| 578 | - // TODO: for literal, the name should be $name |
|
| 579 | - $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
| 580 | - ++$i; |
|
| 581 | - } |
|
| 582 | - if(count($array_types) > 1){
|
|
| 583 | - $array_typename = 'xsd:anyType'; |
|
| 584 | - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
|
|
| 585 | - if ($tt == 'integer') {
|
|
| 586 | - $tt = 'int'; |
|
| 587 | - } |
|
| 588 | - $array_typename = 'xsd:'.$tt; |
|
| 589 | - } elseif(isset($tt) && $tt == 'arraySimple'){
|
|
| 590 | - $array_typename = 'SOAP-ENC:Array'; |
|
| 591 | - } elseif(isset($tt) && $tt == 'arrayStruct'){
|
|
| 592 | - $array_typename = 'unnamed_struct_use_soapval'; |
|
| 593 | - } else {
|
|
| 594 | - // if type is prefixed, create type prefix |
|
| 595 | - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
|
|
| 596 | - $array_typename = 'xsd:' . $tt; |
|
| 597 | - } elseif ($tt_ns) {
|
|
| 598 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
| 599 | - $array_typename = "$tt_prefix:$tt"; |
|
| 600 | - $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
|
| 601 | - } else {
|
|
| 602 | - $array_typename = $tt; |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - $array_type = $i; |
|
| 606 | - if ($use == 'literal') {
|
|
| 607 | - $type_str = ''; |
|
| 608 | - } else if (isset($type) && isset($type_prefix)) {
|
|
| 609 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 610 | - } else {
|
|
| 611 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
| 612 | - } |
|
| 613 | - // empty array |
|
| 614 | - } else {
|
|
| 615 | - if ($use == 'literal') {
|
|
| 616 | - $type_str = ''; |
|
| 617 | - } else if (isset($type) && isset($type_prefix)) {
|
|
| 618 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 619 | - } else {
|
|
| 620 | - $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
|
| 621 | - } |
|
| 622 | - } |
|
| 623 | - // TODO: for array in literal, there is no wrapper here |
|
| 624 | - $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
| 625 | - } else {
|
|
| 626 | - // got a struct |
|
| 627 | - $this->debug("serialize_val: serialize struct");
|
|
| 628 | - if(isset($type) && isset($type_prefix)){
|
|
| 629 | - $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 630 | - } else {
|
|
| 631 | - $type_str = ''; |
|
| 632 | - } |
|
| 633 | - if ($use == 'literal') {
|
|
| 634 | - $xml .= "<$name$xmlns$atts>"; |
|
| 635 | - } else {
|
|
| 636 | - $xml .= "<$name$xmlns$type_str$atts>"; |
|
| 637 | - } |
|
| 638 | - foreach($val as $k => $v){
|
|
| 639 | - // Apache Map |
|
| 640 | - if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
|
|
| 641 | - $xml .= '<item>'; |
|
| 642 | - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 643 | - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 644 | - $xml .= '</item>'; |
|
| 645 | - } else {
|
|
| 646 | - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 647 | - } |
|
| 648 | - } |
|
| 649 | - $xml .= "</$name>"; |
|
| 650 | - } |
|
| 651 | - break; |
|
| 652 | - default: |
|
| 653 | - $this->debug("serialize_val: serialize unknown");
|
|
| 654 | - $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
| 655 | - break; |
|
| 656 | - } |
|
| 657 | - $this->debug("serialize_val returning $xml");
|
|
| 658 | - return $xml; |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - /** |
|
| 662 | - * serializes a message |
|
| 663 | - * |
|
| 664 | - * @param string $body the XML of the SOAP body |
|
| 665 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 666 | - * @param array $namespaces optional the namespaces used in generating the body and headers |
|
| 667 | - * @param string $style optional (rpc|document) |
|
| 668 | - * @param string $use optional (encoded|literal) |
|
| 669 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 670 | - * @return string the message |
|
| 671 | - * @access public |
|
| 672 | - */ |
|
| 565 | + $this->debug("serialize_val: serialize array");
|
|
| 566 | + $i = 0; |
|
| 567 | + if(is_array($val) && count($val)> 0){
|
|
| 568 | + foreach($val as $v){
|
|
| 569 | + if(is_object($v) && get_class($v) == 'soapval'){
|
|
| 570 | + $tt_ns = $v->type_ns; |
|
| 571 | + $tt = $v->type; |
|
| 572 | + } elseif (is_array($v)) {
|
|
| 573 | + $tt = $this->isArraySimpleOrStruct($v); |
|
| 574 | + } else {
|
|
| 575 | + $tt = gettype($v); |
|
| 576 | + } |
|
| 577 | + $array_types[$tt] = 1; |
|
| 578 | + // TODO: for literal, the name should be $name |
|
| 579 | + $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
| 580 | + ++$i; |
|
| 581 | + } |
|
| 582 | + if(count($array_types) > 1){
|
|
| 583 | + $array_typename = 'xsd:anyType'; |
|
| 584 | + } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
|
|
| 585 | + if ($tt == 'integer') {
|
|
| 586 | + $tt = 'int'; |
|
| 587 | + } |
|
| 588 | + $array_typename = 'xsd:'.$tt; |
|
| 589 | + } elseif(isset($tt) && $tt == 'arraySimple'){
|
|
| 590 | + $array_typename = 'SOAP-ENC:Array'; |
|
| 591 | + } elseif(isset($tt) && $tt == 'arrayStruct'){
|
|
| 592 | + $array_typename = 'unnamed_struct_use_soapval'; |
|
| 593 | + } else {
|
|
| 594 | + // if type is prefixed, create type prefix |
|
| 595 | + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
|
|
| 596 | + $array_typename = 'xsd:' . $tt; |
|
| 597 | + } elseif ($tt_ns) {
|
|
| 598 | + $tt_prefix = 'ns' . rand(1000, 9999); |
|
| 599 | + $array_typename = "$tt_prefix:$tt"; |
|
| 600 | + $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
|
| 601 | + } else {
|
|
| 602 | + $array_typename = $tt; |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + $array_type = $i; |
|
| 606 | + if ($use == 'literal') {
|
|
| 607 | + $type_str = ''; |
|
| 608 | + } else if (isset($type) && isset($type_prefix)) {
|
|
| 609 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 610 | + } else {
|
|
| 611 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"".$array_typename."[$array_type]\""; |
|
| 612 | + } |
|
| 613 | + // empty array |
|
| 614 | + } else {
|
|
| 615 | + if ($use == 'literal') {
|
|
| 616 | + $type_str = ''; |
|
| 617 | + } else if (isset($type) && isset($type_prefix)) {
|
|
| 618 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 619 | + } else {
|
|
| 620 | + $type_str = " xsi:type=\"SOAP-ENC:Array\" SOAP-ENC:arrayType=\"xsd:anyType[0]\""; |
|
| 621 | + } |
|
| 622 | + } |
|
| 623 | + // TODO: for array in literal, there is no wrapper here |
|
| 624 | + $xml = "<$name$xmlns$type_str$atts>".$xml."</$name>"; |
|
| 625 | + } else {
|
|
| 626 | + // got a struct |
|
| 627 | + $this->debug("serialize_val: serialize struct");
|
|
| 628 | + if(isset($type) && isset($type_prefix)){
|
|
| 629 | + $type_str = " xsi:type=\"$type_prefix:$type\""; |
|
| 630 | + } else {
|
|
| 631 | + $type_str = ''; |
|
| 632 | + } |
|
| 633 | + if ($use == 'literal') {
|
|
| 634 | + $xml .= "<$name$xmlns$atts>"; |
|
| 635 | + } else {
|
|
| 636 | + $xml .= "<$name$xmlns$type_str$atts>"; |
|
| 637 | + } |
|
| 638 | + foreach($val as $k => $v){
|
|
| 639 | + // Apache Map |
|
| 640 | + if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
|
|
| 641 | + $xml .= '<item>'; |
|
| 642 | + $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 643 | + $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 644 | + $xml .= '</item>'; |
|
| 645 | + } else {
|
|
| 646 | + $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 647 | + } |
|
| 648 | + } |
|
| 649 | + $xml .= "</$name>"; |
|
| 650 | + } |
|
| 651 | + break; |
|
| 652 | + default: |
|
| 653 | + $this->debug("serialize_val: serialize unknown");
|
|
| 654 | + $xml .= 'not detected, got '.gettype($val).' for '.$val; |
|
| 655 | + break; |
|
| 656 | + } |
|
| 657 | + $this->debug("serialize_val returning $xml");
|
|
| 658 | + return $xml; |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + /** |
|
| 662 | + * serializes a message |
|
| 663 | + * |
|
| 664 | + * @param string $body the XML of the SOAP body |
|
| 665 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 666 | + * @param array $namespaces optional the namespaces used in generating the body and headers |
|
| 667 | + * @param string $style optional (rpc|document) |
|
| 668 | + * @param string $use optional (encoded|literal) |
|
| 669 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 670 | + * @return string the message |
|
| 671 | + * @access public |
|
| 672 | + */ |
|
| 673 | 673 | function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
|
| 674 | 674 | // TODO: add an option to automatically run utf8_encode on $body and $headers |
| 675 | 675 | // if $this->soap_defencoding is UTF-8. Not doing this automatically allows |
| 676 | 676 | // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 |
| 677 | 677 | |
| 678 | - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
|
|
| 679 | - $this->debug("headers:");
|
|
| 680 | - $this->appendDebug($this->varDump($headers)); |
|
| 681 | - $this->debug("namespaces:");
|
|
| 682 | - $this->appendDebug($this->varDump($namespaces)); |
|
| 678 | + $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
|
|
| 679 | + $this->debug("headers:");
|
|
| 680 | + $this->appendDebug($this->varDump($headers)); |
|
| 681 | + $this->debug("namespaces:");
|
|
| 682 | + $this->appendDebug($this->varDump($namespaces)); |
|
| 683 | 683 | |
| 684 | - // serialize namespaces |
|
| 684 | + // serialize namespaces |
|
| 685 | 685 | $ns_string = ''; |
| 686 | - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
|
|
| 687 | - $ns_string .= " xmlns:$k=\"$v\""; |
|
| 688 | - } |
|
| 689 | - if($encodingStyle) {
|
|
| 690 | - $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - // serialize headers |
|
| 694 | - if($headers){
|
|
| 695 | - if (is_array($headers)) {
|
|
| 696 | - $xml = ''; |
|
| 697 | - foreach ($headers as $k => $v) {
|
|
| 698 | - if (is_object($v) && get_class($v) == 'soapval') {
|
|
| 699 | - $xml .= $this->serialize_val($v, false, false, false, false, false, $use); |
|
| 700 | - } else {
|
|
| 701 | - $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 702 | - } |
|
| 703 | - } |
|
| 704 | - $headers = $xml; |
|
| 705 | - $this->debug("In serializeEnvelope, serialized array of headers to $headers");
|
|
| 706 | - } |
|
| 707 | - $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
| 708 | - } |
|
| 709 | - // serialize envelope |
|
| 710 | - return |
|
| 711 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
| 712 | - '<SOAP-ENV:Envelope'.$ns_string.">". |
|
| 713 | - $headers. |
|
| 714 | - "<SOAP-ENV:Body>". |
|
| 715 | - $body. |
|
| 716 | - "</SOAP-ENV:Body>". |
|
| 717 | - "</SOAP-ENV:Envelope>"; |
|
| 718 | - } |
|
| 719 | - |
|
| 720 | - /** |
|
| 721 | - * formats a string to be inserted into an HTML stream |
|
| 722 | - * |
|
| 723 | - * @param string $str The string to format |
|
| 724 | - * @return string The formatted string |
|
| 725 | - * @access public |
|
| 726 | - * @deprecated |
|
| 727 | - */ |
|
| 686 | + foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
|
|
| 687 | + $ns_string .= " xmlns:$k=\"$v\""; |
|
| 688 | + } |
|
| 689 | + if($encodingStyle) {
|
|
| 690 | + $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + // serialize headers |
|
| 694 | + if($headers){
|
|
| 695 | + if (is_array($headers)) {
|
|
| 696 | + $xml = ''; |
|
| 697 | + foreach ($headers as $k => $v) {
|
|
| 698 | + if (is_object($v) && get_class($v) == 'soapval') {
|
|
| 699 | + $xml .= $this->serialize_val($v, false, false, false, false, false, $use); |
|
| 700 | + } else {
|
|
| 701 | + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 702 | + } |
|
| 703 | + } |
|
| 704 | + $headers = $xml; |
|
| 705 | + $this->debug("In serializeEnvelope, serialized array of headers to $headers");
|
|
| 706 | + } |
|
| 707 | + $headers = "<SOAP-ENV:Header>".$headers."</SOAP-ENV:Header>"; |
|
| 708 | + } |
|
| 709 | + // serialize envelope |
|
| 710 | + return |
|
| 711 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
| 712 | + '<SOAP-ENV:Envelope'.$ns_string.">". |
|
| 713 | + $headers. |
|
| 714 | + "<SOAP-ENV:Body>". |
|
| 715 | + $body. |
|
| 716 | + "</SOAP-ENV:Body>". |
|
| 717 | + "</SOAP-ENV:Envelope>"; |
|
| 718 | + } |
|
| 719 | + |
|
| 720 | + /** |
|
| 721 | + * formats a string to be inserted into an HTML stream |
|
| 722 | + * |
|
| 723 | + * @param string $str The string to format |
|
| 724 | + * @return string The formatted string |
|
| 725 | + * @access public |
|
| 726 | + * @deprecated |
|
| 727 | + */ |
|
| 728 | 728 | function formatDump($str){
|
| 729 | - $str = htmlspecialchars($str); |
|
| 730 | - return nl2br($str); |
|
| 731 | - } |
|
| 732 | - |
|
| 733 | - /** |
|
| 734 | - * contracts (changes namespace to prefix) a qualified name |
|
| 735 | - * |
|
| 736 | - * @param string $qname qname |
|
| 737 | - * @return string contracted qname |
|
| 738 | - * @access private |
|
| 739 | - */ |
|
| 740 | - function contractQname($qname){
|
|
| 741 | - // get element namespace |
|
| 742 | - //$this->xdebug("Contract $qname");
|
|
| 743 | - if (strrpos($qname, ':')) {
|
|
| 744 | - // get unqualified name |
|
| 745 | - $name = substr($qname, strrpos($qname, ':') + 1); |
|
| 746 | - // get ns |
|
| 747 | - $ns = substr($qname, 0, strrpos($qname, ':')); |
|
| 748 | - $p = $this->getPrefixFromNamespace($ns); |
|
| 749 | - if ($p) {
|
|
| 750 | - return $p . ':' . $name; |
|
| 751 | - } |
|
| 752 | - return $qname; |
|
| 753 | - } else {
|
|
| 754 | - return $qname; |
|
| 755 | - } |
|
| 756 | - } |
|
| 757 | - |
|
| 758 | - /** |
|
| 759 | - * expands (changes prefix to namespace) a qualified name |
|
| 760 | - * |
|
| 761 | - * @param string $qname qname |
|
| 762 | - * @return string expanded qname |
|
| 763 | - * @access private |
|
| 764 | - */ |
|
| 765 | - function expandQname($qname){
|
|
| 766 | - // get element prefix |
|
| 767 | - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
|
|
| 768 | - // get unqualified name |
|
| 769 | - $name = substr(strstr($qname,':'),1); |
|
| 770 | - // get ns prefix |
|
| 771 | - $prefix = substr($qname,0,strpos($qname,':')); |
|
| 772 | - if(isset($this->namespaces[$prefix])){
|
|
| 773 | - return $this->namespaces[$prefix].':'.$name; |
|
| 774 | - } else {
|
|
| 775 | - return $qname; |
|
| 776 | - } |
|
| 777 | - } else {
|
|
| 778 | - return $qname; |
|
| 779 | - } |
|
| 780 | - } |
|
| 781 | - |
|
| 782 | - /** |
|
| 783 | - * returns the local part of a prefixed string |
|
| 784 | - * returns the original string, if not prefixed |
|
| 785 | - * |
|
| 786 | - * @param string $str The prefixed string |
|
| 787 | - * @return string The local part |
|
| 788 | - * @access public |
|
| 789 | - */ |
|
| 790 | - function getLocalPart($str){
|
|
| 791 | - if($sstr = strrchr($str,':')){
|
|
| 792 | - // get unqualified name |
|
| 793 | - return substr( $sstr, 1 ); |
|
| 794 | - } else {
|
|
| 795 | - return $str; |
|
| 796 | - } |
|
| 797 | - } |
|
| 798 | - |
|
| 799 | - /** |
|
| 800 | - * returns the prefix part of a prefixed string |
|
| 801 | - * returns false, if not prefixed |
|
| 802 | - * |
|
| 803 | - * @param string $str The prefixed string |
|
| 804 | - * @return mixed The prefix or false if there is no prefix |
|
| 805 | - * @access public |
|
| 806 | - */ |
|
| 807 | - function getPrefix($str){
|
|
| 808 | - if($pos = strrpos($str,':')){
|
|
| 809 | - // get prefix |
|
| 810 | - return substr($str,0,$pos); |
|
| 811 | - } |
|
| 812 | - return false; |
|
| 813 | - } |
|
| 814 | - |
|
| 815 | - /** |
|
| 816 | - * pass it a prefix, it returns a namespace |
|
| 817 | - * |
|
| 818 | - * @param string $prefix The prefix |
|
| 819 | - * @return mixed The namespace, false if no namespace has the specified prefix |
|
| 820 | - * @access public |
|
| 821 | - */ |
|
| 822 | - function getNamespaceFromPrefix($prefix){
|
|
| 823 | - if (isset($this->namespaces[$prefix])) {
|
|
| 824 | - return $this->namespaces[$prefix]; |
|
| 825 | - } |
|
| 826 | - //$this->setError("No namespace registered for prefix '$prefix'");
|
|
| 827 | - return false; |
|
| 828 | - } |
|
| 829 | - |
|
| 830 | - /** |
|
| 831 | - * returns the prefix for a given namespace (or prefix) |
|
| 832 | - * or false if no prefixes registered for the given namespace |
|
| 833 | - * |
|
| 834 | - * @param string $ns The namespace |
|
| 835 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
| 836 | - * @access public |
|
| 837 | - */ |
|
| 838 | - function getPrefixFromNamespace($ns) {
|
|
| 839 | - foreach ($this->namespaces as $p => $n) {
|
|
| 840 | - if ($ns == $n || $ns == $p) {
|
|
| 841 | - $this->usedNamespaces[$p] = $n; |
|
| 842 | - return $p; |
|
| 843 | - } |
|
| 844 | - } |
|
| 845 | - return false; |
|
| 846 | - } |
|
| 847 | - |
|
| 848 | - /** |
|
| 849 | - * returns the time in ODBC canonical form with microseconds |
|
| 850 | - * |
|
| 851 | - * @return string The time in ODBC canonical form with microseconds |
|
| 852 | - * @access public |
|
| 853 | - */ |
|
| 854 | - function getmicrotime() {
|
|
| 855 | - if (function_exists('gettimeofday')) {
|
|
| 856 | - $tod = gettimeofday(); |
|
| 857 | - $sec = $tod['sec']; |
|
| 858 | - $usec = $tod['usec']; |
|
| 859 | - } else {
|
|
| 860 | - $sec = time(); |
|
| 861 | - $usec = 0; |
|
| 862 | - } |
|
| 863 | - return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
|
|
| 864 | - } |
|
| 865 | - |
|
| 866 | - /** |
|
| 867 | - * Returns a string with the output of var_dump |
|
| 868 | - * |
|
| 869 | - * @param mixed $data The variable to var_dump |
|
| 870 | - * @return string The output of var_dump |
|
| 871 | - * @access public |
|
| 872 | - */ |
|
| 729 | + $str = htmlspecialchars($str); |
|
| 730 | + return nl2br($str); |
|
| 731 | + } |
|
| 732 | + |
|
| 733 | + /** |
|
| 734 | + * contracts (changes namespace to prefix) a qualified name |
|
| 735 | + * |
|
| 736 | + * @param string $qname qname |
|
| 737 | + * @return string contracted qname |
|
| 738 | + * @access private |
|
| 739 | + */ |
|
| 740 | + function contractQname($qname){
|
|
| 741 | + // get element namespace |
|
| 742 | + //$this->xdebug("Contract $qname");
|
|
| 743 | + if (strrpos($qname, ':')) {
|
|
| 744 | + // get unqualified name |
|
| 745 | + $name = substr($qname, strrpos($qname, ':') + 1); |
|
| 746 | + // get ns |
|
| 747 | + $ns = substr($qname, 0, strrpos($qname, ':')); |
|
| 748 | + $p = $this->getPrefixFromNamespace($ns); |
|
| 749 | + if ($p) {
|
|
| 750 | + return $p . ':' . $name; |
|
| 751 | + } |
|
| 752 | + return $qname; |
|
| 753 | + } else {
|
|
| 754 | + return $qname; |
|
| 755 | + } |
|
| 756 | + } |
|
| 757 | + |
|
| 758 | + /** |
|
| 759 | + * expands (changes prefix to namespace) a qualified name |
|
| 760 | + * |
|
| 761 | + * @param string $qname qname |
|
| 762 | + * @return string expanded qname |
|
| 763 | + * @access private |
|
| 764 | + */ |
|
| 765 | + function expandQname($qname){
|
|
| 766 | + // get element prefix |
|
| 767 | + if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
|
|
| 768 | + // get unqualified name |
|
| 769 | + $name = substr(strstr($qname,':'),1); |
|
| 770 | + // get ns prefix |
|
| 771 | + $prefix = substr($qname,0,strpos($qname,':')); |
|
| 772 | + if(isset($this->namespaces[$prefix])){
|
|
| 773 | + return $this->namespaces[$prefix].':'.$name; |
|
| 774 | + } else {
|
|
| 775 | + return $qname; |
|
| 776 | + } |
|
| 777 | + } else {
|
|
| 778 | + return $qname; |
|
| 779 | + } |
|
| 780 | + } |
|
| 781 | + |
|
| 782 | + /** |
|
| 783 | + * returns the local part of a prefixed string |
|
| 784 | + * returns the original string, if not prefixed |
|
| 785 | + * |
|
| 786 | + * @param string $str The prefixed string |
|
| 787 | + * @return string The local part |
|
| 788 | + * @access public |
|
| 789 | + */ |
|
| 790 | + function getLocalPart($str){
|
|
| 791 | + if($sstr = strrchr($str,':')){
|
|
| 792 | + // get unqualified name |
|
| 793 | + return substr( $sstr, 1 ); |
|
| 794 | + } else {
|
|
| 795 | + return $str; |
|
| 796 | + } |
|
| 797 | + } |
|
| 798 | + |
|
| 799 | + /** |
|
| 800 | + * returns the prefix part of a prefixed string |
|
| 801 | + * returns false, if not prefixed |
|
| 802 | + * |
|
| 803 | + * @param string $str The prefixed string |
|
| 804 | + * @return mixed The prefix or false if there is no prefix |
|
| 805 | + * @access public |
|
| 806 | + */ |
|
| 807 | + function getPrefix($str){
|
|
| 808 | + if($pos = strrpos($str,':')){
|
|
| 809 | + // get prefix |
|
| 810 | + return substr($str,0,$pos); |
|
| 811 | + } |
|
| 812 | + return false; |
|
| 813 | + } |
|
| 814 | + |
|
| 815 | + /** |
|
| 816 | + * pass it a prefix, it returns a namespace |
|
| 817 | + * |
|
| 818 | + * @param string $prefix The prefix |
|
| 819 | + * @return mixed The namespace, false if no namespace has the specified prefix |
|
| 820 | + * @access public |
|
| 821 | + */ |
|
| 822 | + function getNamespaceFromPrefix($prefix){
|
|
| 823 | + if (isset($this->namespaces[$prefix])) {
|
|
| 824 | + return $this->namespaces[$prefix]; |
|
| 825 | + } |
|
| 826 | + //$this->setError("No namespace registered for prefix '$prefix'");
|
|
| 827 | + return false; |
|
| 828 | + } |
|
| 829 | + |
|
| 830 | + /** |
|
| 831 | + * returns the prefix for a given namespace (or prefix) |
|
| 832 | + * or false if no prefixes registered for the given namespace |
|
| 833 | + * |
|
| 834 | + * @param string $ns The namespace |
|
| 835 | + * @return mixed The prefix, false if the namespace has no prefixes |
|
| 836 | + * @access public |
|
| 837 | + */ |
|
| 838 | + function getPrefixFromNamespace($ns) {
|
|
| 839 | + foreach ($this->namespaces as $p => $n) {
|
|
| 840 | + if ($ns == $n || $ns == $p) {
|
|
| 841 | + $this->usedNamespaces[$p] = $n; |
|
| 842 | + return $p; |
|
| 843 | + } |
|
| 844 | + } |
|
| 845 | + return false; |
|
| 846 | + } |
|
| 847 | + |
|
| 848 | + /** |
|
| 849 | + * returns the time in ODBC canonical form with microseconds |
|
| 850 | + * |
|
| 851 | + * @return string The time in ODBC canonical form with microseconds |
|
| 852 | + * @access public |
|
| 853 | + */ |
|
| 854 | + function getmicrotime() {
|
|
| 855 | + if (function_exists('gettimeofday')) {
|
|
| 856 | + $tod = gettimeofday(); |
|
| 857 | + $sec = $tod['sec']; |
|
| 858 | + $usec = $tod['usec']; |
|
| 859 | + } else {
|
|
| 860 | + $sec = time(); |
|
| 861 | + $usec = 0; |
|
| 862 | + } |
|
| 863 | + return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
|
|
| 864 | + } |
|
| 865 | + |
|
| 866 | + /** |
|
| 867 | + * Returns a string with the output of var_dump |
|
| 868 | + * |
|
| 869 | + * @param mixed $data The variable to var_dump |
|
| 870 | + * @return string The output of var_dump |
|
| 871 | + * @access public |
|
| 872 | + */ |
|
| 873 | 873 | function varDump($data) {
|
| 874 | - ob_start(); |
|
| 875 | - var_dump($data); |
|
| 876 | - $ret_val = ob_get_contents(); |
|
| 877 | - ob_end_clean(); |
|
| 878 | - return $ret_val; |
|
| 879 | - } |
|
| 880 | - |
|
| 881 | - /** |
|
| 882 | - * represents the object as a string |
|
| 883 | - * |
|
| 884 | - * @return string |
|
| 885 | - * @access public |
|
| 886 | - */ |
|
| 887 | - function __toString() {
|
|
| 888 | - return $this->varDump($this); |
|
| 889 | - } |
|
| 874 | + ob_start(); |
|
| 875 | + var_dump($data); |
|
| 876 | + $ret_val = ob_get_contents(); |
|
| 877 | + ob_end_clean(); |
|
| 878 | + return $ret_val; |
|
| 879 | + } |
|
| 880 | + |
|
| 881 | + /** |
|
| 882 | + * represents the object as a string |
|
| 883 | + * |
|
| 884 | + * @return string |
|
| 885 | + * @access public |
|
| 886 | + */ |
|
| 887 | + function __toString() {
|
|
| 888 | + return $this->varDump($this); |
|
| 889 | + } |
|
| 890 | 890 | } |
| 891 | 891 | |
| 892 | 892 | // XML Schema Datatype Helper Functions |
@@ -902,35 +902,35 @@ discard block |
||
| 902 | 902 | * @access public |
| 903 | 903 | */ |
| 904 | 904 | function timestamp_to_iso8601($timestamp,$utc=true){
|
| 905 | - $datestr = date('Y-m-d\TH:i:sO',$timestamp);
|
|
| 906 | - $pos = strrpos($datestr, "+"); |
|
| 907 | - if ($pos === FALSE) {
|
|
| 908 | - $pos = strrpos($datestr, "-"); |
|
| 909 | - } |
|
| 910 | - if ($pos !== FALSE) {
|
|
| 911 | - if (strlen($datestr) == $pos + 5) {
|
|
| 912 | - $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
| 913 | - } |
|
| 914 | - } |
|
| 915 | - if($utc){
|
|
| 916 | - $pattern = '/'. |
|
| 917 | - '([0-9]{4})-'. // centuries & years CCYY-
|
|
| 918 | - '([0-9]{2})-'. // months MM-
|
|
| 919 | - '([0-9]{2})'. // days DD
|
|
| 920 | - 'T'. // separator T |
|
| 921 | - '([0-9]{2}):'. // hours hh:
|
|
| 922 | - '([0-9]{2}):'. // minutes mm:
|
|
| 923 | - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
|
|
| 924 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 925 | - '/'; |
|
| 926 | - |
|
| 927 | - if(preg_match($pattern,$datestr,$regs)){
|
|
| 928 | - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
|
|
| 929 | - } |
|
| 930 | - return false; |
|
| 931 | - } else {
|
|
| 932 | - return $datestr; |
|
| 933 | - } |
|
| 905 | + $datestr = date('Y-m-d\TH:i:sO',$timestamp);
|
|
| 906 | + $pos = strrpos($datestr, "+"); |
|
| 907 | + if ($pos === FALSE) {
|
|
| 908 | + $pos = strrpos($datestr, "-"); |
|
| 909 | + } |
|
| 910 | + if ($pos !== FALSE) {
|
|
| 911 | + if (strlen($datestr) == $pos + 5) {
|
|
| 912 | + $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
| 913 | + } |
|
| 914 | + } |
|
| 915 | + if($utc){
|
|
| 916 | + $pattern = '/'. |
|
| 917 | + '([0-9]{4})-'. // centuries & years CCYY-
|
|
| 918 | + '([0-9]{2})-'. // months MM-
|
|
| 919 | + '([0-9]{2})'. // days DD
|
|
| 920 | + 'T'. // separator T |
|
| 921 | + '([0-9]{2}):'. // hours hh:
|
|
| 922 | + '([0-9]{2}):'. // minutes mm:
|
|
| 923 | + '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
|
|
| 924 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 925 | + '/'; |
|
| 926 | + |
|
| 927 | + if(preg_match($pattern,$datestr,$regs)){
|
|
| 928 | + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
|
|
| 929 | + } |
|
| 930 | + return false; |
|
| 931 | + } else {
|
|
| 932 | + return $datestr; |
|
| 933 | + } |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -941,35 +941,35 @@ discard block |
||
| 941 | 941 | * @access public |
| 942 | 942 | */ |
| 943 | 943 | function iso8601_to_timestamp($datestr){
|
| 944 | - $pattern = '/'. |
|
| 945 | - '([0-9]{4})-'. // centuries & years CCYY-
|
|
| 946 | - '([0-9]{2})-'. // months MM-
|
|
| 947 | - '([0-9]{2})'. // days DD
|
|
| 948 | - 'T'. // separator T |
|
| 949 | - '([0-9]{2}):'. // hours hh:
|
|
| 950 | - '([0-9]{2}):'. // minutes mm:
|
|
| 951 | - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
|
|
| 952 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 953 | - '/'; |
|
| 954 | - if(preg_match($pattern,$datestr,$regs)){
|
|
| 955 | - // not utc |
|
| 956 | - if($regs[8] != 'Z'){
|
|
| 957 | - $op = substr($regs[8],0,1); |
|
| 958 | - $h = substr($regs[8],1,2); |
|
| 959 | - $m = substr($regs[8],strlen($regs[8])-2,2); |
|
| 960 | - if($op == '-'){
|
|
| 961 | - $regs[4] = $regs[4] + $h; |
|
| 962 | - $regs[5] = $regs[5] + $m; |
|
| 963 | - } elseif($op == '+'){
|
|
| 964 | - $regs[4] = $regs[4] - $h; |
|
| 965 | - $regs[5] = $regs[5] - $m; |
|
| 966 | - } |
|
| 967 | - } |
|
| 968 | - return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
| 944 | + $pattern = '/'. |
|
| 945 | + '([0-9]{4})-'. // centuries & years CCYY-
|
|
| 946 | + '([0-9]{2})-'. // months MM-
|
|
| 947 | + '([0-9]{2})'. // days DD
|
|
| 948 | + 'T'. // separator T |
|
| 949 | + '([0-9]{2}):'. // hours hh:
|
|
| 950 | + '([0-9]{2}):'. // minutes mm:
|
|
| 951 | + '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
|
|
| 952 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 953 | + '/'; |
|
| 954 | + if(preg_match($pattern,$datestr,$regs)){
|
|
| 955 | + // not utc |
|
| 956 | + if($regs[8] != 'Z'){
|
|
| 957 | + $op = substr($regs[8],0,1); |
|
| 958 | + $h = substr($regs[8],1,2); |
|
| 959 | + $m = substr($regs[8],strlen($regs[8])-2,2); |
|
| 960 | + if($op == '-'){
|
|
| 961 | + $regs[4] = $regs[4] + $h; |
|
| 962 | + $regs[5] = $regs[5] + $m; |
|
| 963 | + } elseif($op == '+'){
|
|
| 964 | + $regs[4] = $regs[4] - $h; |
|
| 965 | + $regs[5] = $regs[5] - $m; |
|
| 966 | + } |
|
| 967 | + } |
|
| 968 | + return gmmktime($regs[4], $regs[5], $regs[6], $regs[2], $regs[3], $regs[1]); |
|
| 969 | 969 | // return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
|
| 970 | - } else {
|
|
| 971 | - return false; |
|
| 972 | - } |
|
| 970 | + } else {
|
|
| 971 | + return false; |
|
| 972 | + } |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | /** |
@@ -981,15 +981,15 @@ discard block |
||
| 981 | 981 | */ |
| 982 | 982 | function usleepWindows($usec) |
| 983 | 983 | {
|
| 984 | - $start = gettimeofday(); |
|
| 985 | - |
|
| 986 | - do |
|
| 987 | - {
|
|
| 988 | - $stop = gettimeofday(); |
|
| 989 | - $timePassed = 1000000 * ($stop['sec'] - $start['sec']) |
|
| 990 | - + $stop['usec'] - $start['usec']; |
|
| 991 | - } |
|
| 992 | - while ($timePassed < $usec); |
|
| 984 | + $start = gettimeofday(); |
|
| 985 | + |
|
| 986 | + do |
|
| 987 | + {
|
|
| 988 | + $stop = gettimeofday(); |
|
| 989 | + $timePassed = 1000000 * ($stop['sec'] - $start['sec']) |
|
| 990 | + + $stop['usec'] - $start['usec']; |
|
| 991 | + } |
|
| 992 | + while ($timePassed < $usec); |
|
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 | |
@@ -183,26 +183,26 @@ discard block |
||
| 183 | 183 | */ |
| 184 | 184 | var $typemap = array( |
| 185 | 185 | 'http://www.w3.org/2001/XMLSchema' => array( |
| 186 | - 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
|
| 187 | - 'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'', |
|
| 188 | - 'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string', |
|
| 186 | + 'string'=>'string', 'boolean'=>'boolean', 'float'=>'double', 'double'=>'double', 'decimal'=>'double', |
|
| 187 | + 'duration'=>'', 'dateTime'=>'string', 'time'=>'string', 'date'=>'string', 'gYearMonth'=>'', |
|
| 188 | + 'gYear'=>'', 'gMonthDay'=>'', 'gDay'=>'', 'gMonth'=>'', 'hexBinary'=>'string', 'base64Binary'=>'string', |
|
| 189 | 189 | // abstract "any" types |
| 190 | - 'anyType'=>'string','anySimpleType'=>'string', |
|
| 190 | + 'anyType'=>'string', 'anySimpleType'=>'string', |
|
| 191 | 191 | // derived datatypes |
| 192 | - 'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'', |
|
| 193 | - 'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer', |
|
| 194 | - 'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer', |
|
| 195 | - 'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''), |
|
| 192 | + 'normalizedString'=>'string', 'token'=>'string', 'language'=>'', 'NMTOKEN'=>'', 'NMTOKENS'=>'', 'Name'=>'', 'NCName'=>'', 'ID'=>'', |
|
| 193 | + 'IDREF'=>'', 'IDREFS'=>'', 'ENTITY'=>'', 'ENTITIES'=>'', 'integer'=>'integer', 'nonPositiveInteger'=>'integer', |
|
| 194 | + 'negativeInteger'=>'integer', 'long'=>'integer', 'int'=>'integer', 'short'=>'integer', 'byte'=>'integer', 'nonNegativeInteger'=>'integer', |
|
| 195 | + 'unsignedLong'=>'', 'unsignedInt'=>'', 'unsignedShort'=>'', 'unsignedByte'=>'', 'positiveInteger'=>''), |
|
| 196 | 196 | 'http://www.w3.org/2000/10/XMLSchema' => array( |
| 197 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 198 | - 'float'=>'double','dateTime'=>'string', |
|
| 199 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 197 | + 'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double', |
|
| 198 | + 'float'=>'double', 'dateTime'=>'string', |
|
| 199 | + 'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'), |
|
| 200 | 200 | 'http://www.w3.org/1999/XMLSchema' => array( |
| 201 | - 'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double', |
|
| 202 | - 'float'=>'double','dateTime'=>'string', |
|
| 203 | - 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
|
| 201 | + 'i4'=>'', 'int'=>'integer', 'boolean'=>'boolean', 'string'=>'string', 'double'=>'double', |
|
| 202 | + 'float'=>'double', 'dateTime'=>'string', |
|
| 203 | + 'timeInstant'=>'string', 'base64Binary'=>'string', 'base64'=>'string', 'ur-type'=>'array'), |
|
| 204 | 204 | 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
|
| 205 | - 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
|
|
| 205 | + 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string', 'array'=>'array', 'Array'=>'array'),
|
|
| 206 | 206 | 'http://xml.apache.org/xml-soap' => array('Map')
|
| 207 | 207 | ); |
| 208 | 208 | |
@@ -214,8 +214,8 @@ discard block |
||
| 214 | 214 | * @deprecated |
| 215 | 215 | * @see expandEntities |
| 216 | 216 | */ |
| 217 | - var $xmlEntities = array('quot' => '"','amp' => '&',
|
|
| 218 | - 'lt' => '<','gt' => '>','apos' => "'"); |
|
| 217 | + var $xmlEntities = array('quot' => '"', 'amp' => '&',
|
|
| 218 | + 'lt' => '<', 'gt' => '>', 'apos' => "'"); |
|
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | 221 | * constructor |
@@ -272,7 +272,7 @@ discard block |
||
| 272 | 272 | * @param string $string debug data |
| 273 | 273 | * @access private |
| 274 | 274 | */ |
| 275 | - function debug($string){
|
|
| 275 | + function debug($string) {
|
|
| 276 | 276 | if ($this->debugLevel > 0) {
|
| 277 | 277 | $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
| 278 | 278 | } |
@@ -284,7 +284,7 @@ discard block |
||
| 284 | 284 | * @param string $string debug data |
| 285 | 285 | * @access public |
| 286 | 286 | */ |
| 287 | - function appendDebug($string){
|
|
| 287 | + function appendDebug($string) {
|
|
| 288 | 288 | if ($this->debugLevel > 0) {
|
| 289 | 289 | // it would be nice to use a memory stream here to use |
| 290 | 290 | // memory more efficiently |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | while (strpos($this->debug_str, '--')) {
|
| 329 | 329 | $this->debug_str = str_replace('--', '- -', $this->debug_str);
|
| 330 | 330 | } |
| 331 | - $ret = "<!--\n" . $this->debug_str . "\n-->"; |
|
| 331 | + $ret = "<!--\n".$this->debug_str."\n-->"; |
|
| 332 | 332 | return $ret; |
| 333 | 333 | } |
| 334 | 334 | |
@@ -355,8 +355,8 @@ discard block |
||
| 355 | 355 | * @return mixed error string or false |
| 356 | 356 | * @access public |
| 357 | 357 | */ |
| 358 | - function getError(){
|
|
| 359 | - if($this->error_str != ''){
|
|
| 358 | + function getError() {
|
|
| 359 | + if ($this->error_str != '') {
|
|
| 360 | 360 | return $this->error_str; |
| 361 | 361 | } |
| 362 | 362 | return false; |
@@ -368,7 +368,7 @@ discard block |
||
| 368 | 368 | * @return boolean $string error string |
| 369 | 369 | * @access private |
| 370 | 370 | */ |
| 371 | - function setError($str){
|
|
| 371 | + function setError($str) {
|
|
| 372 | 372 | $this->error_str = $str; |
| 373 | 373 | } |
| 374 | 374 | |
@@ -404,12 +404,12 @@ discard block |
||
| 404 | 404 | * @return string The serialized element, possibly with child elements |
| 405 | 405 | * @access public |
| 406 | 406 | */ |
| 407 | - function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) {
|
|
| 407 | + function serialize_val($val, $name = false, $type = false, $name_ns = false, $type_ns = false, $attributes = false, $use = 'encoded', $soapval = false) {
|
|
| 408 | 408 | $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval");
|
| 409 | - $this->appendDebug('value=' . $this->varDump($val));
|
|
| 410 | - $this->appendDebug('attributes=' . $this->varDump($attributes));
|
|
| 409 | + $this->appendDebug('value='.$this->varDump($val));
|
|
| 410 | + $this->appendDebug('attributes='.$this->varDump($attributes));
|
|
| 411 | 411 | |
| 412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) {
|
|
| 412 | + if (is_object($val) && get_class($val) == 'soapval' && (!$soapval)) {
|
|
| 413 | 413 | $this->debug("serialize_val: serialize soapval");
|
| 414 | 414 | $xml = $val->serialize($use); |
| 415 | 415 | $this->appendDebug($val->getDebug()); |
@@ -419,30 +419,30 @@ discard block |
||
| 419 | 419 | } |
| 420 | 420 | // force valid name if necessary |
| 421 | 421 | if (is_numeric($name)) {
|
| 422 | - $name = '__numeric_' . $name; |
|
| 423 | - } elseif (! $name) {
|
|
| 422 | + $name = '__numeric_'.$name; |
|
| 423 | + } elseif (!$name) {
|
|
| 424 | 424 | $name = 'noname'; |
| 425 | 425 | } |
| 426 | 426 | // if name has ns, add ns prefix to name |
| 427 | 427 | $xmlns = ''; |
| 428 | - if($name_ns){
|
|
| 429 | - $prefix = 'nu'.rand(1000,9999); |
|
| 428 | + if ($name_ns) {
|
|
| 429 | + $prefix = 'nu'.rand(1000, 9999); |
|
| 430 | 430 | $name = $prefix.':'.$name; |
| 431 | 431 | $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
| 432 | 432 | } |
| 433 | 433 | // if type is prefixed, create type prefix |
| 434 | - if($type_ns != '' && $type_ns == $this->namespaces['xsd']){
|
|
| 434 | + if ($type_ns != '' && $type_ns == $this->namespaces['xsd']) {
|
|
| 435 | 435 | // need to fix this. shouldn't default to xsd if no ns specified |
| 436 | 436 | // w/o checking against typemap |
| 437 | 437 | $type_prefix = 'xsd'; |
| 438 | - } elseif($type_ns){
|
|
| 439 | - $type_prefix = 'ns'.rand(1000,9999); |
|
| 438 | + } elseif ($type_ns) {
|
|
| 439 | + $type_prefix = 'ns'.rand(1000, 9999); |
|
| 440 | 440 | $xmlns .= " xmlns:$type_prefix=\"$type_ns\""; |
| 441 | 441 | } |
| 442 | 442 | // serialize attributes if present |
| 443 | 443 | $atts = ''; |
| 444 | - if($attributes){
|
|
| 445 | - foreach($attributes as $k => $v){
|
|
| 444 | + if ($attributes) {
|
|
| 445 | + foreach ($attributes as $k => $v) {
|
|
| 446 | 446 | $atts .= " $k=\"".$this->expandEntities($v).'"'; |
| 447 | 447 | } |
| 448 | 448 | } |
@@ -466,12 +466,12 @@ discard block |
||
| 466 | 466 | } |
| 467 | 467 | } |
| 468 | 468 | // serialize if an xsd built-in primitive type |
| 469 | - if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){
|
|
| 469 | + if ($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])) {
|
|
| 470 | 470 | $this->debug("serialize_val: serialize xsd built-in primitive type");
|
| 471 | 471 | if (is_bool($val)) {
|
| 472 | 472 | if ($type == 'boolean') {
|
| 473 | 473 | $val = $val ? 'true' : 'false'; |
| 474 | - } elseif (! $val) {
|
|
| 474 | + } elseif (!$val) {
|
|
| 475 | 475 | $val = 0; |
| 476 | 476 | } |
| 477 | 477 | } else if (is_string($val)) {
|
@@ -489,12 +489,12 @@ discard block |
||
| 489 | 489 | } |
| 490 | 490 | // detect type and serialize |
| 491 | 491 | $xml = ''; |
| 492 | - switch(true) {
|
|
| 492 | + switch (true) {
|
|
| 493 | 493 | case (is_bool($val) || $type == 'boolean'): |
| 494 | 494 | $this->debug("serialize_val: serialize boolean");
|
| 495 | 495 | if ($type == 'boolean') {
|
| 496 | 496 | $val = $val ? 'true' : 'false'; |
| 497 | - } elseif (! $val) {
|
|
| 497 | + } elseif (!$val) {
|
|
| 498 | 498 | $val = 0; |
| 499 | 499 | } |
| 500 | 500 | if ($use == 'literal') {
|
@@ -511,7 +511,7 @@ discard block |
||
| 511 | 511 | $xml .= "<$name$xmlns xsi:type=\"xsd:int\"$atts>$val</$name>"; |
| 512 | 512 | } |
| 513 | 513 | break; |
| 514 | - case (is_float($val)|| is_double($val) || $type == 'float'): |
|
| 514 | + case (is_float($val) || is_double($val) || $type == 'float'): |
|
| 515 | 515 | $this->debug("serialize_val: serialize float");
|
| 516 | 516 | if ($use == 'literal') {
|
| 517 | 517 | $xml .= "<$name$xmlns$atts>$val</$name>"; |
@@ -536,17 +536,17 @@ discard block |
||
| 536 | 536 | $this->appendDebug($val->getDebug()); |
| 537 | 537 | $val->clearDebug(); |
| 538 | 538 | } else {
|
| 539 | - if (! $name) {
|
|
| 539 | + if (!$name) {
|
|
| 540 | 540 | $name = get_class($val); |
| 541 | 541 | $this->debug("In serialize_val, used class name $name as element name");
|
| 542 | 542 | } else {
|
| 543 | - $this->debug("In serialize_val, do not override name $name for element name for class " . get_class($val));
|
|
| 543 | + $this->debug("In serialize_val, do not override name $name for element name for class ".get_class($val));
|
|
| 544 | 544 | } |
| 545 | - foreach(get_object_vars($val) as $k => $v){
|
|
| 546 | - $pXml = isset($pXml) ? $pXml.$this->serialize_val($v,$k,false,false,false,false,$use) : $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 545 | + foreach (get_object_vars($val) as $k => $v) {
|
|
| 546 | + $pXml = isset($pXml) ? $pXml.$this->serialize_val($v, $k, false, false, false, false, $use) : $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | - if(isset($type) && isset($type_prefix)){
|
|
| 549 | + if (isset($type) && isset($type_prefix)) {
|
|
| 550 | 550 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 551 | 551 | } else {
|
| 552 | 552 | $type_str = ''; |
@@ -561,12 +561,12 @@ discard block |
||
| 561 | 561 | case (is_array($val) || $type): |
| 562 | 562 | // detect if struct or array |
| 563 | 563 | $valueType = $this->isArraySimpleOrStruct($val); |
| 564 | - if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
|
|
| 564 | + if ($valueType == 'arraySimple' || preg_match('/^ArrayOf/', $type)) {
|
|
| 565 | 565 | $this->debug("serialize_val: serialize array");
|
| 566 | 566 | $i = 0; |
| 567 | - if(is_array($val) && count($val)> 0){
|
|
| 568 | - foreach($val as $v){
|
|
| 569 | - if(is_object($v) && get_class($v) == 'soapval'){
|
|
| 567 | + if (is_array($val) && count($val) > 0) {
|
|
| 568 | + foreach ($val as $v) {
|
|
| 569 | + if (is_object($v) && get_class($v) == 'soapval') {
|
|
| 570 | 570 | $tt_ns = $v->type_ns; |
| 571 | 571 | $tt = $v->type; |
| 572 | 572 | } elseif (is_array($v)) {
|
@@ -576,26 +576,26 @@ discard block |
||
| 576 | 576 | } |
| 577 | 577 | $array_types[$tt] = 1; |
| 578 | 578 | // TODO: for literal, the name should be $name |
| 579 | - $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
|
| 579 | + $xml .= $this->serialize_val($v, 'item', false, false, false, false, $use); |
|
| 580 | 580 | ++$i; |
| 581 | 581 | } |
| 582 | - if(count($array_types) > 1){
|
|
| 582 | + if (count($array_types) > 1) {
|
|
| 583 | 583 | $array_typename = 'xsd:anyType'; |
| 584 | - } elseif(isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
|
|
| 584 | + } elseif (isset($tt) && isset($this->typemap[$this->XMLSchemaVersion][$tt])) {
|
|
| 585 | 585 | if ($tt == 'integer') {
|
| 586 | 586 | $tt = 'int'; |
| 587 | 587 | } |
| 588 | 588 | $array_typename = 'xsd:'.$tt; |
| 589 | - } elseif(isset($tt) && $tt == 'arraySimple'){
|
|
| 589 | + } elseif (isset($tt) && $tt == 'arraySimple') {
|
|
| 590 | 590 | $array_typename = 'SOAP-ENC:Array'; |
| 591 | - } elseif(isset($tt) && $tt == 'arrayStruct'){
|
|
| 591 | + } elseif (isset($tt) && $tt == 'arrayStruct') {
|
|
| 592 | 592 | $array_typename = 'unnamed_struct_use_soapval'; |
| 593 | 593 | } else {
|
| 594 | 594 | // if type is prefixed, create type prefix |
| 595 | - if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']){
|
|
| 596 | - $array_typename = 'xsd:' . $tt; |
|
| 595 | + if ($tt_ns != '' && $tt_ns == $this->namespaces['xsd']) {
|
|
| 596 | + $array_typename = 'xsd:'.$tt; |
|
| 597 | 597 | } elseif ($tt_ns) {
|
| 598 | - $tt_prefix = 'ns' . rand(1000, 9999); |
|
| 598 | + $tt_prefix = 'ns'.rand(1000, 9999); |
|
| 599 | 599 | $array_typename = "$tt_prefix:$tt"; |
| 600 | 600 | $xmlns .= " xmlns:$tt_prefix=\"$tt_ns\""; |
| 601 | 601 | } else {
|
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | } else {
|
| 626 | 626 | // got a struct |
| 627 | 627 | $this->debug("serialize_val: serialize struct");
|
| 628 | - if(isset($type) && isset($type_prefix)){
|
|
| 628 | + if (isset($type) && isset($type_prefix)) {
|
|
| 629 | 629 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 630 | 630 | } else {
|
| 631 | 631 | $type_str = ''; |
@@ -635,15 +635,15 @@ discard block |
||
| 635 | 635 | } else {
|
| 636 | 636 | $xml .= "<$name$xmlns$type_str$atts>"; |
| 637 | 637 | } |
| 638 | - foreach($val as $k => $v){
|
|
| 638 | + foreach ($val as $k => $v) {
|
|
| 639 | 639 | // Apache Map |
| 640 | 640 | if ($type == 'Map' && $type_ns == 'http://xml.apache.org/xml-soap') {
|
| 641 | 641 | $xml .= '<item>'; |
| 642 | - $xml .= $this->serialize_val($k,'key',false,false,false,false,$use); |
|
| 643 | - $xml .= $this->serialize_val($v,'value',false,false,false,false,$use); |
|
| 642 | + $xml .= $this->serialize_val($k, 'key', false, false, false, false, $use); |
|
| 643 | + $xml .= $this->serialize_val($v, 'value', false, false, false, false, $use); |
|
| 644 | 644 | $xml .= '</item>'; |
| 645 | 645 | } else {
|
| 646 | - $xml .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 646 | + $xml .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 647 | 647 | } |
| 648 | 648 | } |
| 649 | 649 | $xml .= "</$name>"; |
@@ -670,12 +670,12 @@ discard block |
||
| 670 | 670 | * @return string the message |
| 671 | 671 | * @access public |
| 672 | 672 | */ |
| 673 | - function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){
|
|
| 673 | + function serializeEnvelope($body, $headers = false, $namespaces = array(), $style = 'rpc', $use = 'encoded', $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/') {
|
|
| 674 | 674 | // TODO: add an option to automatically run utf8_encode on $body and $headers |
| 675 | 675 | // if $this->soap_defencoding is UTF-8. Not doing this automatically allows |
| 676 | 676 | // one to send arbitrary UTF-8 characters, not just characters that map to ISO-8859-1 |
| 677 | 677 | |
| 678 | - $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle");
|
|
| 678 | + $this->debug("In serializeEnvelope length=".strlen($body)." body (max 1000 characters)=".substr($body, 0, 1000)." style=$style use=$use encodingStyle=$encodingStyle");
|
|
| 679 | 679 | $this->debug("headers:");
|
| 680 | 680 | $this->appendDebug($this->varDump($headers)); |
| 681 | 681 | $this->debug("namespaces:");
|
@@ -683,15 +683,15 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | // serialize namespaces |
| 685 | 685 | $ns_string = ''; |
| 686 | - foreach(array_merge($this->namespaces,$namespaces) as $k => $v){
|
|
| 686 | + foreach (array_merge($this->namespaces, $namespaces) as $k => $v) {
|
|
| 687 | 687 | $ns_string .= " xmlns:$k=\"$v\""; |
| 688 | 688 | } |
| 689 | - if($encodingStyle) {
|
|
| 689 | + if ($encodingStyle) {
|
|
| 690 | 690 | $ns_string = " SOAP-ENV:encodingStyle=\"$encodingStyle\"$ns_string"; |
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | // serialize headers |
| 694 | - if($headers){
|
|
| 694 | + if ($headers) {
|
|
| 695 | 695 | if (is_array($headers)) {
|
| 696 | 696 | $xml = ''; |
| 697 | 697 | foreach ($headers as $k => $v) {
|
@@ -708,7 +708,7 @@ discard block |
||
| 708 | 708 | } |
| 709 | 709 | // serialize envelope |
| 710 | 710 | return |
| 711 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding .'"?'.">". |
|
| 711 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?'.">". |
|
| 712 | 712 | '<SOAP-ENV:Envelope'.$ns_string.">". |
| 713 | 713 | $headers. |
| 714 | 714 | "<SOAP-ENV:Body>". |
@@ -725,7 +725,7 @@ discard block |
||
| 725 | 725 | * @access public |
| 726 | 726 | * @deprecated |
| 727 | 727 | */ |
| 728 | - function formatDump($str){
|
|
| 728 | + function formatDump($str) {
|
|
| 729 | 729 | $str = htmlspecialchars($str); |
| 730 | 730 | return nl2br($str); |
| 731 | 731 | } |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | * @return string contracted qname |
| 738 | 738 | * @access private |
| 739 | 739 | */ |
| 740 | - function contractQname($qname){
|
|
| 740 | + function contractQname($qname) {
|
|
| 741 | 741 | // get element namespace |
| 742 | 742 | //$this->xdebug("Contract $qname");
|
| 743 | 743 | if (strrpos($qname, ':')) {
|
@@ -747,7 +747,7 @@ discard block |
||
| 747 | 747 | $ns = substr($qname, 0, strrpos($qname, ':')); |
| 748 | 748 | $p = $this->getPrefixFromNamespace($ns); |
| 749 | 749 | if ($p) {
|
| 750 | - return $p . ':' . $name; |
|
| 750 | + return $p.':'.$name; |
|
| 751 | 751 | } |
| 752 | 752 | return $qname; |
| 753 | 753 | } else {
|
@@ -762,14 +762,14 @@ discard block |
||
| 762 | 762 | * @return string expanded qname |
| 763 | 763 | * @access private |
| 764 | 764 | */ |
| 765 | - function expandQname($qname){
|
|
| 765 | + function expandQname($qname) {
|
|
| 766 | 766 | // get element prefix |
| 767 | - if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
|
|
| 767 | + if (strpos($qname, ':') && !preg_match('/^http:\/\//', $qname)) {
|
|
| 768 | 768 | // get unqualified name |
| 769 | - $name = substr(strstr($qname,':'),1); |
|
| 769 | + $name = substr(strstr($qname, ':'), 1); |
|
| 770 | 770 | // get ns prefix |
| 771 | - $prefix = substr($qname,0,strpos($qname,':')); |
|
| 772 | - if(isset($this->namespaces[$prefix])){
|
|
| 771 | + $prefix = substr($qname, 0, strpos($qname, ':')); |
|
| 772 | + if (isset($this->namespaces[$prefix])) {
|
|
| 773 | 773 | return $this->namespaces[$prefix].':'.$name; |
| 774 | 774 | } else {
|
| 775 | 775 | return $qname; |
@@ -787,10 +787,10 @@ discard block |
||
| 787 | 787 | * @return string The local part |
| 788 | 788 | * @access public |
| 789 | 789 | */ |
| 790 | - function getLocalPart($str){
|
|
| 791 | - if($sstr = strrchr($str,':')){
|
|
| 790 | + function getLocalPart($str) {
|
|
| 791 | + if ($sstr = strrchr($str, ':')) {
|
|
| 792 | 792 | // get unqualified name |
| 793 | - return substr( $sstr, 1 ); |
|
| 793 | + return substr($sstr, 1); |
|
| 794 | 794 | } else {
|
| 795 | 795 | return $str; |
| 796 | 796 | } |
@@ -804,10 +804,10 @@ discard block |
||
| 804 | 804 | * @return mixed The prefix or false if there is no prefix |
| 805 | 805 | * @access public |
| 806 | 806 | */ |
| 807 | - function getPrefix($str){
|
|
| 808 | - if($pos = strrpos($str,':')){
|
|
| 807 | + function getPrefix($str) {
|
|
| 808 | + if ($pos = strrpos($str, ':')) {
|
|
| 809 | 809 | // get prefix |
| 810 | - return substr($str,0,$pos); |
|
| 810 | + return substr($str, 0, $pos); |
|
| 811 | 811 | } |
| 812 | 812 | return false; |
| 813 | 813 | } |
@@ -819,7 +819,7 @@ discard block |
||
| 819 | 819 | * @return mixed The namespace, false if no namespace has the specified prefix |
| 820 | 820 | * @access public |
| 821 | 821 | */ |
| 822 | - function getNamespaceFromPrefix($prefix){
|
|
| 822 | + function getNamespaceFromPrefix($prefix) {
|
|
| 823 | 823 | if (isset($this->namespaces[$prefix])) {
|
| 824 | 824 | return $this->namespaces[$prefix]; |
| 825 | 825 | } |
@@ -860,7 +860,7 @@ discard block |
||
| 860 | 860 | $sec = time(); |
| 861 | 861 | $usec = 0; |
| 862 | 862 | } |
| 863 | - return strftime('%Y-%m-%d %H:%M:%S', $sec) . '.' . sprintf('%06d', $usec);
|
|
| 863 | + return strftime('%Y-%m-%d %H:%M:%S', $sec).'.'.sprintf('%06d', $usec);
|
|
| 864 | 864 | } |
| 865 | 865 | |
| 866 | 866 | /** |
@@ -901,31 +901,31 @@ discard block |
||
| 901 | 901 | * @return mixed ISO 8601 date string or false |
| 902 | 902 | * @access public |
| 903 | 903 | */ |
| 904 | -function timestamp_to_iso8601($timestamp,$utc=true){
|
|
| 905 | - $datestr = date('Y-m-d\TH:i:sO',$timestamp);
|
|
| 904 | +function timestamp_to_iso8601($timestamp, $utc = true) {
|
|
| 905 | + $datestr = date('Y-m-d\TH:i:sO', $timestamp);
|
|
| 906 | 906 | $pos = strrpos($datestr, "+"); |
| 907 | 907 | if ($pos === FALSE) {
|
| 908 | 908 | $pos = strrpos($datestr, "-"); |
| 909 | 909 | } |
| 910 | 910 | if ($pos !== FALSE) {
|
| 911 | 911 | if (strlen($datestr) == $pos + 5) {
|
| 912 | - $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2); |
|
| 912 | + $datestr = substr($datestr, 0, $pos + 3).':'.substr($datestr, -2); |
|
| 913 | 913 | } |
| 914 | 914 | } |
| 915 | - if($utc){
|
|
| 915 | + if ($utc) {
|
|
| 916 | 916 | $pattern = '/'. |
| 917 | - '([0-9]{4})-'. // centuries & years CCYY-
|
|
| 918 | - '([0-9]{2})-'. // months MM-
|
|
| 919 | - '([0-9]{2})'. // days DD
|
|
| 920 | - 'T'. // separator T |
|
| 921 | - '([0-9]{2}):'. // hours hh:
|
|
| 922 | - '([0-9]{2}):'. // minutes mm:
|
|
| 923 | - '([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
|
|
| 924 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 917 | + '([0-9]{4})-'.// centuries & years CCYY-
|
|
| 918 | + '([0-9]{2})-'.// months MM-
|
|
| 919 | + '([0-9]{2})'.// days DD
|
|
| 920 | + 'T'.// separator T |
|
| 921 | + '([0-9]{2}):'.// hours hh:
|
|
| 922 | + '([0-9]{2}):'.// minutes mm:
|
|
| 923 | + '([0-9]{2})(\.[0-9]*)?'.// seconds ss.ss...
|
|
| 924 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 925 | 925 | '/'; |
| 926 | 926 | |
| 927 | - if(preg_match($pattern,$datestr,$regs)){
|
|
| 928 | - return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
|
|
| 927 | + if (preg_match($pattern, $datestr, $regs)) {
|
|
| 928 | + return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ', $regs[1], $regs[2], $regs[3], $regs[4], $regs[5], $regs[6]);
|
|
| 929 | 929 | } |
| 930 | 930 | return false; |
| 931 | 931 | } else {
|
@@ -940,27 +940,27 @@ discard block |
||
| 940 | 940 | * @return mixed Unix timestamp (int) or false |
| 941 | 941 | * @access public |
| 942 | 942 | */ |
| 943 | -function iso8601_to_timestamp($datestr){
|
|
| 943 | +function iso8601_to_timestamp($datestr) {
|
|
| 944 | 944 | $pattern = '/'. |
| 945 | - '([0-9]{4})-'. // centuries & years CCYY-
|
|
| 946 | - '([0-9]{2})-'. // months MM-
|
|
| 947 | - '([0-9]{2})'. // days DD
|
|
| 948 | - 'T'. // separator T |
|
| 949 | - '([0-9]{2}):'. // hours hh:
|
|
| 950 | - '([0-9]{2}):'. // minutes mm:
|
|
| 951 | - '([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
|
|
| 952 | - '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 945 | + '([0-9]{4})-'.// centuries & years CCYY-
|
|
| 946 | + '([0-9]{2})-'.// months MM-
|
|
| 947 | + '([0-9]{2})'.// days DD
|
|
| 948 | + 'T'.// separator T |
|
| 949 | + '([0-9]{2}):'.// hours hh:
|
|
| 950 | + '([0-9]{2}):'.// minutes mm:
|
|
| 951 | + '([0-9]{2})(\.[0-9]+)?'.// seconds ss.ss...
|
|
| 952 | + '(Z|[+\-][0-9]{2}:?[0-9]{2})?'.// Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
|
|
| 953 | 953 | '/'; |
| 954 | - if(preg_match($pattern,$datestr,$regs)){
|
|
| 954 | + if (preg_match($pattern, $datestr, $regs)) {
|
|
| 955 | 955 | // not utc |
| 956 | - if($regs[8] != 'Z'){
|
|
| 957 | - $op = substr($regs[8],0,1); |
|
| 958 | - $h = substr($regs[8],1,2); |
|
| 959 | - $m = substr($regs[8],strlen($regs[8])-2,2); |
|
| 960 | - if($op == '-'){
|
|
| 956 | + if ($regs[8] != 'Z') {
|
|
| 957 | + $op = substr($regs[8], 0, 1); |
|
| 958 | + $h = substr($regs[8], 1, 2); |
|
| 959 | + $m = substr($regs[8], strlen($regs[8]) - 2, 2); |
|
| 960 | + if ($op == '-') {
|
|
| 961 | 961 | $regs[4] = $regs[4] + $h; |
| 962 | 962 | $regs[5] = $regs[5] + $m; |
| 963 | - } elseif($op == '+'){
|
|
| 963 | + } elseif ($op == '+') {
|
|
| 964 | 964 | $regs[4] = $regs[4] - $h; |
| 965 | 965 | $regs[5] = $regs[5] - $m; |
| 966 | 966 | } |
@@ -43,7 +43,7 @@ |
||
| 43 | 43 | * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
| 44 | 44 | * @param string $faultactor only used when msg routed between multiple actors |
| 45 | 45 | * @param string $faultstring human readable error message |
| 46 | - * @param mixed $faultdetail detail, typically a string or array of string |
|
| 46 | + * @param string $faultdetail detail, typically a string or array of string |
|
| 47 | 47 | */ |
| 48 | 48 | function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
|
| 49 | 49 | parent::nusoap_base(); |
@@ -12,72 +12,72 @@ |
||
| 12 | 12 | * @access public |
| 13 | 13 | */ |
| 14 | 14 | class nusoap_fault extends nusoap_base {
|
| 15 | - /** |
|
| 16 | - * The fault code (client|server) |
|
| 17 | - * @var string |
|
| 18 | - * @access private |
|
| 19 | - */ |
|
| 20 | - var $faultcode; |
|
| 21 | - /** |
|
| 22 | - * The fault actor |
|
| 23 | - * @var string |
|
| 24 | - * @access private |
|
| 25 | - */ |
|
| 26 | - var $faultactor; |
|
| 27 | - /** |
|
| 28 | - * The fault string, a description of the fault |
|
| 29 | - * @var string |
|
| 30 | - * @access private |
|
| 31 | - */ |
|
| 32 | - var $faultstring; |
|
| 33 | - /** |
|
| 34 | - * The fault detail, typically a string or array of string |
|
| 35 | - * @var mixed |
|
| 36 | - * @access private |
|
| 37 | - */ |
|
| 38 | - var $faultdetail; |
|
| 15 | + /** |
|
| 16 | + * The fault code (client|server) |
|
| 17 | + * @var string |
|
| 18 | + * @access private |
|
| 19 | + */ |
|
| 20 | + var $faultcode; |
|
| 21 | + /** |
|
| 22 | + * The fault actor |
|
| 23 | + * @var string |
|
| 24 | + * @access private |
|
| 25 | + */ |
|
| 26 | + var $faultactor; |
|
| 27 | + /** |
|
| 28 | + * The fault string, a description of the fault |
|
| 29 | + * @var string |
|
| 30 | + * @access private |
|
| 31 | + */ |
|
| 32 | + var $faultstring; |
|
| 33 | + /** |
|
| 34 | + * The fault detail, typically a string or array of string |
|
| 35 | + * @var mixed |
|
| 36 | + * @access private |
|
| 37 | + */ |
|
| 38 | + var $faultdetail; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * constructor |
|
| 42 | - * |
|
| 43 | - * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
|
| 44 | - * @param string $faultactor only used when msg routed between multiple actors |
|
| 45 | - * @param string $faultstring human readable error message |
|
| 46 | - * @param mixed $faultdetail detail, typically a string or array of string |
|
| 47 | - */ |
|
| 48 | - function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
|
|
| 49 | - parent::nusoap_base(); |
|
| 50 | - $this->faultcode = $faultcode; |
|
| 51 | - $this->faultactor = $faultactor; |
|
| 52 | - $this->faultstring = $faultstring; |
|
| 53 | - $this->faultdetail = $faultdetail; |
|
| 54 | - } |
|
| 40 | + /** |
|
| 41 | + * constructor |
|
| 42 | + * |
|
| 43 | + * @param string $faultcode (SOAP-ENV:Client | SOAP-ENV:Server) |
|
| 44 | + * @param string $faultactor only used when msg routed between multiple actors |
|
| 45 | + * @param string $faultstring human readable error message |
|
| 46 | + * @param mixed $faultdetail detail, typically a string or array of string |
|
| 47 | + */ |
|
| 48 | + function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
|
|
| 49 | + parent::nusoap_base(); |
|
| 50 | + $this->faultcode = $faultcode; |
|
| 51 | + $this->faultactor = $faultactor; |
|
| 52 | + $this->faultstring = $faultstring; |
|
| 53 | + $this->faultdetail = $faultdetail; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * serialize a fault |
|
| 58 | - * |
|
| 59 | - * @return string The serialization of the fault instance. |
|
| 60 | - * @access public |
|
| 61 | - */ |
|
| 62 | - function serialize(){
|
|
| 63 | - $ns_string = ''; |
|
| 64 | - foreach($this->namespaces as $k => $v){
|
|
| 65 | - $ns_string .= "\n xmlns:$k=\"$v\""; |
|
| 66 | - } |
|
| 67 | - $return_msg = |
|
| 68 | - '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'. |
|
| 69 | - '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n". |
|
| 70 | - '<SOAP-ENV:Body>'. |
|
| 71 | - '<SOAP-ENV:Fault>'. |
|
| 72 | - $this->serialize_val($this->faultcode, 'faultcode'). |
|
| 73 | - $this->serialize_val($this->faultactor, 'faultactor'). |
|
| 74 | - $this->serialize_val($this->faultstring, 'faultstring'). |
|
| 75 | - $this->serialize_val($this->faultdetail, 'detail'). |
|
| 76 | - '</SOAP-ENV:Fault>'. |
|
| 77 | - '</SOAP-ENV:Body>'. |
|
| 78 | - '</SOAP-ENV:Envelope>'; |
|
| 79 | - return $return_msg; |
|
| 80 | - } |
|
| 56 | + /** |
|
| 57 | + * serialize a fault |
|
| 58 | + * |
|
| 59 | + * @return string The serialization of the fault instance. |
|
| 60 | + * @access public |
|
| 61 | + */ |
|
| 62 | + function serialize(){
|
|
| 63 | + $ns_string = ''; |
|
| 64 | + foreach($this->namespaces as $k => $v){
|
|
| 65 | + $ns_string .= "\n xmlns:$k=\"$v\""; |
|
| 66 | + } |
|
| 67 | + $return_msg = |
|
| 68 | + '<?xml version="1.0" encoding="'.$this->soap_defencoding.'"?>'. |
|
| 69 | + '<SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"'.$ns_string.">\n". |
|
| 70 | + '<SOAP-ENV:Body>'. |
|
| 71 | + '<SOAP-ENV:Fault>'. |
|
| 72 | + $this->serialize_val($this->faultcode, 'faultcode'). |
|
| 73 | + $this->serialize_val($this->faultactor, 'faultactor'). |
|
| 74 | + $this->serialize_val($this->faultstring, 'faultstring'). |
|
| 75 | + $this->serialize_val($this->faultdetail, 'detail'). |
|
| 76 | + '</SOAP-ENV:Fault>'. |
|
| 77 | + '</SOAP-ENV:Body>'. |
|
| 78 | + '</SOAP-ENV:Envelope>'; |
|
| 79 | + return $return_msg; |
|
| 80 | + } |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | * @param string $faultstring human readable error message |
| 46 | 46 | * @param mixed $faultdetail detail, typically a string or array of string |
| 47 | 47 | */ |
| 48 | - function nusoap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
|
|
| 48 | + function nusoap_fault($faultcode, $faultactor = '', $faultstring = '', $faultdetail = '') {
|
|
| 49 | 49 | parent::nusoap_base(); |
| 50 | 50 | $this->faultcode = $faultcode; |
| 51 | 51 | $this->faultactor = $faultactor; |
@@ -59,9 +59,9 @@ discard block |
||
| 59 | 59 | * @return string The serialization of the fault instance. |
| 60 | 60 | * @access public |
| 61 | 61 | */ |
| 62 | - function serialize(){
|
|
| 62 | + function serialize() {
|
|
| 63 | 63 | $ns_string = ''; |
| 64 | - foreach($this->namespaces as $k => $v){
|
|
| 64 | + foreach ($this->namespaces as $k => $v) {
|
|
| 65 | 65 | $ns_string .= "\n xmlns:$k=\"$v\""; |
| 66 | 66 | } |
| 67 | 67 | $return_msg = |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | * |
| 844 | 844 | * @param array $headers The HTTP headers |
| 845 | 845 | * @param string $data unprocessed request data from client |
| 846 | - * @return mixed value of the message, decoded into a PHP type |
|
| 846 | + * @return false|null value of the message, decoded into a PHP type |
|
| 847 | 847 | * @access private |
| 848 | 848 | */ |
| 849 | 849 | function parseRequest($headers, $data) {
|
@@ -951,10 +951,10 @@ discard block |
||
| 951 | 951 | * @param string $name the name of the PHP function, class.method or class..method |
| 952 | 952 | * @param array $in assoc array of input values: key = param name, value = param type |
| 953 | 953 | * @param array $out assoc array of output values: key = param name, value = param type |
| 954 | - * @param mixed $namespace the element namespace for the method or false |
|
| 955 | - * @param mixed $soapaction the soapaction for the method or false |
|
| 956 | - * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 957 | - * @param mixed $use optional (encoded|literal) or false |
|
| 954 | + * @param string $namespace the element namespace for the method or false |
|
| 955 | + * @param string $soapaction the soapaction for the method or false |
|
| 956 | + * @param string $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 957 | + * @param string $use optional (encoded|literal) or false |
|
| 958 | 958 | * @param string $documentation optional Description to include in WSDL |
| 959 | 959 | * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
| 960 | 960 | * @access public |
@@ -1041,11 +1041,12 @@ discard block |
||
| 1041 | 1041 | * Acts as a flag to enable internal WSDL generation |
| 1042 | 1042 | * |
| 1043 | 1043 | * @param string $serviceName, name of the service |
| 1044 | - * @param mixed $namespace optional 'tns' service namespace or false |
|
| 1044 | + * @param string $namespace optional 'tns' service namespace or false |
|
| 1045 | 1045 | * @param mixed $endpoint optional URL of service endpoint or false |
| 1046 | 1046 | * @param string $style optional (rpc|document) WSDL style (also specified by operation) |
| 1047 | 1047 | * @param string $transport optional SOAP transport |
| 1048 | - * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false |
|
| 1048 | + * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false |
|
| 1049 | + * @param string $serviceName |
|
| 1049 | 1050 | */ |
| 1050 | 1051 | function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) |
| 1051 | 1052 | {
|
@@ -14,1076 +14,1076 @@ discard block |
||
| 14 | 14 | * @access public |
| 15 | 15 | */ |
| 16 | 16 | class nusoap_server extends nusoap_base {
|
| 17 | - /** |
|
| 18 | - * HTTP headers of request |
|
| 19 | - * @var array |
|
| 20 | - * @access private |
|
| 21 | - */ |
|
| 22 | - var $headers = array(); |
|
| 23 | - /** |
|
| 24 | - * HTTP request |
|
| 25 | - * @var string |
|
| 26 | - * @access private |
|
| 27 | - */ |
|
| 28 | - var $request = ''; |
|
| 29 | - /** |
|
| 30 | - * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text) |
|
| 31 | - * @var string |
|
| 32 | - * @access public |
|
| 33 | - */ |
|
| 34 | - var $requestHeaders = ''; |
|
| 35 | - /** |
|
| 36 | - * SOAP Headers from request (parsed) |
|
| 37 | - * @var mixed |
|
| 38 | - * @access public |
|
| 39 | - */ |
|
| 40 | - var $requestHeader = NULL; |
|
| 41 | - /** |
|
| 42 | - * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text) |
|
| 43 | - * @var string |
|
| 44 | - * @access public |
|
| 45 | - */ |
|
| 46 | - var $document = ''; |
|
| 47 | - /** |
|
| 48 | - * SOAP payload for request (text) |
|
| 49 | - * @var string |
|
| 50 | - * @access public |
|
| 51 | - */ |
|
| 52 | - var $requestSOAP = ''; |
|
| 53 | - /** |
|
| 54 | - * requested method namespace URI |
|
| 55 | - * @var string |
|
| 56 | - * @access private |
|
| 57 | - */ |
|
| 58 | - var $methodURI = ''; |
|
| 59 | - /** |
|
| 60 | - * name of method requested |
|
| 61 | - * @var string |
|
| 62 | - * @access private |
|
| 63 | - */ |
|
| 64 | - var $methodname = ''; |
|
| 65 | - /** |
|
| 66 | - * method parameters from request |
|
| 67 | - * @var array |
|
| 68 | - * @access private |
|
| 69 | - */ |
|
| 70 | - var $methodparams = array(); |
|
| 71 | - /** |
|
| 72 | - * SOAP Action from request |
|
| 73 | - * @var string |
|
| 74 | - * @access private |
|
| 75 | - */ |
|
| 76 | - var $SOAPAction = ''; |
|
| 77 | - /** |
|
| 78 | - * character set encoding of incoming (request) messages |
|
| 79 | - * @var string |
|
| 80 | - * @access public |
|
| 81 | - */ |
|
| 82 | - var $xml_encoding = ''; |
|
| 83 | - /** |
|
| 84 | - * toggles whether the parser decodes element content w/ utf8_decode() |
|
| 85 | - * @var boolean |
|
| 86 | - * @access public |
|
| 87 | - */ |
|
| 17 | + /** |
|
| 18 | + * HTTP headers of request |
|
| 19 | + * @var array |
|
| 20 | + * @access private |
|
| 21 | + */ |
|
| 22 | + var $headers = array(); |
|
| 23 | + /** |
|
| 24 | + * HTTP request |
|
| 25 | + * @var string |
|
| 26 | + * @access private |
|
| 27 | + */ |
|
| 28 | + var $request = ''; |
|
| 29 | + /** |
|
| 30 | + * SOAP headers from request (incomplete namespace resolution; special characters not escaped) (text) |
|
| 31 | + * @var string |
|
| 32 | + * @access public |
|
| 33 | + */ |
|
| 34 | + var $requestHeaders = ''; |
|
| 35 | + /** |
|
| 36 | + * SOAP Headers from request (parsed) |
|
| 37 | + * @var mixed |
|
| 38 | + * @access public |
|
| 39 | + */ |
|
| 40 | + var $requestHeader = NULL; |
|
| 41 | + /** |
|
| 42 | + * SOAP body request portion (incomplete namespace resolution; special characters not escaped) (text) |
|
| 43 | + * @var string |
|
| 44 | + * @access public |
|
| 45 | + */ |
|
| 46 | + var $document = ''; |
|
| 47 | + /** |
|
| 48 | + * SOAP payload for request (text) |
|
| 49 | + * @var string |
|
| 50 | + * @access public |
|
| 51 | + */ |
|
| 52 | + var $requestSOAP = ''; |
|
| 53 | + /** |
|
| 54 | + * requested method namespace URI |
|
| 55 | + * @var string |
|
| 56 | + * @access private |
|
| 57 | + */ |
|
| 58 | + var $methodURI = ''; |
|
| 59 | + /** |
|
| 60 | + * name of method requested |
|
| 61 | + * @var string |
|
| 62 | + * @access private |
|
| 63 | + */ |
|
| 64 | + var $methodname = ''; |
|
| 65 | + /** |
|
| 66 | + * method parameters from request |
|
| 67 | + * @var array |
|
| 68 | + * @access private |
|
| 69 | + */ |
|
| 70 | + var $methodparams = array(); |
|
| 71 | + /** |
|
| 72 | + * SOAP Action from request |
|
| 73 | + * @var string |
|
| 74 | + * @access private |
|
| 75 | + */ |
|
| 76 | + var $SOAPAction = ''; |
|
| 77 | + /** |
|
| 78 | + * character set encoding of incoming (request) messages |
|
| 79 | + * @var string |
|
| 80 | + * @access public |
|
| 81 | + */ |
|
| 82 | + var $xml_encoding = ''; |
|
| 83 | + /** |
|
| 84 | + * toggles whether the parser decodes element content w/ utf8_decode() |
|
| 85 | + * @var boolean |
|
| 86 | + * @access public |
|
| 87 | + */ |
|
| 88 | 88 | var $decode_utf8 = true; |
| 89 | 89 | |
| 90 | - /** |
|
| 91 | - * HTTP headers of response |
|
| 92 | - * @var array |
|
| 93 | - * @access public |
|
| 94 | - */ |
|
| 95 | - var $outgoing_headers = array(); |
|
| 96 | - /** |
|
| 97 | - * HTTP response |
|
| 98 | - * @var string |
|
| 99 | - * @access private |
|
| 100 | - */ |
|
| 101 | - var $response = ''; |
|
| 102 | - /** |
|
| 103 | - * SOAP headers for response (text or array of soapval or associative array) |
|
| 104 | - * @var mixed |
|
| 105 | - * @access public |
|
| 106 | - */ |
|
| 107 | - var $responseHeaders = ''; |
|
| 108 | - /** |
|
| 109 | - * SOAP payload for response (text) |
|
| 110 | - * @var string |
|
| 111 | - * @access private |
|
| 112 | - */ |
|
| 113 | - var $responseSOAP = ''; |
|
| 114 | - /** |
|
| 115 | - * method return value to place in response |
|
| 116 | - * @var mixed |
|
| 117 | - * @access private |
|
| 118 | - */ |
|
| 119 | - var $methodreturn = false; |
|
| 120 | - /** |
|
| 121 | - * whether $methodreturn is a string of literal XML |
|
| 122 | - * @var boolean |
|
| 123 | - * @access public |
|
| 124 | - */ |
|
| 125 | - var $methodreturnisliteralxml = false; |
|
| 126 | - /** |
|
| 127 | - * SOAP fault for response (or false) |
|
| 128 | - * @var mixed |
|
| 129 | - * @access private |
|
| 130 | - */ |
|
| 131 | - var $fault = false; |
|
| 132 | - /** |
|
| 133 | - * text indication of result (for debugging) |
|
| 134 | - * @var string |
|
| 135 | - * @access private |
|
| 136 | - */ |
|
| 137 | - var $result = 'successful'; |
|
| 90 | + /** |
|
| 91 | + * HTTP headers of response |
|
| 92 | + * @var array |
|
| 93 | + * @access public |
|
| 94 | + */ |
|
| 95 | + var $outgoing_headers = array(); |
|
| 96 | + /** |
|
| 97 | + * HTTP response |
|
| 98 | + * @var string |
|
| 99 | + * @access private |
|
| 100 | + */ |
|
| 101 | + var $response = ''; |
|
| 102 | + /** |
|
| 103 | + * SOAP headers for response (text or array of soapval or associative array) |
|
| 104 | + * @var mixed |
|
| 105 | + * @access public |
|
| 106 | + */ |
|
| 107 | + var $responseHeaders = ''; |
|
| 108 | + /** |
|
| 109 | + * SOAP payload for response (text) |
|
| 110 | + * @var string |
|
| 111 | + * @access private |
|
| 112 | + */ |
|
| 113 | + var $responseSOAP = ''; |
|
| 114 | + /** |
|
| 115 | + * method return value to place in response |
|
| 116 | + * @var mixed |
|
| 117 | + * @access private |
|
| 118 | + */ |
|
| 119 | + var $methodreturn = false; |
|
| 120 | + /** |
|
| 121 | + * whether $methodreturn is a string of literal XML |
|
| 122 | + * @var boolean |
|
| 123 | + * @access public |
|
| 124 | + */ |
|
| 125 | + var $methodreturnisliteralxml = false; |
|
| 126 | + /** |
|
| 127 | + * SOAP fault for response (or false) |
|
| 128 | + * @var mixed |
|
| 129 | + * @access private |
|
| 130 | + */ |
|
| 131 | + var $fault = false; |
|
| 132 | + /** |
|
| 133 | + * text indication of result (for debugging) |
|
| 134 | + * @var string |
|
| 135 | + * @access private |
|
| 136 | + */ |
|
| 137 | + var $result = 'successful'; |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * assoc array of operations => opData; operations are added by the register() |
|
| 141 | - * method or by parsing an external WSDL definition |
|
| 142 | - * @var array |
|
| 143 | - * @access private |
|
| 144 | - */ |
|
| 145 | - var $operations = array(); |
|
| 146 | - /** |
|
| 147 | - * wsdl instance (if one) |
|
| 148 | - * @var mixed |
|
| 149 | - * @access private |
|
| 150 | - */ |
|
| 151 | - var $wsdl = false; |
|
| 152 | - /** |
|
| 153 | - * URL for WSDL (if one) |
|
| 154 | - * @var mixed |
|
| 155 | - * @access private |
|
| 156 | - */ |
|
| 157 | - var $externalWSDLURL = false; |
|
| 158 | - /** |
|
| 159 | - * whether to append debug to response as XML comment |
|
| 160 | - * @var boolean |
|
| 161 | - * @access public |
|
| 162 | - */ |
|
| 163 | - var $debug_flag = false; |
|
| 139 | + /** |
|
| 140 | + * assoc array of operations => opData; operations are added by the register() |
|
| 141 | + * method or by parsing an external WSDL definition |
|
| 142 | + * @var array |
|
| 143 | + * @access private |
|
| 144 | + */ |
|
| 145 | + var $operations = array(); |
|
| 146 | + /** |
|
| 147 | + * wsdl instance (if one) |
|
| 148 | + * @var mixed |
|
| 149 | + * @access private |
|
| 150 | + */ |
|
| 151 | + var $wsdl = false; |
|
| 152 | + /** |
|
| 153 | + * URL for WSDL (if one) |
|
| 154 | + * @var mixed |
|
| 155 | + * @access private |
|
| 156 | + */ |
|
| 157 | + var $externalWSDLURL = false; |
|
| 158 | + /** |
|
| 159 | + * whether to append debug to response as XML comment |
|
| 160 | + * @var boolean |
|
| 161 | + * @access public |
|
| 162 | + */ |
|
| 163 | + var $debug_flag = false; |
|
| 164 | 164 | |
| 165 | 165 | |
| 166 | - /** |
|
| 167 | - * constructor |
|
| 168 | - * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to. |
|
| 169 | - * |
|
| 170 | - * @param mixed $wsdl file path or URL (string), or wsdl instance (object) |
|
| 171 | - * @access public |
|
| 172 | - */ |
|
| 173 | - function nusoap_server($wsdl=false){
|
|
| 174 | - parent::nusoap_base(); |
|
| 175 | - // turn on debugging? |
|
| 176 | - global $debug; |
|
| 177 | - global $HTTP_SERVER_VARS; |
|
| 166 | + /** |
|
| 167 | + * constructor |
|
| 168 | + * the optional parameter is a path to a WSDL file that you'd like to bind the server instance to. |
|
| 169 | + * |
|
| 170 | + * @param mixed $wsdl file path or URL (string), or wsdl instance (object) |
|
| 171 | + * @access public |
|
| 172 | + */ |
|
| 173 | + function nusoap_server($wsdl=false){
|
|
| 174 | + parent::nusoap_base(); |
|
| 175 | + // turn on debugging? |
|
| 176 | + global $debug; |
|
| 177 | + global $HTTP_SERVER_VARS; |
|
| 178 | 178 | |
| 179 | - if (isset($_SERVER)) {
|
|
| 180 | - $this->debug("_SERVER is defined:");
|
|
| 181 | - $this->appendDebug($this->varDump($_SERVER)); |
|
| 182 | - } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 183 | - $this->debug("HTTP_SERVER_VARS is defined:");
|
|
| 184 | - $this->appendDebug($this->varDump($HTTP_SERVER_VARS)); |
|
| 185 | - } else {
|
|
| 186 | - $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
|
|
| 187 | - } |
|
| 179 | + if (isset($_SERVER)) {
|
|
| 180 | + $this->debug("_SERVER is defined:");
|
|
| 181 | + $this->appendDebug($this->varDump($_SERVER)); |
|
| 182 | + } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 183 | + $this->debug("HTTP_SERVER_VARS is defined:");
|
|
| 184 | + $this->appendDebug($this->varDump($HTTP_SERVER_VARS)); |
|
| 185 | + } else {
|
|
| 186 | + $this->debug("Neither _SERVER nor HTTP_SERVER_VARS is defined.");
|
|
| 187 | + } |
|
| 188 | 188 | |
| 189 | - if (isset($debug)) {
|
|
| 190 | - $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
|
|
| 191 | - $this->debug_flag = $debug; |
|
| 192 | - } elseif (isset($_SERVER['QUERY_STRING'])) {
|
|
| 193 | - $qs = explode('&', $_SERVER['QUERY_STRING']);
|
|
| 194 | - foreach ($qs as $v) {
|
|
| 195 | - if (substr($v, 0, 6) == 'debug=') {
|
|
| 196 | - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
|
|
| 197 | - $this->debug_flag = substr($v, 6); |
|
| 198 | - } |
|
| 199 | - } |
|
| 200 | - } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
|
|
| 201 | - $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
|
|
| 202 | - foreach ($qs as $v) {
|
|
| 203 | - if (substr($v, 0, 6) == 'debug=') {
|
|
| 204 | - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
|
|
| 205 | - $this->debug_flag = substr($v, 6); |
|
| 206 | - } |
|
| 207 | - } |
|
| 208 | - } |
|
| 189 | + if (isset($debug)) {
|
|
| 190 | + $this->debug("In nusoap_server, set debug_flag=$debug based on global flag");
|
|
| 191 | + $this->debug_flag = $debug; |
|
| 192 | + } elseif (isset($_SERVER['QUERY_STRING'])) {
|
|
| 193 | + $qs = explode('&', $_SERVER['QUERY_STRING']);
|
|
| 194 | + foreach ($qs as $v) {
|
|
| 195 | + if (substr($v, 0, 6) == 'debug=') {
|
|
| 196 | + $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
|
|
| 197 | + $this->debug_flag = substr($v, 6); |
|
| 198 | + } |
|
| 199 | + } |
|
| 200 | + } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
|
|
| 201 | + $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
|
|
| 202 | + foreach ($qs as $v) {
|
|
| 203 | + if (substr($v, 0, 6) == 'debug=') {
|
|
| 204 | + $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
|
|
| 205 | + $this->debug_flag = substr($v, 6); |
|
| 206 | + } |
|
| 207 | + } |
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - // wsdl |
|
| 211 | - if($wsdl){
|
|
| 212 | - $this->debug("In nusoap_server, WSDL is specified");
|
|
| 213 | - if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
|
|
| 214 | - $this->wsdl = $wsdl; |
|
| 215 | - $this->externalWSDLURL = $this->wsdl->wsdl; |
|
| 216 | - $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
|
|
| 217 | - } else {
|
|
| 218 | - $this->debug('Create wsdl from ' . $wsdl);
|
|
| 219 | - $this->wsdl = new wsdl($wsdl); |
|
| 220 | - $this->externalWSDLURL = $wsdl; |
|
| 221 | - } |
|
| 222 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 223 | - $this->wsdl->clearDebug(); |
|
| 224 | - if($err = $this->wsdl->getError()){
|
|
| 225 | - die('WSDL ERROR: '.$err);
|
|
| 226 | - } |
|
| 227 | - } |
|
| 228 | - } |
|
| 210 | + // wsdl |
|
| 211 | + if($wsdl){
|
|
| 212 | + $this->debug("In nusoap_server, WSDL is specified");
|
|
| 213 | + if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
|
|
| 214 | + $this->wsdl = $wsdl; |
|
| 215 | + $this->externalWSDLURL = $this->wsdl->wsdl; |
|
| 216 | + $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
|
|
| 217 | + } else {
|
|
| 218 | + $this->debug('Create wsdl from ' . $wsdl);
|
|
| 219 | + $this->wsdl = new wsdl($wsdl); |
|
| 220 | + $this->externalWSDLURL = $wsdl; |
|
| 221 | + } |
|
| 222 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 223 | + $this->wsdl->clearDebug(); |
|
| 224 | + if($err = $this->wsdl->getError()){
|
|
| 225 | + die('WSDL ERROR: '.$err);
|
|
| 226 | + } |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * processes request and returns response |
|
| 232 | - * |
|
| 233 | - * @param string $data usually is the value of $HTTP_RAW_POST_DATA |
|
| 234 | - * @access public |
|
| 235 | - */ |
|
| 236 | - function service($data){
|
|
| 237 | - global $HTTP_SERVER_VARS; |
|
| 230 | + /** |
|
| 231 | + * processes request and returns response |
|
| 232 | + * |
|
| 233 | + * @param string $data usually is the value of $HTTP_RAW_POST_DATA |
|
| 234 | + * @access public |
|
| 235 | + */ |
|
| 236 | + function service($data){
|
|
| 237 | + global $HTTP_SERVER_VARS; |
|
| 238 | 238 | |
| 239 | - if (isset($_SERVER['REQUEST_METHOD'])) {
|
|
| 240 | - $rm = $_SERVER['REQUEST_METHOD']; |
|
| 241 | - } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
|
|
| 242 | - $rm = $HTTP_SERVER_VARS['REQUEST_METHOD']; |
|
| 243 | - } else {
|
|
| 244 | - $rm = ''; |
|
| 245 | - } |
|
| 239 | + if (isset($_SERVER['REQUEST_METHOD'])) {
|
|
| 240 | + $rm = $_SERVER['REQUEST_METHOD']; |
|
| 241 | + } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
|
|
| 242 | + $rm = $HTTP_SERVER_VARS['REQUEST_METHOD']; |
|
| 243 | + } else {
|
|
| 244 | + $rm = ''; |
|
| 245 | + } |
|
| 246 | 246 | |
| 247 | - if (isset($_SERVER['QUERY_STRING'])) {
|
|
| 248 | - $qs = $_SERVER['QUERY_STRING']; |
|
| 249 | - } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
|
|
| 250 | - $qs = $HTTP_SERVER_VARS['QUERY_STRING']; |
|
| 251 | - } else {
|
|
| 252 | - $qs = ''; |
|
| 253 | - } |
|
| 254 | - $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
|
|
| 247 | + if (isset($_SERVER['QUERY_STRING'])) {
|
|
| 248 | + $qs = $_SERVER['QUERY_STRING']; |
|
| 249 | + } elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
|
|
| 250 | + $qs = $HTTP_SERVER_VARS['QUERY_STRING']; |
|
| 251 | + } else {
|
|
| 252 | + $qs = ''; |
|
| 253 | + } |
|
| 254 | + $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
|
|
| 255 | 255 | |
| 256 | - if ($rm == 'POST') {
|
|
| 257 | - $this->debug("In service, invoke the request");
|
|
| 258 | - $this->parse_request($data); |
|
| 259 | - if (! $this->fault) {
|
|
| 260 | - $this->invoke_method(); |
|
| 261 | - } |
|
| 262 | - if (! $this->fault) {
|
|
| 263 | - $this->serialize_return(); |
|
| 264 | - } |
|
| 265 | - $this->send_response(); |
|
| 266 | - } elseif (preg_match('/wsdl/', $qs) ){
|
|
| 267 | - $this->debug("In service, this is a request for WSDL");
|
|
| 268 | - if ($this->externalWSDLURL){
|
|
| 269 | - if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
|
|
| 270 | - $this->debug("In service, re-direct for WSDL");
|
|
| 271 | - header('Location: '.$this->externalWSDLURL);
|
|
| 272 | - } else { // assume file
|
|
| 273 | - $this->debug("In service, use file passthru for WSDL");
|
|
| 256 | + if ($rm == 'POST') {
|
|
| 257 | + $this->debug("In service, invoke the request");
|
|
| 258 | + $this->parse_request($data); |
|
| 259 | + if (! $this->fault) {
|
|
| 260 | + $this->invoke_method(); |
|
| 261 | + } |
|
| 262 | + if (! $this->fault) {
|
|
| 263 | + $this->serialize_return(); |
|
| 264 | + } |
|
| 265 | + $this->send_response(); |
|
| 266 | + } elseif (preg_match('/wsdl/', $qs) ){
|
|
| 267 | + $this->debug("In service, this is a request for WSDL");
|
|
| 268 | + if ($this->externalWSDLURL){
|
|
| 269 | + if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
|
|
| 270 | + $this->debug("In service, re-direct for WSDL");
|
|
| 271 | + header('Location: '.$this->externalWSDLURL);
|
|
| 272 | + } else { // assume file
|
|
| 273 | + $this->debug("In service, use file passthru for WSDL");
|
|
| 274 | 274 | header("Content-Type: text/xml\r\n");
|
| 275 | - $pos = strpos($this->externalWSDLURL, "file://"); |
|
| 276 | - if ($pos === false) {
|
|
| 277 | - $filename = $this->externalWSDLURL; |
|
| 278 | - } else {
|
|
| 279 | - $filename = substr($this->externalWSDLURL, $pos + 7); |
|
| 280 | - } |
|
| 275 | + $pos = strpos($this->externalWSDLURL, "file://"); |
|
| 276 | + if ($pos === false) {
|
|
| 277 | + $filename = $this->externalWSDLURL; |
|
| 278 | + } else {
|
|
| 279 | + $filename = substr($this->externalWSDLURL, $pos + 7); |
|
| 280 | + } |
|
| 281 | 281 | $fp = fopen($this->externalWSDLURL, 'r'); |
| 282 | 282 | fpassthru($fp); |
| 283 | - } |
|
| 284 | - } elseif ($this->wsdl) {
|
|
| 285 | - $this->debug("In service, serialize WSDL");
|
|
| 286 | - header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
|
|
| 287 | - print $this->wsdl->serialize($this->debug_flag); |
|
| 288 | - if ($this->debug_flag) {
|
|
| 289 | - $this->debug('wsdl:');
|
|
| 290 | - $this->appendDebug($this->varDump($this->wsdl)); |
|
| 291 | - print $this->getDebugAsXMLComment(); |
|
| 292 | - } |
|
| 293 | - } else {
|
|
| 294 | - $this->debug("In service, there is no WSDL");
|
|
| 295 | - header("Content-Type: text/html; charset=ISO-8859-1\r\n");
|
|
| 296 | - print "This service does not provide WSDL"; |
|
| 297 | - } |
|
| 298 | - } elseif ($this->wsdl) {
|
|
| 299 | - $this->debug("In service, return Web description");
|
|
| 300 | - print $this->wsdl->webDescription(); |
|
| 301 | - } else {
|
|
| 302 | - $this->debug("In service, no Web description");
|
|
| 303 | - header("Content-Type: text/html; charset=ISO-8859-1\r\n");
|
|
| 304 | - print "This service does not provide a Web description"; |
|
| 305 | - } |
|
| 306 | - } |
|
| 283 | + } |
|
| 284 | + } elseif ($this->wsdl) {
|
|
| 285 | + $this->debug("In service, serialize WSDL");
|
|
| 286 | + header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
|
|
| 287 | + print $this->wsdl->serialize($this->debug_flag); |
|
| 288 | + if ($this->debug_flag) {
|
|
| 289 | + $this->debug('wsdl:');
|
|
| 290 | + $this->appendDebug($this->varDump($this->wsdl)); |
|
| 291 | + print $this->getDebugAsXMLComment(); |
|
| 292 | + } |
|
| 293 | + } else {
|
|
| 294 | + $this->debug("In service, there is no WSDL");
|
|
| 295 | + header("Content-Type: text/html; charset=ISO-8859-1\r\n");
|
|
| 296 | + print "This service does not provide WSDL"; |
|
| 297 | + } |
|
| 298 | + } elseif ($this->wsdl) {
|
|
| 299 | + $this->debug("In service, return Web description");
|
|
| 300 | + print $this->wsdl->webDescription(); |
|
| 301 | + } else {
|
|
| 302 | + $this->debug("In service, no Web description");
|
|
| 303 | + header("Content-Type: text/html; charset=ISO-8859-1\r\n");
|
|
| 304 | + print "This service does not provide a Web description"; |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * parses HTTP request headers. |
|
| 310 | - * |
|
| 311 | - * The following fields are set by this function (when successful) |
|
| 312 | - * |
|
| 313 | - * headers |
|
| 314 | - * request |
|
| 315 | - * xml_encoding |
|
| 316 | - * SOAPAction |
|
| 317 | - * |
|
| 318 | - * @access private |
|
| 319 | - */ |
|
| 320 | - function parse_http_headers() {
|
|
| 321 | - global $HTTP_SERVER_VARS; |
|
| 308 | + /** |
|
| 309 | + * parses HTTP request headers. |
|
| 310 | + * |
|
| 311 | + * The following fields are set by this function (when successful) |
|
| 312 | + * |
|
| 313 | + * headers |
|
| 314 | + * request |
|
| 315 | + * xml_encoding |
|
| 316 | + * SOAPAction |
|
| 317 | + * |
|
| 318 | + * @access private |
|
| 319 | + */ |
|
| 320 | + function parse_http_headers() {
|
|
| 321 | + global $HTTP_SERVER_VARS; |
|
| 322 | 322 | |
| 323 | - $this->request = ''; |
|
| 324 | - $this->SOAPAction = ''; |
|
| 325 | - if(function_exists('getallheaders')){
|
|
| 326 | - $this->debug("In parse_http_headers, use getallheaders");
|
|
| 327 | - $headers = getallheaders(); |
|
| 328 | - foreach($headers as $k=>$v){
|
|
| 329 | - $k = strtolower($k); |
|
| 330 | - $this->headers[$k] = $v; |
|
| 331 | - $this->request .= "$k: $v\r\n"; |
|
| 332 | - $this->debug("$k: $v");
|
|
| 333 | - } |
|
| 334 | - // get SOAPAction header |
|
| 335 | - if(isset($this->headers['soapaction'])){
|
|
| 336 | - $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
|
|
| 337 | - } |
|
| 338 | - // get the character encoding of the incoming request |
|
| 339 | - if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
|
|
| 340 | - $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
|
|
| 341 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 342 | - $this->xml_encoding = strtoupper($enc); |
|
| 343 | - } else {
|
|
| 344 | - $this->xml_encoding = 'US-ASCII'; |
|
| 345 | - } |
|
| 346 | - } else {
|
|
| 347 | - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 348 | - $this->xml_encoding = 'ISO-8859-1'; |
|
| 349 | - } |
|
| 350 | - } elseif(isset($_SERVER) && is_array($_SERVER)){
|
|
| 351 | - $this->debug("In parse_http_headers, use _SERVER");
|
|
| 352 | - foreach ($_SERVER as $k => $v) {
|
|
| 353 | - if (substr($k, 0, 5) == 'HTTP_') {
|
|
| 354 | - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
|
|
| 355 | - } else {
|
|
| 356 | - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
|
|
| 357 | - } |
|
| 358 | - if ($k == 'soapaction') {
|
|
| 359 | - // get SOAPAction header |
|
| 360 | - $k = 'SOAPAction'; |
|
| 361 | - $v = str_replace('"', '', $v);
|
|
| 362 | - $v = str_replace('\\', '', $v);
|
|
| 363 | - $this->SOAPAction = $v; |
|
| 364 | - } else if ($k == 'content-type') {
|
|
| 365 | - // get the character encoding of the incoming request |
|
| 366 | - if (strpos($v, '=')) {
|
|
| 367 | - $enc = substr(strstr($v, '='), 1); |
|
| 368 | - $enc = str_replace('"', '', $enc);
|
|
| 369 | - $enc = str_replace('\\', '', $enc);
|
|
| 370 | - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
|
|
| 371 | - $this->xml_encoding = strtoupper($enc); |
|
| 372 | - } else {
|
|
| 373 | - $this->xml_encoding = 'US-ASCII'; |
|
| 374 | - } |
|
| 375 | - } else {
|
|
| 376 | - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 377 | - $this->xml_encoding = 'ISO-8859-1'; |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - $this->headers[$k] = $v; |
|
| 381 | - $this->request .= "$k: $v\r\n"; |
|
| 382 | - $this->debug("$k: $v");
|
|
| 383 | - } |
|
| 384 | - } elseif (is_array($HTTP_SERVER_VARS)) {
|
|
| 385 | - $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
|
|
| 386 | - foreach ($HTTP_SERVER_VARS as $k => $v) {
|
|
| 387 | - if (substr($k, 0, 5) == 'HTTP_') {
|
|
| 388 | - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
|
|
| 389 | - } else {
|
|
| 390 | - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
|
|
| 391 | - } |
|
| 392 | - if ($k == 'soapaction') {
|
|
| 393 | - // get SOAPAction header |
|
| 394 | - $k = 'SOAPAction'; |
|
| 395 | - $v = str_replace('"', '', $v);
|
|
| 396 | - $v = str_replace('\\', '', $v);
|
|
| 397 | - $this->SOAPAction = $v; |
|
| 398 | - } else if ($k == 'content-type') {
|
|
| 399 | - // get the character encoding of the incoming request |
|
| 400 | - if (strpos($v, '=')) {
|
|
| 401 | - $enc = substr(strstr($v, '='), 1); |
|
| 402 | - $enc = str_replace('"', '', $enc);
|
|
| 403 | - $enc = str_replace('\\', '', $enc);
|
|
| 404 | - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
|
|
| 405 | - $this->xml_encoding = strtoupper($enc); |
|
| 406 | - } else {
|
|
| 407 | - $this->xml_encoding = 'US-ASCII'; |
|
| 408 | - } |
|
| 409 | - } else {
|
|
| 410 | - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 411 | - $this->xml_encoding = 'ISO-8859-1'; |
|
| 412 | - } |
|
| 413 | - } |
|
| 414 | - $this->headers[$k] = $v; |
|
| 415 | - $this->request .= "$k: $v\r\n"; |
|
| 416 | - $this->debug("$k: $v");
|
|
| 417 | - } |
|
| 418 | - } else {
|
|
| 419 | - $this->debug("In parse_http_headers, HTTP headers not accessible");
|
|
| 420 | - $this->setError("HTTP headers not accessible");
|
|
| 421 | - } |
|
| 422 | - } |
|
| 323 | + $this->request = ''; |
|
| 324 | + $this->SOAPAction = ''; |
|
| 325 | + if(function_exists('getallheaders')){
|
|
| 326 | + $this->debug("In parse_http_headers, use getallheaders");
|
|
| 327 | + $headers = getallheaders(); |
|
| 328 | + foreach($headers as $k=>$v){
|
|
| 329 | + $k = strtolower($k); |
|
| 330 | + $this->headers[$k] = $v; |
|
| 331 | + $this->request .= "$k: $v\r\n"; |
|
| 332 | + $this->debug("$k: $v");
|
|
| 333 | + } |
|
| 334 | + // get SOAPAction header |
|
| 335 | + if(isset($this->headers['soapaction'])){
|
|
| 336 | + $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
|
|
| 337 | + } |
|
| 338 | + // get the character encoding of the incoming request |
|
| 339 | + if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
|
|
| 340 | + $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
|
|
| 341 | + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 342 | + $this->xml_encoding = strtoupper($enc); |
|
| 343 | + } else {
|
|
| 344 | + $this->xml_encoding = 'US-ASCII'; |
|
| 345 | + } |
|
| 346 | + } else {
|
|
| 347 | + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 348 | + $this->xml_encoding = 'ISO-8859-1'; |
|
| 349 | + } |
|
| 350 | + } elseif(isset($_SERVER) && is_array($_SERVER)){
|
|
| 351 | + $this->debug("In parse_http_headers, use _SERVER");
|
|
| 352 | + foreach ($_SERVER as $k => $v) {
|
|
| 353 | + if (substr($k, 0, 5) == 'HTTP_') {
|
|
| 354 | + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5))));
|
|
| 355 | + } else {
|
|
| 356 | + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k)));
|
|
| 357 | + } |
|
| 358 | + if ($k == 'soapaction') {
|
|
| 359 | + // get SOAPAction header |
|
| 360 | + $k = 'SOAPAction'; |
|
| 361 | + $v = str_replace('"', '', $v);
|
|
| 362 | + $v = str_replace('\\', '', $v);
|
|
| 363 | + $this->SOAPAction = $v; |
|
| 364 | + } else if ($k == 'content-type') {
|
|
| 365 | + // get the character encoding of the incoming request |
|
| 366 | + if (strpos($v, '=')) {
|
|
| 367 | + $enc = substr(strstr($v, '='), 1); |
|
| 368 | + $enc = str_replace('"', '', $enc);
|
|
| 369 | + $enc = str_replace('\\', '', $enc);
|
|
| 370 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
|
|
| 371 | + $this->xml_encoding = strtoupper($enc); |
|
| 372 | + } else {
|
|
| 373 | + $this->xml_encoding = 'US-ASCII'; |
|
| 374 | + } |
|
| 375 | + } else {
|
|
| 376 | + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 377 | + $this->xml_encoding = 'ISO-8859-1'; |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + $this->headers[$k] = $v; |
|
| 381 | + $this->request .= "$k: $v\r\n"; |
|
| 382 | + $this->debug("$k: $v");
|
|
| 383 | + } |
|
| 384 | + } elseif (is_array($HTTP_SERVER_VARS)) {
|
|
| 385 | + $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
|
|
| 386 | + foreach ($HTTP_SERVER_VARS as $k => $v) {
|
|
| 387 | + if (substr($k, 0, 5) == 'HTTP_') {
|
|
| 388 | + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
|
|
| 389 | + } else {
|
|
| 390 | + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
|
|
| 391 | + } |
|
| 392 | + if ($k == 'soapaction') {
|
|
| 393 | + // get SOAPAction header |
|
| 394 | + $k = 'SOAPAction'; |
|
| 395 | + $v = str_replace('"', '', $v);
|
|
| 396 | + $v = str_replace('\\', '', $v);
|
|
| 397 | + $this->SOAPAction = $v; |
|
| 398 | + } else if ($k == 'content-type') {
|
|
| 399 | + // get the character encoding of the incoming request |
|
| 400 | + if (strpos($v, '=')) {
|
|
| 401 | + $enc = substr(strstr($v, '='), 1); |
|
| 402 | + $enc = str_replace('"', '', $enc);
|
|
| 403 | + $enc = str_replace('\\', '', $enc);
|
|
| 404 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
|
|
| 405 | + $this->xml_encoding = strtoupper($enc); |
|
| 406 | + } else {
|
|
| 407 | + $this->xml_encoding = 'US-ASCII'; |
|
| 408 | + } |
|
| 409 | + } else {
|
|
| 410 | + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 411 | + $this->xml_encoding = 'ISO-8859-1'; |
|
| 412 | + } |
|
| 413 | + } |
|
| 414 | + $this->headers[$k] = $v; |
|
| 415 | + $this->request .= "$k: $v\r\n"; |
|
| 416 | + $this->debug("$k: $v");
|
|
| 417 | + } |
|
| 418 | + } else {
|
|
| 419 | + $this->debug("In parse_http_headers, HTTP headers not accessible");
|
|
| 420 | + $this->setError("HTTP headers not accessible");
|
|
| 421 | + } |
|
| 422 | + } |
|
| 423 | 423 | |
| 424 | - /** |
|
| 425 | - * parses a request |
|
| 426 | - * |
|
| 427 | - * The following fields are set by this function (when successful) |
|
| 428 | - * |
|
| 429 | - * headers |
|
| 430 | - * request |
|
| 431 | - * xml_encoding |
|
| 432 | - * SOAPAction |
|
| 433 | - * request |
|
| 434 | - * requestSOAP |
|
| 435 | - * methodURI |
|
| 436 | - * methodname |
|
| 437 | - * methodparams |
|
| 438 | - * requestHeaders |
|
| 439 | - * document |
|
| 440 | - * |
|
| 441 | - * This sets the fault field on error |
|
| 442 | - * |
|
| 443 | - * @param string $data XML string |
|
| 444 | - * @access private |
|
| 445 | - */ |
|
| 446 | - function parse_request($data='') {
|
|
| 447 | - $this->debug('entering parse_request()');
|
|
| 448 | - $this->parse_http_headers(); |
|
| 449 | - $this->debug('got character encoding: '.$this->xml_encoding);
|
|
| 450 | - // uncompress if necessary |
|
| 451 | - if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
|
|
| 452 | - $this->debug('got content encoding: ' . $this->headers['content-encoding']);
|
|
| 453 | - if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
|
|
| 454 | - // if decoding works, use it. else assume data wasn't gzencoded |
|
| 455 | - if (function_exists('gzuncompress')) {
|
|
| 456 | - if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
|
|
| 457 | - $data = $degzdata; |
|
| 458 | - } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
|
|
| 459 | - $data = $degzdata; |
|
| 460 | - } else {
|
|
| 461 | - $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
|
|
| 462 | - return; |
|
| 463 | - } |
|
| 464 | - } else {
|
|
| 465 | - $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
|
|
| 466 | - return; |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - } |
|
| 470 | - $this->request .= "\r\n".$data; |
|
| 471 | - $data = $this->parseRequest($this->headers, $data); |
|
| 472 | - $this->requestSOAP = $data; |
|
| 473 | - $this->debug('leaving parse_request');
|
|
| 474 | - } |
|
| 424 | + /** |
|
| 425 | + * parses a request |
|
| 426 | + * |
|
| 427 | + * The following fields are set by this function (when successful) |
|
| 428 | + * |
|
| 429 | + * headers |
|
| 430 | + * request |
|
| 431 | + * xml_encoding |
|
| 432 | + * SOAPAction |
|
| 433 | + * request |
|
| 434 | + * requestSOAP |
|
| 435 | + * methodURI |
|
| 436 | + * methodname |
|
| 437 | + * methodparams |
|
| 438 | + * requestHeaders |
|
| 439 | + * document |
|
| 440 | + * |
|
| 441 | + * This sets the fault field on error |
|
| 442 | + * |
|
| 443 | + * @param string $data XML string |
|
| 444 | + * @access private |
|
| 445 | + */ |
|
| 446 | + function parse_request($data='') {
|
|
| 447 | + $this->debug('entering parse_request()');
|
|
| 448 | + $this->parse_http_headers(); |
|
| 449 | + $this->debug('got character encoding: '.$this->xml_encoding);
|
|
| 450 | + // uncompress if necessary |
|
| 451 | + if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
|
|
| 452 | + $this->debug('got content encoding: ' . $this->headers['content-encoding']);
|
|
| 453 | + if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
|
|
| 454 | + // if decoding works, use it. else assume data wasn't gzencoded |
|
| 455 | + if (function_exists('gzuncompress')) {
|
|
| 456 | + if ($this->headers['content-encoding'] == 'deflate' && $degzdata = @gzuncompress($data)) {
|
|
| 457 | + $data = $degzdata; |
|
| 458 | + } elseif ($this->headers['content-encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))) {
|
|
| 459 | + $data = $degzdata; |
|
| 460 | + } else {
|
|
| 461 | + $this->fault('SOAP-ENV:Client', 'Errors occurred when trying to decode the data');
|
|
| 462 | + return; |
|
| 463 | + } |
|
| 464 | + } else {
|
|
| 465 | + $this->fault('SOAP-ENV:Client', 'This Server does not support compressed data');
|
|
| 466 | + return; |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + } |
|
| 470 | + $this->request .= "\r\n".$data; |
|
| 471 | + $data = $this->parseRequest($this->headers, $data); |
|
| 472 | + $this->requestSOAP = $data; |
|
| 473 | + $this->debug('leaving parse_request');
|
|
| 474 | + } |
|
| 475 | 475 | |
| 476 | - /** |
|
| 477 | - * invokes a PHP function for the requested SOAP method |
|
| 478 | - * |
|
| 479 | - * The following fields are set by this function (when successful) |
|
| 480 | - * |
|
| 481 | - * methodreturn |
|
| 482 | - * |
|
| 483 | - * Note that the PHP function that is called may also set the following |
|
| 484 | - * fields to affect the response sent to the client |
|
| 485 | - * |
|
| 486 | - * responseHeaders |
|
| 487 | - * outgoing_headers |
|
| 488 | - * |
|
| 489 | - * This sets the fault field on error |
|
| 490 | - * |
|
| 491 | - * @access private |
|
| 492 | - */ |
|
| 493 | - function invoke_method() {
|
|
| 494 | - $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
|
|
| 476 | + /** |
|
| 477 | + * invokes a PHP function for the requested SOAP method |
|
| 478 | + * |
|
| 479 | + * The following fields are set by this function (when successful) |
|
| 480 | + * |
|
| 481 | + * methodreturn |
|
| 482 | + * |
|
| 483 | + * Note that the PHP function that is called may also set the following |
|
| 484 | + * fields to affect the response sent to the client |
|
| 485 | + * |
|
| 486 | + * responseHeaders |
|
| 487 | + * outgoing_headers |
|
| 488 | + * |
|
| 489 | + * This sets the fault field on error |
|
| 490 | + * |
|
| 491 | + * @access private |
|
| 492 | + */ |
|
| 493 | + function invoke_method() {
|
|
| 494 | + $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
|
|
| 495 | 495 | |
| 496 | - // |
|
| 497 | - // if you are debugging in this area of the code, your service uses a class to implement methods, |
|
| 498 | - // you use SOAP RPC, and the client is .NET, please be aware of the following... |
|
| 499 | - // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the |
|
| 500 | - // method name. that is fine for naming the .NET methods. it is not fine for properly constructing |
|
| 501 | - // the XML request and reading the XML response. you need to add the RequestElementName and |
|
| 502 | - // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe |
|
| 503 | - // generates for the method. these parameters are used to specify the correct XML element names |
|
| 504 | - // for .NET to use, i.e. the names with the '.' in them. |
|
| 505 | - // |
|
| 506 | - $orig_methodname = $this->methodname; |
|
| 507 | - if ($this->wsdl) {
|
|
| 508 | - if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
|
|
| 509 | - $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
|
|
| 510 | - $this->appendDebug('opData=' . $this->varDump($this->opData));
|
|
| 511 | - } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
|
|
| 512 | - // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element |
|
| 513 | - $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
|
|
| 514 | - $this->appendDebug('opData=' . $this->varDump($this->opData));
|
|
| 515 | - $this->methodname = $this->opData['name']; |
|
| 516 | - } else {
|
|
| 517 | - $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
|
|
| 518 | - $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
|
|
| 519 | - return; |
|
| 520 | - } |
|
| 521 | - } else {
|
|
| 522 | - $this->debug('in invoke_method, no WSDL to validate method');
|
|
| 523 | - } |
|
| 496 | + // |
|
| 497 | + // if you are debugging in this area of the code, your service uses a class to implement methods, |
|
| 498 | + // you use SOAP RPC, and the client is .NET, please be aware of the following... |
|
| 499 | + // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the |
|
| 500 | + // method name. that is fine for naming the .NET methods. it is not fine for properly constructing |
|
| 501 | + // the XML request and reading the XML response. you need to add the RequestElementName and |
|
| 502 | + // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe |
|
| 503 | + // generates for the method. these parameters are used to specify the correct XML element names |
|
| 504 | + // for .NET to use, i.e. the names with the '.' in them. |
|
| 505 | + // |
|
| 506 | + $orig_methodname = $this->methodname; |
|
| 507 | + if ($this->wsdl) {
|
|
| 508 | + if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
|
|
| 509 | + $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
|
|
| 510 | + $this->appendDebug('opData=' . $this->varDump($this->opData));
|
|
| 511 | + } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
|
|
| 512 | + // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element |
|
| 513 | + $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
|
|
| 514 | + $this->appendDebug('opData=' . $this->varDump($this->opData));
|
|
| 515 | + $this->methodname = $this->opData['name']; |
|
| 516 | + } else {
|
|
| 517 | + $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
|
|
| 518 | + $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
|
|
| 519 | + return; |
|
| 520 | + } |
|
| 521 | + } else {
|
|
| 522 | + $this->debug('in invoke_method, no WSDL to validate method');
|
|
| 523 | + } |
|
| 524 | 524 | |
| 525 | - // if a . is present in $this->methodname, we see if there is a class in scope, |
|
| 526 | - // which could be referred to. We will also distinguish between two deliminators, |
|
| 527 | - // to allow methods to be called a the class or an instance |
|
| 528 | - if (strpos($this->methodname, '..') > 0) {
|
|
| 529 | - $delim = '..'; |
|
| 530 | - } else if (strpos($this->methodname, '.') > 0) {
|
|
| 531 | - $delim = '.'; |
|
| 532 | - } else {
|
|
| 533 | - $delim = ''; |
|
| 534 | - } |
|
| 535 | - $this->debug("in invoke_method, delim=$delim");
|
|
| 525 | + // if a . is present in $this->methodname, we see if there is a class in scope, |
|
| 526 | + // which could be referred to. We will also distinguish between two deliminators, |
|
| 527 | + // to allow methods to be called a the class or an instance |
|
| 528 | + if (strpos($this->methodname, '..') > 0) {
|
|
| 529 | + $delim = '..'; |
|
| 530 | + } else if (strpos($this->methodname, '.') > 0) {
|
|
| 531 | + $delim = '.'; |
|
| 532 | + } else {
|
|
| 533 | + $delim = ''; |
|
| 534 | + } |
|
| 535 | + $this->debug("in invoke_method, delim=$delim");
|
|
| 536 | 536 | |
| 537 | - $class = ''; |
|
| 538 | - $method = ''; |
|
| 539 | - if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
|
|
| 540 | - $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim)); |
|
| 541 | - if (class_exists($try_class)) {
|
|
| 542 | - // get the class and method name |
|
| 543 | - $class = $try_class; |
|
| 544 | - $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim)); |
|
| 545 | - $this->debug("in invoke_method, class=$class method=$method delim=$delim");
|
|
| 546 | - } else {
|
|
| 547 | - $this->debug("in invoke_method, class=$try_class not found");
|
|
| 548 | - } |
|
| 549 | - } else {
|
|
| 550 | - $try_class = ''; |
|
| 551 | - $this->debug("in invoke_method, no class to try");
|
|
| 552 | - } |
|
| 537 | + $class = ''; |
|
| 538 | + $method = ''; |
|
| 539 | + if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
|
|
| 540 | + $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim)); |
|
| 541 | + if (class_exists($try_class)) {
|
|
| 542 | + // get the class and method name |
|
| 543 | + $class = $try_class; |
|
| 544 | + $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim)); |
|
| 545 | + $this->debug("in invoke_method, class=$class method=$method delim=$delim");
|
|
| 546 | + } else {
|
|
| 547 | + $this->debug("in invoke_method, class=$try_class not found");
|
|
| 548 | + } |
|
| 549 | + } else {
|
|
| 550 | + $try_class = ''; |
|
| 551 | + $this->debug("in invoke_method, no class to try");
|
|
| 552 | + } |
|
| 553 | 553 | |
| 554 | - // does method exist? |
|
| 555 | - if ($class == '') {
|
|
| 556 | - if (!function_exists($this->methodname)) {
|
|
| 557 | - $this->debug("in invoke_method, function '$this->methodname' not found!");
|
|
| 558 | - $this->result = 'fault: method not found'; |
|
| 559 | - $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
|
|
| 560 | - return; |
|
| 561 | - } |
|
| 562 | - } else {
|
|
| 563 | - $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method; |
|
| 564 | - if (!in_array($method_to_compare, get_class_methods($class))) {
|
|
| 565 | - $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
|
|
| 566 | - $this->result = 'fault: method not found'; |
|
| 567 | - $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
|
|
| 568 | - return; |
|
| 569 | - } |
|
| 570 | - } |
|
| 554 | + // does method exist? |
|
| 555 | + if ($class == '') {
|
|
| 556 | + if (!function_exists($this->methodname)) {
|
|
| 557 | + $this->debug("in invoke_method, function '$this->methodname' not found!");
|
|
| 558 | + $this->result = 'fault: method not found'; |
|
| 559 | + $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
|
|
| 560 | + return; |
|
| 561 | + } |
|
| 562 | + } else {
|
|
| 563 | + $method_to_compare = (substr(phpversion(), 0, 2) == '4.') ? strtolower($method) : $method; |
|
| 564 | + if (!in_array($method_to_compare, get_class_methods($class))) {
|
|
| 565 | + $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
|
|
| 566 | + $this->result = 'fault: method not found'; |
|
| 567 | + $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
|
|
| 568 | + return; |
|
| 569 | + } |
|
| 570 | + } |
|
| 571 | 571 | |
| 572 | - // evaluate message, getting back parameters |
|
| 573 | - // verify that request parameters match the method's signature |
|
| 574 | - if(! $this->verify_method($this->methodname,$this->methodparams)){
|
|
| 575 | - // debug |
|
| 576 | - $this->debug('ERROR: request not verified against method signature');
|
|
| 577 | - $this->result = 'fault: request failed validation against method signature'; |
|
| 578 | - // return fault |
|
| 579 | - $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
|
|
| 580 | - return; |
|
| 581 | - } |
|
| 572 | + // evaluate message, getting back parameters |
|
| 573 | + // verify that request parameters match the method's signature |
|
| 574 | + if(! $this->verify_method($this->methodname,$this->methodparams)){
|
|
| 575 | + // debug |
|
| 576 | + $this->debug('ERROR: request not verified against method signature');
|
|
| 577 | + $this->result = 'fault: request failed validation against method signature'; |
|
| 578 | + // return fault |
|
| 579 | + $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
|
|
| 580 | + return; |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | - // if there are parameters to pass |
|
| 584 | - $this->debug('in invoke_method, params:');
|
|
| 585 | - $this->appendDebug($this->varDump($this->methodparams)); |
|
| 586 | - $this->debug("in invoke_method, calling '$this->methodname'");
|
|
| 587 | - if (!function_exists('call_user_func_array')) {
|
|
| 588 | - if ($class == '') {
|
|
| 589 | - $this->debug('in invoke_method, calling function using eval()');
|
|
| 590 | - $funcCall = "\$this->methodreturn = $this->methodname(";
|
|
| 591 | - } else {
|
|
| 592 | - if ($delim == '..') {
|
|
| 593 | - $this->debug('in invoke_method, calling class method using eval()');
|
|
| 594 | - $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
|
|
| 595 | - } else {
|
|
| 596 | - $this->debug('in invoke_method, calling instance method using eval()');
|
|
| 597 | - // generate unique instance name |
|
| 598 | - $instname = "\$inst_".time(); |
|
| 599 | - $funcCall = $instname." = new ".$class."(); "; |
|
| 600 | - $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
|
|
| 601 | - } |
|
| 602 | - } |
|
| 603 | - if ($this->methodparams) {
|
|
| 604 | - foreach ($this->methodparams as $param) {
|
|
| 605 | - if (is_array($param) || is_object($param)) {
|
|
| 606 | - $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
|
|
| 607 | - return; |
|
| 608 | - } |
|
| 609 | - $funcCall .= "\"$param\","; |
|
| 610 | - } |
|
| 611 | - $funcCall = substr($funcCall, 0, -1); |
|
| 612 | - } |
|
| 613 | - $funcCall .= ');'; |
|
| 614 | - $this->debug('in invoke_method, function call: '.$funcCall);
|
|
| 615 | - @eval($funcCall); |
|
| 616 | - } else {
|
|
| 617 | - if ($class == '') {
|
|
| 618 | - $this->debug('in invoke_method, calling function using call_user_func_array()');
|
|
| 619 | - $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() |
|
| 620 | - } elseif ($delim == '..') {
|
|
| 621 | - $this->debug('in invoke_method, calling class method using call_user_func_array()');
|
|
| 622 | - $call_arg = array ($class, $method); |
|
| 623 | - } else {
|
|
| 624 | - $this->debug('in invoke_method, calling instance method using call_user_func_array()');
|
|
| 625 | - $instance = new $class (); |
|
| 626 | - $call_arg = array(&$instance, $method); |
|
| 627 | - } |
|
| 628 | - if (is_array($this->methodparams)) {
|
|
| 629 | - $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams)); |
|
| 630 | - } else {
|
|
| 631 | - $this->methodreturn = call_user_func_array($call_arg, array()); |
|
| 632 | - } |
|
| 633 | - } |
|
| 583 | + // if there are parameters to pass |
|
| 584 | + $this->debug('in invoke_method, params:');
|
|
| 585 | + $this->appendDebug($this->varDump($this->methodparams)); |
|
| 586 | + $this->debug("in invoke_method, calling '$this->methodname'");
|
|
| 587 | + if (!function_exists('call_user_func_array')) {
|
|
| 588 | + if ($class == '') {
|
|
| 589 | + $this->debug('in invoke_method, calling function using eval()');
|
|
| 590 | + $funcCall = "\$this->methodreturn = $this->methodname(";
|
|
| 591 | + } else {
|
|
| 592 | + if ($delim == '..') {
|
|
| 593 | + $this->debug('in invoke_method, calling class method using eval()');
|
|
| 594 | + $funcCall = "\$this->methodreturn = ".$class."::".$method."(";
|
|
| 595 | + } else {
|
|
| 596 | + $this->debug('in invoke_method, calling instance method using eval()');
|
|
| 597 | + // generate unique instance name |
|
| 598 | + $instname = "\$inst_".time(); |
|
| 599 | + $funcCall = $instname." = new ".$class."(); "; |
|
| 600 | + $funcCall .= "\$this->methodreturn = ".$instname."->".$method."(";
|
|
| 601 | + } |
|
| 602 | + } |
|
| 603 | + if ($this->methodparams) {
|
|
| 604 | + foreach ($this->methodparams as $param) {
|
|
| 605 | + if (is_array($param) || is_object($param)) {
|
|
| 606 | + $this->fault('SOAP-ENV:Client', 'NuSOAP does not handle complexType parameters correctly when using eval; call_user_func_array must be available');
|
|
| 607 | + return; |
|
| 608 | + } |
|
| 609 | + $funcCall .= "\"$param\","; |
|
| 610 | + } |
|
| 611 | + $funcCall = substr($funcCall, 0, -1); |
|
| 612 | + } |
|
| 613 | + $funcCall .= ');'; |
|
| 614 | + $this->debug('in invoke_method, function call: '.$funcCall);
|
|
| 615 | + @eval($funcCall); |
|
| 616 | + } else {
|
|
| 617 | + if ($class == '') {
|
|
| 618 | + $this->debug('in invoke_method, calling function using call_user_func_array()');
|
|
| 619 | + $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() |
|
| 620 | + } elseif ($delim == '..') {
|
|
| 621 | + $this->debug('in invoke_method, calling class method using call_user_func_array()');
|
|
| 622 | + $call_arg = array ($class, $method); |
|
| 623 | + } else {
|
|
| 624 | + $this->debug('in invoke_method, calling instance method using call_user_func_array()');
|
|
| 625 | + $instance = new $class (); |
|
| 626 | + $call_arg = array(&$instance, $method); |
|
| 627 | + } |
|
| 628 | + if (is_array($this->methodparams)) {
|
|
| 629 | + $this->methodreturn = call_user_func_array($call_arg, array_values($this->methodparams)); |
|
| 630 | + } else {
|
|
| 631 | + $this->methodreturn = call_user_func_array($call_arg, array()); |
|
| 632 | + } |
|
| 633 | + } |
|
| 634 | 634 | $this->debug('in invoke_method, methodreturn:');
|
| 635 | 635 | $this->appendDebug($this->varDump($this->methodreturn)); |
| 636 | - $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
|
|
| 637 | - } |
|
| 636 | + $this->debug("in invoke_method, called method $this->methodname, received data of type ".gettype($this->methodreturn));
|
|
| 637 | + } |
|
| 638 | 638 | |
| 639 | - /** |
|
| 640 | - * serializes the return value from a PHP function into a full SOAP Envelope |
|
| 641 | - * |
|
| 642 | - * The following fields are set by this function (when successful) |
|
| 643 | - * |
|
| 644 | - * responseSOAP |
|
| 645 | - * |
|
| 646 | - * This sets the fault field on error |
|
| 647 | - * |
|
| 648 | - * @access private |
|
| 649 | - */ |
|
| 650 | - function serialize_return() {
|
|
| 651 | - $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
|
|
| 652 | - // if fault |
|
| 653 | - if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
|
|
| 654 | - $this->debug('got a fault object from method');
|
|
| 655 | - $this->fault = $this->methodreturn; |
|
| 656 | - return; |
|
| 657 | - } elseif ($this->methodreturnisliteralxml) {
|
|
| 658 | - $return_val = $this->methodreturn; |
|
| 659 | - // returned value(s) |
|
| 660 | - } else {
|
|
| 661 | - $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
|
|
| 662 | - $this->debug('serializing return value');
|
|
| 663 | - if($this->wsdl){
|
|
| 664 | - $opParams = ""; |
|
| 665 | - if (sizeof($this->opData['output']['parts']) > 1) {
|
|
| 666 | - $this->debug('more than one output part, so use the method return unchanged');
|
|
| 667 | - $opParams = $this->methodreturn; |
|
| 668 | - } elseif (sizeof($this->opData['output']['parts']) == 1) {
|
|
| 669 | - $this->debug('exactly one output part, so wrap the method return in a simple array');
|
|
| 670 | - // TODO: verify that it is not already wrapped! |
|
| 671 | - //foreach ($this->opData['output']['parts'] as $name => $type) {
|
|
| 672 | - // $this->debug('wrap in element named ' . $name);
|
|
| 673 | - //} |
|
| 674 | - $opParams = array($this->methodreturn); |
|
| 675 | - } |
|
| 676 | - $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams); |
|
| 677 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 678 | - $this->wsdl->clearDebug(); |
|
| 679 | - if($errstr = $this->wsdl->getError()){
|
|
| 680 | - $this->debug('got wsdl error: '.$errstr);
|
|
| 681 | - $this->fault('SOAP-ENV:Server', 'unable to serialize result');
|
|
| 682 | - return; |
|
| 683 | - } |
|
| 684 | - } else {
|
|
| 685 | - if (isset($this->methodreturn)) {
|
|
| 686 | - $return_val = $this->serialize_val($this->methodreturn, 'return'); |
|
| 687 | - } else {
|
|
| 688 | - $return_val = ''; |
|
| 689 | - $this->debug('in absence of WSDL, assume void return for backward compatibility');
|
|
| 690 | - } |
|
| 691 | - } |
|
| 692 | - } |
|
| 693 | - $this->debug('return value:');
|
|
| 694 | - $this->appendDebug($this->varDump($return_val)); |
|
| 639 | + /** |
|
| 640 | + * serializes the return value from a PHP function into a full SOAP Envelope |
|
| 641 | + * |
|
| 642 | + * The following fields are set by this function (when successful) |
|
| 643 | + * |
|
| 644 | + * responseSOAP |
|
| 645 | + * |
|
| 646 | + * This sets the fault field on error |
|
| 647 | + * |
|
| 648 | + * @access private |
|
| 649 | + */ |
|
| 650 | + function serialize_return() {
|
|
| 651 | + $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
|
|
| 652 | + // if fault |
|
| 653 | + if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
|
|
| 654 | + $this->debug('got a fault object from method');
|
|
| 655 | + $this->fault = $this->methodreturn; |
|
| 656 | + return; |
|
| 657 | + } elseif ($this->methodreturnisliteralxml) {
|
|
| 658 | + $return_val = $this->methodreturn; |
|
| 659 | + // returned value(s) |
|
| 660 | + } else {
|
|
| 661 | + $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
|
|
| 662 | + $this->debug('serializing return value');
|
|
| 663 | + if($this->wsdl){
|
|
| 664 | + $opParams = ""; |
|
| 665 | + if (sizeof($this->opData['output']['parts']) > 1) {
|
|
| 666 | + $this->debug('more than one output part, so use the method return unchanged');
|
|
| 667 | + $opParams = $this->methodreturn; |
|
| 668 | + } elseif (sizeof($this->opData['output']['parts']) == 1) {
|
|
| 669 | + $this->debug('exactly one output part, so wrap the method return in a simple array');
|
|
| 670 | + // TODO: verify that it is not already wrapped! |
|
| 671 | + //foreach ($this->opData['output']['parts'] as $name => $type) {
|
|
| 672 | + // $this->debug('wrap in element named ' . $name);
|
|
| 673 | + //} |
|
| 674 | + $opParams = array($this->methodreturn); |
|
| 675 | + } |
|
| 676 | + $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams); |
|
| 677 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 678 | + $this->wsdl->clearDebug(); |
|
| 679 | + if($errstr = $this->wsdl->getError()){
|
|
| 680 | + $this->debug('got wsdl error: '.$errstr);
|
|
| 681 | + $this->fault('SOAP-ENV:Server', 'unable to serialize result');
|
|
| 682 | + return; |
|
| 683 | + } |
|
| 684 | + } else {
|
|
| 685 | + if (isset($this->methodreturn)) {
|
|
| 686 | + $return_val = $this->serialize_val($this->methodreturn, 'return'); |
|
| 687 | + } else {
|
|
| 688 | + $return_val = ''; |
|
| 689 | + $this->debug('in absence of WSDL, assume void return for backward compatibility');
|
|
| 690 | + } |
|
| 691 | + } |
|
| 692 | + } |
|
| 693 | + $this->debug('return value:');
|
|
| 694 | + $this->appendDebug($this->varDump($return_val)); |
|
| 695 | 695 | |
| 696 | - $this->debug('serializing response');
|
|
| 697 | - if ($this->wsdl) {
|
|
| 698 | - $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
|
|
| 699 | - if ($this->opData['style'] == 'rpc') {
|
|
| 700 | - $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
|
|
| 701 | - if ($this->opData['output']['use'] == 'literal') {
|
|
| 702 | - // 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 |
|
| 703 | - if ($this->methodURI) {
|
|
| 704 | - $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
|
| 705 | - } else {
|
|
| 706 | - $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>'; |
|
| 707 | - } |
|
| 708 | - } else {
|
|
| 709 | - if ($this->methodURI) {
|
|
| 710 | - $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
|
| 711 | - } else {
|
|
| 712 | - $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>'; |
|
| 713 | - } |
|
| 714 | - } |
|
| 715 | - } else {
|
|
| 716 | - $this->debug('style is not rpc for serialization: assume document');
|
|
| 717 | - $payload = $return_val; |
|
| 718 | - } |
|
| 719 | - } else {
|
|
| 720 | - $this->debug('do not have WSDL for serialization: assume rpc/encoded');
|
|
| 721 | - $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
|
| 722 | - } |
|
| 723 | - $this->result = 'successful'; |
|
| 724 | - if($this->wsdl){
|
|
| 725 | - //if($this->debug_flag){
|
|
| 726 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 696 | + $this->debug('serializing response');
|
|
| 697 | + if ($this->wsdl) {
|
|
| 698 | + $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
|
|
| 699 | + if ($this->opData['style'] == 'rpc') {
|
|
| 700 | + $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
|
|
| 701 | + if ($this->opData['output']['use'] == 'literal') {
|
|
| 702 | + // 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 |
|
| 703 | + if ($this->methodURI) {
|
|
| 704 | + $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
|
| 705 | + } else {
|
|
| 706 | + $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>'; |
|
| 707 | + } |
|
| 708 | + } else {
|
|
| 709 | + if ($this->methodURI) {
|
|
| 710 | + $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
|
| 711 | + } else {
|
|
| 712 | + $payload = '<'.$this->methodname.'Response>'.$return_val.'</'.$this->methodname.'Response>'; |
|
| 713 | + } |
|
| 714 | + } |
|
| 715 | + } else {
|
|
| 716 | + $this->debug('style is not rpc for serialization: assume document');
|
|
| 717 | + $payload = $return_val; |
|
| 718 | + } |
|
| 719 | + } else {
|
|
| 720 | + $this->debug('do not have WSDL for serialization: assume rpc/encoded');
|
|
| 721 | + $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
|
| 722 | + } |
|
| 723 | + $this->result = 'successful'; |
|
| 724 | + if($this->wsdl){
|
|
| 725 | + //if($this->debug_flag){
|
|
| 726 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 727 | 727 | // } |
| 728 | - if (isset($this->opData['output']['encodingStyle'])) {
|
|
| 729 | - $encodingStyle = $this->opData['output']['encodingStyle']; |
|
| 730 | - } else {
|
|
| 731 | - $encodingStyle = ''; |
|
| 732 | - } |
|
| 733 | - // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces. |
|
| 734 | - $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle); |
|
| 735 | - } else {
|
|
| 736 | - $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders); |
|
| 737 | - } |
|
| 738 | - $this->debug("Leaving serialize_return");
|
|
| 739 | - } |
|
| 728 | + if (isset($this->opData['output']['encodingStyle'])) {
|
|
| 729 | + $encodingStyle = $this->opData['output']['encodingStyle']; |
|
| 730 | + } else {
|
|
| 731 | + $encodingStyle = ''; |
|
| 732 | + } |
|
| 733 | + // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces. |
|
| 734 | + $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle); |
|
| 735 | + } else {
|
|
| 736 | + $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders); |
|
| 737 | + } |
|
| 738 | + $this->debug("Leaving serialize_return");
|
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - /** |
|
| 742 | - * sends an HTTP response |
|
| 743 | - * |
|
| 744 | - * The following fields are set by this function (when successful) |
|
| 745 | - * |
|
| 746 | - * outgoing_headers |
|
| 747 | - * response |
|
| 748 | - * |
|
| 749 | - * @access private |
|
| 750 | - */ |
|
| 751 | - function send_response() {
|
|
| 752 | - $this->debug('Enter send_response');
|
|
| 753 | - if ($this->fault) {
|
|
| 754 | - $payload = $this->fault->serialize(); |
|
| 755 | - $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error"; |
|
| 756 | - $this->outgoing_headers[] = "Status: 500 Internal Server Error"; |
|
| 757 | - } else {
|
|
| 758 | - $payload = $this->responseSOAP; |
|
| 759 | - // Some combinations of PHP+Web server allow the Status |
|
| 760 | - // to come through as a header. Since OK is the default |
|
| 761 | - // just do nothing. |
|
| 762 | - // $this->outgoing_headers[] = "HTTP/1.0 200 OK"; |
|
| 763 | - // $this->outgoing_headers[] = "Status: 200 OK"; |
|
| 764 | - } |
|
| 741 | + /** |
|
| 742 | + * sends an HTTP response |
|
| 743 | + * |
|
| 744 | + * The following fields are set by this function (when successful) |
|
| 745 | + * |
|
| 746 | + * outgoing_headers |
|
| 747 | + * response |
|
| 748 | + * |
|
| 749 | + * @access private |
|
| 750 | + */ |
|
| 751 | + function send_response() {
|
|
| 752 | + $this->debug('Enter send_response');
|
|
| 753 | + if ($this->fault) {
|
|
| 754 | + $payload = $this->fault->serialize(); |
|
| 755 | + $this->outgoing_headers[] = "HTTP/1.0 500 Internal Server Error"; |
|
| 756 | + $this->outgoing_headers[] = "Status: 500 Internal Server Error"; |
|
| 757 | + } else {
|
|
| 758 | + $payload = $this->responseSOAP; |
|
| 759 | + // Some combinations of PHP+Web server allow the Status |
|
| 760 | + // to come through as a header. Since OK is the default |
|
| 761 | + // just do nothing. |
|
| 762 | + // $this->outgoing_headers[] = "HTTP/1.0 200 OK"; |
|
| 763 | + // $this->outgoing_headers[] = "Status: 200 OK"; |
|
| 764 | + } |
|
| 765 | 765 | // add debug data if in debug mode |
| 766 | - if(isset($this->debug_flag) && $this->debug_flag){
|
|
| 767 | - $payload .= $this->getDebugAsXMLComment(); |
|
| 766 | + if(isset($this->debug_flag) && $this->debug_flag){
|
|
| 767 | + $payload .= $this->getDebugAsXMLComment(); |
|
| 768 | + } |
|
| 769 | + $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; |
|
| 770 | + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 771 | + $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
|
|
| 772 | + // Let the Web server decide about this |
|
| 773 | + //$this->outgoing_headers[] = "Connection: Close\r\n"; |
|
| 774 | + $payload = $this->getHTTPBody($payload); |
|
| 775 | + $type = $this->getHTTPContentType(); |
|
| 776 | + $charset = $this->getHTTPContentTypeCharset(); |
|
| 777 | + $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : ''); |
|
| 778 | + //begin code to compress payload - by John |
|
| 779 | + // NOTE: there is no way to know whether the Web server will also compress |
|
| 780 | + // this data. |
|
| 781 | + if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
|
|
| 782 | + if (strstr($this->headers['accept-encoding'], 'gzip')) {
|
|
| 783 | + if (function_exists('gzencode')) {
|
|
| 784 | + if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 785 | + $payload .= "<!-- Content being gzipped -->"; |
|
| 786 | + } |
|
| 787 | + $this->outgoing_headers[] = "Content-Encoding: gzip"; |
|
| 788 | + $payload = gzencode($payload); |
|
| 789 | + } else {
|
|
| 790 | + if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 791 | + $payload .= "<!-- Content will not be gzipped: no gzencode -->"; |
|
| 792 | + } |
|
| 793 | + } |
|
| 794 | + } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
|
|
| 795 | + // Note: MSIE requires gzdeflate output (no Zlib header and checksum), |
|
| 796 | + // instead of gzcompress output, |
|
| 797 | + // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5) |
|
| 798 | + if (function_exists('gzdeflate')) {
|
|
| 799 | + if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 800 | + $payload .= "<!-- Content being deflated -->"; |
|
| 801 | + } |
|
| 802 | + $this->outgoing_headers[] = "Content-Encoding: deflate"; |
|
| 803 | + $payload = gzdeflate($payload); |
|
| 804 | + } else {
|
|
| 805 | + if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 806 | + $payload .= "<!-- Content will not be deflated: no gzcompress -->"; |
|
| 807 | + } |
|
| 808 | + } |
|
| 809 | + } |
|
| 768 | 810 | } |
| 769 | - $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; |
|
| 770 | - preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 771 | - $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
|
|
| 772 | - // Let the Web server decide about this |
|
| 773 | - //$this->outgoing_headers[] = "Connection: Close\r\n"; |
|
| 774 | - $payload = $this->getHTTPBody($payload); |
|
| 775 | - $type = $this->getHTTPContentType(); |
|
| 776 | - $charset = $this->getHTTPContentTypeCharset(); |
|
| 777 | - $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : ''); |
|
| 778 | - //begin code to compress payload - by John |
|
| 779 | - // NOTE: there is no way to know whether the Web server will also compress |
|
| 780 | - // this data. |
|
| 781 | - if (strlen($payload) > 1024 && isset($this->headers) && isset($this->headers['accept-encoding'])) {
|
|
| 782 | - if (strstr($this->headers['accept-encoding'], 'gzip')) {
|
|
| 783 | - if (function_exists('gzencode')) {
|
|
| 784 | - if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 785 | - $payload .= "<!-- Content being gzipped -->"; |
|
| 786 | - } |
|
| 787 | - $this->outgoing_headers[] = "Content-Encoding: gzip"; |
|
| 788 | - $payload = gzencode($payload); |
|
| 789 | - } else {
|
|
| 790 | - if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 791 | - $payload .= "<!-- Content will not be gzipped: no gzencode -->"; |
|
| 792 | - } |
|
| 793 | - } |
|
| 794 | - } elseif (strstr($this->headers['accept-encoding'], 'deflate')) {
|
|
| 795 | - // Note: MSIE requires gzdeflate output (no Zlib header and checksum), |
|
| 796 | - // instead of gzcompress output, |
|
| 797 | - // which conflicts with HTTP 1.1 spec (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5) |
|
| 798 | - if (function_exists('gzdeflate')) {
|
|
| 799 | - if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 800 | - $payload .= "<!-- Content being deflated -->"; |
|
| 801 | - } |
|
| 802 | - $this->outgoing_headers[] = "Content-Encoding: deflate"; |
|
| 803 | - $payload = gzdeflate($payload); |
|
| 804 | - } else {
|
|
| 805 | - if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 806 | - $payload .= "<!-- Content will not be deflated: no gzcompress -->"; |
|
| 807 | - } |
|
| 808 | - } |
|
| 809 | - } |
|
| 810 | - } |
|
| 811 | - //end code |
|
| 812 | - $this->outgoing_headers[] = "Content-Length: ".strlen($payload); |
|
| 813 | - reset($this->outgoing_headers); |
|
| 814 | - foreach($this->outgoing_headers as $hdr){
|
|
| 815 | - header($hdr, false); |
|
| 816 | - } |
|
| 817 | - print $payload; |
|
| 818 | - $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
|
|
| 819 | - } |
|
| 811 | + //end code |
|
| 812 | + $this->outgoing_headers[] = "Content-Length: ".strlen($payload); |
|
| 813 | + reset($this->outgoing_headers); |
|
| 814 | + foreach($this->outgoing_headers as $hdr){
|
|
| 815 | + header($hdr, false); |
|
| 816 | + } |
|
| 817 | + print $payload; |
|
| 818 | + $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
|
|
| 819 | + } |
|
| 820 | 820 | |
| 821 | - /** |
|
| 822 | - * takes the value that was created by parsing the request |
|
| 823 | - * and compares to the method's signature, if available. |
|
| 824 | - * |
|
| 825 | - * @param string $operation The operation to be invoked |
|
| 826 | - * @param array $request The array of parameter values |
|
| 827 | - * @return boolean Whether the operation was found |
|
| 828 | - * @access private |
|
| 829 | - */ |
|
| 830 | - function verify_method($operation,$request){
|
|
| 831 | - if(isset($this->wsdl) && is_object($this->wsdl)){
|
|
| 832 | - if($this->wsdl->getOperationData($operation)){
|
|
| 833 | - return true; |
|
| 834 | - } |
|
| 835 | - } elseif(isset($this->operations[$operation])){
|
|
| 836 | - return true; |
|
| 837 | - } |
|
| 838 | - return false; |
|
| 839 | - } |
|
| 821 | + /** |
|
| 822 | + * takes the value that was created by parsing the request |
|
| 823 | + * and compares to the method's signature, if available. |
|
| 824 | + * |
|
| 825 | + * @param string $operation The operation to be invoked |
|
| 826 | + * @param array $request The array of parameter values |
|
| 827 | + * @return boolean Whether the operation was found |
|
| 828 | + * @access private |
|
| 829 | + */ |
|
| 830 | + function verify_method($operation,$request){
|
|
| 831 | + if(isset($this->wsdl) && is_object($this->wsdl)){
|
|
| 832 | + if($this->wsdl->getOperationData($operation)){
|
|
| 833 | + return true; |
|
| 834 | + } |
|
| 835 | + } elseif(isset($this->operations[$operation])){
|
|
| 836 | + return true; |
|
| 837 | + } |
|
| 838 | + return false; |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | - /** |
|
| 842 | - * processes SOAP message received from client |
|
| 843 | - * |
|
| 844 | - * @param array $headers The HTTP headers |
|
| 845 | - * @param string $data unprocessed request data from client |
|
| 846 | - * @return mixed value of the message, decoded into a PHP type |
|
| 847 | - * @access private |
|
| 848 | - */ |
|
| 841 | + /** |
|
| 842 | + * processes SOAP message received from client |
|
| 843 | + * |
|
| 844 | + * @param array $headers The HTTP headers |
|
| 845 | + * @param string $data unprocessed request data from client |
|
| 846 | + * @return mixed value of the message, decoded into a PHP type |
|
| 847 | + * @access private |
|
| 848 | + */ |
|
| 849 | 849 | function parseRequest($headers, $data) {
|
| 850 | - $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
|
|
| 851 | - $this->appendDebug($this->varDump($headers)); |
|
| 852 | - if (!isset($headers['content-type'])) {
|
|
| 853 | - $this->setError('Request not of type text/xml (no content-type header)');
|
|
| 854 | - return false; |
|
| 855 | - } |
|
| 856 | - if (!strstr($headers['content-type'], 'text/xml')) {
|
|
| 857 | - $this->setError('Request not of type text/xml');
|
|
| 858 | - return false; |
|
| 859 | - } |
|
| 860 | - if (strpos($headers['content-type'], '=')) {
|
|
| 861 | - $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
|
| 862 | - $this->debug('Got response encoding: ' . $enc);
|
|
| 863 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 864 | - $this->xml_encoding = strtoupper($enc); |
|
| 865 | - } else {
|
|
| 866 | - $this->xml_encoding = 'US-ASCII'; |
|
| 867 | - } |
|
| 868 | - } else {
|
|
| 869 | - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 870 | - $this->xml_encoding = 'ISO-8859-1'; |
|
| 871 | - } |
|
| 872 | - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 873 | - // parse response, get soap parser obj |
|
| 874 | - $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8); |
|
| 850 | + $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
|
|
| 851 | + $this->appendDebug($this->varDump($headers)); |
|
| 852 | + if (!isset($headers['content-type'])) {
|
|
| 853 | + $this->setError('Request not of type text/xml (no content-type header)');
|
|
| 854 | + return false; |
|
| 855 | + } |
|
| 856 | + if (!strstr($headers['content-type'], 'text/xml')) {
|
|
| 857 | + $this->setError('Request not of type text/xml');
|
|
| 858 | + return false; |
|
| 859 | + } |
|
| 860 | + if (strpos($headers['content-type'], '=')) {
|
|
| 861 | + $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
|
| 862 | + $this->debug('Got response encoding: ' . $enc);
|
|
| 863 | + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 864 | + $this->xml_encoding = strtoupper($enc); |
|
| 865 | + } else {
|
|
| 866 | + $this->xml_encoding = 'US-ASCII'; |
|
| 867 | + } |
|
| 868 | + } else {
|
|
| 869 | + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 870 | + $this->xml_encoding = 'ISO-8859-1'; |
|
| 871 | + } |
|
| 872 | + $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 873 | + // parse response, get soap parser obj |
|
| 874 | + $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8); |
|
| 875 | 875 | |
| 876 | - // parser debug |
|
| 877 | - $this->debug("parser debug: \n".$parser->getDebug());
|
|
| 878 | - // if fault occurred during message parsing |
|
| 879 | - if($err = $parser->getError()){
|
|
| 880 | - $this->result = 'fault: error in msg parsing: '.$err; |
|
| 881 | - $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
|
|
| 882 | - // else successfully parsed request into soapval object |
|
| 883 | - } else {
|
|
| 884 | - // get/set methodname |
|
| 885 | - $this->methodURI = $parser->root_struct_namespace; |
|
| 886 | - $this->methodname = $parser->root_struct_name; |
|
| 887 | - $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
|
|
| 888 | - $this->debug('calling parser->get_soapbody()');
|
|
| 889 | - $this->methodparams = $parser->get_soapbody(); |
|
| 890 | - // get SOAP headers |
|
| 891 | - $this->requestHeaders = $parser->getHeaders(); |
|
| 892 | - // get SOAP Header |
|
| 893 | - $this->requestHeader = $parser->get_soapheader(); |
|
| 876 | + // parser debug |
|
| 877 | + $this->debug("parser debug: \n".$parser->getDebug());
|
|
| 878 | + // if fault occurred during message parsing |
|
| 879 | + if($err = $parser->getError()){
|
|
| 880 | + $this->result = 'fault: error in msg parsing: '.$err; |
|
| 881 | + $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
|
|
| 882 | + // else successfully parsed request into soapval object |
|
| 883 | + } else {
|
|
| 884 | + // get/set methodname |
|
| 885 | + $this->methodURI = $parser->root_struct_namespace; |
|
| 886 | + $this->methodname = $parser->root_struct_name; |
|
| 887 | + $this->debug('methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
|
|
| 888 | + $this->debug('calling parser->get_soapbody()');
|
|
| 889 | + $this->methodparams = $parser->get_soapbody(); |
|
| 890 | + // get SOAP headers |
|
| 891 | + $this->requestHeaders = $parser->getHeaders(); |
|
| 892 | + // get SOAP Header |
|
| 893 | + $this->requestHeader = $parser->get_soapheader(); |
|
| 894 | 894 | // add document for doclit support |
| 895 | 895 | $this->document = $parser->document; |
| 896 | - } |
|
| 897 | - } |
|
| 896 | + } |
|
| 897 | + } |
|
| 898 | 898 | |
| 899 | - /** |
|
| 900 | - * gets the HTTP body for the current response. |
|
| 901 | - * |
|
| 902 | - * @param string $soapmsg The SOAP payload |
|
| 903 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 904 | - * @access private |
|
| 905 | - */ |
|
| 906 | - function getHTTPBody($soapmsg) {
|
|
| 907 | - return $soapmsg; |
|
| 908 | - } |
|
| 899 | + /** |
|
| 900 | + * gets the HTTP body for the current response. |
|
| 901 | + * |
|
| 902 | + * @param string $soapmsg The SOAP payload |
|
| 903 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 904 | + * @access private |
|
| 905 | + */ |
|
| 906 | + function getHTTPBody($soapmsg) {
|
|
| 907 | + return $soapmsg; |
|
| 908 | + } |
|
| 909 | 909 | |
| 910 | - /** |
|
| 911 | - * gets the HTTP content type for the current response. |
|
| 912 | - * |
|
| 913 | - * Note: getHTTPBody must be called before this. |
|
| 914 | - * |
|
| 915 | - * @return string the HTTP content type for the current response. |
|
| 916 | - * @access private |
|
| 917 | - */ |
|
| 918 | - function getHTTPContentType() {
|
|
| 919 | - return 'text/xml'; |
|
| 920 | - } |
|
| 910 | + /** |
|
| 911 | + * gets the HTTP content type for the current response. |
|
| 912 | + * |
|
| 913 | + * Note: getHTTPBody must be called before this. |
|
| 914 | + * |
|
| 915 | + * @return string the HTTP content type for the current response. |
|
| 916 | + * @access private |
|
| 917 | + */ |
|
| 918 | + function getHTTPContentType() {
|
|
| 919 | + return 'text/xml'; |
|
| 920 | + } |
|
| 921 | 921 | |
| 922 | - /** |
|
| 923 | - * gets the HTTP content type charset for the current response. |
|
| 924 | - * returns false for non-text content types. |
|
| 925 | - * |
|
| 926 | - * Note: getHTTPBody must be called before this. |
|
| 927 | - * |
|
| 928 | - * @return string the HTTP content type charset for the current response. |
|
| 929 | - * @access private |
|
| 930 | - */ |
|
| 931 | - function getHTTPContentTypeCharset() {
|
|
| 932 | - return $this->soap_defencoding; |
|
| 933 | - } |
|
| 922 | + /** |
|
| 923 | + * gets the HTTP content type charset for the current response. |
|
| 924 | + * returns false for non-text content types. |
|
| 925 | + * |
|
| 926 | + * Note: getHTTPBody must be called before this. |
|
| 927 | + * |
|
| 928 | + * @return string the HTTP content type charset for the current response. |
|
| 929 | + * @access private |
|
| 930 | + */ |
|
| 931 | + function getHTTPContentTypeCharset() {
|
|
| 932 | + return $this->soap_defencoding; |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | - /** |
|
| 936 | - * add a method to the dispatch map (this has been replaced by the register method) |
|
| 937 | - * |
|
| 938 | - * @param string $methodname |
|
| 939 | - * @param string $in array of input values |
|
| 940 | - * @param string $out array of output values |
|
| 941 | - * @access public |
|
| 942 | - * @deprecated |
|
| 943 | - */ |
|
| 944 | - function add_to_map($methodname,$in,$out){
|
|
| 945 | - $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
|
|
| 946 | - } |
|
| 935 | + /** |
|
| 936 | + * add a method to the dispatch map (this has been replaced by the register method) |
|
| 937 | + * |
|
| 938 | + * @param string $methodname |
|
| 939 | + * @param string $in array of input values |
|
| 940 | + * @param string $out array of output values |
|
| 941 | + * @access public |
|
| 942 | + * @deprecated |
|
| 943 | + */ |
|
| 944 | + function add_to_map($methodname,$in,$out){
|
|
| 945 | + $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
|
|
| 946 | + } |
|
| 947 | 947 | |
| 948 | - /** |
|
| 949 | - * register a service function with the server |
|
| 950 | - * |
|
| 951 | - * @param string $name the name of the PHP function, class.method or class..method |
|
| 952 | - * @param array $in assoc array of input values: key = param name, value = param type |
|
| 953 | - * @param array $out assoc array of output values: key = param name, value = param type |
|
| 954 | - * @param mixed $namespace the element namespace for the method or false |
|
| 955 | - * @param mixed $soapaction the soapaction for the method or false |
|
| 956 | - * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 957 | - * @param mixed $use optional (encoded|literal) or false |
|
| 958 | - * @param string $documentation optional Description to include in WSDL |
|
| 959 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 960 | - * @access public |
|
| 961 | - */ |
|
| 962 | - function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
|
|
| 963 | - global $HTTP_SERVER_VARS; |
|
| 948 | + /** |
|
| 949 | + * register a service function with the server |
|
| 950 | + * |
|
| 951 | + * @param string $name the name of the PHP function, class.method or class..method |
|
| 952 | + * @param array $in assoc array of input values: key = param name, value = param type |
|
| 953 | + * @param array $out assoc array of output values: key = param name, value = param type |
|
| 954 | + * @param mixed $namespace the element namespace for the method or false |
|
| 955 | + * @param mixed $soapaction the soapaction for the method or false |
|
| 956 | + * @param mixed $style optional (rpc|document) or false Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 957 | + * @param mixed $use optional (encoded|literal) or false |
|
| 958 | + * @param string $documentation optional Description to include in WSDL |
|
| 959 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 960 | + * @access public |
|
| 961 | + */ |
|
| 962 | + function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
|
|
| 963 | + global $HTTP_SERVER_VARS; |
|
| 964 | 964 | |
| 965 | - if($this->externalWSDLURL){
|
|
| 966 | - die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
|
|
| 967 | - } |
|
| 968 | - if (! $name) {
|
|
| 969 | - die('You must specify a name when you register an operation');
|
|
| 970 | - } |
|
| 971 | - if (!is_array($in)) {
|
|
| 972 | - die('You must provide an array for operation inputs');
|
|
| 973 | - } |
|
| 974 | - if (!is_array($out)) {
|
|
| 975 | - die('You must provide an array for operation outputs');
|
|
| 976 | - } |
|
| 977 | - if(false == $namespace) {
|
|
| 978 | - } |
|
| 979 | - if(false == $soapaction) {
|
|
| 980 | - if (isset($_SERVER)) {
|
|
| 981 | - $SERVER_NAME = $_SERVER['SERVER_NAME']; |
|
| 982 | - $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; |
|
| 983 | - $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); |
|
| 984 | - } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 985 | - $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; |
|
| 986 | - $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; |
|
| 987 | - $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; |
|
| 988 | - } else {
|
|
| 989 | - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
|
| 990 | - } |
|
| 991 | - if ($HTTPS == '1' || $HTTPS == 'on') {
|
|
| 992 | - $SCHEME = 'https'; |
|
| 993 | - } else {
|
|
| 994 | - $SCHEME = 'http'; |
|
| 995 | - } |
|
| 996 | - $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; |
|
| 997 | - } |
|
| 998 | - if(false == $style) {
|
|
| 999 | - $style = "rpc"; |
|
| 1000 | - } |
|
| 1001 | - if(false == $use) {
|
|
| 1002 | - $use = "encoded"; |
|
| 1003 | - } |
|
| 1004 | - if ($use == 'encoded' && $encodingStyle == '') {
|
|
| 1005 | - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1006 | - } |
|
| 965 | + if($this->externalWSDLURL){
|
|
| 966 | + die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
|
|
| 967 | + } |
|
| 968 | + if (! $name) {
|
|
| 969 | + die('You must specify a name when you register an operation');
|
|
| 970 | + } |
|
| 971 | + if (!is_array($in)) {
|
|
| 972 | + die('You must provide an array for operation inputs');
|
|
| 973 | + } |
|
| 974 | + if (!is_array($out)) {
|
|
| 975 | + die('You must provide an array for operation outputs');
|
|
| 976 | + } |
|
| 977 | + if(false == $namespace) {
|
|
| 978 | + } |
|
| 979 | + if(false == $soapaction) {
|
|
| 980 | + if (isset($_SERVER)) {
|
|
| 981 | + $SERVER_NAME = $_SERVER['SERVER_NAME']; |
|
| 982 | + $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; |
|
| 983 | + $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); |
|
| 984 | + } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 985 | + $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; |
|
| 986 | + $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; |
|
| 987 | + $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; |
|
| 988 | + } else {
|
|
| 989 | + $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
|
| 990 | + } |
|
| 991 | + if ($HTTPS == '1' || $HTTPS == 'on') {
|
|
| 992 | + $SCHEME = 'https'; |
|
| 993 | + } else {
|
|
| 994 | + $SCHEME = 'http'; |
|
| 995 | + } |
|
| 996 | + $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; |
|
| 997 | + } |
|
| 998 | + if(false == $style) {
|
|
| 999 | + $style = "rpc"; |
|
| 1000 | + } |
|
| 1001 | + if(false == $use) {
|
|
| 1002 | + $use = "encoded"; |
|
| 1003 | + } |
|
| 1004 | + if ($use == 'encoded' && $encodingStyle == '') {
|
|
| 1005 | + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 1006 | + } |
|
| 1007 | 1007 | |
| 1008 | - $this->operations[$name] = array( |
|
| 1009 | - 'name' => $name, |
|
| 1010 | - 'in' => $in, |
|
| 1011 | - 'out' => $out, |
|
| 1012 | - 'namespace' => $namespace, |
|
| 1013 | - 'soapaction' => $soapaction, |
|
| 1014 | - 'style' => $style); |
|
| 1008 | + $this->operations[$name] = array( |
|
| 1009 | + 'name' => $name, |
|
| 1010 | + 'in' => $in, |
|
| 1011 | + 'out' => $out, |
|
| 1012 | + 'namespace' => $namespace, |
|
| 1013 | + 'soapaction' => $soapaction, |
|
| 1014 | + 'style' => $style); |
|
| 1015 | 1015 | if($this->wsdl){
|
| 1016 | - $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle); |
|
| 1017 | - } |
|
| 1018 | - return true; |
|
| 1019 | - } |
|
| 1016 | + $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle); |
|
| 1017 | + } |
|
| 1018 | + return true; |
|
| 1019 | + } |
|
| 1020 | 1020 | |
| 1021 | - /** |
|
| 1022 | - * Specify a fault to be returned to the client. |
|
| 1023 | - * This also acts as a flag to the server that a fault has occured. |
|
| 1024 | - * |
|
| 1025 | - * @param string $faultcode |
|
| 1026 | - * @param string $faultstring |
|
| 1027 | - * @param string $faultactor |
|
| 1028 | - * @param string $faultdetail |
|
| 1029 | - * @access public |
|
| 1030 | - */ |
|
| 1031 | - function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
|
|
| 1032 | - if ($faultdetail == '' && $this->debug_flag) {
|
|
| 1033 | - $faultdetail = $this->getDebug(); |
|
| 1034 | - } |
|
| 1035 | - $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail); |
|
| 1036 | - $this->fault->soap_defencoding = $this->soap_defencoding; |
|
| 1037 | - } |
|
| 1021 | + /** |
|
| 1022 | + * Specify a fault to be returned to the client. |
|
| 1023 | + * This also acts as a flag to the server that a fault has occured. |
|
| 1024 | + * |
|
| 1025 | + * @param string $faultcode |
|
| 1026 | + * @param string $faultstring |
|
| 1027 | + * @param string $faultactor |
|
| 1028 | + * @param string $faultdetail |
|
| 1029 | + * @access public |
|
| 1030 | + */ |
|
| 1031 | + function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
|
|
| 1032 | + if ($faultdetail == '' && $this->debug_flag) {
|
|
| 1033 | + $faultdetail = $this->getDebug(); |
|
| 1034 | + } |
|
| 1035 | + $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail); |
|
| 1036 | + $this->fault->soap_defencoding = $this->soap_defencoding; |
|
| 1037 | + } |
|
| 1038 | 1038 | |
| 1039 | 1039 | /** |
| 1040 | - * Sets up wsdl object. |
|
| 1041 | - * Acts as a flag to enable internal WSDL generation |
|
| 1042 | - * |
|
| 1043 | - * @param string $serviceName, name of the service |
|
| 1044 | - * @param mixed $namespace optional 'tns' service namespace or false |
|
| 1045 | - * @param mixed $endpoint optional URL of service endpoint or false |
|
| 1046 | - * @param string $style optional (rpc|document) WSDL style (also specified by operation) |
|
| 1047 | - * @param string $transport optional SOAP transport |
|
| 1048 | - * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false |
|
| 1049 | - */ |
|
| 1040 | + * Sets up wsdl object. |
|
| 1041 | + * Acts as a flag to enable internal WSDL generation |
|
| 1042 | + * |
|
| 1043 | + * @param string $serviceName, name of the service |
|
| 1044 | + * @param mixed $namespace optional 'tns' service namespace or false |
|
| 1045 | + * @param mixed $endpoint optional URL of service endpoint or false |
|
| 1046 | + * @param string $style optional (rpc|document) WSDL style (also specified by operation) |
|
| 1047 | + * @param string $transport optional SOAP transport |
|
| 1048 | + * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false |
|
| 1049 | + */ |
|
| 1050 | 1050 | function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) |
| 1051 | 1051 | {
|
| 1052 | - global $HTTP_SERVER_VARS; |
|
| 1052 | + global $HTTP_SERVER_VARS; |
|
| 1053 | 1053 | |
| 1054 | - if (isset($_SERVER)) {
|
|
| 1055 | - $SERVER_NAME = $_SERVER['SERVER_NAME']; |
|
| 1056 | - $SERVER_PORT = $_SERVER['SERVER_PORT']; |
|
| 1057 | - $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; |
|
| 1058 | - $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); |
|
| 1059 | - } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 1060 | - $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; |
|
| 1061 | - $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT']; |
|
| 1062 | - $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; |
|
| 1063 | - $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; |
|
| 1064 | - } else {
|
|
| 1065 | - $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
|
| 1066 | - } |
|
| 1067 | - // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) |
|
| 1068 | - $colon = strpos($SERVER_NAME,":"); |
|
| 1069 | - if ($colon) {
|
|
| 1070 | - $SERVER_NAME = substr($SERVER_NAME, 0, $colon); |
|
| 1071 | - } |
|
| 1072 | - if ($SERVER_PORT == 80) {
|
|
| 1073 | - $SERVER_PORT = ''; |
|
| 1074 | - } else {
|
|
| 1075 | - $SERVER_PORT = ':' . $SERVER_PORT; |
|
| 1076 | - } |
|
| 1054 | + if (isset($_SERVER)) {
|
|
| 1055 | + $SERVER_NAME = $_SERVER['SERVER_NAME']; |
|
| 1056 | + $SERVER_PORT = $_SERVER['SERVER_PORT']; |
|
| 1057 | + $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; |
|
| 1058 | + $HTTPS = isset($_SERVER['HTTPS']) ? $_SERVER['HTTPS'] : (isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'); |
|
| 1059 | + } elseif (isset($HTTP_SERVER_VARS)) {
|
|
| 1060 | + $SERVER_NAME = $HTTP_SERVER_VARS['SERVER_NAME']; |
|
| 1061 | + $SERVER_PORT = $HTTP_SERVER_VARS['SERVER_PORT']; |
|
| 1062 | + $SCRIPT_NAME = isset($HTTP_SERVER_VARS['PHP_SELF']) ? $HTTP_SERVER_VARS['PHP_SELF'] : $HTTP_SERVER_VARS['SCRIPT_NAME']; |
|
| 1063 | + $HTTPS = isset($HTTP_SERVER_VARS['HTTPS']) ? $HTTP_SERVER_VARS['HTTPS'] : 'off'; |
|
| 1064 | + } else {
|
|
| 1065 | + $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
|
| 1066 | + } |
|
| 1067 | + // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) |
|
| 1068 | + $colon = strpos($SERVER_NAME,":"); |
|
| 1069 | + if ($colon) {
|
|
| 1070 | + $SERVER_NAME = substr($SERVER_NAME, 0, $colon); |
|
| 1071 | + } |
|
| 1072 | + if ($SERVER_PORT == 80) {
|
|
| 1073 | + $SERVER_PORT = ''; |
|
| 1074 | + } else {
|
|
| 1075 | + $SERVER_PORT = ':' . $SERVER_PORT; |
|
| 1076 | + } |
|
| 1077 | 1077 | if(false == $namespace) {
|
| 1078 | 1078 | $namespace = "http://$SERVER_NAME/soap/$serviceName"; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | if(false == $endpoint) {
|
| 1082 | - if ($HTTPS == '1' || $HTTPS == 'on') {
|
|
| 1083 | - $SCHEME = 'https'; |
|
| 1084 | - } else {
|
|
| 1085 | - $SCHEME = 'http'; |
|
| 1086 | - } |
|
| 1082 | + if ($HTTPS == '1' || $HTTPS == 'on') {
|
|
| 1083 | + $SCHEME = 'https'; |
|
| 1084 | + } else {
|
|
| 1085 | + $SCHEME = 'http'; |
|
| 1086 | + } |
|
| 1087 | 1087 | $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME"; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
@@ -1091,29 +1091,29 @@ discard block |
||
| 1091 | 1091 | $schemaTargetNamespace = $namespace; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
| 1094 | - $this->wsdl = new wsdl; |
|
| 1095 | - $this->wsdl->serviceName = $serviceName; |
|
| 1094 | + $this->wsdl = new wsdl; |
|
| 1095 | + $this->wsdl->serviceName = $serviceName; |
|
| 1096 | 1096 | $this->wsdl->endpoint = $endpoint; |
| 1097 | - $this->wsdl->namespaces['tns'] = $namespace; |
|
| 1098 | - $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 1099 | - $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/'; |
|
| 1100 | - if ($schemaTargetNamespace != $namespace) {
|
|
| 1101 | - $this->wsdl->namespaces['types'] = $schemaTargetNamespace; |
|
| 1102 | - } |
|
| 1097 | + $this->wsdl->namespaces['tns'] = $namespace; |
|
| 1098 | + $this->wsdl->namespaces['soap'] = 'http://schemas.xmlsoap.org/wsdl/soap/'; |
|
| 1099 | + $this->wsdl->namespaces['wsdl'] = 'http://schemas.xmlsoap.org/wsdl/'; |
|
| 1100 | + if ($schemaTargetNamespace != $namespace) {
|
|
| 1101 | + $this->wsdl->namespaces['types'] = $schemaTargetNamespace; |
|
| 1102 | + } |
|
| 1103 | 1103 | $this->wsdl->schemas[$schemaTargetNamespace][0] = new nusoap_xmlschema('', '', $this->wsdl->namespaces);
|
| 1104 | 1104 | if ($style == 'document') {
|
| 1105 | - $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; |
|
| 1105 | + $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaInfo['elementFormDefault'] = 'qualified'; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | $this->wsdl->schemas[$schemaTargetNamespace][0]->schemaTargetNamespace = $schemaTargetNamespace; |
| 1108 | 1108 | $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/soap/encoding/'][0] = array('location' => '', 'loaded' => true);
|
| 1109 | 1109 | $this->wsdl->schemas[$schemaTargetNamespace][0]->imports['http://schemas.xmlsoap.org/wsdl/'][0] = array('location' => '', 'loaded' => true);
|
| 1110 | 1110 | $this->wsdl->bindings[$serviceName.'Binding'] = array( |
| 1111 | - 'name'=>$serviceName.'Binding', |
|
| 1111 | + 'name'=>$serviceName.'Binding', |
|
| 1112 | 1112 | 'style'=>$style, |
| 1113 | 1113 | 'transport'=>$transport, |
| 1114 | 1114 | 'portType'=>$serviceName.'PortType'); |
| 1115 | 1115 | $this->wsdl->ports[$serviceName.'Port'] = array( |
| 1116 | - 'binding'=>$serviceName.'Binding', |
|
| 1116 | + 'binding'=>$serviceName.'Binding', |
|
| 1117 | 1117 | 'location'=>$endpoint, |
| 1118 | 1118 | 'bindingType'=>'http://schemas.xmlsoap.org/wsdl/soap/'); |
| 1119 | 1119 | } |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | * @param mixed $wsdl file path or URL (string), or wsdl instance (object) |
| 171 | 171 | * @access public |
| 172 | 172 | */ |
| 173 | - function nusoap_server($wsdl=false){
|
|
| 173 | + function nusoap_server($wsdl = false) {
|
|
| 174 | 174 | parent::nusoap_base(); |
| 175 | 175 | // turn on debugging? |
| 176 | 176 | global $debug; |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $qs = explode('&', $_SERVER['QUERY_STRING']);
|
| 194 | 194 | foreach ($qs as $v) {
|
| 195 | 195 | if (substr($v, 0, 6) == 'debug=') {
|
| 196 | - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #1");
|
|
| 196 | + $this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #1");
|
|
| 197 | 197 | $this->debug_flag = substr($v, 6); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -201,27 +201,27 @@ discard block |
||
| 201 | 201 | $qs = explode('&', $HTTP_SERVER_VARS['QUERY_STRING']);
|
| 202 | 202 | foreach ($qs as $v) {
|
| 203 | 203 | if (substr($v, 0, 6) == 'debug=') {
|
| 204 | - $this->debug("In nusoap_server, set debug_flag=" . substr($v, 6) . " based on query string #2");
|
|
| 204 | + $this->debug("In nusoap_server, set debug_flag=".substr($v, 6)." based on query string #2");
|
|
| 205 | 205 | $this->debug_flag = substr($v, 6); |
| 206 | 206 | } |
| 207 | 207 | } |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | // wsdl |
| 211 | - if($wsdl){
|
|
| 211 | + if ($wsdl) {
|
|
| 212 | 212 | $this->debug("In nusoap_server, WSDL is specified");
|
| 213 | 213 | if (is_object($wsdl) && (get_class($wsdl) == 'wsdl')) {
|
| 214 | 214 | $this->wsdl = $wsdl; |
| 215 | 215 | $this->externalWSDLURL = $this->wsdl->wsdl; |
| 216 | - $this->debug('Use existing wsdl instance from ' . $this->externalWSDLURL);
|
|
| 216 | + $this->debug('Use existing wsdl instance from '.$this->externalWSDLURL);
|
|
| 217 | 217 | } else {
|
| 218 | - $this->debug('Create wsdl from ' . $wsdl);
|
|
| 218 | + $this->debug('Create wsdl from '.$wsdl);
|
|
| 219 | 219 | $this->wsdl = new wsdl($wsdl); |
| 220 | 220 | $this->externalWSDLURL = $wsdl; |
| 221 | 221 | } |
| 222 | 222 | $this->appendDebug($this->wsdl->getDebug()); |
| 223 | 223 | $this->wsdl->clearDebug(); |
| 224 | - if($err = $this->wsdl->getError()){
|
|
| 224 | + if ($err = $this->wsdl->getError()) {
|
|
| 225 | 225 | die('WSDL ERROR: '.$err);
|
| 226 | 226 | } |
| 227 | 227 | } |
@@ -233,7 +233,7 @@ discard block |
||
| 233 | 233 | * @param string $data usually is the value of $HTTP_RAW_POST_DATA |
| 234 | 234 | * @access public |
| 235 | 235 | */ |
| 236 | - function service($data){
|
|
| 236 | + function service($data) {
|
|
| 237 | 237 | global $HTTP_SERVER_VARS; |
| 238 | 238 | |
| 239 | 239 | if (isset($_SERVER['REQUEST_METHOD'])) {
|
@@ -251,21 +251,21 @@ discard block |
||
| 251 | 251 | } else {
|
| 252 | 252 | $qs = ''; |
| 253 | 253 | } |
| 254 | - $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
|
|
| 254 | + $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=".strlen($data));
|
|
| 255 | 255 | |
| 256 | 256 | if ($rm == 'POST') {
|
| 257 | 257 | $this->debug("In service, invoke the request");
|
| 258 | 258 | $this->parse_request($data); |
| 259 | - if (! $this->fault) {
|
|
| 259 | + if (!$this->fault) {
|
|
| 260 | 260 | $this->invoke_method(); |
| 261 | 261 | } |
| 262 | - if (! $this->fault) {
|
|
| 262 | + if (!$this->fault) {
|
|
| 263 | 263 | $this->serialize_return(); |
| 264 | 264 | } |
| 265 | 265 | $this->send_response(); |
| 266 | - } elseif (preg_match('/wsdl/', $qs) ){
|
|
| 266 | + } elseif (preg_match('/wsdl/', $qs)) {
|
|
| 267 | 267 | $this->debug("In service, this is a request for WSDL");
|
| 268 | - if ($this->externalWSDLURL){
|
|
| 268 | + if ($this->externalWSDLURL) {
|
|
| 269 | 269 | if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
|
| 270 | 270 | $this->debug("In service, re-direct for WSDL");
|
| 271 | 271 | header('Location: '.$this->externalWSDLURL);
|
@@ -322,23 +322,23 @@ discard block |
||
| 322 | 322 | |
| 323 | 323 | $this->request = ''; |
| 324 | 324 | $this->SOAPAction = ''; |
| 325 | - if(function_exists('getallheaders')){
|
|
| 325 | + if (function_exists('getallheaders')) {
|
|
| 326 | 326 | $this->debug("In parse_http_headers, use getallheaders");
|
| 327 | 327 | $headers = getallheaders(); |
| 328 | - foreach($headers as $k=>$v){
|
|
| 328 | + foreach ($headers as $k=>$v) {
|
|
| 329 | 329 | $k = strtolower($k); |
| 330 | 330 | $this->headers[$k] = $v; |
| 331 | 331 | $this->request .= "$k: $v\r\n"; |
| 332 | 332 | $this->debug("$k: $v");
|
| 333 | 333 | } |
| 334 | 334 | // get SOAPAction header |
| 335 | - if(isset($this->headers['soapaction'])){
|
|
| 336 | - $this->SOAPAction = str_replace('"','',$this->headers['soapaction']);
|
|
| 335 | + if (isset($this->headers['soapaction'])) {
|
|
| 336 | + $this->SOAPAction = str_replace('"', '', $this->headers['soapaction']);
|
|
| 337 | 337 | } |
| 338 | 338 | // get the character encoding of the incoming request |
| 339 | - if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
|
|
| 340 | - $enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
|
|
| 341 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 339 | + if (isset($this->headers['content-type']) && strpos($this->headers['content-type'], '=')) {
|
|
| 340 | + $enc = str_replace('"', '', substr(strstr($this->headers["content-type"], '='), 1));
|
|
| 341 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
|
|
| 342 | 342 | $this->xml_encoding = strtoupper($enc); |
| 343 | 343 | } else {
|
| 344 | 344 | $this->xml_encoding = 'US-ASCII'; |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
| 348 | 348 | $this->xml_encoding = 'ISO-8859-1'; |
| 349 | 349 | } |
| 350 | - } elseif(isset($_SERVER) && is_array($_SERVER)){
|
|
| 350 | + } elseif (isset($_SERVER) && is_array($_SERVER)) {
|
|
| 351 | 351 | $this->debug("In parse_http_headers, use _SERVER");
|
| 352 | 352 | foreach ($_SERVER as $k => $v) {
|
| 353 | 353 | if (substr($k, 0, 5) == 'HTTP_') {
|
@@ -367,7 +367,7 @@ discard block |
||
| 367 | 367 | $enc = substr(strstr($v, '='), 1); |
| 368 | 368 | $enc = str_replace('"', '', $enc);
|
| 369 | 369 | $enc = str_replace('\\', '', $enc);
|
| 370 | - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
|
|
| 370 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
|
|
| 371 | 371 | $this->xml_encoding = strtoupper($enc); |
| 372 | 372 | } else {
|
| 373 | 373 | $this->xml_encoding = 'US-ASCII'; |
@@ -385,9 +385,9 @@ discard block |
||
| 385 | 385 | $this->debug("In parse_http_headers, use HTTP_SERVER_VARS");
|
| 386 | 386 | foreach ($HTTP_SERVER_VARS as $k => $v) {
|
| 387 | 387 | if (substr($k, 0, 5) == 'HTTP_') {
|
| 388 | - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
|
|
| 388 | + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', substr($k, 5)))); $k = strtolower(substr($k, 5));
|
|
| 389 | 389 | } else {
|
| 390 | - $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
|
|
| 390 | + $k = str_replace(' ', '-', strtolower(str_replace('_', ' ', $k))); $k = strtolower($k);
|
|
| 391 | 391 | } |
| 392 | 392 | if ($k == 'soapaction') {
|
| 393 | 393 | // get SOAPAction header |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | $enc = substr(strstr($v, '='), 1); |
| 402 | 402 | $enc = str_replace('"', '', $enc);
|
| 403 | 403 | $enc = str_replace('\\', '', $enc);
|
| 404 | - if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
|
|
| 404 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
|
|
| 405 | 405 | $this->xml_encoding = strtoupper($enc); |
| 406 | 406 | } else {
|
| 407 | 407 | $this->xml_encoding = 'US-ASCII'; |
@@ -443,13 +443,13 @@ discard block |
||
| 443 | 443 | * @param string $data XML string |
| 444 | 444 | * @access private |
| 445 | 445 | */ |
| 446 | - function parse_request($data='') {
|
|
| 446 | + function parse_request($data = '') {
|
|
| 447 | 447 | $this->debug('entering parse_request()');
|
| 448 | 448 | $this->parse_http_headers(); |
| 449 | 449 | $this->debug('got character encoding: '.$this->xml_encoding);
|
| 450 | 450 | // uncompress if necessary |
| 451 | 451 | if (isset($this->headers['content-encoding']) && $this->headers['content-encoding'] != '') {
|
| 452 | - $this->debug('got content encoding: ' . $this->headers['content-encoding']);
|
|
| 452 | + $this->debug('got content encoding: '.$this->headers['content-encoding']);
|
|
| 453 | 453 | if ($this->headers['content-encoding'] == 'deflate' || $this->headers['content-encoding'] == 'gzip') {
|
| 454 | 454 | // if decoding works, use it. else assume data wasn't gzencoded |
| 455 | 455 | if (function_exists('gzuncompress')) {
|
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | * @access private |
| 492 | 492 | */ |
| 493 | 493 | function invoke_method() {
|
| 494 | - $this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
|
|
| 494 | + $this->debug('in invoke_method, methodname='.$this->methodname.' methodURI='.$this->methodURI.' SOAPAction='.$this->SOAPAction);
|
|
| 495 | 495 | |
| 496 | 496 | // |
| 497 | 497 | // if you are debugging in this area of the code, your service uses a class to implement methods, |
@@ -506,16 +506,16 @@ discard block |
||
| 506 | 506 | $orig_methodname = $this->methodname; |
| 507 | 507 | if ($this->wsdl) {
|
| 508 | 508 | if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
|
| 509 | - $this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
|
|
| 510 | - $this->appendDebug('opData=' . $this->varDump($this->opData));
|
|
| 509 | + $this->debug('in invoke_method, found WSDL operation='.$this->methodname);
|
|
| 510 | + $this->appendDebug('opData='.$this->varDump($this->opData));
|
|
| 511 | 511 | } elseif ($this->opData = $this->wsdl->getOperationDataForSoapAction($this->SOAPAction)) {
|
| 512 | 512 | // Note: hopefully this case will only be used for doc/lit, since rpc services should have wrapper element |
| 513 | - $this->debug('in invoke_method, found WSDL soapAction=' . $this->SOAPAction . ' for operation=' . $this->opData['name']);
|
|
| 514 | - $this->appendDebug('opData=' . $this->varDump($this->opData));
|
|
| 513 | + $this->debug('in invoke_method, found WSDL soapAction='.$this->SOAPAction.' for operation='.$this->opData['name']);
|
|
| 514 | + $this->appendDebug('opData='.$this->varDump($this->opData));
|
|
| 515 | 515 | $this->methodname = $this->opData['name']; |
| 516 | 516 | } else {
|
| 517 | - $this->debug('in invoke_method, no WSDL for operation=' . $this->methodname);
|
|
| 518 | - $this->fault('SOAP-ENV:Client', "Operation '" . $this->methodname . "' is not defined in the WSDL for this service");
|
|
| 517 | + $this->debug('in invoke_method, no WSDL for operation='.$this->methodname);
|
|
| 518 | + $this->fault('SOAP-ENV:Client', "Operation '".$this->methodname."' is not defined in the WSDL for this service");
|
|
| 519 | 519 | return; |
| 520 | 520 | } |
| 521 | 521 | } else {
|
@@ -556,7 +556,7 @@ discard block |
||
| 556 | 556 | if (!function_exists($this->methodname)) {
|
| 557 | 557 | $this->debug("in invoke_method, function '$this->methodname' not found!");
|
| 558 | 558 | $this->result = 'fault: method not found'; |
| 559 | - $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
|
|
| 559 | + $this->fault('SOAP-ENV:Client', "method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
|
|
| 560 | 560 | return; |
| 561 | 561 | } |
| 562 | 562 | } else {
|
@@ -564,19 +564,19 @@ discard block |
||
| 564 | 564 | if (!in_array($method_to_compare, get_class_methods($class))) {
|
| 565 | 565 | $this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
|
| 566 | 566 | $this->result = 'fault: method not found'; |
| 567 | - $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
|
|
| 567 | + $this->fault('SOAP-ENV:Client', "method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
|
|
| 568 | 568 | return; |
| 569 | 569 | } |
| 570 | 570 | } |
| 571 | 571 | |
| 572 | 572 | // evaluate message, getting back parameters |
| 573 | 573 | // verify that request parameters match the method's signature |
| 574 | - if(! $this->verify_method($this->methodname,$this->methodparams)){
|
|
| 574 | + if (!$this->verify_method($this->methodname, $this->methodparams)) {
|
|
| 575 | 575 | // debug |
| 576 | 576 | $this->debug('ERROR: request not verified against method signature');
|
| 577 | 577 | $this->result = 'fault: request failed validation against method signature'; |
| 578 | 578 | // return fault |
| 579 | - $this->fault('SOAP-ENV:Client',"Operation '$this->methodname' not defined in service.");
|
|
| 579 | + $this->fault('SOAP-ENV:Client', "Operation '$this->methodname' not defined in service.");
|
|
| 580 | 580 | return; |
| 581 | 581 | } |
| 582 | 582 | |
@@ -616,13 +616,13 @@ discard block |
||
| 616 | 616 | } else {
|
| 617 | 617 | if ($class == '') {
|
| 618 | 618 | $this->debug('in invoke_method, calling function using call_user_func_array()');
|
| 619 | - $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() |
|
| 619 | + $call_arg = "$this->methodname"; // straight assignment changes $this->methodname to lower case after call_user_func_array() |
|
| 620 | 620 | } elseif ($delim == '..') {
|
| 621 | 621 | $this->debug('in invoke_method, calling class method using call_user_func_array()');
|
| 622 | - $call_arg = array ($class, $method); |
|
| 622 | + $call_arg = array($class, $method); |
|
| 623 | 623 | } else {
|
| 624 | 624 | $this->debug('in invoke_method, calling instance method using call_user_func_array()');
|
| 625 | - $instance = new $class (); |
|
| 625 | + $instance = new $class(); |
|
| 626 | 626 | $call_arg = array(&$instance, $method); |
| 627 | 627 | } |
| 628 | 628 | if (is_array($this->methodparams)) {
|
@@ -648,7 +648,7 @@ discard block |
||
| 648 | 648 | * @access private |
| 649 | 649 | */ |
| 650 | 650 | function serialize_return() {
|
| 651 | - $this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
|
|
| 651 | + $this->debug('Entering serialize_return methodname: '.$this->methodname.' methodURI: '.$this->methodURI);
|
|
| 652 | 652 | // if fault |
| 653 | 653 | if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
|
| 654 | 654 | $this->debug('got a fault object from method');
|
@@ -660,7 +660,7 @@ discard block |
||
| 660 | 660 | } else {
|
| 661 | 661 | $this->debug('got a(n) '.gettype($this->methodreturn).' from method');
|
| 662 | 662 | $this->debug('serializing return value');
|
| 663 | - if($this->wsdl){
|
|
| 663 | + if ($this->wsdl) {
|
|
| 664 | 664 | $opParams = ""; |
| 665 | 665 | if (sizeof($this->opData['output']['parts']) > 1) {
|
| 666 | 666 | $this->debug('more than one output part, so use the method return unchanged');
|
@@ -673,10 +673,10 @@ discard block |
||
| 673 | 673 | //} |
| 674 | 674 | $opParams = array($this->methodreturn); |
| 675 | 675 | } |
| 676 | - $return_val = $this->wsdl->serializeRPCParameters($this->methodname,'output',$opParams); |
|
| 676 | + $return_val = $this->wsdl->serializeRPCParameters($this->methodname, 'output', $opParams); |
|
| 677 | 677 | $this->appendDebug($this->wsdl->getDebug()); |
| 678 | 678 | $this->wsdl->clearDebug(); |
| 679 | - if($errstr = $this->wsdl->getError()){
|
|
| 679 | + if ($errstr = $this->wsdl->getError()) {
|
|
| 680 | 680 | $this->debug('got wsdl error: '.$errstr);
|
| 681 | 681 | $this->fault('SOAP-ENV:Server', 'unable to serialize result');
|
| 682 | 682 | return; |
@@ -695,9 +695,9 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | $this->debug('serializing response');
|
| 697 | 697 | if ($this->wsdl) {
|
| 698 | - $this->debug('have WSDL for serialization: style is ' . $this->opData['style']);
|
|
| 698 | + $this->debug('have WSDL for serialization: style is '.$this->opData['style']);
|
|
| 699 | 699 | if ($this->opData['style'] == 'rpc') {
|
| 700 | - $this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
|
|
| 700 | + $this->debug('style is rpc for serialization: use is '.$this->opData['output']['use']);
|
|
| 701 | 701 | if ($this->opData['output']['use'] == 'literal') {
|
| 702 | 702 | // 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 |
| 703 | 703 | if ($this->methodURI) {
|
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | $payload = '<ns1:'.$this->methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'</ns1:'.$this->methodname."Response>"; |
| 722 | 722 | } |
| 723 | 723 | $this->result = 'successful'; |
| 724 | - if($this->wsdl){
|
|
| 724 | + if ($this->wsdl) {
|
|
| 725 | 725 | //if($this->debug_flag){
|
| 726 | 726 | $this->appendDebug($this->wsdl->getDebug()); |
| 727 | 727 | // } |
@@ -731,9 +731,9 @@ discard block |
||
| 731 | 731 | $encodingStyle = ''; |
| 732 | 732 | } |
| 733 | 733 | // Added: In case we use a WSDL, return a serialized env. WITH the usedNamespaces. |
| 734 | - $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders,$this->wsdl->usedNamespaces,$this->opData['style'],$this->opData['output']['use'],$encodingStyle); |
|
| 734 | + $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders, $this->wsdl->usedNamespaces, $this->opData['style'], $this->opData['output']['use'], $encodingStyle); |
|
| 735 | 735 | } else {
|
| 736 | - $this->responseSOAP = $this->serializeEnvelope($payload,$this->responseHeaders); |
|
| 736 | + $this->responseSOAP = $this->serializeEnvelope($payload, $this->responseHeaders); |
|
| 737 | 737 | } |
| 738 | 738 | $this->debug("Leaving serialize_return");
|
| 739 | 739 | } |
@@ -763,18 +763,18 @@ discard block |
||
| 763 | 763 | // $this->outgoing_headers[] = "Status: 200 OK"; |
| 764 | 764 | } |
| 765 | 765 | // add debug data if in debug mode |
| 766 | - if(isset($this->debug_flag) && $this->debug_flag){
|
|
| 766 | + if (isset($this->debug_flag) && $this->debug_flag) {
|
|
| 767 | 767 | $payload .= $this->getDebugAsXMLComment(); |
| 768 | 768 | } |
| 769 | 769 | $this->outgoing_headers[] = "Server: $this->title Server v$this->version"; |
| 770 | - preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 770 | + preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 771 | 771 | $this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
|
| 772 | 772 | // Let the Web server decide about this |
| 773 | 773 | //$this->outgoing_headers[] = "Connection: Close\r\n"; |
| 774 | 774 | $payload = $this->getHTTPBody($payload); |
| 775 | 775 | $type = $this->getHTTPContentType(); |
| 776 | 776 | $charset = $this->getHTTPContentTypeCharset(); |
| 777 | - $this->outgoing_headers[] = "Content-Type: $type" . ($charset ? '; charset=' . $charset : ''); |
|
| 777 | + $this->outgoing_headers[] = "Content-Type: $type".($charset ? '; charset='.$charset : ''); |
|
| 778 | 778 | //begin code to compress payload - by John |
| 779 | 779 | // NOTE: there is no way to know whether the Web server will also compress |
| 780 | 780 | // this data. |
@@ -811,11 +811,11 @@ discard block |
||
| 811 | 811 | //end code |
| 812 | 812 | $this->outgoing_headers[] = "Content-Length: ".strlen($payload); |
| 813 | 813 | reset($this->outgoing_headers); |
| 814 | - foreach($this->outgoing_headers as $hdr){
|
|
| 814 | + foreach ($this->outgoing_headers as $hdr) {
|
|
| 815 | 815 | header($hdr, false); |
| 816 | 816 | } |
| 817 | 817 | print $payload; |
| 818 | - $this->response = join("\r\n",$this->outgoing_headers)."\r\n\r\n".$payload;
|
|
| 818 | + $this->response = join("\r\n", $this->outgoing_headers)."\r\n\r\n".$payload;
|
|
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | /** |
@@ -827,12 +827,12 @@ discard block |
||
| 827 | 827 | * @return boolean Whether the operation was found |
| 828 | 828 | * @access private |
| 829 | 829 | */ |
| 830 | - function verify_method($operation,$request){
|
|
| 831 | - if(isset($this->wsdl) && is_object($this->wsdl)){
|
|
| 832 | - if($this->wsdl->getOperationData($operation)){
|
|
| 830 | + function verify_method($operation, $request) {
|
|
| 831 | + if (isset($this->wsdl) && is_object($this->wsdl)) {
|
|
| 832 | + if ($this->wsdl->getOperationData($operation)) {
|
|
| 833 | 833 | return true; |
| 834 | 834 | } |
| 835 | - } elseif(isset($this->operations[$operation])){
|
|
| 835 | + } elseif (isset($this->operations[$operation])) {
|
|
| 836 | 836 | return true; |
| 837 | 837 | } |
| 838 | 838 | return false; |
@@ -847,7 +847,7 @@ discard block |
||
| 847 | 847 | * @access private |
| 848 | 848 | */ |
| 849 | 849 | function parseRequest($headers, $data) {
|
| 850 | - $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
|
|
| 850 | + $this->debug('Entering parseRequest() for data of length '.strlen($data).' headers:');
|
|
| 851 | 851 | $this->appendDebug($this->varDump($headers)); |
| 852 | 852 | if (!isset($headers['content-type'])) {
|
| 853 | 853 | $this->setError('Request not of type text/xml (no content-type header)');
|
@@ -859,8 +859,8 @@ discard block |
||
| 859 | 859 | } |
| 860 | 860 | if (strpos($headers['content-type'], '=')) {
|
| 861 | 861 | $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
| 862 | - $this->debug('Got response encoding: ' . $enc);
|
|
| 863 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 862 | + $this->debug('Got response encoding: '.$enc);
|
|
| 863 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
|
|
| 864 | 864 | $this->xml_encoding = strtoupper($enc); |
| 865 | 865 | } else {
|
| 866 | 866 | $this->xml_encoding = 'US-ASCII'; |
@@ -869,16 +869,16 @@ discard block |
||
| 869 | 869 | // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
| 870 | 870 | $this->xml_encoding = 'ISO-8859-1'; |
| 871 | 871 | } |
| 872 | - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 872 | + $this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
|
|
| 873 | 873 | // parse response, get soap parser obj |
| 874 | - $parser = new nusoap_parser($data,$this->xml_encoding,'',$this->decode_utf8); |
|
| 874 | + $parser = new nusoap_parser($data, $this->xml_encoding, '', $this->decode_utf8); |
|
| 875 | 875 | |
| 876 | 876 | // parser debug |
| 877 | 877 | $this->debug("parser debug: \n".$parser->getDebug());
|
| 878 | 878 | // if fault occurred during message parsing |
| 879 | - if($err = $parser->getError()){
|
|
| 879 | + if ($err = $parser->getError()) {
|
|
| 880 | 880 | $this->result = 'fault: error in msg parsing: '.$err; |
| 881 | - $this->fault('SOAP-ENV:Client',"error in msg parsing:\n".$err);
|
|
| 881 | + $this->fault('SOAP-ENV:Client', "error in msg parsing:\n".$err);
|
|
| 882 | 882 | // else successfully parsed request into soapval object |
| 883 | 883 | } else {
|
| 884 | 884 | // get/set methodname |
@@ -941,8 +941,8 @@ discard block |
||
| 941 | 941 | * @access public |
| 942 | 942 | * @deprecated |
| 943 | 943 | */ |
| 944 | - function add_to_map($methodname,$in,$out){
|
|
| 945 | - $this->operations[$methodname] = array('name' => $methodname,'in' => $in,'out' => $out);
|
|
| 944 | + function add_to_map($methodname, $in, $out) {
|
|
| 945 | + $this->operations[$methodname] = array('name' => $methodname, 'in' => $in, 'out' => $out);
|
|
| 946 | 946 | } |
| 947 | 947 | |
| 948 | 948 | /** |
@@ -959,13 +959,13 @@ discard block |
||
| 959 | 959 | * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
| 960 | 960 | * @access public |
| 961 | 961 | */ |
| 962 | - function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=false,$style=false,$use=false,$documentation='',$encodingStyle=''){
|
|
| 962 | + function register($name, $in = array(), $out = array(), $namespace = false, $soapaction = false, $style = false, $use = false, $documentation = '', $encodingStyle = '') {
|
|
| 963 | 963 | global $HTTP_SERVER_VARS; |
| 964 | 964 | |
| 965 | - if($this->externalWSDLURL){
|
|
| 965 | + if ($this->externalWSDLURL) {
|
|
| 966 | 966 | die('You cannot bind to an external WSDL file, and register methods outside of it! Please choose either WSDL or no WSDL.');
|
| 967 | 967 | } |
| 968 | - if (! $name) {
|
|
| 968 | + if (!$name) {
|
|
| 969 | 969 | die('You must specify a name when you register an operation');
|
| 970 | 970 | } |
| 971 | 971 | if (!is_array($in)) {
|
@@ -974,9 +974,9 @@ discard block |
||
| 974 | 974 | if (!is_array($out)) {
|
| 975 | 975 | die('You must provide an array for operation outputs');
|
| 976 | 976 | } |
| 977 | - if(false == $namespace) {
|
|
| 977 | + if (false == $namespace) {
|
|
| 978 | 978 | } |
| 979 | - if(false == $soapaction) {
|
|
| 979 | + if (false == $soapaction) {
|
|
| 980 | 980 | if (isset($_SERVER)) {
|
| 981 | 981 | $SERVER_NAME = $_SERVER['SERVER_NAME']; |
| 982 | 982 | $SCRIPT_NAME = isset($_SERVER['PHP_SELF']) ? $_SERVER['PHP_SELF'] : $_SERVER['SCRIPT_NAME']; |
@@ -995,10 +995,10 @@ discard block |
||
| 995 | 995 | } |
| 996 | 996 | $soapaction = "$SCHEME://$SERVER_NAME$SCRIPT_NAME/$name"; |
| 997 | 997 | } |
| 998 | - if(false == $style) {
|
|
| 998 | + if (false == $style) {
|
|
| 999 | 999 | $style = "rpc"; |
| 1000 | 1000 | } |
| 1001 | - if(false == $use) {
|
|
| 1001 | + if (false == $use) {
|
|
| 1002 | 1002 | $use = "encoded"; |
| 1003 | 1003 | } |
| 1004 | 1004 | if ($use == 'encoded' && $encodingStyle == '') {
|
@@ -1012,8 +1012,8 @@ discard block |
||
| 1012 | 1012 | 'namespace' => $namespace, |
| 1013 | 1013 | 'soapaction' => $soapaction, |
| 1014 | 1014 | 'style' => $style); |
| 1015 | - if($this->wsdl){
|
|
| 1016 | - $this->wsdl->addOperation($name,$in,$out,$namespace,$soapaction,$style,$use,$documentation,$encodingStyle); |
|
| 1015 | + if ($this->wsdl) {
|
|
| 1016 | + $this->wsdl->addOperation($name, $in, $out, $namespace, $soapaction, $style, $use, $documentation, $encodingStyle); |
|
| 1017 | 1017 | } |
| 1018 | 1018 | return true; |
| 1019 | 1019 | } |
@@ -1028,11 +1028,11 @@ discard block |
||
| 1028 | 1028 | * @param string $faultdetail |
| 1029 | 1029 | * @access public |
| 1030 | 1030 | */ |
| 1031 | - function fault($faultcode,$faultstring,$faultactor='',$faultdetail=''){
|
|
| 1031 | + function fault($faultcode, $faultstring, $faultactor = '', $faultdetail = '') {
|
|
| 1032 | 1032 | if ($faultdetail == '' && $this->debug_flag) {
|
| 1033 | 1033 | $faultdetail = $this->getDebug(); |
| 1034 | 1034 | } |
| 1035 | - $this->fault = new nusoap_fault($faultcode,$faultactor,$faultstring,$faultdetail); |
|
| 1035 | + $this->fault = new nusoap_fault($faultcode, $faultactor, $faultstring, $faultdetail); |
|
| 1036 | 1036 | $this->fault->soap_defencoding = $this->soap_defencoding; |
| 1037 | 1037 | } |
| 1038 | 1038 | |
@@ -1047,7 +1047,7 @@ discard block |
||
| 1047 | 1047 | * @param string $transport optional SOAP transport |
| 1048 | 1048 | * @param mixed $schemaTargetNamespace optional 'types' targetNamespace for service schema or false |
| 1049 | 1049 | */ |
| 1050 | - function configureWSDL($serviceName,$namespace = false,$endpoint = false,$style='rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) |
|
| 1050 | + function configureWSDL($serviceName, $namespace = false, $endpoint = false, $style = 'rpc', $transport = 'http://schemas.xmlsoap.org/soap/http', $schemaTargetNamespace = false) |
|
| 1051 | 1051 | {
|
| 1052 | 1052 | global $HTTP_SERVER_VARS; |
| 1053 | 1053 | |
@@ -1065,20 +1065,20 @@ discard block |
||
| 1065 | 1065 | $this->setError("Neither _SERVER nor HTTP_SERVER_VARS is available");
|
| 1066 | 1066 | } |
| 1067 | 1067 | // If server name has port number attached then strip it (else port number gets duplicated in WSDL output) (occurred using lighttpd and FastCGI) |
| 1068 | - $colon = strpos($SERVER_NAME,":"); |
|
| 1068 | + $colon = strpos($SERVER_NAME, ":"); |
|
| 1069 | 1069 | if ($colon) {
|
| 1070 | 1070 | $SERVER_NAME = substr($SERVER_NAME, 0, $colon); |
| 1071 | 1071 | } |
| 1072 | 1072 | if ($SERVER_PORT == 80) {
|
| 1073 | 1073 | $SERVER_PORT = ''; |
| 1074 | 1074 | } else {
|
| 1075 | - $SERVER_PORT = ':' . $SERVER_PORT; |
|
| 1075 | + $SERVER_PORT = ':'.$SERVER_PORT; |
|
| 1076 | 1076 | } |
| 1077 | - if(false == $namespace) {
|
|
| 1077 | + if (false == $namespace) {
|
|
| 1078 | 1078 | $namespace = "http://$SERVER_NAME/soap/$serviceName"; |
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | - if(false == $endpoint) {
|
|
| 1081 | + if (false == $endpoint) {
|
|
| 1082 | 1082 | if ($HTTPS == '1' || $HTTPS == 'on') {
|
| 1083 | 1083 | $SCHEME = 'https'; |
| 1084 | 1084 | } else {
|
@@ -1087,7 +1087,7 @@ discard block |
||
| 1087 | 1087 | $endpoint = "$SCHEME://$SERVER_NAME$SERVER_PORT$SCRIPT_NAME"; |
| 1088 | 1088 | } |
| 1089 | 1089 | |
| 1090 | - if(false == $schemaTargetNamespace) {
|
|
| 1090 | + if (false == $schemaTargetNamespace) {
|
|
| 1091 | 1091 | $schemaTargetNamespace = $namespace; |
| 1092 | 1092 | } |
| 1093 | 1093 | |
@@ -169,10 +169,6 @@ discard block |
||
| 169 | 169 | /** |
| 170 | 170 | * establish an HTTP connection |
| 171 | 171 | * |
| 172 | - * @param integer $timeout set connection timeout in seconds |
|
| 173 | - * @param integer $response_timeout set response timeout in seconds |
|
| 174 | - * @return boolean true if connected, false if not |
|
| 175 | - * @access private |
|
| 176 | 172 | */ |
| 177 | 173 | function connect($connection_timeout=0,$response_timeout=30){
|
| 178 | 174 | // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like |
@@ -731,7 +727,7 @@ discard block |
||
| 731 | 727 | * |
| 732 | 728 | * @param string $data message data |
| 733 | 729 | * @param array $cookies cookies to send |
| 734 | - * @return boolean true if OK, false if problem |
|
| 730 | + * @return boolean|null true if OK, false if problem |
|
| 735 | 731 | * @access private |
| 736 | 732 | */ |
| 737 | 733 | function sendRequest($data, $cookies = NULL) {
|
@@ -1166,7 +1162,7 @@ discard block |
||
| 1166 | 1162 | * sets the content-type for the SOAP message to be sent |
| 1167 | 1163 | * |
| 1168 | 1164 | * @param string $type the content type, MIME style |
| 1169 | - * @param mixed $charset character set used for encoding (or false) |
|
| 1165 | + * @param string $charset character set used for encoding (or false) |
|
| 1170 | 1166 | * @access public |
| 1171 | 1167 | */ |
| 1172 | 1168 | function setContentType($type, $charset = false) {
|
@@ -1199,6 +1195,10 @@ discard block |
||
| 1199 | 1195 | /* |
| 1200 | 1196 | * TODO: allow a Set-Cookie string to be parsed into multiple cookies |
| 1201 | 1197 | */ |
| 1198 | + |
|
| 1199 | + /** |
|
| 1200 | + * @param string $cookie_str |
|
| 1201 | + */ |
|
| 1202 | 1202 | function parseCookie($cookie_str) {
|
| 1203 | 1203 | $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
|
| 1204 | 1204 | $data = preg_split('/;/', $cookie_str);
|
@@ -14,171 +14,171 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class soap_transport_http extends nusoap_base {
|
| 16 | 16 | |
| 17 | - var $url = ''; |
|
| 18 | - var $uri = ''; |
|
| 19 | - var $digest_uri = ''; |
|
| 20 | - var $scheme = ''; |
|
| 21 | - var $host = ''; |
|
| 22 | - var $port = ''; |
|
| 23 | - var $path = ''; |
|
| 24 | - var $request_method = 'POST'; |
|
| 25 | - var $protocol_version = '1.0'; |
|
| 26 | - var $encoding = ''; |
|
| 27 | - var $outgoing_headers = array(); |
|
| 28 | - var $incoming_headers = array(); |
|
| 29 | - var $incoming_cookies = array(); |
|
| 30 | - var $outgoing_payload = ''; |
|
| 31 | - var $incoming_payload = ''; |
|
| 32 | - var $response_status_line; // HTTP response status line |
|
| 33 | - var $useSOAPAction = true; |
|
| 34 | - var $persistentConnection = false; |
|
| 35 | - var $ch = false; // cURL handle |
|
| 36 | - var $ch_options = array(); // cURL custom options |
|
| 37 | - var $use_curl = false; // force cURL use |
|
| 38 | - var $proxy = null; // proxy information (associative array) |
|
| 39 | - var $username = ''; |
|
| 40 | - var $password = ''; |
|
| 41 | - var $authtype = ''; |
|
| 42 | - var $digestRequest = array(); |
|
| 43 | - var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) |
|
| 44 | - // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' |
|
| 45 | - // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' |
|
| 46 | - // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' |
|
| 47 | - // passphrase: SSL key password/passphrase |
|
| 48 | - // certpassword: SSL certificate password |
|
| 49 | - // verifypeer: default is 1 |
|
| 50 | - // verifyhost: default is 1 |
|
| 17 | + var $url = ''; |
|
| 18 | + var $uri = ''; |
|
| 19 | + var $digest_uri = ''; |
|
| 20 | + var $scheme = ''; |
|
| 21 | + var $host = ''; |
|
| 22 | + var $port = ''; |
|
| 23 | + var $path = ''; |
|
| 24 | + var $request_method = 'POST'; |
|
| 25 | + var $protocol_version = '1.0'; |
|
| 26 | + var $encoding = ''; |
|
| 27 | + var $outgoing_headers = array(); |
|
| 28 | + var $incoming_headers = array(); |
|
| 29 | + var $incoming_cookies = array(); |
|
| 30 | + var $outgoing_payload = ''; |
|
| 31 | + var $incoming_payload = ''; |
|
| 32 | + var $response_status_line; // HTTP response status line |
|
| 33 | + var $useSOAPAction = true; |
|
| 34 | + var $persistentConnection = false; |
|
| 35 | + var $ch = false; // cURL handle |
|
| 36 | + var $ch_options = array(); // cURL custom options |
|
| 37 | + var $use_curl = false; // force cURL use |
|
| 38 | + var $proxy = null; // proxy information (associative array) |
|
| 39 | + var $username = ''; |
|
| 40 | + var $password = ''; |
|
| 41 | + var $authtype = ''; |
|
| 42 | + var $digestRequest = array(); |
|
| 43 | + var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) |
|
| 44 | + // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' |
|
| 45 | + // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' |
|
| 46 | + // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' |
|
| 47 | + // passphrase: SSL key password/passphrase |
|
| 48 | + // certpassword: SSL certificate password |
|
| 49 | + // verifypeer: default is 1 |
|
| 50 | + // verifyhost: default is 1 |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * constructor |
|
| 54 | - * |
|
| 55 | - * @param string $url The URL to which to connect |
|
| 56 | - * @param array $curl_options User-specified cURL options |
|
| 57 | - * @param boolean $use_curl Whether to try to force cURL use |
|
| 58 | - * @access public |
|
| 59 | - */ |
|
| 60 | - function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
|
|
| 61 | - parent::nusoap_base(); |
|
| 62 | - $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
|
|
| 63 | - $this->appendDebug($this->varDump($curl_options)); |
|
| 64 | - $this->setURL($url); |
|
| 65 | - if (is_array($curl_options)) {
|
|
| 66 | - $this->ch_options = $curl_options; |
|
| 67 | - } |
|
| 68 | - $this->use_curl = $use_curl; |
|
| 69 | - preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 70 | - $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
|
|
| 71 | - } |
|
| 52 | + /** |
|
| 53 | + * constructor |
|
| 54 | + * |
|
| 55 | + * @param string $url The URL to which to connect |
|
| 56 | + * @param array $curl_options User-specified cURL options |
|
| 57 | + * @param boolean $use_curl Whether to try to force cURL use |
|
| 58 | + * @access public |
|
| 59 | + */ |
|
| 60 | + function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
|
|
| 61 | + parent::nusoap_base(); |
|
| 62 | + $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
|
|
| 63 | + $this->appendDebug($this->varDump($curl_options)); |
|
| 64 | + $this->setURL($url); |
|
| 65 | + if (is_array($curl_options)) {
|
|
| 66 | + $this->ch_options = $curl_options; |
|
| 67 | + } |
|
| 68 | + $this->use_curl = $use_curl; |
|
| 69 | + preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 70 | + $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
|
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * sets a cURL option |
|
| 75 | - * |
|
| 76 | - * @param mixed $option The cURL option (always integer?) |
|
| 77 | - * @param mixed $value The cURL option value |
|
| 78 | - * @access private |
|
| 79 | - */ |
|
| 80 | - function setCurlOption($option, $value) {
|
|
| 81 | - $this->debug("setCurlOption option=$option, value=");
|
|
| 82 | - $this->appendDebug($this->varDump($value)); |
|
| 83 | - curl_setopt($this->ch, $option, $value); |
|
| 84 | - } |
|
| 73 | + /** |
|
| 74 | + * sets a cURL option |
|
| 75 | + * |
|
| 76 | + * @param mixed $option The cURL option (always integer?) |
|
| 77 | + * @param mixed $value The cURL option value |
|
| 78 | + * @access private |
|
| 79 | + */ |
|
| 80 | + function setCurlOption($option, $value) {
|
|
| 81 | + $this->debug("setCurlOption option=$option, value=");
|
|
| 82 | + $this->appendDebug($this->varDump($value)); |
|
| 83 | + curl_setopt($this->ch, $option, $value); |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - /** |
|
| 87 | - * sets an HTTP header |
|
| 88 | - * |
|
| 89 | - * @param string $name The name of the header |
|
| 90 | - * @param string $value The value of the header |
|
| 91 | - * @access private |
|
| 92 | - */ |
|
| 93 | - function setHeader($name, $value) {
|
|
| 94 | - $this->outgoing_headers[$name] = $value; |
|
| 95 | - $this->debug("set header $name: $value");
|
|
| 96 | - } |
|
| 86 | + /** |
|
| 87 | + * sets an HTTP header |
|
| 88 | + * |
|
| 89 | + * @param string $name The name of the header |
|
| 90 | + * @param string $value The value of the header |
|
| 91 | + * @access private |
|
| 92 | + */ |
|
| 93 | + function setHeader($name, $value) {
|
|
| 94 | + $this->outgoing_headers[$name] = $value; |
|
| 95 | + $this->debug("set header $name: $value");
|
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * unsets an HTTP header |
|
| 100 | - * |
|
| 101 | - * @param string $name The name of the header |
|
| 102 | - * @access private |
|
| 103 | - */ |
|
| 104 | - function unsetHeader($name) {
|
|
| 105 | - if (isset($this->outgoing_headers[$name])) {
|
|
| 106 | - $this->debug("unset header $name");
|
|
| 107 | - unset($this->outgoing_headers[$name]); |
|
| 108 | - } |
|
| 109 | - } |
|
| 98 | + /** |
|
| 99 | + * unsets an HTTP header |
|
| 100 | + * |
|
| 101 | + * @param string $name The name of the header |
|
| 102 | + * @access private |
|
| 103 | + */ |
|
| 104 | + function unsetHeader($name) {
|
|
| 105 | + if (isset($this->outgoing_headers[$name])) {
|
|
| 106 | + $this->debug("unset header $name");
|
|
| 107 | + unset($this->outgoing_headers[$name]); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - /** |
|
| 112 | - * sets the URL to which to connect |
|
| 113 | - * |
|
| 114 | - * @param string $url The URL to which to connect |
|
| 115 | - * @access private |
|
| 116 | - */ |
|
| 117 | - function setURL($url) {
|
|
| 118 | - $this->url = $url; |
|
| 111 | + /** |
|
| 112 | + * sets the URL to which to connect |
|
| 113 | + * |
|
| 114 | + * @param string $url The URL to which to connect |
|
| 115 | + * @access private |
|
| 116 | + */ |
|
| 117 | + function setURL($url) {
|
|
| 118 | + $this->url = $url; |
|
| 119 | 119 | |
| 120 | - $u = parse_url($url); |
|
| 121 | - foreach($u as $k => $v){
|
|
| 122 | - $this->debug("parsed URL $k = $v");
|
|
| 123 | - $this->$k = $v; |
|
| 124 | - } |
|
| 120 | + $u = parse_url($url); |
|
| 121 | + foreach($u as $k => $v){
|
|
| 122 | + $this->debug("parsed URL $k = $v");
|
|
| 123 | + $this->$k = $v; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - // add any GET params to path |
|
| 127 | - if(isset($u['query']) && $u['query'] != ''){
|
|
| 126 | + // add any GET params to path |
|
| 127 | + if(isset($u['query']) && $u['query'] != ''){
|
|
| 128 | 128 | $this->path .= '?' . $u['query']; |
| 129 | - } |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | - // set default port |
|
| 132 | - if(!isset($u['port'])){
|
|
| 133 | - if($u['scheme'] == 'https'){
|
|
| 134 | - $this->port = 443; |
|
| 135 | - } else {
|
|
| 136 | - $this->port = 80; |
|
| 137 | - } |
|
| 138 | - } |
|
| 131 | + // set default port |
|
| 132 | + if(!isset($u['port'])){
|
|
| 133 | + if($u['scheme'] == 'https'){
|
|
| 134 | + $this->port = 443; |
|
| 135 | + } else {
|
|
| 136 | + $this->port = 80; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - $this->uri = $this->path; |
|
| 141 | - $this->digest_uri = $this->uri; |
|
| 140 | + $this->uri = $this->path; |
|
| 141 | + $this->digest_uri = $this->uri; |
|
| 142 | 142 | |
| 143 | - // build headers |
|
| 144 | - if (!isset($u['port'])) {
|
|
| 145 | - $this->setHeader('Host', $this->host);
|
|
| 146 | - } else {
|
|
| 147 | - $this->setHeader('Host', $this->host.':'.$this->port);
|
|
| 148 | - } |
|
| 143 | + // build headers |
|
| 144 | + if (!isset($u['port'])) {
|
|
| 145 | + $this->setHeader('Host', $this->host);
|
|
| 146 | + } else {
|
|
| 147 | + $this->setHeader('Host', $this->host.':'.$this->port);
|
|
| 148 | + } |
|
| 149 | 149 | |
| 150 | - if (isset($u['user']) && $u['user'] != '') {
|
|
| 151 | - $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : ''); |
|
| 152 | - } |
|
| 153 | - } |
|
| 150 | + if (isset($u['user']) && $u['user'] != '') {
|
|
| 151 | + $this->setCredentials(urldecode($u['user']), isset($u['pass']) ? urldecode($u['pass']) : ''); |
|
| 152 | + } |
|
| 153 | + } |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * gets the I/O method to use |
|
| 157 | - * |
|
| 158 | - * @return string I/O method to use (socket|curl|unknown) |
|
| 159 | - * @access private |
|
| 160 | - */ |
|
| 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'; |
|
| 166 | - return 'unknown'; |
|
| 167 | - } |
|
| 155 | + /** |
|
| 156 | + * gets the I/O method to use |
|
| 157 | + * |
|
| 158 | + * @return string I/O method to use (socket|curl|unknown) |
|
| 159 | + * @access private |
|
| 160 | + */ |
|
| 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'; |
|
| 166 | + return 'unknown'; |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * establish an HTTP connection |
|
| 171 | - * |
|
| 172 | - * @param integer $timeout set connection timeout in seconds |
|
| 173 | - * @param integer $response_timeout set response timeout in seconds |
|
| 174 | - * @return boolean true if connected, false if not |
|
| 175 | - * @access private |
|
| 176 | - */ |
|
| 177 | - function connect($connection_timeout=0,$response_timeout=30){
|
|
| 178 | - // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like |
|
| 179 | - // "regular" socket. |
|
| 180 | - // TODO: disabled for now because OpenSSL must be *compiled* in (not just |
|
| 181 | - // loaded), and until PHP5 stream_get_wrappers is not available. |
|
| 169 | + /** |
|
| 170 | + * establish an HTTP connection |
|
| 171 | + * |
|
| 172 | + * @param integer $timeout set connection timeout in seconds |
|
| 173 | + * @param integer $response_timeout set response timeout in seconds |
|
| 174 | + * @return boolean true if connected, false if not |
|
| 175 | + * @access private |
|
| 176 | + */ |
|
| 177 | + function connect($connection_timeout=0,$response_timeout=30){
|
|
| 178 | + // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like |
|
| 179 | + // "regular" socket. |
|
| 180 | + // TODO: disabled for now because OpenSSL must be *compiled* in (not just |
|
| 181 | + // loaded), and until PHP5 stream_get_wrappers is not available. |
|
| 182 | 182 | // if ($this->scheme == 'https') {
|
| 183 | 183 | // if (version_compare(phpversion(), '4.3.0') >= 0) {
|
| 184 | 184 | // if (extension_loaded('openssl')) {
|
@@ -187,1120 +187,1120 @@ discard block |
||
| 187 | 187 | // } |
| 188 | 188 | // } |
| 189 | 189 | // } |
| 190 | - $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
|
|
| 191 | - if ($this->io_method() == 'socket') {
|
|
| 192 | - if (!is_array($this->proxy)) {
|
|
| 193 | - $host = $this->host; |
|
| 194 | - $port = $this->port; |
|
| 195 | - } else {
|
|
| 196 | - $host = $this->proxy['host']; |
|
| 197 | - $port = $this->proxy['port']; |
|
| 198 | - } |
|
| 190 | + $this->debug("connect connection_timeout $connection_timeout, response_timeout $response_timeout, scheme $this->scheme, host $this->host, port $this->port");
|
|
| 191 | + if ($this->io_method() == 'socket') {
|
|
| 192 | + if (!is_array($this->proxy)) {
|
|
| 193 | + $host = $this->host; |
|
| 194 | + $port = $this->port; |
|
| 195 | + } else {
|
|
| 196 | + $host = $this->proxy['host']; |
|
| 197 | + $port = $this->proxy['port']; |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - // use persistent connection |
|
| 201 | - if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
|
|
| 202 | - if (!feof($this->fp)) {
|
|
| 203 | - $this->debug('Re-use persistent connection');
|
|
| 204 | - return true; |
|
| 205 | - } |
|
| 206 | - fclose($this->fp); |
|
| 207 | - $this->debug('Closed persistent connection at EOF');
|
|
| 208 | - } |
|
| 200 | + // use persistent connection |
|
| 201 | + if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
|
|
| 202 | + if (!feof($this->fp)) {
|
|
| 203 | + $this->debug('Re-use persistent connection');
|
|
| 204 | + return true; |
|
| 205 | + } |
|
| 206 | + fclose($this->fp); |
|
| 207 | + $this->debug('Closed persistent connection at EOF');
|
|
| 208 | + } |
|
| 209 | 209 | |
| 210 | - // munge host if using OpenSSL |
|
| 211 | - if ($this->scheme == 'ssl') {
|
|
| 212 | - $host = 'ssl://' . $host; |
|
| 213 | - } |
|
| 214 | - $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
|
|
| 210 | + // munge host if using OpenSSL |
|
| 211 | + if ($this->scheme == 'ssl') {
|
|
| 212 | + $host = 'ssl://' . $host; |
|
| 213 | + } |
|
| 214 | + $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
|
|
| 215 | 215 | |
| 216 | - // open socket |
|
| 217 | - if($connection_timeout > 0){
|
|
| 218 | - $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout); |
|
| 219 | - } else {
|
|
| 220 | - $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str); |
|
| 221 | - } |
|
| 216 | + // open socket |
|
| 217 | + if($connection_timeout > 0){
|
|
| 218 | + $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout); |
|
| 219 | + } else {
|
|
| 220 | + $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str); |
|
| 221 | + } |
|
| 222 | 222 | |
| 223 | - // test pointer |
|
| 224 | - if(!$this->fp) {
|
|
| 225 | - $msg = 'Couldn\'t open socket connection to server ' . $this->url; |
|
| 226 | - if ($this->errno) {
|
|
| 227 | - $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
|
|
| 228 | - } else {
|
|
| 229 | - $msg .= ' prior to connect(). This is often a problem looking up the host name.'; |
|
| 230 | - } |
|
| 231 | - $this->debug($msg); |
|
| 232 | - $this->setError($msg); |
|
| 233 | - return false; |
|
| 234 | - } |
|
| 223 | + // test pointer |
|
| 224 | + if(!$this->fp) {
|
|
| 225 | + $msg = 'Couldn\'t open socket connection to server ' . $this->url; |
|
| 226 | + if ($this->errno) {
|
|
| 227 | + $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
|
|
| 228 | + } else {
|
|
| 229 | + $msg .= ' prior to connect(). This is often a problem looking up the host name.'; |
|
| 230 | + } |
|
| 231 | + $this->debug($msg); |
|
| 232 | + $this->setError($msg); |
|
| 233 | + return false; |
|
| 234 | + } |
|
| 235 | 235 | |
| 236 | - // set response timeout |
|
| 237 | - $this->debug('set response timeout to ' . $response_timeout);
|
|
| 238 | - socket_set_timeout( $this->fp, $response_timeout); |
|
| 236 | + // set response timeout |
|
| 237 | + $this->debug('set response timeout to ' . $response_timeout);
|
|
| 238 | + socket_set_timeout( $this->fp, $response_timeout); |
|
| 239 | 239 | |
| 240 | - $this->debug('socket connected');
|
|
| 241 | - return true; |
|
| 242 | - } else if ($this->io_method() == 'curl') {
|
|
| 243 | - if (!extension_loaded('curl')) {
|
|
| 240 | + $this->debug('socket connected');
|
|
| 241 | + return true; |
|
| 242 | + } else if ($this->io_method() == 'curl') {
|
|
| 243 | + if (!extension_loaded('curl')) {
|
|
| 244 | 244 | // $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
|
| 245 | - $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.');
|
|
| 246 | - return false; |
|
| 247 | - } |
|
| 248 | - // 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; |
|
| 245 | + $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.');
|
|
| 246 | + return false; |
|
| 247 | + } |
|
| 248 | + // 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; |
|
| 273 | 273 | |
| 274 | - $this->debug('connect using cURL');
|
|
| 275 | - // init CURL |
|
| 276 | - $this->ch = curl_init(); |
|
| 277 | - // set url |
|
| 278 | - $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; |
|
| 279 | - // add path |
|
| 280 | - $hostURL .= $this->path; |
|
| 281 | - $this->setCurlOption(CURLOPT_URL, $hostURL); |
|
| 282 | - // follow location headers (re-directs) |
|
| 283 | - if (ini_get('safe_mode') || ini_get('open_basedir')) {
|
|
| 284 | - $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
|
|
| 285 | - $this->debug('safe_mode = ');
|
|
| 286 | - $this->appendDebug($this->varDump(ini_get('safe_mode')));
|
|
| 287 | - $this->debug('open_basedir = ');
|
|
| 288 | - $this->appendDebug($this->varDump(ini_get('open_basedir')));
|
|
| 289 | - } else {
|
|
| 290 | - $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1); |
|
| 291 | - } |
|
| 292 | - // ask for headers in the response output |
|
| 293 | - $this->setCurlOption(CURLOPT_HEADER, 1); |
|
| 294 | - // ask for the response output as the return value |
|
| 295 | - $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1); |
|
| 296 | - // encode |
|
| 297 | - // We manage this ourselves through headers and encoding |
|
| 274 | + $this->debug('connect using cURL');
|
|
| 275 | + // init CURL |
|
| 276 | + $this->ch = curl_init(); |
|
| 277 | + // set url |
|
| 278 | + $hostURL = ($this->port != '') ? "$this->scheme://$this->host:$this->port" : "$this->scheme://$this->host"; |
|
| 279 | + // add path |
|
| 280 | + $hostURL .= $this->path; |
|
| 281 | + $this->setCurlOption(CURLOPT_URL, $hostURL); |
|
| 282 | + // follow location headers (re-directs) |
|
| 283 | + if (ini_get('safe_mode') || ini_get('open_basedir')) {
|
|
| 284 | + $this->debug('safe_mode or open_basedir set, so do not set CURLOPT_FOLLOWLOCATION');
|
|
| 285 | + $this->debug('safe_mode = ');
|
|
| 286 | + $this->appendDebug($this->varDump(ini_get('safe_mode')));
|
|
| 287 | + $this->debug('open_basedir = ');
|
|
| 288 | + $this->appendDebug($this->varDump(ini_get('open_basedir')));
|
|
| 289 | + } else {
|
|
| 290 | + $this->setCurlOption(CURLOPT_FOLLOWLOCATION, 1); |
|
| 291 | + } |
|
| 292 | + // ask for headers in the response output |
|
| 293 | + $this->setCurlOption(CURLOPT_HEADER, 1); |
|
| 294 | + // ask for the response output as the return value |
|
| 295 | + $this->setCurlOption(CURLOPT_RETURNTRANSFER, 1); |
|
| 296 | + // encode |
|
| 297 | + // We manage this ourselves through headers and encoding |
|
| 298 | 298 | // if(function_exists('gzuncompress')){
|
| 299 | 299 | // $this->setCurlOption(CURLOPT_ENCODING, 'deflate'); |
| 300 | 300 | // } |
| 301 | - // persistent connection |
|
| 302 | - if ($this->persistentConnection) {
|
|
| 303 | - // I believe the following comment is now bogus, having applied to |
|
| 304 | - // the code when it used CURLOPT_CUSTOMREQUEST to send the request. |
|
| 305 | - // The way we send data, we cannot use persistent connections, since |
|
| 306 | - // there will be some "junk" at the end of our request. |
|
| 307 | - //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true); |
|
| 308 | - $this->persistentConnection = false; |
|
| 309 | - $this->setHeader('Connection', 'close');
|
|
| 310 | - } |
|
| 311 | - // set timeouts |
|
| 312 | - if ($connection_timeout != 0) {
|
|
| 313 | - $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout); |
|
| 314 | - } |
|
| 315 | - if ($response_timeout != 0) {
|
|
| 316 | - $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout); |
|
| 317 | - } |
|
| 301 | + // persistent connection |
|
| 302 | + if ($this->persistentConnection) {
|
|
| 303 | + // I believe the following comment is now bogus, having applied to |
|
| 304 | + // the code when it used CURLOPT_CUSTOMREQUEST to send the request. |
|
| 305 | + // The way we send data, we cannot use persistent connections, since |
|
| 306 | + // there will be some "junk" at the end of our request. |
|
| 307 | + //$this->setCurlOption(CURL_HTTP_VERSION_1_1, true); |
|
| 308 | + $this->persistentConnection = false; |
|
| 309 | + $this->setHeader('Connection', 'close');
|
|
| 310 | + } |
|
| 311 | + // set timeouts |
|
| 312 | + if ($connection_timeout != 0) {
|
|
| 313 | + $this->setCurlOption($CURLOPT_CONNECTIONTIMEOUT, $connection_timeout); |
|
| 314 | + } |
|
| 315 | + if ($response_timeout != 0) {
|
|
| 316 | + $this->setCurlOption(CURLOPT_TIMEOUT, $response_timeout); |
|
| 317 | + } |
|
| 318 | 318 | |
| 319 | - if ($this->scheme == 'https') {
|
|
| 320 | - $this->debug('set cURL SSL verify options');
|
|
| 321 | - // recent versions of cURL turn on peer/host checking by default, |
|
| 322 | - // while PHP binaries are not compiled with a default location for the |
|
| 323 | - // CA cert bundle, so disable peer/host checking. |
|
| 324 | - //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); |
|
| 325 | - $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0); |
|
| 326 | - $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); |
|
| 319 | + if ($this->scheme == 'https') {
|
|
| 320 | + $this->debug('set cURL SSL verify options');
|
|
| 321 | + // recent versions of cURL turn on peer/host checking by default, |
|
| 322 | + // while PHP binaries are not compiled with a default location for the |
|
| 323 | + // CA cert bundle, so disable peer/host checking. |
|
| 324 | + //$this->setCurlOption(CURLOPT_CAINFO, 'f:\php-4.3.2-win32\extensions\curl-ca-bundle.crt'); |
|
| 325 | + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 0); |
|
| 326 | + $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 0); |
|
| 327 | 327 | |
| 328 | - // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) |
|
| 329 | - if ($this->authtype == 'certificate') {
|
|
| 330 | - $this->debug('set cURL certificate options');
|
|
| 331 | - if (isset($this->certRequest['cainfofile'])) {
|
|
| 332 | - $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']); |
|
| 333 | - } |
|
| 334 | - if (isset($this->certRequest['verifypeer'])) {
|
|
| 335 | - $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']); |
|
| 336 | - } else {
|
|
| 337 | - $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1); |
|
| 338 | - } |
|
| 339 | - if (isset($this->certRequest['verifyhost'])) {
|
|
| 340 | - $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']); |
|
| 341 | - } else {
|
|
| 342 | - $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1); |
|
| 343 | - } |
|
| 344 | - if (isset($this->certRequest['sslcertfile'])) {
|
|
| 345 | - $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']); |
|
| 346 | - } |
|
| 347 | - if (isset($this->certRequest['sslkeyfile'])) {
|
|
| 348 | - $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']); |
|
| 349 | - } |
|
| 350 | - if (isset($this->certRequest['passphrase'])) {
|
|
| 351 | - $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']); |
|
| 352 | - } |
|
| 353 | - if (isset($this->certRequest['certpassword'])) {
|
|
| 354 | - $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']); |
|
| 355 | - } |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - if ($this->authtype && ($this->authtype != 'certificate')) {
|
|
| 359 | - if ($this->username) {
|
|
| 360 | - $this->debug('set cURL username/password');
|
|
| 361 | - $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password"); |
|
| 362 | - } |
|
| 363 | - if ($this->authtype == 'basic') {
|
|
| 364 | - $this->debug('set cURL for Basic authentication');
|
|
| 365 | - $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC); |
|
| 366 | - } |
|
| 367 | - if ($this->authtype == 'digest') {
|
|
| 368 | - $this->debug('set cURL for digest authentication');
|
|
| 369 | - $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST); |
|
| 370 | - } |
|
| 371 | - if ($this->authtype == 'ntlm') {
|
|
| 372 | - $this->debug('set cURL for NTLM authentication');
|
|
| 373 | - $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM); |
|
| 374 | - } |
|
| 375 | - } |
|
| 376 | - if (is_array($this->proxy)) {
|
|
| 377 | - $this->debug('set cURL proxy options');
|
|
| 378 | - if ($this->proxy['port'] != '') {
|
|
| 379 | - $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']); |
|
| 380 | - } else {
|
|
| 381 | - $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']); |
|
| 382 | - } |
|
| 383 | - if ($this->proxy['username'] || $this->proxy['password']) {
|
|
| 384 | - $this->debug('set cURL proxy authentication options');
|
|
| 385 | - $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']); |
|
| 386 | - if ($this->proxy['authtype'] == 'basic') {
|
|
| 387 | - $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC); |
|
| 388 | - } |
|
| 389 | - if ($this->proxy['authtype'] == 'ntlm') {
|
|
| 390 | - $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM); |
|
| 391 | - } |
|
| 392 | - } |
|
| 393 | - } |
|
| 394 | - $this->debug('cURL connection set up');
|
|
| 395 | - return true; |
|
| 396 | - } else {
|
|
| 397 | - $this->setError('Unknown scheme ' . $this->scheme);
|
|
| 398 | - $this->debug('Unknown scheme ' . $this->scheme);
|
|
| 399 | - return false; |
|
| 400 | - } |
|
| 401 | - } |
|
| 328 | + // support client certificates (thanks Tobias Boes, Doug Anarino, Eryan Ariobowo) |
|
| 329 | + if ($this->authtype == 'certificate') {
|
|
| 330 | + $this->debug('set cURL certificate options');
|
|
| 331 | + if (isset($this->certRequest['cainfofile'])) {
|
|
| 332 | + $this->setCurlOption(CURLOPT_CAINFO, $this->certRequest['cainfofile']); |
|
| 333 | + } |
|
| 334 | + if (isset($this->certRequest['verifypeer'])) {
|
|
| 335 | + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, $this->certRequest['verifypeer']); |
|
| 336 | + } else {
|
|
| 337 | + $this->setCurlOption(CURLOPT_SSL_VERIFYPEER, 1); |
|
| 338 | + } |
|
| 339 | + if (isset($this->certRequest['verifyhost'])) {
|
|
| 340 | + $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, $this->certRequest['verifyhost']); |
|
| 341 | + } else {
|
|
| 342 | + $this->setCurlOption(CURLOPT_SSL_VERIFYHOST, 1); |
|
| 343 | + } |
|
| 344 | + if (isset($this->certRequest['sslcertfile'])) {
|
|
| 345 | + $this->setCurlOption(CURLOPT_SSLCERT, $this->certRequest['sslcertfile']); |
|
| 346 | + } |
|
| 347 | + if (isset($this->certRequest['sslkeyfile'])) {
|
|
| 348 | + $this->setCurlOption(CURLOPT_SSLKEY, $this->certRequest['sslkeyfile']); |
|
| 349 | + } |
|
| 350 | + if (isset($this->certRequest['passphrase'])) {
|
|
| 351 | + $this->setCurlOption(CURLOPT_SSLKEYPASSWD, $this->certRequest['passphrase']); |
|
| 352 | + } |
|
| 353 | + if (isset($this->certRequest['certpassword'])) {
|
|
| 354 | + $this->setCurlOption(CURLOPT_SSLCERTPASSWD, $this->certRequest['certpassword']); |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + if ($this->authtype && ($this->authtype != 'certificate')) {
|
|
| 359 | + if ($this->username) {
|
|
| 360 | + $this->debug('set cURL username/password');
|
|
| 361 | + $this->setCurlOption(CURLOPT_USERPWD, "$this->username:$this->password"); |
|
| 362 | + } |
|
| 363 | + if ($this->authtype == 'basic') {
|
|
| 364 | + $this->debug('set cURL for Basic authentication');
|
|
| 365 | + $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_BASIC); |
|
| 366 | + } |
|
| 367 | + if ($this->authtype == 'digest') {
|
|
| 368 | + $this->debug('set cURL for digest authentication');
|
|
| 369 | + $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_DIGEST); |
|
| 370 | + } |
|
| 371 | + if ($this->authtype == 'ntlm') {
|
|
| 372 | + $this->debug('set cURL for NTLM authentication');
|
|
| 373 | + $this->setCurlOption($CURLOPT_HTTPAUTH, $CURLAUTH_NTLM); |
|
| 374 | + } |
|
| 375 | + } |
|
| 376 | + if (is_array($this->proxy)) {
|
|
| 377 | + $this->debug('set cURL proxy options');
|
|
| 378 | + if ($this->proxy['port'] != '') {
|
|
| 379 | + $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host'].':'.$this->proxy['port']); |
|
| 380 | + } else {
|
|
| 381 | + $this->setCurlOption(CURLOPT_PROXY, $this->proxy['host']); |
|
| 382 | + } |
|
| 383 | + if ($this->proxy['username'] || $this->proxy['password']) {
|
|
| 384 | + $this->debug('set cURL proxy authentication options');
|
|
| 385 | + $this->setCurlOption(CURLOPT_PROXYUSERPWD, $this->proxy['username'].':'.$this->proxy['password']); |
|
| 386 | + if ($this->proxy['authtype'] == 'basic') {
|
|
| 387 | + $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_BASIC); |
|
| 388 | + } |
|
| 389 | + if ($this->proxy['authtype'] == 'ntlm') {
|
|
| 390 | + $this->setCurlOption($CURLOPT_PROXYAUTH, $CURLAUTH_NTLM); |
|
| 391 | + } |
|
| 392 | + } |
|
| 393 | + } |
|
| 394 | + $this->debug('cURL connection set up');
|
|
| 395 | + return true; |
|
| 396 | + } else {
|
|
| 397 | + $this->setError('Unknown scheme ' . $this->scheme);
|
|
| 398 | + $this->debug('Unknown scheme ' . $this->scheme);
|
|
| 399 | + return false; |
|
| 400 | + } |
|
| 401 | + } |
|
| 402 | 402 | |
| 403 | - /** |
|
| 404 | - * sends the SOAP request and gets the SOAP response via HTTP[S] |
|
| 405 | - * |
|
| 406 | - * @param string $data message data |
|
| 407 | - * @param integer $timeout set connection timeout in seconds |
|
| 408 | - * @param integer $response_timeout set response timeout in seconds |
|
| 409 | - * @param array $cookies cookies to send |
|
| 410 | - * @return string data |
|
| 411 | - * @access public |
|
| 412 | - */ |
|
| 413 | - function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
|
|
| 403 | + /** |
|
| 404 | + * sends the SOAP request and gets the SOAP response via HTTP[S] |
|
| 405 | + * |
|
| 406 | + * @param string $data message data |
|
| 407 | + * @param integer $timeout set connection timeout in seconds |
|
| 408 | + * @param integer $response_timeout set response timeout in seconds |
|
| 409 | + * @param array $cookies cookies to send |
|
| 410 | + * @return string data |
|
| 411 | + * @access public |
|
| 412 | + */ |
|
| 413 | + function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
|
|
| 414 | 414 | |
| 415 | - $this->debug('entered send() with data of length: '.strlen($data));
|
|
| 415 | + $this->debug('entered send() with data of length: '.strlen($data));
|
|
| 416 | 416 | |
| 417 | - $this->tryagain = true; |
|
| 418 | - $tries = 0; |
|
| 419 | - while ($this->tryagain) {
|
|
| 420 | - $this->tryagain = false; |
|
| 421 | - if ($tries++ < 2) {
|
|
| 422 | - // make connnection |
|
| 423 | - if (!$this->connect($timeout, $response_timeout)){
|
|
| 424 | - return false; |
|
| 425 | - } |
|
| 417 | + $this->tryagain = true; |
|
| 418 | + $tries = 0; |
|
| 419 | + while ($this->tryagain) {
|
|
| 420 | + $this->tryagain = false; |
|
| 421 | + if ($tries++ < 2) {
|
|
| 422 | + // make connnection |
|
| 423 | + if (!$this->connect($timeout, $response_timeout)){
|
|
| 424 | + return false; |
|
| 425 | + } |
|
| 426 | 426 | |
| 427 | - // send request |
|
| 428 | - if (!$this->sendRequest($data, $cookies)){
|
|
| 429 | - return false; |
|
| 430 | - } |
|
| 427 | + // send request |
|
| 428 | + if (!$this->sendRequest($data, $cookies)){
|
|
| 429 | + return false; |
|
| 430 | + } |
|
| 431 | 431 | |
| 432 | - // get response |
|
| 433 | - $respdata = $this->getResponse(); |
|
| 434 | - } else {
|
|
| 435 | - $this->setError("Too many tries to get an OK response ($this->response_status_line)");
|
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - $this->debug('end of send()');
|
|
| 439 | - return $respdata; |
|
| 440 | - } |
|
| 432 | + // get response |
|
| 433 | + $respdata = $this->getResponse(); |
|
| 434 | + } else {
|
|
| 435 | + $this->setError("Too many tries to get an OK response ($this->response_status_line)");
|
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + $this->debug('end of send()');
|
|
| 439 | + return $respdata; |
|
| 440 | + } |
|
| 441 | 441 | |
| 442 | 442 | |
| 443 | - /** |
|
| 444 | - * sends the SOAP request and gets the SOAP response via HTTPS using CURL |
|
| 445 | - * |
|
| 446 | - * @param string $data message data |
|
| 447 | - * @param integer $timeout set connection timeout in seconds |
|
| 448 | - * @param integer $response_timeout set response timeout in seconds |
|
| 449 | - * @param array $cookies cookies to send |
|
| 450 | - * @return string data |
|
| 451 | - * @access public |
|
| 452 | - * @deprecated |
|
| 453 | - */ |
|
| 454 | - function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
|
|
| 455 | - return $this->send($data, $timeout, $response_timeout, $cookies); |
|
| 456 | - } |
|
| 443 | + /** |
|
| 444 | + * sends the SOAP request and gets the SOAP response via HTTPS using CURL |
|
| 445 | + * |
|
| 446 | + * @param string $data message data |
|
| 447 | + * @param integer $timeout set connection timeout in seconds |
|
| 448 | + * @param integer $response_timeout set response timeout in seconds |
|
| 449 | + * @param array $cookies cookies to send |
|
| 450 | + * @return string data |
|
| 451 | + * @access public |
|
| 452 | + * @deprecated |
|
| 453 | + */ |
|
| 454 | + function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
|
|
| 455 | + return $this->send($data, $timeout, $response_timeout, $cookies); |
|
| 456 | + } |
|
| 457 | 457 | |
| 458 | - /** |
|
| 459 | - * if authenticating, set user credentials here |
|
| 460 | - * |
|
| 461 | - * @param string $username |
|
| 462 | - * @param string $password |
|
| 463 | - * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 464 | - * @param array $digestRequest (keys must be nonce, nc, realm, qop) |
|
| 465 | - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 466 | - * @access public |
|
| 467 | - */ |
|
| 468 | - function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
|
|
| 469 | - $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
|
|
| 470 | - $this->appendDebug($this->varDump($digestRequest)); |
|
| 471 | - $this->debug("certRequest=");
|
|
| 472 | - $this->appendDebug($this->varDump($certRequest)); |
|
| 473 | - // cf. RFC 2617 |
|
| 474 | - if ($authtype == 'basic') {
|
|
| 475 | - $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
|
|
| 476 | - } elseif ($authtype == 'digest') {
|
|
| 477 | - if (isset($digestRequest['nonce'])) {
|
|
| 478 | - $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; |
|
| 458 | + /** |
|
| 459 | + * if authenticating, set user credentials here |
|
| 460 | + * |
|
| 461 | + * @param string $username |
|
| 462 | + * @param string $password |
|
| 463 | + * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 464 | + * @param array $digestRequest (keys must be nonce, nc, realm, qop) |
|
| 465 | + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 466 | + * @access public |
|
| 467 | + */ |
|
| 468 | + function setCredentials($username, $password, $authtype = 'basic', $digestRequest = array(), $certRequest = array()) {
|
|
| 469 | + $this->debug("setCredentials username=$username authtype=$authtype digestRequest=");
|
|
| 470 | + $this->appendDebug($this->varDump($digestRequest)); |
|
| 471 | + $this->debug("certRequest=");
|
|
| 472 | + $this->appendDebug($this->varDump($certRequest)); |
|
| 473 | + // cf. RFC 2617 |
|
| 474 | + if ($authtype == 'basic') {
|
|
| 475 | + $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
|
|
| 476 | + } elseif ($authtype == 'digest') {
|
|
| 477 | + if (isset($digestRequest['nonce'])) {
|
|
| 478 | + $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; |
|
| 479 | 479 | |
| 480 | - // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html) |
|
| 480 | + // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html) |
|
| 481 | 481 | |
| 482 | - // A1 = unq(username-value) ":" unq(realm-value) ":" passwd |
|
| 483 | - $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password; |
|
| 482 | + // A1 = unq(username-value) ":" unq(realm-value) ":" passwd |
|
| 483 | + $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password; |
|
| 484 | 484 | |
| 485 | - // H(A1) = MD5(A1) |
|
| 486 | - $HA1 = md5($A1); |
|
| 485 | + // H(A1) = MD5(A1) |
|
| 486 | + $HA1 = md5($A1); |
|
| 487 | 487 | |
| 488 | - // A2 = Method ":" digest-uri-value |
|
| 489 | - $A2 = $this->request_method . ':' . $this->digest_uri; |
|
| 488 | + // A2 = Method ":" digest-uri-value |
|
| 489 | + $A2 = $this->request_method . ':' . $this->digest_uri; |
|
| 490 | 490 | |
| 491 | - // H(A2) |
|
| 492 | - $HA2 = md5($A2); |
|
| 491 | + // H(A2) |
|
| 492 | + $HA2 = md5($A2); |
|
| 493 | 493 | |
| 494 | - // KD(secret, data) = H(concat(secret, ":", data)) |
|
| 495 | - // if qop == auth: |
|
| 496 | - // request-digest = <"> < KD ( H(A1), unq(nonce-value) |
|
| 497 | - // ":" nc-value |
|
| 498 | - // ":" unq(cnonce-value) |
|
| 499 | - // ":" unq(qop-value) |
|
| 500 | - // ":" H(A2) |
|
| 501 | - // ) <"> |
|
| 502 | - // if qop is missing, |
|
| 503 | - // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <"> |
|
| 494 | + // KD(secret, data) = H(concat(secret, ":", data)) |
|
| 495 | + // if qop == auth: |
|
| 496 | + // request-digest = <"> < KD ( H(A1), unq(nonce-value) |
|
| 497 | + // ":" nc-value |
|
| 498 | + // ":" unq(cnonce-value) |
|
| 499 | + // ":" unq(qop-value) |
|
| 500 | + // ":" H(A2) |
|
| 501 | + // ) <"> |
|
| 502 | + // if qop is missing, |
|
| 503 | + // request-digest = <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <"> |
|
| 504 | 504 | |
| 505 | - $unhashedDigest = ''; |
|
| 506 | - $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; |
|
| 507 | - $cnonce = $nonce; |
|
| 508 | - if ($digestRequest['qop'] != '') {
|
|
| 509 | - $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
|
|
| 510 | - } else {
|
|
| 511 | - $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; |
|
| 512 | - } |
|
| 505 | + $unhashedDigest = ''; |
|
| 506 | + $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; |
|
| 507 | + $cnonce = $nonce; |
|
| 508 | + if ($digestRequest['qop'] != '') {
|
|
| 509 | + $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
|
|
| 510 | + } else {
|
|
| 511 | + $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; |
|
| 512 | + } |
|
| 513 | 513 | |
| 514 | - $hashedDigest = md5($unhashedDigest); |
|
| 514 | + $hashedDigest = md5($unhashedDigest); |
|
| 515 | 515 | |
| 516 | - $opaque = ''; |
|
| 517 | - if (isset($digestRequest['opaque'])) {
|
|
| 518 | - $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; |
|
| 519 | - } |
|
| 516 | + $opaque = ''; |
|
| 517 | + if (isset($digestRequest['opaque'])) {
|
|
| 518 | + $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; |
|
| 519 | + } |
|
| 520 | 520 | |
| 521 | - $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 . '"');
|
|
| 522 | - } |
|
| 523 | - } elseif ($authtype == 'certificate') {
|
|
| 524 | - $this->certRequest = $certRequest; |
|
| 525 | - $this->debug('Authorization header not set for certificate');
|
|
| 526 | - } elseif ($authtype == 'ntlm') {
|
|
| 527 | - // do nothing |
|
| 528 | - $this->debug('Authorization header not set for ntlm');
|
|
| 529 | - } |
|
| 530 | - $this->username = $username; |
|
| 531 | - $this->password = $password; |
|
| 532 | - $this->authtype = $authtype; |
|
| 533 | - $this->digestRequest = $digestRequest; |
|
| 534 | - } |
|
| 521 | + $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 . '"');
|
|
| 522 | + } |
|
| 523 | + } elseif ($authtype == 'certificate') {
|
|
| 524 | + $this->certRequest = $certRequest; |
|
| 525 | + $this->debug('Authorization header not set for certificate');
|
|
| 526 | + } elseif ($authtype == 'ntlm') {
|
|
| 527 | + // do nothing |
|
| 528 | + $this->debug('Authorization header not set for ntlm');
|
|
| 529 | + } |
|
| 530 | + $this->username = $username; |
|
| 531 | + $this->password = $password; |
|
| 532 | + $this->authtype = $authtype; |
|
| 533 | + $this->digestRequest = $digestRequest; |
|
| 534 | + } |
|
| 535 | 535 | |
| 536 | - /** |
|
| 537 | - * set the soapaction value |
|
| 538 | - * |
|
| 539 | - * @param string $soapaction |
|
| 540 | - * @access public |
|
| 541 | - */ |
|
| 542 | - function setSOAPAction($soapaction) {
|
|
| 543 | - $this->setHeader('SOAPAction', '"' . $soapaction . '"');
|
|
| 544 | - } |
|
| 536 | + /** |
|
| 537 | + * set the soapaction value |
|
| 538 | + * |
|
| 539 | + * @param string $soapaction |
|
| 540 | + * @access public |
|
| 541 | + */ |
|
| 542 | + function setSOAPAction($soapaction) {
|
|
| 543 | + $this->setHeader('SOAPAction', '"' . $soapaction . '"');
|
|
| 544 | + } |
|
| 545 | 545 | |
| 546 | - /** |
|
| 547 | - * use http encoding |
|
| 548 | - * |
|
| 549 | - * @param string $enc encoding style. supported values: gzip, deflate, or both |
|
| 550 | - * @access public |
|
| 551 | - */ |
|
| 552 | - function setEncoding($enc='gzip, deflate') {
|
|
| 553 | - if (function_exists('gzdeflate')) {
|
|
| 554 | - $this->protocol_version = '1.1'; |
|
| 555 | - $this->setHeader('Accept-Encoding', $enc);
|
|
| 556 | - if (!isset($this->outgoing_headers['Connection'])) {
|
|
| 557 | - $this->setHeader('Connection', 'close');
|
|
| 558 | - $this->persistentConnection = false; |
|
| 559 | - } |
|
| 560 | - // deprecated as of PHP 5.3.0 |
|
| 561 | - //set_magic_quotes_runtime(0); |
|
| 562 | - $this->encoding = $enc; |
|
| 563 | - } |
|
| 564 | - } |
|
| 546 | + /** |
|
| 547 | + * use http encoding |
|
| 548 | + * |
|
| 549 | + * @param string $enc encoding style. supported values: gzip, deflate, or both |
|
| 550 | + * @access public |
|
| 551 | + */ |
|
| 552 | + function setEncoding($enc='gzip, deflate') {
|
|
| 553 | + if (function_exists('gzdeflate')) {
|
|
| 554 | + $this->protocol_version = '1.1'; |
|
| 555 | + $this->setHeader('Accept-Encoding', $enc);
|
|
| 556 | + if (!isset($this->outgoing_headers['Connection'])) {
|
|
| 557 | + $this->setHeader('Connection', 'close');
|
|
| 558 | + $this->persistentConnection = false; |
|
| 559 | + } |
|
| 560 | + // deprecated as of PHP 5.3.0 |
|
| 561 | + //set_magic_quotes_runtime(0); |
|
| 562 | + $this->encoding = $enc; |
|
| 563 | + } |
|
| 564 | + } |
|
| 565 | 565 | |
| 566 | - /** |
|
| 567 | - * set proxy info here |
|
| 568 | - * |
|
| 569 | - * @param string $proxyhost use an empty string to remove proxy |
|
| 570 | - * @param string $proxyport |
|
| 571 | - * @param string $proxyusername |
|
| 572 | - * @param string $proxypassword |
|
| 573 | - * @param string $proxyauthtype (basic|ntlm) |
|
| 574 | - * @access public |
|
| 575 | - */ |
|
| 576 | - function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
|
|
| 577 | - if ($proxyhost) {
|
|
| 578 | - $this->proxy = array( |
|
| 579 | - 'host' => $proxyhost, |
|
| 580 | - 'port' => $proxyport, |
|
| 581 | - 'username' => $proxyusername, |
|
| 582 | - 'password' => $proxypassword, |
|
| 583 | - 'authtype' => $proxyauthtype |
|
| 584 | - ); |
|
| 585 | - if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
|
|
| 586 | - $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
|
|
| 587 | - } |
|
| 588 | - } else {
|
|
| 589 | - $this->debug('remove proxy');
|
|
| 590 | - $proxy = null; |
|
| 591 | - unsetHeader('Proxy-Authorization');
|
|
| 592 | - } |
|
| 593 | - } |
|
| 566 | + /** |
|
| 567 | + * set proxy info here |
|
| 568 | + * |
|
| 569 | + * @param string $proxyhost use an empty string to remove proxy |
|
| 570 | + * @param string $proxyport |
|
| 571 | + * @param string $proxyusername |
|
| 572 | + * @param string $proxypassword |
|
| 573 | + * @param string $proxyauthtype (basic|ntlm) |
|
| 574 | + * @access public |
|
| 575 | + */ |
|
| 576 | + function setProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '', $proxyauthtype = 'basic') {
|
|
| 577 | + if ($proxyhost) {
|
|
| 578 | + $this->proxy = array( |
|
| 579 | + 'host' => $proxyhost, |
|
| 580 | + 'port' => $proxyport, |
|
| 581 | + 'username' => $proxyusername, |
|
| 582 | + 'password' => $proxypassword, |
|
| 583 | + 'authtype' => $proxyauthtype |
|
| 584 | + ); |
|
| 585 | + if ($proxyusername != '' && $proxypassword != '' && $proxyauthtype = 'basic') {
|
|
| 586 | + $this->setHeader('Proxy-Authorization', ' Basic '.base64_encode($proxyusername.':'.$proxypassword));
|
|
| 587 | + } |
|
| 588 | + } else {
|
|
| 589 | + $this->debug('remove proxy');
|
|
| 590 | + $proxy = null; |
|
| 591 | + unsetHeader('Proxy-Authorization');
|
|
| 592 | + } |
|
| 593 | + } |
|
| 594 | 594 | |
| 595 | 595 | |
| 596 | - /** |
|
| 597 | - * Test if the given string starts with a header that is to be skipped. |
|
| 598 | - * Skippable headers result from chunked transfer and proxy requests. |
|
| 599 | - * |
|
| 600 | - * @param string $data The string to check. |
|
| 601 | - * @returns boolean Whether a skippable header was found. |
|
| 602 | - * @access private |
|
| 603 | - */ |
|
| 604 | - function isSkippableCurlHeader(&$data) {
|
|
| 605 | - $skipHeaders = array( 'HTTP/1.1 100', |
|
| 606 | - 'HTTP/1.0 301', |
|
| 607 | - 'HTTP/1.1 301', |
|
| 608 | - 'HTTP/1.0 302', |
|
| 609 | - 'HTTP/1.1 302', |
|
| 610 | - 'HTTP/1.0 401', |
|
| 611 | - 'HTTP/1.1 401', |
|
| 612 | - 'HTTP/1.0 200 Connection established'); |
|
| 613 | - foreach ($skipHeaders as $hd) {
|
|
| 614 | - $prefix = substr($data, 0, strlen($hd)); |
|
| 615 | - if ($prefix == $hd) return true; |
|
| 616 | - } |
|
| 596 | + /** |
|
| 597 | + * Test if the given string starts with a header that is to be skipped. |
|
| 598 | + * Skippable headers result from chunked transfer and proxy requests. |
|
| 599 | + * |
|
| 600 | + * @param string $data The string to check. |
|
| 601 | + * @returns boolean Whether a skippable header was found. |
|
| 602 | + * @access private |
|
| 603 | + */ |
|
| 604 | + function isSkippableCurlHeader(&$data) {
|
|
| 605 | + $skipHeaders = array( 'HTTP/1.1 100', |
|
| 606 | + 'HTTP/1.0 301', |
|
| 607 | + 'HTTP/1.1 301', |
|
| 608 | + 'HTTP/1.0 302', |
|
| 609 | + 'HTTP/1.1 302', |
|
| 610 | + 'HTTP/1.0 401', |
|
| 611 | + 'HTTP/1.1 401', |
|
| 612 | + 'HTTP/1.0 200 Connection established'); |
|
| 613 | + foreach ($skipHeaders as $hd) {
|
|
| 614 | + $prefix = substr($data, 0, strlen($hd)); |
|
| 615 | + if ($prefix == $hd) return true; |
|
| 616 | + } |
|
| 617 | 617 | |
| 618 | - return false; |
|
| 619 | - } |
|
| 618 | + return false; |
|
| 619 | + } |
|
| 620 | 620 | |
| 621 | - /** |
|
| 622 | - * decode a string that is encoded w/ "chunked' transfer encoding |
|
| 623 | - * as defined in RFC2068 19.4.6 |
|
| 624 | - * |
|
| 625 | - * @param string $buffer |
|
| 626 | - * @param string $lb |
|
| 627 | - * @returns string |
|
| 628 | - * @access public |
|
| 629 | - * @deprecated |
|
| 630 | - */ |
|
| 631 | - function decodeChunked($buffer, $lb){
|
|
| 632 | - // length := 0 |
|
| 633 | - $length = 0; |
|
| 634 | - $new = ''; |
|
| 621 | + /** |
|
| 622 | + * decode a string that is encoded w/ "chunked' transfer encoding |
|
| 623 | + * as defined in RFC2068 19.4.6 |
|
| 624 | + * |
|
| 625 | + * @param string $buffer |
|
| 626 | + * @param string $lb |
|
| 627 | + * @returns string |
|
| 628 | + * @access public |
|
| 629 | + * @deprecated |
|
| 630 | + */ |
|
| 631 | + function decodeChunked($buffer, $lb){
|
|
| 632 | + // length := 0 |
|
| 633 | + $length = 0; |
|
| 634 | + $new = ''; |
|
| 635 | 635 | |
| 636 | - // read chunk-size, chunk-extension (if any) and CRLF |
|
| 637 | - // get the position of the linebreak |
|
| 638 | - $chunkend = strpos($buffer, $lb); |
|
| 639 | - if ($chunkend == FALSE) {
|
|
| 640 | - $this->debug('no linebreak found in decodeChunked');
|
|
| 641 | - return $new; |
|
| 642 | - } |
|
| 643 | - $temp = substr($buffer,0,$chunkend); |
|
| 644 | - $chunk_size = hexdec( trim($temp) ); |
|
| 645 | - $chunkstart = $chunkend + strlen($lb); |
|
| 646 | - // while (chunk-size > 0) {
|
|
| 647 | - while ($chunk_size > 0) {
|
|
| 648 | - $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
|
|
| 649 | - $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size); |
|
| 636 | + // read chunk-size, chunk-extension (if any) and CRLF |
|
| 637 | + // get the position of the linebreak |
|
| 638 | + $chunkend = strpos($buffer, $lb); |
|
| 639 | + if ($chunkend == FALSE) {
|
|
| 640 | + $this->debug('no linebreak found in decodeChunked');
|
|
| 641 | + return $new; |
|
| 642 | + } |
|
| 643 | + $temp = substr($buffer,0,$chunkend); |
|
| 644 | + $chunk_size = hexdec( trim($temp) ); |
|
| 645 | + $chunkstart = $chunkend + strlen($lb); |
|
| 646 | + // while (chunk-size > 0) {
|
|
| 647 | + while ($chunk_size > 0) {
|
|
| 648 | + $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
|
|
| 649 | + $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size); |
|
| 650 | 650 | |
| 651 | - // Just in case we got a broken connection |
|
| 652 | - if ($chunkend == FALSE) {
|
|
| 653 | - $chunk = substr($buffer,$chunkstart); |
|
| 654 | - // append chunk-data to entity-body |
|
| 655 | - $new .= $chunk; |
|
| 656 | - $length += strlen($chunk); |
|
| 657 | - break; |
|
| 658 | - } |
|
| 651 | + // Just in case we got a broken connection |
|
| 652 | + if ($chunkend == FALSE) {
|
|
| 653 | + $chunk = substr($buffer,$chunkstart); |
|
| 654 | + // append chunk-data to entity-body |
|
| 655 | + $new .= $chunk; |
|
| 656 | + $length += strlen($chunk); |
|
| 657 | + break; |
|
| 658 | + } |
|
| 659 | 659 | |
| 660 | - // read chunk-data and CRLF |
|
| 661 | - $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
| 662 | - // append chunk-data to entity-body |
|
| 663 | - $new .= $chunk; |
|
| 664 | - // length := length + chunk-size |
|
| 665 | - $length += strlen($chunk); |
|
| 666 | - // read chunk-size and CRLF |
|
| 667 | - $chunkstart = $chunkend + strlen($lb); |
|
| 660 | + // read chunk-data and CRLF |
|
| 661 | + $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
| 662 | + // append chunk-data to entity-body |
|
| 663 | + $new .= $chunk; |
|
| 664 | + // length := length + chunk-size |
|
| 665 | + $length += strlen($chunk); |
|
| 666 | + // read chunk-size and CRLF |
|
| 667 | + $chunkstart = $chunkend + strlen($lb); |
|
| 668 | 668 | |
| 669 | - $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); |
|
| 670 | - if ($chunkend == FALSE) {
|
|
| 671 | - break; //Just in case we got a broken connection |
|
| 672 | - } |
|
| 673 | - $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
| 674 | - $chunk_size = hexdec( trim($temp) ); |
|
| 675 | - $chunkstart = $chunkend; |
|
| 676 | - } |
|
| 677 | - return $new; |
|
| 678 | - } |
|
| 669 | + $chunkend = strpos($buffer, $lb, $chunkstart) + strlen($lb); |
|
| 670 | + if ($chunkend == FALSE) {
|
|
| 671 | + break; //Just in case we got a broken connection |
|
| 672 | + } |
|
| 673 | + $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
| 674 | + $chunk_size = hexdec( trim($temp) ); |
|
| 675 | + $chunkstart = $chunkend; |
|
| 676 | + } |
|
| 677 | + return $new; |
|
| 678 | + } |
|
| 679 | 679 | |
| 680 | - /** |
|
| 681 | - * Writes the payload, including HTTP headers, to $this->outgoing_payload. |
|
| 682 | - * |
|
| 683 | - * @param string $data HTTP body |
|
| 684 | - * @param string $cookie_str data for HTTP Cookie header |
|
| 685 | - * @return void |
|
| 686 | - * @access private |
|
| 687 | - */ |
|
| 688 | - function buildPayload($data, $cookie_str = '') {
|
|
| 689 | - // Note: for cURL connections, $this->outgoing_payload is ignored, |
|
| 690 | - // as is the Content-Length header, but these are still created as |
|
| 691 | - // debugging guides. |
|
| 680 | + /** |
|
| 681 | + * Writes the payload, including HTTP headers, to $this->outgoing_payload. |
|
| 682 | + * |
|
| 683 | + * @param string $data HTTP body |
|
| 684 | + * @param string $cookie_str data for HTTP Cookie header |
|
| 685 | + * @return void |
|
| 686 | + * @access private |
|
| 687 | + */ |
|
| 688 | + function buildPayload($data, $cookie_str = '') {
|
|
| 689 | + // Note: for cURL connections, $this->outgoing_payload is ignored, |
|
| 690 | + // as is the Content-Length header, but these are still created as |
|
| 691 | + // debugging guides. |
|
| 692 | 692 | |
| 693 | - // add content-length header |
|
| 694 | - if ($this->request_method != 'GET') {
|
|
| 695 | - $this->setHeader('Content-Length', strlen($data));
|
|
| 696 | - } |
|
| 693 | + // add content-length header |
|
| 694 | + if ($this->request_method != 'GET') {
|
|
| 695 | + $this->setHeader('Content-Length', strlen($data));
|
|
| 696 | + } |
|
| 697 | 697 | |
| 698 | - // start building outgoing payload: |
|
| 699 | - if ($this->proxy) {
|
|
| 700 | - $uri = $this->url; |
|
| 701 | - } else {
|
|
| 702 | - $uri = $this->uri; |
|
| 703 | - } |
|
| 704 | - $req = "$this->request_method $uri HTTP/$this->protocol_version"; |
|
| 705 | - $this->debug("HTTP request: $req");
|
|
| 706 | - $this->outgoing_payload = "$req\r\n"; |
|
| 698 | + // start building outgoing payload: |
|
| 699 | + if ($this->proxy) {
|
|
| 700 | + $uri = $this->url; |
|
| 701 | + } else {
|
|
| 702 | + $uri = $this->uri; |
|
| 703 | + } |
|
| 704 | + $req = "$this->request_method $uri HTTP/$this->protocol_version"; |
|
| 705 | + $this->debug("HTTP request: $req");
|
|
| 706 | + $this->outgoing_payload = "$req\r\n"; |
|
| 707 | 707 | |
| 708 | - // loop thru headers, serializing |
|
| 709 | - foreach($this->outgoing_headers as $k => $v){
|
|
| 710 | - $hdr = $k.': '.$v; |
|
| 711 | - $this->debug("HTTP header: $hdr");
|
|
| 712 | - $this->outgoing_payload .= "$hdr\r\n"; |
|
| 713 | - } |
|
| 708 | + // loop thru headers, serializing |
|
| 709 | + foreach($this->outgoing_headers as $k => $v){
|
|
| 710 | + $hdr = $k.': '.$v; |
|
| 711 | + $this->debug("HTTP header: $hdr");
|
|
| 712 | + $this->outgoing_payload .= "$hdr\r\n"; |
|
| 713 | + } |
|
| 714 | 714 | |
| 715 | - // add any cookies |
|
| 716 | - if ($cookie_str != '') {
|
|
| 717 | - $hdr = 'Cookie: '.$cookie_str; |
|
| 718 | - $this->debug("HTTP header: $hdr");
|
|
| 719 | - $this->outgoing_payload .= "$hdr\r\n"; |
|
| 720 | - } |
|
| 715 | + // add any cookies |
|
| 716 | + if ($cookie_str != '') {
|
|
| 717 | + $hdr = 'Cookie: '.$cookie_str; |
|
| 718 | + $this->debug("HTTP header: $hdr");
|
|
| 719 | + $this->outgoing_payload .= "$hdr\r\n"; |
|
| 720 | + } |
|
| 721 | 721 | |
| 722 | - // header/body separator |
|
| 723 | - $this->outgoing_payload .= "\r\n"; |
|
| 722 | + // header/body separator |
|
| 723 | + $this->outgoing_payload .= "\r\n"; |
|
| 724 | 724 | |
| 725 | - // add data |
|
| 726 | - $this->outgoing_payload .= $data; |
|
| 727 | - } |
|
| 725 | + // add data |
|
| 726 | + $this->outgoing_payload .= $data; |
|
| 727 | + } |
|
| 728 | 728 | |
| 729 | - /** |
|
| 730 | - * sends the SOAP request via HTTP[S] |
|
| 731 | - * |
|
| 732 | - * @param string $data message data |
|
| 733 | - * @param array $cookies cookies to send |
|
| 734 | - * @return boolean true if OK, false if problem |
|
| 735 | - * @access private |
|
| 736 | - */ |
|
| 737 | - function sendRequest($data, $cookies = NULL) {
|
|
| 738 | - // build cookie string |
|
| 739 | - $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); |
|
| 729 | + /** |
|
| 730 | + * sends the SOAP request via HTTP[S] |
|
| 731 | + * |
|
| 732 | + * @param string $data message data |
|
| 733 | + * @param array $cookies cookies to send |
|
| 734 | + * @return boolean true if OK, false if problem |
|
| 735 | + * @access private |
|
| 736 | + */ |
|
| 737 | + function sendRequest($data, $cookies = NULL) {
|
|
| 738 | + // build cookie string |
|
| 739 | + $cookie_str = $this->getCookiesForRequest($cookies, (($this->scheme == 'ssl') || ($this->scheme == 'https'))); |
|
| 740 | 740 | |
| 741 | - // build payload |
|
| 742 | - $this->buildPayload($data, $cookie_str); |
|
| 741 | + // build payload |
|
| 742 | + $this->buildPayload($data, $cookie_str); |
|
| 743 | 743 | |
| 744 | - if ($this->io_method() == 'socket') {
|
|
| 745 | - // send payload |
|
| 746 | - if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
|
|
| 747 | - $this->setError('couldn\'t write message data to socket');
|
|
| 748 | - $this->debug('couldn\'t write message data to socket');
|
|
| 749 | - return false; |
|
| 750 | - } |
|
| 751 | - $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
|
|
| 752 | - return true; |
|
| 753 | - } else if ($this->io_method() == 'curl') {
|
|
| 754 | - // set payload |
|
| 755 | - // cURL does say this should only be the verb, and in fact it |
|
| 756 | - // turns out that the URI and HTTP version are appended to this, which |
|
| 757 | - // some servers refuse to work with (so we no longer use this method!) |
|
| 758 | - //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); |
|
| 759 | - $curl_headers = array(); |
|
| 760 | - foreach($this->outgoing_headers as $k => $v){
|
|
| 761 | - if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
|
|
| 762 | - $this->debug("Skip cURL header $k: $v");
|
|
| 763 | - } else {
|
|
| 764 | - $curl_headers[] = "$k: $v"; |
|
| 765 | - } |
|
| 766 | - } |
|
| 767 | - if ($cookie_str != '') {
|
|
| 768 | - $curl_headers[] = 'Cookie: ' . $cookie_str; |
|
| 769 | - } |
|
| 770 | - $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); |
|
| 771 | - $this->debug('set cURL HTTP headers');
|
|
| 772 | - if ($this->request_method == "POST") {
|
|
| 773 | - $this->setCurlOption(CURLOPT_POST, 1); |
|
| 774 | - $this->setCurlOption(CURLOPT_POSTFIELDS, $data); |
|
| 775 | - $this->debug('set cURL POST data');
|
|
| 776 | - } else {
|
|
| 777 | - } |
|
| 778 | - // insert custom user-set cURL options |
|
| 779 | - foreach ($this->ch_options as $key => $val) {
|
|
| 780 | - $this->setCurlOption($key, $val); |
|
| 781 | - } |
|
| 744 | + if ($this->io_method() == 'socket') {
|
|
| 745 | + // send payload |
|
| 746 | + if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
|
|
| 747 | + $this->setError('couldn\'t write message data to socket');
|
|
| 748 | + $this->debug('couldn\'t write message data to socket');
|
|
| 749 | + return false; |
|
| 750 | + } |
|
| 751 | + $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
|
|
| 752 | + return true; |
|
| 753 | + } else if ($this->io_method() == 'curl') {
|
|
| 754 | + // set payload |
|
| 755 | + // cURL does say this should only be the verb, and in fact it |
|
| 756 | + // turns out that the URI and HTTP version are appended to this, which |
|
| 757 | + // some servers refuse to work with (so we no longer use this method!) |
|
| 758 | + //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); |
|
| 759 | + $curl_headers = array(); |
|
| 760 | + foreach($this->outgoing_headers as $k => $v){
|
|
| 761 | + if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
|
|
| 762 | + $this->debug("Skip cURL header $k: $v");
|
|
| 763 | + } else {
|
|
| 764 | + $curl_headers[] = "$k: $v"; |
|
| 765 | + } |
|
| 766 | + } |
|
| 767 | + if ($cookie_str != '') {
|
|
| 768 | + $curl_headers[] = 'Cookie: ' . $cookie_str; |
|
| 769 | + } |
|
| 770 | + $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); |
|
| 771 | + $this->debug('set cURL HTTP headers');
|
|
| 772 | + if ($this->request_method == "POST") {
|
|
| 773 | + $this->setCurlOption(CURLOPT_POST, 1); |
|
| 774 | + $this->setCurlOption(CURLOPT_POSTFIELDS, $data); |
|
| 775 | + $this->debug('set cURL POST data');
|
|
| 776 | + } else {
|
|
| 777 | + } |
|
| 778 | + // insert custom user-set cURL options |
|
| 779 | + foreach ($this->ch_options as $key => $val) {
|
|
| 780 | + $this->setCurlOption($key, $val); |
|
| 781 | + } |
|
| 782 | 782 | |
| 783 | - $this->debug('set cURL payload');
|
|
| 784 | - return true; |
|
| 785 | - } |
|
| 786 | - } |
|
| 783 | + $this->debug('set cURL payload');
|
|
| 784 | + return true; |
|
| 785 | + } |
|
| 786 | + } |
|
| 787 | 787 | |
| 788 | - /** |
|
| 789 | - * gets the SOAP response via HTTP[S] |
|
| 790 | - * |
|
| 791 | - * @return string the response (also sets member variables like incoming_payload) |
|
| 792 | - * @access private |
|
| 793 | - */ |
|
| 794 | - function getResponse(){
|
|
| 795 | - $this->incoming_payload = ''; |
|
| 788 | + /** |
|
| 789 | + * gets the SOAP response via HTTP[S] |
|
| 790 | + * |
|
| 791 | + * @return string the response (also sets member variables like incoming_payload) |
|
| 792 | + * @access private |
|
| 793 | + */ |
|
| 794 | + function getResponse(){
|
|
| 795 | + $this->incoming_payload = ''; |
|
| 796 | 796 | |
| 797 | - if ($this->io_method() == 'socket') {
|
|
| 798 | - // loop until headers have been retrieved |
|
| 799 | - $data = ''; |
|
| 800 | - while (!isset($lb)){
|
|
| 797 | + if ($this->io_method() == 'socket') {
|
|
| 798 | + // loop until headers have been retrieved |
|
| 799 | + $data = ''; |
|
| 800 | + while (!isset($lb)){
|
|
| 801 | 801 | |
| 802 | - // We might EOF during header read. |
|
| 803 | - if(feof($this->fp)) {
|
|
| 804 | - $this->incoming_payload = $data; |
|
| 805 | - $this->debug('found no headers before EOF after length ' . strlen($data));
|
|
| 806 | - $this->debug("received before EOF:\n" . $data);
|
|
| 807 | - $this->setError('server failed to send headers');
|
|
| 808 | - return false; |
|
| 809 | - } |
|
| 802 | + // We might EOF during header read. |
|
| 803 | + if(feof($this->fp)) {
|
|
| 804 | + $this->incoming_payload = $data; |
|
| 805 | + $this->debug('found no headers before EOF after length ' . strlen($data));
|
|
| 806 | + $this->debug("received before EOF:\n" . $data);
|
|
| 807 | + $this->setError('server failed to send headers');
|
|
| 808 | + return false; |
|
| 809 | + } |
|
| 810 | 810 | |
| 811 | - $tmp = fgets($this->fp, 256); |
|
| 812 | - $tmplen = strlen($tmp); |
|
| 813 | - $this->debug("read line of $tmplen bytes: " . trim($tmp));
|
|
| 811 | + $tmp = fgets($this->fp, 256); |
|
| 812 | + $tmplen = strlen($tmp); |
|
| 813 | + $this->debug("read line of $tmplen bytes: " . trim($tmp));
|
|
| 814 | 814 | |
| 815 | - if ($tmplen == 0) {
|
|
| 816 | - $this->incoming_payload = $data; |
|
| 817 | - $this->debug('socket read of headers timed out after length ' . strlen($data));
|
|
| 818 | - $this->debug("read before timeout: " . $data);
|
|
| 819 | - $this->setError('socket read of headers timed out');
|
|
| 820 | - return false; |
|
| 821 | - } |
|
| 815 | + if ($tmplen == 0) {
|
|
| 816 | + $this->incoming_payload = $data; |
|
| 817 | + $this->debug('socket read of headers timed out after length ' . strlen($data));
|
|
| 818 | + $this->debug("read before timeout: " . $data);
|
|
| 819 | + $this->setError('socket read of headers timed out');
|
|
| 820 | + return false; |
|
| 821 | + } |
|
| 822 | 822 | |
| 823 | - $data .= $tmp; |
|
| 824 | - $pos = strpos($data,"\r\n\r\n"); |
|
| 825 | - if($pos > 1){
|
|
| 826 | - $lb = "\r\n"; |
|
| 827 | - } else {
|
|
| 828 | - $pos = strpos($data,"\n\n"); |
|
| 829 | - if($pos > 1){
|
|
| 830 | - $lb = "\n"; |
|
| 831 | - } |
|
| 832 | - } |
|
| 833 | - // remove 100 headers |
|
| 834 | - if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
|
|
| 835 | - unset($lb); |
|
| 836 | - $data = ''; |
|
| 837 | - }// |
|
| 838 | - } |
|
| 839 | - // store header data |
|
| 840 | - $this->incoming_payload .= $data; |
|
| 841 | - $this->debug('found end of headers after length ' . strlen($data));
|
|
| 842 | - // process headers |
|
| 843 | - $header_data = trim(substr($data,0,$pos)); |
|
| 844 | - $header_array = explode($lb,$header_data); |
|
| 845 | - $this->incoming_headers = array(); |
|
| 846 | - $this->incoming_cookies = array(); |
|
| 847 | - foreach($header_array as $header_line){
|
|
| 848 | - $arr = explode(':',$header_line, 2);
|
|
| 849 | - if(count($arr) > 1){
|
|
| 850 | - $header_name = strtolower(trim($arr[0])); |
|
| 851 | - $this->incoming_headers[$header_name] = trim($arr[1]); |
|
| 852 | - if ($header_name == 'set-cookie') {
|
|
| 853 | - // TODO: allow multiple cookies from parseCookie |
|
| 854 | - $cookie = $this->parseCookie(trim($arr[1])); |
|
| 855 | - if ($cookie) {
|
|
| 856 | - $this->incoming_cookies[] = $cookie; |
|
| 857 | - $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
|
|
| 858 | - } else {
|
|
| 859 | - $this->debug('did not find cookie in ' . trim($arr[1]));
|
|
| 860 | - } |
|
| 861 | - } |
|
| 862 | - } else if (isset($header_name)) {
|
|
| 863 | - // append continuation line to previous header |
|
| 864 | - $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; |
|
| 865 | - } |
|
| 866 | - } |
|
| 823 | + $data .= $tmp; |
|
| 824 | + $pos = strpos($data,"\r\n\r\n"); |
|
| 825 | + if($pos > 1){
|
|
| 826 | + $lb = "\r\n"; |
|
| 827 | + } else {
|
|
| 828 | + $pos = strpos($data,"\n\n"); |
|
| 829 | + if($pos > 1){
|
|
| 830 | + $lb = "\n"; |
|
| 831 | + } |
|
| 832 | + } |
|
| 833 | + // remove 100 headers |
|
| 834 | + if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
|
|
| 835 | + unset($lb); |
|
| 836 | + $data = ''; |
|
| 837 | + }// |
|
| 838 | + } |
|
| 839 | + // store header data |
|
| 840 | + $this->incoming_payload .= $data; |
|
| 841 | + $this->debug('found end of headers after length ' . strlen($data));
|
|
| 842 | + // process headers |
|
| 843 | + $header_data = trim(substr($data,0,$pos)); |
|
| 844 | + $header_array = explode($lb,$header_data); |
|
| 845 | + $this->incoming_headers = array(); |
|
| 846 | + $this->incoming_cookies = array(); |
|
| 847 | + foreach($header_array as $header_line){
|
|
| 848 | + $arr = explode(':',$header_line, 2);
|
|
| 849 | + if(count($arr) > 1){
|
|
| 850 | + $header_name = strtolower(trim($arr[0])); |
|
| 851 | + $this->incoming_headers[$header_name] = trim($arr[1]); |
|
| 852 | + if ($header_name == 'set-cookie') {
|
|
| 853 | + // TODO: allow multiple cookies from parseCookie |
|
| 854 | + $cookie = $this->parseCookie(trim($arr[1])); |
|
| 855 | + if ($cookie) {
|
|
| 856 | + $this->incoming_cookies[] = $cookie; |
|
| 857 | + $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
|
|
| 858 | + } else {
|
|
| 859 | + $this->debug('did not find cookie in ' . trim($arr[1]));
|
|
| 860 | + } |
|
| 861 | + } |
|
| 862 | + } else if (isset($header_name)) {
|
|
| 863 | + // append continuation line to previous header |
|
| 864 | + $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | 867 | |
| 868 | - // loop until msg has been received |
|
| 869 | - if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
|
|
| 870 | - $content_length = 2147483647; // ignore any content-length header |
|
| 871 | - $chunked = true; |
|
| 872 | - $this->debug("want to read chunked content");
|
|
| 873 | - } elseif (isset($this->incoming_headers['content-length'])) {
|
|
| 874 | - $content_length = $this->incoming_headers['content-length']; |
|
| 875 | - $chunked = false; |
|
| 876 | - $this->debug("want to read content of length $content_length");
|
|
| 877 | - } else {
|
|
| 878 | - $content_length = 2147483647; |
|
| 879 | - $chunked = false; |
|
| 880 | - $this->debug("want to read content to EOF");
|
|
| 881 | - } |
|
| 882 | - $data = ''; |
|
| 883 | - do {
|
|
| 884 | - if ($chunked) {
|
|
| 885 | - $tmp = fgets($this->fp, 256); |
|
| 886 | - $tmplen = strlen($tmp); |
|
| 887 | - $this->debug("read chunk line of $tmplen bytes");
|
|
| 888 | - if ($tmplen == 0) {
|
|
| 889 | - $this->incoming_payload = $data; |
|
| 890 | - $this->debug('socket read of chunk length timed out after length ' . strlen($data));
|
|
| 891 | - $this->debug("read before timeout:\n" . $data);
|
|
| 892 | - $this->setError('socket read of chunk length timed out');
|
|
| 893 | - return false; |
|
| 894 | - } |
|
| 895 | - $content_length = hexdec(trim($tmp)); |
|
| 896 | - $this->debug("chunk length $content_length");
|
|
| 897 | - } |
|
| 898 | - $strlen = 0; |
|
| 899 | - while (($strlen < $content_length) && (!feof($this->fp))) {
|
|
| 900 | - $readlen = min(8192, $content_length - $strlen); |
|
| 901 | - $tmp = fread($this->fp, $readlen); |
|
| 902 | - $tmplen = strlen($tmp); |
|
| 903 | - $this->debug("read buffer of $tmplen bytes");
|
|
| 904 | - if (($tmplen == 0) && (!feof($this->fp))) {
|
|
| 905 | - $this->incoming_payload = $data; |
|
| 906 | - $this->debug('socket read of body timed out after length ' . strlen($data));
|
|
| 907 | - $this->debug("read before timeout:\n" . $data);
|
|
| 908 | - $this->setError('socket read of body timed out');
|
|
| 909 | - return false; |
|
| 910 | - } |
|
| 911 | - $strlen += $tmplen; |
|
| 912 | - $data .= $tmp; |
|
| 913 | - } |
|
| 914 | - if ($chunked && ($content_length > 0)) {
|
|
| 915 | - $tmp = fgets($this->fp, 256); |
|
| 916 | - $tmplen = strlen($tmp); |
|
| 917 | - $this->debug("read chunk terminator of $tmplen bytes");
|
|
| 918 | - if ($tmplen == 0) {
|
|
| 919 | - $this->incoming_payload = $data; |
|
| 920 | - $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
|
|
| 921 | - $this->debug("read before timeout:\n" . $data);
|
|
| 922 | - $this->setError('socket read of chunk terminator timed out');
|
|
| 923 | - return false; |
|
| 924 | - } |
|
| 925 | - } |
|
| 926 | - } while ($chunked && ($content_length > 0) && (!feof($this->fp))); |
|
| 927 | - if (feof($this->fp)) {
|
|
| 928 | - $this->debug('read to EOF');
|
|
| 929 | - } |
|
| 930 | - $this->debug('read body of length ' . strlen($data));
|
|
| 931 | - $this->incoming_payload .= $data; |
|
| 932 | - $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
|
|
| 868 | + // loop until msg has been received |
|
| 869 | + if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
|
|
| 870 | + $content_length = 2147483647; // ignore any content-length header |
|
| 871 | + $chunked = true; |
|
| 872 | + $this->debug("want to read chunked content");
|
|
| 873 | + } elseif (isset($this->incoming_headers['content-length'])) {
|
|
| 874 | + $content_length = $this->incoming_headers['content-length']; |
|
| 875 | + $chunked = false; |
|
| 876 | + $this->debug("want to read content of length $content_length");
|
|
| 877 | + } else {
|
|
| 878 | + $content_length = 2147483647; |
|
| 879 | + $chunked = false; |
|
| 880 | + $this->debug("want to read content to EOF");
|
|
| 881 | + } |
|
| 882 | + $data = ''; |
|
| 883 | + do {
|
|
| 884 | + if ($chunked) {
|
|
| 885 | + $tmp = fgets($this->fp, 256); |
|
| 886 | + $tmplen = strlen($tmp); |
|
| 887 | + $this->debug("read chunk line of $tmplen bytes");
|
|
| 888 | + if ($tmplen == 0) {
|
|
| 889 | + $this->incoming_payload = $data; |
|
| 890 | + $this->debug('socket read of chunk length timed out after length ' . strlen($data));
|
|
| 891 | + $this->debug("read before timeout:\n" . $data);
|
|
| 892 | + $this->setError('socket read of chunk length timed out');
|
|
| 893 | + return false; |
|
| 894 | + } |
|
| 895 | + $content_length = hexdec(trim($tmp)); |
|
| 896 | + $this->debug("chunk length $content_length");
|
|
| 897 | + } |
|
| 898 | + $strlen = 0; |
|
| 899 | + while (($strlen < $content_length) && (!feof($this->fp))) {
|
|
| 900 | + $readlen = min(8192, $content_length - $strlen); |
|
| 901 | + $tmp = fread($this->fp, $readlen); |
|
| 902 | + $tmplen = strlen($tmp); |
|
| 903 | + $this->debug("read buffer of $tmplen bytes");
|
|
| 904 | + if (($tmplen == 0) && (!feof($this->fp))) {
|
|
| 905 | + $this->incoming_payload = $data; |
|
| 906 | + $this->debug('socket read of body timed out after length ' . strlen($data));
|
|
| 907 | + $this->debug("read before timeout:\n" . $data);
|
|
| 908 | + $this->setError('socket read of body timed out');
|
|
| 909 | + return false; |
|
| 910 | + } |
|
| 911 | + $strlen += $tmplen; |
|
| 912 | + $data .= $tmp; |
|
| 913 | + } |
|
| 914 | + if ($chunked && ($content_length > 0)) {
|
|
| 915 | + $tmp = fgets($this->fp, 256); |
|
| 916 | + $tmplen = strlen($tmp); |
|
| 917 | + $this->debug("read chunk terminator of $tmplen bytes");
|
|
| 918 | + if ($tmplen == 0) {
|
|
| 919 | + $this->incoming_payload = $data; |
|
| 920 | + $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
|
|
| 921 | + $this->debug("read before timeout:\n" . $data);
|
|
| 922 | + $this->setError('socket read of chunk terminator timed out');
|
|
| 923 | + return false; |
|
| 924 | + } |
|
| 925 | + } |
|
| 926 | + } while ($chunked && ($content_length > 0) && (!feof($this->fp))); |
|
| 927 | + if (feof($this->fp)) {
|
|
| 928 | + $this->debug('read to EOF');
|
|
| 929 | + } |
|
| 930 | + $this->debug('read body of length ' . strlen($data));
|
|
| 931 | + $this->incoming_payload .= $data; |
|
| 932 | + $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
|
|
| 933 | 933 | |
| 934 | - // close filepointer |
|
| 935 | - if( |
|
| 936 | - (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || |
|
| 937 | - (! $this->persistentConnection) || feof($this->fp)){
|
|
| 938 | - fclose($this->fp); |
|
| 939 | - $this->fp = false; |
|
| 940 | - $this->debug('closed socket');
|
|
| 941 | - } |
|
| 934 | + // close filepointer |
|
| 935 | + if( |
|
| 936 | + (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || |
|
| 937 | + (! $this->persistentConnection) || feof($this->fp)){
|
|
| 938 | + fclose($this->fp); |
|
| 939 | + $this->fp = false; |
|
| 940 | + $this->debug('closed socket');
|
|
| 941 | + } |
|
| 942 | 942 | |
| 943 | - // connection was closed unexpectedly |
|
| 944 | - if($this->incoming_payload == ''){
|
|
| 945 | - $this->setError('no response from server');
|
|
| 946 | - return false; |
|
| 947 | - } |
|
| 943 | + // connection was closed unexpectedly |
|
| 944 | + if($this->incoming_payload == ''){
|
|
| 945 | + $this->setError('no response from server');
|
|
| 946 | + return false; |
|
| 947 | + } |
|
| 948 | 948 | |
| 949 | - // decode transfer-encoding |
|
| 949 | + // decode transfer-encoding |
|
| 950 | 950 | // if(isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked'){
|
| 951 | 951 | // if(!$data = $this->decodeChunked($data, $lb)){
|
| 952 | 952 | // $this->setError('Decoding of chunked data failed');
|
| 953 | 953 | // return false; |
| 954 | 954 | // } |
| 955 | - //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>"; |
|
| 956 | - // set decoded payload |
|
| 955 | + //print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>"; |
|
| 956 | + // set decoded payload |
|
| 957 | 957 | // $this->incoming_payload = $header_data.$lb.$lb.$data; |
| 958 | 958 | // } |
| 959 | 959 | |
| 960 | - } else if ($this->io_method() == 'curl') {
|
|
| 961 | - // send and receive |
|
| 962 | - $this->debug('send and receive with cURL');
|
|
| 963 | - $this->incoming_payload = curl_exec($this->ch); |
|
| 964 | - $data = $this->incoming_payload; |
|
| 960 | + } else if ($this->io_method() == 'curl') {
|
|
| 961 | + // send and receive |
|
| 962 | + $this->debug('send and receive with cURL');
|
|
| 963 | + $this->incoming_payload = curl_exec($this->ch); |
|
| 964 | + $data = $this->incoming_payload; |
|
| 965 | 965 | |
| 966 | 966 | $cErr = curl_error($this->ch); |
| 967 | - if ($cErr != '') {
|
|
| 968 | - $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>'; |
|
| 969 | - // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE |
|
| 970 | - foreach(curl_getinfo($this->ch) as $k => $v){
|
|
| 971 | - $err .= "$k: $v<br>"; |
|
| 972 | - } |
|
| 973 | - $this->debug($err); |
|
| 974 | - $this->setError($err); |
|
| 975 | - curl_close($this->ch); |
|
| 976 | - return false; |
|
| 977 | - } else {
|
|
| 978 | - //echo '<pre>'; |
|
| 979 | - //var_dump(curl_getinfo($this->ch)); |
|
| 980 | - //echo '</pre>'; |
|
| 981 | - } |
|
| 982 | - // close curl |
|
| 983 | - $this->debug('No cURL error, closing cURL');
|
|
| 984 | - curl_close($this->ch); |
|
| 967 | + if ($cErr != '') {
|
|
| 968 | + $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>'; |
|
| 969 | + // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE |
|
| 970 | + foreach(curl_getinfo($this->ch) as $k => $v){
|
|
| 971 | + $err .= "$k: $v<br>"; |
|
| 972 | + } |
|
| 973 | + $this->debug($err); |
|
| 974 | + $this->setError($err); |
|
| 975 | + curl_close($this->ch); |
|
| 976 | + return false; |
|
| 977 | + } else {
|
|
| 978 | + //echo '<pre>'; |
|
| 979 | + //var_dump(curl_getinfo($this->ch)); |
|
| 980 | + //echo '</pre>'; |
|
| 981 | + } |
|
| 982 | + // close curl |
|
| 983 | + $this->debug('No cURL error, closing cURL');
|
|
| 984 | + curl_close($this->ch); |
|
| 985 | 985 | |
| 986 | - // try removing skippable headers |
|
| 987 | - $savedata = $data; |
|
| 988 | - while ($this->isSkippableCurlHeader($data)) {
|
|
| 989 | - $this->debug("Found HTTP header to skip");
|
|
| 990 | - if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 991 | - $data = ltrim(substr($data,$pos)); |
|
| 992 | - } elseif($pos = strpos($data,"\n\n") ) {
|
|
| 993 | - $data = ltrim(substr($data,$pos)); |
|
| 994 | - } |
|
| 995 | - } |
|
| 986 | + // try removing skippable headers |
|
| 987 | + $savedata = $data; |
|
| 988 | + while ($this->isSkippableCurlHeader($data)) {
|
|
| 989 | + $this->debug("Found HTTP header to skip");
|
|
| 990 | + if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 991 | + $data = ltrim(substr($data,$pos)); |
|
| 992 | + } elseif($pos = strpos($data,"\n\n") ) {
|
|
| 993 | + $data = ltrim(substr($data,$pos)); |
|
| 994 | + } |
|
| 995 | + } |
|
| 996 | 996 | |
| 997 | - if ($data == '') {
|
|
| 998 | - // have nothing left; just remove 100 header(s) |
|
| 999 | - $data = $savedata; |
|
| 1000 | - while (preg_match('/^HTTP\/1.1 100/',$data)) {
|
|
| 1001 | - if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 1002 | - $data = ltrim(substr($data,$pos)); |
|
| 1003 | - } elseif($pos = strpos($data,"\n\n") ) {
|
|
| 1004 | - $data = ltrim(substr($data,$pos)); |
|
| 1005 | - } |
|
| 1006 | - } |
|
| 1007 | - } |
|
| 997 | + if ($data == '') {
|
|
| 998 | + // have nothing left; just remove 100 header(s) |
|
| 999 | + $data = $savedata; |
|
| 1000 | + while (preg_match('/^HTTP\/1.1 100/',$data)) {
|
|
| 1001 | + if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 1002 | + $data = ltrim(substr($data,$pos)); |
|
| 1003 | + } elseif($pos = strpos($data,"\n\n") ) {
|
|
| 1004 | + $data = ltrim(substr($data,$pos)); |
|
| 1005 | + } |
|
| 1006 | + } |
|
| 1007 | + } |
|
| 1008 | 1008 | |
| 1009 | - // separate content from HTTP headers |
|
| 1010 | - if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 1011 | - $lb = "\r\n"; |
|
| 1012 | - } elseif( $pos = strpos($data,"\n\n")) {
|
|
| 1013 | - $lb = "\n"; |
|
| 1014 | - } else {
|
|
| 1015 | - $this->debug('no proper separation of headers and document');
|
|
| 1016 | - $this->setError('no proper separation of headers and document');
|
|
| 1017 | - return false; |
|
| 1018 | - } |
|
| 1019 | - $header_data = trim(substr($data,0,$pos)); |
|
| 1020 | - $header_array = explode($lb,$header_data); |
|
| 1021 | - $data = ltrim(substr($data,$pos)); |
|
| 1022 | - $this->debug('found proper separation of headers and document');
|
|
| 1023 | - $this->debug('cleaned data, stringlen: '.strlen($data));
|
|
| 1024 | - // clean headers |
|
| 1025 | - foreach ($header_array as $header_line) {
|
|
| 1026 | - $arr = explode(':',$header_line,2);
|
|
| 1027 | - if(count($arr) > 1){
|
|
| 1028 | - $header_name = strtolower(trim($arr[0])); |
|
| 1029 | - $this->incoming_headers[$header_name] = trim($arr[1]); |
|
| 1030 | - if ($header_name == 'set-cookie') {
|
|
| 1031 | - // TODO: allow multiple cookies from parseCookie |
|
| 1032 | - $cookie = $this->parseCookie(trim($arr[1])); |
|
| 1033 | - if ($cookie) {
|
|
| 1034 | - $this->incoming_cookies[] = $cookie; |
|
| 1035 | - $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
|
|
| 1036 | - } else {
|
|
| 1037 | - $this->debug('did not find cookie in ' . trim($arr[1]));
|
|
| 1038 | - } |
|
| 1039 | - } |
|
| 1040 | - } else if (isset($header_name)) {
|
|
| 1041 | - // append continuation line to previous header |
|
| 1042 | - $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; |
|
| 1043 | - } |
|
| 1044 | - } |
|
| 1045 | - } |
|
| 1009 | + // separate content from HTTP headers |
|
| 1010 | + if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 1011 | + $lb = "\r\n"; |
|
| 1012 | + } elseif( $pos = strpos($data,"\n\n")) {
|
|
| 1013 | + $lb = "\n"; |
|
| 1014 | + } else {
|
|
| 1015 | + $this->debug('no proper separation of headers and document');
|
|
| 1016 | + $this->setError('no proper separation of headers and document');
|
|
| 1017 | + return false; |
|
| 1018 | + } |
|
| 1019 | + $header_data = trim(substr($data,0,$pos)); |
|
| 1020 | + $header_array = explode($lb,$header_data); |
|
| 1021 | + $data = ltrim(substr($data,$pos)); |
|
| 1022 | + $this->debug('found proper separation of headers and document');
|
|
| 1023 | + $this->debug('cleaned data, stringlen: '.strlen($data));
|
|
| 1024 | + // clean headers |
|
| 1025 | + foreach ($header_array as $header_line) {
|
|
| 1026 | + $arr = explode(':',$header_line,2);
|
|
| 1027 | + if(count($arr) > 1){
|
|
| 1028 | + $header_name = strtolower(trim($arr[0])); |
|
| 1029 | + $this->incoming_headers[$header_name] = trim($arr[1]); |
|
| 1030 | + if ($header_name == 'set-cookie') {
|
|
| 1031 | + // TODO: allow multiple cookies from parseCookie |
|
| 1032 | + $cookie = $this->parseCookie(trim($arr[1])); |
|
| 1033 | + if ($cookie) {
|
|
| 1034 | + $this->incoming_cookies[] = $cookie; |
|
| 1035 | + $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
|
|
| 1036 | + } else {
|
|
| 1037 | + $this->debug('did not find cookie in ' . trim($arr[1]));
|
|
| 1038 | + } |
|
| 1039 | + } |
|
| 1040 | + } else if (isset($header_name)) {
|
|
| 1041 | + // append continuation line to previous header |
|
| 1042 | + $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; |
|
| 1043 | + } |
|
| 1044 | + } |
|
| 1045 | + } |
|
| 1046 | 1046 | |
| 1047 | - $this->response_status_line = $header_array[0]; |
|
| 1048 | - $arr = explode(' ', $this->response_status_line, 3);
|
|
| 1049 | - $http_version = $arr[0]; |
|
| 1050 | - $http_status = intval($arr[1]); |
|
| 1051 | - $http_reason = count($arr) > 2 ? $arr[2] : ''; |
|
| 1047 | + $this->response_status_line = $header_array[0]; |
|
| 1048 | + $arr = explode(' ', $this->response_status_line, 3);
|
|
| 1049 | + $http_version = $arr[0]; |
|
| 1050 | + $http_status = intval($arr[1]); |
|
| 1051 | + $http_reason = count($arr) > 2 ? $arr[2] : ''; |
|
| 1052 | 1052 | |
| 1053 | - // see if we need to resend the request with http digest authentication |
|
| 1054 | - if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
|
|
| 1055 | - $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
|
|
| 1056 | - $this->setURL($this->incoming_headers['location']); |
|
| 1057 | - $this->tryagain = true; |
|
| 1058 | - return false; |
|
| 1059 | - } |
|
| 1053 | + // see if we need to resend the request with http digest authentication |
|
| 1054 | + if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
|
|
| 1055 | + $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
|
|
| 1056 | + $this->setURL($this->incoming_headers['location']); |
|
| 1057 | + $this->tryagain = true; |
|
| 1058 | + return false; |
|
| 1059 | + } |
|
| 1060 | 1060 | |
| 1061 | - // see if we need to resend the request with http digest authentication |
|
| 1062 | - if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
|
|
| 1063 | - $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
|
|
| 1064 | - if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
|
|
| 1065 | - $this->debug('Server wants digest authentication');
|
|
| 1066 | - // remove "Digest " from our elements |
|
| 1067 | - $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
|
|
| 1061 | + // see if we need to resend the request with http digest authentication |
|
| 1062 | + if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
|
|
| 1063 | + $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
|
|
| 1064 | + if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
|
|
| 1065 | + $this->debug('Server wants digest authentication');
|
|
| 1066 | + // remove "Digest " from our elements |
|
| 1067 | + $digestString = str_replace('Digest ', '', $this->incoming_headers['www-authenticate']);
|
|
| 1068 | 1068 | |
| 1069 | - // parse elements into array |
|
| 1070 | - $digestElements = explode(',', $digestString);
|
|
| 1071 | - foreach ($digestElements as $val) {
|
|
| 1072 | - $tempElement = explode('=', trim($val), 2);
|
|
| 1073 | - $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
|
|
| 1074 | - } |
|
| 1069 | + // parse elements into array |
|
| 1070 | + $digestElements = explode(',', $digestString);
|
|
| 1071 | + foreach ($digestElements as $val) {
|
|
| 1072 | + $tempElement = explode('=', trim($val), 2);
|
|
| 1073 | + $digestRequest[$tempElement[0]] = str_replace("\"", '', $tempElement[1]);
|
|
| 1074 | + } |
|
| 1075 | 1075 | |
| 1076 | - // should have (at least) qop, realm, nonce |
|
| 1077 | - if (isset($digestRequest['nonce'])) {
|
|
| 1078 | - $this->setCredentials($this->username, $this->password, 'digest', $digestRequest); |
|
| 1079 | - $this->tryagain = true; |
|
| 1080 | - return false; |
|
| 1081 | - } |
|
| 1082 | - } |
|
| 1083 | - $this->debug('HTTP authentication failed');
|
|
| 1084 | - $this->setError('HTTP authentication failed');
|
|
| 1085 | - return false; |
|
| 1086 | - } |
|
| 1076 | + // should have (at least) qop, realm, nonce |
|
| 1077 | + if (isset($digestRequest['nonce'])) {
|
|
| 1078 | + $this->setCredentials($this->username, $this->password, 'digest', $digestRequest); |
|
| 1079 | + $this->tryagain = true; |
|
| 1080 | + return false; |
|
| 1081 | + } |
|
| 1082 | + } |
|
| 1083 | + $this->debug('HTTP authentication failed');
|
|
| 1084 | + $this->setError('HTTP authentication failed');
|
|
| 1085 | + return false; |
|
| 1086 | + } |
|
| 1087 | 1087 | |
| 1088 | - if ( |
|
| 1089 | - ($http_status >= 300 && $http_status <= 307) || |
|
| 1090 | - ($http_status >= 400 && $http_status <= 417) || |
|
| 1091 | - ($http_status >= 501 && $http_status <= 505) |
|
| 1092 | - ) {
|
|
| 1093 | - $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
|
|
| 1094 | - return false; |
|
| 1095 | - } |
|
| 1088 | + if ( |
|
| 1089 | + ($http_status >= 300 && $http_status <= 307) || |
|
| 1090 | + ($http_status >= 400 && $http_status <= 417) || |
|
| 1091 | + ($http_status >= 501 && $http_status <= 505) |
|
| 1092 | + ) {
|
|
| 1093 | + $this->setError("Unsupported HTTP response status $http_status $http_reason (soapclient->response has contents of the response)");
|
|
| 1094 | + return false; |
|
| 1095 | + } |
|
| 1096 | 1096 | |
| 1097 | - // decode content-encoding |
|
| 1098 | - if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
|
|
| 1099 | - if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
|
|
| 1100 | - // if decoding works, use it. else assume data wasn't gzencoded |
|
| 1101 | - if(function_exists('gzinflate')){
|
|
| 1102 | - //$timer->setMarker('starting decoding of gzip/deflated content');
|
|
| 1103 | - // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress) |
|
| 1104 | - // this means there are no Zlib headers, although there should be |
|
| 1105 | - $this->debug('The gzinflate function exists');
|
|
| 1106 | - $datalen = strlen($data); |
|
| 1107 | - if ($this->incoming_headers['content-encoding'] == 'deflate') {
|
|
| 1108 | - if ($degzdata = @gzinflate($data)) {
|
|
| 1109 | - $data = $degzdata; |
|
| 1110 | - $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
|
|
| 1111 | - if (strlen($data) < $datalen) {
|
|
| 1112 | - // test for the case that the payload has been compressed twice |
|
| 1113 | - $this->debug('The inflated payload is smaller than the gzipped one; try again');
|
|
| 1114 | - if ($degzdata = @gzinflate($data)) {
|
|
| 1115 | - $data = $degzdata; |
|
| 1116 | - $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
|
|
| 1117 | - } |
|
| 1118 | - } |
|
| 1119 | - } else {
|
|
| 1120 | - $this->debug('Error using gzinflate to inflate the payload');
|
|
| 1121 | - $this->setError('Error using gzinflate to inflate the payload');
|
|
| 1122 | - } |
|
| 1123 | - } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
|
|
| 1124 | - if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
|
|
| 1125 | - $data = $degzdata; |
|
| 1126 | - $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
|
|
| 1127 | - if (strlen($data) < $datalen) {
|
|
| 1128 | - // test for the case that the payload has been compressed twice |
|
| 1129 | - $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
|
|
| 1130 | - if ($degzdata = @gzinflate(substr($data, 10))) {
|
|
| 1131 | - $data = $degzdata; |
|
| 1132 | - $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
|
|
| 1133 | - } |
|
| 1134 | - } |
|
| 1135 | - } else {
|
|
| 1136 | - $this->debug('Error using gzinflate to un-gzip the payload');
|
|
| 1137 | - $this->setError('Error using gzinflate to un-gzip the payload');
|
|
| 1138 | - } |
|
| 1139 | - } |
|
| 1140 | - //$timer->setMarker('finished decoding of gzip/deflated content');
|
|
| 1141 | - //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>"; |
|
| 1142 | - // set decoded payload |
|
| 1143 | - $this->incoming_payload = $header_data.$lb.$lb.$data; |
|
| 1144 | - } else {
|
|
| 1145 | - $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
|
|
| 1146 | - $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
|
|
| 1147 | - } |
|
| 1148 | - } else {
|
|
| 1149 | - $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
|
|
| 1150 | - $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
|
|
| 1151 | - } |
|
| 1152 | - } else {
|
|
| 1153 | - $this->debug('No Content-Encoding header');
|
|
| 1154 | - } |
|
| 1097 | + // decode content-encoding |
|
| 1098 | + if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
|
|
| 1099 | + if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
|
|
| 1100 | + // if decoding works, use it. else assume data wasn't gzencoded |
|
| 1101 | + if(function_exists('gzinflate')){
|
|
| 1102 | + //$timer->setMarker('starting decoding of gzip/deflated content');
|
|
| 1103 | + // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress) |
|
| 1104 | + // this means there are no Zlib headers, although there should be |
|
| 1105 | + $this->debug('The gzinflate function exists');
|
|
| 1106 | + $datalen = strlen($data); |
|
| 1107 | + if ($this->incoming_headers['content-encoding'] == 'deflate') {
|
|
| 1108 | + if ($degzdata = @gzinflate($data)) {
|
|
| 1109 | + $data = $degzdata; |
|
| 1110 | + $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
|
|
| 1111 | + if (strlen($data) < $datalen) {
|
|
| 1112 | + // test for the case that the payload has been compressed twice |
|
| 1113 | + $this->debug('The inflated payload is smaller than the gzipped one; try again');
|
|
| 1114 | + if ($degzdata = @gzinflate($data)) {
|
|
| 1115 | + $data = $degzdata; |
|
| 1116 | + $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
|
|
| 1117 | + } |
|
| 1118 | + } |
|
| 1119 | + } else {
|
|
| 1120 | + $this->debug('Error using gzinflate to inflate the payload');
|
|
| 1121 | + $this->setError('Error using gzinflate to inflate the payload');
|
|
| 1122 | + } |
|
| 1123 | + } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
|
|
| 1124 | + if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
|
|
| 1125 | + $data = $degzdata; |
|
| 1126 | + $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
|
|
| 1127 | + if (strlen($data) < $datalen) {
|
|
| 1128 | + // test for the case that the payload has been compressed twice |
|
| 1129 | + $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
|
|
| 1130 | + if ($degzdata = @gzinflate(substr($data, 10))) {
|
|
| 1131 | + $data = $degzdata; |
|
| 1132 | + $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
|
|
| 1133 | + } |
|
| 1134 | + } |
|
| 1135 | + } else {
|
|
| 1136 | + $this->debug('Error using gzinflate to un-gzip the payload');
|
|
| 1137 | + $this->setError('Error using gzinflate to un-gzip the payload');
|
|
| 1138 | + } |
|
| 1139 | + } |
|
| 1140 | + //$timer->setMarker('finished decoding of gzip/deflated content');
|
|
| 1141 | + //print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>"; |
|
| 1142 | + // set decoded payload |
|
| 1143 | + $this->incoming_payload = $header_data.$lb.$lb.$data; |
|
| 1144 | + } else {
|
|
| 1145 | + $this->debug('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
|
|
| 1146 | + $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
|
|
| 1147 | + } |
|
| 1148 | + } else {
|
|
| 1149 | + $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
|
|
| 1150 | + $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
|
|
| 1151 | + } |
|
| 1152 | + } else {
|
|
| 1153 | + $this->debug('No Content-Encoding header');
|
|
| 1154 | + } |
|
| 1155 | 1155 | |
| 1156 | - if(strlen($data) == 0){
|
|
| 1157 | - $this->debug('no data after headers!');
|
|
| 1158 | - $this->setError('no data present after HTTP headers');
|
|
| 1159 | - return false; |
|
| 1160 | - } |
|
| 1156 | + if(strlen($data) == 0){
|
|
| 1157 | + $this->debug('no data after headers!');
|
|
| 1158 | + $this->setError('no data present after HTTP headers');
|
|
| 1159 | + return false; |
|
| 1160 | + } |
|
| 1161 | 1161 | |
| 1162 | - return $data; |
|
| 1163 | - } |
|
| 1162 | + return $data; |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | - /** |
|
| 1166 | - * sets the content-type for the SOAP message to be sent |
|
| 1167 | - * |
|
| 1168 | - * @param string $type the content type, MIME style |
|
| 1169 | - * @param mixed $charset character set used for encoding (or false) |
|
| 1170 | - * @access public |
|
| 1171 | - */ |
|
| 1172 | - function setContentType($type, $charset = false) {
|
|
| 1173 | - $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
|
|
| 1174 | - } |
|
| 1165 | + /** |
|
| 1166 | + * sets the content-type for the SOAP message to be sent |
|
| 1167 | + * |
|
| 1168 | + * @param string $type the content type, MIME style |
|
| 1169 | + * @param mixed $charset character set used for encoding (or false) |
|
| 1170 | + * @access public |
|
| 1171 | + */ |
|
| 1172 | + function setContentType($type, $charset = false) {
|
|
| 1173 | + $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
|
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | - /** |
|
| 1177 | - * specifies that an HTTP persistent connection should be used |
|
| 1178 | - * |
|
| 1179 | - * @return boolean whether the request was honored by this method. |
|
| 1180 | - * @access public |
|
| 1181 | - */ |
|
| 1182 | - function usePersistentConnection(){
|
|
| 1183 | - if (isset($this->outgoing_headers['Accept-Encoding'])) {
|
|
| 1184 | - return false; |
|
| 1185 | - } |
|
| 1186 | - $this->protocol_version = '1.1'; |
|
| 1187 | - $this->persistentConnection = true; |
|
| 1188 | - $this->setHeader('Connection', 'Keep-Alive');
|
|
| 1189 | - return true; |
|
| 1190 | - } |
|
| 1176 | + /** |
|
| 1177 | + * specifies that an HTTP persistent connection should be used |
|
| 1178 | + * |
|
| 1179 | + * @return boolean whether the request was honored by this method. |
|
| 1180 | + * @access public |
|
| 1181 | + */ |
|
| 1182 | + function usePersistentConnection(){
|
|
| 1183 | + if (isset($this->outgoing_headers['Accept-Encoding'])) {
|
|
| 1184 | + return false; |
|
| 1185 | + } |
|
| 1186 | + $this->protocol_version = '1.1'; |
|
| 1187 | + $this->persistentConnection = true; |
|
| 1188 | + $this->setHeader('Connection', 'Keep-Alive');
|
|
| 1189 | + return true; |
|
| 1190 | + } |
|
| 1191 | 1191 | |
| 1192 | - /** |
|
| 1193 | - * parse an incoming Cookie into it's parts |
|
| 1194 | - * |
|
| 1195 | - * @param string $cookie_str content of cookie |
|
| 1196 | - * @return array with data of that cookie |
|
| 1197 | - * @access private |
|
| 1198 | - */ |
|
| 1199 | - /* |
|
| 1192 | + /** |
|
| 1193 | + * parse an incoming Cookie into it's parts |
|
| 1194 | + * |
|
| 1195 | + * @param string $cookie_str content of cookie |
|
| 1196 | + * @return array with data of that cookie |
|
| 1197 | + * @access private |
|
| 1198 | + */ |
|
| 1199 | + /* |
|
| 1200 | 1200 | * TODO: allow a Set-Cookie string to be parsed into multiple cookies |
| 1201 | 1201 | */ |
| 1202 | - function parseCookie($cookie_str) {
|
|
| 1203 | - $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
|
|
| 1204 | - $data = preg_split('/;/', $cookie_str);
|
|
| 1205 | - $value_str = $data[0]; |
|
| 1202 | + function parseCookie($cookie_str) {
|
|
| 1203 | + $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
|
|
| 1204 | + $data = preg_split('/;/', $cookie_str);
|
|
| 1205 | + $value_str = $data[0]; |
|
| 1206 | 1206 | |
| 1207 | - $cookie_param = 'domain='; |
|
| 1208 | - $start = strpos($cookie_str, $cookie_param); |
|
| 1209 | - if ($start > 0) {
|
|
| 1210 | - $domain = substr($cookie_str, $start + strlen($cookie_param)); |
|
| 1211 | - $domain = substr($domain, 0, strpos($domain, ';')); |
|
| 1212 | - } else {
|
|
| 1213 | - $domain = ''; |
|
| 1214 | - } |
|
| 1207 | + $cookie_param = 'domain='; |
|
| 1208 | + $start = strpos($cookie_str, $cookie_param); |
|
| 1209 | + if ($start > 0) {
|
|
| 1210 | + $domain = substr($cookie_str, $start + strlen($cookie_param)); |
|
| 1211 | + $domain = substr($domain, 0, strpos($domain, ';')); |
|
| 1212 | + } else {
|
|
| 1213 | + $domain = ''; |
|
| 1214 | + } |
|
| 1215 | 1215 | |
| 1216 | - $cookie_param = 'expires='; |
|
| 1217 | - $start = strpos($cookie_str, $cookie_param); |
|
| 1218 | - if ($start > 0) {
|
|
| 1219 | - $expires = substr($cookie_str, $start + strlen($cookie_param)); |
|
| 1220 | - $expires = substr($expires, 0, strpos($expires, ';')); |
|
| 1221 | - } else {
|
|
| 1222 | - $expires = ''; |
|
| 1223 | - } |
|
| 1216 | + $cookie_param = 'expires='; |
|
| 1217 | + $start = strpos($cookie_str, $cookie_param); |
|
| 1218 | + if ($start > 0) {
|
|
| 1219 | + $expires = substr($cookie_str, $start + strlen($cookie_param)); |
|
| 1220 | + $expires = substr($expires, 0, strpos($expires, ';')); |
|
| 1221 | + } else {
|
|
| 1222 | + $expires = ''; |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | - $cookie_param = 'path='; |
|
| 1226 | - $start = strpos($cookie_str, $cookie_param); |
|
| 1227 | - if ( $start > 0 ) {
|
|
| 1228 | - $path = substr($cookie_str, $start + strlen($cookie_param)); |
|
| 1229 | - $path = substr($path, 0, strpos($path, ';')); |
|
| 1230 | - } else {
|
|
| 1231 | - $path = '/'; |
|
| 1232 | - } |
|
| 1225 | + $cookie_param = 'path='; |
|
| 1226 | + $start = strpos($cookie_str, $cookie_param); |
|
| 1227 | + if ( $start > 0 ) {
|
|
| 1228 | + $path = substr($cookie_str, $start + strlen($cookie_param)); |
|
| 1229 | + $path = substr($path, 0, strpos($path, ';')); |
|
| 1230 | + } else {
|
|
| 1231 | + $path = '/'; |
|
| 1232 | + } |
|
| 1233 | 1233 | |
| 1234 | - $cookie_param = ';secure;'; |
|
| 1235 | - if (strpos($cookie_str, $cookie_param) !== FALSE) {
|
|
| 1236 | - $secure = true; |
|
| 1237 | - } else {
|
|
| 1238 | - $secure = false; |
|
| 1239 | - } |
|
| 1234 | + $cookie_param = ';secure;'; |
|
| 1235 | + if (strpos($cookie_str, $cookie_param) !== FALSE) {
|
|
| 1236 | + $secure = true; |
|
| 1237 | + } else {
|
|
| 1238 | + $secure = false; |
|
| 1239 | + } |
|
| 1240 | 1240 | |
| 1241 | - $sep_pos = strpos($value_str, '='); |
|
| 1241 | + $sep_pos = strpos($value_str, '='); |
|
| 1242 | 1242 | |
| 1243 | - if ($sep_pos) {
|
|
| 1244 | - $name = substr($value_str, 0, $sep_pos); |
|
| 1245 | - $value = substr($value_str, $sep_pos + 1); |
|
| 1246 | - $cookie= array( 'name' => $name, |
|
| 1247 | - 'value' => $value, |
|
| 1248 | - 'domain' => $domain, |
|
| 1249 | - 'path' => $path, |
|
| 1250 | - 'expires' => $expires, |
|
| 1251 | - 'secure' => $secure |
|
| 1252 | - ); |
|
| 1253 | - return $cookie; |
|
| 1254 | - } |
|
| 1255 | - return false; |
|
| 1256 | - } |
|
| 1243 | + if ($sep_pos) {
|
|
| 1244 | + $name = substr($value_str, 0, $sep_pos); |
|
| 1245 | + $value = substr($value_str, $sep_pos + 1); |
|
| 1246 | + $cookie= array( 'name' => $name, |
|
| 1247 | + 'value' => $value, |
|
| 1248 | + 'domain' => $domain, |
|
| 1249 | + 'path' => $path, |
|
| 1250 | + 'expires' => $expires, |
|
| 1251 | + 'secure' => $secure |
|
| 1252 | + ); |
|
| 1253 | + return $cookie; |
|
| 1254 | + } |
|
| 1255 | + return false; |
|
| 1256 | + } |
|
| 1257 | 1257 | |
| 1258 | - /** |
|
| 1259 | - * sort out cookies for the current request |
|
| 1260 | - * |
|
| 1261 | - * @param array $cookies array with all cookies |
|
| 1262 | - * @param boolean $secure is the send-content secure or not? |
|
| 1263 | - * @return string for Cookie-HTTP-Header |
|
| 1264 | - * @access private |
|
| 1265 | - */ |
|
| 1266 | - function getCookiesForRequest($cookies, $secure=false) {
|
|
| 1267 | - $cookie_str = ''; |
|
| 1268 | - if ((! is_null($cookies)) && (is_array($cookies))) {
|
|
| 1269 | - foreach ($cookies as $cookie) {
|
|
| 1270 | - if (! is_array($cookie)) {
|
|
| 1271 | - continue; |
|
| 1272 | - } |
|
| 1273 | - $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
|
|
| 1274 | - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 1275 | - if (strtotime($cookie['expires']) <= time()) {
|
|
| 1276 | - $this->debug('cookie has expired');
|
|
| 1277 | - continue; |
|
| 1278 | - } |
|
| 1279 | - } |
|
| 1280 | - if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
|
|
| 1281 | - $domain = preg_quote($cookie['domain']); |
|
| 1282 | - if (! preg_match("'.*$domain$'i", $this->host)) {
|
|
| 1283 | - $this->debug('cookie has different domain');
|
|
| 1284 | - continue; |
|
| 1285 | - } |
|
| 1286 | - } |
|
| 1287 | - if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
|
|
| 1288 | - $path = preg_quote($cookie['path']); |
|
| 1289 | - if (! preg_match("'^$path.*'i", $this->path)) {
|
|
| 1290 | - $this->debug('cookie is for a different path');
|
|
| 1291 | - continue; |
|
| 1292 | - } |
|
| 1293 | - } |
|
| 1294 | - if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
|
|
| 1295 | - $this->debug('cookie is secure, transport is not');
|
|
| 1296 | - continue; |
|
| 1297 | - } |
|
| 1298 | - $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; '; |
|
| 1299 | - $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
|
|
| 1300 | - } |
|
| 1301 | - } |
|
| 1302 | - return $cookie_str; |
|
| 1303 | - } |
|
| 1258 | + /** |
|
| 1259 | + * sort out cookies for the current request |
|
| 1260 | + * |
|
| 1261 | + * @param array $cookies array with all cookies |
|
| 1262 | + * @param boolean $secure is the send-content secure or not? |
|
| 1263 | + * @return string for Cookie-HTTP-Header |
|
| 1264 | + * @access private |
|
| 1265 | + */ |
|
| 1266 | + function getCookiesForRequest($cookies, $secure=false) {
|
|
| 1267 | + $cookie_str = ''; |
|
| 1268 | + if ((! is_null($cookies)) && (is_array($cookies))) {
|
|
| 1269 | + foreach ($cookies as $cookie) {
|
|
| 1270 | + if (! is_array($cookie)) {
|
|
| 1271 | + continue; |
|
| 1272 | + } |
|
| 1273 | + $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
|
|
| 1274 | + if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 1275 | + if (strtotime($cookie['expires']) <= time()) {
|
|
| 1276 | + $this->debug('cookie has expired');
|
|
| 1277 | + continue; |
|
| 1278 | + } |
|
| 1279 | + } |
|
| 1280 | + if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
|
|
| 1281 | + $domain = preg_quote($cookie['domain']); |
|
| 1282 | + if (! preg_match("'.*$domain$'i", $this->host)) {
|
|
| 1283 | + $this->debug('cookie has different domain');
|
|
| 1284 | + continue; |
|
| 1285 | + } |
|
| 1286 | + } |
|
| 1287 | + if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
|
|
| 1288 | + $path = preg_quote($cookie['path']); |
|
| 1289 | + if (! preg_match("'^$path.*'i", $this->path)) {
|
|
| 1290 | + $this->debug('cookie is for a different path');
|
|
| 1291 | + continue; |
|
| 1292 | + } |
|
| 1293 | + } |
|
| 1294 | + if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
|
|
| 1295 | + $this->debug('cookie is secure, transport is not');
|
|
| 1296 | + continue; |
|
| 1297 | + } |
|
| 1298 | + $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; '; |
|
| 1299 | + $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
|
|
| 1300 | + } |
|
| 1301 | + } |
|
| 1302 | + return $cookie_str; |
|
| 1303 | + } |
|
| 1304 | 1304 | } |
| 1305 | 1305 | |
| 1306 | 1306 | |
@@ -29,18 +29,18 @@ discard block |
||
| 29 | 29 | var $incoming_cookies = array(); |
| 30 | 30 | var $outgoing_payload = ''; |
| 31 | 31 | var $incoming_payload = ''; |
| 32 | - var $response_status_line; // HTTP response status line |
|
| 32 | + var $response_status_line; // HTTP response status line |
|
| 33 | 33 | var $useSOAPAction = true; |
| 34 | 34 | var $persistentConnection = false; |
| 35 | - var $ch = false; // cURL handle |
|
| 36 | - var $ch_options = array(); // cURL custom options |
|
| 37 | - var $use_curl = false; // force cURL use |
|
| 38 | - var $proxy = null; // proxy information (associative array) |
|
| 35 | + var $ch = false; // cURL handle |
|
| 36 | + var $ch_options = array(); // cURL custom options |
|
| 37 | + var $use_curl = false; // force cURL use |
|
| 38 | + var $proxy = null; // proxy information (associative array) |
|
| 39 | 39 | var $username = ''; |
| 40 | 40 | var $password = ''; |
| 41 | 41 | var $authtype = ''; |
| 42 | 42 | var $digestRequest = array(); |
| 43 | - var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) |
|
| 43 | + var $certRequest = array(); // keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional) |
|
| 44 | 44 | // cainfofile: certificate authority file, e.g. '$pathToPemFiles/rootca.pem' |
| 45 | 45 | // sslcertfile: SSL certificate file, e.g. '$pathToPemFiles/mycert.pem' |
| 46 | 46 | // sslkeyfile: SSL key file, e.g. '$pathToPemFiles/mykey.pem' |
@@ -57,7 +57,7 @@ discard block |
||
| 57 | 57 | * @param boolean $use_curl Whether to try to force cURL use |
| 58 | 58 | * @access public |
| 59 | 59 | */ |
| 60 | - function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
|
|
| 60 | + function soap_transport_http($url, $curl_options = NULL, $use_curl = false) {
|
|
| 61 | 61 | parent::nusoap_base(); |
| 62 | 62 | $this->debug("ctor url=$url use_curl=$use_curl curl_options:");
|
| 63 | 63 | $this->appendDebug($this->varDump($curl_options)); |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | $this->ch_options = $curl_options; |
| 67 | 67 | } |
| 68 | 68 | $this->use_curl = $use_curl; |
| 69 | - preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 69 | + preg_match('/\$Revisio'.'n: ([^ ]+)/', $this->revision, $rev);
|
|
| 70 | 70 | $this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
|
| 71 | 71 | } |
| 72 | 72 | |
@@ -118,19 +118,19 @@ discard block |
||
| 118 | 118 | $this->url = $url; |
| 119 | 119 | |
| 120 | 120 | $u = parse_url($url); |
| 121 | - foreach($u as $k => $v){
|
|
| 121 | + foreach ($u as $k => $v) {
|
|
| 122 | 122 | $this->debug("parsed URL $k = $v");
|
| 123 | 123 | $this->$k = $v; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | // add any GET params to path |
| 127 | - if(isset($u['query']) && $u['query'] != ''){
|
|
| 128 | - $this->path .= '?' . $u['query']; |
|
| 127 | + if (isset($u['query']) && $u['query'] != '') {
|
|
| 128 | + $this->path .= '?'.$u['query']; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // set default port |
| 132 | - if(!isset($u['port'])){
|
|
| 133 | - if($u['scheme'] == 'https'){
|
|
| 132 | + if (!isset($u['port'])) {
|
|
| 133 | + if ($u['scheme'] == 'https') {
|
|
| 134 | 134 | $this->port = 443; |
| 135 | 135 | } else {
|
| 136 | 136 | $this->port = 80; |
@@ -174,7 +174,7 @@ discard block |
||
| 174 | 174 | * @return boolean true if connected, false if not |
| 175 | 175 | * @access private |
| 176 | 176 | */ |
| 177 | - function connect($connection_timeout=0,$response_timeout=30){
|
|
| 177 | + function connect($connection_timeout = 0, $response_timeout = 30) {
|
|
| 178 | 178 | // For PHP 4.3 with OpenSSL, change https scheme to ssl, then treat like |
| 179 | 179 | // "regular" socket. |
| 180 | 180 | // TODO: disabled for now because OpenSSL must be *compiled* in (not just |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | } |
| 199 | 199 | |
| 200 | 200 | // use persistent connection |
| 201 | - if($this->persistentConnection && isset($this->fp) && is_resource($this->fp)){
|
|
| 201 | + if ($this->persistentConnection && isset($this->fp) && is_resource($this->fp)) {
|
|
| 202 | 202 | if (!feof($this->fp)) {
|
| 203 | 203 | $this->debug('Re-use persistent connection');
|
| 204 | 204 | return true; |
@@ -209,20 +209,20 @@ discard block |
||
| 209 | 209 | |
| 210 | 210 | // munge host if using OpenSSL |
| 211 | 211 | if ($this->scheme == 'ssl') {
|
| 212 | - $host = 'ssl://' . $host; |
|
| 212 | + $host = 'ssl://'.$host; |
|
| 213 | 213 | } |
| 214 | - $this->debug('calling fsockopen with host ' . $host . ' connection_timeout ' . $connection_timeout);
|
|
| 214 | + $this->debug('calling fsockopen with host '.$host.' connection_timeout '.$connection_timeout);
|
|
| 215 | 215 | |
| 216 | 216 | // open socket |
| 217 | - if($connection_timeout > 0){
|
|
| 218 | - $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str, $connection_timeout); |
|
| 217 | + if ($connection_timeout > 0) {
|
|
| 218 | + $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str, $connection_timeout); |
|
| 219 | 219 | } else {
|
| 220 | - $this->fp = @fsockopen( $host, $this->port, $this->errno, $this->error_str); |
|
| 220 | + $this->fp = @fsockopen($host, $this->port, $this->errno, $this->error_str); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | // test pointer |
| 224 | - if(!$this->fp) {
|
|
| 225 | - $msg = 'Couldn\'t open socket connection to server ' . $this->url; |
|
| 224 | + if (!$this->fp) {
|
|
| 225 | + $msg = 'Couldn\'t open socket connection to server '.$this->url; |
|
| 226 | 226 | if ($this->errno) {
|
| 227 | 227 | $msg .= ', Error ('.$this->errno.'): '.$this->error_str;
|
| 228 | 228 | } else {
|
@@ -234,8 +234,8 @@ discard block |
||
| 234 | 234 | } |
| 235 | 235 | |
| 236 | 236 | // set response timeout |
| 237 | - $this->debug('set response timeout to ' . $response_timeout);
|
|
| 238 | - socket_set_timeout( $this->fp, $response_timeout); |
|
| 237 | + $this->debug('set response timeout to '.$response_timeout);
|
|
| 238 | + socket_set_timeout($this->fp, $response_timeout); |
|
| 239 | 239 | |
| 240 | 240 | $this->debug('socket connected');
|
| 241 | 241 | return true; |
@@ -394,8 +394,8 @@ discard block |
||
| 394 | 394 | $this->debug('cURL connection set up');
|
| 395 | 395 | return true; |
| 396 | 396 | } else {
|
| 397 | - $this->setError('Unknown scheme ' . $this->scheme);
|
|
| 398 | - $this->debug('Unknown scheme ' . $this->scheme);
|
|
| 397 | + $this->setError('Unknown scheme '.$this->scheme);
|
|
| 398 | + $this->debug('Unknown scheme '.$this->scheme);
|
|
| 399 | 399 | return false; |
| 400 | 400 | } |
| 401 | 401 | } |
@@ -410,7 +410,7 @@ discard block |
||
| 410 | 410 | * @return string data |
| 411 | 411 | * @access public |
| 412 | 412 | */ |
| 413 | - function send($data, $timeout=0, $response_timeout=30, $cookies=NULL) {
|
|
| 413 | + function send($data, $timeout = 0, $response_timeout = 30, $cookies = NULL) {
|
|
| 414 | 414 | |
| 415 | 415 | $this->debug('entered send() with data of length: '.strlen($data));
|
| 416 | 416 | |
@@ -420,12 +420,12 @@ discard block |
||
| 420 | 420 | $this->tryagain = false; |
| 421 | 421 | if ($tries++ < 2) {
|
| 422 | 422 | // make connnection |
| 423 | - if (!$this->connect($timeout, $response_timeout)){
|
|
| 423 | + if (!$this->connect($timeout, $response_timeout)) {
|
|
| 424 | 424 | return false; |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | // send request |
| 428 | - if (!$this->sendRequest($data, $cookies)){
|
|
| 428 | + if (!$this->sendRequest($data, $cookies)) {
|
|
| 429 | 429 | return false; |
| 430 | 430 | } |
| 431 | 431 | |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | * @access public |
| 452 | 452 | * @deprecated |
| 453 | 453 | */ |
| 454 | - function sendHTTPS($data, $timeout=0, $response_timeout=30, $cookies) {
|
|
| 454 | + function sendHTTPS($data, $timeout = 0, $response_timeout = 30, $cookies) {
|
|
| 455 | 455 | return $this->send($data, $timeout, $response_timeout, $cookies); |
| 456 | 456 | } |
| 457 | 457 | |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | $this->appendDebug($this->varDump($certRequest)); |
| 473 | 473 | // cf. RFC 2617 |
| 474 | 474 | if ($authtype == 'basic') {
|
| 475 | - $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':','',$username).':'.$password));
|
|
| 475 | + $this->setHeader('Authorization', 'Basic '.base64_encode(str_replace(':', '', $username).':'.$password));
|
|
| 476 | 476 | } elseif ($authtype == 'digest') {
|
| 477 | 477 | if (isset($digestRequest['nonce'])) {
|
| 478 | 478 | $digestRequest['nc'] = isset($digestRequest['nc']) ? $digestRequest['nc']++ : 1; |
@@ -480,16 +480,16 @@ discard block |
||
| 480 | 480 | // calculate the Digest hashes (calculate code based on digest implementation found at: http://www.rassoc.com/gregr/weblog/stories/2002/07/09/webServicesSecurityHttpDigestAuthenticationWithoutActiveDirectory.html) |
| 481 | 481 | |
| 482 | 482 | // A1 = unq(username-value) ":" unq(realm-value) ":" passwd |
| 483 | - $A1 = $username. ':' . (isset($digestRequest['realm']) ? $digestRequest['realm'] : '') . ':' . $password; |
|
| 483 | + $A1 = $username.':'.(isset($digestRequest['realm']) ? $digestRequest['realm'] : '').':'.$password; |
|
| 484 | 484 | |
| 485 | 485 | // H(A1) = MD5(A1) |
| 486 | 486 | $HA1 = md5($A1); |
| 487 | 487 | |
| 488 | 488 | // A2 = Method ":" digest-uri-value |
| 489 | - $A2 = $this->request_method . ':' . $this->digest_uri; |
|
| 489 | + $A2 = $this->request_method.':'.$this->digest_uri; |
|
| 490 | 490 | |
| 491 | 491 | // H(A2) |
| 492 | - $HA2 = md5($A2); |
|
| 492 | + $HA2 = md5($A2); |
|
| 493 | 493 | |
| 494 | 494 | // KD(secret, data) = H(concat(secret, ":", data)) |
| 495 | 495 | // if qop == auth: |
@@ -506,19 +506,19 @@ discard block |
||
| 506 | 506 | $nonce = isset($digestRequest['nonce']) ? $digestRequest['nonce'] : ''; |
| 507 | 507 | $cnonce = $nonce; |
| 508 | 508 | if ($digestRequest['qop'] != '') {
|
| 509 | - $unhashedDigest = $HA1 . ':' . $nonce . ':' . sprintf("%08d", $digestRequest['nc']) . ':' . $cnonce . ':' . $digestRequest['qop'] . ':' . $HA2;
|
|
| 509 | + $unhashedDigest = $HA1.':'.$nonce.':'.sprintf("%08d", $digestRequest['nc']).':'.$cnonce.':'.$digestRequest['qop'].':'.$HA2;
|
|
| 510 | 510 | } else {
|
| 511 | - $unhashedDigest = $HA1 . ':' . $nonce . ':' . $HA2; |
|
| 511 | + $unhashedDigest = $HA1.':'.$nonce.':'.$HA2; |
|
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | $hashedDigest = md5($unhashedDigest); |
| 515 | 515 | |
| 516 | 516 | $opaque = ''; |
| 517 | 517 | if (isset($digestRequest['opaque'])) {
|
| 518 | - $opaque = ', opaque="' . $digestRequest['opaque'] . '"'; |
|
| 518 | + $opaque = ', opaque="'.$digestRequest['opaque'].'"'; |
|
| 519 | 519 | } |
| 520 | 520 | |
| 521 | - $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 . '"');
|
|
| 521 | + $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.'"');
|
|
| 522 | 522 | } |
| 523 | 523 | } elseif ($authtype == 'certificate') {
|
| 524 | 524 | $this->certRequest = $certRequest; |
@@ -540,7 +540,7 @@ discard block |
||
| 540 | 540 | * @access public |
| 541 | 541 | */ |
| 542 | 542 | function setSOAPAction($soapaction) {
|
| 543 | - $this->setHeader('SOAPAction', '"' . $soapaction . '"');
|
|
| 543 | + $this->setHeader('SOAPAction', '"'.$soapaction.'"');
|
|
| 544 | 544 | } |
| 545 | 545 | |
| 546 | 546 | /** |
@@ -549,7 +549,7 @@ discard block |
||
| 549 | 549 | * @param string $enc encoding style. supported values: gzip, deflate, or both |
| 550 | 550 | * @access public |
| 551 | 551 | */ |
| 552 | - function setEncoding($enc='gzip, deflate') {
|
|
| 552 | + function setEncoding($enc = 'gzip, deflate') {
|
|
| 553 | 553 | if (function_exists('gzdeflate')) {
|
| 554 | 554 | $this->protocol_version = '1.1'; |
| 555 | 555 | $this->setHeader('Accept-Encoding', $enc);
|
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | * @access private |
| 603 | 603 | */ |
| 604 | 604 | function isSkippableCurlHeader(&$data) {
|
| 605 | - $skipHeaders = array( 'HTTP/1.1 100', |
|
| 605 | + $skipHeaders = array('HTTP/1.1 100',
|
|
| 606 | 606 | 'HTTP/1.0 301', |
| 607 | 607 | 'HTTP/1.1 301', |
| 608 | 608 | 'HTTP/1.0 302', |
@@ -628,7 +628,7 @@ discard block |
||
| 628 | 628 | * @access public |
| 629 | 629 | * @deprecated |
| 630 | 630 | */ |
| 631 | - function decodeChunked($buffer, $lb){
|
|
| 631 | + function decodeChunked($buffer, $lb) {
|
|
| 632 | 632 | // length := 0 |
| 633 | 633 | $length = 0; |
| 634 | 634 | $new = ''; |
@@ -640,17 +640,17 @@ discard block |
||
| 640 | 640 | $this->debug('no linebreak found in decodeChunked');
|
| 641 | 641 | return $new; |
| 642 | 642 | } |
| 643 | - $temp = substr($buffer,0,$chunkend); |
|
| 644 | - $chunk_size = hexdec( trim($temp) ); |
|
| 643 | + $temp = substr($buffer, 0, $chunkend); |
|
| 644 | + $chunk_size = hexdec(trim($temp)); |
|
| 645 | 645 | $chunkstart = $chunkend + strlen($lb); |
| 646 | 646 | // while (chunk-size > 0) {
|
| 647 | 647 | while ($chunk_size > 0) {
|
| 648 | 648 | $this->debug("chunkstart: $chunkstart chunk_size: $chunk_size");
|
| 649 | - $chunkend = strpos( $buffer, $lb, $chunkstart + $chunk_size); |
|
| 649 | + $chunkend = strpos($buffer, $lb, $chunkstart + $chunk_size); |
|
| 650 | 650 | |
| 651 | 651 | // Just in case we got a broken connection |
| 652 | 652 | if ($chunkend == FALSE) {
|
| 653 | - $chunk = substr($buffer,$chunkstart); |
|
| 653 | + $chunk = substr($buffer, $chunkstart); |
|
| 654 | 654 | // append chunk-data to entity-body |
| 655 | 655 | $new .= $chunk; |
| 656 | 656 | $length += strlen($chunk); |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | // read chunk-data and CRLF |
| 661 | - $chunk = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
| 661 | + $chunk = substr($buffer, $chunkstart, $chunkend - $chunkstart); |
|
| 662 | 662 | // append chunk-data to entity-body |
| 663 | 663 | $new .= $chunk; |
| 664 | 664 | // length := length + chunk-size |
@@ -670,8 +670,8 @@ discard block |
||
| 670 | 670 | if ($chunkend == FALSE) {
|
| 671 | 671 | break; //Just in case we got a broken connection |
| 672 | 672 | } |
| 673 | - $temp = substr($buffer,$chunkstart,$chunkend-$chunkstart); |
|
| 674 | - $chunk_size = hexdec( trim($temp) ); |
|
| 673 | + $temp = substr($buffer, $chunkstart, $chunkend - $chunkstart); |
|
| 674 | + $chunk_size = hexdec(trim($temp)); |
|
| 675 | 675 | $chunkstart = $chunkend; |
| 676 | 676 | } |
| 677 | 677 | return $new; |
@@ -706,7 +706,7 @@ discard block |
||
| 706 | 706 | $this->outgoing_payload = "$req\r\n"; |
| 707 | 707 | |
| 708 | 708 | // loop thru headers, serializing |
| 709 | - foreach($this->outgoing_headers as $k => $v){
|
|
| 709 | + foreach ($this->outgoing_headers as $k => $v) {
|
|
| 710 | 710 | $hdr = $k.': '.$v; |
| 711 | 711 | $this->debug("HTTP header: $hdr");
|
| 712 | 712 | $this->outgoing_payload .= "$hdr\r\n"; |
@@ -743,12 +743,12 @@ discard block |
||
| 743 | 743 | |
| 744 | 744 | if ($this->io_method() == 'socket') {
|
| 745 | 745 | // send payload |
| 746 | - if(!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
|
|
| 746 | + if (!fputs($this->fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
|
|
| 747 | 747 | $this->setError('couldn\'t write message data to socket');
|
| 748 | 748 | $this->debug('couldn\'t write message data to socket');
|
| 749 | 749 | return false; |
| 750 | 750 | } |
| 751 | - $this->debug('wrote data to socket, length = ' . strlen($this->outgoing_payload));
|
|
| 751 | + $this->debug('wrote data to socket, length = '.strlen($this->outgoing_payload));
|
|
| 752 | 752 | return true; |
| 753 | 753 | } else if ($this->io_method() == 'curl') {
|
| 754 | 754 | // set payload |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | // some servers refuse to work with (so we no longer use this method!) |
| 758 | 758 | //$this->setCurlOption(CURLOPT_CUSTOMREQUEST, $this->outgoing_payload); |
| 759 | 759 | $curl_headers = array(); |
| 760 | - foreach($this->outgoing_headers as $k => $v){
|
|
| 760 | + foreach ($this->outgoing_headers as $k => $v) {
|
|
| 761 | 761 | if ($k == 'Connection' || $k == 'Content-Length' || $k == 'Host' || $k == 'Authorization' || $k == 'Proxy-Authorization') {
|
| 762 | 762 | $this->debug("Skip cURL header $k: $v");
|
| 763 | 763 | } else {
|
@@ -765,7 +765,7 @@ discard block |
||
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | if ($cookie_str != '') {
|
| 768 | - $curl_headers[] = 'Cookie: ' . $cookie_str; |
|
| 768 | + $curl_headers[] = 'Cookie: '.$cookie_str; |
|
| 769 | 769 | } |
| 770 | 770 | $this->setCurlOption(CURLOPT_HTTPHEADER, $curl_headers); |
| 771 | 771 | $this->debug('set cURL HTTP headers');
|
@@ -791,62 +791,62 @@ discard block |
||
| 791 | 791 | * @return string the response (also sets member variables like incoming_payload) |
| 792 | 792 | * @access private |
| 793 | 793 | */ |
| 794 | - function getResponse(){
|
|
| 794 | + function getResponse() {
|
|
| 795 | 795 | $this->incoming_payload = ''; |
| 796 | 796 | |
| 797 | 797 | if ($this->io_method() == 'socket') {
|
| 798 | 798 | // loop until headers have been retrieved |
| 799 | 799 | $data = ''; |
| 800 | - while (!isset($lb)){
|
|
| 800 | + while (!isset($lb)) {
|
|
| 801 | 801 | |
| 802 | 802 | // We might EOF during header read. |
| 803 | - if(feof($this->fp)) {
|
|
| 803 | + if (feof($this->fp)) {
|
|
| 804 | 804 | $this->incoming_payload = $data; |
| 805 | - $this->debug('found no headers before EOF after length ' . strlen($data));
|
|
| 806 | - $this->debug("received before EOF:\n" . $data);
|
|
| 805 | + $this->debug('found no headers before EOF after length '.strlen($data));
|
|
| 806 | + $this->debug("received before EOF:\n".$data);
|
|
| 807 | 807 | $this->setError('server failed to send headers');
|
| 808 | 808 | return false; |
| 809 | 809 | } |
| 810 | 810 | |
| 811 | 811 | $tmp = fgets($this->fp, 256); |
| 812 | 812 | $tmplen = strlen($tmp); |
| 813 | - $this->debug("read line of $tmplen bytes: " . trim($tmp));
|
|
| 813 | + $this->debug("read line of $tmplen bytes: ".trim($tmp));
|
|
| 814 | 814 | |
| 815 | 815 | if ($tmplen == 0) {
|
| 816 | 816 | $this->incoming_payload = $data; |
| 817 | - $this->debug('socket read of headers timed out after length ' . strlen($data));
|
|
| 818 | - $this->debug("read before timeout: " . $data);
|
|
| 817 | + $this->debug('socket read of headers timed out after length '.strlen($data));
|
|
| 818 | + $this->debug("read before timeout: ".$data);
|
|
| 819 | 819 | $this->setError('socket read of headers timed out');
|
| 820 | 820 | return false; |
| 821 | 821 | } |
| 822 | 822 | |
| 823 | 823 | $data .= $tmp; |
| 824 | - $pos = strpos($data,"\r\n\r\n"); |
|
| 825 | - if($pos > 1){
|
|
| 824 | + $pos = strpos($data, "\r\n\r\n"); |
|
| 825 | + if ($pos > 1) {
|
|
| 826 | 826 | $lb = "\r\n"; |
| 827 | 827 | } else {
|
| 828 | - $pos = strpos($data,"\n\n"); |
|
| 829 | - if($pos > 1){
|
|
| 828 | + $pos = strpos($data, "\n\n"); |
|
| 829 | + if ($pos > 1) {
|
|
| 830 | 830 | $lb = "\n"; |
| 831 | 831 | } |
| 832 | 832 | } |
| 833 | 833 | // remove 100 headers |
| 834 | - if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
|
|
| 834 | + if (isset($lb) && preg_match('/^HTTP\/1.1 100/', $data)) {
|
|
| 835 | 835 | unset($lb); |
| 836 | 836 | $data = ''; |
| 837 | 837 | }// |
| 838 | 838 | } |
| 839 | 839 | // store header data |
| 840 | 840 | $this->incoming_payload .= $data; |
| 841 | - $this->debug('found end of headers after length ' . strlen($data));
|
|
| 841 | + $this->debug('found end of headers after length '.strlen($data));
|
|
| 842 | 842 | // process headers |
| 843 | - $header_data = trim(substr($data,0,$pos)); |
|
| 844 | - $header_array = explode($lb,$header_data); |
|
| 843 | + $header_data = trim(substr($data, 0, $pos)); |
|
| 844 | + $header_array = explode($lb, $header_data); |
|
| 845 | 845 | $this->incoming_headers = array(); |
| 846 | 846 | $this->incoming_cookies = array(); |
| 847 | - foreach($header_array as $header_line){
|
|
| 848 | - $arr = explode(':',$header_line, 2);
|
|
| 849 | - if(count($arr) > 1){
|
|
| 847 | + foreach ($header_array as $header_line) {
|
|
| 848 | + $arr = explode(':', $header_line, 2);
|
|
| 849 | + if (count($arr) > 1) {
|
|
| 850 | 850 | $header_name = strtolower(trim($arr[0])); |
| 851 | 851 | $this->incoming_headers[$header_name] = trim($arr[1]); |
| 852 | 852 | if ($header_name == 'set-cookie') {
|
@@ -854,20 +854,20 @@ discard block |
||
| 854 | 854 | $cookie = $this->parseCookie(trim($arr[1])); |
| 855 | 855 | if ($cookie) {
|
| 856 | 856 | $this->incoming_cookies[] = $cookie; |
| 857 | - $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
|
|
| 857 | + $this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
|
|
| 858 | 858 | } else {
|
| 859 | - $this->debug('did not find cookie in ' . trim($arr[1]));
|
|
| 859 | + $this->debug('did not find cookie in '.trim($arr[1]));
|
|
| 860 | 860 | } |
| 861 | 861 | } |
| 862 | 862 | } else if (isset($header_name)) {
|
| 863 | 863 | // append continuation line to previous header |
| 864 | - $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; |
|
| 864 | + $this->incoming_headers[$header_name] .= $lb.' '.$header_line; |
|
| 865 | 865 | } |
| 866 | 866 | } |
| 867 | 867 | |
| 868 | 868 | // loop until msg has been received |
| 869 | 869 | if (isset($this->incoming_headers['transfer-encoding']) && strtolower($this->incoming_headers['transfer-encoding']) == 'chunked') {
|
| 870 | - $content_length = 2147483647; // ignore any content-length header |
|
| 870 | + $content_length = 2147483647; // ignore any content-length header |
|
| 871 | 871 | $chunked = true; |
| 872 | 872 | $this->debug("want to read chunked content");
|
| 873 | 873 | } elseif (isset($this->incoming_headers['content-length'])) {
|
@@ -875,7 +875,7 @@ discard block |
||
| 875 | 875 | $chunked = false; |
| 876 | 876 | $this->debug("want to read content of length $content_length");
|
| 877 | 877 | } else {
|
| 878 | - $content_length = 2147483647; |
|
| 878 | + $content_length = 2147483647; |
|
| 879 | 879 | $chunked = false; |
| 880 | 880 | $this->debug("want to read content to EOF");
|
| 881 | 881 | } |
@@ -887,8 +887,8 @@ discard block |
||
| 887 | 887 | $this->debug("read chunk line of $tmplen bytes");
|
| 888 | 888 | if ($tmplen == 0) {
|
| 889 | 889 | $this->incoming_payload = $data; |
| 890 | - $this->debug('socket read of chunk length timed out after length ' . strlen($data));
|
|
| 891 | - $this->debug("read before timeout:\n" . $data);
|
|
| 890 | + $this->debug('socket read of chunk length timed out after length '.strlen($data));
|
|
| 891 | + $this->debug("read before timeout:\n".$data);
|
|
| 892 | 892 | $this->setError('socket read of chunk length timed out');
|
| 893 | 893 | return false; |
| 894 | 894 | } |
@@ -903,8 +903,8 @@ discard block |
||
| 903 | 903 | $this->debug("read buffer of $tmplen bytes");
|
| 904 | 904 | if (($tmplen == 0) && (!feof($this->fp))) {
|
| 905 | 905 | $this->incoming_payload = $data; |
| 906 | - $this->debug('socket read of body timed out after length ' . strlen($data));
|
|
| 907 | - $this->debug("read before timeout:\n" . $data);
|
|
| 906 | + $this->debug('socket read of body timed out after length '.strlen($data));
|
|
| 907 | + $this->debug("read before timeout:\n".$data);
|
|
| 908 | 908 | $this->setError('socket read of body timed out');
|
| 909 | 909 | return false; |
| 910 | 910 | } |
@@ -917,8 +917,8 @@ discard block |
||
| 917 | 917 | $this->debug("read chunk terminator of $tmplen bytes");
|
| 918 | 918 | if ($tmplen == 0) {
|
| 919 | 919 | $this->incoming_payload = $data; |
| 920 | - $this->debug('socket read of chunk terminator timed out after length ' . strlen($data));
|
|
| 921 | - $this->debug("read before timeout:\n" . $data);
|
|
| 920 | + $this->debug('socket read of chunk terminator timed out after length '.strlen($data));
|
|
| 921 | + $this->debug("read before timeout:\n".$data);
|
|
| 922 | 922 | $this->setError('socket read of chunk terminator timed out');
|
| 923 | 923 | return false; |
| 924 | 924 | } |
@@ -927,21 +927,21 @@ discard block |
||
| 927 | 927 | if (feof($this->fp)) {
|
| 928 | 928 | $this->debug('read to EOF');
|
| 929 | 929 | } |
| 930 | - $this->debug('read body of length ' . strlen($data));
|
|
| 930 | + $this->debug('read body of length '.strlen($data));
|
|
| 931 | 931 | $this->incoming_payload .= $data; |
| 932 | 932 | $this->debug('received a total of '.strlen($this->incoming_payload).' bytes of data from server');
|
| 933 | 933 | |
| 934 | 934 | // close filepointer |
| 935 | - if( |
|
| 935 | + if ( |
|
| 936 | 936 | (isset($this->incoming_headers['connection']) && strtolower($this->incoming_headers['connection']) == 'close') || |
| 937 | - (! $this->persistentConnection) || feof($this->fp)){
|
|
| 937 | + (!$this->persistentConnection) || feof($this->fp)) {
|
|
| 938 | 938 | fclose($this->fp); |
| 939 | 939 | $this->fp = false; |
| 940 | 940 | $this->debug('closed socket');
|
| 941 | 941 | } |
| 942 | 942 | |
| 943 | 943 | // connection was closed unexpectedly |
| 944 | - if($this->incoming_payload == ''){
|
|
| 944 | + if ($this->incoming_payload == '') {
|
|
| 945 | 945 | $this->setError('no response from server');
|
| 946 | 946 | return false; |
| 947 | 947 | } |
@@ -967,7 +967,7 @@ discard block |
||
| 967 | 967 | if ($cErr != '') {
|
| 968 | 968 | $err = 'cURL ERROR: '.curl_errno($this->ch).': '.$cErr.'<br>'; |
| 969 | 969 | // TODO: there is a PHP bug that can cause this to SEGV for CURLINFO_CONTENT_TYPE |
| 970 | - foreach(curl_getinfo($this->ch) as $k => $v){
|
|
| 970 | + foreach (curl_getinfo($this->ch) as $k => $v) {
|
|
| 971 | 971 | $err .= "$k: $v<br>"; |
| 972 | 972 | } |
| 973 | 973 | $this->debug($err); |
@@ -987,44 +987,44 @@ discard block |
||
| 987 | 987 | $savedata = $data; |
| 988 | 988 | while ($this->isSkippableCurlHeader($data)) {
|
| 989 | 989 | $this->debug("Found HTTP header to skip");
|
| 990 | - if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 991 | - $data = ltrim(substr($data,$pos)); |
|
| 992 | - } elseif($pos = strpos($data,"\n\n") ) {
|
|
| 993 | - $data = ltrim(substr($data,$pos)); |
|
| 990 | + if ($pos = strpos($data, "\r\n\r\n")) {
|
|
| 991 | + $data = ltrim(substr($data, $pos)); |
|
| 992 | + } elseif ($pos = strpos($data, "\n\n")) {
|
|
| 993 | + $data = ltrim(substr($data, $pos)); |
|
| 994 | 994 | } |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | 997 | if ($data == '') {
|
| 998 | 998 | // have nothing left; just remove 100 header(s) |
| 999 | 999 | $data = $savedata; |
| 1000 | - while (preg_match('/^HTTP\/1.1 100/',$data)) {
|
|
| 1001 | - if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 1002 | - $data = ltrim(substr($data,$pos)); |
|
| 1003 | - } elseif($pos = strpos($data,"\n\n") ) {
|
|
| 1004 | - $data = ltrim(substr($data,$pos)); |
|
| 1000 | + while (preg_match('/^HTTP\/1.1 100/', $data)) {
|
|
| 1001 | + if ($pos = strpos($data, "\r\n\r\n")) {
|
|
| 1002 | + $data = ltrim(substr($data, $pos)); |
|
| 1003 | + } elseif ($pos = strpos($data, "\n\n")) {
|
|
| 1004 | + $data = ltrim(substr($data, $pos)); |
|
| 1005 | 1005 | } |
| 1006 | 1006 | } |
| 1007 | 1007 | } |
| 1008 | 1008 | |
| 1009 | 1009 | // separate content from HTTP headers |
| 1010 | - if ($pos = strpos($data,"\r\n\r\n")) {
|
|
| 1010 | + if ($pos = strpos($data, "\r\n\r\n")) {
|
|
| 1011 | 1011 | $lb = "\r\n"; |
| 1012 | - } elseif( $pos = strpos($data,"\n\n")) {
|
|
| 1012 | + } elseif ($pos = strpos($data, "\n\n")) {
|
|
| 1013 | 1013 | $lb = "\n"; |
| 1014 | 1014 | } else {
|
| 1015 | 1015 | $this->debug('no proper separation of headers and document');
|
| 1016 | 1016 | $this->setError('no proper separation of headers and document');
|
| 1017 | 1017 | return false; |
| 1018 | 1018 | } |
| 1019 | - $header_data = trim(substr($data,0,$pos)); |
|
| 1020 | - $header_array = explode($lb,$header_data); |
|
| 1021 | - $data = ltrim(substr($data,$pos)); |
|
| 1019 | + $header_data = trim(substr($data, 0, $pos)); |
|
| 1020 | + $header_array = explode($lb, $header_data); |
|
| 1021 | + $data = ltrim(substr($data, $pos)); |
|
| 1022 | 1022 | $this->debug('found proper separation of headers and document');
|
| 1023 | 1023 | $this->debug('cleaned data, stringlen: '.strlen($data));
|
| 1024 | 1024 | // clean headers |
| 1025 | 1025 | foreach ($header_array as $header_line) {
|
| 1026 | - $arr = explode(':',$header_line,2);
|
|
| 1027 | - if(count($arr) > 1){
|
|
| 1026 | + $arr = explode(':', $header_line, 2);
|
|
| 1027 | + if (count($arr) > 1) {
|
|
| 1028 | 1028 | $header_name = strtolower(trim($arr[0])); |
| 1029 | 1029 | $this->incoming_headers[$header_name] = trim($arr[1]); |
| 1030 | 1030 | if ($header_name == 'set-cookie') {
|
@@ -1032,14 +1032,14 @@ discard block |
||
| 1032 | 1032 | $cookie = $this->parseCookie(trim($arr[1])); |
| 1033 | 1033 | if ($cookie) {
|
| 1034 | 1034 | $this->incoming_cookies[] = $cookie; |
| 1035 | - $this->debug('found cookie: ' . $cookie['name'] . ' = ' . $cookie['value']);
|
|
| 1035 | + $this->debug('found cookie: '.$cookie['name'].' = '.$cookie['value']);
|
|
| 1036 | 1036 | } else {
|
| 1037 | - $this->debug('did not find cookie in ' . trim($arr[1]));
|
|
| 1037 | + $this->debug('did not find cookie in '.trim($arr[1]));
|
|
| 1038 | 1038 | } |
| 1039 | 1039 | } |
| 1040 | 1040 | } else if (isset($header_name)) {
|
| 1041 | 1041 | // append continuation line to previous header |
| 1042 | - $this->incoming_headers[$header_name] .= $lb . ' ' . $header_line; |
|
| 1042 | + $this->incoming_headers[$header_name] .= $lb.' '.$header_line; |
|
| 1043 | 1043 | } |
| 1044 | 1044 | } |
| 1045 | 1045 | } |
@@ -1052,7 +1052,7 @@ discard block |
||
| 1052 | 1052 | |
| 1053 | 1053 | // see if we need to resend the request with http digest authentication |
| 1054 | 1054 | if (isset($this->incoming_headers['location']) && ($http_status == 301 || $http_status == 302)) {
|
| 1055 | - $this->debug("Got $http_status $http_reason with Location: " . $this->incoming_headers['location']);
|
|
| 1055 | + $this->debug("Got $http_status $http_reason with Location: ".$this->incoming_headers['location']);
|
|
| 1056 | 1056 | $this->setURL($this->incoming_headers['location']); |
| 1057 | 1057 | $this->tryagain = true; |
| 1058 | 1058 | return false; |
@@ -1060,7 +1060,7 @@ discard block |
||
| 1060 | 1060 | |
| 1061 | 1061 | // see if we need to resend the request with http digest authentication |
| 1062 | 1062 | if (isset($this->incoming_headers['www-authenticate']) && $http_status == 401) {
|
| 1063 | - $this->debug("Got 401 $http_reason with WWW-Authenticate: " . $this->incoming_headers['www-authenticate']);
|
|
| 1063 | + $this->debug("Got 401 $http_reason with WWW-Authenticate: ".$this->incoming_headers['www-authenticate']);
|
|
| 1064 | 1064 | if (strstr($this->incoming_headers['www-authenticate'], "Digest ")) {
|
| 1065 | 1065 | $this->debug('Server wants digest authentication');
|
| 1066 | 1066 | // remove "Digest " from our elements |
@@ -1095,10 +1095,10 @@ discard block |
||
| 1095 | 1095 | } |
| 1096 | 1096 | |
| 1097 | 1097 | // decode content-encoding |
| 1098 | - if(isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != ''){
|
|
| 1099 | - if(strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip'){
|
|
| 1098 | + if (isset($this->incoming_headers['content-encoding']) && $this->incoming_headers['content-encoding'] != '') {
|
|
| 1099 | + if (strtolower($this->incoming_headers['content-encoding']) == 'deflate' || strtolower($this->incoming_headers['content-encoding']) == 'gzip') {
|
|
| 1100 | 1100 | // if decoding works, use it. else assume data wasn't gzencoded |
| 1101 | - if(function_exists('gzinflate')){
|
|
| 1101 | + if (function_exists('gzinflate')) {
|
|
| 1102 | 1102 | //$timer->setMarker('starting decoding of gzip/deflated content');
|
| 1103 | 1103 | // IIS 5 requires gzinflate instead of gzuncompress (similar to IE 5 and gzdeflate v. gzcompress) |
| 1104 | 1104 | // this means there are no Zlib headers, although there should be |
@@ -1107,13 +1107,13 @@ discard block |
||
| 1107 | 1107 | if ($this->incoming_headers['content-encoding'] == 'deflate') {
|
| 1108 | 1108 | if ($degzdata = @gzinflate($data)) {
|
| 1109 | 1109 | $data = $degzdata; |
| 1110 | - $this->debug('The payload has been inflated to ' . strlen($data) . ' bytes');
|
|
| 1110 | + $this->debug('The payload has been inflated to '.strlen($data).' bytes');
|
|
| 1111 | 1111 | if (strlen($data) < $datalen) {
|
| 1112 | 1112 | // test for the case that the payload has been compressed twice |
| 1113 | 1113 | $this->debug('The inflated payload is smaller than the gzipped one; try again');
|
| 1114 | 1114 | if ($degzdata = @gzinflate($data)) {
|
| 1115 | 1115 | $data = $degzdata; |
| 1116 | - $this->debug('The payload has been inflated again to ' . strlen($data) . ' bytes');
|
|
| 1116 | + $this->debug('The payload has been inflated again to '.strlen($data).' bytes');
|
|
| 1117 | 1117 | } |
| 1118 | 1118 | } |
| 1119 | 1119 | } else {
|
@@ -1123,13 +1123,13 @@ discard block |
||
| 1123 | 1123 | } elseif ($this->incoming_headers['content-encoding'] == 'gzip') {
|
| 1124 | 1124 | if ($degzdata = @gzinflate(substr($data, 10))) { // do our best
|
| 1125 | 1125 | $data = $degzdata; |
| 1126 | - $this->debug('The payload has been un-gzipped to ' . strlen($data) . ' bytes');
|
|
| 1126 | + $this->debug('The payload has been un-gzipped to '.strlen($data).' bytes');
|
|
| 1127 | 1127 | if (strlen($data) < $datalen) {
|
| 1128 | 1128 | // test for the case that the payload has been compressed twice |
| 1129 | 1129 | $this->debug('The un-gzipped payload is smaller than the gzipped one; try again');
|
| 1130 | 1130 | if ($degzdata = @gzinflate(substr($data, 10))) {
|
| 1131 | 1131 | $data = $degzdata; |
| 1132 | - $this->debug('The payload has been un-gzipped again to ' . strlen($data) . ' bytes');
|
|
| 1132 | + $this->debug('The payload has been un-gzipped again to '.strlen($data).' bytes');
|
|
| 1133 | 1133 | } |
| 1134 | 1134 | } |
| 1135 | 1135 | } else {
|
@@ -1146,14 +1146,14 @@ discard block |
||
| 1146 | 1146 | $this->setError('The server sent compressed data. Your php install must have the Zlib extension compiled in to support this.');
|
| 1147 | 1147 | } |
| 1148 | 1148 | } else {
|
| 1149 | - $this->debug('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
|
|
| 1150 | - $this->setError('Unsupported Content-Encoding ' . $this->incoming_headers['content-encoding']);
|
|
| 1149 | + $this->debug('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
|
|
| 1150 | + $this->setError('Unsupported Content-Encoding '.$this->incoming_headers['content-encoding']);
|
|
| 1151 | 1151 | } |
| 1152 | 1152 | } else {
|
| 1153 | 1153 | $this->debug('No Content-Encoding header');
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | - if(strlen($data) == 0){
|
|
| 1156 | + if (strlen($data) == 0) {
|
|
| 1157 | 1157 | $this->debug('no data after headers!');
|
| 1158 | 1158 | $this->setError('no data present after HTTP headers');
|
| 1159 | 1159 | return false; |
@@ -1170,7 +1170,7 @@ discard block |
||
| 1170 | 1170 | * @access public |
| 1171 | 1171 | */ |
| 1172 | 1172 | function setContentType($type, $charset = false) {
|
| 1173 | - $this->setHeader('Content-Type', $type . ($charset ? '; charset=' . $charset : ''));
|
|
| 1173 | + $this->setHeader('Content-Type', $type.($charset ? '; charset='.$charset : ''));
|
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | /** |
@@ -1179,7 +1179,7 @@ discard block |
||
| 1179 | 1179 | * @return boolean whether the request was honored by this method. |
| 1180 | 1180 | * @access public |
| 1181 | 1181 | */ |
| 1182 | - function usePersistentConnection(){
|
|
| 1182 | + function usePersistentConnection() {
|
|
| 1183 | 1183 | if (isset($this->outgoing_headers['Accept-Encoding'])) {
|
| 1184 | 1184 | return false; |
| 1185 | 1185 | } |
@@ -1200,7 +1200,7 @@ discard block |
||
| 1200 | 1200 | * TODO: allow a Set-Cookie string to be parsed into multiple cookies |
| 1201 | 1201 | */ |
| 1202 | 1202 | function parseCookie($cookie_str) {
|
| 1203 | - $cookie_str = str_replace('; ', ';', $cookie_str) . ';';
|
|
| 1203 | + $cookie_str = str_replace('; ', ';', $cookie_str).';';
|
|
| 1204 | 1204 | $data = preg_split('/;/', $cookie_str);
|
| 1205 | 1205 | $value_str = $data[0]; |
| 1206 | 1206 | |
@@ -1224,7 +1224,7 @@ discard block |
||
| 1224 | 1224 | |
| 1225 | 1225 | $cookie_param = 'path='; |
| 1226 | 1226 | $start = strpos($cookie_str, $cookie_param); |
| 1227 | - if ( $start > 0 ) {
|
|
| 1227 | + if ($start > 0) {
|
|
| 1228 | 1228 | $path = substr($cookie_str, $start + strlen($cookie_param)); |
| 1229 | 1229 | $path = substr($path, 0, strpos($path, ';')); |
| 1230 | 1230 | } else {
|
@@ -1243,7 +1243,7 @@ discard block |
||
| 1243 | 1243 | if ($sep_pos) {
|
| 1244 | 1244 | $name = substr($value_str, 0, $sep_pos); |
| 1245 | 1245 | $value = substr($value_str, $sep_pos + 1); |
| 1246 | - $cookie= array( 'name' => $name, |
|
| 1246 | + $cookie = array('name' => $name,
|
|
| 1247 | 1247 | 'value' => $value, |
| 1248 | 1248 | 'domain' => $domain, |
| 1249 | 1249 | 'path' => $path, |
@@ -1263,40 +1263,40 @@ discard block |
||
| 1263 | 1263 | * @return string for Cookie-HTTP-Header |
| 1264 | 1264 | * @access private |
| 1265 | 1265 | */ |
| 1266 | - function getCookiesForRequest($cookies, $secure=false) {
|
|
| 1266 | + function getCookiesForRequest($cookies, $secure = false) {
|
|
| 1267 | 1267 | $cookie_str = ''; |
| 1268 | - if ((! is_null($cookies)) && (is_array($cookies))) {
|
|
| 1268 | + if ((!is_null($cookies)) && (is_array($cookies))) {
|
|
| 1269 | 1269 | foreach ($cookies as $cookie) {
|
| 1270 | - if (! is_array($cookie)) {
|
|
| 1270 | + if (!is_array($cookie)) {
|
|
| 1271 | 1271 | continue; |
| 1272 | 1272 | } |
| 1273 | 1273 | $this->debug("check cookie for validity: ".$cookie['name'].'='.$cookie['value']);
|
| 1274 | - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 1274 | + if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
|
|
| 1275 | 1275 | if (strtotime($cookie['expires']) <= time()) {
|
| 1276 | 1276 | $this->debug('cookie has expired');
|
| 1277 | 1277 | continue; |
| 1278 | 1278 | } |
| 1279 | 1279 | } |
| 1280 | - if ((isset($cookie['domain'])) && (! empty($cookie['domain']))) {
|
|
| 1280 | + if ((isset($cookie['domain'])) && (!empty($cookie['domain']))) {
|
|
| 1281 | 1281 | $domain = preg_quote($cookie['domain']); |
| 1282 | - if (! preg_match("'.*$domain$'i", $this->host)) {
|
|
| 1282 | + if (!preg_match("'.*$domain$'i", $this->host)) {
|
|
| 1283 | 1283 | $this->debug('cookie has different domain');
|
| 1284 | 1284 | continue; |
| 1285 | 1285 | } |
| 1286 | 1286 | } |
| 1287 | - if ((isset($cookie['path'])) && (! empty($cookie['path']))) {
|
|
| 1287 | + if ((isset($cookie['path'])) && (!empty($cookie['path']))) {
|
|
| 1288 | 1288 | $path = preg_quote($cookie['path']); |
| 1289 | - if (! preg_match("'^$path.*'i", $this->path)) {
|
|
| 1289 | + if (!preg_match("'^$path.*'i", $this->path)) {
|
|
| 1290 | 1290 | $this->debug('cookie is for a different path');
|
| 1291 | 1291 | continue; |
| 1292 | 1292 | } |
| 1293 | 1293 | } |
| 1294 | - if ((! $secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
|
|
| 1294 | + if ((!$secure) && (isset($cookie['secure'])) && ($cookie['secure'])) {
|
|
| 1295 | 1295 | $this->debug('cookie is secure, transport is not');
|
| 1296 | 1296 | continue; |
| 1297 | 1297 | } |
| 1298 | - $cookie_str .= $cookie['name'] . '=' . $cookie['value'] . '; '; |
|
| 1299 | - $this->debug('add cookie to Cookie-String: ' . $cookie['name'] . '=' . $cookie['value']);
|
|
| 1298 | + $cookie_str .= $cookie['name'].'='.$cookie['value'].'; '; |
|
| 1299 | + $this->debug('add cookie to Cookie-String: '.$cookie['name'].'='.$cookie['value']);
|
|
| 1300 | 1300 | } |
| 1301 | 1301 | } |
| 1302 | 1302 | return $cookie_str; |
@@ -159,10 +159,12 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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; |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | * |
| 64 | 64 | * @param string $name optional name |
| 65 | 65 | * @param mixed $type optional type name |
| 66 | - * @param mixed $value optional value |
|
| 66 | + * @param integer $value optional value |
|
| 67 | 67 | * @param mixed $element_ns optional namespace of value |
| 68 | 68 | * @param mixed $type_ns optional namespace of type |
| 69 | 69 | * @param mixed $attributes associative array of attributes to add to element serialization |
@@ -15,90 +15,90 @@ |
||
| 15 | 15 | * @access public |
| 16 | 16 | */ |
| 17 | 17 | class soapval extends nusoap_base {
|
| 18 | - /** |
|
| 19 | - * The XML element name |
|
| 20 | - * |
|
| 21 | - * @var string |
|
| 22 | - * @access private |
|
| 23 | - */ |
|
| 24 | - var $name; |
|
| 25 | - /** |
|
| 26 | - * The XML type name (string or false) |
|
| 27 | - * |
|
| 28 | - * @var mixed |
|
| 29 | - * @access private |
|
| 30 | - */ |
|
| 31 | - var $type; |
|
| 32 | - /** |
|
| 33 | - * The PHP value |
|
| 34 | - * |
|
| 35 | - * @var mixed |
|
| 36 | - * @access private |
|
| 37 | - */ |
|
| 38 | - var $value; |
|
| 39 | - /** |
|
| 40 | - * The XML element namespace (string or false) |
|
| 41 | - * |
|
| 42 | - * @var mixed |
|
| 43 | - * @access private |
|
| 44 | - */ |
|
| 45 | - var $element_ns; |
|
| 46 | - /** |
|
| 47 | - * The XML type namespace (string or false) |
|
| 48 | - * |
|
| 49 | - * @var mixed |
|
| 50 | - * @access private |
|
| 51 | - */ |
|
| 52 | - var $type_ns; |
|
| 53 | - /** |
|
| 54 | - * The XML element attributes (array or false) |
|
| 55 | - * |
|
| 56 | - * @var mixed |
|
| 57 | - * @access private |
|
| 58 | - */ |
|
| 59 | - var $attributes; |
|
| 18 | + /** |
|
| 19 | + * The XML element name |
|
| 20 | + * |
|
| 21 | + * @var string |
|
| 22 | + * @access private |
|
| 23 | + */ |
|
| 24 | + var $name; |
|
| 25 | + /** |
|
| 26 | + * The XML type name (string or false) |
|
| 27 | + * |
|
| 28 | + * @var mixed |
|
| 29 | + * @access private |
|
| 30 | + */ |
|
| 31 | + var $type; |
|
| 32 | + /** |
|
| 33 | + * The PHP value |
|
| 34 | + * |
|
| 35 | + * @var mixed |
|
| 36 | + * @access private |
|
| 37 | + */ |
|
| 38 | + var $value; |
|
| 39 | + /** |
|
| 40 | + * The XML element namespace (string or false) |
|
| 41 | + * |
|
| 42 | + * @var mixed |
|
| 43 | + * @access private |
|
| 44 | + */ |
|
| 45 | + var $element_ns; |
|
| 46 | + /** |
|
| 47 | + * The XML type namespace (string or false) |
|
| 48 | + * |
|
| 49 | + * @var mixed |
|
| 50 | + * @access private |
|
| 51 | + */ |
|
| 52 | + var $type_ns; |
|
| 53 | + /** |
|
| 54 | + * The XML element attributes (array or false) |
|
| 55 | + * |
|
| 56 | + * @var mixed |
|
| 57 | + * @access private |
|
| 58 | + */ |
|
| 59 | + var $attributes; |
|
| 60 | 60 | |
| 61 | - /** |
|
| 62 | - * constructor |
|
| 63 | - * |
|
| 64 | - * @param string $name optional name |
|
| 65 | - * @param mixed $type optional type name |
|
| 66 | - * @param mixed $value optional value |
|
| 67 | - * @param mixed $element_ns optional namespace of value |
|
| 68 | - * @param mixed $type_ns optional namespace of type |
|
| 69 | - * @param mixed $attributes associative array of attributes to add to element serialization |
|
| 70 | - * @access public |
|
| 71 | - */ |
|
| 72 | - function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
|
|
| 73 | - parent::nusoap_base(); |
|
| 74 | - $this->name = $name; |
|
| 75 | - $this->type = $type; |
|
| 76 | - $this->value = $value; |
|
| 77 | - $this->element_ns = $element_ns; |
|
| 78 | - $this->type_ns = $type_ns; |
|
| 79 | - $this->attributes = $attributes; |
|
| 61 | + /** |
|
| 62 | + * constructor |
|
| 63 | + * |
|
| 64 | + * @param string $name optional name |
|
| 65 | + * @param mixed $type optional type name |
|
| 66 | + * @param mixed $value optional value |
|
| 67 | + * @param mixed $element_ns optional namespace of value |
|
| 68 | + * @param mixed $type_ns optional namespace of type |
|
| 69 | + * @param mixed $attributes associative array of attributes to add to element serialization |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | + function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
|
|
| 73 | + parent::nusoap_base(); |
|
| 74 | + $this->name = $name; |
|
| 75 | + $this->type = $type; |
|
| 76 | + $this->value = $value; |
|
| 77 | + $this->element_ns = $element_ns; |
|
| 78 | + $this->type_ns = $type_ns; |
|
| 79 | + $this->attributes = $attributes; |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - /** |
|
| 83 | - * return serialized value |
|
| 84 | - * |
|
| 85 | - * @param string $use The WSDL use value (encoded|literal) |
|
| 86 | - * @return string XML data |
|
| 87 | - * @access public |
|
| 88 | - */ |
|
| 89 | - function serialize($use='encoded') {
|
|
| 90 | - return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
|
| 82 | + /** |
|
| 83 | + * return serialized value |
|
| 84 | + * |
|
| 85 | + * @param string $use The WSDL use value (encoded|literal) |
|
| 86 | + * @return string XML data |
|
| 87 | + * @access public |
|
| 88 | + */ |
|
| 89 | + function serialize($use='encoded') {
|
|
| 90 | + return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * decodes a soapval object into a PHP native type |
|
| 95 | - * |
|
| 96 | - * @return mixed |
|
| 97 | - * @access public |
|
| 98 | - */ |
|
| 99 | - function decode(){
|
|
| 100 | - return $this->value; |
|
| 101 | - } |
|
| 93 | + /** |
|
| 94 | + * decodes a soapval object into a PHP native type |
|
| 95 | + * |
|
| 96 | + * @return mixed |
|
| 97 | + * @access public |
|
| 98 | + */ |
|
| 99 | + function decode(){
|
|
| 100 | + return $this->value; |
|
| 101 | + } |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * @param mixed $attributes associative array of attributes to add to element serialization |
| 70 | 70 | * @access public |
| 71 | 71 | */ |
| 72 | - function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
|
|
| 72 | + function soapval($name = 'soapval', $type = false, $value = -1, $element_ns = false, $type_ns = false, $attributes = false) {
|
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->name = $name; |
| 75 | 75 | $this->type = $type; |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | * @return string XML data |
| 87 | 87 | * @access public |
| 88 | 88 | */ |
| 89 | - function serialize($use='encoded') {
|
|
| 89 | + function serialize($use = 'encoded') {
|
|
| 90 | 90 | return $this->serialize_val($this->value, $this->name, $this->type, $this->element_ns, $this->type_ns, $this->attributes, $use, true); |
| 91 | 91 | } |
| 92 | 92 | |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | * @return mixed |
| 97 | 97 | * @access public |
| 98 | 98 | */ |
| 99 | - function decode(){
|
|
| 99 | + function decode() {
|
|
| 100 | 100 | return $this->value; |
| 101 | 101 | } |
| 102 | 102 | } |
@@ -743,6 +743,7 @@ |
||
| 743 | 743 | /** |
| 744 | 744 | * dynamically creates proxy class code |
| 745 | 745 | * |
| 746 | + * @param integer $r |
|
| 746 | 747 | * @return string PHP/NuSOAP code for the proxy class |
| 747 | 748 | * @access private |
| 748 | 749 | */ |
@@ -25,967 +25,967 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class nusoap_client extends nusoap_base {
|
| 27 | 27 | |
| 28 | - var $username = ''; // Username for HTTP authentication |
|
| 29 | - var $password = ''; // Password for HTTP authentication |
|
| 30 | - var $authtype = ''; // Type of HTTP authentication |
|
| 31 | - var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | - var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | - var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | - var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | - var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 36 | - var $endpoint; |
|
| 37 | - var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 28 | + var $username = ''; // Username for HTTP authentication |
|
| 29 | + var $password = ''; // Password for HTTP authentication |
|
| 30 | + var $authtype = ''; // Type of HTTP authentication |
|
| 31 | + var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | + var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | + var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | + var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | + var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 36 | + var $endpoint; |
|
| 37 | + var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 38 | 38 | var $proxyhost = ''; |
| 39 | 39 | var $proxyport = ''; |
| 40 | - var $proxyusername = ''; |
|
| 41 | - var $proxypassword = ''; |
|
| 42 | - var $portName = ''; // port name to use in WSDL |
|
| 40 | + var $proxyusername = ''; |
|
| 41 | + var $proxypassword = ''; |
|
| 42 | + var $portName = ''; // port name to use in WSDL |
|
| 43 | 43 | var $xml_encoding = ''; // character set encoding of incoming (response) messages |
| 44 | - var $http_encoding = false; |
|
| 45 | - var $timeout = 0; // HTTP connection timeout |
|
| 46 | - var $response_timeout = 30; // HTTP response timeout |
|
| 47 | - var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 48 | - var $persistentConnection = false; |
|
| 49 | - var $defaultRpcParams = false; // This is no longer used |
|
| 50 | - var $request = ''; // HTTP request |
|
| 51 | - var $response = ''; // HTTP response |
|
| 52 | - var $responseData = ''; // SOAP payload of response |
|
| 53 | - var $cookies = array(); // Cookies from response or for request |
|
| 44 | + var $http_encoding = false; |
|
| 45 | + var $timeout = 0; // HTTP connection timeout |
|
| 46 | + var $response_timeout = 30; // HTTP response timeout |
|
| 47 | + var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 48 | + var $persistentConnection = false; |
|
| 49 | + var $defaultRpcParams = false; // This is no longer used |
|
| 50 | + var $request = ''; // HTTP request |
|
| 51 | + var $response = ''; // HTTP response |
|
| 52 | + var $responseData = ''; // SOAP payload of response |
|
| 53 | + var $cookies = array(); // Cookies from response or for request |
|
| 54 | 54 | var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() |
| 55 | - var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | - var $curl_options = array(); // User-specified cURL options |
|
| 57 | - var $bindingType = ''; // WSDL operation binding type |
|
| 58 | - var $use_curl = false; // whether to always try to use cURL |
|
| 55 | + var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | + var $curl_options = array(); // User-specified cURL options |
|
| 57 | + var $bindingType = ''; // WSDL operation binding type |
|
| 58 | + var $use_curl = false; // whether to always try to use cURL |
|
| 59 | 59 | |
| 60 | - /* |
|
| 60 | + /* |
|
| 61 | 61 | * fault related variables |
| 62 | 62 | */ |
| 63 | - /** |
|
| 64 | - * @var fault |
|
| 65 | - * @access public |
|
| 66 | - */ |
|
| 67 | - var $fault; |
|
| 68 | - /** |
|
| 69 | - * @var faultcode |
|
| 70 | - * @access public |
|
| 71 | - */ |
|
| 72 | - var $faultcode; |
|
| 73 | - /** |
|
| 74 | - * @var faultstring |
|
| 75 | - * @access public |
|
| 76 | - */ |
|
| 77 | - var $faultstring; |
|
| 78 | - /** |
|
| 79 | - * @var faultdetail |
|
| 80 | - * @access public |
|
| 81 | - */ |
|
| 82 | - var $faultdetail; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * constructor |
|
| 86 | - * |
|
| 87 | - * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) |
|
| 88 | - * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL |
|
| 89 | - * @param string $proxyhost optional |
|
| 90 | - * @param string $proxyport optional |
|
| 91 | - * @param string $proxyusername optional |
|
| 92 | - * @param string $proxypassword optional |
|
| 93 | - * @param integer $timeout set the connection timeout |
|
| 94 | - * @param integer $response_timeout set the response timeout |
|
| 95 | - * @param string $portName optional portName in WSDL document |
|
| 96 | - * @access public |
|
| 97 | - */ |
|
| 98 | - function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
|
|
| 99 | - parent::nusoap_base(); |
|
| 100 | - $this->endpoint = $endpoint; |
|
| 101 | - $this->proxyhost = $proxyhost; |
|
| 102 | - $this->proxyport = $proxyport; |
|
| 103 | - $this->proxyusername = $proxyusername; |
|
| 104 | - $this->proxypassword = $proxypassword; |
|
| 105 | - $this->timeout = $timeout; |
|
| 106 | - $this->response_timeout = $response_timeout; |
|
| 107 | - $this->portName = $portName; |
|
| 108 | - |
|
| 109 | - $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
|
| 110 | - $this->appendDebug('endpoint=' . $this->varDump($endpoint));
|
|
| 111 | - |
|
| 112 | - // make values |
|
| 113 | - if($wsdl){
|
|
| 114 | - if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
|
|
| 115 | - $this->wsdl = $endpoint; |
|
| 116 | - $this->endpoint = $this->wsdl->wsdl; |
|
| 117 | - $this->wsdlFile = $this->endpoint; |
|
| 118 | - $this->debug('existing wsdl instance created from ' . $this->endpoint);
|
|
| 119 | - $this->checkWSDL(); |
|
| 120 | - } else {
|
|
| 121 | - $this->wsdlFile = $this->endpoint; |
|
| 122 | - $this->wsdl = null; |
|
| 123 | - $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
|
|
| 124 | - } |
|
| 125 | - $this->endpointType = 'wsdl'; |
|
| 126 | - } else {
|
|
| 127 | - $this->debug("instantiate SOAP with endpoint at $endpoint");
|
|
| 128 | - $this->endpointType = 'soap'; |
|
| 129 | - } |
|
| 130 | - } |
|
| 63 | + /** |
|
| 64 | + * @var fault |
|
| 65 | + * @access public |
|
| 66 | + */ |
|
| 67 | + var $fault; |
|
| 68 | + /** |
|
| 69 | + * @var faultcode |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | + var $faultcode; |
|
| 73 | + /** |
|
| 74 | + * @var faultstring |
|
| 75 | + * @access public |
|
| 76 | + */ |
|
| 77 | + var $faultstring; |
|
| 78 | + /** |
|
| 79 | + * @var faultdetail |
|
| 80 | + * @access public |
|
| 81 | + */ |
|
| 82 | + var $faultdetail; |
|
| 131 | 83 | |
| 132 | - /** |
|
| 133 | - * calls method, returns PHP native type |
|
| 134 | - * |
|
| 135 | - * @param string $operation SOAP server URL or path |
|
| 136 | - * @param mixed $params An array, associative or simple, of the parameters |
|
| 137 | - * for the method call, or a string that is the XML |
|
| 138 | - * for the call. For rpc style, this call will |
|
| 139 | - * wrap the XML in a tag named after the method, as |
|
| 140 | - * well as the SOAP Envelope and Body. For document |
|
| 141 | - * style, this will only wrap with the Envelope and Body. |
|
| 142 | - * IMPORTANT: when using an array with document style, |
|
| 143 | - * in which case there |
|
| 144 | - * is really one parameter, the root of the fragment |
|
| 145 | - * used in the call, which encloses what programmers |
|
| 146 | - * normally think of parameters. A parameter array |
|
| 147 | - * *must* include the wrapper. |
|
| 148 | - * @param string $namespace optional method namespace (WSDL can override) |
|
| 149 | - * @param string $soapAction optional SOAPAction value (WSDL can override) |
|
| 150 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 151 | - * @param boolean $rpcParams optional (no longer used) |
|
| 152 | - * @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override) |
|
| 153 | - * @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override) |
|
| 154 | - * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors |
|
| 155 | - * @access public |
|
| 156 | - */ |
|
| 157 | - function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
|
|
| 158 | - $this->operation = $operation; |
|
| 159 | - $this->fault = false; |
|
| 160 | - $this->setError('');
|
|
| 161 | - $this->request = ''; |
|
| 162 | - $this->response = ''; |
|
| 163 | - $this->responseData = ''; |
|
| 164 | - $this->faultstring = ''; |
|
| 165 | - $this->faultcode = ''; |
|
| 166 | - $this->opData = array(); |
|
| 84 | + /** |
|
| 85 | + * constructor |
|
| 86 | + * |
|
| 87 | + * @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object) |
|
| 88 | + * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL |
|
| 89 | + * @param string $proxyhost optional |
|
| 90 | + * @param string $proxyport optional |
|
| 91 | + * @param string $proxyusername optional |
|
| 92 | + * @param string $proxypassword optional |
|
| 93 | + * @param integer $timeout set the connection timeout |
|
| 94 | + * @param integer $response_timeout set the response timeout |
|
| 95 | + * @param string $portName optional portName in WSDL document |
|
| 96 | + * @access public |
|
| 97 | + */ |
|
| 98 | + function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
|
|
| 99 | + parent::nusoap_base(); |
|
| 100 | + $this->endpoint = $endpoint; |
|
| 101 | + $this->proxyhost = $proxyhost; |
|
| 102 | + $this->proxyport = $proxyport; |
|
| 103 | + $this->proxyusername = $proxyusername; |
|
| 104 | + $this->proxypassword = $proxypassword; |
|
| 105 | + $this->timeout = $timeout; |
|
| 106 | + $this->response_timeout = $response_timeout; |
|
| 107 | + $this->portName = $portName; |
|
| 108 | + |
|
| 109 | + $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
|
| 110 | + $this->appendDebug('endpoint=' . $this->varDump($endpoint));
|
|
| 111 | + |
|
| 112 | + // make values |
|
| 113 | + if($wsdl){
|
|
| 114 | + if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
|
|
| 115 | + $this->wsdl = $endpoint; |
|
| 116 | + $this->endpoint = $this->wsdl->wsdl; |
|
| 117 | + $this->wsdlFile = $this->endpoint; |
|
| 118 | + $this->debug('existing wsdl instance created from ' . $this->endpoint);
|
|
| 119 | + $this->checkWSDL(); |
|
| 120 | + } else {
|
|
| 121 | + $this->wsdlFile = $this->endpoint; |
|
| 122 | + $this->wsdl = null; |
|
| 123 | + $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
|
|
| 124 | + } |
|
| 125 | + $this->endpointType = 'wsdl'; |
|
| 126 | + } else {
|
|
| 127 | + $this->debug("instantiate SOAP with endpoint at $endpoint");
|
|
| 128 | + $this->endpointType = 'soap'; |
|
| 129 | + } |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + /** |
|
| 133 | + * calls method, returns PHP native type |
|
| 134 | + * |
|
| 135 | + * @param string $operation SOAP server URL or path |
|
| 136 | + * @param mixed $params An array, associative or simple, of the parameters |
|
| 137 | + * for the method call, or a string that is the XML |
|
| 138 | + * for the call. For rpc style, this call will |
|
| 139 | + * wrap the XML in a tag named after the method, as |
|
| 140 | + * well as the SOAP Envelope and Body. For document |
|
| 141 | + * style, this will only wrap with the Envelope and Body. |
|
| 142 | + * IMPORTANT: when using an array with document style, |
|
| 143 | + * in which case there |
|
| 144 | + * is really one parameter, the root of the fragment |
|
| 145 | + * used in the call, which encloses what programmers |
|
| 146 | + * normally think of parameters. A parameter array |
|
| 147 | + * *must* include the wrapper. |
|
| 148 | + * @param string $namespace optional method namespace (WSDL can override) |
|
| 149 | + * @param string $soapAction optional SOAPAction value (WSDL can override) |
|
| 150 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 151 | + * @param boolean $rpcParams optional (no longer used) |
|
| 152 | + * @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override) |
|
| 153 | + * @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override) |
|
| 154 | + * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors |
|
| 155 | + * @access public |
|
| 156 | + */ |
|
| 157 | + function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
|
|
| 158 | + $this->operation = $operation; |
|
| 159 | + $this->fault = false; |
|
| 160 | + $this->setError('');
|
|
| 161 | + $this->request = ''; |
|
| 162 | + $this->response = ''; |
|
| 163 | + $this->responseData = ''; |
|
| 164 | + $this->faultstring = ''; |
|
| 165 | + $this->faultcode = ''; |
|
| 166 | + $this->opData = array(); |
|
| 167 | 167 | |
| 168 | - $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
|
|
| 169 | - $this->appendDebug('params=' . $this->varDump($params));
|
|
| 170 | - $this->appendDebug('headers=' . $this->varDump($headers));
|
|
| 171 | - if ($headers) {
|
|
| 172 | - $this->requestHeaders = $headers; |
|
| 173 | - } |
|
| 174 | - if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 175 | - $this->loadWSDL(); |
|
| 176 | - if ($this->getError()) |
|
| 177 | - return false; |
|
| 178 | - } |
|
| 179 | - // serialize parameters |
|
| 180 | - if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
|
| 181 | - // use WSDL for operation |
|
| 182 | - $this->opData = $opData; |
|
| 183 | - $this->debug("found operation");
|
|
| 184 | - $this->appendDebug('opData=' . $this->varDump($opData));
|
|
| 185 | - if (isset($opData['soapAction'])) {
|
|
| 186 | - $soapAction = $opData['soapAction']; |
|
| 187 | - } |
|
| 188 | - if (! $this->forceEndpoint) {
|
|
| 189 | - $this->endpoint = $opData['endpoint']; |
|
| 190 | - } else {
|
|
| 191 | - $this->endpoint = $this->forceEndpoint; |
|
| 192 | - } |
|
| 193 | - $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 194 | - $style = $opData['style']; |
|
| 195 | - $use = $opData['input']['use']; |
|
| 196 | - // add ns to ns array |
|
| 197 | - if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
|
| 198 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 199 | - $this->wsdl->namespaces[$nsPrefix] = $namespace; |
|
| 200 | - } |
|
| 168 | + $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
|
|
| 169 | + $this->appendDebug('params=' . $this->varDump($params));
|
|
| 170 | + $this->appendDebug('headers=' . $this->varDump($headers));
|
|
| 171 | + if ($headers) {
|
|
| 172 | + $this->requestHeaders = $headers; |
|
| 173 | + } |
|
| 174 | + if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 175 | + $this->loadWSDL(); |
|
| 176 | + if ($this->getError()) |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 179 | + // serialize parameters |
|
| 180 | + if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
|
| 181 | + // use WSDL for operation |
|
| 182 | + $this->opData = $opData; |
|
| 183 | + $this->debug("found operation");
|
|
| 184 | + $this->appendDebug('opData=' . $this->varDump($opData));
|
|
| 185 | + if (isset($opData['soapAction'])) {
|
|
| 186 | + $soapAction = $opData['soapAction']; |
|
| 187 | + } |
|
| 188 | + if (! $this->forceEndpoint) {
|
|
| 189 | + $this->endpoint = $opData['endpoint']; |
|
| 190 | + } else {
|
|
| 191 | + $this->endpoint = $this->forceEndpoint; |
|
| 192 | + } |
|
| 193 | + $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 194 | + $style = $opData['style']; |
|
| 195 | + $use = $opData['input']['use']; |
|
| 196 | + // add ns to ns array |
|
| 197 | + if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
|
| 198 | + $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 199 | + $this->wsdl->namespaces[$nsPrefix] = $namespace; |
|
| 200 | + } |
|
| 201 | 201 | $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); |
| 202 | - // serialize payload |
|
| 203 | - if (is_string($params)) {
|
|
| 204 | - $this->debug("serializing param string for WSDL operation $operation");
|
|
| 205 | - $payload = $params; |
|
| 206 | - } elseif (is_array($params)) {
|
|
| 207 | - $this->debug("serializing param array for WSDL operation $operation");
|
|
| 208 | - $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); |
|
| 209 | - } else {
|
|
| 210 | - $this->debug('params must be array or string');
|
|
| 211 | - $this->setError('params must be array or string');
|
|
| 212 | - return false; |
|
| 213 | - } |
|
| 202 | + // serialize payload |
|
| 203 | + if (is_string($params)) {
|
|
| 204 | + $this->debug("serializing param string for WSDL operation $operation");
|
|
| 205 | + $payload = $params; |
|
| 206 | + } elseif (is_array($params)) {
|
|
| 207 | + $this->debug("serializing param array for WSDL operation $operation");
|
|
| 208 | + $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); |
|
| 209 | + } else {
|
|
| 210 | + $this->debug('params must be array or string');
|
|
| 211 | + $this->setError('params must be array or string');
|
|
| 212 | + return false; |
|
| 213 | + } |
|
| 214 | 214 | $usedNamespaces = $this->wsdl->usedNamespaces; |
| 215 | - if (isset($opData['input']['encodingStyle'])) {
|
|
| 216 | - $encodingStyle = $opData['input']['encodingStyle']; |
|
| 217 | - } else {
|
|
| 218 | - $encodingStyle = ''; |
|
| 219 | - } |
|
| 220 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 221 | - $this->wsdl->clearDebug(); |
|
| 222 | - if ($errstr = $this->wsdl->getError()) {
|
|
| 223 | - $this->debug('got wsdl error: '.$errstr);
|
|
| 224 | - $this->setError('wsdl error: '.$errstr);
|
|
| 225 | - return false; |
|
| 226 | - } |
|
| 227 | - } elseif($this->endpointType == 'wsdl') {
|
|
| 228 | - // operation not in WSDL |
|
| 229 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 230 | - $this->wsdl->clearDebug(); |
|
| 231 | - $this->setError('operation '.$operation.' not present in WSDL.');
|
|
| 232 | - $this->debug("operation '$operation' not present in WSDL.");
|
|
| 233 | - return false; |
|
| 234 | - } else {
|
|
| 235 | - // no WSDL |
|
| 236 | - //$this->namespaces['ns1'] = $namespace; |
|
| 237 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 238 | - // serialize |
|
| 239 | - $payload = ''; |
|
| 240 | - if (is_string($params)) {
|
|
| 241 | - $this->debug("serializing param string for operation $operation");
|
|
| 242 | - $payload = $params; |
|
| 243 | - } elseif (is_array($params)) {
|
|
| 244 | - $this->debug("serializing param array for operation $operation");
|
|
| 245 | - foreach($params as $k => $v){
|
|
| 246 | - $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 247 | - } |
|
| 248 | - } else {
|
|
| 249 | - $this->debug('params must be array or string');
|
|
| 250 | - $this->setError('params must be array or string');
|
|
| 251 | - return false; |
|
| 252 | - } |
|
| 253 | - $usedNamespaces = array(); |
|
| 254 | - if ($use == 'encoded') {
|
|
| 255 | - $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 256 | - } else {
|
|
| 257 | - $encodingStyle = ''; |
|
| 258 | - } |
|
| 259 | - } |
|
| 260 | - // wrap RPC calls with method element |
|
| 261 | - if ($style == 'rpc') {
|
|
| 262 | - if ($use == 'literal') {
|
|
| 263 | - $this->debug("wrapping RPC request with literal method element");
|
|
| 264 | - if ($namespace) {
|
|
| 265 | - // 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 |
|
| 266 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 267 | - $payload . |
|
| 268 | - "</$nsPrefix:$operation>"; |
|
| 269 | - } else {
|
|
| 270 | - $payload = "<$operation>" . $payload . "</$operation>"; |
|
| 271 | - } |
|
| 272 | - } else {
|
|
| 273 | - $this->debug("wrapping RPC request with encoded method element");
|
|
| 274 | - if ($namespace) {
|
|
| 275 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 276 | - $payload . |
|
| 277 | - "</$nsPrefix:$operation>"; |
|
| 278 | - } else {
|
|
| 279 | - $payload = "<$operation>" . |
|
| 280 | - $payload . |
|
| 281 | - "</$operation>"; |
|
| 282 | - } |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - // serialize envelope |
|
| 286 | - $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); |
|
| 287 | - $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
|
|
| 288 | - $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
|
|
| 289 | - // send |
|
| 290 | - $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); |
|
| 291 | - if($errstr = $this->getError()){
|
|
| 292 | - $this->debug('Error: '.$errstr);
|
|
| 293 | - return false; |
|
| 294 | - } else {
|
|
| 295 | - $this->return = $return; |
|
| 296 | - $this->debug('sent message successfully and got a(n) '.gettype($return));
|
|
| 297 | - $this->appendDebug('return=' . $this->varDump($return));
|
|
| 215 | + if (isset($opData['input']['encodingStyle'])) {
|
|
| 216 | + $encodingStyle = $opData['input']['encodingStyle']; |
|
| 217 | + } else {
|
|
| 218 | + $encodingStyle = ''; |
|
| 219 | + } |
|
| 220 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 221 | + $this->wsdl->clearDebug(); |
|
| 222 | + if ($errstr = $this->wsdl->getError()) {
|
|
| 223 | + $this->debug('got wsdl error: '.$errstr);
|
|
| 224 | + $this->setError('wsdl error: '.$errstr);
|
|
| 225 | + return false; |
|
| 226 | + } |
|
| 227 | + } elseif($this->endpointType == 'wsdl') {
|
|
| 228 | + // operation not in WSDL |
|
| 229 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 230 | + $this->wsdl->clearDebug(); |
|
| 231 | + $this->setError('operation '.$operation.' not present in WSDL.');
|
|
| 232 | + $this->debug("operation '$operation' not present in WSDL.");
|
|
| 233 | + return false; |
|
| 234 | + } else {
|
|
| 235 | + // no WSDL |
|
| 236 | + //$this->namespaces['ns1'] = $namespace; |
|
| 237 | + $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 238 | + // serialize |
|
| 239 | + $payload = ''; |
|
| 240 | + if (is_string($params)) {
|
|
| 241 | + $this->debug("serializing param string for operation $operation");
|
|
| 242 | + $payload = $params; |
|
| 243 | + } elseif (is_array($params)) {
|
|
| 244 | + $this->debug("serializing param array for operation $operation");
|
|
| 245 | + foreach($params as $k => $v){
|
|
| 246 | + $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 247 | + } |
|
| 248 | + } else {
|
|
| 249 | + $this->debug('params must be array or string');
|
|
| 250 | + $this->setError('params must be array or string');
|
|
| 251 | + return false; |
|
| 252 | + } |
|
| 253 | + $usedNamespaces = array(); |
|
| 254 | + if ($use == 'encoded') {
|
|
| 255 | + $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
|
| 256 | + } else {
|
|
| 257 | + $encodingStyle = ''; |
|
| 258 | + } |
|
| 259 | + } |
|
| 260 | + // wrap RPC calls with method element |
|
| 261 | + if ($style == 'rpc') {
|
|
| 262 | + if ($use == 'literal') {
|
|
| 263 | + $this->debug("wrapping RPC request with literal method element");
|
|
| 264 | + if ($namespace) {
|
|
| 265 | + // 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 |
|
| 266 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 267 | + $payload . |
|
| 268 | + "</$nsPrefix:$operation>"; |
|
| 269 | + } else {
|
|
| 270 | + $payload = "<$operation>" . $payload . "</$operation>"; |
|
| 271 | + } |
|
| 272 | + } else {
|
|
| 273 | + $this->debug("wrapping RPC request with encoded method element");
|
|
| 274 | + if ($namespace) {
|
|
| 275 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 276 | + $payload . |
|
| 277 | + "</$nsPrefix:$operation>"; |
|
| 278 | + } else {
|
|
| 279 | + $payload = "<$operation>" . |
|
| 280 | + $payload . |
|
| 281 | + "</$operation>"; |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + // serialize envelope |
|
| 286 | + $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); |
|
| 287 | + $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
|
|
| 288 | + $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
|
|
| 289 | + // send |
|
| 290 | + $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); |
|
| 291 | + if($errstr = $this->getError()){
|
|
| 292 | + $this->debug('Error: '.$errstr);
|
|
| 293 | + return false; |
|
| 294 | + } else {
|
|
| 295 | + $this->return = $return; |
|
| 296 | + $this->debug('sent message successfully and got a(n) '.gettype($return));
|
|
| 297 | + $this->appendDebug('return=' . $this->varDump($return));
|
|
| 298 | 298 | |
| 299 | - // fault? |
|
| 300 | - if(is_array($return) && isset($return['faultcode'])){
|
|
| 301 | - $this->debug('got fault');
|
|
| 302 | - $this->setError($return['faultcode'].': '.$return['faultstring']); |
|
| 303 | - $this->fault = true; |
|
| 304 | - foreach($return as $k => $v){
|
|
| 305 | - $this->$k = $v; |
|
| 306 | - $this->debug("$k = $v<br>");
|
|
| 307 | - } |
|
| 308 | - return $return; |
|
| 309 | - } elseif ($style == 'document') {
|
|
| 310 | - // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), |
|
| 311 | - // we are only going to return the first part here...sorry about that |
|
| 312 | - return $return; |
|
| 313 | - } else {
|
|
| 314 | - // array of return values |
|
| 315 | - if(is_array($return)){
|
|
| 316 | - // multiple 'out' parameters, which we return wrapped up |
|
| 317 | - // in the array |
|
| 318 | - if(sizeof($return) > 1){
|
|
| 319 | - return $return; |
|
| 320 | - } |
|
| 321 | - // single 'out' parameter (normally the return value) |
|
| 322 | - $return = array_shift($return); |
|
| 323 | - $this->debug('return shifted value: ');
|
|
| 324 | - $this->appendDebug($this->varDump($return)); |
|
| 325 | - return $return; |
|
| 326 | - // nothing returned (ie, echoVoid) |
|
| 327 | - } else {
|
|
| 328 | - return ""; |
|
| 329 | - } |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - } |
|
| 299 | + // fault? |
|
| 300 | + if(is_array($return) && isset($return['faultcode'])){
|
|
| 301 | + $this->debug('got fault');
|
|
| 302 | + $this->setError($return['faultcode'].': '.$return['faultstring']); |
|
| 303 | + $this->fault = true; |
|
| 304 | + foreach($return as $k => $v){
|
|
| 305 | + $this->$k = $v; |
|
| 306 | + $this->debug("$k = $v<br>");
|
|
| 307 | + } |
|
| 308 | + return $return; |
|
| 309 | + } elseif ($style == 'document') {
|
|
| 310 | + // NOTE: if the response is defined to have multiple parts (i.e. unwrapped), |
|
| 311 | + // we are only going to return the first part here...sorry about that |
|
| 312 | + return $return; |
|
| 313 | + } else {
|
|
| 314 | + // array of return values |
|
| 315 | + if(is_array($return)){
|
|
| 316 | + // multiple 'out' parameters, which we return wrapped up |
|
| 317 | + // in the array |
|
| 318 | + if(sizeof($return) > 1){
|
|
| 319 | + return $return; |
|
| 320 | + } |
|
| 321 | + // single 'out' parameter (normally the return value) |
|
| 322 | + $return = array_shift($return); |
|
| 323 | + $this->debug('return shifted value: ');
|
|
| 324 | + $this->appendDebug($this->varDump($return)); |
|
| 325 | + return $return; |
|
| 326 | + // nothing returned (ie, echoVoid) |
|
| 327 | + } else {
|
|
| 328 | + return ""; |
|
| 329 | + } |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - /** |
|
| 335 | - * check WSDL passed as an instance or pulled from an endpoint |
|
| 336 | - * |
|
| 337 | - * @access private |
|
| 338 | - */ |
|
| 339 | - function checkWSDL() {
|
|
| 340 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 341 | - $this->wsdl->clearDebug(); |
|
| 342 | - $this->debug('checkWSDL');
|
|
| 343 | - // catch errors |
|
| 344 | - if ($errstr = $this->wsdl->getError()) {
|
|
| 345 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 346 | - $this->wsdl->clearDebug(); |
|
| 347 | - $this->debug('got wsdl error: '.$errstr);
|
|
| 348 | - $this->setError('wsdl error: '.$errstr);
|
|
| 349 | - } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
|
|
| 350 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 351 | - $this->wsdl->clearDebug(); |
|
| 352 | - $this->bindingType = 'soap'; |
|
| 353 | - $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 354 | - } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
|
|
| 355 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 356 | - $this->wsdl->clearDebug(); |
|
| 357 | - $this->bindingType = 'soap12'; |
|
| 358 | - $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 359 | - $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
|
|
| 360 | - } else {
|
|
| 361 | - $this->appendDebug($this->wsdl->getDebug()); |
|
| 362 | - $this->wsdl->clearDebug(); |
|
| 363 | - $this->debug('getOperations returned false');
|
|
| 364 | - $this->setError('no operations defined in the WSDL document!');
|
|
| 365 | - } |
|
| 366 | - } |
|
| 334 | + /** |
|
| 335 | + * check WSDL passed as an instance or pulled from an endpoint |
|
| 336 | + * |
|
| 337 | + * @access private |
|
| 338 | + */ |
|
| 339 | + function checkWSDL() {
|
|
| 340 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 341 | + $this->wsdl->clearDebug(); |
|
| 342 | + $this->debug('checkWSDL');
|
|
| 343 | + // catch errors |
|
| 344 | + if ($errstr = $this->wsdl->getError()) {
|
|
| 345 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 346 | + $this->wsdl->clearDebug(); |
|
| 347 | + $this->debug('got wsdl error: '.$errstr);
|
|
| 348 | + $this->setError('wsdl error: '.$errstr);
|
|
| 349 | + } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
|
|
| 350 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 351 | + $this->wsdl->clearDebug(); |
|
| 352 | + $this->bindingType = 'soap'; |
|
| 353 | + $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 354 | + } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
|
|
| 355 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 356 | + $this->wsdl->clearDebug(); |
|
| 357 | + $this->bindingType = 'soap12'; |
|
| 358 | + $this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
|
|
| 359 | + $this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
|
|
| 360 | + } else {
|
|
| 361 | + $this->appendDebug($this->wsdl->getDebug()); |
|
| 362 | + $this->wsdl->clearDebug(); |
|
| 363 | + $this->debug('getOperations returned false');
|
|
| 364 | + $this->setError('no operations defined in the WSDL document!');
|
|
| 365 | + } |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - /** |
|
| 369 | - * instantiate wsdl object and parse wsdl file |
|
| 370 | - * |
|
| 371 | - * @access public |
|
| 372 | - */ |
|
| 373 | - function loadWSDL() {
|
|
| 374 | - $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
|
|
| 375 | - $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
|
|
| 376 | - $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); |
|
| 377 | - $this->wsdl->fetchWSDL($this->wsdlFile); |
|
| 378 | - $this->checkWSDL(); |
|
| 379 | - } |
|
| 368 | + /** |
|
| 369 | + * instantiate wsdl object and parse wsdl file |
|
| 370 | + * |
|
| 371 | + * @access public |
|
| 372 | + */ |
|
| 373 | + function loadWSDL() {
|
|
| 374 | + $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
|
|
| 375 | + $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
|
|
| 376 | + $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); |
|
| 377 | + $this->wsdl->fetchWSDL($this->wsdlFile); |
|
| 378 | + $this->checkWSDL(); |
|
| 379 | + } |
|
| 380 | 380 | |
| 381 | - /** |
|
| 382 | - * get available data pertaining to an operation |
|
| 383 | - * |
|
| 384 | - * @param string $operation operation name |
|
| 385 | - * @return array array of data pertaining to the operation |
|
| 386 | - * @access public |
|
| 387 | - */ |
|
| 388 | - function getOperationData($operation){
|
|
| 389 | - if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 390 | - $this->loadWSDL(); |
|
| 391 | - if ($this->getError()) |
|
| 392 | - return false; |
|
| 393 | - } |
|
| 394 | - if(isset($this->operations[$operation])){
|
|
| 395 | - return $this->operations[$operation]; |
|
| 396 | - } |
|
| 397 | - $this->debug("No data for operation: $operation");
|
|
| 398 | - } |
|
| 381 | + /** |
|
| 382 | + * get available data pertaining to an operation |
|
| 383 | + * |
|
| 384 | + * @param string $operation operation name |
|
| 385 | + * @return array array of data pertaining to the operation |
|
| 386 | + * @access public |
|
| 387 | + */ |
|
| 388 | + function getOperationData($operation){
|
|
| 389 | + if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 390 | + $this->loadWSDL(); |
|
| 391 | + if ($this->getError()) |
|
| 392 | + return false; |
|
| 393 | + } |
|
| 394 | + if(isset($this->operations[$operation])){
|
|
| 395 | + return $this->operations[$operation]; |
|
| 396 | + } |
|
| 397 | + $this->debug("No data for operation: $operation");
|
|
| 398 | + } |
|
| 399 | 399 | |
| 400 | 400 | /** |
| 401 | - * send the SOAP message |
|
| 402 | - * |
|
| 403 | - * Note: if the operation has multiple return values |
|
| 404 | - * the return value of this method will be an array |
|
| 405 | - * of those values. |
|
| 406 | - * |
|
| 407 | - * @param string $msg a SOAPx4 soapmsg object |
|
| 408 | - * @param string $soapaction SOAPAction value |
|
| 409 | - * @param integer $timeout set connection timeout in seconds |
|
| 410 | - * @param integer $response_timeout set response timeout in seconds |
|
| 411 | - * @return mixed native PHP types. |
|
| 412 | - * @access private |
|
| 413 | - */ |
|
| 414 | - function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
|
|
| 415 | - $this->checkCookies(); |
|
| 416 | - // detect transport |
|
| 417 | - switch(true){
|
|
| 418 | - // http(s) |
|
| 419 | - case preg_match('/^http/',$this->endpoint):
|
|
| 420 | - $this->debug('transporting via HTTP');
|
|
| 421 | - if($this->persistentConnection == true && is_object($this->persistentConnection)){
|
|
| 422 | - $http =& $this->persistentConnection; |
|
| 423 | - } else {
|
|
| 424 | - $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); |
|
| 425 | - if ($this->persistentConnection) {
|
|
| 426 | - $http->usePersistentConnection(); |
|
| 427 | - } |
|
| 428 | - } |
|
| 429 | - $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); |
|
| 430 | - $http->setSOAPAction($soapaction); |
|
| 431 | - if($this->proxyhost && $this->proxyport){
|
|
| 432 | - $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 433 | - } |
|
| 401 | + * send the SOAP message |
|
| 402 | + * |
|
| 403 | + * Note: if the operation has multiple return values |
|
| 404 | + * the return value of this method will be an array |
|
| 405 | + * of those values. |
|
| 406 | + * |
|
| 407 | + * @param string $msg a SOAPx4 soapmsg object |
|
| 408 | + * @param string $soapaction SOAPAction value |
|
| 409 | + * @param integer $timeout set connection timeout in seconds |
|
| 410 | + * @param integer $response_timeout set response timeout in seconds |
|
| 411 | + * @return mixed native PHP types. |
|
| 412 | + * @access private |
|
| 413 | + */ |
|
| 414 | + function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
|
|
| 415 | + $this->checkCookies(); |
|
| 416 | + // detect transport |
|
| 417 | + switch(true){
|
|
| 418 | + // http(s) |
|
| 419 | + case preg_match('/^http/',$this->endpoint):
|
|
| 420 | + $this->debug('transporting via HTTP');
|
|
| 421 | + if($this->persistentConnection == true && is_object($this->persistentConnection)){
|
|
| 422 | + $http =& $this->persistentConnection; |
|
| 423 | + } else {
|
|
| 424 | + $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); |
|
| 425 | + if ($this->persistentConnection) {
|
|
| 426 | + $http->usePersistentConnection(); |
|
| 427 | + } |
|
| 428 | + } |
|
| 429 | + $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); |
|
| 430 | + $http->setSOAPAction($soapaction); |
|
| 431 | + if($this->proxyhost && $this->proxyport){
|
|
| 432 | + $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 433 | + } |
|
| 434 | 434 | if($this->authtype != '') {
|
| 435 | - $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
|
| 436 | - } |
|
| 437 | - if($this->http_encoding != ''){
|
|
| 438 | - $http->setEncoding($this->http_encoding); |
|
| 439 | - } |
|
| 440 | - $this->debug('sending message, length='.strlen($msg));
|
|
| 441 | - if(preg_match('/^http:/',$this->endpoint)){
|
|
| 442 | - //if(strpos($this->endpoint,'http:')){
|
|
| 443 | - $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); |
|
| 444 | - } elseif(preg_match('/^https/',$this->endpoint)){
|
|
| 445 | - //} elseif(strpos($this->endpoint,'https:')){
|
|
| 446 | - //if(phpversion() == '4.3.0-dev'){
|
|
| 447 | - //$response = $http->send($msg,$timeout,$response_timeout); |
|
| 448 | - //$this->request = $http->outgoing_payload; |
|
| 449 | - //$this->response = $http->incoming_payload; |
|
| 450 | - //} else |
|
| 451 | - $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); |
|
| 452 | - } else {
|
|
| 453 | - $this->setError('no http/s in endpoint url');
|
|
| 454 | - } |
|
| 455 | - $this->request = $http->outgoing_payload; |
|
| 456 | - $this->response = $http->incoming_payload; |
|
| 457 | - $this->appendDebug($http->getDebug()); |
|
| 458 | - $this->UpdateCookies($http->incoming_cookies); |
|
| 459 | - |
|
| 460 | - // save transport object if using persistent connections |
|
| 461 | - if ($this->persistentConnection) {
|
|
| 462 | - $http->clearDebug(); |
|
| 463 | - if (!is_object($this->persistentConnection)) {
|
|
| 464 | - $this->persistentConnection = $http; |
|
| 465 | - } |
|
| 466 | - } |
|
| 435 | + $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
|
| 436 | + } |
|
| 437 | + if($this->http_encoding != ''){
|
|
| 438 | + $http->setEncoding($this->http_encoding); |
|
| 439 | + } |
|
| 440 | + $this->debug('sending message, length='.strlen($msg));
|
|
| 441 | + if(preg_match('/^http:/',$this->endpoint)){
|
|
| 442 | + //if(strpos($this->endpoint,'http:')){
|
|
| 443 | + $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); |
|
| 444 | + } elseif(preg_match('/^https/',$this->endpoint)){
|
|
| 445 | + //} elseif(strpos($this->endpoint,'https:')){
|
|
| 446 | + //if(phpversion() == '4.3.0-dev'){
|
|
| 447 | + //$response = $http->send($msg,$timeout,$response_timeout); |
|
| 448 | + //$this->request = $http->outgoing_payload; |
|
| 449 | + //$this->response = $http->incoming_payload; |
|
| 450 | + //} else |
|
| 451 | + $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); |
|
| 452 | + } else {
|
|
| 453 | + $this->setError('no http/s in endpoint url');
|
|
| 454 | + } |
|
| 455 | + $this->request = $http->outgoing_payload; |
|
| 456 | + $this->response = $http->incoming_payload; |
|
| 457 | + $this->appendDebug($http->getDebug()); |
|
| 458 | + $this->UpdateCookies($http->incoming_cookies); |
|
| 459 | + |
|
| 460 | + // save transport object if using persistent connections |
|
| 461 | + if ($this->persistentConnection) {
|
|
| 462 | + $http->clearDebug(); |
|
| 463 | + if (!is_object($this->persistentConnection)) {
|
|
| 464 | + $this->persistentConnection = $http; |
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | 467 | |
| 468 | - if($err = $http->getError()){
|
|
| 469 | - $this->setError('HTTP Error: '.$err);
|
|
| 470 | - return false; |
|
| 471 | - } elseif($this->getError()){
|
|
| 472 | - return false; |
|
| 473 | - } else {
|
|
| 474 | - $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 475 | - return $this->parseResponse($http->incoming_headers, $this->responseData); |
|
| 476 | - } |
|
| 477 | - break; |
|
| 478 | - default: |
|
| 479 | - $this->setError('no transport found, or selected transport is not yet supported!');
|
|
| 480 | - return false; |
|
| 481 | - break; |
|
| 482 | - } |
|
| 483 | - } |
|
| 468 | + if($err = $http->getError()){
|
|
| 469 | + $this->setError('HTTP Error: '.$err);
|
|
| 470 | + return false; |
|
| 471 | + } elseif($this->getError()){
|
|
| 472 | + return false; |
|
| 473 | + } else {
|
|
| 474 | + $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 475 | + return $this->parseResponse($http->incoming_headers, $this->responseData); |
|
| 476 | + } |
|
| 477 | + break; |
|
| 478 | + default: |
|
| 479 | + $this->setError('no transport found, or selected transport is not yet supported!');
|
|
| 480 | + return false; |
|
| 481 | + break; |
|
| 482 | + } |
|
| 483 | + } |
|
| 484 | 484 | |
| 485 | - /** |
|
| 486 | - * processes SOAP message returned from server |
|
| 487 | - * |
|
| 488 | - * @param array $headers The HTTP headers |
|
| 489 | - * @param string $data unprocessed response data from server |
|
| 490 | - * @return mixed value of the message, decoded into a PHP type |
|
| 491 | - * @access private |
|
| 492 | - */ |
|
| 485 | + /** |
|
| 486 | + * processes SOAP message returned from server |
|
| 487 | + * |
|
| 488 | + * @param array $headers The HTTP headers |
|
| 489 | + * @param string $data unprocessed response data from server |
|
| 490 | + * @return mixed value of the message, decoded into a PHP type |
|
| 491 | + * @access private |
|
| 492 | + */ |
|
| 493 | 493 | function parseResponse($headers, $data) {
|
| 494 | - $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
|
|
| 495 | - $this->appendDebug($this->varDump($headers)); |
|
| 496 | - if (!isset($headers['content-type'])) {
|
|
| 497 | - $this->setError('Response not of type text/xml (no content-type header)');
|
|
| 498 | - return false; |
|
| 499 | - } |
|
| 500 | - if (!strstr($headers['content-type'], 'text/xml')) {
|
|
| 501 | - $this->setError('Response not of type text/xml: ' . $headers['content-type']);
|
|
| 502 | - return false; |
|
| 503 | - } |
|
| 504 | - if (strpos($headers['content-type'], '=')) {
|
|
| 505 | - $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
|
| 506 | - $this->debug('Got response encoding: ' . $enc);
|
|
| 507 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 508 | - $this->xml_encoding = strtoupper($enc); |
|
| 509 | - } else {
|
|
| 510 | - $this->xml_encoding = 'US-ASCII'; |
|
| 511 | - } |
|
| 512 | - } else {
|
|
| 513 | - // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 514 | - $this->xml_encoding = 'ISO-8859-1'; |
|
| 515 | - } |
|
| 516 | - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 517 | - $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); |
|
| 518 | - // add parser debug data to our debug |
|
| 519 | - $this->appendDebug($parser->getDebug()); |
|
| 520 | - // if parse errors |
|
| 521 | - if($errstr = $parser->getError()){
|
|
| 522 | - $this->setError( $errstr); |
|
| 523 | - // destroy the parser object |
|
| 524 | - unset($parser); |
|
| 525 | - return false; |
|
| 526 | - } else {
|
|
| 527 | - // get SOAP headers |
|
| 528 | - $this->responseHeaders = $parser->getHeaders(); |
|
| 529 | - // get SOAP headers |
|
| 530 | - $this->responseHeader = $parser->get_soapheader(); |
|
| 531 | - // get decoded message |
|
| 532 | - $return = $parser->get_soapbody(); |
|
| 494 | + $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
|
|
| 495 | + $this->appendDebug($this->varDump($headers)); |
|
| 496 | + if (!isset($headers['content-type'])) {
|
|
| 497 | + $this->setError('Response not of type text/xml (no content-type header)');
|
|
| 498 | + return false; |
|
| 499 | + } |
|
| 500 | + if (!strstr($headers['content-type'], 'text/xml')) {
|
|
| 501 | + $this->setError('Response not of type text/xml: ' . $headers['content-type']);
|
|
| 502 | + return false; |
|
| 503 | + } |
|
| 504 | + if (strpos($headers['content-type'], '=')) {
|
|
| 505 | + $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
|
| 506 | + $this->debug('Got response encoding: ' . $enc);
|
|
| 507 | + if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 508 | + $this->xml_encoding = strtoupper($enc); |
|
| 509 | + } else {
|
|
| 510 | + $this->xml_encoding = 'US-ASCII'; |
|
| 511 | + } |
|
| 512 | + } else {
|
|
| 513 | + // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
|
| 514 | + $this->xml_encoding = 'ISO-8859-1'; |
|
| 515 | + } |
|
| 516 | + $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 517 | + $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); |
|
| 518 | + // add parser debug data to our debug |
|
| 519 | + $this->appendDebug($parser->getDebug()); |
|
| 520 | + // if parse errors |
|
| 521 | + if($errstr = $parser->getError()){
|
|
| 522 | + $this->setError( $errstr); |
|
| 523 | + // destroy the parser object |
|
| 524 | + unset($parser); |
|
| 525 | + return false; |
|
| 526 | + } else {
|
|
| 527 | + // get SOAP headers |
|
| 528 | + $this->responseHeaders = $parser->getHeaders(); |
|
| 529 | + // get SOAP headers |
|
| 530 | + $this->responseHeader = $parser->get_soapheader(); |
|
| 531 | + // get decoded message |
|
| 532 | + $return = $parser->get_soapbody(); |
|
| 533 | 533 | // add document for doclit support |
| 534 | 534 | $this->document = $parser->document; |
| 535 | - // destroy the parser object |
|
| 536 | - unset($parser); |
|
| 537 | - // return decode message |
|
| 538 | - return $return; |
|
| 539 | - } |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - /** |
|
| 543 | - * sets user-specified cURL options |
|
| 544 | - * |
|
| 545 | - * @param mixed $option The cURL option (always integer?) |
|
| 546 | - * @param mixed $value The cURL option value |
|
| 547 | - * @access public |
|
| 548 | - */ |
|
| 549 | - function setCurlOption($option, $value) {
|
|
| 550 | - $this->debug("setCurlOption option=$option, value=");
|
|
| 551 | - $this->appendDebug($this->varDump($value)); |
|
| 552 | - $this->curl_options[$option] = $value; |
|
| 553 | - } |
|
| 535 | + // destroy the parser object |
|
| 536 | + unset($parser); |
|
| 537 | + // return decode message |
|
| 538 | + return $return; |
|
| 539 | + } |
|
| 540 | + } |
|
| 554 | 541 | |
| 555 | - /** |
|
| 556 | - * sets the SOAP endpoint, which can override WSDL |
|
| 557 | - * |
|
| 558 | - * @param string $endpoint The endpoint URL to use, or empty string or false to prevent override |
|
| 559 | - * @access public |
|
| 560 | - */ |
|
| 561 | - function setEndpoint($endpoint) {
|
|
| 562 | - $this->debug("setEndpoint(\"$endpoint\")");
|
|
| 563 | - $this->forceEndpoint = $endpoint; |
|
| 564 | - } |
|
| 542 | + /** |
|
| 543 | + * sets user-specified cURL options |
|
| 544 | + * |
|
| 545 | + * @param mixed $option The cURL option (always integer?) |
|
| 546 | + * @param mixed $value The cURL option value |
|
| 547 | + * @access public |
|
| 548 | + */ |
|
| 549 | + function setCurlOption($option, $value) {
|
|
| 550 | + $this->debug("setCurlOption option=$option, value=");
|
|
| 551 | + $this->appendDebug($this->varDump($value)); |
|
| 552 | + $this->curl_options[$option] = $value; |
|
| 553 | + } |
|
| 565 | 554 | |
| 566 | - /** |
|
| 567 | - * set the SOAP headers |
|
| 568 | - * |
|
| 569 | - * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers |
|
| 570 | - * @access public |
|
| 571 | - */ |
|
| 572 | - function setHeaders($headers){
|
|
| 573 | - $this->debug("setHeaders headers=");
|
|
| 574 | - $this->appendDebug($this->varDump($headers)); |
|
| 575 | - $this->requestHeaders = $headers; |
|
| 576 | - } |
|
| 555 | + /** |
|
| 556 | + * sets the SOAP endpoint, which can override WSDL |
|
| 557 | + * |
|
| 558 | + * @param string $endpoint The endpoint URL to use, or empty string or false to prevent override |
|
| 559 | + * @access public |
|
| 560 | + */ |
|
| 561 | + function setEndpoint($endpoint) {
|
|
| 562 | + $this->debug("setEndpoint(\"$endpoint\")");
|
|
| 563 | + $this->forceEndpoint = $endpoint; |
|
| 564 | + } |
|
| 577 | 565 | |
| 578 | - /** |
|
| 579 | - * get the SOAP response headers (namespace resolution incomplete) |
|
| 580 | - * |
|
| 581 | - * @return string |
|
| 582 | - * @access public |
|
| 583 | - */ |
|
| 584 | - function getHeaders(){
|
|
| 585 | - return $this->responseHeaders; |
|
| 586 | - } |
|
| 566 | + /** |
|
| 567 | + * set the SOAP headers |
|
| 568 | + * |
|
| 569 | + * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers |
|
| 570 | + * @access public |
|
| 571 | + */ |
|
| 572 | + function setHeaders($headers){
|
|
| 573 | + $this->debug("setHeaders headers=");
|
|
| 574 | + $this->appendDebug($this->varDump($headers)); |
|
| 575 | + $this->requestHeaders = $headers; |
|
| 576 | + } |
|
| 587 | 577 | |
| 588 | - /** |
|
| 589 | - * get the SOAP response Header (parsed) |
|
| 590 | - * |
|
| 591 | - * @return mixed |
|
| 592 | - * @access public |
|
| 593 | - */ |
|
| 594 | - function getHeader(){
|
|
| 595 | - return $this->responseHeader; |
|
| 596 | - } |
|
| 578 | + /** |
|
| 579 | + * get the SOAP response headers (namespace resolution incomplete) |
|
| 580 | + * |
|
| 581 | + * @return string |
|
| 582 | + * @access public |
|
| 583 | + */ |
|
| 584 | + function getHeaders(){
|
|
| 585 | + return $this->responseHeaders; |
|
| 586 | + } |
|
| 597 | 587 | |
| 598 | - /** |
|
| 599 | - * set proxy info here |
|
| 600 | - * |
|
| 601 | - * @param string $proxyhost |
|
| 602 | - * @param string $proxyport |
|
| 603 | - * @param string $proxyusername |
|
| 604 | - * @param string $proxypassword |
|
| 605 | - * @access public |
|
| 606 | - */ |
|
| 607 | - function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
|
|
| 608 | - $this->proxyhost = $proxyhost; |
|
| 609 | - $this->proxyport = $proxyport; |
|
| 610 | - $this->proxyusername = $proxyusername; |
|
| 611 | - $this->proxypassword = $proxypassword; |
|
| 612 | - } |
|
| 588 | + /** |
|
| 589 | + * get the SOAP response Header (parsed) |
|
| 590 | + * |
|
| 591 | + * @return mixed |
|
| 592 | + * @access public |
|
| 593 | + */ |
|
| 594 | + function getHeader(){
|
|
| 595 | + return $this->responseHeader; |
|
| 596 | + } |
|
| 613 | 597 | |
| 614 | - /** |
|
| 615 | - * if authenticating, set user credentials here |
|
| 616 | - * |
|
| 617 | - * @param string $username |
|
| 618 | - * @param string $password |
|
| 619 | - * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 620 | - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 621 | - * @access public |
|
| 622 | - */ |
|
| 623 | - function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
|
|
| 624 | - $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
|
|
| 625 | - $this->appendDebug($this->varDump($certRequest)); |
|
| 626 | - $this->username = $username; |
|
| 627 | - $this->password = $password; |
|
| 628 | - $this->authtype = $authtype; |
|
| 629 | - $this->certRequest = $certRequest; |
|
| 630 | - } |
|
| 598 | + /** |
|
| 599 | + * set proxy info here |
|
| 600 | + * |
|
| 601 | + * @param string $proxyhost |
|
| 602 | + * @param string $proxyport |
|
| 603 | + * @param string $proxyusername |
|
| 604 | + * @param string $proxypassword |
|
| 605 | + * @access public |
|
| 606 | + */ |
|
| 607 | + function setHTTPProxy($proxyhost, $proxyport, $proxyusername = '', $proxypassword = '') {
|
|
| 608 | + $this->proxyhost = $proxyhost; |
|
| 609 | + $this->proxyport = $proxyport; |
|
| 610 | + $this->proxyusername = $proxyusername; |
|
| 611 | + $this->proxypassword = $proxypassword; |
|
| 612 | + } |
|
| 613 | + |
|
| 614 | + /** |
|
| 615 | + * if authenticating, set user credentials here |
|
| 616 | + * |
|
| 617 | + * @param string $username |
|
| 618 | + * @param string $password |
|
| 619 | + * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 620 | + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 621 | + * @access public |
|
| 622 | + */ |
|
| 623 | + function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) {
|
|
| 624 | + $this->debug("setCredentials username=$username authtype=$authtype certRequest=");
|
|
| 625 | + $this->appendDebug($this->varDump($certRequest)); |
|
| 626 | + $this->username = $username; |
|
| 627 | + $this->password = $password; |
|
| 628 | + $this->authtype = $authtype; |
|
| 629 | + $this->certRequest = $certRequest; |
|
| 630 | + } |
|
| 631 | 631 | |
| 632 | - /** |
|
| 633 | - * use HTTP encoding |
|
| 634 | - * |
|
| 635 | - * @param string $enc HTTP encoding |
|
| 636 | - * @access public |
|
| 637 | - */ |
|
| 638 | - function setHTTPEncoding($enc='gzip, deflate'){
|
|
| 639 | - $this->debug("setHTTPEncoding(\"$enc\")");
|
|
| 640 | - $this->http_encoding = $enc; |
|
| 641 | - } |
|
| 632 | + /** |
|
| 633 | + * use HTTP encoding |
|
| 634 | + * |
|
| 635 | + * @param string $enc HTTP encoding |
|
| 636 | + * @access public |
|
| 637 | + */ |
|
| 638 | + function setHTTPEncoding($enc='gzip, deflate'){
|
|
| 639 | + $this->debug("setHTTPEncoding(\"$enc\")");
|
|
| 640 | + $this->http_encoding = $enc; |
|
| 641 | + } |
|
| 642 | 642 | |
| 643 | - /** |
|
| 644 | - * Set whether to try to use cURL connections if possible |
|
| 645 | - * |
|
| 646 | - * @param boolean $use Whether to try to use cURL |
|
| 647 | - * @access public |
|
| 648 | - */ |
|
| 649 | - function setUseCURL($use) {
|
|
| 650 | - $this->debug("setUseCURL($use)");
|
|
| 651 | - $this->use_curl = $use; |
|
| 652 | - } |
|
| 643 | + /** |
|
| 644 | + * Set whether to try to use cURL connections if possible |
|
| 645 | + * |
|
| 646 | + * @param boolean $use Whether to try to use cURL |
|
| 647 | + * @access public |
|
| 648 | + */ |
|
| 649 | + function setUseCURL($use) {
|
|
| 650 | + $this->debug("setUseCURL($use)");
|
|
| 651 | + $this->use_curl = $use; |
|
| 652 | + } |
|
| 653 | 653 | |
| 654 | - /** |
|
| 655 | - * use HTTP persistent connections if possible |
|
| 656 | - * |
|
| 657 | - * @access public |
|
| 658 | - */ |
|
| 659 | - function useHTTPPersistentConnection(){
|
|
| 660 | - $this->debug("useHTTPPersistentConnection");
|
|
| 661 | - $this->persistentConnection = true; |
|
| 662 | - } |
|
| 654 | + /** |
|
| 655 | + * use HTTP persistent connections if possible |
|
| 656 | + * |
|
| 657 | + * @access public |
|
| 658 | + */ |
|
| 659 | + function useHTTPPersistentConnection(){
|
|
| 660 | + $this->debug("useHTTPPersistentConnection");
|
|
| 661 | + $this->persistentConnection = true; |
|
| 662 | + } |
|
| 663 | 663 | |
| 664 | - /** |
|
| 665 | - * gets the default RPC parameter setting. |
|
| 666 | - * If true, default is that call params are like RPC even for document style. |
|
| 667 | - * Each call() can override this value. |
|
| 668 | - * |
|
| 669 | - * This is no longer used. |
|
| 670 | - * |
|
| 671 | - * @return boolean |
|
| 672 | - * @access public |
|
| 673 | - * @deprecated |
|
| 674 | - */ |
|
| 675 | - function getDefaultRpcParams() {
|
|
| 676 | - return $this->defaultRpcParams; |
|
| 677 | - } |
|
| 664 | + /** |
|
| 665 | + * gets the default RPC parameter setting. |
|
| 666 | + * If true, default is that call params are like RPC even for document style. |
|
| 667 | + * Each call() can override this value. |
|
| 668 | + * |
|
| 669 | + * This is no longer used. |
|
| 670 | + * |
|
| 671 | + * @return boolean |
|
| 672 | + * @access public |
|
| 673 | + * @deprecated |
|
| 674 | + */ |
|
| 675 | + function getDefaultRpcParams() {
|
|
| 676 | + return $this->defaultRpcParams; |
|
| 677 | + } |
|
| 678 | 678 | |
| 679 | - /** |
|
| 680 | - * sets the default RPC parameter setting. |
|
| 681 | - * If true, default is that call params are like RPC even for document style |
|
| 682 | - * Each call() can override this value. |
|
| 683 | - * |
|
| 684 | - * This is no longer used. |
|
| 685 | - * |
|
| 686 | - * @param boolean $rpcParams |
|
| 687 | - * @access public |
|
| 688 | - * @deprecated |
|
| 689 | - */ |
|
| 690 | - function setDefaultRpcParams($rpcParams) {
|
|
| 691 | - $this->defaultRpcParams = $rpcParams; |
|
| 692 | - } |
|
| 679 | + /** |
|
| 680 | + * sets the default RPC parameter setting. |
|
| 681 | + * If true, default is that call params are like RPC even for document style |
|
| 682 | + * Each call() can override this value. |
|
| 683 | + * |
|
| 684 | + * This is no longer used. |
|
| 685 | + * |
|
| 686 | + * @param boolean $rpcParams |
|
| 687 | + * @access public |
|
| 688 | + * @deprecated |
|
| 689 | + */ |
|
| 690 | + function setDefaultRpcParams($rpcParams) {
|
|
| 691 | + $this->defaultRpcParams = $rpcParams; |
|
| 692 | + } |
|
| 693 | 693 | |
| 694 | - /** |
|
| 695 | - * dynamically creates an instance of a proxy class, |
|
| 696 | - * allowing user to directly call methods from wsdl |
|
| 697 | - * |
|
| 698 | - * @return object soap_proxy object |
|
| 699 | - * @access public |
|
| 700 | - */ |
|
| 701 | - function getProxy() {
|
|
| 702 | - $r = rand(); |
|
| 703 | - $evalStr = $this->_getProxyClassCode($r); |
|
| 704 | - //$this->debug("proxy class: $evalStr");
|
|
| 705 | - if ($this->getError()) {
|
|
| 706 | - $this->debug("Error from _getProxyClassCode, so return NULL");
|
|
| 707 | - return null; |
|
| 708 | - } |
|
| 709 | - // eval the class |
|
| 710 | - eval($evalStr); |
|
| 711 | - // instantiate proxy object |
|
| 712 | - eval("\$proxy = new nusoap_proxy_$r('');");
|
|
| 713 | - // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice |
|
| 714 | - $proxy->endpointType = 'wsdl'; |
|
| 715 | - $proxy->wsdlFile = $this->wsdlFile; |
|
| 716 | - $proxy->wsdl = $this->wsdl; |
|
| 717 | - $proxy->operations = $this->operations; |
|
| 718 | - $proxy->defaultRpcParams = $this->defaultRpcParams; |
|
| 719 | - // transfer other state |
|
| 720 | - $proxy->soap_defencoding = $this->soap_defencoding; |
|
| 721 | - $proxy->username = $this->username; |
|
| 722 | - $proxy->password = $this->password; |
|
| 723 | - $proxy->authtype = $this->authtype; |
|
| 724 | - $proxy->certRequest = $this->certRequest; |
|
| 725 | - $proxy->requestHeaders = $this->requestHeaders; |
|
| 726 | - $proxy->endpoint = $this->endpoint; |
|
| 727 | - $proxy->forceEndpoint = $this->forceEndpoint; |
|
| 728 | - $proxy->proxyhost = $this->proxyhost; |
|
| 729 | - $proxy->proxyport = $this->proxyport; |
|
| 730 | - $proxy->proxyusername = $this->proxyusername; |
|
| 731 | - $proxy->proxypassword = $this->proxypassword; |
|
| 732 | - $proxy->http_encoding = $this->http_encoding; |
|
| 733 | - $proxy->timeout = $this->timeout; |
|
| 734 | - $proxy->response_timeout = $this->response_timeout; |
|
| 735 | - $proxy->persistentConnection = &$this->persistentConnection; |
|
| 736 | - $proxy->decode_utf8 = $this->decode_utf8; |
|
| 737 | - $proxy->curl_options = $this->curl_options; |
|
| 738 | - $proxy->bindingType = $this->bindingType; |
|
| 739 | - $proxy->use_curl = $this->use_curl; |
|
| 740 | - return $proxy; |
|
| 741 | - } |
|
| 694 | + /** |
|
| 695 | + * dynamically creates an instance of a proxy class, |
|
| 696 | + * allowing user to directly call methods from wsdl |
|
| 697 | + * |
|
| 698 | + * @return object soap_proxy object |
|
| 699 | + * @access public |
|
| 700 | + */ |
|
| 701 | + function getProxy() {
|
|
| 702 | + $r = rand(); |
|
| 703 | + $evalStr = $this->_getProxyClassCode($r); |
|
| 704 | + //$this->debug("proxy class: $evalStr");
|
|
| 705 | + if ($this->getError()) {
|
|
| 706 | + $this->debug("Error from _getProxyClassCode, so return NULL");
|
|
| 707 | + return null; |
|
| 708 | + } |
|
| 709 | + // eval the class |
|
| 710 | + eval($evalStr); |
|
| 711 | + // instantiate proxy object |
|
| 712 | + eval("\$proxy = new nusoap_proxy_$r('');");
|
|
| 713 | + // transfer current wsdl data to the proxy thereby avoiding parsing the wsdl twice |
|
| 714 | + $proxy->endpointType = 'wsdl'; |
|
| 715 | + $proxy->wsdlFile = $this->wsdlFile; |
|
| 716 | + $proxy->wsdl = $this->wsdl; |
|
| 717 | + $proxy->operations = $this->operations; |
|
| 718 | + $proxy->defaultRpcParams = $this->defaultRpcParams; |
|
| 719 | + // transfer other state |
|
| 720 | + $proxy->soap_defencoding = $this->soap_defencoding; |
|
| 721 | + $proxy->username = $this->username; |
|
| 722 | + $proxy->password = $this->password; |
|
| 723 | + $proxy->authtype = $this->authtype; |
|
| 724 | + $proxy->certRequest = $this->certRequest; |
|
| 725 | + $proxy->requestHeaders = $this->requestHeaders; |
|
| 726 | + $proxy->endpoint = $this->endpoint; |
|
| 727 | + $proxy->forceEndpoint = $this->forceEndpoint; |
|
| 728 | + $proxy->proxyhost = $this->proxyhost; |
|
| 729 | + $proxy->proxyport = $this->proxyport; |
|
| 730 | + $proxy->proxyusername = $this->proxyusername; |
|
| 731 | + $proxy->proxypassword = $this->proxypassword; |
|
| 732 | + $proxy->http_encoding = $this->http_encoding; |
|
| 733 | + $proxy->timeout = $this->timeout; |
|
| 734 | + $proxy->response_timeout = $this->response_timeout; |
|
| 735 | + $proxy->persistentConnection = &$this->persistentConnection; |
|
| 736 | + $proxy->decode_utf8 = $this->decode_utf8; |
|
| 737 | + $proxy->curl_options = $this->curl_options; |
|
| 738 | + $proxy->bindingType = $this->bindingType; |
|
| 739 | + $proxy->use_curl = $this->use_curl; |
|
| 740 | + return $proxy; |
|
| 741 | + } |
|
| 742 | 742 | |
| 743 | - /** |
|
| 744 | - * dynamically creates proxy class code |
|
| 745 | - * |
|
| 746 | - * @return string PHP/NuSOAP code for the proxy class |
|
| 747 | - * @access private |
|
| 748 | - */ |
|
| 749 | - function _getProxyClassCode($r) {
|
|
| 750 | - $this->debug("in getProxy endpointType=$this->endpointType");
|
|
| 751 | - $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
|
|
| 752 | - if ($this->endpointType != 'wsdl') {
|
|
| 753 | - $evalStr = 'A proxy can only be created for a WSDL client'; |
|
| 754 | - $this->setError($evalStr); |
|
| 755 | - $evalStr = "echo \"$evalStr\";"; |
|
| 756 | - return $evalStr; |
|
| 757 | - } |
|
| 758 | - if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 759 | - $this->loadWSDL(); |
|
| 760 | - if ($this->getError()) {
|
|
| 761 | - return "echo \"" . $this->getError() . "\";"; |
|
| 762 | - } |
|
| 763 | - } |
|
| 764 | - $evalStr = ''; |
|
| 765 | - foreach ($this->operations as $operation => $opData) {
|
|
| 766 | - if ($operation != '') {
|
|
| 767 | - // create param string and param comment string |
|
| 768 | - if (sizeof($opData['input']['parts']) > 0) {
|
|
| 769 | - $paramStr = ''; |
|
| 770 | - $paramArrayStr = ''; |
|
| 771 | - $paramCommentStr = ''; |
|
| 772 | - foreach ($opData['input']['parts'] as $name => $type) {
|
|
| 773 | - $paramStr .= "\$$name, "; |
|
| 774 | - $paramArrayStr .= "'$name' => \$$name, "; |
|
| 775 | - $paramCommentStr .= "$type \$$name, "; |
|
| 776 | - } |
|
| 777 | - $paramStr = substr($paramStr, 0, strlen($paramStr)-2); |
|
| 778 | - $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); |
|
| 779 | - $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); |
|
| 780 | - } else {
|
|
| 781 | - $paramStr = ''; |
|
| 782 | - $paramArrayStr = ''; |
|
| 783 | - $paramCommentStr = 'void'; |
|
| 784 | - } |
|
| 785 | - $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; |
|
| 786 | - $evalStr .= "// $paramCommentStr |
|
| 743 | + /** |
|
| 744 | + * dynamically creates proxy class code |
|
| 745 | + * |
|
| 746 | + * @return string PHP/NuSOAP code for the proxy class |
|
| 747 | + * @access private |
|
| 748 | + */ |
|
| 749 | + function _getProxyClassCode($r) {
|
|
| 750 | + $this->debug("in getProxy endpointType=$this->endpointType");
|
|
| 751 | + $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
|
|
| 752 | + if ($this->endpointType != 'wsdl') {
|
|
| 753 | + $evalStr = 'A proxy can only be created for a WSDL client'; |
|
| 754 | + $this->setError($evalStr); |
|
| 755 | + $evalStr = "echo \"$evalStr\";"; |
|
| 756 | + return $evalStr; |
|
| 757 | + } |
|
| 758 | + if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
|
| 759 | + $this->loadWSDL(); |
|
| 760 | + if ($this->getError()) {
|
|
| 761 | + return "echo \"" . $this->getError() . "\";"; |
|
| 762 | + } |
|
| 763 | + } |
|
| 764 | + $evalStr = ''; |
|
| 765 | + foreach ($this->operations as $operation => $opData) {
|
|
| 766 | + if ($operation != '') {
|
|
| 767 | + // create param string and param comment string |
|
| 768 | + if (sizeof($opData['input']['parts']) > 0) {
|
|
| 769 | + $paramStr = ''; |
|
| 770 | + $paramArrayStr = ''; |
|
| 771 | + $paramCommentStr = ''; |
|
| 772 | + foreach ($opData['input']['parts'] as $name => $type) {
|
|
| 773 | + $paramStr .= "\$$name, "; |
|
| 774 | + $paramArrayStr .= "'$name' => \$$name, "; |
|
| 775 | + $paramCommentStr .= "$type \$$name, "; |
|
| 776 | + } |
|
| 777 | + $paramStr = substr($paramStr, 0, strlen($paramStr)-2); |
|
| 778 | + $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); |
|
| 779 | + $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); |
|
| 780 | + } else {
|
|
| 781 | + $paramStr = ''; |
|
| 782 | + $paramArrayStr = ''; |
|
| 783 | + $paramCommentStr = 'void'; |
|
| 784 | + } |
|
| 785 | + $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; |
|
| 786 | + $evalStr .= "// $paramCommentStr |
|
| 787 | 787 | function " . str_replace('.', '__', $operation) . "($paramStr) {
|
| 788 | 788 | \$params = array($paramArrayStr); |
| 789 | 789 | return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
|
| 790 | 790 | } |
| 791 | 791 | "; |
| 792 | - unset($paramStr); |
|
| 793 | - unset($paramCommentStr); |
|
| 794 | - } |
|
| 795 | - } |
|
| 796 | - $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
|
|
| 792 | + unset($paramStr); |
|
| 793 | + unset($paramCommentStr); |
|
| 794 | + } |
|
| 795 | + } |
|
| 796 | + $evalStr = 'class nusoap_proxy_'.$r.' extends nusoap_client {
|
|
| 797 | 797 | '.$evalStr.' |
| 798 | 798 | }'; |
| 799 | - return $evalStr; |
|
| 800 | - } |
|
| 799 | + return $evalStr; |
|
| 800 | + } |
|
| 801 | 801 | |
| 802 | - /** |
|
| 803 | - * dynamically creates proxy class code |
|
| 804 | - * |
|
| 805 | - * @return string PHP/NuSOAP code for the proxy class |
|
| 806 | - * @access public |
|
| 807 | - */ |
|
| 808 | - function getProxyClassCode() {
|
|
| 809 | - $r = rand(); |
|
| 810 | - return $this->_getProxyClassCode($r); |
|
| 811 | - } |
|
| 802 | + /** |
|
| 803 | + * dynamically creates proxy class code |
|
| 804 | + * |
|
| 805 | + * @return string PHP/NuSOAP code for the proxy class |
|
| 806 | + * @access public |
|
| 807 | + */ |
|
| 808 | + function getProxyClassCode() {
|
|
| 809 | + $r = rand(); |
|
| 810 | + return $this->_getProxyClassCode($r); |
|
| 811 | + } |
|
| 812 | 812 | |
| 813 | - /** |
|
| 814 | - * gets the HTTP body for the current request. |
|
| 815 | - * |
|
| 816 | - * @param string $soapmsg The SOAP payload |
|
| 817 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 818 | - * @access private |
|
| 819 | - */ |
|
| 820 | - function getHTTPBody($soapmsg) {
|
|
| 821 | - return $soapmsg; |
|
| 822 | - } |
|
| 813 | + /** |
|
| 814 | + * gets the HTTP body for the current request. |
|
| 815 | + * |
|
| 816 | + * @param string $soapmsg The SOAP payload |
|
| 817 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 818 | + * @access private |
|
| 819 | + */ |
|
| 820 | + function getHTTPBody($soapmsg) {
|
|
| 821 | + return $soapmsg; |
|
| 822 | + } |
|
| 823 | 823 | |
| 824 | - /** |
|
| 825 | - * gets the HTTP content type for the current request. |
|
| 826 | - * |
|
| 827 | - * Note: getHTTPBody must be called before this. |
|
| 828 | - * |
|
| 829 | - * @return string the HTTP content type for the current request. |
|
| 830 | - * @access private |
|
| 831 | - */ |
|
| 832 | - function getHTTPContentType() {
|
|
| 833 | - return 'text/xml'; |
|
| 834 | - } |
|
| 824 | + /** |
|
| 825 | + * gets the HTTP content type for the current request. |
|
| 826 | + * |
|
| 827 | + * Note: getHTTPBody must be called before this. |
|
| 828 | + * |
|
| 829 | + * @return string the HTTP content type for the current request. |
|
| 830 | + * @access private |
|
| 831 | + */ |
|
| 832 | + function getHTTPContentType() {
|
|
| 833 | + return 'text/xml'; |
|
| 834 | + } |
|
| 835 | 835 | |
| 836 | - /** |
|
| 837 | - * gets the HTTP content type charset for the current request. |
|
| 838 | - * returns false for non-text content types. |
|
| 839 | - * |
|
| 840 | - * Note: getHTTPBody must be called before this. |
|
| 841 | - * |
|
| 842 | - * @return string the HTTP content type charset for the current request. |
|
| 843 | - * @access private |
|
| 844 | - */ |
|
| 845 | - function getHTTPContentTypeCharset() {
|
|
| 846 | - return $this->soap_defencoding; |
|
| 847 | - } |
|
| 836 | + /** |
|
| 837 | + * gets the HTTP content type charset for the current request. |
|
| 838 | + * returns false for non-text content types. |
|
| 839 | + * |
|
| 840 | + * Note: getHTTPBody must be called before this. |
|
| 841 | + * |
|
| 842 | + * @return string the HTTP content type charset for the current request. |
|
| 843 | + * @access private |
|
| 844 | + */ |
|
| 845 | + function getHTTPContentTypeCharset() {
|
|
| 846 | + return $this->soap_defencoding; |
|
| 847 | + } |
|
| 848 | 848 | |
| 849 | - /* |
|
| 849 | + /* |
|
| 850 | 850 | * whether or not parser should decode utf8 element content |
| 851 | 851 | * |
| 852 | 852 | * @return always returns true |
| 853 | 853 | * @access public |
| 854 | 854 | */ |
| 855 | 855 | function decodeUTF8($bool){
|
| 856 | - $this->decode_utf8 = $bool; |
|
| 857 | - return true; |
|
| 856 | + $this->decode_utf8 = $bool; |
|
| 857 | + return true; |
|
| 858 | 858 | } |
| 859 | 859 | |
| 860 | - /** |
|
| 861 | - * adds a new Cookie into $this->cookies array |
|
| 862 | - * |
|
| 863 | - * @param string $name Cookie Name |
|
| 864 | - * @param string $value Cookie Value |
|
| 865 | - * @return boolean if cookie-set was successful returns true, else false |
|
| 866 | - * @access public |
|
| 867 | - */ |
|
| 868 | - function setCookie($name, $value) {
|
|
| 869 | - if (strlen($name) == 0) {
|
|
| 870 | - return false; |
|
| 871 | - } |
|
| 872 | - $this->cookies[] = array('name' => $name, 'value' => $value);
|
|
| 873 | - return true; |
|
| 874 | - } |
|
| 860 | + /** |
|
| 861 | + * adds a new Cookie into $this->cookies array |
|
| 862 | + * |
|
| 863 | + * @param string $name Cookie Name |
|
| 864 | + * @param string $value Cookie Value |
|
| 865 | + * @return boolean if cookie-set was successful returns true, else false |
|
| 866 | + * @access public |
|
| 867 | + */ |
|
| 868 | + function setCookie($name, $value) {
|
|
| 869 | + if (strlen($name) == 0) {
|
|
| 870 | + return false; |
|
| 871 | + } |
|
| 872 | + $this->cookies[] = array('name' => $name, 'value' => $value);
|
|
| 873 | + return true; |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - /** |
|
| 877 | - * gets all Cookies |
|
| 878 | - * |
|
| 879 | - * @return array with all internal cookies |
|
| 880 | - * @access public |
|
| 881 | - */ |
|
| 882 | - function getCookies() {
|
|
| 883 | - return $this->cookies; |
|
| 884 | - } |
|
| 876 | + /** |
|
| 877 | + * gets all Cookies |
|
| 878 | + * |
|
| 879 | + * @return array with all internal cookies |
|
| 880 | + * @access public |
|
| 881 | + */ |
|
| 882 | + function getCookies() {
|
|
| 883 | + return $this->cookies; |
|
| 884 | + } |
|
| 885 | 885 | |
| 886 | - /** |
|
| 887 | - * checks all Cookies and delete those which are expired |
|
| 888 | - * |
|
| 889 | - * @return boolean always return true |
|
| 890 | - * @access private |
|
| 891 | - */ |
|
| 892 | - function checkCookies() {
|
|
| 893 | - if (sizeof($this->cookies) == 0) {
|
|
| 894 | - return true; |
|
| 895 | - } |
|
| 896 | - $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
|
|
| 897 | - $curr_cookies = $this->cookies; |
|
| 898 | - $this->cookies = array(); |
|
| 899 | - foreach ($curr_cookies as $cookie) {
|
|
| 900 | - if (! is_array($cookie)) {
|
|
| 901 | - $this->debug('Remove cookie that is not an array');
|
|
| 902 | - continue; |
|
| 903 | - } |
|
| 904 | - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 905 | - if (strtotime($cookie['expires']) > time()) {
|
|
| 906 | - $this->cookies[] = $cookie; |
|
| 907 | - } else {
|
|
| 908 | - $this->debug('Remove expired cookie ' . $cookie['name']);
|
|
| 909 | - } |
|
| 910 | - } else {
|
|
| 911 | - $this->cookies[] = $cookie; |
|
| 912 | - } |
|
| 913 | - } |
|
| 914 | - $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
|
|
| 915 | - return true; |
|
| 916 | - } |
|
| 886 | + /** |
|
| 887 | + * checks all Cookies and delete those which are expired |
|
| 888 | + * |
|
| 889 | + * @return boolean always return true |
|
| 890 | + * @access private |
|
| 891 | + */ |
|
| 892 | + function checkCookies() {
|
|
| 893 | + if (sizeof($this->cookies) == 0) {
|
|
| 894 | + return true; |
|
| 895 | + } |
|
| 896 | + $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
|
|
| 897 | + $curr_cookies = $this->cookies; |
|
| 898 | + $this->cookies = array(); |
|
| 899 | + foreach ($curr_cookies as $cookie) {
|
|
| 900 | + if (! is_array($cookie)) {
|
|
| 901 | + $this->debug('Remove cookie that is not an array');
|
|
| 902 | + continue; |
|
| 903 | + } |
|
| 904 | + if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 905 | + if (strtotime($cookie['expires']) > time()) {
|
|
| 906 | + $this->cookies[] = $cookie; |
|
| 907 | + } else {
|
|
| 908 | + $this->debug('Remove expired cookie ' . $cookie['name']);
|
|
| 909 | + } |
|
| 910 | + } else {
|
|
| 911 | + $this->cookies[] = $cookie; |
|
| 912 | + } |
|
| 913 | + } |
|
| 914 | + $this->debug('checkCookie: '.sizeof($this->cookies).' cookies left in array');
|
|
| 915 | + return true; |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | - /** |
|
| 919 | - * updates the current cookies with a new set |
|
| 920 | - * |
|
| 921 | - * @param array $cookies new cookies with which to update current ones |
|
| 922 | - * @return boolean always return true |
|
| 923 | - * @access private |
|
| 924 | - */ |
|
| 925 | - function UpdateCookies($cookies) {
|
|
| 926 | - if (sizeof($this->cookies) == 0) {
|
|
| 927 | - // no existing cookies: take whatever is new |
|
| 928 | - if (sizeof($cookies) > 0) {
|
|
| 929 | - $this->debug('Setting new cookie(s)');
|
|
| 930 | - $this->cookies = $cookies; |
|
| 931 | - } |
|
| 932 | - return true; |
|
| 933 | - } |
|
| 934 | - if (sizeof($cookies) == 0) {
|
|
| 935 | - // no new cookies: keep what we've got |
|
| 936 | - return true; |
|
| 937 | - } |
|
| 938 | - // merge |
|
| 939 | - foreach ($cookies as $newCookie) {
|
|
| 940 | - if (!is_array($newCookie)) {
|
|
| 941 | - continue; |
|
| 942 | - } |
|
| 943 | - if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
|
|
| 944 | - continue; |
|
| 945 | - } |
|
| 946 | - $newName = $newCookie['name']; |
|
| 947 | - |
|
| 948 | - $found = false; |
|
| 949 | - for ($i = 0; $i < count($this->cookies); $i++) {
|
|
| 950 | - $cookie = $this->cookies[$i]; |
|
| 951 | - if (!is_array($cookie)) {
|
|
| 952 | - continue; |
|
| 953 | - } |
|
| 954 | - if (!isset($cookie['name'])) {
|
|
| 955 | - continue; |
|
| 956 | - } |
|
| 957 | - if ($newName != $cookie['name']) {
|
|
| 958 | - continue; |
|
| 959 | - } |
|
| 960 | - $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; |
|
| 961 | - $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; |
|
| 962 | - if ($newDomain != $domain) {
|
|
| 963 | - continue; |
|
| 964 | - } |
|
| 965 | - $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; |
|
| 966 | - $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; |
|
| 967 | - if ($newPath != $path) {
|
|
| 968 | - continue; |
|
| 969 | - } |
|
| 970 | - $this->cookies[$i] = $newCookie; |
|
| 971 | - $found = true; |
|
| 972 | - $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 973 | - break; |
|
| 974 | - } |
|
| 975 | - if (! $found) {
|
|
| 976 | - $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 977 | - $this->cookies[] = $newCookie; |
|
| 978 | - } |
|
| 979 | - } |
|
| 980 | - return true; |
|
| 981 | - } |
|
| 918 | + /** |
|
| 919 | + * updates the current cookies with a new set |
|
| 920 | + * |
|
| 921 | + * @param array $cookies new cookies with which to update current ones |
|
| 922 | + * @return boolean always return true |
|
| 923 | + * @access private |
|
| 924 | + */ |
|
| 925 | + function UpdateCookies($cookies) {
|
|
| 926 | + if (sizeof($this->cookies) == 0) {
|
|
| 927 | + // no existing cookies: take whatever is new |
|
| 928 | + if (sizeof($cookies) > 0) {
|
|
| 929 | + $this->debug('Setting new cookie(s)');
|
|
| 930 | + $this->cookies = $cookies; |
|
| 931 | + } |
|
| 932 | + return true; |
|
| 933 | + } |
|
| 934 | + if (sizeof($cookies) == 0) {
|
|
| 935 | + // no new cookies: keep what we've got |
|
| 936 | + return true; |
|
| 937 | + } |
|
| 938 | + // merge |
|
| 939 | + foreach ($cookies as $newCookie) {
|
|
| 940 | + if (!is_array($newCookie)) {
|
|
| 941 | + continue; |
|
| 942 | + } |
|
| 943 | + if ((!isset($newCookie['name'])) || (!isset($newCookie['value']))) {
|
|
| 944 | + continue; |
|
| 945 | + } |
|
| 946 | + $newName = $newCookie['name']; |
|
| 947 | + |
|
| 948 | + $found = false; |
|
| 949 | + for ($i = 0; $i < count($this->cookies); $i++) {
|
|
| 950 | + $cookie = $this->cookies[$i]; |
|
| 951 | + if (!is_array($cookie)) {
|
|
| 952 | + continue; |
|
| 953 | + } |
|
| 954 | + if (!isset($cookie['name'])) {
|
|
| 955 | + continue; |
|
| 956 | + } |
|
| 957 | + if ($newName != $cookie['name']) {
|
|
| 958 | + continue; |
|
| 959 | + } |
|
| 960 | + $newDomain = isset($newCookie['domain']) ? $newCookie['domain'] : 'NODOMAIN'; |
|
| 961 | + $domain = isset($cookie['domain']) ? $cookie['domain'] : 'NODOMAIN'; |
|
| 962 | + if ($newDomain != $domain) {
|
|
| 963 | + continue; |
|
| 964 | + } |
|
| 965 | + $newPath = isset($newCookie['path']) ? $newCookie['path'] : 'NOPATH'; |
|
| 966 | + $path = isset($cookie['path']) ? $cookie['path'] : 'NOPATH'; |
|
| 967 | + if ($newPath != $path) {
|
|
| 968 | + continue; |
|
| 969 | + } |
|
| 970 | + $this->cookies[$i] = $newCookie; |
|
| 971 | + $found = true; |
|
| 972 | + $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 973 | + break; |
|
| 974 | + } |
|
| 975 | + if (! $found) {
|
|
| 976 | + $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 977 | + $this->cookies[] = $newCookie; |
|
| 978 | + } |
|
| 979 | + } |
|
| 980 | + return true; |
|
| 981 | + } |
|
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | if (!extension_loaded('soap')) {
|
| 985 | - /** |
|
| 986 | - * For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded. |
|
| 987 | - */ |
|
| 988 | - class soapclient extends nusoap_client {
|
|
| 989 | - } |
|
| 985 | + /** |
|
| 986 | + * For backwards compatiblity, define soapclient unless the PHP SOAP extension is loaded. |
|
| 987 | + */ |
|
| 988 | + class soapclient extends nusoap_client {
|
|
| 989 | + } |
|
| 990 | 990 | } |
| 991 | 991 | ?> |
@@ -23,39 +23,39 @@ discard block |
||
| 23 | 23 | * @version $Id: class.soapclient.php,v 1.69 2010/04/26 20:15:08 snichol Exp $ |
| 24 | 24 | * @access public |
| 25 | 25 | */ |
| 26 | -class nusoap_client extends nusoap_base {
|
|
| 27 | - |
|
| 28 | - var $username = ''; // Username for HTTP authentication |
|
| 29 | - var $password = ''; // Password for HTTP authentication |
|
| 30 | - var $authtype = ''; // Type of HTTP authentication |
|
| 31 | - var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | - var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | - var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | - var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | - var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 26 | +class nusoap_client extends nusoap_base {
|
|
| 27 | + |
|
| 28 | + var $username = ''; // Username for HTTP authentication |
|
| 29 | + var $password = ''; // Password for HTTP authentication |
|
| 30 | + var $authtype = ''; // Type of HTTP authentication |
|
| 31 | + var $certRequest = array(); // Certificate for HTTP SSL authentication |
|
| 32 | + var $requestHeaders = false; // SOAP headers in request (text) |
|
| 33 | + var $responseHeaders = ''; // SOAP headers from response (incomplete namespace resolution) (text) |
|
| 34 | + var $responseHeader = NULL; // SOAP Header from response (parsed) |
|
| 35 | + var $document = ''; // SOAP body response portion (incomplete namespace resolution) (text) |
|
| 36 | 36 | var $endpoint; |
| 37 | - var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 37 | + var $forceEndpoint = ''; // overrides WSDL endpoint |
|
| 38 | 38 | var $proxyhost = ''; |
| 39 | 39 | var $proxyport = ''; |
| 40 | 40 | var $proxyusername = ''; |
| 41 | 41 | var $proxypassword = ''; |
| 42 | - var $portName = ''; // port name to use in WSDL |
|
| 43 | - var $xml_encoding = ''; // character set encoding of incoming (response) messages |
|
| 42 | + var $portName = ''; // port name to use in WSDL |
|
| 43 | + var $xml_encoding = ''; // character set encoding of incoming (response) messages |
|
| 44 | 44 | var $http_encoding = false; |
| 45 | - var $timeout = 0; // HTTP connection timeout |
|
| 46 | - var $response_timeout = 30; // HTTP response timeout |
|
| 47 | - var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 45 | + var $timeout = 0; // HTTP connection timeout |
|
| 46 | + var $response_timeout = 30; // HTTP response timeout |
|
| 47 | + var $endpointType = ''; // soap|wsdl, empty for WSDL initialization error |
|
| 48 | 48 | var $persistentConnection = false; |
| 49 | - var $defaultRpcParams = false; // This is no longer used |
|
| 50 | - var $request = ''; // HTTP request |
|
| 51 | - var $response = ''; // HTTP response |
|
| 52 | - var $responseData = ''; // SOAP payload of response |
|
| 53 | - var $cookies = array(); // Cookies from response or for request |
|
| 54 | - var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() |
|
| 55 | - var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | - var $curl_options = array(); // User-specified cURL options |
|
| 57 | - var $bindingType = ''; // WSDL operation binding type |
|
| 58 | - var $use_curl = false; // whether to always try to use cURL |
|
| 49 | + var $defaultRpcParams = false; // This is no longer used |
|
| 50 | + var $request = ''; // HTTP request |
|
| 51 | + var $response = ''; // HTTP response |
|
| 52 | + var $responseData = ''; // SOAP payload of response |
|
| 53 | + var $cookies = array(); // Cookies from response or for request |
|
| 54 | + var $decode_utf8 = true; // toggles whether the parser decodes element content w/ utf8_decode() |
|
| 55 | + var $operations = array(); // WSDL operations, empty for WSDL initialization error |
|
| 56 | + var $curl_options = array(); // User-specified cURL options |
|
| 57 | + var $bindingType = ''; // WSDL operation binding type |
|
| 58 | + var $use_curl = false; // whether to always try to use cURL |
|
| 59 | 59 | |
| 60 | 60 | /* |
| 61 | 61 | * fault related variables |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * @param string $portName optional portName in WSDL document |
| 96 | 96 | * @access public |
| 97 | 97 | */ |
| 98 | - function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
|
|
| 98 | + function nusoap_client($endpoint, $wsdl = false, $proxyhost = false, $proxyport = false, $proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = '') {
|
|
| 99 | 99 | parent::nusoap_base(); |
| 100 | 100 | $this->endpoint = $endpoint; |
| 101 | 101 | $this->proxyhost = $proxyhost; |
@@ -107,20 +107,20 @@ discard block |
||
| 107 | 107 | $this->portName = $portName; |
| 108 | 108 | |
| 109 | 109 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
|
| 110 | - $this->appendDebug('endpoint=' . $this->varDump($endpoint));
|
|
| 110 | + $this->appendDebug('endpoint='.$this->varDump($endpoint));
|
|
| 111 | 111 | |
| 112 | 112 | // make values |
| 113 | - if($wsdl){
|
|
| 113 | + if ($wsdl) {
|
|
| 114 | 114 | if (is_object($endpoint) && (get_class($endpoint) == 'wsdl')) {
|
| 115 | 115 | $this->wsdl = $endpoint; |
| 116 | 116 | $this->endpoint = $this->wsdl->wsdl; |
| 117 | 117 | $this->wsdlFile = $this->endpoint; |
| 118 | - $this->debug('existing wsdl instance created from ' . $this->endpoint);
|
|
| 118 | + $this->debug('existing wsdl instance created from '.$this->endpoint);
|
|
| 119 | 119 | $this->checkWSDL(); |
| 120 | 120 | } else {
|
| 121 | 121 | $this->wsdlFile = $this->endpoint; |
| 122 | 122 | $this->wsdl = null; |
| 123 | - $this->debug('will use lazy evaluation of wsdl from ' . $this->endpoint);
|
|
| 123 | + $this->debug('will use lazy evaluation of wsdl from '.$this->endpoint);
|
|
| 124 | 124 | } |
| 125 | 125 | $this->endpointType = 'wsdl'; |
| 126 | 126 | } else {
|
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors |
| 155 | 155 | * @access public |
| 156 | 156 | */ |
| 157 | - function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
|
|
| 157 | + function call($operation, $params = array(), $namespace = 'http://tempuri.org', $soapAction = '', $headers = false, $rpcParams = null, $style = 'rpc', $use = 'encoded') {
|
|
| 158 | 158 | $this->operation = $operation; |
| 159 | 159 | $this->fault = false; |
| 160 | 160 | $this->setError('');
|
@@ -166,8 +166,8 @@ discard block |
||
| 166 | 166 | $this->opData = array(); |
| 167 | 167 | |
| 168 | 168 | $this->debug("call: operation=$operation, namespace=$namespace, soapAction=$soapAction, rpcParams=$rpcParams, style=$style, use=$use, endpointType=$this->endpointType");
|
| 169 | - $this->appendDebug('params=' . $this->varDump($params));
|
|
| 170 | - $this->appendDebug('headers=' . $this->varDump($headers));
|
|
| 169 | + $this->appendDebug('params='.$this->varDump($params));
|
|
| 170 | + $this->appendDebug('headers='.$this->varDump($headers));
|
|
| 171 | 171 | if ($headers) {
|
| 172 | 172 | $this->requestHeaders = $headers; |
| 173 | 173 | } |
@@ -177,25 +177,25 @@ discard block |
||
| 177 | 177 | return false; |
| 178 | 178 | } |
| 179 | 179 | // serialize parameters |
| 180 | - if($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)){
|
|
| 180 | + if ($this->endpointType == 'wsdl' && $opData = $this->getOperationData($operation)) {
|
|
| 181 | 181 | // use WSDL for operation |
| 182 | 182 | $this->opData = $opData; |
| 183 | 183 | $this->debug("found operation");
|
| 184 | - $this->appendDebug('opData=' . $this->varDump($opData));
|
|
| 184 | + $this->appendDebug('opData='.$this->varDump($opData));
|
|
| 185 | 185 | if (isset($opData['soapAction'])) {
|
| 186 | 186 | $soapAction = $opData['soapAction']; |
| 187 | 187 | } |
| 188 | - if (! $this->forceEndpoint) {
|
|
| 188 | + if (!$this->forceEndpoint) {
|
|
| 189 | 189 | $this->endpoint = $opData['endpoint']; |
| 190 | 190 | } else {
|
| 191 | 191 | $this->endpoint = $this->forceEndpoint; |
| 192 | 192 | } |
| 193 | - $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 193 | + $namespace = isset($opData['input']['namespace']) ? $opData['input']['namespace'] : $namespace; |
|
| 194 | 194 | $style = $opData['style']; |
| 195 | 195 | $use = $opData['input']['use']; |
| 196 | 196 | // add ns to ns array |
| 197 | - if($namespace != '' && !isset($this->wsdl->namespaces[$namespace])){
|
|
| 198 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 197 | + if ($namespace != '' && !isset($this->wsdl->namespaces[$namespace])) {
|
|
| 198 | + $nsPrefix = 'ns'.rand(1000, 9999); |
|
| 199 | 199 | $this->wsdl->namespaces[$nsPrefix] = $namespace; |
| 200 | 200 | } |
| 201 | 201 | $nsPrefix = $this->wsdl->getPrefixFromNamespace($namespace); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | $payload = $params; |
| 206 | 206 | } elseif (is_array($params)) {
|
| 207 | 207 | $this->debug("serializing param array for WSDL operation $operation");
|
| 208 | - $payload = $this->wsdl->serializeRPCParameters($operation,'input',$params,$this->bindingType); |
|
| 208 | + $payload = $this->wsdl->serializeRPCParameters($operation, 'input', $params, $this->bindingType); |
|
| 209 | 209 | } else {
|
| 210 | 210 | $this->debug('params must be array or string');
|
| 211 | 211 | $this->setError('params must be array or string');
|
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | $this->setError('wsdl error: '.$errstr);
|
| 225 | 225 | return false; |
| 226 | 226 | } |
| 227 | - } elseif($this->endpointType == 'wsdl') {
|
|
| 227 | + } elseif ($this->endpointType == 'wsdl') {
|
|
| 228 | 228 | // operation not in WSDL |
| 229 | 229 | $this->appendDebug($this->wsdl->getDebug()); |
| 230 | 230 | $this->wsdl->clearDebug(); |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | } else {
|
| 235 | 235 | // no WSDL |
| 236 | 236 | //$this->namespaces['ns1'] = $namespace; |
| 237 | - $nsPrefix = 'ns' . rand(1000, 9999); |
|
| 237 | + $nsPrefix = 'ns'.rand(1000, 9999); |
|
| 238 | 238 | // serialize |
| 239 | 239 | $payload = ''; |
| 240 | 240 | if (is_string($params)) {
|
@@ -242,8 +242,8 @@ discard block |
||
| 242 | 242 | $payload = $params; |
| 243 | 243 | } elseif (is_array($params)) {
|
| 244 | 244 | $this->debug("serializing param array for operation $operation");
|
| 245 | - foreach($params as $k => $v){
|
|
| 246 | - $payload .= $this->serialize_val($v,$k,false,false,false,false,$use); |
|
| 245 | + foreach ($params as $k => $v) {
|
|
| 246 | + $payload .= $this->serialize_val($v, $k, false, false, false, false, $use); |
|
| 247 | 247 | } |
| 248 | 248 | } else {
|
| 249 | 249 | $this->debug('params must be array or string');
|
@@ -263,45 +263,45 @@ discard block |
||
| 263 | 263 | $this->debug("wrapping RPC request with literal method element");
|
| 264 | 264 | if ($namespace) {
|
| 265 | 265 | // 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 |
| 266 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 267 | - $payload . |
|
| 266 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">". |
|
| 267 | + $payload. |
|
| 268 | 268 | "</$nsPrefix:$operation>"; |
| 269 | 269 | } else {
|
| 270 | - $payload = "<$operation>" . $payload . "</$operation>"; |
|
| 270 | + $payload = "<$operation>".$payload."</$operation>"; |
|
| 271 | 271 | } |
| 272 | 272 | } else {
|
| 273 | 273 | $this->debug("wrapping RPC request with encoded method element");
|
| 274 | 274 | if ($namespace) {
|
| 275 | - $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">" . |
|
| 276 | - $payload . |
|
| 275 | + $payload = "<$nsPrefix:$operation xmlns:$nsPrefix=\"$namespace\">". |
|
| 276 | + $payload. |
|
| 277 | 277 | "</$nsPrefix:$operation>"; |
| 278 | 278 | } else {
|
| 279 | - $payload = "<$operation>" . |
|
| 280 | - $payload . |
|
| 279 | + $payload = "<$operation>". |
|
| 280 | + $payload. |
|
| 281 | 281 | "</$operation>"; |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | } |
| 285 | 285 | // serialize envelope |
| 286 | - $soapmsg = $this->serializeEnvelope($payload,$this->requestHeaders,$usedNamespaces,$style,$use,$encodingStyle); |
|
| 286 | + $soapmsg = $this->serializeEnvelope($payload, $this->requestHeaders, $usedNamespaces, $style, $use, $encodingStyle); |
|
| 287 | 287 | $this->debug("endpoint=$this->endpoint, soapAction=$soapAction, namespace=$namespace, style=$style, use=$use, encodingStyle=$encodingStyle");
|
| 288 | - $this->debug('SOAP message length=' . strlen($soapmsg) . ' contents (max 1000 bytes)=' . substr($soapmsg, 0, 1000));
|
|
| 288 | + $this->debug('SOAP message length='.strlen($soapmsg).' contents (max 1000 bytes)='.substr($soapmsg, 0, 1000));
|
|
| 289 | 289 | // send |
| 290 | - $return = $this->send($this->getHTTPBody($soapmsg),$soapAction,$this->timeout,$this->response_timeout); |
|
| 291 | - if($errstr = $this->getError()){
|
|
| 290 | + $return = $this->send($this->getHTTPBody($soapmsg), $soapAction, $this->timeout, $this->response_timeout); |
|
| 291 | + if ($errstr = $this->getError()) {
|
|
| 292 | 292 | $this->debug('Error: '.$errstr);
|
| 293 | 293 | return false; |
| 294 | 294 | } else {
|
| 295 | 295 | $this->return = $return; |
| 296 | 296 | $this->debug('sent message successfully and got a(n) '.gettype($return));
|
| 297 | - $this->appendDebug('return=' . $this->varDump($return));
|
|
| 297 | + $this->appendDebug('return='.$this->varDump($return));
|
|
| 298 | 298 | |
| 299 | 299 | // fault? |
| 300 | - if(is_array($return) && isset($return['faultcode'])){
|
|
| 300 | + if (is_array($return) && isset($return['faultcode'])) {
|
|
| 301 | 301 | $this->debug('got fault');
|
| 302 | 302 | $this->setError($return['faultcode'].': '.$return['faultstring']); |
| 303 | 303 | $this->fault = true; |
| 304 | - foreach($return as $k => $v){
|
|
| 304 | + foreach ($return as $k => $v) {
|
|
| 305 | 305 | $this->$k = $v; |
| 306 | 306 | $this->debug("$k = $v<br>");
|
| 307 | 307 | } |
@@ -312,10 +312,10 @@ discard block |
||
| 312 | 312 | return $return; |
| 313 | 313 | } else {
|
| 314 | 314 | // array of return values |
| 315 | - if(is_array($return)){
|
|
| 315 | + if (is_array($return)) {
|
|
| 316 | 316 | // multiple 'out' parameters, which we return wrapped up |
| 317 | 317 | // in the array |
| 318 | - if(sizeof($return) > 1){
|
|
| 318 | + if (sizeof($return) > 1) {
|
|
| 319 | 319 | return $return; |
| 320 | 320 | } |
| 321 | 321 | // single 'out' parameter (normally the return value) |
@@ -372,7 +372,7 @@ discard block |
||
| 372 | 372 | */ |
| 373 | 373 | function loadWSDL() {
|
| 374 | 374 | $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
|
| 375 | - $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
|
|
| 375 | + $this->wsdl = new wsdl('', $this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword, $this->timeout, $this->response_timeout, $this->curl_options, $this->use_curl);
|
|
| 376 | 376 | $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest); |
| 377 | 377 | $this->wsdl->fetchWSDL($this->wsdlFile); |
| 378 | 378 | $this->checkWSDL(); |
@@ -385,13 +385,13 @@ discard block |
||
| 385 | 385 | * @return array array of data pertaining to the operation |
| 386 | 386 | * @access public |
| 387 | 387 | */ |
| 388 | - function getOperationData($operation){
|
|
| 388 | + function getOperationData($operation) {
|
|
| 389 | 389 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
| 390 | 390 | $this->loadWSDL(); |
| 391 | 391 | if ($this->getError()) |
| 392 | 392 | return false; |
| 393 | 393 | } |
| 394 | - if(isset($this->operations[$operation])){
|
|
| 394 | + if (isset($this->operations[$operation])) {
|
|
| 395 | 395 | return $this->operations[$operation]; |
| 396 | 396 | } |
| 397 | 397 | $this->debug("No data for operation: $operation");
|
@@ -411,15 +411,15 @@ discard block |
||
| 411 | 411 | * @return mixed native PHP types. |
| 412 | 412 | * @access private |
| 413 | 413 | */ |
| 414 | - function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
|
|
| 414 | + function send($msg, $soapaction = '', $timeout = 0, $response_timeout = 30) {
|
|
| 415 | 415 | $this->checkCookies(); |
| 416 | 416 | // detect transport |
| 417 | - switch(true){
|
|
| 417 | + switch (true) {
|
|
| 418 | 418 | // http(s) |
| 419 | - case preg_match('/^http/',$this->endpoint):
|
|
| 419 | + case preg_match('/^http/', $this->endpoint):
|
|
| 420 | 420 | $this->debug('transporting via HTTP');
|
| 421 | - if($this->persistentConnection == true && is_object($this->persistentConnection)){
|
|
| 422 | - $http =& $this->persistentConnection; |
|
| 421 | + if ($this->persistentConnection == true && is_object($this->persistentConnection)) {
|
|
| 422 | + $http = & $this->persistentConnection; |
|
| 423 | 423 | } else {
|
| 424 | 424 | $http = new soap_transport_http($this->endpoint, $this->curl_options, $this->use_curl); |
| 425 | 425 | if ($this->persistentConnection) {
|
@@ -428,27 +428,27 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | $http->setContentType($this->getHTTPContentType(), $this->getHTTPContentTypeCharset()); |
| 430 | 430 | $http->setSOAPAction($soapaction); |
| 431 | - if($this->proxyhost && $this->proxyport){
|
|
| 432 | - $http->setProxy($this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword); |
|
| 431 | + if ($this->proxyhost && $this->proxyport) {
|
|
| 432 | + $http->setProxy($this->proxyhost, $this->proxyport, $this->proxyusername, $this->proxypassword); |
|
| 433 | 433 | } |
| 434 | - if($this->authtype != '') {
|
|
| 434 | + if ($this->authtype != '') {
|
|
| 435 | 435 | $http->setCredentials($this->username, $this->password, $this->authtype, array(), $this->certRequest); |
| 436 | 436 | } |
| 437 | - if($this->http_encoding != ''){
|
|
| 437 | + if ($this->http_encoding != '') {
|
|
| 438 | 438 | $http->setEncoding($this->http_encoding); |
| 439 | 439 | } |
| 440 | 440 | $this->debug('sending message, length='.strlen($msg));
|
| 441 | - if(preg_match('/^http:/',$this->endpoint)){
|
|
| 441 | + if (preg_match('/^http:/', $this->endpoint)) {
|
|
| 442 | 442 | //if(strpos($this->endpoint,'http:')){
|
| 443 | - $this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies); |
|
| 444 | - } elseif(preg_match('/^https/',$this->endpoint)){
|
|
| 443 | + $this->responseData = $http->send($msg, $timeout, $response_timeout, $this->cookies); |
|
| 444 | + } elseif (preg_match('/^https/', $this->endpoint)) {
|
|
| 445 | 445 | //} elseif(strpos($this->endpoint,'https:')){
|
| 446 | 446 | //if(phpversion() == '4.3.0-dev'){
|
| 447 | 447 | //$response = $http->send($msg,$timeout,$response_timeout); |
| 448 | 448 | //$this->request = $http->outgoing_payload; |
| 449 | 449 | //$this->response = $http->incoming_payload; |
| 450 | 450 | //} else |
| 451 | - $this->responseData = $http->sendHTTPS($msg,$timeout,$response_timeout,$this->cookies); |
|
| 451 | + $this->responseData = $http->sendHTTPS($msg, $timeout, $response_timeout, $this->cookies); |
|
| 452 | 452 | } else {
|
| 453 | 453 | $this->setError('no http/s in endpoint url');
|
| 454 | 454 | } |
@@ -465,13 +465,13 @@ discard block |
||
| 465 | 465 | } |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if($err = $http->getError()){
|
|
| 468 | + if ($err = $http->getError()) {
|
|
| 469 | 469 | $this->setError('HTTP Error: '.$err);
|
| 470 | 470 | return false; |
| 471 | - } elseif($this->getError()){
|
|
| 471 | + } elseif ($this->getError()) {
|
|
| 472 | 472 | return false; |
| 473 | 473 | } else {
|
| 474 | - $this->debug('got response, length='. strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 474 | + $this->debug('got response, length='.strlen($this->responseData).' type='.$http->incoming_headers['content-type']);
|
|
| 475 | 475 | return $this->parseResponse($http->incoming_headers, $this->responseData); |
| 476 | 476 | } |
| 477 | 477 | break; |
@@ -491,20 +491,20 @@ discard block |
||
| 491 | 491 | * @access private |
| 492 | 492 | */ |
| 493 | 493 | function parseResponse($headers, $data) {
|
| 494 | - $this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
|
|
| 494 | + $this->debug('Entering parseResponse() for data of length '.strlen($data).' headers:');
|
|
| 495 | 495 | $this->appendDebug($this->varDump($headers)); |
| 496 | 496 | if (!isset($headers['content-type'])) {
|
| 497 | 497 | $this->setError('Response not of type text/xml (no content-type header)');
|
| 498 | 498 | return false; |
| 499 | 499 | } |
| 500 | 500 | if (!strstr($headers['content-type'], 'text/xml')) {
|
| 501 | - $this->setError('Response not of type text/xml: ' . $headers['content-type']);
|
|
| 501 | + $this->setError('Response not of type text/xml: '.$headers['content-type']);
|
|
| 502 | 502 | return false; |
| 503 | 503 | } |
| 504 | 504 | if (strpos($headers['content-type'], '=')) {
|
| 505 | 505 | $enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
|
| 506 | - $this->debug('Got response encoding: ' . $enc);
|
|
| 507 | - if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
|
|
| 506 | + $this->debug('Got response encoding: '.$enc);
|
|
| 507 | + if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i', $enc)) {
|
|
| 508 | 508 | $this->xml_encoding = strtoupper($enc); |
| 509 | 509 | } else {
|
| 510 | 510 | $this->xml_encoding = 'US-ASCII'; |
@@ -513,13 +513,13 @@ discard block |
||
| 513 | 513 | // should be US-ASCII for HTTP 1.0 or ISO-8859-1 for HTTP 1.1 |
| 514 | 514 | $this->xml_encoding = 'ISO-8859-1'; |
| 515 | 515 | } |
| 516 | - $this->debug('Use encoding: ' . $this->xml_encoding . ' when creating nusoap_parser');
|
|
| 517 | - $parser = new nusoap_parser($data,$this->xml_encoding,$this->operation,$this->decode_utf8); |
|
| 516 | + $this->debug('Use encoding: '.$this->xml_encoding.' when creating nusoap_parser');
|
|
| 517 | + $parser = new nusoap_parser($data, $this->xml_encoding, $this->operation, $this->decode_utf8); |
|
| 518 | 518 | // add parser debug data to our debug |
| 519 | 519 | $this->appendDebug($parser->getDebug()); |
| 520 | 520 | // if parse errors |
| 521 | - if($errstr = $parser->getError()){
|
|
| 522 | - $this->setError( $errstr); |
|
| 521 | + if ($errstr = $parser->getError()) {
|
|
| 522 | + $this->setError($errstr); |
|
| 523 | 523 | // destroy the parser object |
| 524 | 524 | unset($parser); |
| 525 | 525 | return false; |
@@ -569,7 +569,7 @@ discard block |
||
| 569 | 569 | * @param mixed $headers String of XML with SOAP header content, or array of soapval objects for SOAP headers |
| 570 | 570 | * @access public |
| 571 | 571 | */ |
| 572 | - function setHeaders($headers){
|
|
| 572 | + function setHeaders($headers) {
|
|
| 573 | 573 | $this->debug("setHeaders headers=");
|
| 574 | 574 | $this->appendDebug($this->varDump($headers)); |
| 575 | 575 | $this->requestHeaders = $headers; |
@@ -581,7 +581,7 @@ discard block |
||
| 581 | 581 | * @return string |
| 582 | 582 | * @access public |
| 583 | 583 | */ |
| 584 | - function getHeaders(){
|
|
| 584 | + function getHeaders() {
|
|
| 585 | 585 | return $this->responseHeaders; |
| 586 | 586 | } |
| 587 | 587 | |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | * @return mixed |
| 592 | 592 | * @access public |
| 593 | 593 | */ |
| 594 | - function getHeader(){
|
|
| 594 | + function getHeader() {
|
|
| 595 | 595 | return $this->responseHeader; |
| 596 | 596 | } |
| 597 | 597 | |
@@ -635,7 +635,7 @@ discard block |
||
| 635 | 635 | * @param string $enc HTTP encoding |
| 636 | 636 | * @access public |
| 637 | 637 | */ |
| 638 | - function setHTTPEncoding($enc='gzip, deflate'){
|
|
| 638 | + function setHTTPEncoding($enc = 'gzip, deflate') {
|
|
| 639 | 639 | $this->debug("setHTTPEncoding(\"$enc\")");
|
| 640 | 640 | $this->http_encoding = $enc; |
| 641 | 641 | } |
@@ -656,7 +656,7 @@ discard block |
||
| 656 | 656 | * |
| 657 | 657 | * @access public |
| 658 | 658 | */ |
| 659 | - function useHTTPPersistentConnection(){
|
|
| 659 | + function useHTTPPersistentConnection() {
|
|
| 660 | 660 | $this->debug("useHTTPPersistentConnection");
|
| 661 | 661 | $this->persistentConnection = true; |
| 662 | 662 | } |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | function _getProxyClassCode($r) {
|
| 750 | 750 | $this->debug("in getProxy endpointType=$this->endpointType");
|
| 751 | - $this->appendDebug("wsdl=" . $this->varDump($this->wsdl));
|
|
| 751 | + $this->appendDebug("wsdl=".$this->varDump($this->wsdl));
|
|
| 752 | 752 | if ($this->endpointType != 'wsdl') {
|
| 753 | 753 | $evalStr = 'A proxy can only be created for a WSDL client'; |
| 754 | 754 | $this->setError($evalStr); |
@@ -758,7 +758,7 @@ discard block |
||
| 758 | 758 | if ($this->endpointType == 'wsdl' && is_null($this->wsdl)) {
|
| 759 | 759 | $this->loadWSDL(); |
| 760 | 760 | if ($this->getError()) {
|
| 761 | - return "echo \"" . $this->getError() . "\";"; |
|
| 761 | + return "echo \"".$this->getError()."\";"; |
|
| 762 | 762 | } |
| 763 | 763 | } |
| 764 | 764 | $evalStr = ''; |
@@ -774,9 +774,9 @@ discard block |
||
| 774 | 774 | $paramArrayStr .= "'$name' => \$$name, "; |
| 775 | 775 | $paramCommentStr .= "$type \$$name, "; |
| 776 | 776 | } |
| 777 | - $paramStr = substr($paramStr, 0, strlen($paramStr)-2); |
|
| 778 | - $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr)-2); |
|
| 779 | - $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr)-2); |
|
| 777 | + $paramStr = substr($paramStr, 0, strlen($paramStr) - 2); |
|
| 778 | + $paramArrayStr = substr($paramArrayStr, 0, strlen($paramArrayStr) - 2); |
|
| 779 | + $paramCommentStr = substr($paramCommentStr, 0, strlen($paramCommentStr) - 2); |
|
| 780 | 780 | } else {
|
| 781 | 781 | $paramStr = ''; |
| 782 | 782 | $paramArrayStr = ''; |
@@ -784,7 +784,7 @@ discard block |
||
| 784 | 784 | } |
| 785 | 785 | $opData['namespace'] = !isset($opData['namespace']) ? 'http://testuri.com' : $opData['namespace']; |
| 786 | 786 | $evalStr .= "// $paramCommentStr |
| 787 | - function " . str_replace('.', '__', $operation) . "($paramStr) {
|
|
| 787 | + function ".str_replace('.', '__', $operation)."($paramStr) {
|
|
| 788 | 788 | \$params = array($paramArrayStr); |
| 789 | 789 | return \$this->call('$operation', \$params, '".$opData['namespace']."', '".(isset($opData['soapAction']) ? $opData['soapAction'] : '')."');
|
| 790 | 790 | } |
@@ -852,7 +852,7 @@ discard block |
||
| 852 | 852 | * @return always returns true |
| 853 | 853 | * @access public |
| 854 | 854 | */ |
| 855 | - function decodeUTF8($bool){
|
|
| 855 | + function decodeUTF8($bool) {
|
|
| 856 | 856 | $this->decode_utf8 = $bool; |
| 857 | 857 | return true; |
| 858 | 858 | } |
@@ -893,19 +893,19 @@ discard block |
||
| 893 | 893 | if (sizeof($this->cookies) == 0) {
|
| 894 | 894 | return true; |
| 895 | 895 | } |
| 896 | - $this->debug('checkCookie: check ' . sizeof($this->cookies) . ' cookies');
|
|
| 896 | + $this->debug('checkCookie: check '.sizeof($this->cookies).' cookies');
|
|
| 897 | 897 | $curr_cookies = $this->cookies; |
| 898 | 898 | $this->cookies = array(); |
| 899 | 899 | foreach ($curr_cookies as $cookie) {
|
| 900 | - if (! is_array($cookie)) {
|
|
| 900 | + if (!is_array($cookie)) {
|
|
| 901 | 901 | $this->debug('Remove cookie that is not an array');
|
| 902 | 902 | continue; |
| 903 | 903 | } |
| 904 | - if ((isset($cookie['expires'])) && (! empty($cookie['expires']))) {
|
|
| 904 | + if ((isset($cookie['expires'])) && (!empty($cookie['expires']))) {
|
|
| 905 | 905 | if (strtotime($cookie['expires']) > time()) {
|
| 906 | 906 | $this->cookies[] = $cookie; |
| 907 | 907 | } else {
|
| 908 | - $this->debug('Remove expired cookie ' . $cookie['name']);
|
|
| 908 | + $this->debug('Remove expired cookie '.$cookie['name']);
|
|
| 909 | 909 | } |
| 910 | 910 | } else {
|
| 911 | 911 | $this->cookies[] = $cookie; |
@@ -969,11 +969,11 @@ discard block |
||
| 969 | 969 | } |
| 970 | 970 | $this->cookies[$i] = $newCookie; |
| 971 | 971 | $found = true; |
| 972 | - $this->debug('Update cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 972 | + $this->debug('Update cookie '.$newName.'='.$newCookie['value']);
|
|
| 973 | 973 | break; |
| 974 | 974 | } |
| 975 | - if (! $found) {
|
|
| 976 | - $this->debug('Add cookie ' . $newName . '=' . $newCookie['value']);
|
|
| 975 | + if (!$found) {
|
|
| 976 | + $this->debug('Add cookie '.$newName.'='.$newCookie['value']);
|
|
| 977 | 977 | $this->cookies[] = $newCookie; |
| 978 | 978 | } |
| 979 | 979 | } |
@@ -173,8 +173,9 @@ discard block |
||
| 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 |
||
| 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]; |