diff --git a/README.md b/README.md
deleted file mode 100644
index ee43263..0000000
--- a/README.md
+++ /dev/null
@@ -1,2 +0,0 @@
-ZarinGate-WooCommece-V2
-=======================
diff --git a/README.txt b/README.txt
new file mode 100644
index 0000000..f02dd07
--- /dev/null
+++ b/README.txt
@@ -0,0 +1,54 @@
+=== Zarinpal Woocommerce Payment Gateway ===
+Contributors: Amini7
+Donate link: http://masoudamini.ir/
+Tags: zarinpal,Woocommerce,Payment,Gateway,farsi,persian,زرین پال,پرداخت,ووکامرس,درگاه
+Requires at least: 3.0.1
+Tested up to: 3.9
+Stable tag: 4.3
+License: GPLv2 or later
+License URI: http://www.gnu.org/licenses/gpl-2.0.html
+
+افزونه درگاه پرداخت زرین پال برای ووکامرس (زرین گیت)
+
+== Description ==
+
+افزونه درگاه پرداخت زرین پال برای ووکامرس (زرین گیت)
+
+
+
+== Installation ==
+
+This section describes how to install the plugin and get it working.
+
+e.g.
+
+1. Upload `WebGate-WooCommerce-V2/index.php` to the `/wp-content/plugins/` directory
+2. Activate the plugin through the 'Plugins' menu in WordPress
+3.Enter your merchantID in setting
+
+== Frequently Asked Questions ==
+
+
+
+== Screenshots ==
+
+
+
+== Changelog ==
+
+= 1.0 =
+* First Release
+
+
+
+== Upgrade Notice ==
+
+= 1.0 =
+
+
+
+
+== A brief Markdown Example ==
+
+
+``
diff --git a/ZarinpalZarinGate.php b/ZarinpalZarinGate.php
deleted file mode 100644
index 6ca9d83..0000000
--- a/ZarinpalZarinGate.php
+++ /dev/null
@@ -1,260 +0,0 @@
- id = 'zarinpalzg';
- $this -> method_title = __('زرین پال - زرین گیت', 'zarinpalzg');
- $this -> has_fields = false;
- $this -> init_form_fields();
- $this -> init_settings();
- $this -> title = $this -> settings['title'];
- $this -> merchant = $this -> settings['merchant'];
- $this -> redirect_page_id = $this -> settings['redirect_page_id'];
-
- $this -> msg['message'] = "";
- $this -> msg['class'] = "";
- add_action('init', array(&$this, 'check_zarinpalzg_response'));
- add_action('valid-zarinpalzg-request', array(&$this, 'successful_request'));
-
- if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) {
- add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( &$this, 'process_admin_options' ) );
- } else {
- add_action( 'woocommerce_update_options_payment_gateways', array( &$this, 'process_admin_options' ) );
- }
-
-
- add_action('woocommerce_receipt_zarinpalzg', array(&$this, 'receipt_page'));
- add_action('woocommerce_thankyou_zarinpalzg',array(&$this, 'thankyou_page'));
- }
-
- function init_form_fields(){
-
- $this -> form_fields = array(
- 'enabled' => array(
- 'title' => __('فعال سازی/غیر فعال سازی', 'zarinpalzg'),
- 'type' => 'checkbox',
- 'label' => __('فعال سازی درگاه پرداخت زرین پال - زرین گیت', 'zarinpalzg'),
- 'default' => 'no'),
- 'title' => array(
- 'title' => __('عنوان:', 'zarinpalzg'),
- 'type'=> 'text',
- 'description' => __('عنوانی که کاربر در هنگام پرداخت مشاهده می کند', 'zarinpalzg'),
- 'default' => __('پرداخت اینترنتی زرین پال - زرین گیت', 'zarinpalzg')),
- 'description' => array(
- 'title' => __('توضیحات:', 'zarinpalzg'),
- 'type' => 'textarea',
- 'description' => __('توضیحات قابل نمایش به کاربر در هنگام انتخاب درگاه پرداخت', 'zarinpalzg'),
- 'default' => __('پرداخت از طریق درگاه زرین پال با کارت های عضو شتاب', 'zarinpalzg')),
- 'merchant' => array(
- 'title' => __('پین کد', 'zarinpalzg'),
- 'type' => 'text',
- 'description' => __('پین کد درگاه را وارد کنید')),
- 'redirect_page_id' => array(
- 'title' => __('صفحه بازگشت'),
- 'type' => 'select',
- 'options' => $this -> get_pages('انتخاب برگه'),
- 'description' => "ادرس بازگشت از پرداخت در هنگام پرداخت"
- )
- );
-
-
- }
- /**
- * Admin Panel Options
- * - Options for bits like 'title' and availability on a country-by-country basis
- **/
- public function admin_options(){
- echo '
'.__('درگاه زرین پال - زرین گیت', 'zarinpalzg').'
';
- echo ''.__('درگاه زرین پال - زرین گیت').'
';
- echo '';
-
- }
- /**
- * There are no payment fields for zarinpalzg, but we want to show the description if set.
- **/
- function payment_fields(){
- if($this -> description) echo wpautop(wptexturize($this -> description));
- }
- /**
- * Receipt Page
- **/
- function receipt_page($order){
- echo ''.__('با تشکر از سفارش شما. در حال انتقال به درگاه پرداخت...', 'zarinpalzg').'
';
- echo $this -> generate_zarinpalzg_form($order);
- }
- /**
- * Process the payment and return the result
- **/
- function process_payment($order_id){
- $order = &new WC_Order($order_id);
- return array('result' => 'success', 'redirect' => add_query_arg('order',
- $order->id, add_query_arg('key', $order->order_key, get_permalink(get_option('woocommerce_pay_page_id'))))
- );
- }
- /**
- * Check for valid zarinpalzg server callback
- **/
- function check_zarinpalzg_response(){
- global $woocommerce;
- $order_id=$_SESSION['zarinpalzg_id'];
- $order = new WC_Order($order_id);
- $au = $_GET['Authority'];
- $st = $_GET['Status'];
- if($order_id != '' AND $au !='' AND $st == "OK" ){
- if($order -> status !=='completed'){
-
-
- $merchantID = $this -> merchant;
-
- $amount = round($order -> order_total/10);
- include_once("lib/nusoap.php");
- $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
- $res = $client->call("PaymentVerification", array(
- array(
- 'MerchantID' => $merchantID ,
- 'Authority' => $au ,
- 'Amount' => $amount
- )
- ));
-
- if ($res['Status'] == 100)
- {
- $_SESSION['zarinpalzg_id'] = '';
- $output[status] = 1;
- $output[message] ='پرداخت با موفقیت انجام گردید.';
- $order -> payment_complete();
- $order -> add_order_note('پرداخت انجام گردید
کد رهگیری بانک: '.$res['RefID']);
- $order -> add_order_note($this->msg['message']);
- $woocommerce -> cart -> empty_cart();
- }
- else
- {
-
- $output[status] = 0;
- $output[message]= 'پرداخت توسط زرین پال تایید نشد.'.$res['Status'];
- }
-
-
-
- if ($output[status] == 0)
- $order -> add_order_note($output[message]);
-
-
-
-}
-}
-
-}
-
-
-
-
- function showMessage($content){
- return ''.$this -> msg['message'].'
'.$content;
- }
- /**
- * Generate zarinpalzg button link
- **/
-
- public function generate_zarinpalzg_form($order_id){
- global $woocommerce;
- $order = &new WC_Order($order_id);
- $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
- $_SESSION['zarinpalzg_id'] = $order_id;
- $merchantID = trim($this -> merchant);
- $amount = round($order -> order_total/10);
- $invoice_id=date('Y').date('H').date('i').date('s').$order_id;
- $callBackUrl = $redirect_url;
- include_once("lib/nusoap.php");
- $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
- $res = $client->call('PaymentRequest', array(
- array(
- 'MerchantID' => $merchantID ,
- 'Amount' => $amount ,
- 'Description' => $order_id ,
- 'Email' => '' ,
- 'Mobile' => '' ,
- 'CallbackURL' => $callBackUrl
-
- )
- ));
- if ($res['Status'] == 100)
- {
- header('location: https://www.zarinpal.com/pg/StartPay/' . $res['Authority'] .'/ZarinGate');
- exit;
- }
- else
- {
- $this -> msg['class'] = 'error';
- echo $this -> msg['message'] = 'در اتصال به درگاه زرین پال مشکلی به وجود آمد٬ لطفا از درگاه سایر بانکها استفاده نمایید.'.$res['Status'];
-
- }
-
-
-
-
-
-
- if($this -> msg['class']=='error')
- $order -> add_order_note($this->msg['message']);
-
- }
-
-
- // get all pages
- function get_pages($title = false, $indent = true) {
- $wp_pages = get_pages('sort_column=menu_order');
- $page_list = array();
- if ($title) $page_list[] = $title;
- foreach ($wp_pages as $page) {
- $prefix = '';
- // show indented child pages?
- if ($indent) {
- $has_parent = $page->post_parent;
- while($has_parent) {
- $prefix .= ' - ';
- $next_page = get_page($has_parent);
- $has_parent = $next_page->post_parent;
- }
- }
- // add to page list array array
- $page_list[$page->ID] = $prefix . $page->post_title;
- }
- return $page_list;
- }
-
- }
-
- /**
- * Add the Gateway to WooCommerce
- **/
- function woocommerce_add_zarinpalzg_gateway($methods) {
- $methods[] = 'WC_zarinpalzg_Pay';
- return $methods;
- }
-
- add_filter('woocommerce_payment_gateways', 'woocommerce_add_zarinpalzg_gateway' );
-}
-
-?>
diff --git a/images/logo.png b/images/logo.png
new file mode 100644
index 0000000..fedced1
Binary files /dev/null and b/images/logo.png differ
diff --git a/index.php b/index.php
new file mode 100644
index 0000000..8e9b683
--- /dev/null
+++ b/index.php
@@ -0,0 +1,334 @@
+'.urldecode($_GET['msg']).''.$content;
+ }
+
+ class WC_Zarinpalwg_Pay extends WC_Payment_Gateway {
+ protected $msg = array();
+ public function __construct(){
+ // Go wild in here
+ $this -> id = 'zarinpalzg';
+ $this -> method_title = __('زرین پال', 'mrova');
+ $this -> icon = WP_PLUGIN_URL . "/" . plugin_basename(dirname(__FILE__)) . '/images/logo.png';
+ $this -> has_fields = false;
+ $this -> init_form_fields();
+ $this -> init_settings();
+ $this -> title = $this -> settings['title'];
+
+ $this -> merchantid = $this -> settings['merchantid'];
+ $this -> redirect_page_id = $this -> settings['redirect_page_id'];
+
+ $this -> msg['reversal'] = "";
+ $this -> msg['status'] = "";
+ $this -> msg['message'] = "";
+ $this -> msg['class'] = "";
+
+ add_action( 'woocommerce_api_wc_zarinpalzg_pay' , array( $this, 'check_zarinpalzg_response' ) );
+ add_action('valid-zarinpalzg-request', array($this, 'successful_request'));
+ if ( version_compare( WOOCOMMERCE_VERSION, '2.0.0', '>=' ) ) {
+ add_action( 'woocommerce_update_options_payment_gateways_' . $this->id, array( $this, 'process_admin_options' ) );
+ } else {
+ add_action( 'woocommerce_update_options_payment_gateways', array( $this, 'process_admin_options' ) );
+ }
+ add_action('woocommerce_receipt_zarinpalzg', array($this, 'receipt_page'));
+ add_action('woocommerce_thankyou_zarinpalzg',array($this, 'thankyou_page'));
+ }
+
+ function init_form_fields(){
+
+ $this -> form_fields = array(
+ 'enabled' => array(
+ 'title' => __('فعال / غیر فعال کردن', 'mrova'),
+ 'type' => 'checkbox',
+ 'label' => __('انتخاب وضعیت درگاه پرداخت زرین پال', 'mrova'),
+ 'default' => 'no'),
+ 'title' => array(
+ 'title' => __('عنوان درگاه', 'mrova'),
+ 'type'=> 'text',
+ 'description' => __('عنوان درگاه در هنگام انتخاب درگاه پرداخت', 'mrova'),
+ 'default' => __('پرداخت از طریق درگاه پرداخت زرین پال', 'mrova')),
+ 'description' => array(
+ 'title' => __('توضیحات درگاه', 'mrova'),
+ 'type' => 'textarea',
+ 'description' => __('توضیحات نوشته شده در زیر لوگوی درگاه هنگام پرداخت', 'mrova'),
+ 'default' => __('پرداخت با استفاده از درگاه برداخت زرین پال از طریق کلبه کارت های بانکی عضو شتاب', 'mrova')),
+ 'merchantid' => array(
+ 'title' => __('شناسه درگاه', 'mrova'),
+ 'type' => 'text',
+ 'description' => __('شناسه درگاه يا همان MerchantID')),
+ 'redirect_page_id' => array(
+ 'title' => __('برگه بازگشت'),
+ 'type' => 'select',
+ 'options' => $this -> get_pages('انتخاب برگه'),
+ 'description' => __('ادرس بازگشت از پرداخت در هنگام پرداخت')
+ )
+ );
+
+
+ }
+ /**
+ * Admin Panel Options
+ * - Options for bits like 'title' and availability on a country-by-country basis
+ **/
+ public function admin_options(){
+ echo ''.__('درگاه پرداخت زرین پال', 'mrova').'
';
+
+ echo '';
+
+ }
+ /**
+ * There are no payment fields for zarinpalzg, but we want to show the description if set.
+ **/
+ function payment_fields(){
+ if($this -> description) echo wpautop(wptexturize($this -> description));
+ }
+ /**
+ * Receipt Page
+ **/
+ function receipt_page($order){
+ echo ''.__('از سفارش شما متشکريم ، تا انتقال به درگاه پرداخت چند لحظه منتظر بمانيد ...', 'mrova').'
';
+ echo $this -> generate_zarinpalzg_form($order);
+ }
+ /**
+ * Process the payment and return the result
+ **/
+ function process_payment($order_id){
+ $order = new WC_Order($order_id);
+ return array('result' => 'success', 'redirect' => $order->get_checkout_payment_url( true ));
+ }
+ /**
+ * Check for valid zarinpalzg server callback
+ **/
+ function check_zarinpalzg_response(){
+ global $woocommerce;
+ $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
+ $client->soap_defencoding = 'UTF-8';
+ $Status = $_GET['Status'];
+ $Authority = $_GET['Authority'];
+
+ $MerchantID = $this -> merchantid;
+ $order_id = $woocommerce->session->zarinpalzg_woo_id;
+ $order = new WC_Order($order_id);
+ if($Status != "OK"){
+print_r($Status);
+ $this -> msg['status'] = -1;
+ $this -> msg['message']= 'خطا در عمليات پرداخت ! عمليا پرداخت با موفقيت به پايان نرسيده است !';
+ }
+ if( $Status == "OK")
+ {
+ if($order -> status !=='completed')
+ {
+
+ $result = $client->call("PaymentVerification", array(
+ array(
+ 'MerchantID' => $MerchantID ,
+ 'Authority' => $Authority ,
+ 'Amount' => $order->order_total
+ )
+ ));
+
+
+
+ // Check for a fault
+ $Status2 = $result['Status'];
+ $PayPrice = $result['verifyPaymentResult']['PayementedPrice'];
+
+ if(strtolower($Status2) == 100 )
+ {
+ unset($woocommerce->session->zarinpalzg_woo_id);
+ $this -> msg['status'] = 1;
+ $this -> msg['message'] ='پرداخت با موفقیت انجام گردید.';
+ $order -> payment_complete();
+ $order -> add_order_note('پرداخت انجام گردید
شماره رسيد پرداخت: '.$result['RefID'] );
+ $order -> add_order_note($this -> msg['message']);
+ $woocommerce -> cart -> empty_cart();
+ }
+ else
+ {
+ $this -> msg['status'] = -88;
+ $this -> msg['message'] = 'خطايي در اعتبار سنجي پرداخت به وجود آمده است ! وضعيت خطا : '.$Status2;
+ }
+
+ }
+
+ }else
+ {
+ $this -> msg['status'] = -80;
+ $this -> msg['message'] = 'خطا در عمليات پرداخت ! عمليات پرداخت با موفقيت به پايان نرسيده است !';
+ }
+
+
+
+ if ($this -> msg['status'] == 1){
+
+ $this -> msg['class']='success';
+ }
+ else
+ {
+ $order -> add_order_note($this -> msg['message']);
+ $this -> msg['class']='error';
+ }
+ $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
+ //For wooCoomerce 2.0
+ $redirect_url = add_query_arg( array('msg'=> urlencode($this -> msg['message']), 'type'=>$this -> msg['class']), $redirect_url );
+
+ wp_redirect( $redirect_url );
+ exit;
+}
+
+
+
+
+ /**
+ * Generate zarinpalzg button link
+ **/
+
+ public function generate_zarinpalzg_form($order_id){
+ global $woocommerce;
+ $order = &new WC_Order($order_id);
+ $redirect_url = ($this -> redirect_page_id=="" || $this -> redirect_page_id==0)?get_site_url() . "/":get_permalink($this -> redirect_page_id);
+ $redirect_url = add_query_arg( 'wc-api', get_class( $this ), $redirect_url );
+
+
+
+ $client = new nusoap_client('https://de.zarinpal.com/pg/services/WebGate/wsdl', 'wsdl');
+ $client->soap_defencoding = 'UTF-8';
+ $MerchantID = $this -> merchantid;
+ $orderId=rand(1, 9999999999999);
+ unset($woocommerce->session->zarinpalzg_woo_id);
+ $woocommerce->session->zarinpalzg_woo_id = $order_id;
+ $amount = str_replace(".00", "", $order -> order_total);;
+ $callBackUrl = $redirect_url;
+ $payerId = '0';
+
+
+ $result = $client->call("PaymentRequest", array(
+ array(
+ 'MerchantID' => $MerchantID ,
+ 'Amount' => $amount ,
+ 'Description' => 'پرداخت سفارش شماره '. $order_id ,
+ 'Email' => $order->billing_email ,
+ 'Mobile' => $order->billing_phone ,
+ 'CallbackURL' => $callBackUrl
+
+ )
+ ));
+
+
+ // Check for a fault
+ if ($client->fault) {
+ echo 'Fault
';
+ print_r($result);
+ echo '
';
+ }
+ else {
+ // Check for errors
+
+ $Status2 = $result['Status'];
+ $PayPath = 'https://www.zarinpal.com/pg/StartPay/' . $result['Authority'] .'/ZarinGate';
+ if ($Status2 != 100 ) {
+ $this -> msg['class'] = 'error';
+ $this -> msg['message'] = $Status;
+ echo ' در اتصال به درگاه پرداخت خطايي رخ داده است ! وضعيت خطا : '.$Status2.'
';
+ }
+ else {
+ // Display the result
+
+ $send_atu="";
+ echo '
+ '.$send_atu ;
+ }
+ }
+
+
+
+ if($this -> msg['class']=='error')
+ $order -> add_order_note($this->msg['message']);
+
+ }
+
+ private function western_to_persian($str) {
+ $alphabet = array (
+ 'Û°' => '۰', 'Û±' => '۱', 'Û²' => '۲', 'Û³' => '۳', 'Û´' => '۴', 'Ûµ' => '۵', 'Û¶' => '۶', 'Û·' => '۷', 'Û¸' => '۸',
+ 'Û¹' => '۹', 'Ø¢' => 'آ', 'ا' => 'ا', 'Ø£' => 'أ', 'Ø¥' => 'إ', 'ؤ' => 'ؤ', 'ئ' => 'ئ', 'Ø¡' => 'ء', 'ب' => 'ب',
+ 'Ù¾' => 'پ', 'ت' => 'ت', 'Ø«' => 'ث', 'ج' => 'ج', 'Ú†' => 'چ', 'Ø' => 'ح', 'Ø®' => 'خ', 'د' => 'د', 'Ø°' => 'ذ',
+ 'ر' => 'ر', 'ز' => 'ز', 'Ú˜' => 'ژ', 'س' => 'س', 'Ø´' => 'ش', 'ص' => 'ص', 'ض' => 'ض', 'Ø·' => 'ط', 'ظ' => 'ظ',
+ 'ع' => 'ع', 'غ' => 'غ', 'Ù' => 'ف', 'Ù‚' => 'ق', 'Ú©' => 'ک', 'Ú¯' => 'گ', 'Ù„' => 'ل', 'Ù…' => 'م', 'Ù†' => 'ن',
+ 'Ùˆ' => 'و', 'Ù‡' => 'ه', 'ÛŒ' => 'ی', 'ÙŠ' => 'ي', 'Û€' => 'ۀ', 'Ø©' => 'ة', 'ÙŽ' => 'َ', 'Ù' => 'ُ', 'Ù' => 'ِ',
+ 'Ù‘' => 'ّ', 'Ù‹' => 'ً', 'ÙŒ' => 'ٌ', 'Ù' => 'ٍ', 'ØŒ' => '،', 'Ø›' => '؛', ',' => ',', 'ØŸ' => '؟'
+ );
+
+ foreach($alphabet as $western => $fa)
+ $str = str_replace($western, $fa, $str);
+
+ return $str;
+}
+ // get all pages
+ function get_pages($title = false, $indent = true) {
+ $wp_pages = get_pages('sort_column=menu_order');
+ $page_list = array();
+ if ($title) $page_list[] = $title;
+ foreach ($wp_pages as $page) {
+ $prefix = '';
+ // show indented child pages?
+ if ($indent) {
+ $has_parent = $page->post_parent;
+ while($has_parent) {
+ $prefix .= ' - ';
+ $next_page = get_page($has_parent);
+ $has_parent = $next_page->post_parent;
+ }
+ }
+ // add to page list array array
+ $page_list[$page->ID] = $prefix . $page->post_title;
+ }
+ return $page_list;
+ }
+
+ }
+
+ /**
+ * Add the Gateway to WooCommerce
+ **/
+ function woocommerce_add_zarinpalzg_gateway($methods) {
+ $methods[] = 'WC_Zarinpalwg_Pay';
+ return $methods;
+ }
+
+ add_filter('woocommerce_payment_gateways', 'woocommerce_add_zarinpalzg_gateway' );
+}
+
+?>
diff --git a/lib/nusoap.php b/nusoap.php
similarity index 94%
rename from lib/nusoap.php
rename to nusoap.php
index 15c8581..3ae62bb 100644
--- a/lib/nusoap.php
+++ b/nusoap.php
@@ -1,7 +1,7 @@
globalDebugLevel = 9;
/**
*
@@ -79,7 +90,7 @@
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class nusoap_base {
@@ -96,14 +107,14 @@ class nusoap_base {
* @var string
* @access private
*/
- var $version = '0.9.5';
+ var $version = '0.7.3';
/**
* CVS revision for HTTP headers.
*
* @var string
* @access private
*/
- var $revision = '$Revision: 1.123 $';
+ var $revision = '$Revision: 1.114 $';
/**
* Current error string (manipulated by getError/setError)
*
@@ -223,7 +234,7 @@ class nusoap_base {
* @access public
*/
function nusoap_base() {
- $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
+ $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel;
}
/**
@@ -233,7 +244,7 @@ function nusoap_base() {
* @access public
*/
function getGlobalDebugLevel() {
- return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'];
+ return $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel;
}
/**
@@ -243,7 +254,7 @@ function getGlobalDebugLevel() {
* @access public
*/
function setGlobalDebugLevel($level) {
- $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level;
+ $GLOBALS['_transient']['static']['nusoap_base']->globalDebugLevel = $level;
}
/**
@@ -561,7 +572,7 @@ function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=fals
case (is_array($val) || $type):
// detect if struct or array
$valueType = $this->isArraySimpleOrStruct($val);
- if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){
+ if($valueType=='arraySimple' || ereg('^ArrayOf',$type)){
$this->debug("serialize_val: serialize array");
$i = 0;
if(is_array($val) && count($val)> 0){
@@ -764,7 +775,7 @@ function contractQname($qname){
*/
function expandQname($qname){
// get element prefix
- if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){
+ if(strpos($qname,':') && !ereg('^http://',$qname)){
// get unqualified name
$name = substr(strstr($qname,':'),1);
// get ns prefix
@@ -896,24 +907,14 @@ function __toString() {
/**
* convert unix timestamp to ISO 8601 compliant date string
*
-* @param int $timestamp Unix time stamp
+* @param string $timestamp Unix time stamp
* @param boolean $utc Whether the time stamp is UTC or local
-* @return mixed ISO 8601 date string or false
* @access public
*/
function timestamp_to_iso8601($timestamp,$utc=true){
$datestr = date('Y-m-d\TH:i:sO',$timestamp);
- $pos = strrpos($datestr, "+");
- if ($pos === FALSE) {
- $pos = strrpos($datestr, "-");
- }
- if ($pos !== FALSE) {
- if (strlen($datestr) == $pos + 5) {
- $datestr = substr($datestr, 0, $pos + 3) . ':' . substr($datestr, -2);
- }
- }
if($utc){
- $pattern = '/'.
+ $eregStr =
'([0-9]{4})-'. // centuries & years CCYY-
'([0-9]{2})-'. // months MM-
'([0-9]{2})'. // days DD
@@ -921,10 +922,9 @@ function timestamp_to_iso8601($timestamp,$utc=true){
'([0-9]{2}):'. // hours hh:
'([0-9]{2}):'. // minutes mm:
'([0-9]{2})(\.[0-9]*)?'. // seconds ss.ss...
- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
- '/';
+ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
- if(preg_match($pattern,$datestr,$regs)){
+ if(ereg($eregStr,$datestr,$regs)){
return sprintf('%04d-%02d-%02dT%02d:%02d:%02dZ',$regs[1],$regs[2],$regs[3],$regs[4],$regs[5],$regs[6]);
}
return false;
@@ -937,11 +937,10 @@ function timestamp_to_iso8601($timestamp,$utc=true){
* convert ISO 8601 compliant date string to unix timestamp
*
* @param string $datestr ISO 8601 compliant date string
-* @return mixed Unix timestamp (int) or false
* @access public
*/
function iso8601_to_timestamp($datestr){
- $pattern = '/'.
+ $eregStr =
'([0-9]{4})-'. // centuries & years CCYY-
'([0-9]{2})-'. // months MM-
'([0-9]{2})'. // days DD
@@ -949,9 +948,8 @@ function iso8601_to_timestamp($datestr){
'([0-9]{2}):'. // hours hh:
'([0-9]{2}):'. // minutes mm:
'([0-9]{2})(\.[0-9]+)?'. // seconds ss.ss...
- '(Z|[+\-][0-9]{2}:?[0-9]{2})?'. // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
- '/';
- if(preg_match($pattern,$datestr,$regs)){
+ '(Z|[+\-][0-9]{2}:?[0-9]{2})?'; // Z to indicate UTC, -/+HH:MM:SS.SS... for local tz's
+ if(ereg($eregStr,$datestr,$regs)){
// not utc
if($regs[8] != 'Z'){
$op = substr($regs[8],0,1);
@@ -1001,7 +999,7 @@ function usleepWindows($usec)
* Mainly used for returning faults from deployed functions
* in a server instance.
* @author Dietrich Ayala
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class nusoap_fault extends nusoap_base {
@@ -1089,7 +1087,7 @@ class soap_fault extends nusoap_fault {
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class nusoap_xmlschema extends nusoap_base {
@@ -1279,7 +1277,7 @@ function schemaStartElement($parser, $name, $attrs) {
if(count($attrs) > 0){
foreach($attrs as $k => $v){
// if ns declarations, add to class level array of valid namespaces
- if(preg_match('/^xmlns/',$k)){
+ if(ereg("^xmlns",$k)){
//$this->xdebug("$k: $v");
//$this->xdebug('ns_prefix: '.$this->getPrefix($k));
if($ns_prefix = substr(strrchr($k,':'),1)){
@@ -1324,7 +1322,6 @@ function schemaStartElement($parser, $name, $attrs) {
$this->xdebug("parsing attribute:");
$this->appendDebug($this->varDump($attrs));
if (!isset($attrs['form'])) {
- // TODO: handle globals
$attrs['form'] = $this->schemaInfo['attributeFormDefault'];
}
if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) {
@@ -1374,7 +1371,6 @@ function schemaStartElement($parser, $name, $attrs) {
}
break;
case 'complexContent': // (optional) content for a complexType
- $this->xdebug("do nothing for element $name");
break;
case 'complexType':
array_push($this->complexTypeStack, $this->currentComplexType);
@@ -1393,7 +1389,7 @@ function schemaStartElement($parser, $name, $attrs) {
// minOccurs="0" maxOccurs="unbounded" />
//
//
- if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
+ if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
@@ -1413,24 +1409,18 @@ function schemaStartElement($parser, $name, $attrs) {
// minOccurs="0" maxOccurs="unbounded" />
//
//
- if(isset($attrs['base']) && preg_match('/:Array$/',$attrs['base'])){
+ if(isset($attrs['base']) && ereg(':Array$',$attrs['base'])){
$this->xdebug('complexType is unusual array');
$this->complexTypes[$this->currentComplexType]['phpType'] = 'array';
} else {
$this->complexTypes[$this->currentComplexType]['phpType'] = 'struct';
}
}
- $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'false';
break;
case 'element':
array_push($this->elementStack, $this->currentElement);
if (!isset($attrs['form'])) {
- if ($this->currentComplexType) {
- $attrs['form'] = $this->schemaInfo['elementFormDefault'];
- } else {
- // global
- $attrs['form'] = 'qualified';
- }
+ $attrs['form'] = $this->schemaInfo['elementFormDefault'];
}
if(isset($attrs['type'])){
$this->xdebug("processing typed element ".$attrs['name']." of type ".$attrs['type']);
@@ -1484,38 +1474,22 @@ function schemaStartElement($parser, $name, $attrs) {
case 'extension': // simpleContent or complexContent type extension
$this->xdebug('extension ' . $attrs['base']);
if ($this->currentComplexType) {
- $ns = $this->getPrefix($attrs['base']);
- if ($ns == '') {
- $this->complexTypes[$this->currentComplexType]['extensionBase'] = $this->schemaTargetNamespace . ':' . $attrs['base'];
- } else {
- $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
- }
- } else {
- $this->xdebug('no current complexType to set extensionBase');
+ $this->complexTypes[$this->currentComplexType]['extensionBase'] = $attrs['base'];
}
break;
case 'import':
if (isset($attrs['schemaLocation'])) {
- $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
+ //$this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']);
$this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
} else {
- $this->xdebug('import namespace ' . $attrs['namespace']);
+ //$this->xdebug('import namespace ' . $attrs['namespace']);
$this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true);
if (! $this->getPrefixFromNamespace($attrs['namespace'])) {
$this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace'];
}
}
break;
- case 'include':
- if (isset($attrs['schemaLocation'])) {
- $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']);
- $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false);
- } else {
- $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute');
- }
- break;
case 'list': // simpleType value list
- $this->xdebug("do nothing for element $name");
break;
case 'restriction': // simpleType, simpleContent or complexContent value restriction
$this->xdebug('restriction ' . $attrs['base']);
@@ -1542,11 +1516,6 @@ function schemaStartElement($parser, $name, $attrs) {
}
break;
case 'simpleContent': // (optional) content for a complexType
- if ($this->currentComplexType) { // This should *always* be
- $this->complexTypes[$this->currentComplexType]['simpleContent'] = 'true';
- } else {
- $this->xdebug("do nothing for element $name because there is no current complexType");
- }
break;
case 'simpleType':
array_push($this->simpleTypeStack, $this->currentSimpleType);
@@ -1566,10 +1535,9 @@ function schemaStartElement($parser, $name, $attrs) {
}
break;
case 'union': // simpleType type list
- $this->xdebug("do nothing for element $name");
break;
default:
- $this->xdebug("do not have any logic to process element $name");
+ //$this->xdebug("do not have anything to do for element $name");
}
}
@@ -1597,7 +1565,6 @@ function schemaEndElement($parser, $name) {
// move on...
if($name == 'complexType'){
$this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)'));
- $this->xdebug($this->varDump($this->complexTypes[$this->currentComplexType]));
$this->currentComplexType = array_pop($this->complexTypeStack);
//$this->currentElement = false;
}
@@ -1607,7 +1574,6 @@ function schemaEndElement($parser, $name) {
}
if($name == 'simpleType'){
$this->xdebug('done processing simpleType ' . ($this->currentSimpleType ? $this->currentSimpleType : '(unknown)'));
- $this->xdebug($this->varDump($this->simpleTypes[$this->currentSimpleType]));
$this->currentSimpleType = array_pop($this->simpleTypeStack);
}
}
@@ -1844,9 +1810,6 @@ function getTypeDef($type){
if (isset($etype['elements'])) {
$this->elements[$type]['elements'] = $etype['elements'];
}
- if (isset($etype['extensionBase'])) {
- $this->elements[$type]['extensionBase'] = $etype['extensionBase'];
- }
} elseif ($ns == 'http://www.w3.org/2001/XMLSchema') {
$this->xdebug("in getTypeDef, element $type is an XSD type");
$this->elements[$type]['phpType'] = 'scalar';
@@ -1856,7 +1819,7 @@ function getTypeDef($type){
} elseif(isset($this->attributes[$type])){
$this->xdebug("in getTypeDef, found attribute $type");
return $this->attributes[$type];
- } elseif (preg_match('/_ContainedType$/', $type)) {
+ } elseif (ereg('_ContainedType$', $type)) {
$this->xdebug("in getTypeDef, have an untyped element $type");
$typeDef['typeClass'] = 'simpleType';
$typeDef['phpType'] = 'scalar';
@@ -2061,7 +2024,7 @@ class XMLSchema extends nusoap_xmlschema {
* xsd:anyType and user-defined types.
*
* @author Dietrich Ayala
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class soapval extends nusoap_base {
@@ -2163,7 +2126,7 @@ function decode(){
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class soap_transport_http extends nusoap_base {
@@ -2220,7 +2183,7 @@ function soap_transport_http($url, $curl_options = NULL, $use_curl = false){
$this->ch_options = $curl_options;
}
$this->use_curl = $use_curl;
- preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
+ ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
$this->setHeader('User-Agent', $this->title.'/'.$this->version.' ('.$rev[1].')');
}
@@ -2396,7 +2359,7 @@ function connect($connection_timeout=0,$response_timeout=30){
} else if ($this->io_method() == 'curl') {
if (!extension_loaded('curl')) {
// $this->setError('cURL Extension, or OpenSSL extension w/ PHP version >= 4.3 is required for HTTPS');
- $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.');
+ $this->setError('The PHP cURL Extension is required for HTTPS or NLTM. You will need to re-build or update your PHP to included cURL.');
return false;
}
// Avoid warnings when PHP does not have these options
@@ -2711,8 +2674,8 @@ function setEncoding($enc='gzip, deflate') {
$this->setHeader('Connection', 'close');
$this->persistentConnection = false;
}
- // deprecated as of PHP 5.3.0
- //set_magic_quotes_runtime(0);
+ set_magic_quotes_runtime(0);
+ // deprecated
$this->encoding = $enc;
}
}
@@ -2845,9 +2808,7 @@ function buildPayload($data, $cookie_str = '') {
// debugging guides.
// add content-length header
- if ($this->request_method != 'GET') {
- $this->setHeader('Content-Length', strlen($data));
- }
+ $this->setHeader('Content-Length', strlen($data));
// start building outgoing payload:
if ($this->proxy) {
@@ -2985,7 +2946,7 @@ function getResponse(){
}
}
// remove 100 headers
- if (isset($lb) && preg_match('/^HTTP\/1.1 100/',$data)) {
+ if (isset($lb) && ereg('^HTTP/1.1 100',$data)) {
unset($lb);
$data = '';
}//
@@ -3151,7 +3112,7 @@ function getResponse(){
if ($data == '') {
// have nothing left; just remove 100 header(s)
$data = $savedata;
- while (preg_match('/^HTTP\/1.1 100/',$data)) {
+ while (ereg('^HTTP/1.1 100',$data)) {
if ($pos = strpos($data,"\r\n\r\n")) {
$data = ltrim(substr($data,$pos));
} elseif($pos = strpos($data,"\n\n") ) {
@@ -3355,7 +3316,7 @@ function usePersistentConnection(){
*/
function parseCookie($cookie_str) {
$cookie_str = str_replace('; ', ';', $cookie_str) . ';';
- $data = preg_split('/;/', $cookie_str);
+ $data = split(';', $cookie_str);
$value_str = $data[0];
$cookie_param = 'domain=';
@@ -3468,7 +3429,7 @@ function getCookiesForRequest($cookies, $secure=false) {
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class nusoap_server extends nusoap_base {
@@ -3694,14 +3655,6 @@ function nusoap_server($wsdl=false){
function service($data){
global $HTTP_SERVER_VARS;
- if (isset($_SERVER['REQUEST_METHOD'])) {
- $rm = $_SERVER['REQUEST_METHOD'];
- } elseif (isset($HTTP_SERVER_VARS['REQUEST_METHOD'])) {
- $rm = $HTTP_SERVER_VARS['REQUEST_METHOD'];
- } else {
- $rm = '';
- }
-
if (isset($_SERVER['QUERY_STRING'])) {
$qs = $_SERVER['QUERY_STRING'];
} elseif (isset($HTTP_SERVER_VARS['QUERY_STRING'])) {
@@ -3709,38 +3662,19 @@ function service($data){
} else {
$qs = '';
}
- $this->debug("In service, request method=$rm query string=$qs strlen(\$data)=" . strlen($data));
+ $this->debug("In service, query string=$qs");
- if ($rm == 'POST') {
- $this->debug("In service, invoke the request");
- $this->parse_request($data);
- if (! $this->fault) {
- $this->invoke_method();
- }
- if (! $this->fault) {
- $this->serialize_return();
- }
- $this->send_response();
- } elseif (preg_match('/wsdl/', $qs) ){
+ if (ereg('wsdl', $qs) ){
$this->debug("In service, this is a request for WSDL");
- if ($this->externalWSDLURL){
- if (strpos($this->externalWSDLURL, "http://") !== false) { // assume URL
- $this->debug("In service, re-direct for WSDL");
+ if($this->externalWSDLURL){
+ if (strpos($this->externalWSDLURL,"://")!==false) { // assume URL
header('Location: '.$this->externalWSDLURL);
} else { // assume file
- $this->debug("In service, use file passthru for WSDL");
header("Content-Type: text/xml\r\n");
- $pos = strpos($this->externalWSDLURL, "file://");
- if ($pos === false) {
- $filename = $this->externalWSDLURL;
- } else {
- $filename = substr($this->externalWSDLURL, $pos + 7);
- }
$fp = fopen($this->externalWSDLURL, 'r');
fpassthru($fp);
}
} elseif ($this->wsdl) {
- $this->debug("In service, serialize WSDL");
header("Content-Type: text/xml; charset=ISO-8859-1\r\n");
print $this->wsdl->serialize($this->debug_flag);
if ($this->debug_flag) {
@@ -3749,17 +3683,22 @@ function service($data){
print $this->getDebugAsXMLComment();
}
} else {
- $this->debug("In service, there is no WSDL");
header("Content-Type: text/html; charset=ISO-8859-1\r\n");
print "This service does not provide WSDL";
}
- } elseif ($this->wsdl) {
- $this->debug("In service, return Web description");
+ } elseif ($data == '' && $this->wsdl) {
+ $this->debug("In service, there is no data, so return Web description");
print $this->wsdl->webDescription();
} else {
- $this->debug("In service, no Web description");
- header("Content-Type: text/html; charset=ISO-8859-1\r\n");
- print "This service does not provide a Web description";
+ $this->debug("In service, invoke the request");
+ $this->parse_request($data);
+ if (! $this->fault) {
+ $this->invoke_method();
+ }
+ if (! $this->fault) {
+ $this->serialize_return();
+ }
+ $this->send_response();
}
}
@@ -3796,7 +3735,7 @@ function parse_http_headers() {
// get the character encoding of the incoming request
if(isset($this->headers['content-type']) && strpos($this->headers['content-type'],'=')){
$enc = str_replace('"','',substr(strstr($this->headers["content-type"],'='),1));
- if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
+ if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3825,7 +3764,7 @@ function parse_http_headers() {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
- if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
+ if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3859,7 +3798,7 @@ function parse_http_headers() {
$enc = substr(strstr($v, '='), 1);
$enc = str_replace('"', '', $enc);
$enc = str_replace('\\', '', $enc);
- if (preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)) {
+ if (eregi('^(ISO-8859-1|US-ASCII|UTF-8)$', $enc)) {
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -3951,17 +3890,6 @@ function parse_request($data='') {
function invoke_method() {
$this->debug('in invoke_method, methodname=' . $this->methodname . ' methodURI=' . $this->methodURI . ' SOAPAction=' . $this->SOAPAction);
- //
- // if you are debugging in this area of the code, your service uses a class to implement methods,
- // you use SOAP RPC, and the client is .NET, please be aware of the following...
- // when the .NET wsdl.exe utility generates a proxy, it will remove the '.' or '..' from the
- // method name. that is fine for naming the .NET methods. it is not fine for properly constructing
- // the XML request and reading the XML response. you need to add the RequestElementName and
- // ResponseElementName to the System.Web.Services.Protocols.SoapRpcMethodAttribute that wsdl.exe
- // generates for the method. these parameters are used to specify the correct XML element names
- // for .NET to use, i.e. the names with the '.' in them.
- //
- $orig_methodname = $this->methodname;
if ($this->wsdl) {
if ($this->opData = $this->wsdl->getOperationData($this->methodname)) {
$this->debug('in invoke_method, found WSDL operation=' . $this->methodname);
@@ -3983,6 +3911,8 @@ function invoke_method() {
// if a . is present in $this->methodname, we see if there is a class in scope,
// which could be referred to. We will also distinguish between two deliminators,
// to allow methods to be called a the class or an instance
+ $class = '';
+ $method = '';
if (strpos($this->methodname, '..') > 0) {
$delim = '..';
} else if (strpos($this->methodname, '.') > 0) {
@@ -3990,23 +3920,13 @@ function invoke_method() {
} else {
$delim = '';
}
- $this->debug("in invoke_method, delim=$delim");
- $class = '';
- $method = '';
- if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1) {
- $try_class = substr($this->methodname, 0, strpos($this->methodname, $delim));
- if (class_exists($try_class)) {
- // get the class and method name
- $class = $try_class;
- $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
- $this->debug("in invoke_method, class=$class method=$method delim=$delim");
- } else {
- $this->debug("in invoke_method, class=$try_class not found");
- }
- } else {
- $try_class = '';
- $this->debug("in invoke_method, no class to try");
+ if (strlen($delim) > 0 && substr_count($this->methodname, $delim) == 1 &&
+ class_exists(substr($this->methodname, 0, strpos($this->methodname, $delim)))) {
+ // get the class and method name
+ $class = substr($this->methodname, 0, strpos($this->methodname, $delim));
+ $method = substr($this->methodname, strpos($this->methodname, $delim) + strlen($delim));
+ $this->debug("in invoke_method, class=$class method=$method delim=$delim");
}
// does method exist?
@@ -4014,7 +3934,7 @@ function invoke_method() {
if (!function_exists($this->methodname)) {
$this->debug("in invoke_method, function '$this->methodname' not found!");
$this->result = 'fault: method not found';
- $this->fault('SOAP-ENV:Client',"method '$this->methodname'('$orig_methodname') not defined in service('$try_class' '$delim')");
+ $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
return;
}
} else {
@@ -4022,7 +3942,7 @@ function invoke_method() {
if (!in_array($method_to_compare, get_class_methods($class))) {
$this->debug("in invoke_method, method '$this->methodname' not found in class '$class'!");
$this->result = 'fault: method not found';
- $this->fault('SOAP-ENV:Client',"method '$this->methodname'/'$method_to_compare'('$orig_methodname') not defined in service/'$class'('$try_class' '$delim')");
+ $this->fault('SOAP-ENV:Client',"method '$this->methodname' not defined in service");
return;
}
}
@@ -4108,7 +4028,7 @@ function invoke_method() {
function serialize_return() {
$this->debug('Entering serialize_return methodname: ' . $this->methodname . ' methodURI: ' . $this->methodURI);
// if fault
- if (isset($this->methodreturn) && is_object($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
+ if (isset($this->methodreturn) && ((get_class($this->methodreturn) == 'soap_fault') || (get_class($this->methodreturn) == 'nusoap_fault'))) {
$this->debug('got a fault object from method');
$this->fault = $this->methodreturn;
return;
@@ -4157,17 +4077,9 @@ function serialize_return() {
$this->debug('style is rpc for serialization: use is ' . $this->opData['output']['use']);
if ($this->opData['output']['use'] == 'literal') {
// 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
- if ($this->methodURI) {
- $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>";
- } else {
- $payload = '<'.$this->methodname.'Response>'.$return_val.''.$this->methodname.'Response>';
- }
+ $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>";
} else {
- if ($this->methodURI) {
- $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>";
- } else {
- $payload = '<'.$this->methodname.'Response>'.$return_val.''.$this->methodname.'Response>';
- }
+ $payload = 'methodname.'Response xmlns:ns1="'.$this->methodURI.'">'.$return_val.'methodname."Response>";
}
} else {
$this->debug('style is not rpc for serialization: assume document');
@@ -4182,8 +4094,8 @@ function serialize_return() {
//if($this->debug_flag){
$this->appendDebug($this->wsdl->getDebug());
// }
- if (isset($this->opData['output']['encodingStyle'])) {
- $encodingStyle = $this->opData['output']['encodingStyle'];
+ if (isset($opData['output']['encodingStyle'])) {
+ $encodingStyle = $opData['output']['encodingStyle'];
} else {
$encodingStyle = '';
}
@@ -4224,7 +4136,7 @@ function send_response() {
$payload .= $this->getDebugAsXMLComment();
}
$this->outgoing_headers[] = "Server: $this->title Server v$this->version";
- preg_match('/\$Revisio' . 'n: ([^ ]+)/', $this->revision, $rev);
+ ereg('\$Revisio' . 'n: ([^ ]+)', $this->revision, $rev);
$this->outgoing_headers[] = "X-SOAP-Server: $this->title/$this->version (".$rev[1].")";
// Let the Web server decide about this
//$this->outgoing_headers[] = "Connection: Close\r\n";
@@ -4304,12 +4216,7 @@ function verify_method($operation,$request){
* @access private
*/
function parseRequest($headers, $data) {
- $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' headers:');
- $this->appendDebug($this->varDump($headers));
- if (!isset($headers['content-type'])) {
- $this->setError('Request not of type text/xml (no content-type header)');
- return false;
- }
+ $this->debug('Entering parseRequest() for data of length ' . strlen($data) . ' and type ' . $headers['content-type']);
if (!strstr($headers['content-type'], 'text/xml')) {
$this->setError('Request not of type text/xml');
return false;
@@ -4317,7 +4224,7 @@ function parseRequest($headers, $data) {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
- if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
+ if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -4457,7 +4364,7 @@ function register($name,$in=array(),$out=array(),$namespace=false,$soapaction=fa
if(false == $use) {
$use = "encoded";
}
- if ($use == 'encoded' && $encodingStyle == '') {
+ if ($use == 'encoded' && $encodingStyle = '') {
$encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/';
}
@@ -4591,7 +4498,7 @@ class soap_server extends nusoap_server {
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class wsdl extends nusoap_base {
@@ -4805,7 +4712,7 @@ function parseWSDL($wsdl = '') {
$this->appendDebug($tr->getDebug());
// catch errors
if($err = $tr->getError() ){
- $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err;
+ $errstr = 'HTTP ERROR: '.$err;
$this->debug($errstr);
$this->setError($errstr);
unset($tr);
@@ -4884,7 +4791,7 @@ function start_element($parser, $name, $attrs)
$this->currentSchema->schemaStartElement($parser, $name, $attrs);
$this->appendDebug($this->currentSchema->getDebug());
$this->currentSchema->clearDebug();
- } elseif (preg_match('/schema$/', $name)) {
+ } elseif (ereg('schema$', $name)) {
$this->debug('Parsing WSDL schema');
// $this->debug("startElement for $name ($attrs[name]). status = $this->status (".$this->getLocalPart($name).")");
$this->status = 'schema';
@@ -4903,7 +4810,7 @@ function start_element($parser, $name, $attrs)
if (count($attrs) > 0) {
// register namespace declarations
foreach($attrs as $k => $v) {
- if (preg_match('/^xmlns/',$k)) {
+ if (ereg("^xmlns", $k)) {
if ($ns_prefix = substr(strrchr($k, ':'), 1)) {
$this->namespaces[$ns_prefix] = $v;
} else {
@@ -4928,7 +4835,7 @@ function start_element($parser, $name, $attrs)
$attrs = array();
}
// get element prefix, namespace and name
- if (preg_match('/:/', $name)) {
+ if (ereg(':', $name)) {
// get ns prefix
$prefix = substr($name, 0, strpos($name, ':'));
// get ns
@@ -5093,7 +5000,7 @@ function start_element($parser, $name, $attrs)
*/
function end_element($parser, $name){
// unset schema status
- if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) {
+ if (/*ereg('types$', $name) ||*/ ereg('schema$', $name)) {
$this->status = "";
$this->appendDebug($this->currentSchema->getDebug());
$this->currentSchema->clearDebug();
@@ -5131,7 +5038,7 @@ function character_data($parser, $data)
$this->documentation .= $data;
}
}
-
+
/**
* if authenticating, set user credentials here
*
@@ -5160,40 +5067,30 @@ function getBindingData($binding)
/**
* returns an assoc array of operation names => operation data
*
- * @param string $portName WSDL port name
* @param string $bindingType eg: soap, smtp, dime (only soap and soap12 are currently supported)
* @return array
* @access public
*/
- function getOperations($portName = '', $bindingType = 'soap') {
+ function getOperations($bindingType = 'soap') {
$ops = array();
if ($bindingType == 'soap') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap/';
} elseif ($bindingType == 'soap12') {
$bindingType = 'http://schemas.xmlsoap.org/wsdl/soap12/';
- } else {
- $this->debug("getOperations bindingType $bindingType may not be supported");
}
- $this->debug("getOperations for port '$portName' bindingType $bindingType");
// loop thru ports
foreach($this->ports as $port => $portData) {
- $this->debug("getOperations checking port $port bindingType " . $portData['bindingType']);
- if ($portName == '' || $port == $portName) {
- // binding type of port matches parameter
- if ($portData['bindingType'] == $bindingType) {
- $this->debug("getOperations found port $port bindingType $bindingType");
- //$this->debug("port data: " . $this->varDump($portData));
- //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
- // merge bindings
- if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
- $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
- }
+ // binding type of port matches parameter
+ if ($portData['bindingType'] == $bindingType) {
+ //$this->debug("getOperations for port $port");
+ //$this->debug("port data: " . $this->varDump($portData));
+ //$this->debug("bindings: " . $this->varDump($this->bindings[ $portData['binding'] ]));
+ // merge bindings
+ if (isset($this->bindings[ $portData['binding'] ]['operations'])) {
+ $ops = array_merge ($ops, $this->bindings[ $portData['binding'] ]['operations']);
}
}
- }
- if (count($ops) == 0) {
- $this->debug("getOperations found no operations for port '$portName' bindingType $bindingType");
- }
+ }
return $ops;
}
@@ -5295,10 +5192,9 @@ function getTypeDef($type, $ns) {
for ($i = 0; $i < count($this->schemas[$ns]); $i++) {
$xs = &$this->schemas[$ns][$i];
$t = $xs->getTypeDef($type);
- $this->appendDebug($xs->getDebug());
- $xs->clearDebug();
+ //$this->appendDebug($xs->getDebug());
+ //$xs->clearDebug();
if ($t) {
- $this->debug("in getTypeDef: found type $type");
if (!isset($t['phpType'])) {
// get info for type to tack onto the element
$uqType = substr($t['type'], strrpos($t['type'], ':') + 1);
@@ -5316,14 +5212,11 @@ function getTypeDef($type, $ns) {
if (isset($etype['attrs'])) {
$t['attrs'] = $etype['attrs'];
}
- } else {
- $this->debug("did not find type for [element] $type");
}
}
return $t;
}
}
- $this->debug("in getTypeDef: did not find type $type");
} else {
$this->debug("in getTypeDef: do not have schema for namespace $ns");
}
@@ -5362,9 +5255,8 @@ function webDescription(){
background-color: #ccccff; width: 20%; margin-left: 20px; margin-top: 20px; }
.title {
font-family: arial; font-size: 26px; color: #ffffff;
- background-color: #999999; width: 100%;
- margin-left: 0px; margin-right: 0px;
- padding-top: 10px; padding-bottom: 10px;}
+ background-color: #999999; width: 105%; margin-left: 0px;
+ padding-top: 10px; padding-bottom: 10px; padding-left: 15px;}
.hidden {
position: absolute; visibility: hidden; z-index: 200; left: 250px; top: 100px;
font-family: arial; overflow: hidden; width: 600;
@@ -5653,8 +5545,18 @@ function parametersMatchWrapped($type, &$parameters) {
if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
$elements = 0;
$matches = 0;
+ $change = false;
+ if ($this->isArraySimpleOrStruct($parameters) == 'arraySimple' && count($parameters) == count($typeDef['elements'])) {
+ $this->debug("in parametersMatchWrapped: (wrapped return value kludge) correct number of elements in simple array, so change array and wrap");
+ $change = true;
+ }
foreach ($typeDef['elements'] as $name => $attrs) {
- if (isset($parameters[$name])) {
+ if ($change) {
+ $this->debug("in parametersMatchWrapped: change parameter $element to name $name");
+ $parameters[$name] = $parameters[$elements];
+ unset($parameters[$elements]);
+ $matches++;
+ } elseif (isset($parameters[$name])) {
$this->debug("in parametersMatchWrapped: have parameter named $name");
$matches++;
} else {
@@ -5730,14 +5632,7 @@ function serializeRPCParameters($operation, $direction, $parameters, $bindingTyp
// check for Microsoft-style wrapped parameters
if ($style == 'document' && $use == 'literal' && $part_count == 1 && isset($parts['parameters'])) {
$this->debug('check whether the caller has wrapped the parameters');
- if ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1) {
- // TODO: consider checking here for double-wrapping, when
- // service function wraps, then NuSOAP wraps again
- $this->debug("change simple array to associative with 'parameters' element");
- $parameters['parameters'] = $parameters[0];
- unset($parameters[0]);
- }
- if (($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) {
+ if ((($parametersArrayType == 'arrayStruct' || $parameter_count == 0) && !isset($parameters['parameters'])) || ($direction == 'output' && $parametersArrayType == 'arraySimple' && $parameter_count == 1)) {
$this->debug('check whether caller\'s parameters match the wrapped ones');
if ($this->parametersMatchWrapped($parts['parameters'], $parameters)) {
$this->debug('wrap the parameters for the caller');
@@ -6022,11 +5917,6 @@ function serializeType($name, $type, $value, $use='encoded', $encodingStyle=fals
$uqType = substr($uqType, 0, -1);
}
}
- if (!isset($typeDef['phpType'])) {
- $this->setError("$type ($uqType) has no phpType.");
- $this->debug("in serializeType: $type ($uqType) has no phpType.");
- return false;
- }
$phpType = $typeDef['phpType'];
$this->debug("in serializeType: uqType: $uqType, ns: $ns, phptype: $phpType, arrayType: " . (isset($typeDef['arrayType']) ? $typeDef['arrayType'] : '') );
// if php type == struct, map value to the element names
@@ -6048,7 +5938,7 @@ function serializeType($name, $type, $value, $use='encoded', $encodingStyle=fals
}
if (is_null($value)) {
if ($use == 'literal') {
- // TODO: depends on minOccurs and nillable
+ // TODO: depends on minOccurs
$xml = "<$elementName$elementNS/>";
} else {
$xml = "<$elementName$elementNS xsi:nil=\"true\" xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"/>";
@@ -6070,18 +5960,8 @@ function serializeType($name, $type, $value, $use='encoded', $encodingStyle=fals
} else {
$xml = "<$elementName$elementNS$elementAttrs xsi:type=\"" . $this->getPrefixFromNamespace($ns) . ":$uqType\"$encodingStyle>";
}
-
- if (isset($typeDef['simpleContent']) && $typeDef['simpleContent'] == 'true') {
- if (isset($value['!'])) {
- $xml .= $value['!'];
- $this->debug("in serializeType: serialized simpleContent for type $type");
- } else {
- $this->debug("in serializeType: no simpleContent to serialize for type $type");
- }
- } else {
- // complexContent
- $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
- }
+
+ $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
$xml .= "$elementName>";
} else {
$this->debug("in serializeType: phpType is struct, but value is not an array");
@@ -6191,21 +6071,7 @@ function serializeType($name, $type, $value, $use='encoded', $encodingStyle=fals
* @access private
*/
function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
- $this->debug("serializeComplexTypeAttributes for XML Schema type $ns:$uqType");
$xml = '';
- if (isset($typeDef['extensionBase'])) {
- $nsx = $this->getPrefix($typeDef['extensionBase']);
- $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
- if ($this->getNamespaceFromPrefix($nsx)) {
- $nsx = $this->getNamespaceFromPrefix($nsx);
- }
- if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
- $this->debug("serialize attributes for extension base $nsx:$uqTypex");
- $xml .= $this->serializeComplexTypeAttributes($typeDefx, $value, $nsx, $uqTypex);
- } else {
- $this->debug("extension base $nsx:$uqTypex is not a supported type");
- }
- }
if (isset($typeDef['attrs']) && is_array($typeDef['attrs'])) {
$this->debug("serialize attributes for XML Schema type $ns:$uqType");
if (is_array($value)) {
@@ -6238,6 +6104,19 @@ function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
} else {
$this->debug("no attributes to serialize for XML Schema type $ns:$uqType");
}
+ if (isset($typeDef['extensionBase'])) {
+ $ns = $this->getPrefix($typeDef['extensionBase']);
+ $uqType = $this->getLocalPart($typeDef['extensionBase']);
+ if ($this->getNamespaceFromPrefix($ns)) {
+ $ns = $this->getNamespaceFromPrefix($ns);
+ }
+ if ($typeDef = $this->getTypeDef($uqType, $ns)) {
+ $this->debug("serialize attributes for extension base $ns:$uqType");
+ $xml .= $this->serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType);
+ } else {
+ $this->debug("extension base $ns:$uqType is not a supported type");
+ }
+ }
return $xml;
}
@@ -6254,21 +6133,7 @@ function serializeComplexTypeAttributes($typeDef, $value, $ns, $uqType) {
* @access private
*/
function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='encoded', $encodingStyle=false) {
- $this->debug("in serializeComplexTypeElements for XML Schema type $ns:$uqType");
$xml = '';
- if (isset($typeDef['extensionBase'])) {
- $nsx = $this->getPrefix($typeDef['extensionBase']);
- $uqTypex = $this->getLocalPart($typeDef['extensionBase']);
- if ($this->getNamespaceFromPrefix($nsx)) {
- $nsx = $this->getNamespaceFromPrefix($nsx);
- }
- if ($typeDefx = $this->getTypeDef($uqTypex, $nsx)) {
- $this->debug("serialize elements for extension base $nsx:$uqTypex");
- $xml .= $this->serializeComplexTypeElements($typeDefx, $value, $nsx, $uqTypex, $use, $encodingStyle);
- } else {
- $this->debug("extension base $nsx:$uqTypex is not a supported type");
- }
- }
if (isset($typeDef['elements']) && is_array($typeDef['elements'])) {
$this->debug("in serializeComplexTypeElements, serialize elements for XML Schema type $ns:$uqType");
if (is_array($value)) {
@@ -6325,12 +6190,7 @@ function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='enco
}
}
} else {
- if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') {
- // do nothing
- } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') {
- // TODO: serialize a nil correctly, but for now serialize schema-defined type
- $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
- } elseif (isset($attrs['type']) || isset($attrs['ref'])) {
+ if (isset($attrs['type']) || isset($attrs['ref'])) {
// serialize schema-defined type
$xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified);
} else {
@@ -6344,6 +6204,19 @@ function serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use='enco
} else {
$this->debug("no elements to serialize for XML Schema type $ns:$uqType");
}
+ if (isset($typeDef['extensionBase'])) {
+ $ns = $this->getPrefix($typeDef['extensionBase']);
+ $uqType = $this->getLocalPart($typeDef['extensionBase']);
+ if ($this->getNamespaceFromPrefix($ns)) {
+ $ns = $this->getNamespaceFromPrefix($ns);
+ }
+ if ($typeDef = $this->getTypeDef($uqType, $ns)) {
+ $this->debug("serialize elements for extension base $ns:$uqType");
+ $xml .= $this->serializeComplexTypeElements($typeDef, $value, $ns, $uqType, $use, $encodingStyle);
+ } else {
+ $this->debug("extension base $ns:$uqType is not a supported type");
+ }
+ }
return $xml;
}
@@ -6449,7 +6322,7 @@ function addOperation($name, $in = false, $out = false, $namespace = false, $soa
if ($style == 'document') {
$elements = array();
foreach ($in as $n => $t) {
- $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
+ $elements[$n] = array('name' => $n, 'type' => $t);
}
$this->addComplexType($name . 'RequestType', 'complexType', 'struct', 'all', '', $elements);
$this->addElement(array('name' => $name, 'type' => $name . 'RequestType'));
@@ -6457,7 +6330,7 @@ function addOperation($name, $in = false, $out = false, $namespace = false, $soa
$elements = array();
foreach ($out as $n => $t) {
- $elements[$n] = array('name' => $n, 'type' => $t, 'form' => 'unqualified');
+ $elements[$n] = array('name' => $n, 'type' => $t);
}
$this->addComplexType($name . 'ResponseType', 'complexType', 'struct', 'all', '', $elements);
$this->addElement(array('name' => $name . 'Response', 'type' => $name . 'ResponseType', 'form' => 'qualified'));
@@ -6526,7 +6399,7 @@ function addOperation($name, $in = false, $out = false, $namespace = false, $soa
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class nusoap_parser extends nusoap_base {
@@ -6629,8 +6502,6 @@ function nusoap_parser($xml,$encoding='UTF-8',$method='',$decode_utf8=true){
$this->debug("XML payload:\n" . $xml);
$this->setError($err);
} else {
- $this->debug('in nusoap_parser ctor, message:');
- $this->appendDebug($this->varDump($this->message));
$this->debug('parsed successfully, found root struct: '.$this->root_struct.' of name '.$this->root_struct_name);
// get final value
$this->soapresponse = $this->message[$this->root_struct]['result'];
@@ -6696,16 +6567,16 @@ function start_element($parser, $name, $attrs) {
$name = substr(strstr($name,':'),1);
}
// set status
- if ($name == 'Envelope' && $this->status == '') {
+ if($name == 'Envelope'){
$this->status = 'envelope';
- } elseif ($name == 'Header' && $this->status == 'envelope') {
+ } elseif($name == 'Header' && $this->status = 'envelope'){
$this->root_header = $pos;
$this->status = 'header';
- } elseif ($name == 'Body' && $this->status == 'envelope'){
+ } elseif($name == 'Body' && $this->status = 'envelope'){
$this->status = 'body';
$this->body_position = $pos;
// set method
- } elseif($this->status == 'body' && $pos == ($this->body_position+1)) {
+ } elseif($this->status == 'body' && $pos == ($this->body_position+1)){
$this->status = 'method';
$this->root_struct_name = $name;
$this->root_struct = $pos;
@@ -6726,7 +6597,7 @@ function start_element($parser, $name, $attrs) {
$key_localpart = $this->getLocalPart($key);
// if ns declarations, add to class level array of valid namespaces
if($key_prefix == 'xmlns'){
- if(preg_match('/^http:\/\/www.w3.org\/[0-9]{4}\/XMLSchema$/',$value)){
+ if(ereg('^http://www.w3.org/[0-9]{4}/XMLSchema$',$value)){
$this->XMLSchemaVersion = $value;
$this->namespaces['xsd'] = $this->XMLSchemaVersion;
$this->namespaces['xsi'] = $this->XMLSchemaVersion.'-instance';
@@ -6762,8 +6633,8 @@ function start_element($parser, $name, $attrs) {
[5] length ::= nextDimension* Digit+
[6] nextDimension ::= Digit+ ','
*/
- $expr = '/([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]/';
- if(preg_match($expr,$value,$regs)){
+ $expr = '([A-Za-z0-9_]+):([A-Za-z]+[A-Za-z0-9_]+)\[([0-9]+),?([0-9]*)\]';
+ if(ereg($expr,$value,$regs)){
$this->message[$pos]['typePrefix'] = $regs[1];
$this->message[$pos]['arrayTypePrefix'] = $regs[1];
if (isset($this->namespaces[$regs[1]])) {
@@ -6906,17 +6777,15 @@ function end_element($parser, $name) {
$this->document .= "" . (isset($prefix) ? $prefix . ':' : '') . "$name>";
}
// switch status
- if ($pos == $this->root_struct){
+ if($pos == $this->root_struct){
$this->status = 'body';
$this->root_struct_namespace = $this->message[$pos]['namespace'];
- } elseif ($pos == $this->root_header) {
- $this->status = 'envelope';
- } elseif ($name == 'Body' && $this->status == 'body') {
+ } elseif($name == 'Body'){
$this->status = 'envelope';
- } elseif ($name == 'Header' && $this->status == 'header') { // will never happen
+ } elseif($name == 'Header'){
$this->status = 'envelope';
- } elseif ($name == 'Envelope' && $this->status == 'envelope') {
- $this->status = '';
+ } elseif($name == 'Envelope'){
+ //
}
// set parent back to my parent
$this->parent = $this->message[$pos]['parent'];
@@ -7177,7 +7046,7 @@ class soap_parser extends nusoap_parser {
*
* @author Dietrich Ayala
* @author Scott Nichol
-* @version $Id: nusoap.php,v 1.123 2010/04/26 20:15:08 snichol Exp $
+* @version $Id: nusoap.php,v 1.114 2007/11/06 15:17:46 snichol Exp $
* @access public
*/
class nusoap_client extends nusoap_base {
@@ -7196,7 +7065,6 @@ class nusoap_client extends nusoap_base {
var $proxyport = '';
var $proxyusername = '';
var $proxypassword = '';
- var $portName = ''; // port name to use in WSDL
var $xml_encoding = ''; // character set encoding of incoming (response) messages
var $http_encoding = false;
var $timeout = 0; // HTTP connection timeout
@@ -7242,17 +7110,17 @@ class nusoap_client extends nusoap_base {
* constructor
*
* @param mixed $endpoint SOAP server or WSDL URL (string), or wsdl instance (object)
- * @param mixed $wsdl optional, set to 'wsdl' or true if using WSDL
- * @param string $proxyhost optional
- * @param string $proxyport optional
- * @param string $proxyusername optional
- * @param string $proxypassword optional
+ * @param bool $wsdl optional, set to true if using WSDL
+ * @param int $portName optional portName in WSDL document
+ * @param string $proxyhost
+ * @param string $proxyport
+ * @param string $proxyusername
+ * @param string $proxypassword
* @param integer $timeout set the connection timeout
* @param integer $response_timeout set the response timeout
- * @param string $portName optional portName in WSDL document
* @access public
*/
- function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30, $portName = ''){
+ function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = false,$proxyusername = false, $proxypassword = false, $timeout = 0, $response_timeout = 30){
parent::nusoap_base();
$this->endpoint = $endpoint;
$this->proxyhost = $proxyhost;
@@ -7261,7 +7129,6 @@ function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = f
$this->proxypassword = $proxypassword;
$this->timeout = $timeout;
$this->response_timeout = $response_timeout;
- $this->portName = $portName;
$this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout");
$this->appendDebug('endpoint=' . $this->varDump($endpoint));
@@ -7308,7 +7175,7 @@ function nusoap_client($endpoint,$wsdl = false,$proxyhost = false,$proxyport = f
* @param boolean $rpcParams optional (no longer used)
* @param string $style optional (rpc|document) the style to use when serializing parameters (WSDL can override)
* @param string $use optional (encoded|literal) the use when serializing parameters (WSDL can override)
- * @return mixed response from SOAP call, normally an associative array mirroring the structure of the XML response, false for certain fatal errors
+ * @return mixed response from SOAP call
* @access public
*/
function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAction='',$headers=false,$rpcParams=null,$style='rpc',$use='encoded'){
@@ -7385,8 +7252,8 @@ function call($operation,$params=array(),$namespace='http://tempuri.org',$soapAc
// operation not in WSDL
$this->appendDebug($this->wsdl->getDebug());
$this->wsdl->clearDebug();
- $this->setError('operation '.$operation.' not present in WSDL.');
- $this->debug("operation '$operation' not present in WSDL.");
+ $this->setError( 'operation '.$operation.' not present.');
+ $this->debug("operation '$operation' not present.");
return false;
} else {
// no WSDL
@@ -7499,24 +7366,16 @@ function checkWSDL() {
$this->debug('checkWSDL');
// catch errors
if ($errstr = $this->wsdl->getError()) {
- $this->appendDebug($this->wsdl->getDebug());
- $this->wsdl->clearDebug();
$this->debug('got wsdl error: '.$errstr);
$this->setError('wsdl error: '.$errstr);
- } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap')) {
- $this->appendDebug($this->wsdl->getDebug());
- $this->wsdl->clearDebug();
+ } elseif ($this->operations = $this->wsdl->getOperations('soap')) {
$this->bindingType = 'soap';
$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
- } elseif ($this->operations = $this->wsdl->getOperations($this->portName, 'soap12')) {
- $this->appendDebug($this->wsdl->getDebug());
- $this->wsdl->clearDebug();
+ } elseif ($this->operations = $this->wsdl->getOperations('soap12')) {
$this->bindingType = 'soap12';
$this->debug('got '.count($this->operations).' operations from wsdl '.$this->wsdlFile.' for binding type '.$this->bindingType);
$this->debug('**************** WARNING: SOAP 1.2 BINDING *****************');
} else {
- $this->appendDebug($this->wsdl->getDebug());
- $this->wsdl->clearDebug();
$this->debug('getOperations returned false');
$this->setError('no operations defined in the WSDL document!');
}
@@ -7529,7 +7388,7 @@ function checkWSDL() {
*/
function loadWSDL() {
$this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
- $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
+ $this->wsdl =& new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
$this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
$this->wsdl->fetchWSDL($this->wsdlFile);
$this->checkWSDL();
@@ -7573,7 +7432,7 @@ function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
// detect transport
switch(true){
// http(s)
- case preg_match('/^http/',$this->endpoint):
+ case ereg('^http',$this->endpoint):
$this->debug('transporting via HTTP');
if($this->persistentConnection == true && is_object($this->persistentConnection)){
$http =& $this->persistentConnection;
@@ -7595,10 +7454,10 @@ function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
$http->setEncoding($this->http_encoding);
}
$this->debug('sending message, length='.strlen($msg));
- if(preg_match('/^http:/',$this->endpoint)){
+ if(ereg('^http:',$this->endpoint)){
//if(strpos($this->endpoint,'http:')){
$this->responseData = $http->send($msg,$timeout,$response_timeout,$this->cookies);
- } elseif(preg_match('/^https/',$this->endpoint)){
+ } elseif(ereg('^https',$this->endpoint)){
//} elseif(strpos($this->endpoint,'https:')){
//if(phpversion() == '4.3.0-dev'){
//$response = $http->send($msg,$timeout,$response_timeout);
@@ -7650,10 +7509,6 @@ function send($msg, $soapaction = '', $timeout=0, $response_timeout=30) {
function parseResponse($headers, $data) {
$this->debug('Entering parseResponse() for data of length ' . strlen($data) . ' headers:');
$this->appendDebug($this->varDump($headers));
- if (!isset($headers['content-type'])) {
- $this->setError('Response not of type text/xml (no content-type header)');
- return false;
- }
if (!strstr($headers['content-type'], 'text/xml')) {
$this->setError('Response not of type text/xml: ' . $headers['content-type']);
return false;
@@ -7661,7 +7516,7 @@ function parseResponse($headers, $data) {
if (strpos($headers['content-type'], '=')) {
$enc = str_replace('"', '', substr(strstr($headers["content-type"], '='), 1));
$this->debug('Got response encoding: ' . $enc);
- if(preg_match('/^(ISO-8859-1|US-ASCII|UTF-8)$/i',$enc)){
+ if(eregi('^(ISO-8859-1|US-ASCII|UTF-8)$',$enc)){
$this->xml_encoding = strtoupper($enc);
} else {
$this->xml_encoding = 'US-ASCII';
@@ -8145,4 +8000,4 @@ function UpdateCookies($cookies) {
class soapclient extends nusoap_client {
}
}
-
+?>