selamun aleykum
kardeşler php den anlıyosanız eğer bi sorum olcak size.
bi arama scripti var elimde bunun nusoap.php dosyasındaki charset ile sitemin ana charseti uymuyor yani utf-8 ile çalışıyo script bunu nasıl değiştircez ?
eğer anlarım diyosanız dosyayı gönderiyim bi şekilde nereye ne eklemem gerekli söyler misiniz.
|| One small change made by Google Blogoscoped
|| search for "philipp"
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
If you have any questions or comments, please email:
// server class
require_once('class.soap_server.php');*/
/**
*
* nusoap_base
*
* @author Dietrich Ayala <dietrich@ganx4.com>
* @version v 0.6.3
* @access public
*/
class nusoap_base {
var $title = 'NuSOAP';
var $version = '0.6.3';
var $error_str = false;
var $debug_str = '';
// toggles automatic encoding of special characters
var $charencoding = true;
/**
* set schema version
*
* @var XMLSchemaVersion
* @access public
*/
var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema';
/**
* set default encoding
*
* @var soap_defencoding
* @access public
*/
var $soap_defencoding = 'UTF-8';
// var $soap_defencoding = 'ISO-8859-1';
/**
* load namespace uris into an array of uri => prefix
*
* @var namespaces
* @access public
*/
var $namespaces = array(
'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/',
'xsd' => 'http://www.w3.org/2001/XMLSchema',
'xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'SOAP-ENC' => 'http://schemas.xmlsoap.org/soap/encoding/',
'si' => 'http://soapinterop.org/xsd');
/**
* load types into typemap array
* is this legacy yet?
* no, this is used by the xmlschema class to verify type => namespace mappings.
* @var typemap
* @access public
*/
var $typemap = array(
'http://www.w3.org/2001/XMLSchema' => array(
'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double',
'duration'=>'','dateTime'=>'string','time'=>'string','date'=>'string','gYearMonth'=>'',
'gYear'=>'','gMonthDay'=>'','gDay'=>'','gMonth'=>'','hexBinary'=>'string','base64Binary'=>'string',
// derived datatypes
'normalizedString'=>'string','token'=>'string','language'=>'','NMTOKEN'=>'','NMTOKENS'=>'','Name'=>'','NCName'=>'','ID'=>'',
'IDREF'=>'','IDREFS'=>'','ENTITY'=>'','ENTITIES'=>'','integer'=>'integer','nonPositiveInteger'=>'integer',
'negativeInteger'=>'integer','long'=>'integer','int'=>'integer','short'=>'integer','byte'=>'integer','nonNegativeInteger'=>'integer',
'unsignedLong'=>'','unsignedInt'=>'','unsignedShort'=>'','unsignedByte'=>'','positiveInteger'=>''),
'http://www.w3.org/1999/XMLSchema' => array(
'i4'=>'','int'=>'integer','boolean'=>'boolean','string'=>'string','double'=>'double',
'float'=>'double','dateTime'=>'string',
'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'),
'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'),
'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'),
'http://xml.apache.org/xml-soap' => array('Map')
);
/**
* entities to convert
*
* @var xmlEntities
* @access public
*/
var $xmlEntities = array('quot' => '"','amp' => '&',
'lt' => '<','gt' => '>','apos' => "'");
/**
* adds debug data to the class level debug string
*
* @param string $string debug data
* @access private
*/
function debug($string){
$this->debug_str .= get_class($this).": $string\n";
}
/**
* returns error string if present
*
* @return boolean $string error string
* @access public
*/
function getError(){
if($this->error_str != ''){
return $this->error_str;
}
return false;
}
function formatDump($str){
$str = htmlspecialchars($str);
return nl2br($str);
}
/**
* returns the local part of a prefixed string
* returns the original string, if not prefixed
*
* @param string
* @return string
* @access public
*/
function getLocalPart($str){
if($sstr = strrchr($str,':')){
// get unqualified name
return substr( $sstr, 1 );
} else {
return $str;
}
}
/**
* returns the prefix part of a prefixed string
* returns false, if not prefixed
*
* @param string
* @return mixed
* @access public
*/
function getPrefix($str){
if($pos = strrpos($str,':')){
// get prefix
return substr($str,0,$pos);
}
return false;
}
/**
* convert ISO 8601 compliant date string to unix timestamp
*
* @param string $datestr ISO 8601 compliant date string
* @access public
*/
function iso8601_to_timestamp($datestr){
$eregStr =
'([0-9]{4})-'. // centuries & years CCYY-
'([0-9]{2})-'. // months MM-
'([0-9]{2})'. // days DD
'T'. // separator T
'([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(ereg($eregStr,$datestr,$regs)){
// not utc
if($regs[8] != 'Z'){
$op = substr($regs[8],0,1);
$h = substr($regs[8],1,2);
$m = substr($regs[8],strlen($regs[8])-2,2);
if($op == '-'){
$regs[4] = $regs[4] + $h;
$regs[5] = $regs[5] + $m;
} elseif($op == '+'){
$regs[4] = $regs[4] - $h;
$regs[5] = $regs[5] - $m;
}
}
return strtotime("$regs[1]-$regs[2]-$regs[3] $regs[4]:$regs[5]:$regs[6]Z");
} else {
return false;
}
}
?><?php
/**
* soap_fault class, allows for creation of faults
* mainly used for returning faults from deployed functions
* in a server instance.
* @author Dietrich Ayala <dietrich@ganx4.com>
* @version v 0.6.3
* @access public
*/
class soap_fault extends nusoap_base {
var $faultcode;
var $faultactor;
var $faultstring;
var $faultdetail;
/**
* constructor
*
* @param string $faultcode (client | server)
* @param string $faultactor only used when msg routed between multiple actors
* @param string $faultstring human readable error message
* @param string $faultdetail
*/
function soap_fault($faultcode,$faultactor='',$faultstring='',$faultdetail=''){
$this->faultcode = $faultcode;
$this->faultactor = $faultactor;
$this->faultstring = $faultstring;
$this->faultdetail = $faultdetail;
}
/**
* parses an XML Schema, allows access to it's data, other utility methods
* no validation... yet.
* very experimental and limited. As is discussed on XML-DEV, I'm one of the people
* that just doesn't have time to read the spec(s) thoroughly, and just have a couple of trusty
* tutorials I refer to :)
*
* @author Dietrich Ayala <dietrich@ganx4.com>
* @version v 0.6.3
* @access public
*/
class XMLSchema extends nusoap_base {
// files
var $schema = '';
var $xml = '';
// define internal arrays of bindings, ports, operations, messages, etc.
var $complexTypes = array();
// target namespace
var $schemaTargetNamespace = '';
// parser vars
var $parser;
var $position;
var $depth = 0;
var $depth_array = array();
/**
* constructor
*
* @param string $schema schema document URI
* @param string $xml xml document URI
* @access public
*/
function XMLSchema($schema='',$xml=''){
// parse xml file
if($xml != ''){
$this->debug('initial xml file: '.$xml);
$this->parseFile($xml);
}
}
/**
* parse an XML file
*
* @param string $xml, path/URL to XML file
* @param string $type, (schema | xml)
* @return boolean
* @access public
*/
function parseFile($xml,$type){
// parse xml file
if($xml != ""){
$this->debug('parsing $xml');
$xmlStr = @join("",@file($xml));
if($xmlStr == ""){
$this->setError('No file at the specified URL: '.$xml);
return false;
} else {
$this->parseString($xmlStr,$type);
return true;
}
}
return false;
}
/**
* parse an XML string
*
* @param string $xml path or URL
* @param string $type, (schema|xml)
* @access private
*/
function parseString($xml,$type){
// parse xml string
if($xml != ""){
// Create an XML parser.
$this->parser = xml_parser_create();
// Set the options for parsing the XML data.
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0);
// Set the object for the parser.
xml_set_object($this->parser, $this);
// Set the element handlers for the parser.
if($type == "schema"){
xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement');
xml_set_character_data_handler($this->parser,'schemaCharacterData');
} elseif($type == "xml"){
xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement');
xml_set_character_data_handler($this->parser,'xmlCharacterData');
}
// Parse the XML file.
if(!xml_parse($this->parser,$xml,true)){
// Display an error message.
$errstr = sprintf('XML error on line %d: %s',
xml_get_current_line_number($this->parser),
xml_error_string(xml_get_error_code($this->parser))
);
$this->debug('XML parse error: '.$errstr);
$this->setError('Parser error: '.$errstr);
}
xml_parser_free($this->parser);
} else{
$this->debug('no xml passed to parseString()!!');
$this->setError('no xml passed to parseString()!!');
}
}
/**
* start-element handler
*
* @param string $parser XML parser object
* @param string $name element name
* @param string $attrs associative array of attributes
* @access private
*/
function schemaStartElement($parser, $name, $attrs) {
// position in the total number of elements, starting from 0
$pos = $this->position++;
$depth = $this->depth++;
// set self as current value for this depth
$this->depth_array[$depth] = $pos;
// get element prefix
if($prefix = $this->getPrefix($name)){
// get unqualified name
$name = $this->getLocalPart($name);
} else {
$prefix = '';
}
/**
* end-element handler
*
* @param string $parser XML parser object
* @param string $name element name
* @access private
*/
function schemaEndElement($parser, $name) {
// position of current element is equal to the last value left in depth_array for my depth
if(isset($this->depth_array[$this->depth])){
$pos = $this->depth_array[$this->depth];
}
// bring depth down a notch
$this->depth--;
// move on...
if($name == 'complexType'){
$this->currentComplexType = false;
$this->currentElement = false;
}
if($name == 'element'){
$this->currentElement = false;
}
}
/**
* element content handler
*
* @param string $parser XML parser object
* @param string $data element content
* @access private
*/
function schemaCharacterData($parser, $data){
$pos = $this->depth_array[$this->depth];
$this->message[$pos]['cdata'] .= $data;
}
/**
* serialize the schema
*
* @access public
*/
function serializeSchema(){
/**
* expands a qualified name
*
* @param string $string qname
* @return string expanded qname
* @access private
*/
function expandQname($qname){
// get element prefix
if(strpos($qname,':') && !ereg('^http://',$qname)){
// get unqualified name
$name = substr(strstr($qname,':'),1);
// get ns prefix
$prefix = substr($qname,0,strpos($qname,':'));
if(isset($this->namespaces[$prefix])){
return $this->namespaces[$prefix].':'.$name;
} else {
return $qname;
}
} else {
return $qname;
}
}
/**
* adds debug data to the clas level debug string
*
* @param string $string debug data
* @access private
*/
function xdebug($string){
$this->debug(' xmlschema: '.$string);
}
/**
* get the PHP type of a user defined type in the schema
* PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays
* returns false if no type exists, or not w/ the given namespace
* else returns a string that is either a native php type, or 'struct'
*
* @param string $type, name of defined type
* @param string $ns, namespace of type
* @return mixed
* @access public
*/
function getPHPType($type,$ns){
global $typemap;
if(isset($typemap[$ns][$type])){
//print "found type '$type' and ns $ns in typemap<br>";
return $typemap[$ns][$type];
} elseif(isset($this->complexTypes[$type])){
//print "getting type '$type' and ns $ns from complexTypes array<br>";
return $this->complexTypes[$type]['phpType'];
}
return false;
}
/**
* returns the local part of a prefixed string
* returns the original string, if not prefixed
*
* @param string
* @return string
* @access public
*/
function getLocalPart($str){
if($sstr = strrchr($str,':')){
// get unqualified name
return substr( $sstr, 1 );
} else {
return $str;
}
}
/**
* returns the prefix part of a prefixed string
* returns false, if not prefixed
*
* @param string
* @return mixed
* @access public
*/
function getPrefix($str){
if($pos = strrpos($str,':')){
// get prefix
return substr($str,0,$pos);
}
return false;
}
/**
* pass it a prefix, it returns a namespace
* returns false if no namespace registered with the given prefix
*
* @param string
* @return mixed
* @access public
*/
function getNamespaceFromPrefix($prefix){
if(isset($this->namespaces[$prefix])){
return $this->namespaces[$prefix];
}
//$this->setError("No namespace registered for prefix '$prefix'");
return false;
}
/**
* returns the prefix for a given namespace (or prefix)
* or false if no prefixes registered for the given namespace
*
* @param string
* @return mixed
* @access public
*/
function getPrefixFromNamespace($ns){
foreach($this->namespaces as $p => $n){
if($ns == $n || $ns == $p){
$this->usedNamespaces[$p] = $n;
return $p;
}
}
return false;
}
/**
* returns an array of information about a given type
* returns false if no type exists by the given name
*
* typeDef = array(
* 'elements' => array(), // refs to elements array
* 'restrictionBase' => '',
* 'phpType' => '',
* 'order' => '(sequence|all)',
* 'attrs' => array() // refs to attributes array
* )
*
* @param string
* @return mixed
* @access public
*/
function getTypeDef($type){
if(isset($this->complexTypes[$type])){
return $this->complexTypes[$type];
} elseif(isset($this->elements[$type])){
return $this->elements[$type];
} elseif(isset($this->attributes[$type])){
return $this->attributes[$type];
}
return false;
}
/**
* returns a sample serialization of a given type, or false if no type by the given name
*
* @param string $type, name of type
* @return mixed
* @access public
*/
function serializeTypeDef($type){
//print "in sTD() for type $type<br>";
if($typeDef = $this->getTypeDef($type)){
$str .= '<'.$type;
if(is_array($typeDef['attrs'])){
foreach($attrs as $attName => $data){
$str .= " $attName=\"{type = ".$data['type']."}\"";
}
}
$str .= " xmlns=\"".$this->schema['targetNamespace']."\"";
if(count($typeDef['elements']) > 0){
$str .= ">";
foreach($typeDef['elements'] as $element => $eData){
$str .= $this->serializeTypeDef($element);
}
$str .= "</$type>";
} elseif($typeDef['typeClass'] == 'element') {
$str .= "></$type>";
} else {
$str .= "/>";
}
return $str;
}
return false;
}
/**
* returns HTML form elements that allow a user
* to enter values for creating an instance of the given type.
*
* @param string $name, name for type instance
* @param string $type, name of type
* @return string
* @access public
*/
function typeToForm($name,$type){
// get typedef
if($typeDef = $this->getTypeDef($type)){
// if struct
if($typeDef['phpType'] == 'struct'){
$buffer .= '<table>';
foreach($typeDef['elements'] as $child => $childDef){
$buffer .= "
<tr><td align='right'>$childDef[name] (type: ".$this->getLocalPart($childDef['type'])."):</td>
<td><input type='text' name='parameters[".$name."][$childDef[name]]'></td></tr>";
}
$buffer .= '</table>';
// if array
} elseif($typeDef['phpType'] == 'array'){
$buffer .= '<table>';
for($i=0;$i < 3; $i++){
$buffer .= "
<tr><td align='right'>array item (type: $typeDef[arrayType]):</td>
<td><input type='text' name='parameters[".$name."][]'></td></tr>";
}
$buffer .= '</table>';
// if scalar
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
} else {
$buffer .= "<input type='text' name='parameters[$name]'>";
}
return $buffer;
}
/**
* for creating serializable abstractions of native PHP types
* NOTE: this is only really used when WSDL is not available.
*
* @author Dietrich Ayala <dietrich@ganx4.com>
* @version v 0.6.3
* @access public
*/
class soapval extends nusoap_base {
/**
* constructor
*
* @param string $name optional name
* @param string $type optional type name
* @param mixed $value optional value
* @param string $namespace optional namespace of value
* @param string $type_namespace optional namespace of type
* @param array $attributes associative array of attributes to add to element serialization
* @access public
*/
function soapval($name='soapval',$type=false,$value=-1,$element_ns=false,$type_ns=false,$attributes=false) {
$this->name = $name;
$this->value = $value;
$this->type = $type;
$this->element_ns = $element_ns;
$this->type_ns = $type_ns;
$this->attributes = $attributes;
}
/**
* return serialized value
*
* @return string XML data
* @access private
*/
function serialize($use='encoded') {
return $this->serialize_val($this->value,$this->name,$this->type,$this->element_ns,$this->type_ns,$this->attributes,$use);
}
/**
* decodes a soapval object into a PHP native type
*
* @param object $soapval optional SOAPx4 soapval object, else uses self
* @return mixed
* @access public
*/
function decode(){
return $this->value;
}
}
?><?php
/**
* transport class for sending/receiving data via HTTP and HTTPS
* NOTE: PHP must be compiled with the CURL extension for HTTPS support
*
* @author Dietrich Ayala <dietrich@ganx4.com>
* @version v 0.6.3
* @access public
*/
class soap_transport_http extends nusoap_base {
var $username = '';
var $password = '';
var $url = '';
var $proxyhost = '';
var $proxyport = '';
var $scheme = '';
var $request_method = 'POST';
var $protocol_version = '1.0';
var $encoding = '';
var $outgoing_headers = array();
var $incoming_headers = array();
var $outgoing_payload = '';
var $incoming_payload = '';
var $useSOAPAction = true;
// test pointer
if(!$fp) {
$this->debug('Couldn\'t open socket connection to server '.$this->url.', Error: '.$this->error_str);
$this->setError('Couldn\'t open socket connection to server: '.$this->url.', Error: '.$this->error_str);
return false;
}
return $fp;
}
/**
* send the SOAP message via HTTP
*
* @param string $data message data
* @param integer $timeout set timeout in seconds
* @return string data
* @access public
*/
function send($data, $timeout=0) {
$this->debug('entered send() with data of length: '.strlen($data));
// get connnection
if(!$fp = $this->connect($timeout)){
return false;
}
$this->debug('socket connected');
// send payload
if(!fputs($fp, $this->outgoing_payload, strlen($this->outgoing_payload))) {
$this->setError('couldn\'t write message data to socket');
$this->debug('Write error');
}
$this->debug('wrote data to socket');
// get response
$this->incoming_payload = '';
//$strlen = 0;
while( $data = fread($fp, 32768) ){
$this->incoming_payload .= $data;
//$strlen += strlen($data);
}
$this->debug('received '.strlen($this->incoming_payload).' bytes of data from server');
// close filepointer
fclose($fp);
$this->debug('closed socket');
// connection was closed unexpectedly
if($this->incoming_payload == ''){
$this->setError('no response from server');
return false;
}
// decode transfer-encoding
if(isset($headers['Transfer-Encoding']) && $headers['Transfer-Encoding'] == 'chunked'){
//$timer->setMarker('starting to decode chunked content');
if(!$data = $this->decodeChunked($data)){
$this->setError('Decoding of chunked data failed');
return false;
}
//$timer->setMarker('finished decoding of chunked content');
//print "<pre>\nde-chunked:\n---------------\n$data\n\n---------------\n</pre>";
}
// decode content-encoding
if(isset($headers['Content-Encoding']) && $headers['Content-Encoding'] != ''){
if($headers['Content-Encoding'] == 'deflate' || $headers['Content-Encoding'] == 'gzip'){
// if decoding works, use it. else assume data wasn't gzencoded
if(function_exists('gzinflate')){
//$timer->setMarker('starting decoding of gzip/deflated content');
if($headers['Content-Encoding'] == 'deflate' && $degzdata = @gzinflate($data)){
$data = $degzdata;
} elseif($headers['Content-Encoding'] == 'gzip' && $degzdata = gzinflate(substr($data, 10))){
$data = $degzdata;
} else {
$this->setError('Errors occurred when trying to decode the data');
}
//$timer->setMarker('finished decoding of gzip/deflated content');
//print "<xmp>\nde-inflated:\n---------------\n$data\n-------------\n</xmp>";
} else {
$this->setError('The server sent deflated data. Your php install must have the Zlib extension compiled in to support this.');
}
}
}
if(strlen($data) == 0){
$this->debug('no data after headers!');
$this->setError('no data present after HTTP headers');
return false;
}
$this->debug('end of send()');
return $data;
}
/**
* send the SOAP message via HTTPS 1.0 using CURL
*
* @param string $msg message data
* @param integer $timeout set timeout in seconds
* @return string data
* @access public
*/
function sendHTTPS($data, $timeout=0) {
//global $t;
//$t->setMarker('inside sendHTTPS()');
$this->debug('entered sendHTTPS() with data of length: '.strlen($data));
// init CURL
$ch = curl_init();
//$t->setMarker('got curl handle');
// set proxy
if($this->proxyhost && $this->proxyport){
$host = $this->proxyhost;
$port = $this->proxyport;
} else {
$host = $this->host;
$port = $this->port;
}
// set url
$hostURL = ($port != '') ? "https://$host:$port" : "https://$host";
// add path
$hostURL .= $this->path;
curl_setopt($ch, CURLOPT_URL, $hostURL);
// set other options
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// encode
if(function_exists('gzinflate')){
curl_setopt($ch, CURLOPT_ENCODING, 'deflate');
}
// persistent connection
//curl_setopt($ch, CURL_HTTP_VERSION_1_1, true);
// set timeout
if($timeout != 0){
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
}
Bu forumda yeni başlıklar açamazsınız Bu forumdaki başlıklara cevap veremezsiniz Bu forumdaki mesajlarınızı değiştiremezsiniz Bu forumdaki mesajlarınızı silemezsiniz Bu forumdaki anketlerde oy kullanamazsınız