about summary refs log tree commit diff stats
path: root/js/magic-bird/imgs/extracted-1688-map/MapParts/hills/85.png
blob: e5e80225b58345a5d53d63b879cf324e032d4769 (plain)
ofshex dumpascii
0000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 4f 00 00 00 1d 08 06 00 00 00 eb 72 31 .PNG........IHDR...O..........r1
0020 7a 00 00 05 3c 49 44 41 54 78 da ed 99 0f 48 94 67 1c c7 af 52 2c 17 a6 61 8a 46 c5 8c 25 6c 38 z...<IDATx....H.g...R,..a.F..%l8
0040 2c 92 c4 49 92 14 ca 62 23 69 c4 64 32 d9 68 88 51 5c 0c 63 12 c5 64 21 86 11 c5 49 24 27 46 74 ,..I...b#i.d2.h.Q\.c..d!...I$'Ft
0060 28 4a 87 6c dc 71 a1 38 36 14 47 92 38 6c 2c 82 04 8b 8d 2d 6a 34 99 ce f9 77 db f7 81 cf 4b 2f (J.l.q.86.G.8l,....-j4...w....K/
0080 2f 6a 73 cb d1 9d fe e0 83 ef dd bd ef bd f7 7c df df df 47 97 6b d9 5e 58 5b 21 de 11 41 b1 72 /js............|...G.k.^X[!..A.r
00a0 59 8e 85 59 ae 38 2f 06 44 e6 2c 9f a7 88 02 b1 43 ac b1 bd bf e4 85 7e 57 1c 13 1f 89 32 8e 77 Y..Y.8/.D.,.....C......~W....2.w
00c0 f0 59 aa 38 2c 3a c4 94 18 17 d7 10 f2 6d 71 8a 6b 5e 16 1b 96 82 98 ab c0 b2 90 f8 44 a4 89 04 .Y.8,:.......mq.k^..........D...
00e0 f1 a5 b8 2b 02 e2 8e 18 11 33 e2 4f 98 e6 bd 47 e2 0f 04 fd 55 fc 20 7e 14 9f 8b b8 48 16 d0 78 ...+.....3.O...G....U..~....H..x
0100 cd 2e 8e 1b 45 95 d8 ce eb 3a f1 99 28 14 c3 e2 0b f1 a1 c8 c7 2b 6f 22 a0 11 ef 5b f1 95 68 e7 ....E....:..(........+o"...[..h.
0120 ef 6d f1 bd 68 e3 7b f6 47 a2 78 97 44 ad 58 27 8e b2 50 13 82 e9 a2 94 1c 67 ec 3b 51 ec b8 d6 .m..h.{.G.x.D.X'..P......g.;Q...
0140 8d e7 3d 10 3e 84 ff 54 5c 16 d7 c5 37 62 54 4c 88 5e c2 da 3c a8 ad 8e 7c 19 b6 66 72 d8 d7 e2 ..=.>..T\...7bTL.^..<...|..fr...
0160 4d 3c ca 2f 9e 50 30 f6 3a 44 ce 72 5c 6b 84 b8 47 b8 86 10 de 88 d8 c5 f7 1a 01 5b f0 50 13 ce M<./.P0.:D.r\k..G..........[.P..
0180 7f d9 42 de 78 65 36 0f 2d ec ec 15 b1 45 e4 88 3c f1 1a ef 27 52 65 37 3a ce 8f 11 ab 1d ef 1d ..B.xe6.-....E..<...'Re7:.......
01a0 a0 78 4c 23 d8 05 bc f6 a2 68 25 84 6f 88 5f 6c b9 d2 08 fd 9b 78 88 f0 03 88 db 86 67 6f c7 db .xL#.....h%.o._l.....x......go..
01c0 2d cf 5c cd 6f ab 14 49 8b 25 c6 49 f1 ea 3f 38 ef 75 b1 0f 81 fe 6b 45 34 8b ea 47 bc 6e e1 21 -.\.o..I.%.I..?8.u....kE4..G.n.!
01e0 74 ab 68 77 bc a2 81 1c 38 40 f1 f9 1d 01 a7 10 73 86 eb 47 09 73 53 9c 9a 08 fd 1a bc 39 48 01 t.hw....8@......s..G.sS......9H.
0200 ba 2a ca c9 c1 69 f3 84 7e 34 29 c2 5c fb 96 38 37 df 22 92 09 a1 94 67 2c 76 0b de 70 82 1b 3c .*...i..~4).\..87."....g,v..p..<
0220 0f 2b 45 88 4e c4 ab 47 b8 2a 2a f7 09 16 6c 16 73 5a 0c 91 27 47 08 65 e3 81 8f 29 48 63 8e 6a .+E.N..G.**...l.sZ..'G.e...)Hc.j
0240 6e 3f 9e 84 69 ee 77 0b 71 8e 88 12 f1 86 c8 c0 39 32 88 0a d3 7a 6d 43 e8 4d ff 76 81 85 84 d5 n?..i.w.q.......92...zmC.M.v....
0260 90 2d 3c e7 9a 2e 16 6a 9b 59 50 33 21 eb 23 54 43 1c 57 8b 83 e4 cb 9d 14 19 d3 47 16 51 81 4f .-<....j.YP3!.#TC.W........G.Q.O
0280 12 b6 33 14 96 19 c4 31 82 f6 89 9f f1 d4 5e 5a 9f 00 5e 3c c5 b9 93 a4 85 31 ce 1b a7 fa 5b 85 ..3....1......^Z..^<.....1....[.
02a0 6a 14 91 f7 88 a8 85 e4 34 f3 d4 cf d2 56 14 cd 92 f0 9f 97 05 29 0c 57 08 39 1f 0d 74 1b 61 dd j.......4....V.......).W.9..t.a.
02c0 45 21 aa 27 94 2b 28 4e 89 2c c8 fc d6 f7 11 f5 30 55 bf 9a 87 e0 27 ec 2a b9 b6 15 6e d2 1e f5 E!.'.+(N.,......0U....'.*...n...
02e0 52 9c ba 11 f7 0c 6b cd 43 b0 43 62 bd f3 07 c7 e1 8e e9 fc cd e4 82 03 fc b0 0a 6e d2 b4 88 a2 R.....k.C.Cb...............n....
0300 59 76 0a f1 42 08 d6 c0 d3 36 f7 ff 49 dc 47 c4 20 15 d8 12 30 97 94 b3 09 af cc e2 d8 b4 32 ef Yv..B....6..I.G.....0.........2.
0320 89 1e aa 7c 3e b9 ab 86 b6 aa 04 a1 2b 49 05 1f 20 7e 01 13 ce bc 96 44 7b 31 61 cb 05 c3 30 ce ...|>.......+I...~.....D{1a...0.
0340 53 31 5f 1e fb 3f 55 ee 33 78 5b 80 dc d7 8a 97 35 22 80 97 fc 57 c6 e2 83 84 64 0f 45 a2 9b f7 S1_..?U.3x[.....5"...W....d.E...
0360 ea 08 f1 02 44 b9 8f 37 e7 12 e2 6e 5a 2a ab 28 64 d2 4e 25 e0 c1 a6 80 c4 3f eb c7 ae 25 f9 a7 ....D..7...nZ*.(d.N%.....?...%..
0380 72 1c cb c5 2b 1d e3 d6 62 5b 36 23 dc 08 02 5c 43 28 1f de e7 c5 13 7d e4 c4 00 a1 e5 43 a8 1a r...+...b[6#...\C(.....}.....C..
03a0 9b d7 54 70 be 9b 1c 9d c5 5c bd 15 71 a2 d9 ed 29 e7 b3 75 44 5f 4c b8 36 d8 79 8c 61 13 88 e7 ..Tp.....\..q...)..uD_L.6.y.a...
03c0 25 cc fc 84 a7 8f f6 c2 2a 22 fd 78 e6 25 c4 b2 72 5c 09 3d de 11 5b be ca 21 a4 5f b2 15 b2 28 %.......*".x.%..r\.=..[..!._...(
03e0 3c 6b 85 2b 02 6c 27 c9 7a 90 7c d7 08 41 5e fb 11 f4 2a 5e d7 45 48 57 e1 71 c5 9c ef a1 e5 c9 <k.+.l'.z.|..A^...*^.EHW.q......
0400 a6 78 a4 d3 7a 24 cf d2 98 47 8c 55 93 63 db 11 aa 85 f0 6c b6 1d 5b e2 79 c9 77 6e 44 2b a2 28 .x..z$...G.U.c.....l..[.y.wnD+.(
0420 0c 32 69 d4 32 5d c4 bb 22 d8 4c 65 3f 8e 30 43 f4 51 9d 88 d5 44 b8 36 91 eb 02 78 9a 9f 89 c1 .2i.2]..".Le?.0C.Q...D.6...x....
0440 6d 2b 08 f6 a6 76 17 61 ba 8d bd c0 f5 e4 f3 88 b2 68 b6 b0 1e b0 67 37 82 78 1d 78 56 9d ad cf m+...v.a.........h....g7.x.xV...
0460 0b 52 4c fc e4 bb 1b 08 eb 21 e9 e7 51 f4 22 de 12 68 35 f6 93 e4 07 11 69 80 4d d0 4e 36 03 6a .RL......!..Q."..h5.....i.M.N6.j
0480 09 d1 06 c4 b3 9a e3 76 ae 99 42 ec 16 46 a7 8c 70 17 66 ae cd 81 18 bc a9 87 9e 72 98 31 a8 83 .......v..B..F..p.f........r.1..
04a0 d6 e2 63 7a b0 db 08 38 ca e7 83 f4 68 67 d9 10 18 a7 e7 2b 43 f8 62 8a c3 41 da 90 b0 b5 3d 34 ..cz...8....hg.....+C.b..A....=4
04c0 b8 e7 a9 7e ce 8d 85 7c 76 8f 27 19 ce 9f e0 71 bb a9 98 b5 08 75 9a 1e af 8f 41 bf 91 d7 d7 29 ...~...|v.'....q.....u....A....)
04e0 2a 25 14 83 d8 48 08 c3 64 66 be 66 f2 96 b5 6b d1 c0 78 97 ea 10 f8 16 9e 77 87 1e 6d 37 03 7d *%...H..df.f...k..x......w..m7.}
0500 b9 eb e9 96 7d 0a a1 58 cf 67 1e c6 b6 55 14 81 a8 70 17 ad 90 84 1f 72 6c f7 58 8c b9 9e fe 67 ....}..X.g...U...p.....rl.X....g
0520 ac cf b1 f9 e8 c1 ab fa 11 d4 9a a9 d7 ce 71 af 44 2a 69 d8 5b 9c 2d bf 25 31 f6 ec 65 cc c9 c1 ..............q.D*i.[.-.%1..e...
0540 db 8e db f6 de 4a e9 fc d3 6d fb 7e 69 b0 81 19 72 1f ad c5 b2 61 b1 0b d8 db 8b 5f 96 6b 89 d9 .....J...m.~i...r....a....._.k..
0560 df 8e 60 92 77 fd 19 0c 4f 00 00 00 00 49 45 4e 44 ae 42 60 82 ..`.w...O....IEND.B`.
ef='#n267'>267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132











































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































































                                                                                                                                                    
<?php

/**
 * IXR - The Incutio XML-RPC Library
 *
 * Copyright (c) 2010, Incutio Ltd.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *  - Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 *  - Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *  - Neither the name of Incutio Ltd. nor the names of its contributors
 *    may be used to endorse or promote products derived from this software
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * @package IXR
 * @since 1.5
 *
 * @copyright  Incutio Ltd 2010 (http://www.incutio.com)
 * @version    1.7.4 7th September 2010
 * @author     Simon Willison
 * @link       http://scripts.incutio.com/xmlrpc/ Site/manual
 *
 * Modified for DokuWiki
 * @author  Andreas Gohr <andi@splitbrain.org>
 */
class IXR_Value {

    /** @var  IXR_Value[]|IXR_Date|IXR_Base64|int|bool|double|string */
    var $data;
    /** @var string */
    var $type;

    /**
     * @param mixed $data
     * @param bool $type
     */
    function __construct($data, $type = false) {
        $this->data = $data;
        if(!$type) {
            $type = $this->calculateType();
        }
        $this->type = $type;
        if($type == 'struct') {
            // Turn all the values in the array in to new IXR_Value objects
            foreach($this->data as $key => $value) {
                $this->data[$key] = new IXR_Value($value);
            }
        }
        if($type == 'array') {
            for($i = 0, $j = count($this->data); $i < $j; $i++) {
                $this->data[$i] = new IXR_Value($this->data[$i]);
            }
        }
    }

    /**
     * @return string
     */
    function calculateType() {
        if($this->data === true || $this->data === false) {
            return 'boolean';
        }
        if(is_integer($this->data)) {
            return 'int';
        }
        if(is_double($this->data)) {
            return 'double';
        }

        // Deal with IXR object types base64 and date
        if(is_object($this->data) && is_a($this->data, 'IXR_Date')) {
            return 'date';
        }
        if(is_object($this->data) && is_a($this->data, 'IXR_Base64')) {
            return 'base64';
        }

        // If it is a normal PHP object convert it in to a struct
        if(is_object($this->data)) {
            $this->data = get_object_vars($this->data);
            return 'struct';
        }
        if(!is_array($this->data)) {
            return 'string';
        }

        // We have an array - is it an array or a struct?
        if($this->isStruct($this->data)) {
            return 'struct';
        } else {
            return 'array';
        }
    }

    /**
     * @return bool|string
     */
    function getXml() {
        // Return XML for this value
        switch($this->type) {
            case 'boolean':
                return '<boolean>' . (($this->data) ? '1' : '0') . '</boolean>';
                break;
            case 'int':
                return '<int>' . $this->data . '</int>';
                break;
            case 'double':
                return '<double>' . $this->data . '</double>';
                break;
            case 'string':
                return '<string>' . htmlspecialchars($this->data) . '</string>';
                break;
            case 'array':
                $return = '<array><data>' . "\n";
                foreach($this->data as $item) {
                    $return .= '  <value>' . $item->getXml() . "</value>\n";
                }
                $return .= '</data></array>';
                return $return;
                break;
            case 'struct':
                $return = '<struct>' . "\n";
                foreach($this->data as $name => $value) {
                    $return .= "  <member><name>$name</name><value>";
                    $return .= $value->getXml() . "</value></member>\n";
                }
                $return .= '</struct>';
                return $return;
                break;
            case 'date':
            case 'base64':
                return $this->data->getXml();
                break;
        }
        return false;
    }

    /**
     * Checks whether or not the supplied array is a struct or not
     *
     * @param array $array
     * @return boolean
     */
    function isStruct($array) {
        $expected = 0;
        foreach($array as $key => $value) {
            if((string) $key != (string) $expected) {
                return true;
            }
            $expected++;
        }
        return false;
    }
}

/**
 * IXR_MESSAGE
 *
 * @package IXR
 * @since 1.5
 *
 */
class IXR_Message {
    var $message;
    var $messageType; // methodCall / methodResponse / fault
    var $faultCode;
    var $faultString;
    var $methodName;
    var $params;

    // Current variable stacks
    var $_arraystructs = array(); // The stack used to keep track of the current array/struct
    var $_arraystructstypes = array(); // Stack keeping track of if things are structs or array
    var $_currentStructName = array(); // A stack as well
    var $_param;
    var $_value;
    var $_currentTag;
    var $_currentTagContents;
    var $_lastseen;
    // The XML parser
    var $_parser;

    /**
     * @param string $message
     */
    function __construct($message) {
        $this->message =& $message;
    }

    /**
     * @return bool
     */
    function parse() {
        // first remove the XML declaration
        // merged from WP #10698 - this method avoids the RAM usage of preg_replace on very large messages
        $header = preg_replace('/<\?xml.*?\?' . '>/', '', substr($this->message, 0, 100), 1);
        $this->message = substr_replace($this->message, $header, 0, 100);

        // workaround for a bug in PHP/libxml2, see http://bugs.php.net/bug.php?id=45996
        $this->message = str_replace('&lt;', '&#60;', $this->message);
        $this->message = str_replace('&gt;', '&#62;', $this->message);
        $this->message = str_replace('&amp;', '&#38;', $this->message);
        $this->message = str_replace('&apos;', '&#39;', $this->message);
        $this->message = str_replace('&quot;', '&#34;', $this->message);
        $this->message = str_replace("\x0b", ' ', $this->message); //vertical tab
        if(trim($this->message) == '') {
            return false;
        }
        $this->_parser = xml_parser_create();
        // Set XML parser to take the case of tags in to account
        xml_parser_set_option($this->_parser, XML_OPTION_CASE_FOLDING, false);
        // Set XML parser callback functions
        xml_set_object($this->_parser, $this);
        xml_set_element_handler($this->_parser, 'tag_open', 'tag_close');
        xml_set_character_data_handler($this->_parser, 'cdata');
        $chunk_size = 262144; // 256Kb, parse in chunks to avoid the RAM usage on very large messages
        $final = false;
        do {
            if(strlen($this->message) <= $chunk_size) {
                $final = true;
            }
            $part = substr($this->message, 0, $chunk_size);
            $this->message = substr($this->message, $chunk_size);
            if(!xml_parse($this->_parser, $part, $final)) {
                return false;
            }
            if($final) {
                break;
            }
        } while(true);
        xml_parser_free($this->_parser);

        // Grab the error messages, if any
        if($this->messageType == 'fault') {
            $this->faultCode = $this->params[0]['faultCode'];
            $this->faultString = $this->params[0]['faultString'];
        }
        return true;
    }

    /**
     * @param $parser
     * @param string $tag
     * @param $attr
     */
    function tag_open($parser, $tag, $attr) {
        $this->_currentTagContents = '';
        $this->_currentTag = $tag;

        switch($tag) {
            case 'methodCall':
            case 'methodResponse':
            case 'fault':
                $this->messageType = $tag;
                break;
            /* Deal with stacks of arrays and structs */
            case 'data': // data is to all intents and purposes more interesting than array
                $this->_arraystructstypes[] = 'array';
                $this->_arraystructs[] = array();
                break;
            case 'struct':
                $this->_arraystructstypes[] = 'struct';
                $this->_arraystructs[] = array();
                break;
        }
        $this->_lastseen = $tag;
    }

    /**
     * @param $parser
     * @param string $cdata
     */
    function cdata($parser, $cdata) {
        $this->_currentTagContents .= $cdata;
    }

    /**
     * @param $parser
     * @param $tag
     */
    function tag_close($parser, $tag) {
        $value = null;
        $valueFlag = false;
        switch($tag) {
            case 'int':
            case 'i4':
                $value = (int) trim($this->_currentTagContents);
                $valueFlag = true;
                break;
            case 'double':
                $value = (double) trim($this->_currentTagContents);
                $valueFlag = true;
                break;
            case 'string':
                $value = (string) $this->_currentTagContents;
                $valueFlag = true;
                break;
            case 'dateTime.iso8601':
                $value = new IXR_Date(trim($this->_currentTagContents));
                $valueFlag = true;
                break;
            case 'value':
                // "If no type is indicated, the type is string."
                if($this->_lastseen == 'value') {
                    $value = (string) $this->_currentTagContents;
                    $valueFlag = true;
                }
                break;
            case 'boolean':
                $value = (boolean) trim($this->_currentTagContents);
                $valueFlag = true;
                break;
            case 'base64':
                $value = base64_decode($this->_currentTagContents);
                $valueFlag = true;
                break;
            /* Deal with stacks of arrays and structs */
            case 'data':
            case 'struct':
                $value = array_pop($this->_arraystructs);
                array_pop($this->_arraystructstypes);
                $valueFlag = true;
                break;
            case 'member':
                array_pop($this->_currentStructName);
                break;
            case 'name':
                $this->_currentStructName[] = trim($this->_currentTagContents);
                break;
            case 'methodName':
                $this->methodName = trim($this->_currentTagContents);
                break;
        }

        if($valueFlag) {
            if(count($this->_arraystructs) > 0) {
                // Add value to struct or array
                if($this->_arraystructstypes[count($this->_arraystructstypes) - 1] == 'struct') {
                    // Add to struct
                    $this->_arraystructs[count($this->_arraystructs) - 1][$this->_currentStructName[count($this->_currentStructName) - 1]] = $value;
                } else {
                    // Add to array
                    $this->_arraystructs[count($this->_arraystructs) - 1][] = $value;
                }
            } else {
                // Just add as a parameter
                $this->params[] = $value;
            }
        }
        $this->_currentTagContents = '';
        $this->_lastseen = $tag;
    }
}

/**
 * IXR_Server
 *
 * @package IXR
 * @since 1.5
 */
class IXR_Server {
    var $data;
    /** @var array */
    var $callbacks = array();
    var $message;
    /** @var array */
    var $capabilities;

    /**
     * @param array|bool $callbacks
     * @param bool $data
     * @param bool $wait
     */
    function __construct($callbacks = false, $data = false, $wait = false) {
        $this->setCapabilities();
        if($callbacks) {
            $this->callbacks = $callbacks;
        }
        $this->setCallbacks();

        if(!$wait) {
            $this->serve($data);
        }
    }

    /**
     * @param bool|string $data
     */
    function serve($data = false) {
        if(!$data) {

            $postData = trim(http_get_raw_post_data());
            if(!$postData) {
                header('Content-Type: text/plain'); // merged from WP #9093
                die('XML-RPC server accepts POST requests only.');
            }
            $data = $postData;
        }
        $this->message = new IXR_Message($data);
        if(!$this->message->parse()) {
            $this->error(-32700, 'parse error. not well formed');
        }
        if($this->message->messageType != 'methodCall') {
            $this->error(-32600, 'server error. invalid xml-rpc. not conforming to spec. Request must be a methodCall');
        }
        $result = $this->call($this->message->methodName, $this->message->params);

        // Is the result an error?
        if(is_a($result, 'IXR_Error')) {
            $this->error($result);
        }

        // Encode the result
        $r = new IXR_Value($result);
        $resultxml = $r->getXml();

        // Create the XML
        $xml = <<<EOD
<methodResponse>
  <params>
    <param>
      <value>
        $resultxml
      </value>
    </param>
  </params>
</methodResponse>

EOD;
        // Send it
        $this->output($xml);
    }

    /**
     * @param string $methodname
     * @param array $args
     * @return IXR_Error|mixed
     */
    function call($methodname, $args) {
        if(!$this->hasMethod($methodname)) {
            return new IXR_Error(-32601, 'server error. requested method ' . $methodname . ' does not exist.');
        }
        $method = $this->callbacks[$methodname];

        // Perform the callback and send the response

        # Removed for DokuWiki to have a more consistent interface
        #        if (count($args) == 1) {
        #            // If only one parameter just send that instead of the whole array
        #            $args = $args[0];
        #        }

        # Adjusted for DokuWiki to use call_user_func_array

        // args need to be an array
        $args = (array) $args;

        // Are we dealing with a function or a method?
        if(is_string($method) && substr($method, 0, 5) == 'this:') {
            // It's a class method - check it exists
            $method = substr($method, 5);
            if(!method_exists($this, $method)) {
                return new IXR_Error(-32601, 'server error. requested class method "' . $method . '" does not exist.');
            }
            // Call the method
            #$result = $this->$method($args);
            $result = call_user_func_array(array(&$this, $method), $args);
        } elseif(substr($method, 0, 7) == 'plugin:') {
            list($pluginname, $callback) = explode(':', substr($method, 7), 2);
            if(!plugin_isdisabled($pluginname)) {
                $plugin = plugin_load('action', $pluginname);
                return call_user_func_array(array($plugin, $callback), $args);
            } else {
                return new IXR_Error(-99999, 'server error');
            }
        } else {
            // It's a function - does it exist?
            if(is_array($method)) {
                if(!is_callable(array($method[0], $method[1]))) {
                    return new IXR_Error(-32601, 'server error. requested object method "' . $method[1] . '" does not exist.');
                }
            } else if(!function_exists($method)) {
                return new IXR_Error(-32601, 'server error. requested function "' . $method . '" does not exist.');
            }

            // Call the function
            $result = call_user_func($method, $args);
        }
        return $result;
    }

    /**
     * @param int $error
     * @param string|bool $message
     */
    function error($error, $message = false) {
        // Accepts either an error object or an error code and message
        if($message && !is_object($error)) {
            $error = new IXR_Error($error, $message);
        }
        $this->output($error->getXml());
    }

    /**
     * @param string $xml
     */
    function output($xml) {
        header('Content-Type: text/xml; charset=utf-8');
        echo '<?xml version="1.0"?>', "\n", $xml;
        exit;
    }

    /**
     * @param string $method
     * @return bool
     */
    function hasMethod($method) {
        return in_array($method, array_keys($this->callbacks));
    }

    function setCapabilities() {
        // Initialises capabilities array
        $this->capabilities = array(
            'xmlrpc' => array(
                'specUrl' => 'http://www.xmlrpc.com/spec',
                'specVersion' => 1
            ),
            'faults_interop' => array(
                'specUrl' => 'http://xmlrpc-epi.sourceforge.net/specs/rfc.fault_codes.php',
                'specVersion' => 20010516
            ),
            'system.multicall' => array(
                'specUrl' => 'http://www.xmlrpc.com/discuss/msgReader$1208',
                'specVersion' => 1
            ),
        );
    }

    /**
     * @return mixed
     */
    function getCapabilities() {
        return $this->capabilities;
    }

    function setCallbacks() {
        $this->callbacks['system.getCapabilities'] = 'this:getCapabilities';
        $this->callbacks['system.listMethods'] = 'this:listMethods';
        $this->callbacks['system.multicall'] = 'this:multiCall';
    }

    /**
     * @return array
     */
    function listMethods() {
        // Returns a list of methods - uses array_reverse to ensure user defined
        // methods are listed before server defined methods
        return array_reverse(array_keys($this->callbacks));
    }

    /**
     * @param array $methodcalls
     * @return array
     */
    function multiCall($methodcalls) {
        // See http://www.xmlrpc.com/discuss/msgReader$1208
        $return = array();
        foreach($methodcalls as $call) {
            $method = $call['methodName'];
            $params = $call['params'];
            if($method == 'system.multicall') {
                $result = new IXR_Error(-32800, 'Recursive calls to system.multicall are forbidden');
            } else {
                $result = $this->call($method, $params);
            }
            if(is_a($result, 'IXR_Error')) {
                $return[] = array(
                    'faultCode' => $result->code,
                    'faultString' => $result->message
                );
            } else {
                $return[] = array($result);
            }
        }
        return $return;
    }
}

/**
 * IXR_Request
 *
 * @package IXR
 * @since 1.5
 */
class IXR_Request {
    /** @var string */
    var $method;
    /** @var array */
    var $args;
    /** @var string */
    var $xml;

    /**
     * @param string $method
     * @param array $args
     */
    function __construct($method, $args) {
        $this->method = $method;
        $this->args = $args;
        $this->xml = <<<EOD
<?xml version="1.0"?>
<methodCall>
<methodName>{$this->method}</methodName>
<params>

EOD;
        foreach($this->args as $arg) {
            $this->xml .= '<param><value>';
            $v = new IXR_Value($arg);
            $this->xml .= $v->getXml();
            $this->xml .= "</value></param>\n";
        }
        $this->xml .= '</params></methodCall>';
    }

    /**
     * @return int
     */
    function getLength() {
        return strlen($this->xml);
    }

    /**
     * @return string
     */
    function getXml() {
        return $this->xml;
    }
}

/**
 * IXR_Client
 *
 * @package IXR
 * @since 1.5
 *
 * Changed for DokuWiki to use DokuHTTPClient
 *
 * This should be compatible to the original class, but uses DokuWiki's
 * HTTP client library which will respect proxy settings
 *
 * Because the XMLRPC client is not used in DokuWiki currently this is completely
 * untested
 */
class IXR_Client extends DokuHTTPClient {
    var $posturl = '';
    /** @var IXR_Message|bool */
    var $message = false;

    // Storage place for an error message
    /** @var IXR_Error|bool */
    var $xmlerror = false;

    /**
     * @param string $server
     * @param string|bool $path
     * @param int $port
     * @param int $timeout
     */
    function __construct($server, $path = false, $port = 80, $timeout = 15) {
        parent::__construct();
        if(!$path) {
            // Assume we have been given a URL instead
            $this->posturl = $server;
        } else {
            $this->posturl = 'http://' . $server . ':' . $port . $path;
        }
        $this->timeout = $timeout;
    }

    /**
     * parameters: method and arguments
     * @return bool success or error
     */
    function query() {
        $args = func_get_args();
        $method = array_shift($args);
        $request = new IXR_Request($method, $args);
        $xml = $request->getXml();

        $this->headers['Content-Type'] = 'text/xml';
        if(!$this->sendRequest($this->posturl, $xml, 'POST')) {
            $this->xmlerror = new IXR_Error(-32300, 'transport error - ' . $this->error);
            return false;
        }

        // Check HTTP Response code
        if($this->status < 200 || $this->status > 206) {
            $this->xmlerror = new IXR_Error(-32300, 'transport error - HTTP status ' . $this->status);
            return false;
        }

        // Now parse what we've got back
        $this->message = new IXR_Message($this->resp_body);
        if(!$this->message->parse()) {
            // XML error
            $this->xmlerror = new IXR_Error(-32700, 'parse error. not well formed');
            return false;
        }

        // Is the message a fault?
        if($this->message->messageType == 'fault') {
            $this->xmlerror = new IXR_Error($this->message->faultCode, $this->message->faultString);
            return false;
        }

        // Message must be OK
        return true;
    }

    /**
     * @return mixed
     */
    function getResponse() {
        // methodResponses can only have one param - return that
        return $this->message->params[0];
    }

    /**
     * @return bool
     */
    function isError() {
        return (is_object($this->xmlerror));
    }

    /**
     * @return int
     */
    function getErrorCode() {
        return $this->xmlerror->code;
    }

    /**
     * @return string
     */
    function getErrorMessage() {
        return $this->xmlerror->message;
    }
}

/**
 * IXR_Error
 *
 * @package IXR
 * @since 1.5
 */
class IXR_Error {
    var $code;
    var $message;

    /**
     * @param int $code
     * @param string $message
     */
    function __construct($code, $message) {
        $this->code = $code;
        $this->message = htmlspecialchars($message);
    }

    /**
     * @return string
     */
    function getXml() {
        $xml = <<<EOD
<methodResponse>
  <fault>
    <value>
      <struct>
        <member>
          <name>faultCode</name>
          <value><int>{$this->code}</int></value>
        </member>
        <member>
          <name>faultString</name>
          <value><string>{$this->message}</string></value>
        </member>
      </struct>
    </value>
  </fault>
</methodResponse>

EOD;
        return $xml;
    }
}

/**
 * IXR_Date
 *
 * @package IXR
 * @since 1.5
 */
class IXR_Date {

    /** @var DateTime */
    protected $date;

    /**
     * @param int|string $time
     */
    public function __construct($time) {
        // $time can be a PHP timestamp or an ISO one
        if(is_numeric($time)) {
            $this->parseTimestamp($time);
        } else {
            $this->parseIso($time);
        }
    }

    /**
     * Parse unix timestamp
     *
     * @param int $timestamp
     */
    protected function parseTimestamp($timestamp) {
        $this->date = new DateTime('@' . $timestamp);
    }

    /**
     * Parses less or more complete iso dates and much more, if no timezone given assumes UTC
     *
     * @param string $iso
     */
    protected function parseIso($iso) {
        $this->date = new DateTime($iso, new DateTimeZone("UTC"));
    }

    /**
     * Returns date in ISO 8601 format
     *
     * @return string
     */
    public function getIso() {
        return $this->date->format(DateTime::ISO8601);
    }

    /**
     * Returns date in valid xml
     *
     * @return string
     */
    public function getXml() {
        return '<dateTime.iso8601>' . $this->getIso() . '</dateTime.iso8601>';
    }

    /**
     * Returns Unix timestamp
     *
     * @return int
     */
    function getTimestamp() {
        return $this->date->getTimestamp();
    }
}

/**
 * IXR_Base64
 *
 * @package IXR
 * @since 1.5
 */
class IXR_Base64 {
    var $data;

    /**
     * @param string $data
     */
    function __construct($data) {
        $this->data = $data;
    }

    /**
     * @return string
     */
    function getXml() {
        return '<base64>' . base64_encode($this->data) . '</base64>';
    }
}

/**
 * IXR_IntrospectionServer
 *
 * @package IXR
 * @since 1.5
 */
class IXR_IntrospectionServer extends IXR_Server {
    /** @var array[] */
    var $signatures;
    /** @var string[] */
    var $help;

    /**
     * Constructor
     */
    function __construct() {
        $this->setCallbacks();
        $this->setCapabilities();
        $this->capabilities['introspection'] = array(
            'specUrl' => 'http://xmlrpc.usefulinc.com/doc/reserved.html',
            'specVersion' => 1
        );
        $this->addCallback(
            'system.methodSignature',
            'this:methodSignature',
            array('array', 'string'),
            'Returns an array describing the return type and required parameters of a method'
        );
        $this->addCallback(
            'system.getCapabilities',
            'this:getCapabilities',
            array('struct'),
            'Returns a struct describing the XML-RPC specifications supported by this server'
        );
        $this->addCallback(
            'system.listMethods',
            'this:listMethods',
            array('array'),
            'Returns an array of available methods on this server'
        );
        $this->addCallback(
            'system.methodHelp',
            'this:methodHelp',
            array('string', 'string'),
            'Returns a documentation string for the specified method'
        );
    }

    /**
     * @param string $method
     * @param string $callback
     * @param string[] $args
     * @param string $help
     */
    function addCallback($method, $callback, $args, $help) {
        $this->callbacks[$method] = $callback;
        $this->signatures[$method] = $args;
        $this->help[$method] = $help;
    }

    /**
     * @param string $methodname
     * @param array $args
     * @return IXR_Error|mixed
     */
    function call($methodname, $args) {
        // Make sure it's in an array
        if($args && !is_array($args)) {
            $args = array($args);
        }

        // Over-rides default call method, adds signature check
        if(!$this->hasMethod($methodname)) {
            return new IXR_Error(-32601, 'server error. requested method "' . $this->message->methodName . '" not specified.');
        }
        $method = $this->callbacks[$methodname];
        $signature = $this->signatures[$methodname];
        $returnType = array_shift($signature);
        // Check the number of arguments. Check only, if the minimum count of parameters is specified. More parameters are possible.
        // This is a hack to allow optional parameters...
        if(count($args) < count($signature)) {
            // print 'Num of args: '.count($args).' Num in signature: '.count($signature);
            return new IXR_Error(-32602, 'server error. wrong number of method parameters');
        }

        // Check the argument types
        $ok = true;
        $argsbackup = $args;
        for($i = 0, $j = count($args); $i < $j; $i++) {
            $arg = array_shift($args);
            $type = array_shift($signature);
            switch($type) {
                case 'int':
                case 'i4':
                    if(is_array($arg) || !is_int($arg)) {
                        $ok = false;
                    }
                    break;
                case 'base64':
                case 'string':
                    if(!is_string($arg)) {
                        $ok = false;
                    }
                    break;
                case 'boolean':
                    if($arg !== false && $arg !== true) {
                        $ok = false;
                    }
                    break;
                case 'float':
                case 'double':
                    if(!is_float($arg)) {
                        $ok = false;
                    }
                    break;
                case 'date':
                case 'dateTime.iso8601':
                    if(!is_a($arg, 'IXR_Date')) {
                        $ok = false;
                    }
                    break;
            }
            if(!$ok) {
                return new IXR_Error(-32602, 'server error. invalid method parameters');
            }
        }
        // It passed the test - run the "real" method call
        return parent::call($methodname, $argsbackup);
    }

    /**
     * @param string $method
     * @return array|IXR_Error
     */
    function methodSignature($method) {
        if(!$this->hasMethod($method)) {
            return new IXR_Error(-32601, 'server error. requested method "' . $method . '" not specified.');
        }
        // We should be returning an array of types
        $types = $this->signatures[$method];
        $return = array();
        foreach($types as $type) {
            switch($type) {
                case 'string':
                    $return[] = 'string';
                    break;
                case 'int':
                case 'i4':
                    $return[] = 42;
                    break;
                case 'double':
                    $return[] = 3.1415;
                    break;
                case 'dateTime.iso8601':
                    $return[] = new IXR_Date(time());
                    break;
                case 'boolean':
                    $return[] = true;
                    break;
                case 'base64':
                    $return[] = new IXR_Base64('base64');
                    break;
                case 'array':
                    $return[] = array('array');
                    break;
                case 'struct':
                    $return[] = array('struct' => 'struct');
                    break;
            }
        }
        return $return;
    }

    /**
     * @param string $method
     * @return mixed
     */
    function methodHelp($method) {
        return $this->help[$method];
    }
}

/**
 * IXR_ClientMulticall
 *
 * @package IXR
 * @since 1.5
 */
class IXR_ClientMulticall extends IXR_Client {

    /** @var array[] */
    var $calls = array();

    /**
     * @param string $server
     * @param string|bool $path
     * @param int $port
     */
    function __construct($server, $path = false, $port = 80) {
        parent::__construct($server, $path, $port);
        //$this->useragent = 'The Incutio XML-RPC PHP Library (multicall client)';
    }

    /**
     * Add a call
     */
    function addCall() {
        $args = func_get_args();
        $methodName = array_shift($args);
        $struct = array(
            'methodName' => $methodName,
            'params' => $args
        );
        $this->calls[] = $struct;
    }

    /**
     * @return bool
     */
    function query() {
        // Prepare multicall, then call the parent::query() method
        return parent::query('system.multicall', $this->calls);
    }
}