Commit 6d36a52be193182967583fbab0e4ae7b5015247a

Authored by Edmar Moretti
1 parent 6920cf73

--no commit message

pacotes/SOAP/easy_parser.inc 0 → 100644
... ... @@ -0,0 +1,191 @@
  1 +<?
  2 +
  3 +class easy_parser{
  4 +
  5 +var $old_element = "";
  6 +var $attribute = array();
  7 +var $dado = "";
  8 +var $array_element = array();
  9 +var $array_attribute_value = array();
  10 +var $array_attributes = array();
  11 +var $array_nodes = array();
  12 +var $current_element = "";
  13 +var $array_texto = array();
  14 +var $get_err = "";
  15 +var $texto = "";
  16 +
  17 +function getpart($texto,$string,$reset=TRUE,$position=0)
  18 +{
  19 + static $p0=0;
  20 + $p0 += $position;
  21 + if($reset){
  22 + $p0 = 0;
  23 + }
  24 + $get = "";
  25 + $string = trim($string);
  26 + if(strpos($texto,"<$string>",$p0) >=0)
  27 + {
  28 + $p1 = strpos($texto,"<$string>",$p0);
  29 + $p2 = strpos($texto,"</$string>",$p0);
  30 + $len = strlen("<$string>");
  31 + $get = substr($texto,($p1 + $len),($p2 - $p1 - $len));
  32 + $p0 = $p2+$len;
  33 + }
  34 + return $get;
  35 +}
  36 +
  37 +
  38 +function getrpart($texto,$string)
  39 +{
  40 +
  41 + $get = "";
  42 + $string = trim($string);
  43 +
  44 + if(strrpos($texto,"<$string>") >=0)
  45 + {
  46 +
  47 + $p1 = strrpos($texto,"<$string>");
  48 + $texto2 = substr($texto,0,$p1);
  49 + $p2 = strrpos($texto2,"</$string>");
  50 + $len = strlen("<$string>");
  51 + $get = substr($texto2,$p2);
  52 + }
  53 + return $get;
  54 +}
  55 +
  56 +function parser($document,$is_file=TRUE){
  57 + $result = TRUE;
  58 + $parser = xml_parser_create('ISO-8859-1');
  59 + xml_set_object($parser,$this);
  60 + xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING, 0);
  61 + xml_set_element_handler($parser,"start_element","end_element");
  62 + xml_set_character_data_handler($parser,"character_data");
  63 +
  64 + if($is_file){
  65 + if(file_exists($document)){
  66 +
  67 + $xml_file = fopen($document,"r");
  68 + $data = "";
  69 + $ind = 0;
  70 + while (!feof($xml_file)) {
  71 + $data = fgets($xml_file,256);
  72 + if(ereg("<!ENTITY.*SYSTEM",$data,$matchs) && strpos($data,"NDATA") < 1){
  73 + $arrai = split(" ",$data);
  74 + $arrai[3] = str_replace("\">","",$arrai[3]);
  75 + $arrai[3] = trim(str_replace("\"","",$arrai[3]));
  76 + if(file_exists($arrai[3])){
  77 + $fp = fopen($arrai[3],"r");
  78 + while(!feof($fp)){
  79 + $ext_val[$ind] .= fgets($fp,1024);
  80 + }
  81 + fclose($fp);
  82 + $ext_key[$ind] = trim($arrai[1]);
  83 + ++$ind;
  84 + }
  85 + }
  86 +
  87 + $this->texto .= $data;
  88 + }
  89 +
  90 + fclose($xml_file);
  91 + }else{
  92 + print "<b><h3>The file: <font color=\"blue\">$document</font> not found.</b><h3>";
  93 + }
  94 + }else{
  95 + $this->texto = $document;
  96 + }
  97 +
  98 + if(isset($ext_val)){
  99 + $ind = 0;
  100 + foreach($ext_val as $value){
  101 + $this->texto = str_replace("&".$ext_key[$ind].";","$value\\n",$this->texto);
  102 + ++$ind;
  103 + }
  104 + }
  105 + $this->array_texto = explode("\n",$this->texto);
  106 +
  107 + if (!xml_parse($parser, $this->texto,TRUE)) {
  108 + $err_line = $this->array_texto[(xml_get_current_line_number($parser)-1)];
  109 + $err_col = xml_get_current_column_number($parser);
  110 + $text1 = "<font color=\"blue\" size=\"3\" face=\"arial\">".htmlentities(substr($err_line,0,($err_col -1)))."</font><font color=\"red\" size=\"3\" face=\"arial\">";
  111 + $text2 = htmlentities(substr($err_line,($err_col),1))."</font><font color=\"blue\" size=\"3\" face=\"arial\">";
  112 + $text3 = htmlentities(substr($err_line,($err_col +1)))."<font>";
  113 + $this->get_err = "<font color=\"black\" size=\"3\" face=\"arial\">Fonte do documento: $document<br>"
  114 + ."<b>XML error: </b>".xml_error_string(xml_get_error_code($parser))." <b>at</b> line "
  115 + .xml_get_current_line_number($parser)." and colunm $err_col<br>"
  116 + ."<b> Texto: </b>$text1$text2$text3";
  117 + $result = FALSE;
  118 + }
  119 +
  120 + xml_parser_free($parser);
  121 + return $result;
  122 +}
  123 +
  124 +function start_element($parser,$element_name,$attributes){
  125 + $this->attribute = $attributes;
  126 + $this->dado = "";
  127 + $this->current_element = $element_name;
  128 +
  129 + if(!in_array($element_name,$this->array_nodes)){
  130 + $this->array_nodes[] = $element_name;
  131 + }
  132 +
  133 + while(list($key,$value) = each($attributes)){
  134 + $attr[] = $key;
  135 + }
  136 +$this->array_attributes[$this->current_element] = $attr;
  137 +
  138 +}
  139 +
  140 +function end_element($parser,$element_name){
  141 + if(trim($this->dado) != ""){
  142 + $this->array_element[$this->current_element][] = $this->dado;
  143 + }
  144 + reset($this->attribute);
  145 + $this->dado = "";
  146 + if(count($this->attribute)>0){
  147 + $this->array_attribute_value[$this->current_element][] = $this->attribute;
  148 + }
  149 +}
  150 +
  151 +
  152 +function character_data($parser,$data){
  153 + $this->dado .= $data;
  154 +}
  155 +
  156 +
  157 +function get_element_value($element,$ind = 0){
  158 + return $this->array_element[$element][$ind];
  159 +}
  160 +
  161 +
  162 +
  163 +function get_element_rows($element){
  164 + return count($this->array_element[$element]);
  165 +}
  166 +
  167 +
  168 +
  169 +function get_elements(){
  170 + return $this->array_nodes;
  171 +}
  172 +
  173 +
  174 +function get_element_attribute($element,$ind = 0,$attribute){
  175 + return $this->array_attribute_value[$element][$ind][$attribute];
  176 +}
  177 +
  178 +
  179 +
  180 +function get_attributes($element){
  181 + return $this->array_attributes[$element];
  182 +}
  183 +
  184 +function view_source(){
  185 + $retorno = htmlentities($this->texto);
  186 + return str_replace("&gt;","&gt;<br>",$retorno);
  187 +}
  188 +
  189 +}
  190 +
  191 +?>
... ...
pacotes/SOAP/nusoap.php
... ... @@ -7380,8 +7380,9 @@ class nusoap_client extends nusoap_base {
7380 7380 * @access public
7381 7381 */
7382 7382 function loadWSDL() {
  7383 + error_reporting(0);
7383 7384 $this->debug('instantiating wsdl class with doc: '.$this->wsdlFile);
7384   - $this->wsdl =& new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
  7385 + $this->wsdl = new wsdl('',$this->proxyhost,$this->proxyport,$this->proxyusername,$this->proxypassword,$this->timeout,$this->response_timeout,$this->curl_options,$this->use_curl);
7385 7386 $this->wsdl->setCredentials($this->username, $this->password, $this->authtype, $this->certRequest);
7386 7387 $this->wsdl->fetchWSDL($this->wsdlFile);
7387 7388 $this->checkWSDL();
... ...