[ Index ] |
|
Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1 |
1 <?php 2 /** 3 * @package linkpoint_api_payment_module 4 * @copyright Copyright 2003 LinkPoint International, Inc. All Rights Reserved. 5 * @version (within Zen Cart SVN) $Id: class.linkpoint_api.php 5423 2006-12-28 10:59:25Z drbyte $ 6 */ 7 /* lphp.php LINKPOINT PHP MODULE */ 8 9 /* A php interlocutor CLASS for 10 LinkPoint: LINKPOINT LSGS API using 11 libcurl, liblphp.so and liblpssl.so 12 v3.0.005 20 Aug. 2003 smoffet */ 13 14 # Copyright 2003 LinkPoint International, Inc. All Rights Reserved. 15 # 16 # This software is the proprietary information of LinkPoint International, Inc. 17 # Use is subject to license terms. 18 19 20 ### YOU REALLY DO NOT NEED TO EDIT THIS FILE! ### 21 22 23 class lphp 24 { 25 var $debugging; 26 27 ########################################### 28 # 29 # F U N C T I O N p r o c e s s ( ) 30 # 31 # process a hash table or XML string 32 # using LIBLPHP.SO and LIBLPSSL.SO 33 # 34 ########################################### 35 36 function process($data) 37 { 38 $using_xml = 0; 39 $webspace = 1; 40 41 if (isset($data["webspace"])) 42 { 43 if ($data["webspace"] == "false") // if explicitly set to false, don't use html output 44 $webspace = 0; 45 } 46 47 if ( isset($data["debugging"]) || isset($data["debug"]) ) 48 { 49 if ($data["debugging"] == "true" || $data["debug"] == "true" ) 50 { 51 $this->debugging = 1; 52 53 # print out incoming hash 54 if ($webspace) // use html-friendly output 55 { 56 echo "at process, incoming data: <br>"; 57 58 while (list($key, $value) = each($data)) 59 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n"; 60 } 61 else // don't use html output 62 { 63 echo "at process, incoming data: \n"; 64 65 while (list($key, $value) = each($data)) 66 echo "$key = $value\n"; 67 } 68 69 reset($data); 70 } 71 } 72 73 if (isset($data["xml"])) // if XML string is passed in, we'll use it 74 { 75 $using_xml = 1; 76 $xml = $data["xml"]; 77 } 78 else 79 { 80 // otherwise convert incoming hash to XML string 81 $xml = $this->buildXML($data); 82 } 83 84 // then set up transaction variables 85 $key = $data["keyfile"]; 86 $host = $data["host"]; 87 $port = $data["port"]; 88 89 90 # FOR PERFORMANCE, Use the 'extensions' statement in your php.ini to load 91 # this library at PHP startup, then comment out the next seven lines 92 93 // load library 94 if (!extension_loaded('liblphp')) 95 { 96 if (!dl('liblphp.so')) 97 { 98 exit("cannot load liblphp.so, bye\n"); 99 } 100 } 101 102 if ($this->debugging) 103 { 104 if ($webspace) 105 echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>"; 106 else 107 echo "\nsending xml string:\n$xml\n\n"; 108 } 109 110 // send transaction to LSGS 111 $retstg = send_stg($xml, $key, $host, $port); 112 113 114 if (strlen($retstg) < 4) 115 exit ("cannot connect to lsgs, exiting"); 116 117 if ($this->debugging) 118 { 119 if ($this->webspace) // we're web space 120 echo "<br>server responds:<br>" . htmlspecialchars($retstg) . "<br><br>"; 121 else // not html output 122 echo "\nserver responds:\n $retstg\n\n"; 123 } 124 125 if ($using_xml != 1) 126 { 127 // convert xml response back to hash 128 $retarr = $this->decodeXML($retstg); 129 130 // and send it back to caller 131 return ($retarr); 132 } 133 else 134 { 135 // send server response back 136 return $retstg; 137 } 138 } 139 140 141 ##################################################### 142 # 143 # F U N C T I O N c u r l _ p r o c e s s ( ) 144 # 145 # process hash table or xml string table using 146 # curl, either with PHP built-in curl methods 147 # or binary executable curl 148 # 149 ##################################################### 150 151 function curl_process($data) 152 { 153 $using_xml = 0; 154 $webspace = 1; 155 156 if (isset($data["webspace"])) 157 { 158 if ($data["webspace"] == "false") // if explicitly set to false, don't use html output 159 $webspace = 0; 160 } 161 162 if (isset($data["debugging"]) || isset($data["debug"]) ) 163 { 164 if ($data["debugging"] == "true" || $data["debug"] == "true" ) 165 { 166 $this->debugging = 1; 167 168 # print out incoming hash 169 if ($webspace) // use html-friendly output 170 { 171 echo "at curl_process, incoming data: <br>"; 172 173 while (list($key, $value) = each($data)) 174 echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<BR>\n"; 175 } 176 else // don't use html output 177 { 178 echo "at curl_process, incoming data: \n"; 179 $this->sendData = "\nat curl_process, incoming data: \n"; 180 181 while (list($key, $value) = each($data)) { 182 echo "$key = $value\n"; 183 if ($key != 'cardnumber' && $key != 'cvmvalue') $this->sendData .= "$key = $value\n"; 184 } 185 } 186 187 reset($data); 188 } 189 } 190 191 if (isset($data["xml"])) // if XML string is passed in, we'll use it 192 { 193 $using_xml = 1; 194 $xml = $data["xml"]; 195 } 196 else 197 { 198 // otherwise convert incoming hash to XML string 199 $xml = $this->buildXML($data); 200 } 201 202 if ($this->debugging) 203 { 204 if ($webspace) 205 echo "<br>sending xml string:<br>" . htmlspecialchars($xml) . "<br><br>"; 206 else 207 echo "\nsending xml string:\n$xml\n\n"; 208 $this->xmlString .= "\nsending xml string:\n$xml\n\n"; 209 } 210 211 // set up transaction variables 212 $key = $data["keyfile"]; 213 $port = $data["port"]; 214 $host = "https://".$data["host"].":".$port."/LSGSXML"; 215 216 217 if (isset($data["cbin"])) //using BINARY curl methods 218 { 219 if ($data["cbin"] == "true") 220 { 221 if (isset($data["cpath"])) 222 $cpath = $data["cpath"]; 223 224 else // curl path has not been set, try to find curl binary 225 { 226 if (getenv("OS") == "Windows_NT") 227 $cpath = "c:\\curl\\curl.exe"; 228 else 229 $cpath = "/usr/bin/curl"; 230 } 231 232 // look for $cargs variable, otherwise use default curl arguments 233 if (isset($data["cargs"])) 234 $args = $data["cargs"]; 235 else 236 $args = "-m 300 -s -S"; // default curl args; 5 min. timeout 237 238 239 # TRANSACT # 240 241 if (getenv("OS") == "Windows_NT") 242 { 243 if ($this->debugging) 244 $result = exec ("$cpath -v -d \"$xml\" -E $key -k $host", $retarr, $retnum); 245 else 246 $result = exec ("$cpath -d \"$xml\" -E $key -k $host", $retarr, $retnum); 247 } 248 249 else //*nix string 250 { 251 if ($this->debugging) 252 $result = exec ("'$cpath' $args -v -k -E '$key' -d '$xml' '$host'", $retarr, $retnum); 253 else 254 $result = exec ("'$cpath' $args -v -k -E '$key' -d '$xml' '$host'", $retarr, $retnum); 255 } 256 257 # EVALUATE RESPONSE # 258 259 if (strlen($result) < 2) // no response 260 { 261 $result = "<r_approved>FAILURE</r_approved><r_error>Could not connect.</r_error>"; 262 return $result; 263 } 264 265 if ($this->debugging) 266 { 267 if ($this->webspace) 268 echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>"; 269 else // non html output 270 echo "\nserver responds:\n $result\n\n"; 271 $this->serverResponse .= "\nserver responds:\n $result\n\n"; 272 } 273 274 if ($using_xml == 1) 275 { 276 // return xml string straight from server 277 return ($result); 278 } 279 else 280 { 281 // convert xml response back to hash 282 $retarr = $this->decodeXML($result); 283 284 // and send it back to caller. Done. 285 return ($retarr); 286 } 287 } 288 } 289 290 else // using BUILT-IN PHP curl methods 291 { 292 $ch = curl_init (); 293 curl_setopt ($ch, CURLOPT_URL,$host); 294 curl_setopt ($ch, CURLOPT_POST, 1); 295 curl_setopt ($ch, CURLOPT_POSTFIELDS, $xml); 296 curl_setopt ($ch, CURLOPT_SSLCERT, $key); 297 curl_setopt ($ch, CURLOPT_CAINFO, $key); 298 curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, false); 299 curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, false); 300 curl_setopt ($ch, CURLOPT_SSLVERSION, 3); 301 curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true); 302 303 304 if (CURL_PROXY_REQUIRED == 'True') { 305 $proxy_tunnel_flag = (defined('CURL_PROXY_TUNNEL_FLAG') && strtoupper(CURL_PROXY_TUNNEL_FLAG) == 'FALSE') ? false : true; 306 curl_setopt ($ch, CURLOPT_HTTPPROXYTUNNEL, $proxy_tunnel_flag); 307 curl_setopt ($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); 308 curl_setopt ($ch, CURLOPT_PROXY, CURL_PROXY_SERVER_DETAILS); 309 } 310 311 if ($this->debugging) 312 curl_setopt ($ch, CURLOPT_VERBOSE, 1); 313 314 # use curl to send the xml SSL string 315 $result = curl_exec ($ch); 316 $this->commInfo = @curl_getinfo($ch); 317 if ($this->debugging) 318 { 319 if ($webspace) // html-friendly output 320 echo "<br>server responds:<br>" . htmlspecialchars(curl_error($ch)). ' <br>ErrNo#: ' . curl_errno($ch) . "<br><br>"; 321 else 322 echo "\nserver responds:\n". curl_error($ch). " \nErrNo:" . curl_errno($ch)."\n\n"; 323 $this->commError = "\nCommunication Result:\n". curl_error($ch). " \nErrNo: " . curl_errno($ch)."\n\n"; 324 } 325 curl_close($ch); 326 if (strlen($result) < 2) # no response 327 { 328 $result = "<r_approved>FAILURE</r_approved><r_error>Could not connect.</r_error>"; 329 if ($this->debugging) 330 { 331 if ($webspace) // html-friendly output 332 echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>"; 333 else 334 echo "\nserver responds:\n $result\n\n"; 335 $this->serverResponse .= "\nCould Not Connect:\n $result\n\n"; 336 } 337 return $result; 338 } 339 340 if ($this->debugging) 341 { 342 if ($webspace) // html-friendly output 343 echo "<br>server responds:<br>" . htmlspecialchars($result) . "<br><br>"; 344 else 345 echo "\nserver responds:\n $result\n\n"; 346 $this->serverResponse .= "\nserver responds:\n $result\n\n"; 347 } 348 349 if ($using_xml) 350 { 351 # send xml response back 352 return $result; 353 } 354 else 355 { 356 #convert xml response to hash 357 $retarr = $this->decodeXML($result); 358 359 # and send it back 360 return ($retarr); 361 } 362 } 363 } 364 365 366 ############################################# 367 # 368 # F U N C T I O N d e c o d e X M L ( ) 369 # 370 # converts the LSGS response xml string 371 # to a hash of name-value pairs 372 # 373 ############################################# 374 375 function decodeXML($xmlstg) 376 { 377 preg_match_all ("/<(.*?)>(.*?)\</", $xmlstg, $out, PREG_SET_ORDER); 378 379 $n = 0; 380 while (isset($out[$n])) 381 { 382 $retarr[$out[$n][1]] = strip_tags($out[$n][0]); 383 $n++; 384 } 385 386 return $retarr; 387 } 388 389 390 ############################################ 391 # 392 # F U N C T I O N b u i l d X M L ( ) 393 # 394 # converts a hash of name-value pairs 395 # to the correct XML format for LSGS 396 # 397 ############################################ 398 399 function buildXML($pdata) 400 { 401 402 // while (list($key, $value) = each($pdata)) 403 // echo htmlspecialchars($key) . " = " . htmlspecialchars($value) . "<br>\n"; 404 405 406 ### ORDEROPTIONS NODE ### 407 $xml = "<order><orderoptions>"; 408 409 if (isset($pdata["ordertype"])) 410 $xml .= "<ordertype>" . $pdata["ordertype"] . "</ordertype>"; 411 412 if (isset($pdata["result"])) 413 $xml .= "<result>" . $pdata["result"] . "</result>"; 414 415 $xml .= "</orderoptions>"; 416 417 418 ### CREDITCARD NODE ### 419 $xml .= "<creditcard>"; 420 421 if (isset($pdata["cardnumber"])) 422 $xml .= "<cardnumber>" . $pdata["cardnumber"] . "</cardnumber>"; 423 424 if (isset($pdata["cardexpmonth"])) 425 $xml .= "<cardexpmonth>" . $pdata["cardexpmonth"] . "</cardexpmonth>"; 426 427 if (isset($pdata["cardexpyear"])) 428 $xml .= "<cardexpyear>" . $pdata["cardexpyear"] . "</cardexpyear>"; 429 430 if (isset($pdata["cvmvalue"])) 431 $xml .= "<cvmvalue>" . $pdata["cvmvalue"] . "</cvmvalue>"; 432 433 if (isset($pdata["cvmindicator"])) 434 $xml .= "<cvmindicator>" . $pdata["cvmindicator"] . "</cvmindicator>"; 435 436 if (isset($pdata["track"])) 437 $xml .= "<track>" . $pdata["track"] . "</track>"; 438 439 $xml .= "</creditcard>"; 440 441 442 ### BILLING NODE ### 443 $xml .= "<billing>"; 444 445 if (isset($pdata["name"])) 446 $xml .= "<name>" . $pdata["name"] . "</name>"; 447 448 if (isset($pdata["company"])) 449 $xml .= "<company>" . $pdata["company"] . "</company>"; 450 451 if (isset($pdata["address1"])) 452 $xml .= "<address1>" . $pdata["address1"] . "</address1>"; 453 elseif (isset($pdata["address"])) 454 $xml .= "<address1>" . $pdata["address"] . "</address1>"; 455 456 if (isset($pdata["address2"])) 457 $xml .= "<address2>" . $pdata["address2"] . "</address2>"; 458 459 if (isset($pdata["city"])) 460 $xml .= "<city>" . $pdata["city"] . "</city>"; 461 462 if (isset($pdata["state"])) 463 $xml .= "<state>" . $pdata["state"] . "</state>"; 464 465 if (isset($pdata["zip"])) 466 $xml .= "<zip>" . $pdata["zip"] . "</zip>"; 467 468 if (isset($pdata["country"])) 469 $xml .= "<country>" . $pdata["country"] . "</country>"; 470 471 if (isset($pdata["userid"])) 472 $xml .= "<userid>" . $pdata["userid"] . "</userid>"; 473 474 if (isset($pdata["email"])) 475 $xml .= "<email>" . $pdata["email"] . "</email>"; 476 477 if (isset($pdata["phone"])) 478 $xml .= "<phone>" . $pdata["phone"] . "</phone>"; 479 480 if (isset($pdata["fax"])) 481 $xml .= "<fax>" . $pdata["fax"] . "</fax>"; 482 483 if (isset($pdata["addrnum"])) 484 $xml .= "<addrnum>" . $pdata["addrnum"] . "</addrnum>"; 485 486 $xml .= "</billing>"; 487 488 489 ## SHIPPING NODE ## 490 $xml .= "<shipping>"; 491 492 if (isset($pdata["sname"])) 493 $xml .= "<name>" . $pdata["sname"] . "</name>"; 494 495 if (isset($pdata["saddress1"])) 496 $xml .= "<address1>" . $pdata["saddress1"] . "</address1>"; 497 498 if (isset($pdata["saddress2"])) 499 $xml .= "<address2>" . $pdata["saddress2"] . "</address2>"; 500 501 if (isset($pdata["scity"])) 502 $xml .= "<city>" . $pdata["scity"] . "</city>"; 503 504 if (isset($pdata["sstate"])) 505 $xml .= "<state>" . $pdata["sstate"] . "</state>"; 506 elseif (isset($pdata["state"])) 507 $xml .= "<state>" . $pdata["sstate"] . "</state>"; 508 509 if (isset($pdata["szip"])) 510 $xml .= "<zip>" . $pdata["szip"] . "</zip>"; 511 elseif (isset($pdata["sip"])) 512 $xml .= "<zip>" . $pdata["zip"] . "</zip>"; 513 514 if (isset($pdata["scountry"])) 515 $xml .= "<country>" . $pdata["scountry"] . "</country>"; 516 517 if (isset($pdata["scarrier"])) 518 $xml .= "<carrier>" . $pdata["scarrier"] . "</carrier>"; 519 520 if (isset($pdata["sitems"])) 521 $xml .= "<items>" . $pdata["sitems"] . "</items>"; 522 523 if (isset($pdata["sweight"])) 524 $xml .= "<weight>" . $pdata["sweight"] . "</weight>"; 525 526 if (isset($pdata["stotal"])) 527 $xml .= "<total>" . $pdata["stotal"] . "</total>"; 528 529 $xml .= "</shipping>"; 530 531 532 ### TRANSACTIONDETAILS NODE ### 533 $xml .= "<transactiondetails>"; 534 535 if (isset($pdata["oid"])) 536 $xml .= "<oid>" . $pdata["oid"] . "</oid>"; 537 538 if (isset($pdata["ponumber"])) 539 $xml .= "<ponumber>" . $pdata["ponumber"] . "</ponumber>"; 540 541 if (isset($pdata["recurring"])) 542 $xml .= "<recurring>" . $pdata["recurring"] . "</recurring>"; 543 544 if (isset($pdata["taxexempt"])) 545 $xml .= "<taxexempt>" . $pdata["taxexempt"] . "</taxexempt>"; 546 547 if (isset($pdata["terminaltype"])) 548 $xml .= "<terminaltype>" . $pdata["terminaltype"] . "</terminaltype>"; 549 550 if (isset($pdata["ip"])) 551 $xml .= "<ip>" . $pdata["ip"] . "</ip>"; 552 553 if (isset($pdata["reference_number"])) 554 $xml .= "<reference_number>" . $pdata["reference_number"] . "</reference_number>"; 555 556 if (isset($pdata["transactionorigin"])) 557 $xml .= "<transactionorigin>" . $pdata["transactionorigin"] . "</transactionorigin>"; 558 559 if (isset($pdata["tdate"])) 560 $xml .= "<tdate>" . $pdata["tdate"] . "</tdate>"; 561 562 $xml .= "</transactiondetails>"; 563 564 565 ### MERCHANTINFO NODE ### 566 $xml .= "<merchantinfo>"; 567 568 if (isset($pdata["configfile"])) 569 $xml .= "<configfile>" . $pdata["configfile"] . "</configfile>"; 570 571 if (isset($pdata["keyfile"])) 572 $xml .= "<keyfile>" . $pdata["keyfile"] . "</keyfile>"; 573 574 if (isset($pdata["host"])) 575 $xml .= "<host>" . $pdata["host"] . "</host>"; 576 577 if (isset($pdata["port"])) 578 $xml .= "<port>" . $pdata["port"] . "</port>"; 579 580 if (isset($pdata["appname"])) 581 $xml .= "<appname>" . $pdata["appname"] . "</appname>"; 582 583 $xml .= "</merchantinfo>"; 584 585 586 587 ### PAYMENT NODE ### 588 $xml .= "<payment>"; 589 590 if (isset($pdata["chargetotal"])) 591 $xml .= "<chargetotal>" . $pdata["chargetotal"] . "</chargetotal>"; 592 593 if (isset($pdata["tax"])) 594 $xml .= "<tax>" . $pdata["tax"] . "</tax>"; 595 596 if (isset($pdata["vattax"])) 597 $xml .= "<vattax>" . $pdata["vattax"] . "</vattax>"; 598 599 if (isset($pdata["shipping"])) 600 $xml .= "<shipping>" . $pdata["shipping"] . "</shipping>"; 601 602 if (isset($pdata["subtotal"])) 603 $xml .= "<subtotal>" . $pdata["subtotal"] . "</subtotal>"; 604 605 $xml .= "</payment>"; 606 607 608 ### CHECK NODE ### 609 610 611 if (isset($pdata["voidcheck"])) 612 { 613 $xml .= "<telecheck><void>1</void></telecheck>"; 614 } 615 elseif (isset($pdata["routing"])) 616 { 617 $xml .= "<telecheck>"; 618 $xml .= "<routing>" . $pdata["routing"] . "</routing>"; 619 620 if (isset($pdata["account"])) 621 $xml .= "<account>" . $pdata["account"] . "</account>"; 622 623 if (isset($pdata["bankname"])) 624 $xml .= "<bankname>" . $pdata["bankname"] . "</bankname>"; 625 626 if (isset($pdata["bankstate"])) 627 $xml .= "<bankstate>" . $pdata["bankstate"] . "</bankstate>"; 628 629 if (isset($pdata["ssn"])) 630 $xml .= "<ssn>" . $pdata["ssn"] . "</ssn>"; 631 632 if (isset($pdata["dl"])) 633 $xml .= "<dl>" . $pdata["dl"] . "</dl>"; 634 635 if (isset($pdata["dlstate"])) 636 $xml .= "<dlstate>" . $pdata["dlstate"] . "</dlstate>"; 637 638 if (isset($pdata["checknumber"])) 639 $xml .= "<checknumber>" . $pdata["checknumber"] . "</checknumber>"; 640 641 if (isset($pdata["accounttype"])) 642 $xml .= "<accounttype>" . $pdata["accounttype"] . "</accounttype>"; 643 644 $xml .= "</telecheck>"; 645 } 646 647 648 ### PERIODIC NODE ### 649 650 if (isset($pdata["startdate"])) 651 { 652 $xml .= "<periodic>"; 653 654 $xml .= "<startdate>" . $pdata["startdate"] . "</startdate>"; 655 656 if (isset($pdata["installments"])) 657 $xml .= "<installments>" . $pdata["installments"] . "</installments>"; 658 659 if (isset($pdata["threshold"])) 660 $xml .= "<threshold>" . $pdata["threshold"] . "</threshold>"; 661 662 if (isset($pdata["periodicity"])) 663 $xml .= "<periodicity>" . $pdata["periodicity"] . "</periodicity>"; 664 665 if (isset($pdata["pbcomments"])) 666 $xml .= "<comments>" . $pdata["pbcomments"] . "</comments>"; 667 668 if (isset($pdata["action"])) 669 $xml .= "<action>" . $pdata["action"] . "</action>"; 670 671 $xml .= "</periodic>"; 672 } 673 674 675 ### NOTES NODE ### 676 677 if (isset($pdata["comments"]) || isset($pdata["referred"])) 678 { 679 $xml .= "<notes>"; 680 681 if (isset($pdata["comments"])) 682 $xml .= "<comments>" . $pdata["comments"] . "</comments>"; 683 684 if (isset($pdata["referred"])) 685 $xml .= "<referred>" . $pdata["referred"] . "</referred>"; 686 687 $xml .= "</notes>"; 688 } 689 690 ### ITEMS AND OPTIONS NODES ### 691 692 if ($this->debugging) // make it easy to see 693 { // LSGS doesn't mind whitespace 694 reset($pdata); 695 696 while (list ($key, $val) = each ($pdata)) 697 { 698 if (is_array($val)) 699 { 700 $otag = 0; 701 $ostag = 0; 702 $items_array = $val; 703 $xml .= "\n<items>\n"; 704 705 while(list($key1, $val1) = each ($items_array)) 706 { 707 $xml .= "\t<item>\n"; 708 709 while (list($key2, $val2) = each ($val1)) 710 { 711 if (!is_array($val2)) 712 $xml .= "\t\t<$key2>$val2</$key2>\n"; 713 714 else 715 { 716 if (!$ostag) 717 { 718 $xml .= "\t\t<options>\n"; 719 $ostag = 1; 720 } 721 722 $xml .= "\t\t\t<option>\n"; 723 $otag = 1; 724 725 while (list($key3, $val3) = each ($val2)) 726 $xml .= "\t\t\t\t<$key3>$val3</$key3>\n"; 727 } 728 729 if ($otag) 730 { 731 $xml .= "\t\t\t</option>\n"; 732 $otag = 0; 733 } 734 } 735 736 if ($ostag) 737 { 738 $xml .= "\t\t</options>\n"; 739 $ostag = 0; 740 } 741 $xml .= "\t</item>\n"; 742 } 743 $xml .= "</items>\n"; 744 } 745 } 746 } 747 748 else // !debugging 749 { 750 while (list ($key, $val) = each ($pdata)) 751 { 752 if (is_array($val)) 753 { 754 $otag = 0; 755 $ostag = 0; 756 $items_array = $val; 757 $xml .= "<items>"; 758 759 while(list($key1, $val1) = each ($items_array)) 760 { 761 $xml .= "<item>"; 762 763 while (list($key2, $val2) = each ($val1)) 764 { 765 if (!is_array($val2)) 766 $xml .= "<$key2>$val2</$key2>"; 767 768 else 769 { 770 if (!$ostag) 771 { 772 $xml .= "<options>"; 773 $ostag = 1; 774 } 775 776 $xml .= "<option>"; 777 $otag = 1; 778 779 while (list($key3, $val3) = each ($val2)) 780 $xml .= "<$key3>$val3</$key3>"; 781 } 782 783 if ($otag) 784 { 785 $xml .= "</option>"; 786 $otag = 0; 787 } 788 } 789 790 if ($ostag) 791 { 792 $xml .= "</options>"; 793 $ostag = 0; 794 } 795 $xml .= "</item>"; 796 } 797 $xml .= "</items>"; 798 } 799 } 800 } 801 802 $xml .= "</order>"; 803 804 return $xml; 805 } 806 } 807 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 16:45:43 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |