@@ -14,35 +14,35 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class wsdl extends nusoap_base { |
| 16 | 16 | // URL or filename of the root of this WSDL |
| 17 | - var $wsdl; |
|
| 18 | - // define internal arrays of bindings, ports, operations, messages, etc. |
|
| 19 | - var $schemas = array(); |
|
| 20 | - var $currentSchema; |
|
| 21 | - var $message = array(); |
|
| 22 | - var $complexTypes = array(); |
|
| 23 | - var $messages = array(); |
|
| 24 | - var $currentMessage; |
|
| 25 | - var $currentOperation; |
|
| 26 | - var $portTypes = array(); |
|
| 27 | - var $currentPortType; |
|
| 28 | - var $bindings = array(); |
|
| 29 | - var $currentBinding; |
|
| 30 | - var $ports = array(); |
|
| 31 | - var $currentPort; |
|
| 32 | - var $opData = array(); |
|
| 33 | - var $status = ''; |
|
| 34 | - var $documentation = false; |
|
| 35 | - var $endpoint = ''; |
|
| 36 | - // array of wsdl docs to import |
|
| 37 | - var $import = array(); |
|
| 38 | - // parser vars |
|
| 39 | - var $parser; |
|
| 40 | - var $position = 0; |
|
| 41 | - var $depth = 0; |
|
| 42 | - var $depth_array = array(); |
|
| 17 | + var $wsdl; |
|
| 18 | + // define internal arrays of bindings, ports, operations, messages, etc. |
|
| 19 | + var $schemas = array(); |
|
| 20 | + var $currentSchema; |
|
| 21 | + var $message = array(); |
|
| 22 | + var $complexTypes = array(); |
|
| 23 | + var $messages = array(); |
|
| 24 | + var $currentMessage; |
|
| 25 | + var $currentOperation; |
|
| 26 | + var $portTypes = array(); |
|
| 27 | + var $currentPortType; |
|
| 28 | + var $bindings = array(); |
|
| 29 | + var $currentBinding; |
|
| 30 | + var $ports = array(); |
|
| 31 | + var $currentPort; |
|
| 32 | + var $opData = array(); |
|
| 33 | + var $status = ''; |
|
| 34 | + var $documentation = false; |
|
| 35 | + var $endpoint = ''; |
|
| 36 | + // array of wsdl docs to import |
|
| 37 | + var $import = array(); |
|
| 38 | + // parser vars |
|
| 39 | + var $parser; |
|
| 40 | + var $position = 0; |
|
| 41 | + var $depth = 0; |
|
| 42 | + var $depth_array = array(); |
|
| 43 | 43 | // for getting wsdl |
| 44 | 44 | var $proxyhost = ''; |
| 45 | - var $proxyport = ''; |
|
| 45 | + var $proxyport = ''; |
|
| 46 | 46 | var $proxyusername = ''; |
| 47 | 47 | var $proxypassword = ''; |
| 48 | 48 | var $timeout = 0; |
@@ -55,10 +55,10 @@ discard block |
||
| 55 | 55 | var $authtype = ''; // Type of HTTP authentication |
| 56 | 56 | var $certRequest = array(); // Certificate for HTTP SSL authentication |
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * constructor |
|
| 60 | - * |
|
| 61 | - * @param string $wsdl WSDL document URL |
|
| 58 | + /** |
|
| 59 | + * constructor |
|
| 60 | + * |
|
| 61 | + * @param string $wsdl WSDL document URL |
|
| 62 | 62 | * @param string $proxyhost |
| 63 | 63 | * @param string $proxyport |
| 64 | 64 | * @param string $proxyusername |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | * @param integer $response_timeout set the response timeout |
| 68 | 68 | * @param array $curl_options user-specified cURL options |
| 69 | 69 | * @param boolean $use_curl try to use cURL |
| 70 | - * @access public |
|
| 71 | - */ |
|
| 72 | - public function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ |
|
| 70 | + * @access public |
|
| 71 | + */ |
|
| 72 | + public function wsdl($wsdl = '',$proxyhost=false,$proxyport=false,$proxyusername=false,$proxypassword=false,$timeout=0,$response_timeout=30,$curl_options=null,$use_curl=false){ |
|
| 73 | 73 | parent::nusoap_base(); |
| 74 | 74 | $this->debug("ctor wsdl=$wsdl timeout=$timeout response_timeout=$response_timeout"); |
| 75 | - $this->proxyhost = $proxyhost; |
|
| 76 | - $this->proxyport = $proxyport; |
|
| 75 | + $this->proxyhost = $proxyhost; |
|
| 76 | + $this->proxyport = $proxyport; |
|
| 77 | 77 | $this->proxyusername = $proxyusername; |
| 78 | 78 | $this->proxypassword = $proxypassword; |
| 79 | 79 | $this->timeout = $timeout; |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | $this->curl_options = $curl_options; |
| 83 | 83 | $this->use_curl = $use_curl; |
| 84 | 84 | $this->fetchWSDL($wsdl); |
| 85 | - } |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * fetches the WSDL document and parses it |
@@ -92,28 +92,28 @@ discard block |
||
| 92 | 92 | public function fetchWSDL($wsdl) { |
| 93 | 93 | $this->debug("parse and process WSDL path=$wsdl"); |
| 94 | 94 | $this->wsdl = $wsdl; |
| 95 | - // parse wsdl file |
|
| 96 | - if ($this->wsdl != "") { |
|
| 97 | - $this->parseWSDL($this->wsdl); |
|
| 98 | - } |
|
| 99 | - $imported_urls = array(); |
|
| 100 | - $imported = 1; |
|
| 101 | - while ($imported > 0) { |
|
| 102 | - $imported = 0; |
|
| 103 | - // Schema imports |
|
| 104 | - foreach ($this->schemas as $ns => $list) { |
|
| 105 | - foreach ($list as $xs) { |
|
| 95 | + // parse wsdl file |
|
| 96 | + if ($this->wsdl != "") { |
|
| 97 | + $this->parseWSDL($this->wsdl); |
|
| 98 | + } |
|
| 99 | + $imported_urls = array(); |
|
| 100 | + $imported = 1; |
|
| 101 | + while ($imported > 0) { |
|
| 102 | + $imported = 0; |
|
| 103 | + // Schema imports |
|
| 104 | + foreach ($this->schemas as $ns => $list) { |
|
| 105 | + foreach ($list as $xs) { |
|
| 106 | 106 | $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
| 107 | - foreach ($xs->imports as $ns2 => $list2) { |
|
| 108 | - for ($ii = 0; $ii < count($list2); $ii++) { |
|
| 109 | - if (! $list2[$ii]['loaded']) { |
|
| 110 | - /* |
|
| 107 | + foreach ($xs->imports as $ns2 => $list2) { |
|
| 108 | + for ($ii = 0; $ii < count($list2); $ii++) { |
|
| 109 | + if (! $list2[$ii]['loaded']) { |
|
| 110 | + /* |
|
| 111 | 111 | * Substituted with line below |
| 112 | 112 | * because of error "Warning: attempt to modify property of non-object" |
| 113 | 113 | * GitHub issue #1 |
| 114 | 114 | */ |
| 115 | - $list2[$ii]['loaded'] = true; |
|
| 116 | - $url = $list2[$ii]['location']; |
|
| 115 | + $list2[$ii]['loaded'] = true; |
|
| 116 | + $url = $list2[$ii]['location']; |
|
| 117 | 117 | if ($url != '') { |
| 118 | 118 | $urlparts = parse_url($url); |
| 119 | 119 | if (!isset($urlparts['host'])) { |
@@ -121,25 +121,25 @@ discard block |
||
| 121 | 121 | substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
| 122 | 122 | } |
| 123 | 123 | if (! in_array($url, $imported_urls)) { |
| 124 | - $this->parseWSDL($url); |
|
| 125 | - $imported++; |
|
| 126 | - $imported_urls[] = $url; |
|
| 127 | - } |
|
| 124 | + $this->parseWSDL($url); |
|
| 125 | + $imported++; |
|
| 126 | + $imported_urls[] = $url; |
|
| 127 | + } |
|
| 128 | 128 | } else { |
| 129 | 129 | $this->debug("Unexpected scenario: empty URL for unloaded import"); |
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
| 133 | - } |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - // WSDL imports |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + // WSDL imports |
|
| 137 | 137 | $wsdlparts = parse_url($this->wsdl); // this is bogusly simple! |
| 138 | - foreach ($this->import as $ns => $list) { |
|
| 139 | - for ($ii = 0; $ii < count($list); $ii++) { |
|
| 140 | - if (! $list[$ii]['loaded']) { |
|
| 141 | - $this->import[$ns][$ii]['loaded'] = true; |
|
| 142 | - $url = $list[$ii]['location']; |
|
| 138 | + foreach ($this->import as $ns => $list) { |
|
| 139 | + for ($ii = 0; $ii < count($list); $ii++) { |
|
| 140 | + if (! $list[$ii]['loaded']) { |
|
| 141 | + $this->import[$ns][$ii]['loaded'] = true; |
|
| 142 | + $url = $list[$ii]['location']; |
|
| 143 | 143 | if ($url != '') { |
| 144 | 144 | $urlparts = parse_url($url); |
| 145 | 145 | if (!isset($urlparts['host'])) { |
@@ -147,70 +147,70 @@ discard block |
||
| 147 | 147 | substr($wsdlparts['path'],0,strrpos($wsdlparts['path'],'/') + 1) .$urlparts['path']; |
| 148 | 148 | } |
| 149 | 149 | if (! in_array($url, $imported_urls)) { |
| 150 | - $this->parseWSDL($url); |
|
| 151 | - $imported++; |
|
| 152 | - $imported_urls[] = $url; |
|
| 153 | - } |
|
| 150 | + $this->parseWSDL($url); |
|
| 151 | + $imported++; |
|
| 152 | + $imported_urls[] = $url; |
|
| 153 | + } |
|
| 154 | 154 | } else { |
| 155 | 155 | $this->debug("Unexpected scenario: empty URL for unloaded import"); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | 158 | } |
| 159 | - } |
|
| 159 | + } |
|
| 160 | 160 | } |
| 161 | - // add new data to operation data |
|
| 162 | - foreach($this->bindings as $binding => $bindingData) { |
|
| 163 | - if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { |
|
| 164 | - foreach($bindingData['operations'] as $operation => $data) { |
|
| 165 | - $this->debug('post-parse data gathering for ' . $operation); |
|
| 166 | - $this->bindings[$binding]['operations'][$operation]['input'] = |
|
| 161 | + // add new data to operation data |
|
| 162 | + foreach($this->bindings as $binding => $bindingData) { |
|
| 163 | + if (isset($bindingData['operations']) && is_array($bindingData['operations'])) { |
|
| 164 | + foreach($bindingData['operations'] as $operation => $data) { |
|
| 165 | + $this->debug('post-parse data gathering for ' . $operation); |
|
| 166 | + $this->bindings[$binding]['operations'][$operation]['input'] = |
|
| 167 | 167 | isset($this->bindings[$binding]['operations'][$operation]['input']) ? |
| 168 | 168 | array_merge($this->bindings[$binding]['operations'][$operation]['input'], $this->portTypes[ $bindingData['portType'] ][$operation]['input']) : |
| 169 | 169 | $this->portTypes[ $bindingData['portType'] ][$operation]['input']; |
| 170 | - $this->bindings[$binding]['operations'][$operation]['output'] = |
|
| 170 | + $this->bindings[$binding]['operations'][$operation]['output'] = |
|
| 171 | 171 | isset($this->bindings[$binding]['operations'][$operation]['output']) ? |
| 172 | 172 | array_merge($this->bindings[$binding]['operations'][$operation]['output'], $this->portTypes[ $bindingData['portType'] ][$operation]['output']) : |
| 173 | 173 | $this->portTypes[ $bindingData['portType'] ][$operation]['output']; |
| 174 | - if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){ |
|
| 174 | + if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ])){ |
|
| 175 | 175 | $this->bindings[$binding]['operations'][$operation]['input']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['input']['message'] ]; |
| 176 | 176 | } |
| 177 | 177 | if(isset($this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ])){ |
| 178 | - $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 179 | - } |
|
| 180 | - // Set operation style if necessary, but do not override one already provided |
|
| 178 | + $this->bindings[$binding]['operations'][$operation]['output']['parts'] = $this->messages[ $this->bindings[$binding]['operations'][$operation]['output']['message'] ]; |
|
| 179 | + } |
|
| 180 | + // Set operation style if necessary, but do not override one already provided |
|
| 181 | 181 | if (isset($bindingData['style']) && !isset($this->bindings[$binding]['operations'][$operation]['style'])) { |
| 182 | - $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
|
| 183 | - } |
|
| 184 | - $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
|
| 185 | - $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; |
|
| 186 | - $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; |
|
| 187 | - } |
|
| 188 | - } |
|
| 189 | - } |
|
| 182 | + $this->bindings[$binding]['operations'][$operation]['style'] = $bindingData['style']; |
|
| 183 | + } |
|
| 184 | + $this->bindings[$binding]['operations'][$operation]['transport'] = isset($bindingData['transport']) ? $bindingData['transport'] : ''; |
|
| 185 | + $this->bindings[$binding]['operations'][$operation]['documentation'] = isset($this->portTypes[ $bindingData['portType'] ][$operation]['documentation']) ? $this->portTypes[ $bindingData['portType'] ][$operation]['documentation'] : ''; |
|
| 186 | + $this->bindings[$binding]['operations'][$operation]['endpoint'] = isset($bindingData['endpoint']) ? $bindingData['endpoint'] : ''; |
|
| 187 | + } |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | - /** |
|
| 193 | - * parses the wsdl document |
|
| 194 | - * |
|
| 195 | - * @param string $wsdl path or URL |
|
| 196 | - * @access private |
|
| 197 | - */ |
|
| 198 | - public function parseWSDL($wsdl = '') { |
|
| 192 | + /** |
|
| 193 | + * parses the wsdl document |
|
| 194 | + * |
|
| 195 | + * @param string $wsdl path or URL |
|
| 196 | + * @access private |
|
| 197 | + */ |
|
| 198 | + public function parseWSDL($wsdl = '') { |
|
| 199 | 199 | $this->debug("parse WSDL at path=$wsdl"); |
| 200 | 200 | |
| 201 | - if ($wsdl == '') { |
|
| 202 | - $this->debug('no wsdl passed to parseWSDL()!!'); |
|
| 203 | - $this->setError('no wsdl passed to parseWSDL()!!'); |
|
| 204 | - return false; |
|
| 205 | - } |
|
| 201 | + if ($wsdl == '') { |
|
| 202 | + $this->debug('no wsdl passed to parseWSDL()!!'); |
|
| 203 | + $this->setError('no wsdl passed to parseWSDL()!!'); |
|
| 204 | + return false; |
|
| 205 | + } |
|
| 206 | 206 | |
| 207 | - // parse $wsdl for url format |
|
| 208 | - $wsdl_props = parse_url($wsdl); |
|
| 207 | + // parse $wsdl for url format |
|
| 208 | + $wsdl_props = parse_url($wsdl); |
|
| 209 | 209 | |
| 210 | - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { |
|
| 211 | - $this->debug('getting WSDL http(s) URL ' . $wsdl); |
|
| 212 | - // get wsdl |
|
| 213 | - $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
|
| 210 | + if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'http' || $wsdl_props['scheme'] == 'https')) { |
|
| 211 | + $this->debug('getting WSDL http(s) URL ' . $wsdl); |
|
| 212 | + // get wsdl |
|
| 213 | + $tr = new soap_transport_http($wsdl, $this->curl_options, $this->use_curl); |
|
| 214 | 214 | $tr->request_method = 'GET'; |
| 215 | 215 | $tr->useSOAPAction = false; |
| 216 | 216 | if($this->proxyhost && $this->proxyport){ |
@@ -226,239 +226,239 @@ discard block |
||
| 226 | 226 | if($err = $tr->getError() ){ |
| 227 | 227 | $errstr = 'Getting ' . $wsdl . ' - HTTP ERROR: '.$err; |
| 228 | 228 | $this->debug($errstr); |
| 229 | - $this->setError($errstr); |
|
| 229 | + $this->setError($errstr); |
|
| 230 | 230 | unset($tr); |
| 231 | - return false; |
|
| 231 | + return false; |
|
| 232 | 232 | } |
| 233 | 233 | unset($tr); |
| 234 | 234 | $this->debug("got WSDL URL"); |
| 235 | - } else { |
|
| 236 | - // $wsdl is not http(s), so treat it as a file URL or plain file path |
|
| 237 | - if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { |
|
| 238 | - $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 239 | - } else { |
|
| 240 | - $path = $wsdl; |
|
| 241 | - } |
|
| 242 | - $this->debug('getting WSDL file ' . $path); |
|
| 243 | - if ($fp = @fopen($path, 'r')) { |
|
| 244 | - $wsdl_string = ''; |
|
| 245 | - while ($data = fread($fp, 32768)) { |
|
| 246 | - $wsdl_string .= $data; |
|
| 247 | - } |
|
| 248 | - fclose($fp); |
|
| 249 | - } else { |
|
| 250 | - $errstr = "Bad path to WSDL file $path"; |
|
| 251 | - $this->debug($errstr); |
|
| 252 | - $this->setError($errstr); |
|
| 253 | - return false; |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - $this->debug('Parse WSDL'); |
|
| 257 | - // end new code added |
|
| 258 | - // Create an XML parser. |
|
| 259 | - $this->parser = xml_parser_create(); |
|
| 260 | - // Set the options for parsing the XML data. |
|
| 261 | - // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 262 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 263 | - // Set the object for the parser. |
|
| 264 | - xml_set_object($this->parser, $this); |
|
| 265 | - // Set the element handlers for the parser. |
|
| 266 | - xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
| 267 | - xml_set_character_data_handler($this->parser, 'character_data'); |
|
| 268 | - // Parse the XML file. |
|
| 269 | - if (!xml_parse($this->parser, $wsdl_string, true)) { |
|
| 270 | - // Display an error message. |
|
| 271 | - $errstr = sprintf( |
|
| 235 | + } else { |
|
| 236 | + // $wsdl is not http(s), so treat it as a file URL or plain file path |
|
| 237 | + if (isset($wsdl_props['scheme']) && ($wsdl_props['scheme'] == 'file') && isset($wsdl_props['path'])) { |
|
| 238 | + $path = isset($wsdl_props['host']) ? ($wsdl_props['host'] . ':' . $wsdl_props['path']) : $wsdl_props['path']; |
|
| 239 | + } else { |
|
| 240 | + $path = $wsdl; |
|
| 241 | + } |
|
| 242 | + $this->debug('getting WSDL file ' . $path); |
|
| 243 | + if ($fp = @fopen($path, 'r')) { |
|
| 244 | + $wsdl_string = ''; |
|
| 245 | + while ($data = fread($fp, 32768)) { |
|
| 246 | + $wsdl_string .= $data; |
|
| 247 | + } |
|
| 248 | + fclose($fp); |
|
| 249 | + } else { |
|
| 250 | + $errstr = "Bad path to WSDL file $path"; |
|
| 251 | + $this->debug($errstr); |
|
| 252 | + $this->setError($errstr); |
|
| 253 | + return false; |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + $this->debug('Parse WSDL'); |
|
| 257 | + // end new code added |
|
| 258 | + // Create an XML parser. |
|
| 259 | + $this->parser = xml_parser_create(); |
|
| 260 | + // Set the options for parsing the XML data. |
|
| 261 | + // xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); |
|
| 262 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 263 | + // Set the object for the parser. |
|
| 264 | + xml_set_object($this->parser, $this); |
|
| 265 | + // Set the element handlers for the parser. |
|
| 266 | + xml_set_element_handler($this->parser, 'start_element', 'end_element'); |
|
| 267 | + xml_set_character_data_handler($this->parser, 'character_data'); |
|
| 268 | + // Parse the XML file. |
|
| 269 | + if (!xml_parse($this->parser, $wsdl_string, true)) { |
|
| 270 | + // Display an error message. |
|
| 271 | + $errstr = sprintf( |
|
| 272 | 272 | 'XML error parsing WSDL from %s on line %d: %s', |
| 273 | 273 | $wsdl, |
| 274 | - xml_get_current_line_number($this->parser), |
|
| 275 | - xml_error_string(xml_get_error_code($this->parser)) |
|
| 276 | - ); |
|
| 277 | - $this->debug($errstr); |
|
| 274 | + xml_get_current_line_number($this->parser), |
|
| 275 | + xml_error_string(xml_get_error_code($this->parser)) |
|
| 276 | + ); |
|
| 277 | + $this->debug($errstr); |
|
| 278 | 278 | $this->debug("XML payload:\n" . $wsdl_string); |
| 279 | - $this->setError($errstr); |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 279 | + $this->setError($errstr); |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | 282 | // free the parser |
| 283 | - xml_parser_free($this->parser); |
|
| 284 | - $this->debug('Parsing WSDL done'); |
|
| 283 | + xml_parser_free($this->parser); |
|
| 284 | + $this->debug('Parsing WSDL done'); |
|
| 285 | 285 | // catch wsdl parse errors |
| 286 | 286 | if($this->getError()){ |
| 287 | 287 | return false; |
| 288 | 288 | } |
| 289 | - return true; |
|
| 290 | - } |
|
| 289 | + return true; |
|
| 290 | + } |
|
| 291 | 291 | |
| 292 | - /** |
|
| 293 | - * start-element handler |
|
| 294 | - * |
|
| 295 | - * @param string $parser XML parser object |
|
| 296 | - * @param string $name element name |
|
| 297 | - * @param string $attrs associative array of attributes |
|
| 298 | - * @access private |
|
| 299 | - */ |
|
| 300 | - public function start_element($parser, $name, $attrs) |
|
| 301 | - { |
|
| 302 | - if ($this->status == 'schema') { |
|
| 303 | - $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 304 | - $this->appendDebug($this->currentSchema->getDebug()); |
|
| 305 | - $this->currentSchema->clearDebug(); |
|
| 306 | - } elseif (preg_match('/schema$/', $name)) { |
|
| 307 | - $this->debug('Parsing WSDL schema'); |
|
| 308 | - $this->status = 'schema'; |
|
| 309 | - $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces); |
|
| 310 | - $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 311 | - $this->appendDebug($this->currentSchema->getDebug()); |
|
| 312 | - $this->currentSchema->clearDebug(); |
|
| 313 | - } else { |
|
| 314 | - // position in the total number of elements, starting from 0 |
|
| 315 | - $pos = $this->position++; |
|
| 316 | - $depth = $this->depth++; |
|
| 317 | - // set self as current value for this depth |
|
| 318 | - $this->depth_array[$depth] = $pos; |
|
| 319 | - $this->message[$pos] = array('cdata' => ''); |
|
| 320 | - // process attributes |
|
| 321 | - if (count($attrs) > 0) { |
|
| 292 | + /** |
|
| 293 | + * start-element handler |
|
| 294 | + * |
|
| 295 | + * @param string $parser XML parser object |
|
| 296 | + * @param string $name element name |
|
| 297 | + * @param string $attrs associative array of attributes |
|
| 298 | + * @access private |
|
| 299 | + */ |
|
| 300 | + public function start_element($parser, $name, $attrs) |
|
| 301 | + { |
|
| 302 | + if ($this->status == 'schema') { |
|
| 303 | + $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 304 | + $this->appendDebug($this->currentSchema->getDebug()); |
|
| 305 | + $this->currentSchema->clearDebug(); |
|
| 306 | + } elseif (preg_match('/schema$/', $name)) { |
|
| 307 | + $this->debug('Parsing WSDL schema'); |
|
| 308 | + $this->status = 'schema'; |
|
| 309 | + $this->currentSchema = new nusoap_xmlschema('', '', $this->namespaces); |
|
| 310 | + $this->currentSchema->schemaStartElement($parser, $name, $attrs); |
|
| 311 | + $this->appendDebug($this->currentSchema->getDebug()); |
|
| 312 | + $this->currentSchema->clearDebug(); |
|
| 313 | + } else { |
|
| 314 | + // position in the total number of elements, starting from 0 |
|
| 315 | + $pos = $this->position++; |
|
| 316 | + $depth = $this->depth++; |
|
| 317 | + // set self as current value for this depth |
|
| 318 | + $this->depth_array[$depth] = $pos; |
|
| 319 | + $this->message[$pos] = array('cdata' => ''); |
|
| 320 | + // process attributes |
|
| 321 | + if (count($attrs) > 0) { |
|
| 322 | 322 | // register namespace declarations |
| 323 | - foreach($attrs as $k => $v) { |
|
| 324 | - if (preg_match('/^xmlns/',$k)) { |
|
| 325 | - if ($ns_prefix = substr(strrchr($k, ':'), 1)) { |
|
| 326 | - $this->namespaces[$ns_prefix] = $v; |
|
| 327 | - } else { |
|
| 328 | - $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; |
|
| 329 | - } |
|
| 330 | - if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { |
|
| 331 | - $this->XMLSchemaVersion = $v; |
|
| 332 | - $this->namespaces['xsi'] = $v . '-instance'; |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - } |
|
| 336 | - // expand each attribute prefix to its namespace |
|
| 337 | - foreach($attrs as $k => $v) { |
|
| 338 | - $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 339 | - if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { |
|
| 340 | - $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 341 | - } |
|
| 342 | - $eAttrs[$k] = $v; |
|
| 343 | - } |
|
| 344 | - $attrs = $eAttrs; |
|
| 345 | - } else { |
|
| 346 | - $attrs = array(); |
|
| 347 | - } |
|
| 348 | - // get element prefix, namespace and name |
|
| 349 | - if (preg_match('/:/', $name)) { |
|
| 350 | - // get ns prefix |
|
| 351 | - $prefix = substr($name, 0, strpos($name, ':')); |
|
| 352 | - // get ns |
|
| 353 | - $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; |
|
| 354 | - // get unqualified name |
|
| 355 | - $name = substr(strstr($name, ':'), 1); |
|
| 356 | - } |
|
| 323 | + foreach($attrs as $k => $v) { |
|
| 324 | + if (preg_match('/^xmlns/',$k)) { |
|
| 325 | + if ($ns_prefix = substr(strrchr($k, ':'), 1)) { |
|
| 326 | + $this->namespaces[$ns_prefix] = $v; |
|
| 327 | + } else { |
|
| 328 | + $this->namespaces['ns' . (count($this->namespaces) + 1)] = $v; |
|
| 329 | + } |
|
| 330 | + if ($v == 'http://www.w3.org/2001/XMLSchema' || $v == 'http://www.w3.org/1999/XMLSchema' || $v == 'http://www.w3.org/2000/10/XMLSchema') { |
|
| 331 | + $this->XMLSchemaVersion = $v; |
|
| 332 | + $this->namespaces['xsi'] = $v . '-instance'; |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + } |
|
| 336 | + // expand each attribute prefix to its namespace |
|
| 337 | + foreach($attrs as $k => $v) { |
|
| 338 | + $k = strpos($k, ':') ? $this->expandQname($k) : $k; |
|
| 339 | + if ($k != 'location' && $k != 'soapAction' && $k != 'namespace') { |
|
| 340 | + $v = strpos($v, ':') ? $this->expandQname($v) : $v; |
|
| 341 | + } |
|
| 342 | + $eAttrs[$k] = $v; |
|
| 343 | + } |
|
| 344 | + $attrs = $eAttrs; |
|
| 345 | + } else { |
|
| 346 | + $attrs = array(); |
|
| 347 | + } |
|
| 348 | + // get element prefix, namespace and name |
|
| 349 | + if (preg_match('/:/', $name)) { |
|
| 350 | + // get ns prefix |
|
| 351 | + $prefix = substr($name, 0, strpos($name, ':')); |
|
| 352 | + // get ns |
|
| 353 | + $namespace = isset($this->namespaces[$prefix]) ? $this->namespaces[$prefix] : ''; |
|
| 354 | + // get unqualified name |
|
| 355 | + $name = substr(strstr($name, ':'), 1); |
|
| 356 | + } |
|
| 357 | 357 | // process attributes, expanding any prefixes to namespaces |
| 358 | - // find status, register data |
|
| 359 | - switch ($this->status) { |
|
| 360 | - case 'message': |
|
| 361 | - if ($name == 'part') { |
|
| 362 | - if (isset($attrs['type'])) { |
|
| 363 | - $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); |
|
| 364 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
|
| 365 | - } |
|
| 366 | - if (isset($attrs['element'])) { |
|
| 367 | - $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); |
|
| 368 | - $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 369 | - } |
|
| 370 | - } |
|
| 371 | - break; |
|
| 372 | - case 'portType': |
|
| 373 | - switch ($name) { |
|
| 374 | - case 'operation': |
|
| 375 | - $this->currentPortOperation = $attrs['name']; |
|
| 376 | - $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); |
|
| 377 | - if (isset($attrs['parameterOrder'])) { |
|
| 378 | - $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; |
|
| 379 | - } |
|
| 380 | - break; |
|
| 381 | - case 'documentation': |
|
| 382 | - $this->documentation = true; |
|
| 383 | - break; |
|
| 384 | - // merge input/output data |
|
| 385 | - default: |
|
| 386 | - $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; |
|
| 387 | - $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; |
|
| 388 | - break; |
|
| 358 | + // find status, register data |
|
| 359 | + switch ($this->status) { |
|
| 360 | + case 'message': |
|
| 361 | + if ($name == 'part') { |
|
| 362 | + if (isset($attrs['type'])) { |
|
| 363 | + $this->debug("msg " . $this->currentMessage . ": found part (with type) $attrs[name]: " . implode(',', $attrs)); |
|
| 364 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['type']; |
|
| 365 | + } |
|
| 366 | + if (isset($attrs['element'])) { |
|
| 367 | + $this->debug("msg " . $this->currentMessage . ": found part (with element) $attrs[name]: " . implode(',', $attrs)); |
|
| 368 | + $this->messages[$this->currentMessage][$attrs['name']] = $attrs['element'] . '^'; |
|
| 369 | + } |
|
| 389 | 370 | } |
| 390 | - break; |
|
| 371 | + break; |
|
| 372 | + case 'portType': |
|
| 373 | + switch ($name) { |
|
| 374 | + case 'operation': |
|
| 375 | + $this->currentPortOperation = $attrs['name']; |
|
| 376 | + $this->debug("portType $this->currentPortType operation: $this->currentPortOperation"); |
|
| 377 | + if (isset($attrs['parameterOrder'])) { |
|
| 378 | + $this->portTypes[$this->currentPortType][$attrs['name']]['parameterOrder'] = $attrs['parameterOrder']; |
|
| 379 | + } |
|
| 380 | + break; |
|
| 381 | + case 'documentation': |
|
| 382 | + $this->documentation = true; |
|
| 383 | + break; |
|
| 384 | + // merge input/output data |
|
| 385 | + default: |
|
| 386 | + $m = isset($attrs['message']) ? $this->getLocalPart($attrs['message']) : ''; |
|
| 387 | + $this->portTypes[$this->currentPortType][$this->currentPortOperation][$name]['message'] = $m; |
|
| 388 | + break; |
|
| 389 | + } |
|
| 390 | + break; |
|
| 391 | 391 | case 'binding': |
| 392 | - switch ($name) { |
|
| 393 | - case 'binding': |
|
| 394 | - // get ns prefix |
|
| 395 | - if (isset($attrs['style'])) { |
|
| 396 | - $this->bindings[$this->currentBinding]['prefix'] = $prefix; |
|
| 397 | - } |
|
| 398 | - $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); |
|
| 399 | - break; |
|
| 392 | + switch ($name) { |
|
| 393 | + case 'binding': |
|
| 394 | + // get ns prefix |
|
| 395 | + if (isset($attrs['style'])) { |
|
| 396 | + $this->bindings[$this->currentBinding]['prefix'] = $prefix; |
|
| 397 | + } |
|
| 398 | + $this->bindings[$this->currentBinding] = array_merge($this->bindings[$this->currentBinding], $attrs); |
|
| 399 | + break; |
|
| 400 | 400 | case 'header': |
| 401 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; |
|
| 402 | - break; |
|
| 401 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus]['headers'][] = $attrs; |
|
| 402 | + break; |
|
| 403 | 403 | case 'operation': |
| 404 | - if (isset($attrs['soapAction'])) { |
|
| 405 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; |
|
| 406 | - } |
|
| 407 | - if (isset($attrs['style'])) { |
|
| 408 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; |
|
| 409 | - } |
|
| 410 | - if (isset($attrs['name'])) { |
|
| 411 | - $this->currentOperation = $attrs['name']; |
|
| 412 | - $this->debug("current binding operation: $this->currentOperation"); |
|
| 413 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; |
|
| 414 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; |
|
| 415 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; |
|
| 416 | - } |
|
| 417 | - break; |
|
| 404 | + if (isset($attrs['soapAction'])) { |
|
| 405 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['soapAction'] = $attrs['soapAction']; |
|
| 406 | + } |
|
| 407 | + if (isset($attrs['style'])) { |
|
| 408 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['style'] = $attrs['style']; |
|
| 409 | + } |
|
| 410 | + if (isset($attrs['name'])) { |
|
| 411 | + $this->currentOperation = $attrs['name']; |
|
| 412 | + $this->debug("current binding operation: $this->currentOperation"); |
|
| 413 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['name'] = $attrs['name']; |
|
| 414 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['binding'] = $this->currentBinding; |
|
| 415 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation]['endpoint'] = isset($this->bindings[$this->currentBinding]['endpoint']) ? $this->bindings[$this->currentBinding]['endpoint'] : ''; |
|
| 416 | + } |
|
| 417 | + break; |
|
| 418 | 418 | case 'input': |
| 419 | - $this->opStatus = 'input'; |
|
| 420 | - break; |
|
| 419 | + $this->opStatus = 'input'; |
|
| 420 | + break; |
|
| 421 | 421 | case 'output': |
| 422 | - $this->opStatus = 'output'; |
|
| 423 | - break; |
|
| 422 | + $this->opStatus = 'output'; |
|
| 423 | + break; |
|
| 424 | 424 | case 'body': |
| 425 | - if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) { |
|
| 426 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); |
|
| 427 | - } else { |
|
| 428 | - $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; |
|
| 429 | - } |
|
| 430 | - break; |
|
| 425 | + if (isset($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus])) { |
|
| 426 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = array_merge($this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus], $attrs); |
|
| 427 | + } else { |
|
| 428 | + $this->bindings[$this->currentBinding]['operations'][$this->currentOperation][$this->opStatus] = $attrs; |
|
| 429 | + } |
|
| 430 | + break; |
|
| 431 | 431 | } |
| 432 | 432 | break; |
| 433 | 433 | case 'service': |
| 434 | 434 | switch ($name) { |
| 435 | - case 'port': |
|
| 436 | - $this->currentPort = $attrs['name']; |
|
| 437 | - $this->debug('current port: ' . $this->currentPort); |
|
| 438 | - $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
|
| 435 | + case 'port': |
|
| 436 | + $this->currentPort = $attrs['name']; |
|
| 437 | + $this->debug('current port: ' . $this->currentPort); |
|
| 438 | + $this->ports[$this->currentPort]['binding'] = $this->getLocalPart($attrs['binding']); |
|
| 439 | 439 | |
| 440 | - break; |
|
| 441 | - case 'address': |
|
| 442 | - $this->ports[$this->currentPort]['location'] = $attrs['location']; |
|
| 443 | - $this->ports[$this->currentPort]['bindingType'] = $namespace; |
|
| 444 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 445 | - $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 446 | - break; |
|
| 440 | + break; |
|
| 441 | + case 'address': |
|
| 442 | + $this->ports[$this->currentPort]['location'] = $attrs['location']; |
|
| 443 | + $this->ports[$this->currentPort]['bindingType'] = $namespace; |
|
| 444 | + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['bindingType'] = $namespace; |
|
| 445 | + $this->bindings[ $this->ports[$this->currentPort]['binding'] ]['endpoint'] = $attrs['location']; |
|
| 446 | + break; |
|
| 447 | 447 | } |
| 448 | 448 | break; |
| 449 | 449 | } |
| 450 | 450 | // set status |
| 451 | 451 | switch ($name) { |
| 452 | 452 | case 'import': |
| 453 | - if (isset($attrs['location'])) { |
|
| 454 | - $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); |
|
| 455 | - $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')'); |
|
| 453 | + if (isset($attrs['location'])) { |
|
| 454 | + $this->import[$attrs['namespace']][] = array('location' => $attrs['location'], 'loaded' => false); |
|
| 455 | + $this->debug('parsing import ' . $attrs['namespace']. ' - ' . $attrs['location'] . ' (' . count($this->import[$attrs['namespace']]).')'); |
|
| 456 | 456 | } else { |
| 457 | - $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
|
| 457 | + $this->import[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
|
| 458 | 458 | if (! $this->getPrefixFromNamespace($attrs['namespace'])) { |
| 459 | 459 | $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
| 460 | 460 | } |
| 461 | - $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')'); |
|
| 461 | + $this->debug('parsing import ' . $attrs['namespace']. ' - [no location] (' . count($this->import[$attrs['namespace']]).')'); |
|
| 462 | 462 | } |
| 463 | 463 | break; |
| 464 | 464 | //wait for schema |
@@ -479,9 +479,9 @@ discard block |
||
| 479 | 479 | if (isset($attrs['name'])) { |
| 480 | 480 | // get binding name |
| 481 | 481 | if (strpos($attrs['name'], ':')) { |
| 482 | - $this->currentBinding = $this->getLocalPart($attrs['name']); |
|
| 482 | + $this->currentBinding = $this->getLocalPart($attrs['name']); |
|
| 483 | 483 | } else { |
| 484 | - $this->currentBinding = $attrs['name']; |
|
| 484 | + $this->currentBinding = $attrs['name']; |
|
| 485 | 485 | } |
| 486 | 486 | $this->status = 'binding'; |
| 487 | 487 | $this->bindings[$this->currentBinding]['portType'] = $this->getLocalPart($attrs['type']); |
@@ -503,20 +503,20 @@ discard block |
||
| 503 | 503 | } |
| 504 | 504 | |
| 505 | 505 | /** |
| 506 | - * end-element handler |
|
| 507 | - * |
|
| 508 | - * @param string $parser XML parser object |
|
| 509 | - * @param string $name element name |
|
| 510 | - * @access private |
|
| 511 | - */ |
|
| 506 | + * end-element handler |
|
| 507 | + * |
|
| 508 | + * @param string $parser XML parser object |
|
| 509 | + * @param string $name element name |
|
| 510 | + * @access private |
|
| 511 | + */ |
|
| 512 | 512 | public function end_element($parser, $name){ |
| 513 | 513 | // unset schema status |
| 514 | 514 | if (/*preg_match('/types$/', $name) ||*/ preg_match('/schema$/', $name)) { |
| 515 | 515 | $this->status = ""; |
| 516 | - $this->appendDebug($this->currentSchema->getDebug()); |
|
| 517 | - $this->currentSchema->clearDebug(); |
|
| 516 | + $this->appendDebug($this->currentSchema->getDebug()); |
|
| 517 | + $this->currentSchema->clearDebug(); |
|
| 518 | 518 | $this->schemas[$this->currentSchema->schemaTargetNamespace][] = $this->currentSchema; |
| 519 | - $this->debug('Parsing WSDL schema done'); |
|
| 519 | + $this->debug('Parsing WSDL schema done'); |
|
| 520 | 520 | } |
| 521 | 521 | if ($this->status == 'schema') { |
| 522 | 522 | $this->currentSchema->schemaEndElement($parser, $name); |
@@ -549,14 +549,14 @@ discard block |
||
| 549 | 549 | } |
| 550 | 550 | |
| 551 | 551 | /** |
| 552 | - * if authenticating, set user credentials here |
|
| 553 | - * |
|
| 554 | - * @param string $username |
|
| 555 | - * @param string $password |
|
| 556 | - * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 557 | - * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 558 | - * @access public |
|
| 559 | - */ |
|
| 552 | + * if authenticating, set user credentials here |
|
| 553 | + * |
|
| 554 | + * @param string $username |
|
| 555 | + * @param string $password |
|
| 556 | + * @param string $authtype (basic|digest|certificate|ntlm) |
|
| 557 | + * @param array $certRequest (keys must be cainfofile (optional), sslcertfile, sslkeyfile, passphrase, certpassword (optional), verifypeer (optional), verifyhost (optional): see corresponding options in cURL docs) |
|
| 558 | + * @access public |
|
| 559 | + */ |
|
| 560 | 560 | public function setCredentials($username, $password, $authtype = 'basic', $certRequest = array()) { |
| 561 | 561 | $this->debug("setCredentials username=$username authtype=$authtype certRequest="); |
| 562 | 562 | $this->appendDebug($this->varDump($certRequest)); |
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | // note that we could/should also check the namespace here |
| 637 | 637 | if ($operation == $bOperation) { |
| 638 | 638 | $opData = $this->bindings[ $portData['binding'] ]['operations'][$operation]; |
| 639 | - return $opData; |
|
| 639 | + return $opData; |
|
| 640 | 640 | } |
| 641 | 641 | } |
| 642 | 642 | } |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | // loop through operations for the binding |
| 665 | 665 | foreach ($this->bindings[ $portData['binding'] ]['operations'] as $bOperation => $opData) { |
| 666 | 666 | if ($opData['soapAction'] == $soapAction) { |
| 667 | - return $opData; |
|
| 667 | + return $opData; |
|
| 668 | 668 | } |
| 669 | 669 | } |
| 670 | 670 | } |
@@ -672,23 +672,23 @@ discard block |
||
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | /** |
| 675 | - * returns an array of information about a given type |
|
| 676 | - * returns false if no type exists by the given name |
|
| 677 | - * |
|
| 678 | - * typeDef = array( |
|
| 679 | - * 'elements' => array(), // refs to elements array |
|
| 680 | - * 'restrictionBase' => '', |
|
| 681 | - * 'phpType' => '', |
|
| 682 | - * 'order' => '(sequence|all)', |
|
| 683 | - * 'attrs' => array() // refs to attributes array |
|
| 684 | - * ) |
|
| 685 | - * |
|
| 686 | - * @param string $type the type |
|
| 687 | - * @param string $ns namespace (not prefix) of the type |
|
| 688 | - * @return mixed |
|
| 689 | - * @access public |
|
| 690 | - * @see nusoap_xmlschema |
|
| 691 | - */ |
|
| 675 | + * returns an array of information about a given type |
|
| 676 | + * returns false if no type exists by the given name |
|
| 677 | + * |
|
| 678 | + * typeDef = array( |
|
| 679 | + * 'elements' => array(), // refs to elements array |
|
| 680 | + * 'restrictionBase' => '', |
|
| 681 | + * 'phpType' => '', |
|
| 682 | + * 'order' => '(sequence|all)', |
|
| 683 | + * 'attrs' => array() // refs to attributes array |
|
| 684 | + * ) |
|
| 685 | + * |
|
| 686 | + * @param string $type the type |
|
| 687 | + * @param string $ns namespace (not prefix) of the type |
|
| 688 | + * @return mixed |
|
| 689 | + * @access public |
|
| 690 | + * @see nusoap_xmlschema |
|
| 691 | + */ |
|
| 692 | 692 | public function getTypeDef($type, $ns) { |
| 693 | 693 | $this->debug("in getTypeDef: type=$type, ns=$ns"); |
| 694 | 694 | if ((! $ns) && isset($this->namespaces['tns'])) { |
@@ -744,13 +744,13 @@ discard block |
||
| 744 | 744 | return false; |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | - /** |
|
| 748 | - * prints html description of services |
|
| 749 | - * |
|
| 750 | - * @access private |
|
| 751 | - */ |
|
| 752 | - public function webDescription(){ |
|
| 753 | - global $HTTP_SERVER_VARS; |
|
| 747 | + /** |
|
| 748 | + * prints html description of services |
|
| 749 | + * |
|
| 750 | + * @access private |
|
| 751 | + */ |
|
| 752 | + public function webDescription(){ |
|
| 753 | + global $HTTP_SERVER_VARS; |
|
| 754 | 754 | |
| 755 | 755 | if (isset($_SERVER)) { |
| 756 | 756 | $PHP_SELF = $_SERVER['PHP_SELF']; |
@@ -844,29 +844,29 @@ discard block |
||
| 844 | 844 | Click on an operation name to view it's details.</p> |
| 845 | 845 | <ul>'; |
| 846 | 846 | foreach($this->getOperations() as $op => $data){ |
| 847 | - $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>"; |
|
| 848 | - // create hidden div |
|
| 849 | - $b .= "<div id='$op' class='hidden'> |
|
| 847 | + $b .= "<li><a href='#' onclick=\"popout();popup('$op')\">$op</a></li>"; |
|
| 848 | + // create hidden div |
|
| 849 | + $b .= "<div id='$op' class='hidden'> |
|
| 850 | 850 | <a href='#' onclick='popout()'><font color='#ffffff'>Close</font></a><br><br>"; |
| 851 | - foreach($data as $donnie => $marie){ // loop through opdata |
|
| 851 | + foreach($data as $donnie => $marie){ // loop through opdata |
|
| 852 | 852 | if($donnie == 'input' || $donnie == 'output'){ // show input/output data |
| 853 | - $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 854 | - foreach($marie as $captain => $tenille){ // loop through data |
|
| 853 | + $b .= "<font color='white'>".ucfirst($donnie).':</font><br>'; |
|
| 854 | + foreach($marie as $captain => $tenille){ // loop through data |
|
| 855 | 855 | if($captain == 'parts'){ // loop thru parts |
| 856 | - $b .= " $captain:<br>"; |
|
| 857 | - //if(is_array($tenille)){ |
|
| 858 | - foreach($tenille as $joanie => $chachi){ |
|
| 856 | + $b .= " $captain:<br>"; |
|
| 857 | + //if(is_array($tenille)){ |
|
| 858 | + foreach($tenille as $joanie => $chachi){ |
|
| 859 | 859 | $b .= " $joanie: $chachi<br>"; |
| 860 | - } |
|
| 861 | - //} |
|
| 860 | + } |
|
| 861 | + //} |
|
| 862 | 862 | } else { |
| 863 | - $b .= " $captain: $tenille<br>"; |
|
| 863 | + $b .= " $captain: $tenille<br>"; |
|
| 864 | 864 | } |
| 865 | - } |
|
| 865 | + } |
|
| 866 | 866 | } else { |
| 867 | - $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 867 | + $b .= "<font color='white'>".ucfirst($donnie).":</font> $marie<br>"; |
|
| 868 | 868 | } |
| 869 | - } |
|
| 869 | + } |
|
| 870 | 870 | $b .= '</div>'; |
| 871 | 871 | } |
| 872 | 872 | $b .= ' |
@@ -874,15 +874,15 @@ discard block |
||
| 874 | 874 | </div> |
| 875 | 875 | </div></body></html>'; |
| 876 | 876 | return $b; |
| 877 | - } |
|
| 877 | + } |
|
| 878 | 878 | |
| 879 | 879 | /** |
| 880 | - * serialize the parsed wsdl |
|
| 881 | - * |
|
| 882 | - * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 883 | - * @return string serialization of WSDL |
|
| 884 | - * @access public |
|
| 885 | - */ |
|
| 880 | + * serialize the parsed wsdl |
|
| 881 | + * |
|
| 882 | + * @param mixed $debug whether to put debug=1 in endpoint URL |
|
| 883 | + * @return string serialization of WSDL |
|
| 884 | + * @access public |
|
| 885 | + */ |
|
| 886 | 886 | public function serialize($debug = 0) |
| 887 | 887 | { |
| 888 | 888 | $xml = '<?xml version="1.0" encoding="ISO-8859-1"?>'; |
@@ -928,19 +928,19 @@ discard block |
||
| 928 | 928 | foreach($msgParts as $partName => $partType) { |
| 929 | 929 | // print 'serializing '.$partType.', sv: '.$this->XMLSchemaVersion.'<br>'; |
| 930 | 930 | if (strpos($partType, ':')) { |
| 931 | - $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
|
| 931 | + $typePrefix = $this->getPrefixFromNamespace($this->getPrefix($partType)); |
|
| 932 | 932 | } elseif (isset($this->typemap[$this->namespaces['xsd']][$partType])) { |
| 933 | - // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
|
| 934 | - $typePrefix = 'xsd'; |
|
| 933 | + // print 'checking typemap: '.$this->XMLSchemaVersion.'<br>'; |
|
| 934 | + $typePrefix = 'xsd'; |
|
| 935 | 935 | } else { |
| 936 | - foreach($this->typemap as $ns => $types) { |
|
| 937 | - if (isset($types[$partType])) { |
|
| 938 | - $typePrefix = $this->getPrefixFromNamespace($ns); |
|
| 939 | - } |
|
| 940 | - } |
|
| 941 | - if (!isset($typePrefix)) { |
|
| 942 | - die("$partType has no namespace!"); |
|
| 943 | - } |
|
| 936 | + foreach($this->typemap as $ns => $types) { |
|
| 937 | + if (isset($types[$partType])) { |
|
| 938 | + $typePrefix = $this->getPrefixFromNamespace($ns); |
|
| 939 | + } |
|
| 940 | + } |
|
| 941 | + if (!isset($typePrefix)) { |
|
| 942 | + die("$partType has no namespace!"); |
|
| 943 | + } |
|
| 944 | 944 | } |
| 945 | 945 | $ns = $this->getNamespaceFromPrefix($typePrefix); |
| 946 | 946 | $localPart = $this->getLocalPart($partType); |
@@ -985,7 +985,7 @@ discard block |
||
| 985 | 985 | $binding_xml .= "\n" . ' </operation>'; |
| 986 | 986 | $portType_xml .= "\n" . ' <operation name="' . $opParts['name'] . '"'; |
| 987 | 987 | if (isset($opParts['parameterOrder'])) { |
| 988 | - $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 988 | + $portType_xml .= ' parameterOrder="' . $opParts['parameterOrder'] . '"'; |
|
| 989 | 989 | } |
| 990 | 990 | $portType_xml .= '>'; |
| 991 | 991 | if(isset($opParts['documentation']) && $opParts['documentation'] != '') { |
@@ -1280,34 +1280,34 @@ discard block |
||
| 1280 | 1280 | } |
| 1281 | 1281 | |
| 1282 | 1282 | // if a soapval has been supplied, let its type override the WSDL |
| 1283 | - if (is_object($value) && get_class($value) == 'soapval') { |
|
| 1284 | - if ($value->type_ns) { |
|
| 1285 | - $type = $value->type_ns . ':' . $value->type; |
|
| 1286 | - $forceType = true; |
|
| 1287 | - $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1288 | - } elseif ($value->type) { |
|
| 1289 | - $type = $value->type; |
|
| 1290 | - $forceType = true; |
|
| 1291 | - $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1292 | - } else { |
|
| 1293 | - $forceType = false; |
|
| 1294 | - $this->debug("in serializeType: soapval does not override type"); |
|
| 1295 | - } |
|
| 1296 | - $attrs = $value->attributes; |
|
| 1297 | - $value = $value->value; |
|
| 1298 | - $this->debug("in serializeType: soapval overrides value to $value"); |
|
| 1299 | - if ($attrs) { |
|
| 1300 | - if (!is_array($value)) { |
|
| 1301 | - $value['!'] = $value; |
|
| 1302 | - } |
|
| 1303 | - foreach ($attrs as $n => $v) { |
|
| 1304 | - $value['!' . $n] = $v; |
|
| 1305 | - } |
|
| 1306 | - $this->debug("in serializeType: soapval provides attributes"); |
|
| 1307 | - } |
|
| 1308 | - } else { |
|
| 1309 | - $forceType = false; |
|
| 1310 | - } |
|
| 1283 | + if (is_object($value) && get_class($value) == 'soapval') { |
|
| 1284 | + if ($value->type_ns) { |
|
| 1285 | + $type = $value->type_ns . ':' . $value->type; |
|
| 1286 | + $forceType = true; |
|
| 1287 | + $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1288 | + } elseif ($value->type) { |
|
| 1289 | + $type = $value->type; |
|
| 1290 | + $forceType = true; |
|
| 1291 | + $this->debug("in serializeType: soapval overrides type to $type"); |
|
| 1292 | + } else { |
|
| 1293 | + $forceType = false; |
|
| 1294 | + $this->debug("in serializeType: soapval does not override type"); |
|
| 1295 | + } |
|
| 1296 | + $attrs = $value->attributes; |
|
| 1297 | + $value = $value->value; |
|
| 1298 | + $this->debug("in serializeType: soapval overrides value to $value"); |
|
| 1299 | + if ($attrs) { |
|
| 1300 | + if (!is_array($value)) { |
|
| 1301 | + $value['!'] = $value; |
|
| 1302 | + } |
|
| 1303 | + foreach ($attrs as $n => $v) { |
|
| 1304 | + $value['!' . $n] = $v; |
|
| 1305 | + } |
|
| 1306 | + $this->debug("in serializeType: soapval provides attributes"); |
|
| 1307 | + } |
|
| 1308 | + } else { |
|
| 1309 | + $forceType = false; |
|
| 1310 | + } |
|
| 1311 | 1311 | |
| 1312 | 1312 | $xml = ''; |
| 1313 | 1313 | if (strpos($type, ':')) { |
@@ -1339,8 +1339,8 @@ discard block |
||
| 1339 | 1339 | // JBoss/Axis does this sometimes |
| 1340 | 1340 | return $this->serialize_val($value, $name, false, false, false, false, $use); |
| 1341 | 1341 | } |
| 1342 | - if ($uqType == 'boolean') { |
|
| 1343 | - if ((is_string($value) && $value == 'false') || (! $value)) { |
|
| 1342 | + if ($uqType == 'boolean') { |
|
| 1343 | + if ((is_string($value) && $value == 'false') || (! $value)) { |
|
| 1344 | 1344 | $value = 'false'; |
| 1345 | 1345 | } else { |
| 1346 | 1346 | $value = 'true'; |
@@ -1523,9 +1523,9 @@ discard block |
||
| 1523 | 1523 | $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); |
| 1524 | 1524 | //if (strpos($typeDef['arrayType'], ':') ) { |
| 1525 | 1525 | if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) { |
| 1526 | - $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); |
|
| 1526 | + $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); |
|
| 1527 | 1527 | } else { |
| 1528 | - $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
|
| 1528 | + $contents .= $this->serialize_val($v, 'item', $typeDef['arrayType'], null, $this->XMLSchemaVersion, false, $use); |
|
| 1529 | 1529 | } |
| 1530 | 1530 | } |
| 1531 | 1531 | } else { |
@@ -1681,7 +1681,7 @@ discard block |
||
| 1681 | 1681 | } |
| 1682 | 1682 | // if user took advantage of a minOccurs=0, then only serialize named parameters |
| 1683 | 1683 | if (isset($optionals) |
| 1684 | - && (!isset($xvalue[$eName])) |
|
| 1684 | + && (!isset($xvalue[$eName])) |
|
| 1685 | 1685 | && ( (!isset($attrs['nillable'])) || $attrs['nillable'] != 'true') |
| 1686 | 1686 | ){ |
| 1687 | 1687 | if (isset($attrs['minOccurs']) && $attrs['minOccurs'] <> '0') { |
@@ -1692,9 +1692,9 @@ discard block |
||
| 1692 | 1692 | } else { |
| 1693 | 1693 | // get value |
| 1694 | 1694 | if (isset($xvalue[$eName])) { |
| 1695 | - $v = $xvalue[$eName]; |
|
| 1695 | + $v = $xvalue[$eName]; |
|
| 1696 | 1696 | } else { |
| 1697 | - $v = null; |
|
| 1697 | + $v = null; |
|
| 1698 | 1698 | } |
| 1699 | 1699 | if (isset($attrs['form'])) { |
| 1700 | 1700 | $unqualified = ($attrs['form'] == 'unqualified'); |
@@ -1706,24 +1706,24 @@ discard block |
||
| 1706 | 1706 | foreach ($vv as $k => $v) { |
| 1707 | 1707 | if (isset($attrs['type']) || isset($attrs['ref'])) { |
| 1708 | 1708 | // serialize schema-defined type |
| 1709 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1709 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1710 | 1710 | } else { |
| 1711 | 1711 | // serialize generic type (can this ever really happen?) |
| 1712 | - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1713 | - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1712 | + $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1713 | + $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1714 | 1714 | } |
| 1715 | 1715 | } |
| 1716 | 1716 | } else { |
| 1717 | 1717 | if (is_null($v) && isset($attrs['minOccurs']) && $attrs['minOccurs'] == '0') { |
| 1718 | 1718 | } elseif (is_null($v) && isset($attrs['nillable']) && $attrs['nillable'] == 'true') { |
| 1719 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1719 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1720 | 1720 | } elseif (isset($attrs['type']) || isset($attrs['ref'])) { |
| 1721 | 1721 | // serialize schema-defined type |
| 1722 | - $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1722 | + $xml .= $this->serializeType($eName, isset($attrs['type']) ? $attrs['type'] : $attrs['ref'], $v, $use, $encodingStyle, $unqualified); |
|
| 1723 | 1723 | } else { |
| 1724 | 1724 | // serialize generic type (can this ever really happen?) |
| 1725 | - $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1726 | - $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1725 | + $this->debug("calling serialize_val() for $v, $eName, false, false, false, false, $use"); |
|
| 1726 | + $xml .= $this->serialize_val($v, $eName, false, false, false, false, $use); |
|
| 1727 | 1727 | } |
| 1728 | 1728 | } |
| 1729 | 1729 | } |
@@ -1735,46 +1735,46 @@ discard block |
||
| 1735 | 1735 | } |
| 1736 | 1736 | |
| 1737 | 1737 | /** |
| 1738 | - * adds an XML Schema complex type to the WSDL types |
|
| 1739 | - * |
|
| 1740 | - * @param string $name |
|
| 1741 | - * @param string $typeClass (complexType|simpleType|attribute) |
|
| 1742 | - * @param string $phpType currently supported are array and struct (php assoc array) |
|
| 1743 | - * @param string $compositor (all|sequence|choice) |
|
| 1744 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1745 | - * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) |
|
| 1746 | - * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')) |
|
| 1747 | - * @param string $arrayType as namespace:name (xsd:string) |
|
| 1748 | - * @see nusoap_xmlschema |
|
| 1749 | - * @access public |
|
| 1750 | - */ |
|
| 1738 | + * adds an XML Schema complex type to the WSDL types |
|
| 1739 | + * |
|
| 1740 | + * @param string $name |
|
| 1741 | + * @param string $typeClass (complexType|simpleType|attribute) |
|
| 1742 | + * @param string $phpType currently supported are array and struct (php assoc array) |
|
| 1743 | + * @param string $compositor (all|sequence|choice) |
|
| 1744 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1745 | + * @param array $elements e.g. array ( name => array(name=>'',type=>'') ) |
|
| 1746 | + * @param array $attrs e.g. array(array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'xsd:string[]')) |
|
| 1747 | + * @param string $arrayType as namespace:name (xsd:string) |
|
| 1748 | + * @see nusoap_xmlschema |
|
| 1749 | + * @access public |
|
| 1750 | + */ |
|
| 1751 | 1751 | public function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType='') { |
| 1752 | 1752 | if (count($elements) > 0) { |
| 1753 | 1753 | $eElements = array(); |
| 1754 | - foreach($elements as $n => $e){ |
|
| 1755 | - // expand each element |
|
| 1756 | - $ee = array(); |
|
| 1757 | - foreach ($e as $k => $v) { |
|
| 1758 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1759 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1760 | - $ee[$k] = $v; |
|
| 1761 | - } |
|
| 1762 | - $eElements[$n] = $ee; |
|
| 1763 | - } |
|
| 1764 | - $elements = $eElements; |
|
| 1754 | + foreach($elements as $n => $e){ |
|
| 1755 | + // expand each element |
|
| 1756 | + $ee = array(); |
|
| 1757 | + foreach ($e as $k => $v) { |
|
| 1758 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1759 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1760 | + $ee[$k] = $v; |
|
| 1761 | + } |
|
| 1762 | + $eElements[$n] = $ee; |
|
| 1763 | + } |
|
| 1764 | + $elements = $eElements; |
|
| 1765 | 1765 | } |
| 1766 | 1766 | |
| 1767 | 1767 | if (count($attrs) > 0) { |
| 1768 | - foreach($attrs as $n => $a){ |
|
| 1769 | - // expand each attribute |
|
| 1770 | - foreach ($a as $k => $v) { |
|
| 1771 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1772 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1773 | - $aa[$k] = $v; |
|
| 1774 | - } |
|
| 1775 | - $eAttrs[$n] = $aa; |
|
| 1776 | - } |
|
| 1777 | - $attrs = $eAttrs; |
|
| 1768 | + foreach($attrs as $n => $a){ |
|
| 1769 | + // expand each attribute |
|
| 1770 | + foreach ($a as $k => $v) { |
|
| 1771 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 1772 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 1773 | + $aa[$k] = $v; |
|
| 1774 | + } |
|
| 1775 | + $eAttrs[$n] = $aa; |
|
| 1776 | + } |
|
| 1777 | + $attrs = $eAttrs; |
|
| 1778 | 1778 | } |
| 1779 | 1779 | |
| 1780 | 1780 | $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
@@ -1785,16 +1785,16 @@ discard block |
||
| 1785 | 1785 | } |
| 1786 | 1786 | |
| 1787 | 1787 | /** |
| 1788 | - * adds an XML Schema simple type to the WSDL types |
|
| 1789 | - * |
|
| 1790 | - * @param string $name |
|
| 1791 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1792 | - * @param string $typeClass (should always be simpleType) |
|
| 1793 | - * @param string $phpType (should always be scalar) |
|
| 1794 | - * @param array $enumeration array of values |
|
| 1795 | - * @see nusoap_xmlschema |
|
| 1796 | - * @access public |
|
| 1797 | - */ |
|
| 1788 | + * adds an XML Schema simple type to the WSDL types |
|
| 1789 | + * |
|
| 1790 | + * @param string $name |
|
| 1791 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 1792 | + * @param string $typeClass (should always be simpleType) |
|
| 1793 | + * @param string $phpType (should always be scalar) |
|
| 1794 | + * @param array $enumeration array of values |
|
| 1795 | + * @see nusoap_xmlschema |
|
| 1796 | + * @access public |
|
| 1797 | + */ |
|
| 1798 | 1798 | public function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { |
| 1799 | 1799 | $restrictionBase = strpos($restrictionBase,':') ? $this->expandQname($restrictionBase) : $restrictionBase; |
| 1800 | 1800 | |
@@ -1803,31 +1803,31 @@ discard block |
||
| 1803 | 1803 | } |
| 1804 | 1804 | |
| 1805 | 1805 | /** |
| 1806 | - * adds an element to the WSDL types |
|
| 1807 | - * |
|
| 1808 | - * @param array $attrs attributes that must include name and type |
|
| 1809 | - * @see nusoap_xmlschema |
|
| 1810 | - * @access public |
|
| 1811 | - */ |
|
| 1806 | + * adds an element to the WSDL types |
|
| 1807 | + * |
|
| 1808 | + * @param array $attrs attributes that must include name and type |
|
| 1809 | + * @see nusoap_xmlschema |
|
| 1810 | + * @access public |
|
| 1811 | + */ |
|
| 1812 | 1812 | public function addElement($attrs) { |
| 1813 | 1813 | $typens = isset($this->namespaces['types']) ? $this->namespaces['types'] : $this->namespaces['tns']; |
| 1814 | 1814 | $this->schemas[$typens][0]->addElement($attrs); |
| 1815 | 1815 | } |
| 1816 | 1816 | |
| 1817 | 1817 | /** |
| 1818 | - * register an operation with the server |
|
| 1819 | - * |
|
| 1820 | - * @param string $name operation (method) name |
|
| 1821 | - * @param array $in assoc array of input values: key = param name, value = param type |
|
| 1822 | - * @param array $out assoc array of output values: key = param name, value = param type |
|
| 1823 | - * @param string $namespace optional The namespace for the operation |
|
| 1824 | - * @param string $soapaction optional The soapaction for the operation |
|
| 1825 | - * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 1826 | - * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) |
|
| 1827 | - * @param string $documentation optional The description to include in the WSDL |
|
| 1828 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 1829 | - * @access public |
|
| 1830 | - */ |
|
| 1818 | + * register an operation with the server |
|
| 1819 | + * |
|
| 1820 | + * @param string $name operation (method) name |
|
| 1821 | + * @param array $in assoc array of input values: key = param name, value = param type |
|
| 1822 | + * @param array $out assoc array of output values: key = param name, value = param type |
|
| 1823 | + * @param string $namespace optional The namespace for the operation |
|
| 1824 | + * @param string $soapaction optional The soapaction for the operation |
|
| 1825 | + * @param string $style (rpc|document) optional The style for the operation Note: when 'document' is specified, parameter and return wrappers are created for you automatically |
|
| 1826 | + * @param string $use (encoded|literal) optional The use for the parameters (cannot mix right now) |
|
| 1827 | + * @param string $documentation optional The description to include in the WSDL |
|
| 1828 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 1829 | + * @access public |
|
| 1830 | + */ |
|
| 1831 | 1831 | public function addOperation($name, $in = false, $out = false, $namespace = false, $soapaction = false, $style = 'rpc', $use = 'encoded', $documentation = '', $encodingStyle = ''){ |
| 1832 | 1832 | if ($use == 'encoded' && $encodingStyle == '') { |
| 1833 | 1833 | $encodingStyle = 'http://schemas.xmlsoap.org/soap/encoding/'; |
@@ -1886,8 +1886,8 @@ discard block |
||
| 1886 | 1886 | $this->messages[$name.'Request'][$pName] = $pType; |
| 1887 | 1887 | } |
| 1888 | 1888 | } else { |
| 1889 | - $this->messages[$name.'Request']= '0'; |
|
| 1890 | - } |
|
| 1889 | + $this->messages[$name.'Request']= '0'; |
|
| 1890 | + } |
|
| 1891 | 1891 | if($out) |
| 1892 | 1892 | { |
| 1893 | 1893 | foreach($out as $pName => $pType) |
@@ -1898,8 +1898,8 @@ discard block |
||
| 1898 | 1898 | $this->messages[$name.'Response'][$pName] = $pType; |
| 1899 | 1899 | } |
| 1900 | 1900 | } else { |
| 1901 | - $this->messages[$name.'Response']= '0'; |
|
| 1902 | - } |
|
| 1901 | + $this->messages[$name.'Response']= '0'; |
|
| 1902 | + } |
|
| 1903 | 1903 | return true; |
| 1904 | 1904 | } |
| 1905 | 1905 | } |
@@ -104,21 +104,21 @@ discard block |
||
| 104 | 104 | * @access private |
| 105 | 105 | */ |
| 106 | 106 | var $revision = '$Revision: 1.57 $'; |
| 107 | - /** |
|
| 108 | - * Current error string (manipulated by getError/setError) |
|
| 107 | + /** |
|
| 108 | + * Current error string (manipulated by getError/setError) |
|
| 109 | 109 | * |
| 110 | 110 | * @var string |
| 111 | 111 | * @access private |
| 112 | 112 | */ |
| 113 | 113 | var $error_str = ''; |
| 114 | - /** |
|
| 115 | - * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
|
| 114 | + /** |
|
| 115 | + * Current debug string (manipulated by debug/appendDebug/clearDebug/getDebug/getDebugAsXMLComment) |
|
| 116 | 116 | * |
| 117 | 117 | * @var string |
| 118 | 118 | * @access private |
| 119 | 119 | */ |
| 120 | - var $debug_str = ''; |
|
| 121 | - /** |
|
| 120 | + var $debug_str = ''; |
|
| 121 | + /** |
|
| 122 | 122 | * toggles automatic encoding of special characters as entities |
| 123 | 123 | * (should always be true, I think) |
| 124 | 124 | * |
@@ -134,31 +134,31 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | var $debugLevel; |
| 136 | 136 | |
| 137 | - /** |
|
| 138 | - * set schema version |
|
| 139 | - * |
|
| 140 | - * @var string |
|
| 141 | - * @access public |
|
| 142 | - */ |
|
| 137 | + /** |
|
| 138 | + * set schema version |
|
| 139 | + * |
|
| 140 | + * @var string |
|
| 141 | + * @access public |
|
| 142 | + */ |
|
| 143 | 143 | var $XMLSchemaVersion = 'http://www.w3.org/2001/XMLSchema'; |
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * charset encoding for outgoing messages |
|
| 147 | - * |
|
| 148 | - * @var string |
|
| 149 | - * @access public |
|
| 150 | - */ |
|
| 151 | - var $soap_defencoding = 'UTF-8'; |
|
| 145 | + /** |
|
| 146 | + * charset encoding for outgoing messages |
|
| 147 | + * |
|
| 148 | + * @var string |
|
| 149 | + * @access public |
|
| 150 | + */ |
|
| 151 | + var $soap_defencoding = 'UTF-8'; |
|
| 152 | 152 | //var $soap_defencoding = 'UTF-8'; |
| 153 | 153 | |
| 154 | 154 | /** |
| 155 | - * namespaces in an array of prefix => uri |
|
| 156 | - * |
|
| 157 | - * this is "seeded" by a set of constants, but it may be altered by code |
|
| 158 | - * |
|
| 159 | - * @var array |
|
| 160 | - * @access public |
|
| 161 | - */ |
|
| 155 | + * namespaces in an array of prefix => uri |
|
| 156 | + * |
|
| 157 | + * this is "seeded" by a set of constants, but it may be altered by code |
|
| 158 | + * |
|
| 159 | + * @var array |
|
| 160 | + * @access public |
|
| 161 | + */ |
|
| 162 | 162 | var $namespaces = array( |
| 163 | 163 | 'SOAP-ENV' => 'http://schemas.xmlsoap.org/soap/envelope/', |
| 164 | 164 | 'xsd' => 'http://www.w3.org/2001/XMLSchema', |
@@ -167,20 +167,20 @@ discard block |
||
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | 169 | /** |
| 170 | - * namespaces used in the current context, e.g. during serialization |
|
| 171 | - * |
|
| 172 | - * @var array |
|
| 173 | - * @access private |
|
| 174 | - */ |
|
| 170 | + * namespaces used in the current context, e.g. during serialization |
|
| 171 | + * |
|
| 172 | + * @var array |
|
| 173 | + * @access private |
|
| 174 | + */ |
|
| 175 | 175 | var $usedNamespaces = array(); |
| 176 | 176 | |
| 177 | 177 | /** |
| 178 | - * XML Schema types in an array of uri => (array of xml type => php type) |
|
| 179 | - * is this legacy yet? |
|
| 180 | - * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
| 181 | - * @var array |
|
| 182 | - * @access public |
|
| 183 | - */ |
|
| 178 | + * XML Schema types in an array of uri => (array of xml type => php type) |
|
| 179 | + * is this legacy yet? |
|
| 180 | + * no, this is used by the nusoap_xmlschema class to verify type => namespace mappings. |
|
| 181 | + * @var array |
|
| 182 | + * @access public |
|
| 183 | + */ |
|
| 184 | 184 | var $typemap = array( |
| 185 | 185 | 'http://www.w3.org/2001/XMLSchema' => array( |
| 186 | 186 | 'string'=>'string','boolean'=>'boolean','float'=>'double','double'=>'double','decimal'=>'double', |
@@ -203,75 +203,75 @@ discard block |
||
| 203 | 203 | 'timeInstant'=>'string','base64Binary'=>'string','base64'=>'string','ur-type'=>'array'), |
| 204 | 204 | 'http://soapinterop.org/xsd' => array('SOAPStruct'=>'struct'), |
| 205 | 205 | 'http://schemas.xmlsoap.org/soap/encoding/' => array('base64'=>'string','array'=>'array','Array'=>'array'), |
| 206 | - 'http://xml.apache.org/xml-soap' => array('Map') |
|
| 206 | + 'http://xml.apache.org/xml-soap' => array('Map') |
|
| 207 | 207 | ); |
| 208 | 208 | |
| 209 | 209 | /** |
| 210 | - * XML entities to convert |
|
| 211 | - * |
|
| 212 | - * @var array |
|
| 213 | - * @access public |
|
| 214 | - * @deprecated |
|
| 215 | - * @see expandEntities |
|
| 216 | - */ |
|
| 210 | + * XML entities to convert |
|
| 211 | + * |
|
| 212 | + * @var array |
|
| 213 | + * @access public |
|
| 214 | + * @deprecated |
|
| 215 | + * @see expandEntities |
|
| 216 | + */ |
|
| 217 | 217 | var $xmlEntities = array('quot' => '"','amp' => '&', |
| 218 | 218 | 'lt' => '<','gt' => '>','apos' => "'"); |
| 219 | 219 | |
| 220 | 220 | /** |
| 221 | - * constructor |
|
| 222 | - * |
|
| 223 | - * @access public |
|
| 224 | - */ |
|
| 221 | + * constructor |
|
| 222 | + * |
|
| 223 | + * @access public |
|
| 224 | + */ |
|
| 225 | 225 | public function nusoap_base() { |
| 226 | 226 | $this->debugLevel = $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /** |
| 230 | - * gets the global debug level, which applies to future instances |
|
| 231 | - * |
|
| 232 | - * @return integer Debug level 0-9, where 0 turns off |
|
| 233 | - * @access public |
|
| 234 | - */ |
|
| 230 | + * gets the global debug level, which applies to future instances |
|
| 231 | + * |
|
| 232 | + * @return integer Debug level 0-9, where 0 turns off |
|
| 233 | + * @access public |
|
| 234 | + */ |
|
| 235 | 235 | public function getGlobalDebugLevel() { |
| 236 | 236 | return $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel']; |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | /** |
| 240 | - * sets the global debug level, which applies to future instances |
|
| 241 | - * |
|
| 242 | - * @param int $level Debug level 0-9, where 0 turns off |
|
| 243 | - * @access public |
|
| 244 | - */ |
|
| 240 | + * sets the global debug level, which applies to future instances |
|
| 241 | + * |
|
| 242 | + * @param int $level Debug level 0-9, where 0 turns off |
|
| 243 | + * @access public |
|
| 244 | + */ |
|
| 245 | 245 | public function setGlobalDebugLevel($level) { |
| 246 | 246 | $GLOBALS['_transient']['static']['nusoap_base']['globalDebugLevel'] = $level; |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | /** |
| 250 | - * gets the debug level for this instance |
|
| 251 | - * |
|
| 252 | - * @return int Debug level 0-9, where 0 turns off |
|
| 253 | - * @access public |
|
| 254 | - */ |
|
| 250 | + * gets the debug level for this instance |
|
| 251 | + * |
|
| 252 | + * @return int Debug level 0-9, where 0 turns off |
|
| 253 | + * @access public |
|
| 254 | + */ |
|
| 255 | 255 | public function getDebugLevel() { |
| 256 | 256 | return $this->debugLevel; |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | - * sets the debug level for this instance |
|
| 261 | - * |
|
| 262 | - * @param int $level Debug level 0-9, where 0 turns off |
|
| 263 | - * @access public |
|
| 264 | - */ |
|
| 260 | + * sets the debug level for this instance |
|
| 261 | + * |
|
| 262 | + * @param int $level Debug level 0-9, where 0 turns off |
|
| 263 | + * @access public |
|
| 264 | + */ |
|
| 265 | 265 | public function setDebugLevel($level) { |
| 266 | 266 | $this->debugLevel = $level; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | /** |
| 270 | - * adds debug data to the instance debug string with formatting |
|
| 271 | - * |
|
| 272 | - * @param string $string debug data |
|
| 273 | - * @access private |
|
| 274 | - */ |
|
| 270 | + * adds debug data to the instance debug string with formatting |
|
| 271 | + * |
|
| 272 | + * @param string $string debug data |
|
| 273 | + * @access private |
|
| 274 | + */ |
|
| 275 | 275 | public function debug($string){ |
| 276 | 276 | if ($this->debugLevel > 0) { |
| 277 | 277 | $this->appendDebug($this->getmicrotime().' '.get_class($this).": $string\n"); |
@@ -279,11 +279,11 @@ discard block |
||
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
| 282 | - * adds debug data to the instance debug string without formatting |
|
| 283 | - * |
|
| 284 | - * @param string $string debug data |
|
| 285 | - * @access public |
|
| 286 | - */ |
|
| 282 | + * adds debug data to the instance debug string without formatting |
|
| 283 | + * |
|
| 284 | + * @param string $string debug data |
|
| 285 | + * @access public |
|
| 286 | + */ |
|
| 287 | 287 | public function appendDebug($string){ |
| 288 | 288 | if ($this->debugLevel > 0) { |
| 289 | 289 | // it would be nice to use a memory stream here to use |
@@ -293,10 +293,10 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
| 296 | - * clears the current debug data for this instance |
|
| 297 | - * |
|
| 298 | - * @access public |
|
| 299 | - */ |
|
| 296 | + * clears the current debug data for this instance |
|
| 297 | + * |
|
| 298 | + * @access public |
|
| 299 | + */ |
|
| 300 | 300 | public function clearDebug() { |
| 301 | 301 | // it would be nice to use a memory stream here to use |
| 302 | 302 | // memory more efficiently |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
| 307 | - * gets the current debug data for this instance |
|
| 308 | - * |
|
| 309 | - * @return debug data |
|
| 310 | - * @access public |
|
| 311 | - */ |
|
| 307 | + * gets the current debug data for this instance |
|
| 308 | + * |
|
| 309 | + * @return debug data |
|
| 310 | + * @access public |
|
| 311 | + */ |
|
| 312 | 312 | public function &getDebug() { |
| 313 | 313 | // it would be nice to use a memory stream here to use |
| 314 | 314 | // memory more efficiently |
@@ -316,12 +316,12 @@ discard block |
||
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | /** |
| 319 | - * gets the current debug data for this instance as an XML comment |
|
| 320 | - * this may change the contents of the debug data |
|
| 321 | - * |
|
| 322 | - * @return debug data as an XML comment |
|
| 323 | - * @access public |
|
| 324 | - */ |
|
| 319 | + * gets the current debug data for this instance as an XML comment |
|
| 320 | + * this may change the contents of the debug data |
|
| 321 | + * |
|
| 322 | + * @return debug data as an XML comment |
|
| 323 | + * @access public |
|
| 324 | + */ |
|
| 325 | 325 | public function &getDebugAsXMLComment() { |
| 326 | 326 | // it would be nice to use a memory stream here to use |
| 327 | 327 | // memory more efficiently |
@@ -329,32 +329,32 @@ discard block |
||
| 329 | 329 | $this->debug_str = str_replace('--', '- -', $this->debug_str); |
| 330 | 330 | } |
| 331 | 331 | $ret = "<!--\n" . $this->debug_str . "\n-->"; |
| 332 | - return $ret; |
|
| 332 | + return $ret; |
|
| 333 | 333 | } |
| 334 | 334 | |
| 335 | 335 | /** |
| 336 | - * expands entities, e.g. changes '<' to '<'. |
|
| 337 | - * |
|
| 338 | - * @param string $val The string in which to expand entities. |
|
| 339 | - * @access private |
|
| 340 | - */ |
|
| 336 | + * expands entities, e.g. changes '<' to '<'. |
|
| 337 | + * |
|
| 338 | + * @param string $val The string in which to expand entities. |
|
| 339 | + * @access private |
|
| 340 | + */ |
|
| 341 | 341 | public function expandEntities($val) { |
| 342 | 342 | if ($this->charencoding) { |
| 343 | - $val = str_replace('&', '&', $val); |
|
| 344 | - $val = str_replace("'", ''', $val); |
|
| 345 | - $val = str_replace('"', '"', $val); |
|
| 346 | - $val = str_replace('<', '<', $val); |
|
| 347 | - $val = str_replace('>', '>', $val); |
|
| 348 | - } |
|
| 349 | - return $val; |
|
| 343 | + $val = str_replace('&', '&', $val); |
|
| 344 | + $val = str_replace("'", ''', $val); |
|
| 345 | + $val = str_replace('"', '"', $val); |
|
| 346 | + $val = str_replace('<', '<', $val); |
|
| 347 | + $val = str_replace('>', '>', $val); |
|
| 348 | + } |
|
| 349 | + return $val; |
|
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * returns error string if present |
|
| 354 | - * |
|
| 355 | - * @return mixed error string or false |
|
| 356 | - * @access public |
|
| 357 | - */ |
|
| 353 | + * returns error string if present |
|
| 354 | + * |
|
| 355 | + * @return mixed error string or false |
|
| 356 | + * @access public |
|
| 357 | + */ |
|
| 358 | 358 | public function getError(){ |
| 359 | 359 | if($this->error_str != ''){ |
| 360 | 360 | return $this->error_str; |
@@ -363,24 +363,24 @@ discard block |
||
| 363 | 363 | } |
| 364 | 364 | |
| 365 | 365 | /** |
| 366 | - * sets error string |
|
| 367 | - * |
|
| 368 | - * @return boolean $string error string |
|
| 369 | - * @access private |
|
| 370 | - */ |
|
| 366 | + * sets error string |
|
| 367 | + * |
|
| 368 | + * @return boolean $string error string |
|
| 369 | + * @access private |
|
| 370 | + */ |
|
| 371 | 371 | public function setError($str){ |
| 372 | 372 | $this->error_str = $str; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /** |
| 376 | - * detect if array is a simple array or a struct (associative array) |
|
| 377 | - * |
|
| 378 | - * @param mixed $val The PHP array |
|
| 379 | - * @return string (arraySimple|arrayStruct) |
|
| 380 | - * @access private |
|
| 381 | - */ |
|
| 376 | + * detect if array is a simple array or a struct (associative array) |
|
| 377 | + * |
|
| 378 | + * @param mixed $val The PHP array |
|
| 379 | + * @return string (arraySimple|arrayStruct) |
|
| 380 | + * @access private |
|
| 381 | + */ |
|
| 382 | 382 | public function isArraySimpleOrStruct($val) { |
| 383 | - $keyList = array_keys($val); |
|
| 383 | + $keyList = array_keys($val); |
|
| 384 | 384 | foreach ($keyList as $keyListValue) { |
| 385 | 385 | if (!is_int($keyListValue)) { |
| 386 | 386 | return 'arrayStruct'; |
@@ -390,33 +390,33 @@ discard block |
||
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
| 393 | - * serializes PHP values in accordance w/ section 5. Type information is |
|
| 394 | - * not serialized if $use == 'literal'. |
|
| 395 | - * |
|
| 396 | - * @param mixed $val The value to serialize |
|
| 397 | - * @param string $name The name (local part) of the XML element |
|
| 398 | - * @param string $type The XML schema type (local part) for the element |
|
| 399 | - * @param string $name_ns The namespace for the name of the XML element |
|
| 400 | - * @param string $type_ns The namespace for the type of the element |
|
| 401 | - * @param array $attributes The attributes to serialize as name=>value pairs |
|
| 402 | - * @param string $use The WSDL "use" (encoded|literal) |
|
| 403 | - * @param boolean $soapval Whether this is called from soapval. |
|
| 404 | - * @return string The serialized element, possibly with child elements |
|
| 405 | - * @access public |
|
| 406 | - */ |
|
| 393 | + * serializes PHP values in accordance w/ section 5. Type information is |
|
| 394 | + * not serialized if $use == 'literal'. |
|
| 395 | + * |
|
| 396 | + * @param mixed $val The value to serialize |
|
| 397 | + * @param string $name The name (local part) of the XML element |
|
| 398 | + * @param string $type The XML schema type (local part) for the element |
|
| 399 | + * @param string $name_ns The namespace for the name of the XML element |
|
| 400 | + * @param string $type_ns The namespace for the type of the element |
|
| 401 | + * @param array $attributes The attributes to serialize as name=>value pairs |
|
| 402 | + * @param string $use The WSDL "use" (encoded|literal) |
|
| 403 | + * @param boolean $soapval Whether this is called from soapval. |
|
| 404 | + * @return string The serialized element, possibly with child elements |
|
| 405 | + * @access public |
|
| 406 | + */ |
|
| 407 | 407 | public function serialize_val($val,$name=false,$type=false,$name_ns=false,$type_ns=false,$attributes=false,$use='encoded',$soapval=false) { |
| 408 | 408 | $this->debug("in serialize_val: name=$name, type=$type, name_ns=$name_ns, type_ns=$type_ns, use=$use, soapval=$soapval"); |
| 409 | 409 | $this->appendDebug('value=' . $this->varDump($val)); |
| 410 | 410 | $this->appendDebug('attributes=' . $this->varDump($attributes)); |
| 411 | 411 | |
| 412 | - if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
| 413 | - $this->debug("serialize_val: serialize soapval"); |
|
| 414 | - $xml = $val->serialize($use); |
|
| 412 | + if (is_object($val) && get_class($val) == 'soapval' && (! $soapval)) { |
|
| 413 | + $this->debug("serialize_val: serialize soapval"); |
|
| 414 | + $xml = $val->serialize($use); |
|
| 415 | 415 | $this->appendDebug($val->getDebug()); |
| 416 | 416 | $val->clearDebug(); |
| 417 | 417 | $this->debug("serialize_val of soapval returning $xml"); |
| 418 | 418 | return $xml; |
| 419 | - } |
|
| 419 | + } |
|
| 420 | 420 | // force valid name if necessary |
| 421 | 421 | if (is_numeric($name)) { |
| 422 | 422 | $name = '__numeric_' . $name; |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | } |
| 426 | 426 | // if name has ns, add ns prefix to name |
| 427 | 427 | $xmlns = ''; |
| 428 | - if($name_ns){ |
|
| 428 | + if($name_ns){ |
|
| 429 | 429 | $prefix = 'nu'.rand(1000,9999); |
| 430 | 430 | $name = $prefix.':'.$name; |
| 431 | 431 | $xmlns .= " xmlns:$prefix=\"$name_ns\""; |
@@ -433,7 +433,7 @@ discard block |
||
| 433 | 433 | // if type is prefixed, create type prefix |
| 434 | 434 | if($type_ns != '' && $type_ns == $this->namespaces['xsd']){ |
| 435 | 435 | // need to fix this. shouldn't default to xsd if no ns specified |
| 436 | - // w/o checking against typemap |
|
| 436 | + // w/o checking against typemap |
|
| 437 | 437 | $type_prefix = 'xsd'; |
| 438 | 438 | } elseif($type_ns){ |
| 439 | 439 | $type_prefix = 'ns'.rand(1000,9999); |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | } |
| 449 | 449 | // serialize null value |
| 450 | 450 | if (is_null($val)) { |
| 451 | - $this->debug("serialize_val: serialize null"); |
|
| 451 | + $this->debug("serialize_val: serialize null"); |
|
| 452 | 452 | if ($use == 'literal') { |
| 453 | 453 | $xml = "<$name$xmlns$atts/>"; |
| 454 | 454 | $this->debug("serialize_val returning $xml"); |
| 455 | - return $xml; |
|
| 456 | - } else { |
|
| 455 | + return $xml; |
|
| 456 | + } else { |
|
| 457 | 457 | if (isset($type) && isset($type_prefix)) { |
| 458 | 458 | $type_str = " xsi:type=\"$type_prefix:$type\""; |
| 459 | 459 | } else { |
@@ -461,41 +461,41 @@ discard block |
||
| 461 | 461 | } |
| 462 | 462 | $xml = "<$name$xmlns$type_str$atts xsi:nil=\"true\"/>"; |
| 463 | 463 | $this->debug("serialize_val returning $xml"); |
| 464 | - return $xml; |
|
| 465 | - } |
|
| 464 | + return $xml; |
|
| 465 | + } |
|
| 466 | 466 | } |
| 467 | - // serialize if an xsd built-in primitive type |
|
| 468 | - if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
|
| 469 | - $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
| 470 | - if (is_bool($val)) { |
|
| 471 | - if ($type == 'boolean') { |
|
| 472 | - $val = $val ? 'true' : 'false'; |
|
| 473 | - } elseif (! $val) { |
|
| 474 | - $val = 0; |
|
| 475 | - } |
|
| 467 | + // serialize if an xsd built-in primitive type |
|
| 468 | + if($type != '' && isset($this->typemap[$this->XMLSchemaVersion][$type])){ |
|
| 469 | + $this->debug("serialize_val: serialize xsd built-in primitive type"); |
|
| 470 | + if (is_bool($val)) { |
|
| 471 | + if ($type == 'boolean') { |
|
| 472 | + $val = $val ? 'true' : 'false'; |
|
| 473 | + } elseif (! $val) { |
|
| 474 | + $val = 0; |
|
| 475 | + } |
|
| 476 | 476 | } else if (is_string($val)) { |
| 477 | 477 | $val = $this->expandEntities($val); |
| 478 | 478 | } |
| 479 | 479 | if ($use == 'literal') { |
| 480 | 480 | $xml = "<$name$xmlns$atts>$val</$name>"; |
| 481 | 481 | $this->debug("serialize_val returning $xml"); |
| 482 | - return $xml; |
|
| 483 | - } else { |
|
| 482 | + return $xml; |
|
| 483 | + } else { |
|
| 484 | 484 | $xml = "<$name$xmlns xsi:type=\"xsd:$type\"$atts>$val</$name>"; |
| 485 | 485 | $this->debug("serialize_val returning $xml"); |
| 486 | - return $xml; |
|
| 487 | - } |
|
| 488 | - } |
|
| 486 | + return $xml; |
|
| 487 | + } |
|
| 488 | + } |
|
| 489 | 489 | // detect type and serialize |
| 490 | 490 | $xml = ''; |
| 491 | 491 | switch(true) { |
| 492 | 492 | case (is_bool($val) || $type == 'boolean'): |
| 493 | 493 | $this->debug("serialize_val: serialize boolean"); |
| 494 | - if ($type == 'boolean') { |
|
| 495 | - $val = $val ? 'true' : 'false'; |
|
| 496 | - } elseif (! $val) { |
|
| 497 | - $val = 0; |
|
| 498 | - } |
|
| 494 | + if ($type == 'boolean') { |
|
| 495 | + $val = $val ? 'true' : 'false'; |
|
| 496 | + } elseif (! $val) { |
|
| 497 | + $val = 0; |
|
| 498 | + } |
|
| 499 | 499 | if ($use == 'literal') { |
| 500 | 500 | $xml .= "<$name$xmlns$atts>$val</$name>"; |
| 501 | 501 | } else { |
@@ -529,12 +529,12 @@ discard block |
||
| 529 | 529 | break; |
| 530 | 530 | case is_object($val): |
| 531 | 531 | $this->debug("serialize_val: serialize object"); |
| 532 | - if (get_class($val) == 'soapval') { |
|
| 533 | - $this->debug("serialize_val: serialize soapval object"); |
|
| 534 | - $pXml = $val->serialize($use); |
|
| 532 | + if (get_class($val) == 'soapval') { |
|
| 533 | + $this->debug("serialize_val: serialize soapval object"); |
|
| 534 | + $pXml = $val->serialize($use); |
|
| 535 | 535 | $this->appendDebug($val->getDebug()); |
| 536 | 536 | $val->clearDebug(); |
| 537 | - } else { |
|
| 537 | + } else { |
|
| 538 | 538 | if (! $name) { |
| 539 | 539 | $name = get_class($val); |
| 540 | 540 | $this->debug("In serialize_val, used class name $name as element name"); |
@@ -560,19 +560,19 @@ discard block |
||
| 560 | 560 | case (is_array($val) || $type): |
| 561 | 561 | // detect if struct or array |
| 562 | 562 | $valueType = $this->isArraySimpleOrStruct($val); |
| 563 | - if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
|
| 563 | + if($valueType=='arraySimple' || preg_match('/^ArrayOf/',$type)){ |
|
| 564 | 564 | $this->debug("serialize_val: serialize array"); |
| 565 | 565 | $i = 0; |
| 566 | 566 | if(is_array($val) && count($val)> 0){ |
| 567 | 567 | foreach($val as $v){ |
| 568 | - if(is_object($v) && get_class($v) == 'soapval'){ |
|
| 568 | + if(is_object($v) && get_class($v) == 'soapval'){ |
|
| 569 | 569 | $tt_ns = $v->type_ns; |
| 570 | 570 | $tt = $v->type; |
| 571 | 571 | } elseif (is_array($v)) { |
| 572 | 572 | $tt = $this->isArraySimpleOrStruct($v); |
| 573 | 573 | } else { |
| 574 | 574 | $tt = gettype($v); |
| 575 | - } |
|
| 575 | + } |
|
| 576 | 576 | $array_types[$tt] = 1; |
| 577 | 577 | $xml .= $this->serialize_val($v,'item',false,false,false,false,$use); |
| 578 | 578 | ++$i; |
@@ -655,19 +655,19 @@ discard block |
||
| 655 | 655 | return $xml; |
| 656 | 656 | } |
| 657 | 657 | |
| 658 | - /** |
|
| 659 | - * serializes a message |
|
| 660 | - * |
|
| 661 | - * @param string $body the XML of the SOAP body |
|
| 662 | - * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 663 | - * @param array $namespaces optional the namespaces used in generating the body and headers |
|
| 664 | - * @param string $style optional (rpc|document) |
|
| 665 | - * @param string $use optional (encoded|literal) |
|
| 666 | - * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 667 | - * @return string the message |
|
| 668 | - * @access public |
|
| 669 | - */ |
|
| 670 | - public function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
|
| 658 | + /** |
|
| 659 | + * serializes a message |
|
| 660 | + * |
|
| 661 | + * @param string $body the XML of the SOAP body |
|
| 662 | + * @param mixed $headers optional string of XML with SOAP header content, or array of soapval objects for SOAP headers, or associative array |
|
| 663 | + * @param array $namespaces optional the namespaces used in generating the body and headers |
|
| 664 | + * @param string $style optional (rpc|document) |
|
| 665 | + * @param string $use optional (encoded|literal) |
|
| 666 | + * @param string $encodingStyle optional (usually 'http://schemas.xmlsoap.org/soap/encoding/' for encoded) |
|
| 667 | + * @return string the message |
|
| 668 | + * @access public |
|
| 669 | + */ |
|
| 670 | + public function serializeEnvelope($body,$headers=false,$namespaces=array(),$style='rpc',$use='encoded',$encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'){ |
|
| 671 | 671 | |
| 672 | 672 | $this->debug("In serializeEnvelope length=" . strlen($body) . " body (max 1000 characters)=" . substr($body, 0, 1000) . " style=$style use=$use encodingStyle=$encodingStyle"); |
| 673 | 673 | $this->debug("headers:"); |
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | $this->appendDebug($this->varDump($namespaces)); |
| 677 | 677 | |
| 678 | 678 | // serialize namespaces |
| 679 | - $ns_string = ''; |
|
| 679 | + $ns_string = ''; |
|
| 680 | 680 | foreach(array_merge($this->namespaces,$namespaces) as $k => $v){ |
| 681 | 681 | $ns_string .= " xmlns:$k=\"$v\""; |
| 682 | 682 | } |
@@ -709,7 +709,7 @@ discard block |
||
| 709 | 709 | $body. |
| 710 | 710 | "</SOAP-ENV:Body>". |
| 711 | 711 | "</SOAP-ENV:Envelope>"; |
| 712 | - } |
|
| 712 | + } |
|
| 713 | 713 | |
| 714 | 714 | /** |
| 715 | 715 | * formats a string to be inserted into an HTML stream |
@@ -719,18 +719,18 @@ discard block |
||
| 719 | 719 | * @access public |
| 720 | 720 | * @deprecated |
| 721 | 721 | */ |
| 722 | - public function formatDump($str){ |
|
| 722 | + public function formatDump($str){ |
|
| 723 | 723 | $str = htmlspecialchars($str); |
| 724 | 724 | return nl2br($str); |
| 725 | - } |
|
| 725 | + } |
|
| 726 | 726 | |
| 727 | 727 | /** |
| 728 | - * contracts (changes namespace to prefix) a qualified name |
|
| 729 | - * |
|
| 730 | - * @param string $qname qname |
|
| 731 | - * @return string contracted qname |
|
| 732 | - * @access private |
|
| 733 | - */ |
|
| 728 | + * contracts (changes namespace to prefix) a qualified name |
|
| 729 | + * |
|
| 730 | + * @param string $qname qname |
|
| 731 | + * @return string contracted qname |
|
| 732 | + * @access private |
|
| 733 | + */ |
|
| 734 | 734 | public function contractQname($qname){ |
| 735 | 735 | // get element namespace |
| 736 | 736 | if (strrpos($qname, ':')) { |
@@ -749,12 +749,12 @@ discard block |
||
| 749 | 749 | } |
| 750 | 750 | |
| 751 | 751 | /** |
| 752 | - * expands (changes prefix to namespace) a qualified name |
|
| 753 | - * |
|
| 754 | - * @param string $qname qname |
|
| 755 | - * @return string expanded qname |
|
| 756 | - * @access private |
|
| 757 | - */ |
|
| 752 | + * expands (changes prefix to namespace) a qualified name |
|
| 753 | + * |
|
| 754 | + * @param string $qname qname |
|
| 755 | + * @return string expanded qname |
|
| 756 | + * @access private |
|
| 757 | + */ |
|
| 758 | 758 | public function expandQname($qname){ |
| 759 | 759 | // get element prefix |
| 760 | 760 | if(strpos($qname,':') && !preg_match('/^http:\/\//',$qname)){ |
@@ -772,14 +772,14 @@ discard block |
||
| 772 | 772 | } |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - /** |
|
| 776 | - * returns the local part of a prefixed string |
|
| 777 | - * returns the original string, if not prefixed |
|
| 778 | - * |
|
| 779 | - * @param string $str The prefixed string |
|
| 780 | - * @return string The local part |
|
| 781 | - * @access public |
|
| 782 | - */ |
|
| 775 | + /** |
|
| 776 | + * returns the local part of a prefixed string |
|
| 777 | + * returns the original string, if not prefixed |
|
| 778 | + * |
|
| 779 | + * @param string $str The prefixed string |
|
| 780 | + * @return string The local part |
|
| 781 | + * @access public |
|
| 782 | + */ |
|
| 783 | 783 | public function getLocalPart($str){ |
| 784 | 784 | if($sstr = strrchr($str,':')){ |
| 785 | 785 | // get unqualified name |
@@ -790,13 +790,13 @@ discard block |
||
| 790 | 790 | } |
| 791 | 791 | |
| 792 | 792 | /** |
| 793 | - * returns the prefix part of a prefixed string |
|
| 794 | - * returns false, if not prefixed |
|
| 795 | - * |
|
| 796 | - * @param string $str The prefixed string |
|
| 797 | - * @return mixed The prefix or false if there is no prefix |
|
| 798 | - * @access public |
|
| 799 | - */ |
|
| 793 | + * returns the prefix part of a prefixed string |
|
| 794 | + * returns false, if not prefixed |
|
| 795 | + * |
|
| 796 | + * @param string $str The prefixed string |
|
| 797 | + * @return mixed The prefix or false if there is no prefix |
|
| 798 | + * @access public |
|
| 799 | + */ |
|
| 800 | 800 | public function getPrefix($str){ |
| 801 | 801 | if($pos = strrpos($str,':')){ |
| 802 | 802 | // get prefix |
@@ -806,12 +806,12 @@ discard block |
||
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | /** |
| 809 | - * pass it a prefix, it returns a namespace |
|
| 810 | - * |
|
| 811 | - * @param string $prefix The prefix |
|
| 812 | - * @return mixed The namespace, false if no namespace has the specified prefix |
|
| 813 | - * @access public |
|
| 814 | - */ |
|
| 809 | + * pass it a prefix, it returns a namespace |
|
| 810 | + * |
|
| 811 | + * @param string $prefix The prefix |
|
| 812 | + * @return mixed The namespace, false if no namespace has the specified prefix |
|
| 813 | + * @access public |
|
| 814 | + */ |
|
| 815 | 815 | public function getNamespaceFromPrefix($prefix){ |
| 816 | 816 | if (isset($this->namespaces[$prefix])) { |
| 817 | 817 | return $this->namespaces[$prefix]; |
@@ -820,17 +820,17 @@ discard block |
||
| 820 | 820 | } |
| 821 | 821 | |
| 822 | 822 | /** |
| 823 | - * returns the prefix for a given namespace (or prefix) |
|
| 824 | - * or false if no prefixes registered for the given namespace |
|
| 825 | - * |
|
| 826 | - * @param string $ns The namespace |
|
| 827 | - * @return mixed The prefix, false if the namespace has no prefixes |
|
| 828 | - * @access public |
|
| 829 | - */ |
|
| 823 | + * returns the prefix for a given namespace (or prefix) |
|
| 824 | + * or false if no prefixes registered for the given namespace |
|
| 825 | + * |
|
| 826 | + * @param string $ns The namespace |
|
| 827 | + * @return mixed The prefix, false if the namespace has no prefixes |
|
| 828 | + * @access public |
|
| 829 | + */ |
|
| 830 | 830 | public function getPrefixFromNamespace($ns) { |
| 831 | 831 | foreach ($this->namespaces as $p => $n) { |
| 832 | 832 | if ($ns == $n || $ns == $p) { |
| 833 | - $this->usedNamespaces[$p] = $n; |
|
| 833 | + $this->usedNamespaces[$p] = $n; |
|
| 834 | 834 | return $p; |
| 835 | 835 | } |
| 836 | 836 | } |
@@ -838,11 +838,11 @@ discard block |
||
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | /** |
| 841 | - * returns the time in ODBC canonical form with microseconds |
|
| 842 | - * |
|
| 843 | - * @return string The time in ODBC canonical form with microseconds |
|
| 844 | - * @access public |
|
| 845 | - */ |
|
| 841 | + * returns the time in ODBC canonical form with microseconds |
|
| 842 | + * |
|
| 843 | + * @return string The time in ODBC canonical form with microseconds |
|
| 844 | + * @access public |
|
| 845 | + */ |
|
| 846 | 846 | public function getmicrotime() { |
| 847 | 847 | if (function_exists('gettimeofday')) { |
| 848 | 848 | $tod = gettimeofday(); |
@@ -862,7 +862,7 @@ discard block |
||
| 862 | 862 | * @return string The output of var_dump |
| 863 | 863 | * @access public |
| 864 | 864 | */ |
| 865 | - public function varDump($data) { |
|
| 865 | + public function varDump($data) { |
|
| 866 | 866 | // <-------- YetiForce Sp. z o.o. --------> |
| 867 | 867 | // original code: ob_start(); var_dump($data); $ret_val = ob_get_contents(); ob_end_clean(); |
| 868 | 868 | $ret_val = var_export($data, true); |
@@ -871,11 +871,11 @@ discard block |
||
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | /** |
| 874 | - * represents the object as a string |
|
| 875 | - * |
|
| 876 | - * @return string |
|
| 877 | - * @access public |
|
| 878 | - */ |
|
| 874 | + * represents the object as a string |
|
| 875 | + * |
|
| 876 | + * @return string |
|
| 877 | + * @access public |
|
| 878 | + */ |
|
| 879 | 879 | public function __toString() { |
| 880 | 880 | return $this->varDump($this); |
| 881 | 881 | } |
@@ -44,13 +44,13 @@ discard block |
||
| 44 | 44 | var $defaultNamespace = array(); |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | - * constructor |
|
| 48 | - * |
|
| 49 | - * @param string $schema schema document URI |
|
| 50 | - * @param string $xml xml document URI |
|
| 51 | - * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | - * @access public |
|
| 53 | - */ |
|
| 47 | + * constructor |
|
| 48 | + * |
|
| 49 | + * @param string $schema schema document URI |
|
| 50 | + * @param string $xml xml document URI |
|
| 51 | + * @param string $namespaces namespaces defined in enclosing XML |
|
| 52 | + * @access public |
|
| 53 | + */ |
|
| 54 | 54 | public function nusoap_xmlschema($schema='',$xml='',$namespaces=array()){ |
| 55 | 55 | parent::nusoap_base(); |
| 56 | 56 | $this->debug('nusoap_xmlschema class instantiated, inside constructor'); |
@@ -76,14 +76,14 @@ discard block |
||
| 76 | 76 | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * parse an XML file |
|
| 81 | - * |
|
| 82 | - * @param string $xml path/URL to XML file |
|
| 83 | - * @param string $type (schema | xml) |
|
| 84 | - * @return boolean |
|
| 85 | - * @access public |
|
| 86 | - */ |
|
| 79 | + /** |
|
| 80 | + * parse an XML file |
|
| 81 | + * |
|
| 82 | + * @param string $xml path/URL to XML file |
|
| 83 | + * @param string $type (schema | xml) |
|
| 84 | + * @return boolean |
|
| 85 | + * @access public |
|
| 86 | + */ |
|
| 87 | 87 | public function parseFile($xml,$type){ |
| 88 | 88 | // parse xml file |
| 89 | 89 | if($xml != ""){ |
@@ -104,35 +104,35 @@ discard block |
||
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
| 107 | - * parse an XML string |
|
| 108 | - * |
|
| 109 | - * @param string $xml path or URL |
|
| 110 | - * @param string $type (schema|xml) |
|
| 111 | - * @access private |
|
| 112 | - */ |
|
| 107 | + * parse an XML string |
|
| 108 | + * |
|
| 109 | + * @param string $xml path or URL |
|
| 110 | + * @param string $type (schema|xml) |
|
| 111 | + * @access private |
|
| 112 | + */ |
|
| 113 | 113 | public function parseString($xml,$type){ |
| 114 | 114 | // parse xml string |
| 115 | 115 | if($xml != ""){ |
| 116 | 116 | |
| 117 | - // Create an XML parser. |
|
| 118 | - $this->parser = xml_parser_create(); |
|
| 119 | - // Set the options for parsing the XML data. |
|
| 120 | - xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 117 | + // Create an XML parser. |
|
| 118 | + $this->parser = xml_parser_create(); |
|
| 119 | + // Set the options for parsing the XML data. |
|
| 120 | + xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); |
|
| 121 | 121 | |
| 122 | - // Set the object for the parser. |
|
| 123 | - xml_set_object($this->parser, $this); |
|
| 122 | + // Set the object for the parser. |
|
| 123 | + xml_set_object($this->parser, $this); |
|
| 124 | 124 | |
| 125 | - // Set the element handlers for the parser. |
|
| 125 | + // Set the element handlers for the parser. |
|
| 126 | 126 | if($type == "schema"){ |
| 127 | - xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | - xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 127 | + xml_set_element_handler($this->parser, 'schemaStartElement','schemaEndElement'); |
|
| 128 | + xml_set_character_data_handler($this->parser,'schemaCharacterData'); |
|
| 129 | 129 | } elseif($type == "xml"){ |
| 130 | 130 | xml_set_element_handler($this->parser, 'xmlStartElement','xmlEndElement'); |
| 131 | - xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 131 | + xml_set_character_data_handler($this->parser,'xmlCharacterData'); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - // Parse the XML file. |
|
| 135 | - if(!xml_parse($this->parser,$xml,true)){ |
|
| 134 | + // Parse the XML file. |
|
| 135 | + if(!xml_parse($this->parser,$xml,true)){ |
|
| 136 | 136 | // Display an error message. |
| 137 | 137 | $errstr = sprintf('XML error parsing XML schema on line %d: %s', |
| 138 | 138 | xml_get_current_line_number($this->parser), |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $this->debug($errstr); |
| 142 | 142 | $this->debug("XML payload:\n" . $xml); |
| 143 | 143 | $this->setError($errstr); |
| 144 | - } |
|
| 144 | + } |
|
| 145 | 145 | |
| 146 | 146 | xml_parser_free($this->parser); |
| 147 | 147 | } else{ |
@@ -166,13 +166,13 @@ discard block |
||
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
| 169 | - * start-element handler |
|
| 170 | - * |
|
| 171 | - * @param string $parser XML parser object |
|
| 172 | - * @param string $name element name |
|
| 173 | - * @param string $attrs associative array of attributes |
|
| 174 | - * @access private |
|
| 175 | - */ |
|
| 169 | + * start-element handler |
|
| 170 | + * |
|
| 171 | + * @param string $parser XML parser object |
|
| 172 | + * @param string $name element name |
|
| 173 | + * @param string $attrs associative array of attributes |
|
| 174 | + * @access private |
|
| 175 | + */ |
|
| 176 | 176 | public function schemaStartElement($parser, $name, $attrs) { |
| 177 | 177 | |
| 178 | 178 | // position in the total number of elements, starting from 0 |
@@ -192,15 +192,15 @@ discard block |
||
| 192 | 192 | // get unqualified name |
| 193 | 193 | $name = $this->getLocalPart($name); |
| 194 | 194 | } else { |
| 195 | - $prefix = ''; |
|
| 196 | - } |
|
| 195 | + $prefix = ''; |
|
| 196 | + } |
|
| 197 | 197 | |
| 198 | - // loop thru attributes, expanding, and registering namespace declarations |
|
| 199 | - if(count($attrs) > 0){ |
|
| 200 | - foreach($attrs as $k => $v){ |
|
| 201 | - // if ns declarations, add to class level array of valid namespaces |
|
| 198 | + // loop thru attributes, expanding, and registering namespace declarations |
|
| 199 | + if(count($attrs) > 0){ |
|
| 200 | + foreach($attrs as $k => $v){ |
|
| 201 | + // if ns declarations, add to class level array of valid namespaces |
|
| 202 | 202 | if(preg_match('/^xmlns/',$k)){ |
| 203 | - if($ns_prefix = substr(strrchr($k,':'),1)){ |
|
| 203 | + if($ns_prefix = substr(strrchr($k,':'),1)){ |
|
| 204 | 204 | $this->namespaces[$ns_prefix] = $v; |
| 205 | 205 | } else { |
| 206 | 206 | $this->defaultNamespace[$pos] = $v; |
@@ -213,17 +213,17 @@ discard block |
||
| 213 | 213 | $this->namespaces['xsi'] = $v.'-instance'; |
| 214 | 214 | } |
| 215 | 215 | } |
| 216 | - } |
|
| 217 | - foreach($attrs as $k => $v){ |
|
| 218 | - // expand each attribute |
|
| 219 | - $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 220 | - $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 221 | - $eAttrs[$k] = $v; |
|
| 222 | - } |
|
| 223 | - $attrs = $eAttrs; |
|
| 224 | - } else { |
|
| 225 | - $attrs = array(); |
|
| 226 | - } |
|
| 216 | + } |
|
| 217 | + foreach($attrs as $k => $v){ |
|
| 218 | + // expand each attribute |
|
| 219 | + $k = strpos($k,':') ? $this->expandQname($k) : $k; |
|
| 220 | + $v = strpos($v,':') ? $this->expandQname($v) : $v; |
|
| 221 | + $eAttrs[$k] = $v; |
|
| 222 | + } |
|
| 223 | + $attrs = $eAttrs; |
|
| 224 | + } else { |
|
| 225 | + $attrs = array(); |
|
| 226 | + } |
|
| 227 | 227 | // find status, register data |
| 228 | 228 | switch($name){ |
| 229 | 229 | case 'all': // (optional) compositor content for a complexType |
@@ -234,12 +234,12 @@ discard block |
||
| 234 | 234 | |
| 235 | 235 | break; |
| 236 | 236 | case 'attribute': // complexType attribute |
| 237 | - $this->xdebug("parsing attribute:"); |
|
| 238 | - $this->appendDebug($this->varDump($attrs)); |
|
| 237 | + $this->xdebug("parsing attribute:"); |
|
| 238 | + $this->appendDebug($this->varDump($attrs)); |
|
| 239 | 239 | if (!isset($attrs['form'])) { |
| 240 | 240 | $attrs['form'] = $this->schemaInfo['attributeFormDefault']; |
| 241 | 241 | } |
| 242 | - if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { |
|
| 242 | + if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { |
|
| 243 | 243 | $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 244 | 244 | if (!strpos($v, ':')) { |
| 245 | 245 | // no namespace in arrayType attribute value... |
@@ -248,19 +248,19 @@ discard block |
||
| 248 | 248 | $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'] = $this->defaultNamespace[$pos] . ':' . $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 249 | 249 | } |
| 250 | 250 | } |
| 251 | - } |
|
| 252 | - if(isset($attrs['name'])){ |
|
| 251 | + } |
|
| 252 | + if(isset($attrs['name'])){ |
|
| 253 | 253 | $this->attributes[$attrs['name']] = $attrs; |
| 254 | 254 | $aname = $attrs['name']; |
| 255 | 255 | } elseif(isset($attrs['ref']) && $attrs['ref'] == 'http://schemas.xmlsoap.org/soap/encoding/:arrayType'){ |
| 256 | 256 | if (isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])) { |
| 257 | - $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 258 | - } else { |
|
| 259 | - $aname = ''; |
|
| 260 | - } |
|
| 257 | + $aname = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
|
| 258 | + } else { |
|
| 259 | + $aname = ''; |
|
| 260 | + } |
|
| 261 | 261 | } elseif(isset($attrs['ref'])){ |
| 262 | 262 | $aname = $attrs['ref']; |
| 263 | - $this->attributes[$attrs['ref']] = $attrs; |
|
| 263 | + $this->attributes[$attrs['ref']] = $attrs; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | if($this->currentComplexType){ // This should *always* be |
@@ -269,20 +269,20 @@ discard block |
||
| 269 | 269 | // arrayType attribute |
| 270 | 270 | if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']) || $this->getLocalPart($aname) == 'arrayType'){ |
| 271 | 271 | $this->complexTypes[$this->currentComplexType]['phpType'] = 'array'; |
| 272 | - $prefix = $this->getPrefix($aname); |
|
| 272 | + $prefix = $this->getPrefix($aname); |
|
| 273 | 273 | if(isset($attrs['http://schemas.xmlsoap.org/wsdl/:arrayType'])){ |
| 274 | 274 | $v = $attrs['http://schemas.xmlsoap.org/wsdl/:arrayType']; |
| 275 | 275 | } else { |
| 276 | 276 | $v = ''; |
| 277 | 277 | } |
| 278 | - if(strpos($v,'[,]')){ |
|
| 279 | - $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
|
| 280 | - } |
|
| 281 | - $v = substr($v,0,strpos($v,'[')); // clip the [] |
|
| 282 | - if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){ |
|
| 283 | - $v = $this->XMLSchemaVersion.':'.$v; |
|
| 284 | - } |
|
| 285 | - $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
|
| 278 | + if(strpos($v,'[,]')){ |
|
| 279 | + $this->complexTypes[$this->currentComplexType]['multidimensional'] = true; |
|
| 280 | + } |
|
| 281 | + $v = substr($v,0,strpos($v,'[')); // clip the [] |
|
| 282 | + if(!strpos($v,':') && isset($this->typemap[$this->XMLSchemaVersion][$v])){ |
|
| 283 | + $v = $this->XMLSchemaVersion.':'.$v; |
|
| 284 | + } |
|
| 285 | + $this->complexTypes[$this->currentComplexType]['arrayType'] = $v; |
|
| 286 | 286 | } |
| 287 | 287 | break; |
| 288 | 288 | case 'complexContent': // (optional) content for a complexType |
@@ -396,21 +396,21 @@ discard block |
||
| 396 | 396 | } |
| 397 | 397 | break; |
| 398 | 398 | case 'import': |
| 399 | - if (isset($attrs['schemaLocation'])) { |
|
| 399 | + if (isset($attrs['schemaLocation'])) { |
|
| 400 | 400 | $this->xdebug('import namespace ' . $attrs['namespace'] . ' from ' . $attrs['schemaLocation']); |
| 401 | - $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); |
|
| 401 | + $this->imports[$attrs['namespace']][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); |
|
| 402 | 402 | } else { |
| 403 | 403 | $this->xdebug('import namespace ' . $attrs['namespace']); |
| 404 | - $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
|
| 404 | + $this->imports[$attrs['namespace']][] = array('location' => '', 'loaded' => true); |
|
| 405 | 405 | if (! $this->getPrefixFromNamespace($attrs['namespace'])) { |
| 406 | 406 | $this->namespaces['ns'.(count($this->namespaces)+1)] = $attrs['namespace']; |
| 407 | 407 | } |
| 408 | 408 | } |
| 409 | 409 | break; |
| 410 | 410 | case 'include': |
| 411 | - if (isset($attrs['schemaLocation'])) { |
|
| 411 | + if (isset($attrs['schemaLocation'])) { |
|
| 412 | 412 | $this->xdebug('include into namespace ' . $this->schemaTargetNamespace . ' from ' . $attrs['schemaLocation']); |
| 413 | - $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); |
|
| 413 | + $this->imports[$this->schemaTargetNamespace][] = array('location' => $attrs['schemaLocation'], 'loaded' => false); |
|
| 414 | 414 | } else { |
| 415 | 415 | $this->xdebug('ignoring invalid XML Schema construct: include without schemaLocation attribute'); |
| 416 | 416 | } |
@@ -474,26 +474,26 @@ discard block |
||
| 474 | 474 | } |
| 475 | 475 | |
| 476 | 476 | /** |
| 477 | - * end-element handler |
|
| 478 | - * |
|
| 479 | - * @param string $parser XML parser object |
|
| 480 | - * @param string $name element name |
|
| 481 | - * @access private |
|
| 482 | - */ |
|
| 477 | + * end-element handler |
|
| 478 | + * |
|
| 479 | + * @param string $parser XML parser object |
|
| 480 | + * @param string $name element name |
|
| 481 | + * @access private |
|
| 482 | + */ |
|
| 483 | 483 | public function schemaEndElement($parser, $name) { |
| 484 | 484 | // bring depth down a notch |
| 485 | 485 | $this->depth--; |
| 486 | 486 | // position of current element is equal to the last value left in depth_array for my depth |
| 487 | 487 | if(isset($this->depth_array[$this->depth])){ |
| 488 | - $pos = $this->depth_array[$this->depth]; |
|
| 489 | - } |
|
| 488 | + $pos = $this->depth_array[$this->depth]; |
|
| 489 | + } |
|
| 490 | 490 | // get element prefix |
| 491 | 491 | if ($prefix = $this->getPrefix($name)){ |
| 492 | 492 | // get unqualified name |
| 493 | 493 | $name = $this->getLocalPart($name); |
| 494 | 494 | } else { |
| 495 | - $prefix = ''; |
|
| 496 | - } |
|
| 495 | + $prefix = ''; |
|
| 496 | + } |
|
| 497 | 497 | // move on... |
| 498 | 498 | if($name == 'complexType'){ |
| 499 | 499 | $this->xdebug('done processing complexType ' . ($this->currentComplexType ? $this->currentComplexType : '(unknown)')); |
@@ -512,22 +512,22 @@ discard block |
||
| 512 | 512 | } |
| 513 | 513 | |
| 514 | 514 | /** |
| 515 | - * element content handler |
|
| 516 | - * |
|
| 517 | - * @param string $parser XML parser object |
|
| 518 | - * @param string $data element content |
|
| 519 | - * @access private |
|
| 520 | - */ |
|
| 515 | + * element content handler |
|
| 516 | + * |
|
| 517 | + * @param string $parser XML parser object |
|
| 518 | + * @param string $data element content |
|
| 519 | + * @access private |
|
| 520 | + */ |
|
| 521 | 521 | public function schemaCharacterData($parser, $data){ |
| 522 | 522 | $pos = $this->depth_array[$this->depth - 1]; |
| 523 | 523 | $this->message[$pos]['cdata'] .= $data; |
| 524 | 524 | } |
| 525 | 525 | |
| 526 | 526 | /** |
| 527 | - * serialize the schema |
|
| 528 | - * |
|
| 529 | - * @access public |
|
| 530 | - */ |
|
| 527 | + * serialize the schema |
|
| 528 | + * |
|
| 529 | + * @access public |
|
| 530 | + */ |
|
| 531 | 531 | public function serializeSchema(){ |
| 532 | 532 | |
| 533 | 533 | $schemaPrefix = $this->getPrefixFromNamespace($this->XMLSchemaVersion); |
@@ -641,27 +641,27 @@ discard block |
||
| 641 | 641 | } |
| 642 | 642 | |
| 643 | 643 | /** |
| 644 | - * adds debug data to the clas level debug string |
|
| 645 | - * |
|
| 646 | - * @param string $string debug data |
|
| 647 | - * @access private |
|
| 648 | - */ |
|
| 644 | + * adds debug data to the clas level debug string |
|
| 645 | + * |
|
| 646 | + * @param string $string debug data |
|
| 647 | + * @access private |
|
| 648 | + */ |
|
| 649 | 649 | public function xdebug($string){ |
| 650 | 650 | $this->debug('<' . $this->schemaTargetNamespace . '> '.$string); |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | - /** |
|
| 654 | - * get the PHP type of a user defined type in the schema |
|
| 655 | - * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 656 | - * returns false if no type exists, or not w/ the given namespace |
|
| 657 | - * else returns a string that is either a native php type, or 'struct' |
|
| 658 | - * |
|
| 659 | - * @param string $type name of defined type |
|
| 660 | - * @param string $ns namespace of type |
|
| 661 | - * @return mixed |
|
| 662 | - * @access public |
|
| 663 | - * @deprecated |
|
| 664 | - */ |
|
| 653 | + /** |
|
| 654 | + * get the PHP type of a user defined type in the schema |
|
| 655 | + * PHP type is kind of a misnomer since it actually returns 'struct' for assoc. arrays |
|
| 656 | + * returns false if no type exists, or not w/ the given namespace |
|
| 657 | + * else returns a string that is either a native php type, or 'struct' |
|
| 658 | + * |
|
| 659 | + * @param string $type name of defined type |
|
| 660 | + * @param string $ns namespace of type |
|
| 661 | + * @return mixed |
|
| 662 | + * @access public |
|
| 663 | + * @deprecated |
|
| 664 | + */ |
|
| 665 | 665 | public function getPHPType($type,$ns){ |
| 666 | 666 | if(isset($this->typemap[$ns][$type])){ |
| 667 | 667 | //print "found type '$type' and ns $ns in typemap<br>"; |
@@ -674,27 +674,27 @@ discard block |
||
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | /** |
| 677 | - * returns an associative array of information about a given type |
|
| 678 | - * returns false if no type exists by the given name |
|
| 679 | - * |
|
| 680 | - * For a complexType typeDef = array( |
|
| 681 | - * 'restrictionBase' => '', |
|
| 682 | - * 'phpType' => '', |
|
| 683 | - * 'compositor' => '(sequence|all)', |
|
| 684 | - * 'elements' => array(), // refs to elements array |
|
| 685 | - * 'attrs' => array() // refs to attributes array |
|
| 686 | - * ... and so on (see addComplexType) |
|
| 687 | - * ) |
|
| 688 | - * |
|
| 689 | - * For simpleType or element, the array has different keys. |
|
| 690 | - * |
|
| 691 | - * @param string $type |
|
| 692 | - * @return mixed |
|
| 693 | - * @access public |
|
| 694 | - * @see addComplexType |
|
| 695 | - * @see addSimpleType |
|
| 696 | - * @see addElement |
|
| 697 | - */ |
|
| 677 | + * returns an associative array of information about a given type |
|
| 678 | + * returns false if no type exists by the given name |
|
| 679 | + * |
|
| 680 | + * For a complexType typeDef = array( |
|
| 681 | + * 'restrictionBase' => '', |
|
| 682 | + * 'phpType' => '', |
|
| 683 | + * 'compositor' => '(sequence|all)', |
|
| 684 | + * 'elements' => array(), // refs to elements array |
|
| 685 | + * 'attrs' => array() // refs to attributes array |
|
| 686 | + * ... and so on (see addComplexType) |
|
| 687 | + * ) |
|
| 688 | + * |
|
| 689 | + * For simpleType or element, the array has different keys. |
|
| 690 | + * |
|
| 691 | + * @param string $type |
|
| 692 | + * @return mixed |
|
| 693 | + * @access public |
|
| 694 | + * @see addComplexType |
|
| 695 | + * @see addSimpleType |
|
| 696 | + * @see addElement |
|
| 697 | + */ |
|
| 698 | 698 | public function getTypeDef($type){ |
| 699 | 699 | if (substr($type, -1) == '^') { |
| 700 | 700 | $is_element = 1; |
@@ -764,49 +764,49 @@ discard block |
||
| 764 | 764 | } |
| 765 | 765 | |
| 766 | 766 | /** |
| 767 | - * returns a sample serialization of a given type, or false if no type by the given name |
|
| 768 | - * |
|
| 769 | - * @param string $type name of type |
|
| 770 | - * @return mixed |
|
| 771 | - * @access public |
|
| 772 | - * @deprecated |
|
| 773 | - */ |
|
| 774 | - public function serializeTypeDef($type){ |
|
| 775 | - //print "in sTD() for type $type<br>"; |
|
| 767 | + * returns a sample serialization of a given type, or false if no type by the given name |
|
| 768 | + * |
|
| 769 | + * @param string $type name of type |
|
| 770 | + * @return mixed |
|
| 771 | + * @access public |
|
| 772 | + * @deprecated |
|
| 773 | + */ |
|
| 774 | + public function serializeTypeDef($type){ |
|
| 775 | + //print "in sTD() for type $type<br>"; |
|
| 776 | 776 | if($typeDef = $this->getTypeDef($type)){ |
| 777 | 777 | $str .= '<'.$type; |
| 778 | - if(is_array($typeDef['attrs'])){ |
|
| 778 | + if(is_array($typeDef['attrs'])){ |
|
| 779 | 779 | foreach($typeDef['attrs'] as $attName => $data){ |
| 780 | - $str .= " $attName=\"{type = ".$data['type']."}\""; |
|
| 780 | + $str .= " $attName=\"{type = ".$data['type']."}\""; |
|
| 781 | 781 | } |
| 782 | - } |
|
| 783 | - $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 784 | - if(count($typeDef['elements']) > 0){ |
|
| 782 | + } |
|
| 783 | + $str .= " xmlns=\"".$this->schema['targetNamespace']."\""; |
|
| 784 | + if(count($typeDef['elements']) > 0){ |
|
| 785 | 785 | $str .= ">"; |
| 786 | 786 | foreach($typeDef['elements'] as $element => $eData){ |
| 787 | - $str .= $this->serializeTypeDef($element); |
|
| 787 | + $str .= $this->serializeTypeDef($element); |
|
| 788 | 788 | } |
| 789 | 789 | $str .= "</$type>"; |
| 790 | - } elseif($typeDef['typeClass'] == 'element') { |
|
| 790 | + } elseif($typeDef['typeClass'] == 'element') { |
|
| 791 | 791 | $str .= "></$type>"; |
| 792 | - } else { |
|
| 792 | + } else { |
|
| 793 | 793 | $str .= "/>"; |
| 794 | - } |
|
| 794 | + } |
|
| 795 | 795 | return $str; |
| 796 | 796 | } |
| 797 | - return false; |
|
| 798 | - } |
|
| 797 | + return false; |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | - /** |
|
| 801 | - * returns HTML form elements that allow a user |
|
| 802 | - * to enter values for creating an instance of the given type. |
|
| 803 | - * |
|
| 804 | - * @param string $name name for type instance |
|
| 805 | - * @param string $type name of type |
|
| 806 | - * @return string |
|
| 807 | - * @access public |
|
| 808 | - * @deprecated |
|
| 809 | - */ |
|
| 800 | + /** |
|
| 801 | + * returns HTML form elements that allow a user |
|
| 802 | + * to enter values for creating an instance of the given type. |
|
| 803 | + * |
|
| 804 | + * @param string $name name for type instance |
|
| 805 | + * @param string $type name of type |
|
| 806 | + * @return string |
|
| 807 | + * @access public |
|
| 808 | + * @deprecated |
|
| 809 | + */ |
|
| 810 | 810 | public function typeToForm($name,$type){ |
| 811 | 811 | // get typedef |
| 812 | 812 | if($typeDef = $this->getTypeDef($type)){ |
@@ -839,56 +839,56 @@ discard block |
||
| 839 | 839 | } |
| 840 | 840 | |
| 841 | 841 | /** |
| 842 | - * adds a complex type to the schema |
|
| 843 | - * |
|
| 844 | - * example: array |
|
| 845 | - * |
|
| 846 | - * addType( |
|
| 847 | - * 'ArrayOfstring', |
|
| 848 | - * 'complexType', |
|
| 849 | - * 'array', |
|
| 850 | - * '', |
|
| 851 | - * 'SOAP-ENC:Array', |
|
| 852 | - * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), |
|
| 853 | - * 'xsd:string' |
|
| 854 | - * ); |
|
| 855 | - * |
|
| 856 | - * example: PHP associative array ( SOAP Struct ) |
|
| 857 | - * |
|
| 858 | - * addType( |
|
| 859 | - * 'SOAPStruct', |
|
| 860 | - * 'complexType', |
|
| 861 | - * 'struct', |
|
| 862 | - * 'all', |
|
| 863 | - * array('myVar'=> array('name'=>'myVar','type'=>'string') |
|
| 864 | - * ); |
|
| 865 | - * |
|
| 866 | - * @param name |
|
| 867 | - * @param typeClass (complexType|simpleType|attribute) |
|
| 868 | - * @param phpType: currently supported are array and struct (php assoc array) |
|
| 869 | - * @param compositor (all|sequence|choice) |
|
| 870 | - * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 871 | - * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 872 | - * @param attrs = array( |
|
| 873 | - * array( |
|
| 874 | - * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 875 | - * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 876 | - * ) |
|
| 877 | - * ) |
|
| 878 | - * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 879 | - * @access public |
|
| 880 | - * @see getTypeDef |
|
| 881 | - */ |
|
| 842 | + * adds a complex type to the schema |
|
| 843 | + * |
|
| 844 | + * example: array |
|
| 845 | + * |
|
| 846 | + * addType( |
|
| 847 | + * 'ArrayOfstring', |
|
| 848 | + * 'complexType', |
|
| 849 | + * 'array', |
|
| 850 | + * '', |
|
| 851 | + * 'SOAP-ENC:Array', |
|
| 852 | + * array('ref'=>'SOAP-ENC:arrayType','wsdl:arrayType'=>'string[]'), |
|
| 853 | + * 'xsd:string' |
|
| 854 | + * ); |
|
| 855 | + * |
|
| 856 | + * example: PHP associative array ( SOAP Struct ) |
|
| 857 | + * |
|
| 858 | + * addType( |
|
| 859 | + * 'SOAPStruct', |
|
| 860 | + * 'complexType', |
|
| 861 | + * 'struct', |
|
| 862 | + * 'all', |
|
| 863 | + * array('myVar'=> array('name'=>'myVar','type'=>'string') |
|
| 864 | + * ); |
|
| 865 | + * |
|
| 866 | + * @param name |
|
| 867 | + * @param typeClass (complexType|simpleType|attribute) |
|
| 868 | + * @param phpType: currently supported are array and struct (php assoc array) |
|
| 869 | + * @param compositor (all|sequence|choice) |
|
| 870 | + * @param restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 871 | + * @param elements = array ( name = array(name=>'',type=>'') ) |
|
| 872 | + * @param attrs = array( |
|
| 873 | + * array( |
|
| 874 | + * 'ref' => "http://schemas.xmlsoap.org/soap/encoding/:arrayType", |
|
| 875 | + * "http://schemas.xmlsoap.org/wsdl/:arrayType" => "string[]" |
|
| 876 | + * ) |
|
| 877 | + * ) |
|
| 878 | + * @param arrayType: namespace:name (http://www.w3.org/2001/XMLSchema:string) |
|
| 879 | + * @access public |
|
| 880 | + * @see getTypeDef |
|
| 881 | + */ |
|
| 882 | 882 | public function addComplexType($name,$typeClass='complexType',$phpType='array',$compositor='',$restrictionBase='',$elements=array(),$attrs=array(),$arrayType=''){ |
| 883 | 883 | $this->complexTypes[$name] = array( |
| 884 | - 'name' => $name, |
|
| 885 | - 'typeClass' => $typeClass, |
|
| 886 | - 'phpType' => $phpType, |
|
| 884 | + 'name' => $name, |
|
| 885 | + 'typeClass' => $typeClass, |
|
| 886 | + 'phpType' => $phpType, |
|
| 887 | 887 | 'compositor'=> $compositor, |
| 888 | - 'restrictionBase' => $restrictionBase, |
|
| 888 | + 'restrictionBase' => $restrictionBase, |
|
| 889 | 889 | 'elements' => $elements, |
| 890 | - 'attrs' => $attrs, |
|
| 891 | - 'arrayType' => $arrayType |
|
| 890 | + 'attrs' => $attrs, |
|
| 891 | + 'arrayType' => $arrayType |
|
| 892 | 892 | ); |
| 893 | 893 | |
| 894 | 894 | $this->xdebug("addComplexType $name:"); |
@@ -896,24 +896,24 @@ discard block |
||
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | /** |
| 899 | - * adds a simple type to the schema |
|
| 900 | - * |
|
| 901 | - * @param string $name |
|
| 902 | - * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 903 | - * @param string $typeClass (should always be simpleType) |
|
| 904 | - * @param string $phpType (should always be scalar) |
|
| 905 | - * @param array $enumeration array of values |
|
| 906 | - * @access public |
|
| 907 | - * @see nusoap_xmlschema |
|
| 908 | - * @see getTypeDef |
|
| 909 | - */ |
|
| 899 | + * adds a simple type to the schema |
|
| 900 | + * |
|
| 901 | + * @param string $name |
|
| 902 | + * @param string $restrictionBase namespace:name (http://schemas.xmlsoap.org/soap/encoding/:Array) |
|
| 903 | + * @param string $typeClass (should always be simpleType) |
|
| 904 | + * @param string $phpType (should always be scalar) |
|
| 905 | + * @param array $enumeration array of values |
|
| 906 | + * @access public |
|
| 907 | + * @see nusoap_xmlschema |
|
| 908 | + * @see getTypeDef |
|
| 909 | + */ |
|
| 910 | 910 | public function addSimpleType($name, $restrictionBase='', $typeClass='simpleType', $phpType='scalar', $enumeration=array()) { |
| 911 | 911 | $this->simpleTypes[$name] = array( |
| 912 | - 'name' => $name, |
|
| 913 | - 'typeClass' => $typeClass, |
|
| 914 | - 'phpType' => $phpType, |
|
| 915 | - 'type' => $restrictionBase, |
|
| 916 | - 'enumeration' => $enumeration |
|
| 912 | + 'name' => $name, |
|
| 913 | + 'typeClass' => $typeClass, |
|
| 914 | + 'phpType' => $phpType, |
|
| 915 | + 'type' => $restrictionBase, |
|
| 916 | + 'enumeration' => $enumeration |
|
| 917 | 917 | ); |
| 918 | 918 | |
| 919 | 919 | $this->xdebug("addSimpleType $name:"); |
@@ -921,12 +921,12 @@ discard block |
||
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
| 924 | - * adds an element to the schema |
|
| 925 | - * |
|
| 926 | - * @param array $attrs attributes that must include name and type |
|
| 927 | - * @see nusoap_xmlschema |
|
| 928 | - * @access public |
|
| 929 | - */ |
|
| 924 | + * adds an element to the schema |
|
| 925 | + * |
|
| 926 | + * @param array $attrs attributes that must include name and type |
|
| 927 | + * @see nusoap_xmlschema |
|
| 928 | + * @access public |
|
| 929 | + */ |
|
| 930 | 930 | public function addElement($attrs) { |
| 931 | 931 | if (! $this->getPrefix($attrs['type'])) { |
| 932 | 932 | $attrs['type'] = $this->schemaTargetNamespace . ':' . $attrs['type']; |
@@ -71,20 +71,20 @@ discard block |
||
| 71 | 71 | var $mimeContentType; |
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | - * adds a MIME attachment to the current request. |
|
| 75 | - * |
|
| 76 | - * If the $data parameter contains an empty string, this method will read |
|
| 77 | - * the contents of the file named by the $filename parameter. |
|
| 78 | - * |
|
| 79 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | - * |
|
| 81 | - * @param string $data The data of the attachment |
|
| 82 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | - * @return string The content-id (cid) of the attachment |
|
| 86 | - * @access public |
|
| 87 | - */ |
|
| 74 | + * adds a MIME attachment to the current request. |
|
| 75 | + * |
|
| 76 | + * If the $data parameter contains an empty string, this method will read |
|
| 77 | + * the contents of the file named by the $filename parameter. |
|
| 78 | + * |
|
| 79 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 80 | + * |
|
| 81 | + * @param string $data The data of the attachment |
|
| 82 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 83 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 84 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 85 | + * @return string The content-id (cid) of the attachment |
|
| 86 | + * @access public |
|
| 87 | + */ |
|
| 88 | 88 | public function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { |
| 89 | 89 | if (! $cid) { |
| 90 | 90 | $cid = md5(uniqid(time())); |
@@ -101,35 +101,35 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | /** |
| 104 | - * clears the MIME attachments for the current request. |
|
| 105 | - * |
|
| 106 | - * @access public |
|
| 107 | - */ |
|
| 104 | + * clears the MIME attachments for the current request. |
|
| 105 | + * |
|
| 106 | + * @access public |
|
| 107 | + */ |
|
| 108 | 108 | public function clearAttachments() { |
| 109 | 109 | $this->requestAttachments = array(); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | /** |
| 113 | - * gets the MIME attachments from the current response. |
|
| 114 | - * |
|
| 115 | - * Each array element in the return is an associative array with keys |
|
| 116 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | - * for addAttachment. |
|
| 118 | - * |
|
| 119 | - * @return array The attachments. |
|
| 120 | - * @access public |
|
| 121 | - */ |
|
| 113 | + * gets the MIME attachments from the current response. |
|
| 114 | + * |
|
| 115 | + * Each array element in the return is an associative array with keys |
|
| 116 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 117 | + * for addAttachment. |
|
| 118 | + * |
|
| 119 | + * @return array The attachments. |
|
| 120 | + * @access public |
|
| 121 | + */ |
|
| 122 | 122 | public function getAttachments() { |
| 123 | 123 | return $this->responseAttachments; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | /** |
| 127 | - * gets the HTTP body for the current request. |
|
| 128 | - * |
|
| 129 | - * @param string $soapmsg The SOAP payload |
|
| 130 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | - * @access private |
|
| 132 | - */ |
|
| 127 | + * gets the HTTP body for the current request. |
|
| 128 | + * |
|
| 129 | + * @param string $soapmsg The SOAP payload |
|
| 130 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 131 | + * @access private |
|
| 132 | + */ |
|
| 133 | 133 | public function getHTTPBody($soapmsg) { |
| 134 | 134 | if (count($this->requestAttachments) > 0) { |
| 135 | 135 | $params['content_type'] = 'multipart/related; type="text/xml"'; |
@@ -182,13 +182,13 @@ discard block |
||
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | /** |
| 185 | - * gets the HTTP content type for the current request. |
|
| 186 | - * |
|
| 187 | - * Note: getHTTPBody must be called before this. |
|
| 188 | - * |
|
| 189 | - * @return string the HTTP content type for the current request. |
|
| 190 | - * @access private |
|
| 191 | - */ |
|
| 185 | + * gets the HTTP content type for the current request. |
|
| 186 | + * |
|
| 187 | + * Note: getHTTPBody must be called before this. |
|
| 188 | + * |
|
| 189 | + * @return string the HTTP content type for the current request. |
|
| 190 | + * @access private |
|
| 191 | + */ |
|
| 192 | 192 | public function getHTTPContentType() { |
| 193 | 193 | if (count($this->requestAttachments) > 0) { |
| 194 | 194 | return $this->mimeContentType; |
@@ -197,14 +197,14 @@ discard block |
||
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | /** |
| 200 | - * gets the HTTP content type charset for the current request. |
|
| 201 | - * returns false for non-text content types. |
|
| 202 | - * |
|
| 203 | - * Note: getHTTPBody must be called before this. |
|
| 204 | - * |
|
| 205 | - * @return string the HTTP content type charset for the current request. |
|
| 206 | - * @access private |
|
| 207 | - */ |
|
| 200 | + * gets the HTTP content type charset for the current request. |
|
| 201 | + * returns false for non-text content types. |
|
| 202 | + * |
|
| 203 | + * Note: getHTTPBody must be called before this. |
|
| 204 | + * |
|
| 205 | + * @return string the HTTP content type charset for the current request. |
|
| 206 | + * @access private |
|
| 207 | + */ |
|
| 208 | 208 | public function getHTTPContentTypeCharset() { |
| 209 | 209 | if (count($this->requestAttachments) > 0) { |
| 210 | 210 | return false; |
@@ -213,14 +213,14 @@ discard block |
||
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | /** |
| 216 | - * processes SOAP message returned from server |
|
| 217 | - * |
|
| 218 | - * @param array $headers The HTTP headers |
|
| 219 | - * @param string $data unprocessed response data from server |
|
| 220 | - * @return mixed value of the message, decoded into a PHP type |
|
| 221 | - * @access private |
|
| 222 | - */ |
|
| 223 | - public function parseResponse($headers, $data) { |
|
| 216 | + * processes SOAP message returned from server |
|
| 217 | + * |
|
| 218 | + * @param array $headers The HTTP headers |
|
| 219 | + * @param string $data unprocessed response data from server |
|
| 220 | + * @return mixed value of the message, decoded into a PHP type |
|
| 221 | + * @access private |
|
| 222 | + */ |
|
| 223 | + public function parseResponse($headers, $data) { |
|
| 224 | 224 | $this->debug('Entering parseResponse() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); |
| 225 | 225 | $this->responseAttachments = array(); |
| 226 | 226 | if (strstr($headers['content-type'], 'multipart/related')) { |
@@ -301,20 +301,20 @@ discard block |
||
| 301 | 301 | var $mimeContentType; |
| 302 | 302 | |
| 303 | 303 | /** |
| 304 | - * adds a MIME attachment to the current response. |
|
| 305 | - * |
|
| 306 | - * If the $data parameter contains an empty string, this method will read |
|
| 307 | - * the contents of the file named by the $filename parameter. |
|
| 308 | - * |
|
| 309 | - * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | - * |
|
| 311 | - * @param string $data The data of the attachment |
|
| 312 | - * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | - * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | - * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | - * @return string The content-id (cid) of the attachment |
|
| 316 | - * @access public |
|
| 317 | - */ |
|
| 304 | + * adds a MIME attachment to the current response. |
|
| 305 | + * |
|
| 306 | + * If the $data parameter contains an empty string, this method will read |
|
| 307 | + * the contents of the file named by the $filename parameter. |
|
| 308 | + * |
|
| 309 | + * If the $cid parameter is false, this method will generate the cid. |
|
| 310 | + * |
|
| 311 | + * @param string $data The data of the attachment |
|
| 312 | + * @param string $filename The filename of the attachment (default is empty string) |
|
| 313 | + * @param string $contenttype The MIME Content-Type of the attachment (default is application/octet-stream) |
|
| 314 | + * @param string $cid The content-id (cid) of the attachment (default is false) |
|
| 315 | + * @return string The content-id (cid) of the attachment |
|
| 316 | + * @access public |
|
| 317 | + */ |
|
| 318 | 318 | public function addAttachment($data, $filename = '', $contenttype = 'application/octet-stream', $cid = false) { |
| 319 | 319 | if (! $cid) { |
| 320 | 320 | $cid = md5(uniqid(time())); |
@@ -331,35 +331,35 @@ discard block |
||
| 331 | 331 | } |
| 332 | 332 | |
| 333 | 333 | /** |
| 334 | - * clears the MIME attachments for the current response. |
|
| 335 | - * |
|
| 336 | - * @access public |
|
| 337 | - */ |
|
| 334 | + * clears the MIME attachments for the current response. |
|
| 335 | + * |
|
| 336 | + * @access public |
|
| 337 | + */ |
|
| 338 | 338 | public function clearAttachments() { |
| 339 | 339 | $this->responseAttachments = array(); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | 342 | /** |
| 343 | - * gets the MIME attachments from the current request. |
|
| 344 | - * |
|
| 345 | - * Each array element in the return is an associative array with keys |
|
| 346 | - * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | - * for addAttachment. |
|
| 348 | - * |
|
| 349 | - * @return array The attachments. |
|
| 350 | - * @access public |
|
| 351 | - */ |
|
| 343 | + * gets the MIME attachments from the current request. |
|
| 344 | + * |
|
| 345 | + * Each array element in the return is an associative array with keys |
|
| 346 | + * data, filename, contenttype, cid. These keys correspond to the parameters |
|
| 347 | + * for addAttachment. |
|
| 348 | + * |
|
| 349 | + * @return array The attachments. |
|
| 350 | + * @access public |
|
| 351 | + */ |
|
| 352 | 352 | public function getAttachments() { |
| 353 | 353 | return $this->requestAttachments; |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | /** |
| 357 | - * gets the HTTP body for the current response. |
|
| 358 | - * |
|
| 359 | - * @param string $soapmsg The SOAP payload |
|
| 360 | - * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | - * @access private |
|
| 362 | - */ |
|
| 357 | + * gets the HTTP body for the current response. |
|
| 358 | + * |
|
| 359 | + * @param string $soapmsg The SOAP payload |
|
| 360 | + * @return string The HTTP body, which includes the SOAP payload |
|
| 361 | + * @access private |
|
| 362 | + */ |
|
| 363 | 363 | public function getHTTPBody($soapmsg) { |
| 364 | 364 | if (count($this->responseAttachments) > 0) { |
| 365 | 365 | $params['content_type'] = 'multipart/related; type="text/xml"'; |
@@ -412,13 +412,13 @@ discard block |
||
| 412 | 412 | } |
| 413 | 413 | |
| 414 | 414 | /** |
| 415 | - * gets the HTTP content type for the current response. |
|
| 416 | - * |
|
| 417 | - * Note: getHTTPBody must be called before this. |
|
| 418 | - * |
|
| 419 | - * @return string the HTTP content type for the current response. |
|
| 420 | - * @access private |
|
| 421 | - */ |
|
| 415 | + * gets the HTTP content type for the current response. |
|
| 416 | + * |
|
| 417 | + * Note: getHTTPBody must be called before this. |
|
| 418 | + * |
|
| 419 | + * @return string the HTTP content type for the current response. |
|
| 420 | + * @access private |
|
| 421 | + */ |
|
| 422 | 422 | public function getHTTPContentType() { |
| 423 | 423 | if (count($this->responseAttachments) > 0) { |
| 424 | 424 | return $this->mimeContentType; |
@@ -427,14 +427,14 @@ discard block |
||
| 427 | 427 | } |
| 428 | 428 | |
| 429 | 429 | /** |
| 430 | - * gets the HTTP content type charset for the current response. |
|
| 431 | - * returns false for non-text content types. |
|
| 432 | - * |
|
| 433 | - * Note: getHTTPBody must be called before this. |
|
| 434 | - * |
|
| 435 | - * @return string the HTTP content type charset for the current response. |
|
| 436 | - * @access private |
|
| 437 | - */ |
|
| 430 | + * gets the HTTP content type charset for the current response. |
|
| 431 | + * returns false for non-text content types. |
|
| 432 | + * |
|
| 433 | + * Note: getHTTPBody must be called before this. |
|
| 434 | + * |
|
| 435 | + * @return string the HTTP content type charset for the current response. |
|
| 436 | + * @access private |
|
| 437 | + */ |
|
| 438 | 438 | public function getHTTPContentTypeCharset() { |
| 439 | 439 | if (count($this->responseAttachments) > 0) { |
| 440 | 440 | return false; |
@@ -443,14 +443,14 @@ discard block |
||
| 443 | 443 | } |
| 444 | 444 | |
| 445 | 445 | /** |
| 446 | - * processes SOAP message received from client |
|
| 447 | - * |
|
| 448 | - * @param array $headers The HTTP headers |
|
| 449 | - * @param string $data unprocessed request data from client |
|
| 450 | - * @return mixed value of the message, decoded into a PHP type |
|
| 451 | - * @access private |
|
| 452 | - */ |
|
| 453 | - public function parseRequest($headers, $data) { |
|
| 446 | + * processes SOAP message received from client |
|
| 447 | + * |
|
| 448 | + * @param array $headers The HTTP headers |
|
| 449 | + * @param string $data unprocessed request data from client |
|
| 450 | + * @return mixed value of the message, decoded into a PHP type |
|
| 451 | + * @access private |
|
| 452 | + */ |
|
| 453 | + public function parseRequest($headers, $data) { |
|
| 454 | 454 | $this->debug('Entering parseRequest() for payload of length ' . strlen($data) . ' and type of ' . $headers['content-type']); |
| 455 | 455 | $this->requestAttachments = array(); |
| 456 | 456 | if (strstr($headers['content-type'], 'multipart/related')) { |
@@ -59,306 +59,306 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | class HTTP_Session_Container_MDB2 extends HTTP_Session_Container |
| 61 | 61 | { |
| 62 | - /** |
|
| 63 | - * MDB2 connection object |
|
| 64 | - * |
|
| 65 | - * @var object MDB2 |
|
| 66 | - * @access private |
|
| 67 | - */ |
|
| 68 | - var $db = null; |
|
| 62 | + /** |
|
| 63 | + * MDB2 connection object |
|
| 64 | + * |
|
| 65 | + * @var object MDB2 |
|
| 66 | + * @access private |
|
| 67 | + */ |
|
| 68 | + var $db = null; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Session data cache id |
|
| 72 | - * |
|
| 73 | - * @var mixed |
|
| 74 | - * @access private |
|
| 75 | - */ |
|
| 76 | - var $crc = false; |
|
| 70 | + /** |
|
| 71 | + * Session data cache id |
|
| 72 | + * |
|
| 73 | + * @var mixed |
|
| 74 | + * @access private |
|
| 75 | + */ |
|
| 76 | + var $crc = false; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Constructor method |
|
| 80 | - * |
|
| 81 | - * $options is an array with the options.<br> |
|
| 82 | - * The options are: |
|
| 83 | - * <ul> |
|
| 84 | - * <li>'dsn' - The DSN string</li> |
|
| 85 | - * <li>'table' - Table with session data, default is 'sessiondata'</li> |
|
| 86 | - * <li>'autooptimize' - Boolean, 'true' to optimize |
|
| 87 | - * the table on garbage collection, default is 'false'.</li> |
|
| 88 | - * </ul> |
|
| 89 | - * |
|
| 90 | - * @param array $options Options |
|
| 91 | - * |
|
| 92 | - * @access public |
|
| 93 | - * @return void |
|
| 94 | - */ |
|
| 95 | - public function HTTP_Session_Container_MDB2($options) |
|
| 96 | - { |
|
| 97 | - $this->_setDefaults(); |
|
| 98 | - if (is_array($options)) { |
|
| 99 | - $this->_parseOptions($options); |
|
| 100 | - } else { |
|
| 101 | - $this->options['dsn'] = $options; |
|
| 102 | - } |
|
| 103 | - } |
|
| 78 | + /** |
|
| 79 | + * Constructor method |
|
| 80 | + * |
|
| 81 | + * $options is an array with the options.<br> |
|
| 82 | + * The options are: |
|
| 83 | + * <ul> |
|
| 84 | + * <li>'dsn' - The DSN string</li> |
|
| 85 | + * <li>'table' - Table with session data, default is 'sessiondata'</li> |
|
| 86 | + * <li>'autooptimize' - Boolean, 'true' to optimize |
|
| 87 | + * the table on garbage collection, default is 'false'.</li> |
|
| 88 | + * </ul> |
|
| 89 | + * |
|
| 90 | + * @param array $options Options |
|
| 91 | + * |
|
| 92 | + * @access public |
|
| 93 | + * @return void |
|
| 94 | + */ |
|
| 95 | + public function HTTP_Session_Container_MDB2($options) |
|
| 96 | + { |
|
| 97 | + $this->_setDefaults(); |
|
| 98 | + if (is_array($options)) { |
|
| 99 | + $this->_parseOptions($options); |
|
| 100 | + } else { |
|
| 101 | + $this->options['dsn'] = $options; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Connect to database by using the given DSN string |
|
| 107 | - * |
|
| 108 | - * @param string $dsn DSN string |
|
| 109 | - * |
|
| 110 | - * @access private |
|
| 111 | - * @return mixed Object on error, otherwise bool |
|
| 112 | - */ |
|
| 113 | - public function _connect($dsn) |
|
| 114 | - { |
|
| 115 | - if (is_string($dsn) || is_array($dsn)) { |
|
| 116 | - $this->db = MDB2::connect($dsn); |
|
| 117 | - } else if (is_object($dsn) && is_a($dsn, 'MDB2_Driver_Common')) { |
|
| 118 | - $this->db = $dsn; |
|
| 119 | - } else if (is_object($dsn) && MDB2::isError($dsn)) { |
|
| 120 | - return $dsn; |
|
| 121 | - } else { |
|
| 122 | - return new PEAR_Error("The given dsn was not valid in file " . __FILE__ |
|
| 123 | - . " at line " . __LINE__, |
|
| 124 | - 41, |
|
| 125 | - PEAR_ERROR_RETURN, |
|
| 126 | - null, |
|
| 127 | - null |
|
| 128 | - ); |
|
| 105 | + /** |
|
| 106 | + * Connect to database by using the given DSN string |
|
| 107 | + * |
|
| 108 | + * @param string $dsn DSN string |
|
| 109 | + * |
|
| 110 | + * @access private |
|
| 111 | + * @return mixed Object on error, otherwise bool |
|
| 112 | + */ |
|
| 113 | + public function _connect($dsn) |
|
| 114 | + { |
|
| 115 | + if (is_string($dsn) || is_array($dsn)) { |
|
| 116 | + $this->db = MDB2::connect($dsn); |
|
| 117 | + } else if (is_object($dsn) && is_a($dsn, 'MDB2_Driver_Common')) { |
|
| 118 | + $this->db = $dsn; |
|
| 119 | + } else if (is_object($dsn) && MDB2::isError($dsn)) { |
|
| 120 | + return $dsn; |
|
| 121 | + } else { |
|
| 122 | + return new PEAR_Error("The given dsn was not valid in file " . __FILE__ |
|
| 123 | + . " at line " . __LINE__, |
|
| 124 | + 41, |
|
| 125 | + PEAR_ERROR_RETURN, |
|
| 126 | + null, |
|
| 127 | + null |
|
| 128 | + ); |
|
| 129 | 129 | |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - if (MDB2::isError($this->db)) { |
|
| 133 | - return new MDB2_Error($this->db->code, PEAR_ERROR_DIE); |
|
| 134 | - } |
|
| 132 | + if (MDB2::isError($this->db)) { |
|
| 133 | + return new MDB2_Error($this->db->code, PEAR_ERROR_DIE); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - return true; |
|
| 137 | - } |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Set some default options |
|
| 141 | - * |
|
| 142 | - * @access private |
|
| 143 | - * @return void |
|
| 144 | - */ |
|
| 145 | - public function _setDefaults() |
|
| 146 | - { |
|
| 147 | - $this->options['dsn'] = null; |
|
| 148 | - $this->options['table'] = 'sessiondata'; |
|
| 149 | - $this->options['autooptimize'] = false; |
|
| 150 | - } |
|
| 139 | + /** |
|
| 140 | + * Set some default options |
|
| 141 | + * |
|
| 142 | + * @access private |
|
| 143 | + * @return void |
|
| 144 | + */ |
|
| 145 | + public function _setDefaults() |
|
| 146 | + { |
|
| 147 | + $this->options['dsn'] = null; |
|
| 148 | + $this->options['table'] = 'sessiondata'; |
|
| 149 | + $this->options['autooptimize'] = false; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Establish connection to a database |
|
| 154 | - * |
|
| 155 | - * @param string $save_path Save path |
|
| 156 | - * @param string $session_name Session name |
|
| 157 | - * |
|
| 158 | - * @return bool |
|
| 159 | - */ |
|
| 160 | - public function open($save_path, $session_name) |
|
| 161 | - { |
|
| 162 | - if (MDB2::isError($this->_connect($this->options['dsn']))) { |
|
| 163 | - return false; |
|
| 164 | - } else { |
|
| 165 | - return true; |
|
| 166 | - } |
|
| 167 | - } |
|
| 152 | + /** |
|
| 153 | + * Establish connection to a database |
|
| 154 | + * |
|
| 155 | + * @param string $save_path Save path |
|
| 156 | + * @param string $session_name Session name |
|
| 157 | + * |
|
| 158 | + * @return bool |
|
| 159 | + */ |
|
| 160 | + public function open($save_path, $session_name) |
|
| 161 | + { |
|
| 162 | + if (MDB2::isError($this->_connect($this->options['dsn']))) { |
|
| 163 | + return false; |
|
| 164 | + } else { |
|
| 165 | + return true; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Free resources |
|
| 171 | - * |
|
| 172 | - * @return bool |
|
| 173 | - */ |
|
| 174 | - public function close() |
|
| 175 | - { |
|
| 176 | - return true; |
|
| 177 | - } |
|
| 169 | + /** |
|
| 170 | + * Free resources |
|
| 171 | + * |
|
| 172 | + * @return bool |
|
| 173 | + */ |
|
| 174 | + public function close() |
|
| 175 | + { |
|
| 176 | + return true; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Read session data |
|
| 181 | - * |
|
| 182 | - * @param string $id Session id |
|
| 183 | - * |
|
| 184 | - * @return mixed |
|
| 185 | - */ |
|
| 186 | - public function read($id) |
|
| 187 | - { |
|
| 188 | - $query = sprintf("SELECT data FROM %s WHERE id = %s && expiry >= %d", |
|
| 189 | - $this->options['table'], |
|
| 190 | - $this->db->quote(md5($id), 'text'), |
|
| 191 | - time()); |
|
| 192 | - $result = $this->db->queryOne($query); |
|
| 193 | - if (MDB2::isError($result)) { |
|
| 194 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 195 | - return false; |
|
| 196 | - } |
|
| 197 | - $this->crc = strlen($result) . crc32($result); |
|
| 198 | - return $result; |
|
| 199 | - } |
|
| 179 | + /** |
|
| 180 | + * Read session data |
|
| 181 | + * |
|
| 182 | + * @param string $id Session id |
|
| 183 | + * |
|
| 184 | + * @return mixed |
|
| 185 | + */ |
|
| 186 | + public function read($id) |
|
| 187 | + { |
|
| 188 | + $query = sprintf("SELECT data FROM %s WHERE id = %s && expiry >= %d", |
|
| 189 | + $this->options['table'], |
|
| 190 | + $this->db->quote(md5($id), 'text'), |
|
| 191 | + time()); |
|
| 192 | + $result = $this->db->queryOne($query); |
|
| 193 | + if (MDB2::isError($result)) { |
|
| 194 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 195 | + return false; |
|
| 196 | + } |
|
| 197 | + $this->crc = strlen($result) . crc32($result); |
|
| 198 | + return $result; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Write session data |
|
| 203 | - * |
|
| 204 | - * @param string $id Session id |
|
| 205 | - * @param mixed $data Data |
|
| 206 | - * |
|
| 207 | - * @return bool |
|
| 208 | - */ |
|
| 209 | - public function write($id, $data) |
|
| 210 | - { |
|
| 211 | - if ((false !== $this->crc) && |
|
| 212 | - ($this->crc === strlen($data) . crc32($data))) { |
|
| 213 | - // $_SESSION hasn't been touched, no need to update the blob column |
|
| 214 | - $query = sprintf("UPDATE %s SET expiry = %d WHERE id = %s", |
|
| 215 | - $this->options['table'], |
|
| 216 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 217 | - $this->db->quote(md5($id), 'text')); |
|
| 218 | - } else { |
|
| 219 | - // Check if table row already exists |
|
| 220 | - $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 221 | - $this->options['table'], |
|
| 222 | - $this->db->quote(md5($id), 'text')); |
|
| 223 | - $result = $this->db->queryOne($query); |
|
| 224 | - if (MDB2::isError($result)) { |
|
| 225 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 228 | - if (0 == intval($result)) { |
|
| 229 | - // Insert new row into table |
|
| 230 | - $query = sprintf("INSERT INTO %s (id, expiry, data) VALUES (%s, %d, %s)", |
|
| 231 | - $this->options['table'], |
|
| 232 | - $this->db->quote(md5($id), 'text'), |
|
| 233 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 234 | - $this->db->quote($data, 'text')); |
|
| 235 | - } else { |
|
| 236 | - // Update existing row |
|
| 237 | - $query = sprintf("UPDATE %s SET expiry = %d, data = %s WHERE id = %s", |
|
| 238 | - $this->options['table'], |
|
| 239 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 240 | - $this->db->quote($data, 'text'), |
|
| 241 | - $this->db->quote(md5($id), 'text')); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - $result = $this->db->query($query); |
|
| 245 | - if (MDB2::isError($result)) { |
|
| 246 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 247 | - return false; |
|
| 248 | - } |
|
| 201 | + /** |
|
| 202 | + * Write session data |
|
| 203 | + * |
|
| 204 | + * @param string $id Session id |
|
| 205 | + * @param mixed $data Data |
|
| 206 | + * |
|
| 207 | + * @return bool |
|
| 208 | + */ |
|
| 209 | + public function write($id, $data) |
|
| 210 | + { |
|
| 211 | + if ((false !== $this->crc) && |
|
| 212 | + ($this->crc === strlen($data) . crc32($data))) { |
|
| 213 | + // $_SESSION hasn't been touched, no need to update the blob column |
|
| 214 | + $query = sprintf("UPDATE %s SET expiry = %d WHERE id = %s", |
|
| 215 | + $this->options['table'], |
|
| 216 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 217 | + $this->db->quote(md5($id), 'text')); |
|
| 218 | + } else { |
|
| 219 | + // Check if table row already exists |
|
| 220 | + $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 221 | + $this->options['table'], |
|
| 222 | + $this->db->quote(md5($id), 'text')); |
|
| 223 | + $result = $this->db->queryOne($query); |
|
| 224 | + if (MDB2::isError($result)) { |
|
| 225 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | + if (0 == intval($result)) { |
|
| 229 | + // Insert new row into table |
|
| 230 | + $query = sprintf("INSERT INTO %s (id, expiry, data) VALUES (%s, %d, %s)", |
|
| 231 | + $this->options['table'], |
|
| 232 | + $this->db->quote(md5($id), 'text'), |
|
| 233 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 234 | + $this->db->quote($data, 'text')); |
|
| 235 | + } else { |
|
| 236 | + // Update existing row |
|
| 237 | + $query = sprintf("UPDATE %s SET expiry = %d, data = %s WHERE id = %s", |
|
| 238 | + $this->options['table'], |
|
| 239 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 240 | + $this->db->quote($data, 'text'), |
|
| 241 | + $this->db->quote(md5($id), 'text')); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + $result = $this->db->query($query); |
|
| 245 | + if (MDB2::isError($result)) { |
|
| 246 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 247 | + return false; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - return true; |
|
| 251 | - } |
|
| 250 | + return true; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Destroy session data |
|
| 255 | - * |
|
| 256 | - * @param string $id Session id |
|
| 257 | - * |
|
| 258 | - * @return bool |
|
| 259 | - */ |
|
| 260 | - public function destroy($id) |
|
| 261 | - { |
|
| 262 | - $query = sprintf("DELETE FROM %s WHERE id = %s", |
|
| 263 | - $this->options['table'], |
|
| 264 | - $this->db->quote(md5($id), 'text')); |
|
| 265 | - $result = $this->db->query($query); |
|
| 266 | - if (MDB2::isError($result)) { |
|
| 267 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 268 | - return false; |
|
| 269 | - } |
|
| 253 | + /** |
|
| 254 | + * Destroy session data |
|
| 255 | + * |
|
| 256 | + * @param string $id Session id |
|
| 257 | + * |
|
| 258 | + * @return bool |
|
| 259 | + */ |
|
| 260 | + public function destroy($id) |
|
| 261 | + { |
|
| 262 | + $query = sprintf("DELETE FROM %s WHERE id = %s", |
|
| 263 | + $this->options['table'], |
|
| 264 | + $this->db->quote(md5($id), 'text')); |
|
| 265 | + $result = $this->db->query($query); |
|
| 266 | + if (MDB2::isError($result)) { |
|
| 267 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 268 | + return false; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - return true; |
|
| 272 | - } |
|
| 271 | + return true; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * Replicate session data to table specified in option 'replicateBeforeDestroy' |
|
| 276 | - * |
|
| 277 | - * @param string $targetTable Table to replicate to |
|
| 278 | - * @param string $id Id of record to replicate |
|
| 279 | - * |
|
| 280 | - * @access private |
|
| 281 | - * @return bool |
|
| 282 | - */ |
|
| 283 | - public function replicate($targetTable, $id = null) |
|
| 284 | - { |
|
| 285 | - if (is_null($id)) { |
|
| 286 | - $id = HTTP_Session::id(); |
|
| 287 | - } |
|
| 274 | + /** |
|
| 275 | + * Replicate session data to table specified in option 'replicateBeforeDestroy' |
|
| 276 | + * |
|
| 277 | + * @param string $targetTable Table to replicate to |
|
| 278 | + * @param string $id Id of record to replicate |
|
| 279 | + * |
|
| 280 | + * @access private |
|
| 281 | + * @return bool |
|
| 282 | + */ |
|
| 283 | + public function replicate($targetTable, $id = null) |
|
| 284 | + { |
|
| 285 | + if (is_null($id)) { |
|
| 286 | + $id = HTTP_Session::id(); |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - // Check if table row already exists |
|
| 290 | - $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 291 | - $targetTable, |
|
| 292 | - $this->db->quote(md5($id), 'text')); |
|
| 293 | - $result = $this->db->queryOne($query); |
|
| 294 | - if (MDB2::isError($result)) { |
|
| 295 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 296 | - return false; |
|
| 297 | - } |
|
| 289 | + // Check if table row already exists |
|
| 290 | + $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 291 | + $targetTable, |
|
| 292 | + $this->db->quote(md5($id), 'text')); |
|
| 293 | + $result = $this->db->queryOne($query); |
|
| 294 | + if (MDB2::isError($result)) { |
|
| 295 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 296 | + return false; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - // Insert new row into dest table |
|
| 300 | - if (0 == intval($result)) { |
|
| 301 | - $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", |
|
| 302 | - $targetTable, |
|
| 303 | - $this->options['table'], |
|
| 304 | - $this->db->quote(md5($id), 'text')); |
|
| 299 | + // Insert new row into dest table |
|
| 300 | + if (0 == intval($result)) { |
|
| 301 | + $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", |
|
| 302 | + $targetTable, |
|
| 303 | + $this->options['table'], |
|
| 304 | + $this->db->quote(md5($id), 'text')); |
|
| 305 | 305 | |
| 306 | - } else { |
|
| 307 | - // Update existing row |
|
| 308 | - $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id && src.id = %s", |
|
| 309 | - $targetTable, |
|
| 310 | - $this->options['table'], |
|
| 311 | - $this->db->quote(md5($id), 'text')); |
|
| 312 | - } |
|
| 306 | + } else { |
|
| 307 | + // Update existing row |
|
| 308 | + $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id && src.id = %s", |
|
| 309 | + $targetTable, |
|
| 310 | + $this->options['table'], |
|
| 311 | + $this->db->quote(md5($id), 'text')); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $result = $this->db->query($query); |
|
| 315 | - if (MDB2::isError($result)) { |
|
| 316 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 317 | - return false; |
|
| 318 | - } |
|
| 314 | + $result = $this->db->query($query); |
|
| 315 | + if (MDB2::isError($result)) { |
|
| 316 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 317 | + return false; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - return true; |
|
| 321 | - } |
|
| 320 | + return true; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * Garbage collection |
|
| 325 | - * |
|
| 326 | - * @param int $maxlifetime Maximum lifetime |
|
| 327 | - * |
|
| 328 | - * @return bool |
|
| 329 | - */ |
|
| 330 | - public function gc($maxlifetime) |
|
| 331 | - { |
|
| 332 | - $query = sprintf("DELETE FROM %s WHERE expiry < %d", |
|
| 333 | - $this->options['table'], |
|
| 334 | - time()); |
|
| 335 | - $result = $this->db->query($query); |
|
| 336 | - if (MDB2::isError($result)) { |
|
| 337 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 338 | - return false; |
|
| 339 | - } |
|
| 340 | - if ($this->options['autooptimize']) { |
|
| 341 | - switch($this->db->phptype) { |
|
| 342 | - case 'mysql': |
|
| 343 | - $query = sprintf("OPTIMIZE TABLE %s", $this->options['table']); |
|
| 344 | - break; |
|
| 345 | - case 'pgsql': |
|
| 346 | - $query = sprintf("VACUUM %s", $this->options['table']); |
|
| 347 | - break; |
|
| 348 | - default: |
|
| 349 | - $query = null; |
|
| 350 | - break; |
|
| 351 | - } |
|
| 352 | - if (isset($query)) { |
|
| 353 | - $result = $this->db->query($query); |
|
| 354 | - if (MDB2::isError($result)) { |
|
| 355 | - $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 356 | - return false; |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 323 | + /** |
|
| 324 | + * Garbage collection |
|
| 325 | + * |
|
| 326 | + * @param int $maxlifetime Maximum lifetime |
|
| 327 | + * |
|
| 328 | + * @return bool |
|
| 329 | + */ |
|
| 330 | + public function gc($maxlifetime) |
|
| 331 | + { |
|
| 332 | + $query = sprintf("DELETE FROM %s WHERE expiry < %d", |
|
| 333 | + $this->options['table'], |
|
| 334 | + time()); |
|
| 335 | + $result = $this->db->query($query); |
|
| 336 | + if (MDB2::isError($result)) { |
|
| 337 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 338 | + return false; |
|
| 339 | + } |
|
| 340 | + if ($this->options['autooptimize']) { |
|
| 341 | + switch($this->db->phptype) { |
|
| 342 | + case 'mysql': |
|
| 343 | + $query = sprintf("OPTIMIZE TABLE %s", $this->options['table']); |
|
| 344 | + break; |
|
| 345 | + case 'pgsql': |
|
| 346 | + $query = sprintf("VACUUM %s", $this->options['table']); |
|
| 347 | + break; |
|
| 348 | + default: |
|
| 349 | + $query = null; |
|
| 350 | + break; |
|
| 351 | + } |
|
| 352 | + if (isset($query)) { |
|
| 353 | + $result = $this->db->query($query); |
|
| 354 | + if (MDB2::isError($result)) { |
|
| 355 | + $this->db->raiseError($result->code, PEAR_ERROR_DIE); |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - return true; |
|
| 362 | - } |
|
| 361 | + return true; |
|
| 362 | + } |
|
| 363 | 363 | } |
| 364 | 364 | ?> |
| 365 | 365 | \ No newline at end of file |
@@ -60,305 +60,305 @@ |
||
| 60 | 60 | class HTTP_Session_Container_MDB extends HTTP_Session_Container |
| 61 | 61 | { |
| 62 | 62 | |
| 63 | - /** |
|
| 64 | - * MDB connection object |
|
| 65 | - * |
|
| 66 | - * @var object MDB |
|
| 67 | - * @access private |
|
| 68 | - */ |
|
| 69 | - var $db = null; |
|
| 63 | + /** |
|
| 64 | + * MDB connection object |
|
| 65 | + * |
|
| 66 | + * @var object MDB |
|
| 67 | + * @access private |
|
| 68 | + */ |
|
| 69 | + var $db = null; |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Session data cache id |
|
| 73 | - * |
|
| 74 | - * @var mixed |
|
| 75 | - * @access private |
|
| 76 | - */ |
|
| 77 | - var $crc = false; |
|
| 71 | + /** |
|
| 72 | + * Session data cache id |
|
| 73 | + * |
|
| 74 | + * @var mixed |
|
| 75 | + * @access private |
|
| 76 | + */ |
|
| 77 | + var $crc = false; |
|
| 78 | 78 | |
| 79 | - /** |
|
| 80 | - * Constructor method |
|
| 81 | - * |
|
| 82 | - * $options is an array with the options.<br> |
|
| 83 | - * The options are: |
|
| 84 | - * <ul> |
|
| 85 | - * <li>'dsn' - The DSN string</li> |
|
| 86 | - * <li>'table' - Table with session data, default is 'sessiondata'</li> |
|
| 87 | - * <li>'autooptimize' - Boolean, 'true' to optimize |
|
| 88 | - * the table on garbage collection, default is 'false'.</li> |
|
| 89 | - * </ul> |
|
| 90 | - * |
|
| 91 | - * @param array $options Options |
|
| 92 | - * |
|
| 93 | - * @access public |
|
| 94 | - * @return object |
|
| 95 | - */ |
|
| 96 | - public function HTTP_Session_Container_MDB($options) |
|
| 97 | - { |
|
| 98 | - $this->_setDefaults(); |
|
| 99 | - if (is_array($options)) { |
|
| 100 | - $this->_parseOptions($options); |
|
| 101 | - } else { |
|
| 102 | - $this->options['dsn'] = $options; |
|
| 103 | - } |
|
| 104 | - } |
|
| 79 | + /** |
|
| 80 | + * Constructor method |
|
| 81 | + * |
|
| 82 | + * $options is an array with the options.<br> |
|
| 83 | + * The options are: |
|
| 84 | + * <ul> |
|
| 85 | + * <li>'dsn' - The DSN string</li> |
|
| 86 | + * <li>'table' - Table with session data, default is 'sessiondata'</li> |
|
| 87 | + * <li>'autooptimize' - Boolean, 'true' to optimize |
|
| 88 | + * the table on garbage collection, default is 'false'.</li> |
|
| 89 | + * </ul> |
|
| 90 | + * |
|
| 91 | + * @param array $options Options |
|
| 92 | + * |
|
| 93 | + * @access public |
|
| 94 | + * @return object |
|
| 95 | + */ |
|
| 96 | + public function HTTP_Session_Container_MDB($options) |
|
| 97 | + { |
|
| 98 | + $this->_setDefaults(); |
|
| 99 | + if (is_array($options)) { |
|
| 100 | + $this->_parseOptions($options); |
|
| 101 | + } else { |
|
| 102 | + $this->options['dsn'] = $options; |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - /** |
|
| 107 | - * Connect to database by using the given DSN string |
|
| 108 | - * |
|
| 109 | - * @param string $dsn DSN string |
|
| 110 | - * |
|
| 111 | - * @access private |
|
| 112 | - * @return mixed Object on error, otherwise bool |
|
| 113 | - */ |
|
| 114 | - public function _connect($dsn) |
|
| 115 | - { |
|
| 116 | - if (is_string($dsn) || is_array($dsn)) { |
|
| 117 | - $this->db = MDB::connect($dsn); |
|
| 118 | - } else if (is_object($dsn) && is_a($dsn, 'mdb_common')) { |
|
| 119 | - $this->db = $dsn; |
|
| 120 | - } else if (is_object($dsn) && MDB::isError($dsn)) { |
|
| 121 | - return new MDB_Error($dsn->code, PEAR_ERROR_DIE); |
|
| 122 | - } else { |
|
| 123 | - return new PEAR_Error("The given dsn was not valid in file " . __FILE__ |
|
| 124 | - . " at line " . __LINE__, |
|
| 125 | - 41, |
|
| 126 | - PEAR_ERROR_RETURN, |
|
| 127 | - null, |
|
| 128 | - null |
|
| 129 | - ); |
|
| 106 | + /** |
|
| 107 | + * Connect to database by using the given DSN string |
|
| 108 | + * |
|
| 109 | + * @param string $dsn DSN string |
|
| 110 | + * |
|
| 111 | + * @access private |
|
| 112 | + * @return mixed Object on error, otherwise bool |
|
| 113 | + */ |
|
| 114 | + public function _connect($dsn) |
|
| 115 | + { |
|
| 116 | + if (is_string($dsn) || is_array($dsn)) { |
|
| 117 | + $this->db = MDB::connect($dsn); |
|
| 118 | + } else if (is_object($dsn) && is_a($dsn, 'mdb_common')) { |
|
| 119 | + $this->db = $dsn; |
|
| 120 | + } else if (is_object($dsn) && MDB::isError($dsn)) { |
|
| 121 | + return new MDB_Error($dsn->code, PEAR_ERROR_DIE); |
|
| 122 | + } else { |
|
| 123 | + return new PEAR_Error("The given dsn was not valid in file " . __FILE__ |
|
| 124 | + . " at line " . __LINE__, |
|
| 125 | + 41, |
|
| 126 | + PEAR_ERROR_RETURN, |
|
| 127 | + null, |
|
| 128 | + null |
|
| 129 | + ); |
|
| 130 | 130 | |
| 131 | - } |
|
| 131 | + } |
|
| 132 | 132 | |
| 133 | - if (MDB::isError($this->db)) { |
|
| 134 | - return new MDB_Error($this->db->code, PEAR_ERROR_DIE); |
|
| 135 | - } |
|
| 133 | + if (MDB::isError($this->db)) { |
|
| 134 | + return new MDB_Error($this->db->code, PEAR_ERROR_DIE); |
|
| 135 | + } |
|
| 136 | 136 | |
| 137 | - return true; |
|
| 138 | - } |
|
| 137 | + return true; |
|
| 138 | + } |
|
| 139 | 139 | |
| 140 | - /** |
|
| 141 | - * Set some default options |
|
| 142 | - * |
|
| 143 | - * @access private |
|
| 144 | - * @return void |
|
| 145 | - */ |
|
| 146 | - public function _setDefaults() |
|
| 147 | - { |
|
| 148 | - $this->options['dsn'] = null; |
|
| 149 | - $this->options['table'] = 'sessiondata'; |
|
| 150 | - $this->options['autooptimize'] = false; |
|
| 151 | - } |
|
| 140 | + /** |
|
| 141 | + * Set some default options |
|
| 142 | + * |
|
| 143 | + * @access private |
|
| 144 | + * @return void |
|
| 145 | + */ |
|
| 146 | + public function _setDefaults() |
|
| 147 | + { |
|
| 148 | + $this->options['dsn'] = null; |
|
| 149 | + $this->options['table'] = 'sessiondata'; |
|
| 150 | + $this->options['autooptimize'] = false; |
|
| 151 | + } |
|
| 152 | 152 | |
| 153 | - /** |
|
| 154 | - * Establish connection to a database |
|
| 155 | - * |
|
| 156 | - * @param string $save_path Save path |
|
| 157 | - * @param string $session_name Session name |
|
| 158 | - * |
|
| 159 | - * @return bool |
|
| 160 | - */ |
|
| 161 | - public function open($save_path, $session_name) |
|
| 162 | - { |
|
| 163 | - if (MDB::isError($this->_connect($this->options['dsn']))) { |
|
| 164 | - return false; |
|
| 165 | - } else { |
|
| 166 | - return true; |
|
| 167 | - } |
|
| 168 | - } |
|
| 153 | + /** |
|
| 154 | + * Establish connection to a database |
|
| 155 | + * |
|
| 156 | + * @param string $save_path Save path |
|
| 157 | + * @param string $session_name Session name |
|
| 158 | + * |
|
| 159 | + * @return bool |
|
| 160 | + */ |
|
| 161 | + public function open($save_path, $session_name) |
|
| 162 | + { |
|
| 163 | + if (MDB::isError($this->_connect($this->options['dsn']))) { |
|
| 164 | + return false; |
|
| 165 | + } else { |
|
| 166 | + return true; |
|
| 167 | + } |
|
| 168 | + } |
|
| 169 | 169 | |
| 170 | - /** |
|
| 171 | - * Free resources |
|
| 172 | - * |
|
| 173 | - * @return bool |
|
| 174 | - */ |
|
| 175 | - public function close() |
|
| 176 | - { |
|
| 177 | - return true; |
|
| 178 | - } |
|
| 170 | + /** |
|
| 171 | + * Free resources |
|
| 172 | + * |
|
| 173 | + * @return bool |
|
| 174 | + */ |
|
| 175 | + public function close() |
|
| 176 | + { |
|
| 177 | + return true; |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - /** |
|
| 181 | - * Read session data |
|
| 182 | - * |
|
| 183 | - * @param string $id Session id |
|
| 184 | - * |
|
| 185 | - * @return mixed |
|
| 186 | - */ |
|
| 187 | - public function read($id) |
|
| 188 | - { |
|
| 189 | - $query = sprintf("SELECT data FROM %s WHERE id = %s && expiry >= %d", |
|
| 190 | - $this->options['table'], |
|
| 191 | - $this->db->getTextValue(md5($id)), |
|
| 192 | - time()); |
|
| 193 | - $result = $this->db->getOne($query); |
|
| 194 | - if (MDB::isError($result)) { |
|
| 195 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 196 | - return false; |
|
| 197 | - } |
|
| 198 | - $this->crc = strlen($result) . crc32($result); |
|
| 199 | - return $result; |
|
| 200 | - } |
|
| 180 | + /** |
|
| 181 | + * Read session data |
|
| 182 | + * |
|
| 183 | + * @param string $id Session id |
|
| 184 | + * |
|
| 185 | + * @return mixed |
|
| 186 | + */ |
|
| 187 | + public function read($id) |
|
| 188 | + { |
|
| 189 | + $query = sprintf("SELECT data FROM %s WHERE id = %s && expiry >= %d", |
|
| 190 | + $this->options['table'], |
|
| 191 | + $this->db->getTextValue(md5($id)), |
|
| 192 | + time()); |
|
| 193 | + $result = $this->db->getOne($query); |
|
| 194 | + if (MDB::isError($result)) { |
|
| 195 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 196 | + return false; |
|
| 197 | + } |
|
| 198 | + $this->crc = strlen($result) . crc32($result); |
|
| 199 | + return $result; |
|
| 200 | + } |
|
| 201 | 201 | |
| 202 | - /** |
|
| 203 | - * Write session data |
|
| 204 | - * |
|
| 205 | - * @param string $id Session id |
|
| 206 | - * @param mixed $data Data |
|
| 207 | - * |
|
| 208 | - * @return bool |
|
| 209 | - */ |
|
| 210 | - public function write($id, $data) |
|
| 211 | - { |
|
| 212 | - if ((false !== $this->crc) && |
|
| 213 | - ($this->crc === strlen($data) . crc32($data))) { |
|
| 214 | - // $_SESSION hasn't been touched, no need to update the blob column |
|
| 215 | - $query = sprintf("UPDATE %s SET expiry = %d WHERE id = %s", |
|
| 216 | - $this->options['table'], |
|
| 217 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 218 | - $this->db->getTextValue(md5($id))); |
|
| 219 | - } else { |
|
| 220 | - // Check if table row already exists |
|
| 221 | - $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 222 | - $this->options['table'], |
|
| 223 | - $this->db->getTextValue(md5($id))); |
|
| 224 | - $result = $this->db->getOne($query); |
|
| 225 | - if (MDB::isError($result)) { |
|
| 226 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - if (0 == intval($result)) { |
|
| 230 | - // Insert new row into table |
|
| 231 | - $query = sprintf("INSERT INTO %s (id, expiry, data) VALUES (%s, %d, %s)", |
|
| 232 | - $this->options['table'], |
|
| 233 | - $this->db->getTextValue(md5($id)), |
|
| 234 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 235 | - $this->db->getTextValue($data)); |
|
| 236 | - } else { |
|
| 237 | - // Update existing row |
|
| 238 | - $query = sprintf("UPDATE %s SET expiry = %d, data = %s WHERE id = %s", |
|
| 239 | - $this->options['table'], |
|
| 240 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 241 | - $this->db->getTextValue($data), |
|
| 242 | - $this->db->getTextValue(md5($id))); |
|
| 243 | - } |
|
| 244 | - } |
|
| 245 | - $result = $this->db->query($query); |
|
| 246 | - if (MDB::isError($result)) { |
|
| 247 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 248 | - return false; |
|
| 249 | - } |
|
| 202 | + /** |
|
| 203 | + * Write session data |
|
| 204 | + * |
|
| 205 | + * @param string $id Session id |
|
| 206 | + * @param mixed $data Data |
|
| 207 | + * |
|
| 208 | + * @return bool |
|
| 209 | + */ |
|
| 210 | + public function write($id, $data) |
|
| 211 | + { |
|
| 212 | + if ((false !== $this->crc) && |
|
| 213 | + ($this->crc === strlen($data) . crc32($data))) { |
|
| 214 | + // $_SESSION hasn't been touched, no need to update the blob column |
|
| 215 | + $query = sprintf("UPDATE %s SET expiry = %d WHERE id = %s", |
|
| 216 | + $this->options['table'], |
|
| 217 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 218 | + $this->db->getTextValue(md5($id))); |
|
| 219 | + } else { |
|
| 220 | + // Check if table row already exists |
|
| 221 | + $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 222 | + $this->options['table'], |
|
| 223 | + $this->db->getTextValue(md5($id))); |
|
| 224 | + $result = $this->db->getOne($query); |
|
| 225 | + if (MDB::isError($result)) { |
|
| 226 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + if (0 == intval($result)) { |
|
| 230 | + // Insert new row into table |
|
| 231 | + $query = sprintf("INSERT INTO %s (id, expiry, data) VALUES (%s, %d, %s)", |
|
| 232 | + $this->options['table'], |
|
| 233 | + $this->db->getTextValue(md5($id)), |
|
| 234 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 235 | + $this->db->getTextValue($data)); |
|
| 236 | + } else { |
|
| 237 | + // Update existing row |
|
| 238 | + $query = sprintf("UPDATE %s SET expiry = %d, data = %s WHERE id = %s", |
|
| 239 | + $this->options['table'], |
|
| 240 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 241 | + $this->db->getTextValue($data), |
|
| 242 | + $this->db->getTextValue(md5($id))); |
|
| 243 | + } |
|
| 244 | + } |
|
| 245 | + $result = $this->db->query($query); |
|
| 246 | + if (MDB::isError($result)) { |
|
| 247 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 248 | + return false; |
|
| 249 | + } |
|
| 250 | 250 | |
| 251 | - return true; |
|
| 252 | - } |
|
| 251 | + return true; |
|
| 252 | + } |
|
| 253 | 253 | |
| 254 | - /** |
|
| 255 | - * Destroy session data |
|
| 256 | - * |
|
| 257 | - * @param string $id Session id |
|
| 258 | - * |
|
| 259 | - * @return bool |
|
| 260 | - */ |
|
| 261 | - public function destroy($id) |
|
| 262 | - { |
|
| 263 | - $query = sprintf("DELETE FROM %s WHERE id = %s", |
|
| 264 | - $this->options['table'], |
|
| 265 | - $this->db->getTextValue(md5($id))); |
|
| 266 | - $result = $this->db->query($query); |
|
| 267 | - if (MDB::isError($result)) { |
|
| 268 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 269 | - return false; |
|
| 270 | - } |
|
| 254 | + /** |
|
| 255 | + * Destroy session data |
|
| 256 | + * |
|
| 257 | + * @param string $id Session id |
|
| 258 | + * |
|
| 259 | + * @return bool |
|
| 260 | + */ |
|
| 261 | + public function destroy($id) |
|
| 262 | + { |
|
| 263 | + $query = sprintf("DELETE FROM %s WHERE id = %s", |
|
| 264 | + $this->options['table'], |
|
| 265 | + $this->db->getTextValue(md5($id))); |
|
| 266 | + $result = $this->db->query($query); |
|
| 267 | + if (MDB::isError($result)) { |
|
| 268 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 269 | + return false; |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - return true; |
|
| 273 | - } |
|
| 272 | + return true; |
|
| 273 | + } |
|
| 274 | 274 | |
| 275 | - /** |
|
| 276 | - * Replicate session data to table specified in option 'replicateBeforeDestroy' |
|
| 277 | - * |
|
| 278 | - * @param string $targetTable Table to replicate to |
|
| 279 | - * @param string $id Id of record to replicate |
|
| 280 | - * |
|
| 281 | - * @access private |
|
| 282 | - * @return bool |
|
| 283 | - */ |
|
| 284 | - public function replicate($targetTable, $id = null) |
|
| 285 | - { |
|
| 286 | - if (is_null($id)) { |
|
| 287 | - $id = HTTP_Session::id(); |
|
| 288 | - } |
|
| 275 | + /** |
|
| 276 | + * Replicate session data to table specified in option 'replicateBeforeDestroy' |
|
| 277 | + * |
|
| 278 | + * @param string $targetTable Table to replicate to |
|
| 279 | + * @param string $id Id of record to replicate |
|
| 280 | + * |
|
| 281 | + * @access private |
|
| 282 | + * @return bool |
|
| 283 | + */ |
|
| 284 | + public function replicate($targetTable, $id = null) |
|
| 285 | + { |
|
| 286 | + if (is_null($id)) { |
|
| 287 | + $id = HTTP_Session::id(); |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - // Check if table row already exists |
|
| 291 | - $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 292 | - $targetTable, |
|
| 293 | - $this->db->getTextValue(md5($id))); |
|
| 294 | - $result = $this->db->getOne($query); |
|
| 295 | - if (MDB::isError($result)) { |
|
| 296 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 297 | - return false; |
|
| 298 | - } |
|
| 290 | + // Check if table row already exists |
|
| 291 | + $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 292 | + $targetTable, |
|
| 293 | + $this->db->getTextValue(md5($id))); |
|
| 294 | + $result = $this->db->getOne($query); |
|
| 295 | + if (MDB::isError($result)) { |
|
| 296 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 297 | + return false; |
|
| 298 | + } |
|
| 299 | 299 | |
| 300 | - // Insert new row into dest table |
|
| 301 | - if (0 == intval($result)) { |
|
| 302 | - $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", |
|
| 303 | - $targetTable, |
|
| 304 | - $this->options['table'], |
|
| 305 | - $this->db->getTextValue(md5($id))); |
|
| 306 | - } else { |
|
| 307 | - // Update existing row |
|
| 308 | - $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id && src.id = %s", |
|
| 309 | - $targetTable, |
|
| 310 | - $this->options['table'], |
|
| 311 | - $this->db->getTextValue(md5($id))); |
|
| 312 | - } |
|
| 300 | + // Insert new row into dest table |
|
| 301 | + if (0 == intval($result)) { |
|
| 302 | + $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", |
|
| 303 | + $targetTable, |
|
| 304 | + $this->options['table'], |
|
| 305 | + $this->db->getTextValue(md5($id))); |
|
| 306 | + } else { |
|
| 307 | + // Update existing row |
|
| 308 | + $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id && src.id = %s", |
|
| 309 | + $targetTable, |
|
| 310 | + $this->options['table'], |
|
| 311 | + $this->db->getTextValue(md5($id))); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $result = $this->db->query($query); |
|
| 315 | - if (MDB::isError($result)) { |
|
| 316 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 317 | - return false; |
|
| 318 | - } |
|
| 314 | + $result = $this->db->query($query); |
|
| 315 | + if (MDB::isError($result)) { |
|
| 316 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 317 | + return false; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - return true; |
|
| 321 | - } |
|
| 320 | + return true; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * Garbage collection |
|
| 325 | - * |
|
| 326 | - * @param int $maxlifetime Maximum lifetime |
|
| 327 | - * |
|
| 328 | - * @return bool |
|
| 329 | - */ |
|
| 330 | - public function gc($maxlifetime) |
|
| 331 | - { |
|
| 332 | - $query = sprintf("DELETE FROM %s WHERE expiry < %d", |
|
| 333 | - $this->options['table'], |
|
| 334 | - time()); |
|
| 335 | - $result = $this->db->query($query); |
|
| 336 | - if (MDB::isError($result)) { |
|
| 337 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 338 | - return false; |
|
| 339 | - } |
|
| 340 | - if ($this->options['autooptimize']) { |
|
| 341 | - switch($this->db->phptype) { |
|
| 342 | - case 'mysql': |
|
| 343 | - $query = sprintf("OPTIMIZE TABLE %s", $this->options['table']); |
|
| 344 | - break; |
|
| 345 | - case 'pgsql': |
|
| 346 | - $query = sprintf("VACUUM %s", $this->options['table']); |
|
| 347 | - break; |
|
| 348 | - default: |
|
| 349 | - $query = null; |
|
| 350 | - break; |
|
| 351 | - } |
|
| 352 | - if (isset($query)) { |
|
| 353 | - $result = $this->db->query($query); |
|
| 354 | - if (MDB::isError($result)) { |
|
| 355 | - new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 356 | - return false; |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 323 | + /** |
|
| 324 | + * Garbage collection |
|
| 325 | + * |
|
| 326 | + * @param int $maxlifetime Maximum lifetime |
|
| 327 | + * |
|
| 328 | + * @return bool |
|
| 329 | + */ |
|
| 330 | + public function gc($maxlifetime) |
|
| 331 | + { |
|
| 332 | + $query = sprintf("DELETE FROM %s WHERE expiry < %d", |
|
| 333 | + $this->options['table'], |
|
| 334 | + time()); |
|
| 335 | + $result = $this->db->query($query); |
|
| 336 | + if (MDB::isError($result)) { |
|
| 337 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 338 | + return false; |
|
| 339 | + } |
|
| 340 | + if ($this->options['autooptimize']) { |
|
| 341 | + switch($this->db->phptype) { |
|
| 342 | + case 'mysql': |
|
| 343 | + $query = sprintf("OPTIMIZE TABLE %s", $this->options['table']); |
|
| 344 | + break; |
|
| 345 | + case 'pgsql': |
|
| 346 | + $query = sprintf("VACUUM %s", $this->options['table']); |
|
| 347 | + break; |
|
| 348 | + default: |
|
| 349 | + $query = null; |
|
| 350 | + break; |
|
| 351 | + } |
|
| 352 | + if (isset($query)) { |
|
| 353 | + $result = $this->db->query($query); |
|
| 354 | + if (MDB::isError($result)) { |
|
| 355 | + new MDB_Error($result->code, PEAR_ERROR_DIE); |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - return true; |
|
| 362 | - } |
|
| 361 | + return true; |
|
| 362 | + } |
|
| 363 | 363 | } |
| 364 | 364 | ?> |
| 365 | 365 | \ No newline at end of file |
@@ -43,160 +43,160 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class HTTP_Session_Container_Memcache extends HTTP_Session_Container |
| 45 | 45 | { |
| 46 | - /** |
|
| 47 | - * Memcache connection object |
|
| 48 | - * |
|
| 49 | - * @var object Memcache |
|
| 50 | - * @access private |
|
| 51 | - */ |
|
| 52 | - var $mc; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Constructor method |
|
| 56 | - * |
|
| 57 | - * $options is an array with the options.<br> |
|
| 58 | - * The options are: |
|
| 59 | - * <ul> |
|
| 60 | - * <li>'memcache' - Memcache object |
|
| 61 | - * <li>'prefix' - Key prefix, default is 'sessiondata:'</li> |
|
| 62 | - * </ul> |
|
| 63 | - * |
|
| 64 | - * @param array $options Options |
|
| 65 | - * |
|
| 66 | - * @access public |
|
| 67 | - * @return object |
|
| 68 | - */ |
|
| 69 | - public function HTTP_Session_Container_Memcache($options) |
|
| 70 | - { |
|
| 71 | - $this->_setDefaults(); |
|
| 72 | - |
|
| 73 | - if (is_array($options)) { |
|
| 74 | - $this->_parseOptions($options); |
|
| 75 | - } |
|
| 76 | - } |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * Connect to database by using the given DSN string |
|
| 80 | - * |
|
| 81 | - * @param string $mc Memcache object |
|
| 82 | - * |
|
| 83 | - * @access private |
|
| 84 | - * @return mixed Object on error, otherwise bool |
|
| 85 | - */ |
|
| 86 | - public function _connect($mc) |
|
| 87 | - { |
|
| 88 | - if (is_object($mc) && is_a($mc, 'Memcache')) { |
|
| 89 | - $this->mc = $mc; |
|
| 90 | - |
|
| 91 | - } else { |
|
| 92 | - |
|
| 93 | - return new PEAR_Error('The given memcache object was not valid in file ' |
|
| 94 | - . __FILE__ . ' at line ' . __LINE__, |
|
| 95 | - 41, |
|
| 96 | - PEAR_ERROR_RETURN, |
|
| 97 | - null, |
|
| 98 | - null |
|
| 99 | - ); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - return true; |
|
| 103 | - } |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * Set some default options |
|
| 107 | - * |
|
| 108 | - * @access private |
|
| 109 | - * @return void |
|
| 110 | - */ |
|
| 111 | - public function _setDefaults() |
|
| 112 | - { |
|
| 113 | - $this->options['prefix'] = 'sessiondata:'; |
|
| 114 | - $this->options['memcache'] = null; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Establish connection to a database |
|
| 119 | - * |
|
| 120 | - * @param string $save_path Save path |
|
| 121 | - * @param string $session_name Session name |
|
| 122 | - * |
|
| 123 | - * @access public |
|
| 124 | - * @return mixed Object on error, otherwise bool |
|
| 125 | - */ |
|
| 126 | - public function open($save_path, $session_name) |
|
| 127 | - { |
|
| 128 | - return $this->_connect($this->options['memcache']); |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Free resources |
|
| 133 | - * |
|
| 134 | - * @access public |
|
| 135 | - * @return bool |
|
| 136 | - */ |
|
| 137 | - public function close() |
|
| 138 | - { |
|
| 139 | - return true; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * Read session data |
|
| 144 | - * |
|
| 145 | - * @param string $id Session id |
|
| 146 | - * |
|
| 147 | - * @access public |
|
| 148 | - * @return mixed |
|
| 149 | - */ |
|
| 150 | - public function read($id) |
|
| 151 | - { |
|
| 152 | - $result = $this->mc->get($this->options['prefix'] . $id); |
|
| 153 | - return $result; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - /** |
|
| 157 | - * Write session data |
|
| 158 | - * |
|
| 159 | - * @param string $id Session id |
|
| 160 | - * @param mixed $data Session data |
|
| 161 | - * |
|
| 162 | - * @access public |
|
| 163 | - * @return bool |
|
| 164 | - */ |
|
| 165 | - public function write($id, $data) |
|
| 166 | - { |
|
| 167 | - $this->mc->set($this->options['prefix'] . $id, |
|
| 168 | - $data, |
|
| 169 | - MEMCACHE_COMPRESSED, |
|
| 170 | - time() + ini_get('session.gc_maxlifetime')); |
|
| 171 | - |
|
| 172 | - return true; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Destroy session data |
|
| 177 | - * |
|
| 178 | - * @param string $id Session id |
|
| 179 | - * |
|
| 180 | - * @access public |
|
| 181 | - * @return bool |
|
| 182 | - */ |
|
| 183 | - public function destroy($id) |
|
| 184 | - { |
|
| 185 | - $this->mc->delete($this->options['prefix'] . $id); |
|
| 186 | - return true; |
|
| 187 | - } |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * Garbage collection |
|
| 191 | - * |
|
| 192 | - * @param int $maxlifetime Maximum lifetime |
|
| 193 | - * |
|
| 194 | - * @access public |
|
| 195 | - * @return bool |
|
| 196 | - */ |
|
| 197 | - public function gc($maxlifetime) |
|
| 198 | - { |
|
| 199 | - return true; |
|
| 200 | - } |
|
| 46 | + /** |
|
| 47 | + * Memcache connection object |
|
| 48 | + * |
|
| 49 | + * @var object Memcache |
|
| 50 | + * @access private |
|
| 51 | + */ |
|
| 52 | + var $mc; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Constructor method |
|
| 56 | + * |
|
| 57 | + * $options is an array with the options.<br> |
|
| 58 | + * The options are: |
|
| 59 | + * <ul> |
|
| 60 | + * <li>'memcache' - Memcache object |
|
| 61 | + * <li>'prefix' - Key prefix, default is 'sessiondata:'</li> |
|
| 62 | + * </ul> |
|
| 63 | + * |
|
| 64 | + * @param array $options Options |
|
| 65 | + * |
|
| 66 | + * @access public |
|
| 67 | + * @return object |
|
| 68 | + */ |
|
| 69 | + public function HTTP_Session_Container_Memcache($options) |
|
| 70 | + { |
|
| 71 | + $this->_setDefaults(); |
|
| 72 | + |
|
| 73 | + if (is_array($options)) { |
|
| 74 | + $this->_parseOptions($options); |
|
| 75 | + } |
|
| 76 | + } |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * Connect to database by using the given DSN string |
|
| 80 | + * |
|
| 81 | + * @param string $mc Memcache object |
|
| 82 | + * |
|
| 83 | + * @access private |
|
| 84 | + * @return mixed Object on error, otherwise bool |
|
| 85 | + */ |
|
| 86 | + public function _connect($mc) |
|
| 87 | + { |
|
| 88 | + if (is_object($mc) && is_a($mc, 'Memcache')) { |
|
| 89 | + $this->mc = $mc; |
|
| 90 | + |
|
| 91 | + } else { |
|
| 92 | + |
|
| 93 | + return new PEAR_Error('The given memcache object was not valid in file ' |
|
| 94 | + . __FILE__ . ' at line ' . __LINE__, |
|
| 95 | + 41, |
|
| 96 | + PEAR_ERROR_RETURN, |
|
| 97 | + null, |
|
| 98 | + null |
|
| 99 | + ); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + return true; |
|
| 103 | + } |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * Set some default options |
|
| 107 | + * |
|
| 108 | + * @access private |
|
| 109 | + * @return void |
|
| 110 | + */ |
|
| 111 | + public function _setDefaults() |
|
| 112 | + { |
|
| 113 | + $this->options['prefix'] = 'sessiondata:'; |
|
| 114 | + $this->options['memcache'] = null; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Establish connection to a database |
|
| 119 | + * |
|
| 120 | + * @param string $save_path Save path |
|
| 121 | + * @param string $session_name Session name |
|
| 122 | + * |
|
| 123 | + * @access public |
|
| 124 | + * @return mixed Object on error, otherwise bool |
|
| 125 | + */ |
|
| 126 | + public function open($save_path, $session_name) |
|
| 127 | + { |
|
| 128 | + return $this->_connect($this->options['memcache']); |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Free resources |
|
| 133 | + * |
|
| 134 | + * @access public |
|
| 135 | + * @return bool |
|
| 136 | + */ |
|
| 137 | + public function close() |
|
| 138 | + { |
|
| 139 | + return true; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * Read session data |
|
| 144 | + * |
|
| 145 | + * @param string $id Session id |
|
| 146 | + * |
|
| 147 | + * @access public |
|
| 148 | + * @return mixed |
|
| 149 | + */ |
|
| 150 | + public function read($id) |
|
| 151 | + { |
|
| 152 | + $result = $this->mc->get($this->options['prefix'] . $id); |
|
| 153 | + return $result; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + /** |
|
| 157 | + * Write session data |
|
| 158 | + * |
|
| 159 | + * @param string $id Session id |
|
| 160 | + * @param mixed $data Session data |
|
| 161 | + * |
|
| 162 | + * @access public |
|
| 163 | + * @return bool |
|
| 164 | + */ |
|
| 165 | + public function write($id, $data) |
|
| 166 | + { |
|
| 167 | + $this->mc->set($this->options['prefix'] . $id, |
|
| 168 | + $data, |
|
| 169 | + MEMCACHE_COMPRESSED, |
|
| 170 | + time() + ini_get('session.gc_maxlifetime')); |
|
| 171 | + |
|
| 172 | + return true; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Destroy session data |
|
| 177 | + * |
|
| 178 | + * @param string $id Session id |
|
| 179 | + * |
|
| 180 | + * @access public |
|
| 181 | + * @return bool |
|
| 182 | + */ |
|
| 183 | + public function destroy($id) |
|
| 184 | + { |
|
| 185 | + $this->mc->delete($this->options['prefix'] . $id); |
|
| 186 | + return true; |
|
| 187 | + } |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * Garbage collection |
|
| 191 | + * |
|
| 192 | + * @param int $maxlifetime Maximum lifetime |
|
| 193 | + * |
|
| 194 | + * @access public |
|
| 195 | + * @return bool |
|
| 196 | + */ |
|
| 197 | + public function gc($maxlifetime) |
|
| 198 | + { |
|
| 199 | + return true; |
|
| 200 | + } |
|
| 201 | 201 | } |
| 202 | 202 | ?> |
| 203 | 203 | \ No newline at end of file |
@@ -59,306 +59,306 @@ |
||
| 59 | 59 | */ |
| 60 | 60 | class HTTP_Session_Container_DB extends HTTP_Session_Container |
| 61 | 61 | { |
| 62 | - /** |
|
| 63 | - * DB connection object |
|
| 64 | - * |
|
| 65 | - * @var object DB |
|
| 66 | - * @access private |
|
| 67 | - */ |
|
| 68 | - var $db = null; |
|
| 62 | + /** |
|
| 63 | + * DB connection object |
|
| 64 | + * |
|
| 65 | + * @var object DB |
|
| 66 | + * @access private |
|
| 67 | + */ |
|
| 68 | + var $db = null; |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * Session data cache id |
|
| 72 | - * |
|
| 73 | - * @var mixed |
|
| 74 | - * @access private |
|
| 75 | - */ |
|
| 76 | - var $crc = false; |
|
| 70 | + /** |
|
| 71 | + * Session data cache id |
|
| 72 | + * |
|
| 73 | + * @var mixed |
|
| 74 | + * @access private |
|
| 75 | + */ |
|
| 76 | + var $crc = false; |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * Constrtuctor method |
|
| 80 | - * |
|
| 81 | - * $options is an array with the options.<br> |
|
| 82 | - * The options are: |
|
| 83 | - * <ul> |
|
| 84 | - * <li>'dsn' - The DSN string</li> |
|
| 85 | - * <li>'table' - Table with session data, default is 'sessiondata'</li> |
|
| 86 | - * <li>'autooptimize' - Boolean, 'true' to optimize |
|
| 87 | - * the table on garbage collection, default is 'false'.</li> |
|
| 88 | - * </ul> |
|
| 89 | - * |
|
| 90 | - * @param array $options Options |
|
| 91 | - * |
|
| 92 | - * @access public |
|
| 93 | - * @return object |
|
| 94 | - */ |
|
| 95 | - public function HTTP_Session_Container_DB($options) |
|
| 96 | - { |
|
| 97 | - $this->_setDefaults(); |
|
| 98 | - if (is_array($options)) { |
|
| 99 | - $this->_parseOptions($options); |
|
| 100 | - } else { |
|
| 101 | - $this->options['dsn'] = $options; |
|
| 102 | - } |
|
| 103 | - } |
|
| 78 | + /** |
|
| 79 | + * Constrtuctor method |
|
| 80 | + * |
|
| 81 | + * $options is an array with the options.<br> |
|
| 82 | + * The options are: |
|
| 83 | + * <ul> |
|
| 84 | + * <li>'dsn' - The DSN string</li> |
|
| 85 | + * <li>'table' - Table with session data, default is 'sessiondata'</li> |
|
| 86 | + * <li>'autooptimize' - Boolean, 'true' to optimize |
|
| 87 | + * the table on garbage collection, default is 'false'.</li> |
|
| 88 | + * </ul> |
|
| 89 | + * |
|
| 90 | + * @param array $options Options |
|
| 91 | + * |
|
| 92 | + * @access public |
|
| 93 | + * @return object |
|
| 94 | + */ |
|
| 95 | + public function HTTP_Session_Container_DB($options) |
|
| 96 | + { |
|
| 97 | + $this->_setDefaults(); |
|
| 98 | + if (is_array($options)) { |
|
| 99 | + $this->_parseOptions($options); |
|
| 100 | + } else { |
|
| 101 | + $this->options['dsn'] = $options; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * Connect to database by using the given DSN string |
|
| 107 | - * |
|
| 108 | - * @param string $dsn DSN string |
|
| 109 | - * |
|
| 110 | - * @access private |
|
| 111 | - * @return mixed Object on error, otherwise bool |
|
| 112 | - */ |
|
| 113 | - public function _connect($dsn) |
|
| 114 | - { |
|
| 115 | - if (is_string($dsn) || is_array($dsn)) { |
|
| 116 | - $this->db = DB::connect($dsn); |
|
| 117 | - } else if (is_object($dsn) && is_a($dsn, "db_common")) { |
|
| 118 | - $this->db = $dsn; |
|
| 119 | - } else if (is_object($dsn) && DB::isError($dsn)) { |
|
| 120 | - return new DB_Error($dsn->code, PEAR_ERROR_DIE); |
|
| 121 | - } else { |
|
| 122 | - return new PEAR_Error("The given dsn was not valid in file " . __FILE__ |
|
| 123 | - . " at line " . __LINE__, |
|
| 124 | - 41, |
|
| 125 | - PEAR_ERROR_RETURN, |
|
| 126 | - null, |
|
| 127 | - null |
|
| 128 | - ); |
|
| 105 | + /** |
|
| 106 | + * Connect to database by using the given DSN string |
|
| 107 | + * |
|
| 108 | + * @param string $dsn DSN string |
|
| 109 | + * |
|
| 110 | + * @access private |
|
| 111 | + * @return mixed Object on error, otherwise bool |
|
| 112 | + */ |
|
| 113 | + public function _connect($dsn) |
|
| 114 | + { |
|
| 115 | + if (is_string($dsn) || is_array($dsn)) { |
|
| 116 | + $this->db = DB::connect($dsn); |
|
| 117 | + } else if (is_object($dsn) && is_a($dsn, "db_common")) { |
|
| 118 | + $this->db = $dsn; |
|
| 119 | + } else if (is_object($dsn) && DB::isError($dsn)) { |
|
| 120 | + return new DB_Error($dsn->code, PEAR_ERROR_DIE); |
|
| 121 | + } else { |
|
| 122 | + return new PEAR_Error("The given dsn was not valid in file " . __FILE__ |
|
| 123 | + . " at line " . __LINE__, |
|
| 124 | + 41, |
|
| 125 | + PEAR_ERROR_RETURN, |
|
| 126 | + null, |
|
| 127 | + null |
|
| 128 | + ); |
|
| 129 | 129 | |
| 130 | - } |
|
| 130 | + } |
|
| 131 | 131 | |
| 132 | - if (DB::isError($this->db)) { |
|
| 133 | - return new DB_Error($this->db->code, PEAR_ERROR_DIE); |
|
| 134 | - } |
|
| 132 | + if (DB::isError($this->db)) { |
|
| 133 | + return new DB_Error($this->db->code, PEAR_ERROR_DIE); |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - return true; |
|
| 137 | - } |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | - /** |
|
| 140 | - * Set some default options |
|
| 141 | - * |
|
| 142 | - * @access private |
|
| 143 | - * @return void |
|
| 144 | - */ |
|
| 145 | - public function _setDefaults() |
|
| 146 | - { |
|
| 147 | - $this->options['dsn'] = null; |
|
| 148 | - $this->options['table'] = 'sessiondata'; |
|
| 149 | - $this->options['autooptimize'] = false; |
|
| 150 | - } |
|
| 139 | + /** |
|
| 140 | + * Set some default options |
|
| 141 | + * |
|
| 142 | + * @access private |
|
| 143 | + * @return void |
|
| 144 | + */ |
|
| 145 | + public function _setDefaults() |
|
| 146 | + { |
|
| 147 | + $this->options['dsn'] = null; |
|
| 148 | + $this->options['table'] = 'sessiondata'; |
|
| 149 | + $this->options['autooptimize'] = false; |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - /** |
|
| 153 | - * Establish connection to a database |
|
| 154 | - * |
|
| 155 | - * @param string $save_path Save path |
|
| 156 | - * @param string $session_name Session name |
|
| 157 | - * |
|
| 158 | - * @return bool |
|
| 159 | - */ |
|
| 160 | - public function open($save_path, $session_name) |
|
| 161 | - { |
|
| 162 | - if (DB::isError($this->_connect($this->options['dsn']))) { |
|
| 163 | - return false; |
|
| 164 | - } else { |
|
| 165 | - return true; |
|
| 166 | - } |
|
| 167 | - } |
|
| 152 | + /** |
|
| 153 | + * Establish connection to a database |
|
| 154 | + * |
|
| 155 | + * @param string $save_path Save path |
|
| 156 | + * @param string $session_name Session name |
|
| 157 | + * |
|
| 158 | + * @return bool |
|
| 159 | + */ |
|
| 160 | + public function open($save_path, $session_name) |
|
| 161 | + { |
|
| 162 | + if (DB::isError($this->_connect($this->options['dsn']))) { |
|
| 163 | + return false; |
|
| 164 | + } else { |
|
| 165 | + return true; |
|
| 166 | + } |
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - /** |
|
| 170 | - * Free resources |
|
| 171 | - * |
|
| 172 | - * @return void |
|
| 173 | - */ |
|
| 174 | - public function close() |
|
| 175 | - { |
|
| 176 | - return true; |
|
| 177 | - } |
|
| 169 | + /** |
|
| 170 | + * Free resources |
|
| 171 | + * |
|
| 172 | + * @return void |
|
| 173 | + */ |
|
| 174 | + public function close() |
|
| 175 | + { |
|
| 176 | + return true; |
|
| 177 | + } |
|
| 178 | 178 | |
| 179 | - /** |
|
| 180 | - * Read session data |
|
| 181 | - * |
|
| 182 | - * @param string $id Session id |
|
| 183 | - * |
|
| 184 | - * @return void |
|
| 185 | - */ |
|
| 186 | - public function read($id) |
|
| 187 | - { |
|
| 188 | - $query = sprintf("SELECT data FROM %s WHERE id = %s && expiry >= %d", |
|
| 189 | - $this->options['table'], |
|
| 190 | - $this->db->quoteSmart(md5($id)), |
|
| 191 | - time()); |
|
| 192 | - $result = $this->db->getOne($query); |
|
| 193 | - if (DB::isError($result)) { |
|
| 194 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 195 | - return false; |
|
| 196 | - } |
|
| 197 | - $this->crc = strlen($result) . crc32($result); |
|
| 198 | - return $result; |
|
| 199 | - } |
|
| 179 | + /** |
|
| 180 | + * Read session data |
|
| 181 | + * |
|
| 182 | + * @param string $id Session id |
|
| 183 | + * |
|
| 184 | + * @return void |
|
| 185 | + */ |
|
| 186 | + public function read($id) |
|
| 187 | + { |
|
| 188 | + $query = sprintf("SELECT data FROM %s WHERE id = %s && expiry >= %d", |
|
| 189 | + $this->options['table'], |
|
| 190 | + $this->db->quoteSmart(md5($id)), |
|
| 191 | + time()); |
|
| 192 | + $result = $this->db->getOne($query); |
|
| 193 | + if (DB::isError($result)) { |
|
| 194 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 195 | + return false; |
|
| 196 | + } |
|
| 197 | + $this->crc = strlen($result) . crc32($result); |
|
| 198 | + return $result; |
|
| 199 | + } |
|
| 200 | 200 | |
| 201 | - /** |
|
| 202 | - * Write session data |
|
| 203 | - * |
|
| 204 | - * @param string $id Session id |
|
| 205 | - * @param mixed $data Data |
|
| 206 | - * |
|
| 207 | - * @return bool |
|
| 208 | - */ |
|
| 209 | - public function write($id, $data) |
|
| 210 | - { |
|
| 211 | - if ((false !== $this->crc) && |
|
| 212 | - ($this->crc === strlen($data) . crc32($data))) { |
|
| 213 | - // $_SESSION hasn't been touched, no need to update the blob column |
|
| 214 | - $query = sprintf("UPDATE %s SET expiry = %d WHERE id = %s", |
|
| 215 | - $this->options['table'], |
|
| 216 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 217 | - $this->db->quoteSmart(md5($id))); |
|
| 218 | - } else { |
|
| 219 | - // Check if table row already exists |
|
| 220 | - $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 221 | - $this->options['table'], |
|
| 222 | - $this->db->quoteSmart(md5($id))); |
|
| 223 | - $result = $this->db->getOne($query); |
|
| 224 | - if (DB::isError($result)) { |
|
| 225 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 226 | - return false; |
|
| 227 | - } |
|
| 228 | - if (0 == intval($result)) { |
|
| 229 | - // Insert new row into table |
|
| 230 | - $query = sprintf("INSERT INTO %s (id, expiry, data) VALUES (%s, %d, %s)", |
|
| 231 | - $this->options['table'], |
|
| 232 | - $this->db->quoteSmart(md5($id)), |
|
| 233 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 234 | - $this->db->quoteSmart($data)); |
|
| 235 | - } else { |
|
| 236 | - // Update existing row |
|
| 237 | - $query = sprintf("UPDATE %s SET expiry = %d, data = %s WHERE id = %s", |
|
| 238 | - $this->options['table'], |
|
| 239 | - time() + ini_get('session.gc_maxlifetime'), |
|
| 240 | - $this->db->quoteSmart($data), |
|
| 241 | - $this->db->quoteSmart(md5($id))); |
|
| 242 | - } |
|
| 243 | - } |
|
| 244 | - $result = $this->db->query($query); |
|
| 245 | - if (DB::isError($result)) { |
|
| 246 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 247 | - return false; |
|
| 248 | - } |
|
| 201 | + /** |
|
| 202 | + * Write session data |
|
| 203 | + * |
|
| 204 | + * @param string $id Session id |
|
| 205 | + * @param mixed $data Data |
|
| 206 | + * |
|
| 207 | + * @return bool |
|
| 208 | + */ |
|
| 209 | + public function write($id, $data) |
|
| 210 | + { |
|
| 211 | + if ((false !== $this->crc) && |
|
| 212 | + ($this->crc === strlen($data) . crc32($data))) { |
|
| 213 | + // $_SESSION hasn't been touched, no need to update the blob column |
|
| 214 | + $query = sprintf("UPDATE %s SET expiry = %d WHERE id = %s", |
|
| 215 | + $this->options['table'], |
|
| 216 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 217 | + $this->db->quoteSmart(md5($id))); |
|
| 218 | + } else { |
|
| 219 | + // Check if table row already exists |
|
| 220 | + $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 221 | + $this->options['table'], |
|
| 222 | + $this->db->quoteSmart(md5($id))); |
|
| 223 | + $result = $this->db->getOne($query); |
|
| 224 | + if (DB::isError($result)) { |
|
| 225 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 226 | + return false; |
|
| 227 | + } |
|
| 228 | + if (0 == intval($result)) { |
|
| 229 | + // Insert new row into table |
|
| 230 | + $query = sprintf("INSERT INTO %s (id, expiry, data) VALUES (%s, %d, %s)", |
|
| 231 | + $this->options['table'], |
|
| 232 | + $this->db->quoteSmart(md5($id)), |
|
| 233 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 234 | + $this->db->quoteSmart($data)); |
|
| 235 | + } else { |
|
| 236 | + // Update existing row |
|
| 237 | + $query = sprintf("UPDATE %s SET expiry = %d, data = %s WHERE id = %s", |
|
| 238 | + $this->options['table'], |
|
| 239 | + time() + ini_get('session.gc_maxlifetime'), |
|
| 240 | + $this->db->quoteSmart($data), |
|
| 241 | + $this->db->quoteSmart(md5($id))); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | + $result = $this->db->query($query); |
|
| 245 | + if (DB::isError($result)) { |
|
| 246 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 247 | + return false; |
|
| 248 | + } |
|
| 249 | 249 | |
| 250 | - return true; |
|
| 251 | - } |
|
| 250 | + return true; |
|
| 251 | + } |
|
| 252 | 252 | |
| 253 | - /** |
|
| 254 | - * Destroy session data |
|
| 255 | - * |
|
| 256 | - * @param string $id Session id |
|
| 257 | - * |
|
| 258 | - * @return void |
|
| 259 | - */ |
|
| 260 | - public function destroy($id) |
|
| 261 | - { |
|
| 262 | - $query = sprintf("DELETE FROM %s WHERE id = %s", |
|
| 263 | - $this->options['table'], |
|
| 264 | - $this->db->quoteSmart(md5($id))); |
|
| 265 | - $result = $this->db->query($query); |
|
| 266 | - if (DB::isError($result)) { |
|
| 267 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 268 | - return false; |
|
| 269 | - } |
|
| 253 | + /** |
|
| 254 | + * Destroy session data |
|
| 255 | + * |
|
| 256 | + * @param string $id Session id |
|
| 257 | + * |
|
| 258 | + * @return void |
|
| 259 | + */ |
|
| 260 | + public function destroy($id) |
|
| 261 | + { |
|
| 262 | + $query = sprintf("DELETE FROM %s WHERE id = %s", |
|
| 263 | + $this->options['table'], |
|
| 264 | + $this->db->quoteSmart(md5($id))); |
|
| 265 | + $result = $this->db->query($query); |
|
| 266 | + if (DB::isError($result)) { |
|
| 267 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 268 | + return false; |
|
| 269 | + } |
|
| 270 | 270 | |
| 271 | - return true; |
|
| 272 | - } |
|
| 271 | + return true; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - /** |
|
| 275 | - * Replicate session data to table specified in option 'replicateBeforeDestroy' |
|
| 276 | - * |
|
| 277 | - * @param string $targetTable Table to replicate to |
|
| 278 | - * @param string $id Id of record to replicate |
|
| 279 | - * |
|
| 280 | - * @access private |
|
| 281 | - * @return bool |
|
| 282 | - */ |
|
| 283 | - public function replicate($targetTable, $id = null) |
|
| 284 | - { |
|
| 285 | - if (is_null($id)) { |
|
| 286 | - $id = HTTP_Session::id(); |
|
| 287 | - } |
|
| 274 | + /** |
|
| 275 | + * Replicate session data to table specified in option 'replicateBeforeDestroy' |
|
| 276 | + * |
|
| 277 | + * @param string $targetTable Table to replicate to |
|
| 278 | + * @param string $id Id of record to replicate |
|
| 279 | + * |
|
| 280 | + * @access private |
|
| 281 | + * @return bool |
|
| 282 | + */ |
|
| 283 | + public function replicate($targetTable, $id = null) |
|
| 284 | + { |
|
| 285 | + if (is_null($id)) { |
|
| 286 | + $id = HTTP_Session::id(); |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - // Check if table row already exists |
|
| 290 | - $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 291 | - $targetTable, |
|
| 292 | - $this->db->quoteSmart(md5($id))); |
|
| 293 | - $result = $this->db->getOne($query); |
|
| 294 | - if (DB::isError($result)) { |
|
| 295 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 296 | - return false; |
|
| 297 | - } |
|
| 289 | + // Check if table row already exists |
|
| 290 | + $query = sprintf("SELECT COUNT(id) FROM %s WHERE id = %s", |
|
| 291 | + $targetTable, |
|
| 292 | + $this->db->quoteSmart(md5($id))); |
|
| 293 | + $result = $this->db->getOne($query); |
|
| 294 | + if (DB::isError($result)) { |
|
| 295 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 296 | + return false; |
|
| 297 | + } |
|
| 298 | 298 | |
| 299 | - // Insert new row into dest table |
|
| 300 | - if (0 == intval($result)) { |
|
| 301 | - $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", |
|
| 302 | - $targetTable, |
|
| 303 | - $this->options['table'], |
|
| 304 | - $this->db->quoteSmart(md5($id))); |
|
| 299 | + // Insert new row into dest table |
|
| 300 | + if (0 == intval($result)) { |
|
| 301 | + $query = sprintf("INSERT INTO %s SELECT * FROM %s WHERE id = %s", |
|
| 302 | + $targetTable, |
|
| 303 | + $this->options['table'], |
|
| 304 | + $this->db->quoteSmart(md5($id))); |
|
| 305 | 305 | |
| 306 | - } else { |
|
| 307 | - // Update existing row |
|
| 308 | - $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id && src.id = %s", |
|
| 309 | - $targetTable, |
|
| 310 | - $this->options['table'], |
|
| 311 | - $this->db->quoteSmart(md5($id))); |
|
| 312 | - } |
|
| 306 | + } else { |
|
| 307 | + // Update existing row |
|
| 308 | + $query = sprintf("UPDATE %s dst, %s src SET dst.expiry = src.expiry, dst.data = src.data WHERE dst.id = src.id && src.id = %s", |
|
| 309 | + $targetTable, |
|
| 310 | + $this->options['table'], |
|
| 311 | + $this->db->quoteSmart(md5($id))); |
|
| 312 | + } |
|
| 313 | 313 | |
| 314 | - $result = $this->db->query($query); |
|
| 315 | - if (DB::isError($result)) { |
|
| 316 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 317 | - return false; |
|
| 318 | - } |
|
| 314 | + $result = $this->db->query($query); |
|
| 315 | + if (DB::isError($result)) { |
|
| 316 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 317 | + return false; |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - return true; |
|
| 321 | - } |
|
| 320 | + return true; |
|
| 321 | + } |
|
| 322 | 322 | |
| 323 | - /** |
|
| 324 | - * Garbage collection |
|
| 325 | - * |
|
| 326 | - * @param int $maxlifetime Maximum lifetime |
|
| 327 | - * |
|
| 328 | - * @return bool |
|
| 329 | - */ |
|
| 330 | - public function gc($maxlifetime) |
|
| 331 | - { |
|
| 332 | - $query = sprintf("DELETE FROM %s WHERE expiry < %d", |
|
| 333 | - $this->options['table'], |
|
| 334 | - time()); |
|
| 335 | - $result = $this->db->query($query); |
|
| 336 | - if (DB::isError($result)) { |
|
| 337 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 338 | - return false; |
|
| 339 | - } |
|
| 340 | - if ($this->options['autooptimize']) { |
|
| 341 | - switch($this->db->phptype) { |
|
| 342 | - case 'mysql': |
|
| 343 | - $query = sprintf("OPTIMIZE TABLE %s", $this->options['table']); |
|
| 344 | - break; |
|
| 345 | - case 'pgsql': |
|
| 346 | - $query = sprintf("VACUUM %s", $this->options['table']); |
|
| 347 | - break; |
|
| 348 | - default: |
|
| 349 | - $query = null; |
|
| 350 | - break; |
|
| 351 | - } |
|
| 352 | - if (isset($query)) { |
|
| 353 | - $result = $this->db->query($query); |
|
| 354 | - if (DB::isError($result)) { |
|
| 355 | - new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 356 | - return false; |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 323 | + /** |
|
| 324 | + * Garbage collection |
|
| 325 | + * |
|
| 326 | + * @param int $maxlifetime Maximum lifetime |
|
| 327 | + * |
|
| 328 | + * @return bool |
|
| 329 | + */ |
|
| 330 | + public function gc($maxlifetime) |
|
| 331 | + { |
|
| 332 | + $query = sprintf("DELETE FROM %s WHERE expiry < %d", |
|
| 333 | + $this->options['table'], |
|
| 334 | + time()); |
|
| 335 | + $result = $this->db->query($query); |
|
| 336 | + if (DB::isError($result)) { |
|
| 337 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 338 | + return false; |
|
| 339 | + } |
|
| 340 | + if ($this->options['autooptimize']) { |
|
| 341 | + switch($this->db->phptype) { |
|
| 342 | + case 'mysql': |
|
| 343 | + $query = sprintf("OPTIMIZE TABLE %s", $this->options['table']); |
|
| 344 | + break; |
|
| 345 | + case 'pgsql': |
|
| 346 | + $query = sprintf("VACUUM %s", $this->options['table']); |
|
| 347 | + break; |
|
| 348 | + default: |
|
| 349 | + $query = null; |
|
| 350 | + break; |
|
| 351 | + } |
|
| 352 | + if (isset($query)) { |
|
| 353 | + $result = $this->db->query($query); |
|
| 354 | + if (DB::isError($result)) { |
|
| 355 | + new DB_Error($result->code, PEAR_ERROR_DIE); |
|
| 356 | + return false; |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | 360 | |
| 361 | - return true; |
|
| 362 | - } |
|
| 361 | + return true; |
|
| 362 | + } |
|
| 363 | 363 | } |
| 364 | 364 | ?> |
| 365 | 365 | \ No newline at end of file |
@@ -44,237 +44,237 @@ |
||
| 44 | 44 | */ |
| 45 | 45 | class HTTP_Session_Container |
| 46 | 46 | { |
| 47 | - /** |
|
| 48 | - * Additional options for the container object |
|
| 49 | - * |
|
| 50 | - * @var array |
|
| 51 | - * @access private |
|
| 52 | - */ |
|
| 53 | - var $options = array(); |
|
| 47 | + /** |
|
| 48 | + * Additional options for the container object |
|
| 49 | + * |
|
| 50 | + * @var array |
|
| 51 | + * @access private |
|
| 52 | + */ |
|
| 53 | + var $options = array(); |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Constrtuctor method |
|
| 57 | - * |
|
| 58 | - * @param array $options Additional options for the container object |
|
| 59 | - * |
|
| 60 | - * @access public |
|
| 61 | - * @return object |
|
| 62 | - */ |
|
| 63 | - public function HTTP_Session_Container($options = null) |
|
| 64 | - { |
|
| 65 | - $this->_setDefaults(); |
|
| 66 | - if (is_array($options)) { |
|
| 67 | - $this->_parseOptions(); |
|
| 68 | - } |
|
| 69 | - } |
|
| 55 | + /** |
|
| 56 | + * Constrtuctor method |
|
| 57 | + * |
|
| 58 | + * @param array $options Additional options for the container object |
|
| 59 | + * |
|
| 60 | + * @access public |
|
| 61 | + * @return object |
|
| 62 | + */ |
|
| 63 | + public function HTTP_Session_Container($options = null) |
|
| 64 | + { |
|
| 65 | + $this->_setDefaults(); |
|
| 66 | + if (is_array($options)) { |
|
| 67 | + $this->_parseOptions(); |
|
| 68 | + } |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * Set some default options |
|
| 73 | - * |
|
| 74 | - * @access private |
|
| 75 | - * @return void |
|
| 76 | - */ |
|
| 77 | - public function _setDefaults() |
|
| 78 | - { |
|
| 79 | - } |
|
| 71 | + /** |
|
| 72 | + * Set some default options |
|
| 73 | + * |
|
| 74 | + * @access private |
|
| 75 | + * @return void |
|
| 76 | + */ |
|
| 77 | + public function _setDefaults() |
|
| 78 | + { |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Parse options passed to the container class |
|
| 83 | - * |
|
| 84 | - * @param array $options Options |
|
| 85 | - * |
|
| 86 | - * @access private |
|
| 87 | - * @return void |
|
| 88 | - */ |
|
| 89 | - public function _parseOptions($options) |
|
| 90 | - { |
|
| 91 | - foreach ($options as $option => $value) { |
|
| 92 | - if (in_array($option, array_keys($this->options))) { |
|
| 93 | - $this->options[$option] = $value; |
|
| 94 | - } |
|
| 95 | - } |
|
| 96 | - } |
|
| 81 | + /** |
|
| 82 | + * Parse options passed to the container class |
|
| 83 | + * |
|
| 84 | + * @param array $options Options |
|
| 85 | + * |
|
| 86 | + * @access private |
|
| 87 | + * @return void |
|
| 88 | + */ |
|
| 89 | + public function _parseOptions($options) |
|
| 90 | + { |
|
| 91 | + foreach ($options as $option => $value) { |
|
| 92 | + if (in_array($option, array_keys($this->options))) { |
|
| 93 | + $this->options[$option] = $value; |
|
| 94 | + } |
|
| 95 | + } |
|
| 96 | + } |
|
| 97 | 97 | |
| 98 | - /** |
|
| 99 | - * This function is called by the session handler to initialize things |
|
| 100 | - * |
|
| 101 | - * @param string $save_path Save path |
|
| 102 | - * @param string $session_name Session name |
|
| 103 | - * |
|
| 104 | - * @access public |
|
| 105 | - * @return bool |
|
| 106 | - */ |
|
| 107 | - public function open($save_path, $session_name) |
|
| 108 | - { |
|
| 109 | - return true; |
|
| 110 | - } |
|
| 98 | + /** |
|
| 99 | + * This function is called by the session handler to initialize things |
|
| 100 | + * |
|
| 101 | + * @param string $save_path Save path |
|
| 102 | + * @param string $session_name Session name |
|
| 103 | + * |
|
| 104 | + * @access public |
|
| 105 | + * @return bool |
|
| 106 | + */ |
|
| 107 | + public function open($save_path, $session_name) |
|
| 108 | + { |
|
| 109 | + return true; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * This function is called when the page is finished |
|
| 114 | - * executing and the session handler needs to close things off |
|
| 115 | - * |
|
| 116 | - * Has to be overwritten by each container class |
|
| 117 | - * |
|
| 118 | - * @access public |
|
| 119 | - * @return bool |
|
| 120 | - */ |
|
| 121 | - public function close() |
|
| 122 | - { |
|
| 123 | - return true; |
|
| 124 | - } |
|
| 112 | + /** |
|
| 113 | + * This function is called when the page is finished |
|
| 114 | + * executing and the session handler needs to close things off |
|
| 115 | + * |
|
| 116 | + * Has to be overwritten by each container class |
|
| 117 | + * |
|
| 118 | + * @access public |
|
| 119 | + * @return bool |
|
| 120 | + */ |
|
| 121 | + public function close() |
|
| 122 | + { |
|
| 123 | + return true; |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - /** |
|
| 127 | - * This function is called by the session handler |
|
| 128 | - * to read the data associated with a given session ID. |
|
| 129 | - * This function must retrieve and return the session data |
|
| 130 | - * for the session identified by $id. |
|
| 131 | - * |
|
| 132 | - * Has to be overwritten by each container class |
|
| 133 | - * |
|
| 134 | - * @param string $id ID of the session |
|
| 135 | - * |
|
| 136 | - * @access public |
|
| 137 | - * @return string |
|
| 138 | - */ |
|
| 139 | - public function read($id) |
|
| 140 | - { |
|
| 141 | - return ''; |
|
| 142 | - } |
|
| 126 | + /** |
|
| 127 | + * This function is called by the session handler |
|
| 128 | + * to read the data associated with a given session ID. |
|
| 129 | + * This function must retrieve and return the session data |
|
| 130 | + * for the session identified by $id. |
|
| 131 | + * |
|
| 132 | + * Has to be overwritten by each container class |
|
| 133 | + * |
|
| 134 | + * @param string $id ID of the session |
|
| 135 | + * |
|
| 136 | + * @access public |
|
| 137 | + * @return string |
|
| 138 | + */ |
|
| 139 | + public function read($id) |
|
| 140 | + { |
|
| 141 | + return ''; |
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | - /** |
|
| 145 | - * This function is called when the session handler |
|
| 146 | - * has session data to save, which usually happens |
|
| 147 | - * at the end of your script |
|
| 148 | - * |
|
| 149 | - * Has to be overwritten by each container class |
|
| 150 | - * |
|
| 151 | - * @param string $id ID of the session |
|
| 152 | - * @param mixed $data The data associated with a given session ID |
|
| 153 | - * |
|
| 154 | - * @access public |
|
| 155 | - * @return bool |
|
| 156 | - */ |
|
| 157 | - public function write($id, $data) |
|
| 158 | - { |
|
| 159 | - return true; |
|
| 160 | - } |
|
| 144 | + /** |
|
| 145 | + * This function is called when the session handler |
|
| 146 | + * has session data to save, which usually happens |
|
| 147 | + * at the end of your script |
|
| 148 | + * |
|
| 149 | + * Has to be overwritten by each container class |
|
| 150 | + * |
|
| 151 | + * @param string $id ID of the session |
|
| 152 | + * @param mixed $data The data associated with a given session ID |
|
| 153 | + * |
|
| 154 | + * @access public |
|
| 155 | + * @return bool |
|
| 156 | + */ |
|
| 157 | + public function write($id, $data) |
|
| 158 | + { |
|
| 159 | + return true; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - /** |
|
| 163 | - * This function is called when a session is destroyed. |
|
| 164 | - * It is responsible for deleting the session and cleaning things up. |
|
| 165 | - * |
|
| 166 | - * Has to be overwritten by each container class |
|
| 167 | - * |
|
| 168 | - * @param string $id ID of the session |
|
| 169 | - * |
|
| 170 | - * @access public |
|
| 171 | - * @return bool |
|
| 172 | - */ |
|
| 173 | - public function destroy($id) |
|
| 174 | - { |
|
| 175 | - return true; |
|
| 176 | - } |
|
| 162 | + /** |
|
| 163 | + * This function is called when a session is destroyed. |
|
| 164 | + * It is responsible for deleting the session and cleaning things up. |
|
| 165 | + * |
|
| 166 | + * Has to be overwritten by each container class |
|
| 167 | + * |
|
| 168 | + * @param string $id ID of the session |
|
| 169 | + * |
|
| 170 | + * @access public |
|
| 171 | + * @return bool |
|
| 172 | + */ |
|
| 173 | + public function destroy($id) |
|
| 174 | + { |
|
| 175 | + return true; |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - /** |
|
| 179 | - * This function copies session data of specified id to specified table |
|
| 180 | - * |
|
| 181 | - * Has to be overwritten by each container class |
|
| 182 | - * |
|
| 183 | - * @param string $targetTable Table to replicate data to |
|
| 184 | - * @param string $id ID of the session |
|
| 185 | - * |
|
| 186 | - * @access public |
|
| 187 | - * @return bool |
|
| 188 | - */ |
|
| 189 | - public function replicate($targetTable, $id = null) |
|
| 190 | - { |
|
| 191 | - return true; |
|
| 192 | - } |
|
| 178 | + /** |
|
| 179 | + * This function copies session data of specified id to specified table |
|
| 180 | + * |
|
| 181 | + * Has to be overwritten by each container class |
|
| 182 | + * |
|
| 183 | + * @param string $targetTable Table to replicate data to |
|
| 184 | + * @param string $id ID of the session |
|
| 185 | + * |
|
| 186 | + * @access public |
|
| 187 | + * @return bool |
|
| 188 | + */ |
|
| 189 | + public function replicate($targetTable, $id = null) |
|
| 190 | + { |
|
| 191 | + return true; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - /** |
|
| 195 | - * This function is responsible for garbage collection. |
|
| 196 | - * In the case of session handling, it is responsible |
|
| 197 | - * for deleting old, stale sessions that are hanging around. |
|
| 198 | - * The session handler will call this every now and then. |
|
| 199 | - * |
|
| 200 | - * Has to be overwritten by each container class |
|
| 201 | - * |
|
| 202 | - * @param integer $maxlifetime Maximum lifetime |
|
| 203 | - * |
|
| 204 | - * @access public |
|
| 205 | - * @return bool |
|
| 206 | - */ |
|
| 207 | - public function gc($maxlifetime) |
|
| 208 | - { |
|
| 209 | - return true; |
|
| 210 | - } |
|
| 194 | + /** |
|
| 195 | + * This function is responsible for garbage collection. |
|
| 196 | + * In the case of session handling, it is responsible |
|
| 197 | + * for deleting old, stale sessions that are hanging around. |
|
| 198 | + * The session handler will call this every now and then. |
|
| 199 | + * |
|
| 200 | + * Has to be overwritten by each container class |
|
| 201 | + * |
|
| 202 | + * @param integer $maxlifetime Maximum lifetime |
|
| 203 | + * |
|
| 204 | + * @access public |
|
| 205 | + * @return bool |
|
| 206 | + */ |
|
| 207 | + public function gc($maxlifetime) |
|
| 208 | + { |
|
| 209 | + return true; |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - /** |
|
| 213 | - * Set session save handler |
|
| 214 | - * |
|
| 215 | - * @access public |
|
| 216 | - * @return void |
|
| 217 | - */ |
|
| 218 | - public function set() |
|
| 219 | - { |
|
| 220 | - $GLOBALS['HTTP_Session_Container'] =& $this; |
|
| 221 | - session_module_name('user'); |
|
| 222 | - session_set_save_handler('HTTP_Session_Open', |
|
| 223 | - 'HTTP_Session_Close', |
|
| 224 | - 'HTTP_Session_Read', |
|
| 225 | - 'HTTP_Session_Write', |
|
| 226 | - 'HTTP_Session_Destroy', |
|
| 227 | - 'HTTP_Session_GC'); |
|
| 228 | - } |
|
| 212 | + /** |
|
| 213 | + * Set session save handler |
|
| 214 | + * |
|
| 215 | + * @access public |
|
| 216 | + * @return void |
|
| 217 | + */ |
|
| 218 | + public function set() |
|
| 219 | + { |
|
| 220 | + $GLOBALS['HTTP_Session_Container'] =& $this; |
|
| 221 | + session_module_name('user'); |
|
| 222 | + session_set_save_handler('HTTP_Session_Open', |
|
| 223 | + 'HTTP_Session_Close', |
|
| 224 | + 'HTTP_Session_Read', |
|
| 225 | + 'HTTP_Session_Write', |
|
| 226 | + 'HTTP_Session_Destroy', |
|
| 227 | + 'HTTP_Session_GC'); |
|
| 228 | + } |
|
| 229 | 229 | |
| 230 | - /** |
|
| 231 | - * Destructor for compatibility with PHP >= 5.0.5 |
|
| 232 | - * |
|
| 233 | - * @access private |
|
| 234 | - * @return void |
|
| 235 | - */ |
|
| 236 | - public function __destruct() |
|
| 237 | - { |
|
| 238 | - $GLOBALS['HTTP_Session_Container'] =& $this; |
|
| 239 | - session_write_close(); |
|
| 240 | - } |
|
| 230 | + /** |
|
| 231 | + * Destructor for compatibility with PHP >= 5.0.5 |
|
| 232 | + * |
|
| 233 | + * @access private |
|
| 234 | + * @return void |
|
| 235 | + */ |
|
| 236 | + public function __destruct() |
|
| 237 | + { |
|
| 238 | + $GLOBALS['HTTP_Session_Container'] =& $this; |
|
| 239 | + session_write_close(); |
|
| 240 | + } |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | // Delegate function calls to the object's methods |
| 244 | 244 | /** @ignore */ |
| 245 | 245 | function HTTP_Session_Open($save_path, $session_name) |
| 246 | 246 | { |
| 247 | - return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->open($save_path, $session_name) |
|
| 248 | - : false; |
|
| 247 | + return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->open($save_path, $session_name) |
|
| 248 | + : false; |
|
| 249 | 249 | } |
| 250 | 250 | /** @ignore */ |
| 251 | 251 | function HTTP_Session_Close() |
| 252 | 252 | { |
| 253 | - return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->close() |
|
| 254 | - : false; |
|
| 253 | + return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->close() |
|
| 254 | + : false; |
|
| 255 | 255 | } |
| 256 | 256 | /** @ignore */ |
| 257 | 257 | function HTTP_Session_Read($id) |
| 258 | 258 | { |
| 259 | - return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->read($id) |
|
| 260 | - : false; |
|
| 259 | + return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->read($id) |
|
| 260 | + : false; |
|
| 261 | 261 | } |
| 262 | 262 | /** @ignore */ |
| 263 | 263 | function HTTP_Session_Write($id, $data) |
| 264 | 264 | { |
| 265 | - return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->write($id, $data) |
|
| 266 | - : false; |
|
| 265 | + return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->write($id, $data) |
|
| 266 | + : false; |
|
| 267 | 267 | } |
| 268 | 268 | /** @ignore */ |
| 269 | 269 | function HTTP_Session_Destroy($id) |
| 270 | 270 | { |
| 271 | - return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->destroy($id) |
|
| 272 | - : false; |
|
| 271 | + return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->destroy($id) |
|
| 272 | + : false; |
|
| 273 | 273 | } |
| 274 | 274 | /** @ignore */ |
| 275 | 275 | function HTTP_Session_GC($maxlifetime) |
| 276 | 276 | { |
| 277 | - return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->gc($maxlifetime) |
|
| 278 | - : false; |
|
| 277 | + return (isset($GLOBALS['HTTP_Session_Container'])) ? $GLOBALS['HTTP_Session_Container']->gc($maxlifetime) |
|
| 278 | + : false; |
|
| 279 | 279 | } |
| 280 | 280 | ?> |
| 281 | 281 | \ No newline at end of file |