94 public static $enc_padding =
"\x28\xBF\x4E\x5E\x4E\x75\x8A\x41\x64\x00\x4E\x56\xFF\xFA\x01\x08\x2E\x2E\x00\xB6\xD0\x68\x3E\x80\x2F\x0C\xA9\xFE\x64\x53\x69\x7A";
107 public static $pageboxes = array(
'MediaBox',
'CropBox',
'BleedBox',
'TrimBox',
'ArtBox');
128 return "\x54\x43\x50\x44\x46\x20".self::getTCPDFVersion().
"\x20\x28\x68\x74\x74\x70\x3a\x2f\x2f\x77\x77\x77\x2e\x74\x63\x70\x64\x66\x2e\x6f\x72\x67\x29";
138 if (!defined(
'PHP_VERSION_ID')) {
139 $version = PHP_VERSION;
140 define(
'PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
142 if (PHP_VERSION_ID < 50300) {
143 @set_magic_quotes_runtime($mqr);
154 if (!defined(
'PHP_VERSION_ID')) {
155 $version = PHP_VERSION;
156 define(
'PHP_VERSION_ID', (($version{0} * 10000) + ($version{2} * 100) + $version{4}));
158 if (PHP_VERSION_ID < 50300) {
159 return @get_magic_quotes_runtime();
480 switch (strtoupper($format)) {
482 case 'A0' : {$pf = array( 2383.937, 3370.394);
break;}
483 case 'A1' : {$pf = array( 1683.780, 2383.937);
break;}
484 case 'A2' : {$pf = array( 1190.551, 1683.780);
break;}
485 case 'A3' : {$pf = array( 841.890, 1190.551);
break;}
486 case 'A4' : {$pf = array( 595.276, 841.890);
break;}
487 case 'A5' : {$pf = array( 419.528, 595.276);
break;}
488 case 'A6' : {$pf = array( 297.638, 419.528);
break;}
489 case 'A7' : {$pf = array( 209.764, 297.638);
break;}
490 case 'A8' : {$pf = array( 147.402, 209.764);
break;}
491 case 'A9' : {$pf = array( 104.882, 147.402);
break;}
492 case 'A10': {$pf = array( 73.701, 104.882);
break;}
493 case 'A11': {$pf = array( 51.024, 73.701);
break;}
494 case 'A12': {$pf = array( 36.850, 51.024);
break;}
496 case 'B0' : {$pf = array( 2834.646, 4008.189);
break;}
497 case 'B1' : {$pf = array( 2004.094, 2834.646);
break;}
498 case 'B2' : {$pf = array( 1417.323, 2004.094);
break;}
499 case 'B3' : {$pf = array( 1000.630, 1417.323);
break;}
500 case 'B4' : {$pf = array( 708.661, 1000.630);
break;}
501 case 'B5' : {$pf = array( 498.898, 708.661);
break;}
502 case 'B6' : {$pf = array( 354.331, 498.898);
break;}
503 case 'B7' : {$pf = array( 249.449, 354.331);
break;}
504 case 'B8' : {$pf = array( 175.748, 249.449);
break;}
505 case 'B9' : {$pf = array( 124.724, 175.748);
break;}
506 case 'B10': {$pf = array( 87.874, 124.724);
break;}
507 case 'B11': {$pf = array( 62.362, 87.874);
break;}
508 case 'B12': {$pf = array( 42.520, 62.362);
break;}
510 case 'C0' : {$pf = array( 2599.370, 3676.535);
break;}
511 case 'C1' : {$pf = array( 1836.850, 2599.370);
break;}
512 case 'C2' : {$pf = array( 1298.268, 1836.850);
break;}
513 case 'C3' : {$pf = array( 918.425, 1298.268);
break;}
514 case 'C4' : {$pf = array( 649.134, 918.425);
break;}
515 case 'C5' : {$pf = array( 459.213, 649.134);
break;}
516 case 'C6' : {$pf = array( 323.150, 459.213);
break;}
517 case 'C7' : {$pf = array( 229.606, 323.150);
break;}
518 case 'C8' : {$pf = array( 161.575, 229.606);
break;}
519 case 'C9' : {$pf = array( 113.386, 161.575);
break;}
520 case 'C10': {$pf = array( 79.370, 113.386);
break;}
521 case 'C11': {$pf = array( 56.693, 79.370);
break;}
522 case 'C12': {$pf = array( 39.685, 56.693);
break;}
523 case 'C76': {$pf = array( 229.606, 459.213);
break;}
524 case 'DL' : {$pf = array( 311.811, 623.622);
break;}
526 case 'E0' : {$pf = array( 2491.654, 3517.795);
break;}
527 case 'E1' : {$pf = array( 1757.480, 2491.654);
break;}
528 case 'E2' : {$pf = array( 1247.244, 1757.480);
break;}
529 case 'E3' : {$pf = array( 878.740, 1247.244);
break;}
530 case 'E4' : {$pf = array( 623.622, 878.740);
break;}
531 case 'E5' : {$pf = array( 439.370, 623.622);
break;}
532 case 'E6' : {$pf = array( 311.811, 439.370);
break;}
533 case 'E7' : {$pf = array( 221.102, 311.811);
break;}
534 case 'E8' : {$pf = array( 155.906, 221.102);
break;}
535 case 'E9' : {$pf = array( 110.551, 155.906);
break;}
536 case 'E10': {$pf = array( 76.535, 110.551);
break;}
537 case 'E11': {$pf = array( 53.858, 76.535);
break;}
538 case 'E12': {$pf = array( 36.850, 53.858);
break;}
540 case 'G0' : {$pf = array( 2715.591, 3838.110);
break;}
541 case 'G1' : {$pf = array( 1919.055, 2715.591);
break;}
542 case 'G2' : {$pf = array( 1357.795, 1919.055);
break;}
543 case 'G3' : {$pf = array( 958.110, 1357.795);
break;}
544 case 'G4' : {$pf = array( 677.480, 958.110);
break;}
545 case 'G5' : {$pf = array( 479.055, 677.480);
break;}
546 case 'G6' : {$pf = array( 337.323, 479.055);
break;}
547 case 'G7' : {$pf = array( 238.110, 337.323);
break;}
548 case 'G8' : {$pf = array( 167.244, 238.110);
break;}
549 case 'G9' : {$pf = array( 119.055, 167.244);
break;}
550 case 'G10': {$pf = array( 82.205, 119.055);
break;}
551 case 'G11': {$pf = array( 59.528, 82.205);
break;}
552 case 'G12': {$pf = array( 39.685, 59.528);
break;}
554 case 'RA0': {$pf = array( 2437.795, 3458.268);
break;}
555 case 'RA1': {$pf = array( 1729.134, 2437.795);
break;}
556 case 'RA2': {$pf = array( 1218.898, 1729.134);
break;}
557 case 'RA3': {$pf = array( 864.567, 1218.898);
break;}
558 case 'RA4': {$pf = array( 609.449, 864.567);
break;}
559 case 'SRA0': {$pf = array( 2551.181, 3628.346);
break;}
560 case 'SRA1': {$pf = array( 1814.173, 2551.181);
break;}
561 case 'SRA2': {$pf = array( 1275.591, 1814.173);
break;}
562 case 'SRA3': {$pf = array( 907.087, 1275.591);
break;}
563 case 'SRA4': {$pf = array( 637.795, 907.087);
break;}
565 case '4A0': {$pf = array( 4767.874, 6740.787);
break;}
566 case '2A0': {$pf = array( 3370.394, 4767.874);
break;}
568 case 'A2_EXTRA' : {$pf = array( 1261.417, 1754.646);
break;}
569 case 'A3+' : {$pf = array( 932.598, 1369.134);
break;}
570 case 'A3_EXTRA' : {$pf = array( 912.756, 1261.417);
break;}
571 case 'A3_SUPER' : {$pf = array( 864.567, 1440.000);
break;}
572 case 'SUPER_A3' : {$pf = array( 864.567, 1380.472);
break;}
573 case 'A4_EXTRA' : {$pf = array( 666.142, 912.756);
break;}
574 case 'A4_SUPER' : {$pf = array( 649.134, 912.756);
break;}
575 case 'SUPER_A4' : {$pf = array( 643.465, 1009.134);
break;}
576 case 'A4_LONG' : {$pf = array( 595.276, 986.457);
break;}
577 case 'F4' : {$pf = array( 595.276, 935.433);
break;}
578 case 'SO_B5_EXTRA': {$pf = array( 572.598, 782.362);
break;}
579 case 'A5_EXTRA' : {$pf = array( 490.394, 666.142);
break;}
581 case 'ANSI_E': {$pf = array( 2448.000, 3168.000);
break;}
582 case 'ANSI_D': {$pf = array( 1584.000, 2448.000);
break;}
583 case 'ANSI_C': {$pf = array( 1224.000, 1584.000);
break;}
584 case 'ANSI_B': {$pf = array( 792.000, 1224.000);
break;}
585 case 'ANSI_A': {$pf = array( 612.000, 792.000);
break;}
588 case 'LEDGER' : {$pf = array( 1224.000, 792.000);
break;}
592 case 'TABLOID': {$pf = array( 792.000, 1224.000);
break;}
595 case 'LETTER' : {$pf = array( 612.000, 792.000);
break;}
597 case 'LEGAL' : {$pf = array( 612.000, 1008.000);
break;}
598 case 'GOVERNMENTLETTER':
599 case 'GLETTER': {$pf = array( 576.000, 756.000);
break;}
601 case 'JLEGAL' : {$pf = array( 576.000, 360.000);
break;}
603 case 'QUADDEMY': {$pf = array( 2520.000, 3240.000);
break;}
604 case 'SUPER_B': {$pf = array( 936.000, 1368.000);
break;}
605 case 'QUARTO': {$pf = array( 648.000, 792.000);
break;}
606 case 'GOVERNMENTLEGAL':
607 case 'FOLIO': {$pf = array( 612.000, 936.000);
break;}
609 case 'EXECUTIVE': {$pf = array( 522.000, 756.000);
break;}
612 case 'MEMO': {$pf = array( 396.000, 612.000);
break;}
613 case 'FOOLSCAP': {$pf = array( 595.440, 936.000);
break;}
614 case 'COMPACT': {$pf = array( 306.000, 486.000);
break;}
615 case 'ORGANIZERJ': {$pf = array( 198.000, 360.000);
break;}
617 case 'P1': {$pf = array( 1587.402, 2437.795);
break;}
618 case 'P2': {$pf = array( 1218.898, 1587.402);
break;}
619 case 'P3': {$pf = array( 793.701, 1218.898);
break;}
620 case 'P4': {$pf = array( 609.449, 793.701);
break;}
621 case 'P5': {$pf = array( 396.850, 609.449);
break;}
622 case 'P6': {$pf = array( 303.307, 396.850);
break;}
624 case 'ARCH_E' : {$pf = array( 2592.000, 3456.000);
break;}
625 case 'ARCH_E1': {$pf = array( 2160.000, 3024.000);
break;}
626 case 'ARCH_D' : {$pf = array( 1728.000, 2592.000);
break;}
628 case 'ARCH_C' : {$pf = array( 1296.000, 1728.000);
break;}
629 case 'ARCH_B' : {$pf = array( 864.000, 1296.000);
break;}
630 case 'ARCH_A' : {$pf = array( 648.000, 864.000);
break;}
633 case 'ANNENV_A2' : {$pf = array( 314.640, 414.000);
break;}
634 case 'ANNENV_A6' : {$pf = array( 342.000, 468.000);
break;}
635 case 'ANNENV_A7' : {$pf = array( 378.000, 522.000);
break;}
636 case 'ANNENV_A8' : {$pf = array( 396.000, 584.640);
break;}
637 case 'ANNENV_A10' : {$pf = array( 450.000, 692.640);
break;}
638 case 'ANNENV_SLIM': {$pf = array( 278.640, 638.640);
break;}
640 case 'COMMENV_N6_1/4': {$pf = array( 252.000, 432.000);
break;}
641 case 'COMMENV_N6_3/4': {$pf = array( 260.640, 468.000);
break;}
642 case 'COMMENV_N8' : {$pf = array( 278.640, 540.000);
break;}
643 case 'COMMENV_N9' : {$pf = array( 278.640, 638.640);
break;}
644 case 'COMMENV_N10' : {$pf = array( 296.640, 684.000);
break;}
645 case 'COMMENV_N11' : {$pf = array( 324.000, 746.640);
break;}
646 case 'COMMENV_N12' : {$pf = array( 342.000, 792.000);
break;}
647 case 'COMMENV_N14' : {$pf = array( 360.000, 828.000);
break;}
649 case 'CATENV_N1' : {$pf = array( 432.000, 648.000);
break;}
650 case 'CATENV_N1_3/4' : {$pf = array( 468.000, 684.000);
break;}
651 case 'CATENV_N2' : {$pf = array( 468.000, 720.000);
break;}
652 case 'CATENV_N3' : {$pf = array( 504.000, 720.000);
break;}
653 case 'CATENV_N6' : {$pf = array( 540.000, 756.000);
break;}
654 case 'CATENV_N7' : {$pf = array( 576.000, 792.000);
break;}
655 case 'CATENV_N8' : {$pf = array( 594.000, 810.000);
break;}
656 case 'CATENV_N9_1/2' : {$pf = array( 612.000, 756.000);
break;}
657 case 'CATENV_N9_3/4' : {$pf = array( 630.000, 810.000);
break;}
658 case 'CATENV_N10_1/2': {$pf = array( 648.000, 864.000);
break;}
659 case 'CATENV_N12_1/2': {$pf = array( 684.000, 900.000);
break;}
660 case 'CATENV_N13_1/2': {$pf = array( 720.000, 936.000);
break;}
661 case 'CATENV_N14_1/4': {$pf = array( 810.000, 882.000);
break;}
662 case 'CATENV_N14_1/2': {$pf = array( 828.000, 1044.000);
break;}
664 case 'JIS_B0' : {$pf = array( 2919.685, 4127.244);
break;}
665 case 'JIS_B1' : {$pf = array( 2063.622, 2919.685);
break;}
666 case 'JIS_B2' : {$pf = array( 1459.843, 2063.622);
break;}
667 case 'JIS_B3' : {$pf = array( 1031.811, 1459.843);
break;}
668 case 'JIS_B4' : {$pf = array( 728.504, 1031.811);
break;}
669 case 'JIS_B5' : {$pf = array( 515.906, 728.504);
break;}
670 case 'JIS_B6' : {$pf = array( 362.835, 515.906);
break;}
671 case 'JIS_B7' : {$pf = array( 257.953, 362.835);
break;}
672 case 'JIS_B8' : {$pf = array( 181.417, 257.953);
break;}
673 case 'JIS_B9' : {$pf = array( 127.559, 181.417);
break;}
674 case 'JIS_B10': {$pf = array( 90.709, 127.559);
break;}
675 case 'JIS_B11': {$pf = array( 62.362, 90.709);
break;}
676 case 'JIS_B12': {$pf = array( 45.354, 62.362);
break;}
678 case 'PA0' : {$pf = array( 2381.102, 3174.803,);
break;}
679 case 'PA1' : {$pf = array( 1587.402, 2381.102);
break;}
680 case 'PA2' : {$pf = array( 1190.551, 1587.402);
break;}
681 case 'PA3' : {$pf = array( 793.701, 1190.551);
break;}
682 case 'PA4' : {$pf = array( 595.276, 793.701);
break;}
683 case 'PA5' : {$pf = array( 396.850, 595.276);
break;}
684 case 'PA6' : {$pf = array( 297.638, 396.850);
break;}
685 case 'PA7' : {$pf = array( 198.425, 297.638);
break;}
686 case 'PA8' : {$pf = array( 147.402, 198.425);
break;}
687 case 'PA9' : {$pf = array( 99.213, 147.402);
break;}
688 case 'PA10': {$pf = array( 73.701, 99.213);
break;}
690 case 'PASSPORT_PHOTO': {$pf = array( 99.213, 127.559);
break;}
691 case 'E' : {$pf = array( 233.858, 340.157);
break;}
693 case '3R' : {$pf = array( 252.283, 360.000);
break;}
695 case '4R' : {$pf = array( 289.134, 430.866);
break;}
696 case '4D' : {$pf = array( 340.157, 430.866);
break;}
698 case '5R' : {$pf = array( 360.000, 504.567);
break;}
700 case '6R' : {$pf = array( 430.866, 575.433);
break;}
702 case '8R' : {$pf = array( 575.433, 720.000);
break;}
704 case 'S8R' : {$pf = array( 575.433, 864.567);
break;}
706 case '10R' : {$pf = array( 720.000, 864.567);
break;}
708 case 'S10R': {$pf = array( 720.000, 1080.000);
break;}
709 case '11R' : {$pf = array( 790.866, 1009.134);
break;}
710 case 'S11R': {$pf = array( 790.866, 1224.567);
break;}
711 case '12R' : {$pf = array( 864.567, 1080.000);
break;}
712 case 'S12R': {$pf = array( 864.567, 1292.598);
break;}
714 case 'NEWSPAPER_BROADSHEET': {$pf = array( 2125.984, 1700.787);
break;}
715 case 'NEWSPAPER_BERLINER' : {$pf = array( 1332.283, 892.913);
break;}
716 case 'NEWSPAPER_TABLOID':
717 case 'NEWSPAPER_COMPACT' : {$pf = array( 1218.898, 793.701);
break;}
720 case 'BUSINESS_CARD':
721 case 'BUSINESS_CARD_ISO7810': {$pf = array( 153.014, 242.646);
break;}
722 case 'BUSINESS_CARD_ISO216' : {$pf = array( 147.402, 209.764);
break;}
723 case 'BUSINESS_CARD_IT':
724 case 'BUSINESS_CARD_UK':
725 case 'BUSINESS_CARD_FR':
726 case 'BUSINESS_CARD_DE':
727 case 'BUSINESS_CARD_ES' : {$pf = array( 155.906, 240.945);
break;}
728 case 'BUSINESS_CARD_CA':
729 case 'BUSINESS_CARD_US' : {$pf = array( 144.567, 252.283);
break;}
730 case 'BUSINESS_CARD_JP' : {$pf = array( 155.906, 257.953);
break;}
731 case 'BUSINESS_CARD_HK' : {$pf = array( 153.071, 255.118);
break;}
732 case 'BUSINESS_CARD_AU':
733 case 'BUSINESS_CARD_DK':
734 case 'BUSINESS_CARD_SE' : {$pf = array( 155.906, 255.118);
break;}
735 case 'BUSINESS_CARD_RU':
736 case 'BUSINESS_CARD_CZ':
737 case 'BUSINESS_CARD_FI':
738 case 'BUSINESS_CARD_HU':
739 case 'BUSINESS_CARD_IL' : {$pf = array( 141.732, 255.118);
break;}
741 case '4SHEET' : {$pf = array( 2880.000, 4320.000);
break;}
742 case '6SHEET' : {$pf = array( 3401.575, 5102.362);
break;}
743 case '12SHEET': {$pf = array( 8640.000, 4320.000);
break;}
744 case '16SHEET': {$pf = array( 5760.000, 8640.000);
break;}
745 case '32SHEET': {$pf = array(11520.000, 8640.000);
break;}
746 case '48SHEET': {$pf = array(17280.000, 8640.000);
break;}
747 case '64SHEET': {$pf = array(23040.000, 8640.000);
break;}
748 case '96SHEET': {$pf = array(34560.000, 8640.000);
break;}
751 case 'EN_EMPEROR' : {$pf = array( 3456.000, 5184.000);
break;}
752 case 'EN_ANTIQUARIAN' : {$pf = array( 2232.000, 3816.000);
break;}
753 case 'EN_GRAND_EAGLE' : {$pf = array( 2070.000, 3024.000);
break;}
754 case 'EN_DOUBLE_ELEPHANT' : {$pf = array( 1926.000, 2880.000);
break;}
755 case 'EN_ATLAS' : {$pf = array( 1872.000, 2448.000);
break;}
756 case 'EN_COLOMBIER' : {$pf = array( 1692.000, 2484.000);
break;}
757 case 'EN_ELEPHANT' : {$pf = array( 1656.000, 2016.000);
break;}
758 case 'EN_DOUBLE_DEMY' : {$pf = array( 1620.000, 2556.000);
break;}
759 case 'EN_IMPERIAL' : {$pf = array( 1584.000, 2160.000);
break;}
760 case 'EN_PRINCESS' : {$pf = array( 1548.000, 2016.000);
break;}
761 case 'EN_CARTRIDGE' : {$pf = array( 1512.000, 1872.000);
break;}
762 case 'EN_DOUBLE_LARGE_POST': {$pf = array( 1512.000, 2376.000);
break;}
763 case 'EN_ROYAL' : {$pf = array( 1440.000, 1800.000);
break;}
765 case 'EN_HALF_POST' : {$pf = array( 1404.000, 1692.000);
break;}
766 case 'EN_SUPER_ROYAL' : {$pf = array( 1368.000, 1944.000);
break;}
767 case 'EN_DOUBLE_POST' : {$pf = array( 1368.000, 2196.000);
break;}
768 case 'EN_MEDIUM' : {$pf = array( 1260.000, 1656.000);
break;}
769 case 'EN_DEMY' : {$pf = array( 1260.000, 1620.000);
break;}
770 case 'EN_LARGE_POST' : {$pf = array( 1188.000, 1512.000);
break;}
771 case 'EN_COPY_DRAUGHT' : {$pf = array( 1152.000, 1440.000);
break;}
772 case 'EN_POST' : {$pf = array( 1116.000, 1386.000);
break;}
773 case 'EN_CROWN' : {$pf = array( 1080.000, 1440.000);
break;}
774 case 'EN_PINCHED_POST' : {$pf = array( 1062.000, 1332.000);
break;}
775 case 'EN_BRIEF' : {$pf = array( 972.000, 1152.000);
break;}
776 case 'EN_FOOLSCAP' : {$pf = array( 972.000, 1224.000);
break;}
777 case 'EN_SMALL_FOOLSCAP' : {$pf = array( 954.000, 1188.000);
break;}
778 case 'EN_POTT' : {$pf = array( 900.000, 1080.000);
break;}
780 case 'BE_GRAND_AIGLE' : {$pf = array( 1984.252, 2948.031);
break;}
781 case 'BE_COLOMBIER' : {$pf = array( 1757.480, 2409.449);
break;}
782 case 'BE_DOUBLE_CARRE': {$pf = array( 1757.480, 2607.874);
break;}
783 case 'BE_ELEPHANT' : {$pf = array( 1746.142, 2182.677);
break;}
784 case 'BE_PETIT_AIGLE' : {$pf = array( 1700.787, 2381.102);
break;}
785 case 'BE_GRAND_JESUS' : {$pf = array( 1559.055, 2069.291);
break;}
786 case 'BE_JESUS' : {$pf = array( 1530.709, 2069.291);
break;}
787 case 'BE_RAISIN' : {$pf = array( 1417.323, 1842.520);
break;}
788 case 'BE_GRAND_MEDIAN': {$pf = array( 1303.937, 1714.961);
break;}
789 case 'BE_DOUBLE_POSTE': {$pf = array( 1233.071, 1601.575);
break;}
790 case 'BE_COQUILLE' : {$pf = array( 1218.898, 1587.402);
break;}
791 case 'BE_PETIT_MEDIAN': {$pf = array( 1176.378, 1502.362);
break;}
792 case 'BE_RUCHE' : {$pf = array( 1020.472, 1303.937);
break;}
793 case 'BE_PROPATRIA' : {$pf = array( 977.953, 1218.898);
break;}
794 case 'BE_LYS' : {$pf = array( 898.583, 1125.354);
break;}
795 case 'BE_POT' : {$pf = array( 870.236, 1088.504);
break;}
796 case 'BE_ROSETTE' : {$pf = array( 765.354, 983.622);
break;}
798 case 'FR_UNIVERS' : {$pf = array( 2834.646, 3685.039);
break;}
799 case 'FR_DOUBLE_COLOMBIER' : {$pf = array( 2551.181, 3571.654);
break;}
800 case 'FR_GRANDE_MONDE' : {$pf = array( 2551.181, 3571.654);
break;}
801 case 'FR_DOUBLE_SOLEIL' : {$pf = array( 2267.717, 3401.575);
break;}
802 case 'FR_DOUBLE_JESUS' : {$pf = array( 2154.331, 3174.803);
break;}
803 case 'FR_GRAND_AIGLE' : {$pf = array( 2125.984, 3004.724);
break;}
804 case 'FR_PETIT_AIGLE' : {$pf = array( 1984.252, 2664.567);
break;}
805 case 'FR_DOUBLE_RAISIN' : {$pf = array( 1842.520, 2834.646);
break;}
806 case 'FR_JOURNAL' : {$pf = array( 1842.520, 2664.567);
break;}
807 case 'FR_COLOMBIER_AFFICHE': {$pf = array( 1785.827, 2551.181);
break;}
808 case 'FR_DOUBLE_CAVALIER' : {$pf = array( 1757.480, 2607.874);
break;}
809 case 'FR_CLOCHE' : {$pf = array( 1700.787, 2267.717);
break;}
810 case 'FR_SOLEIL' : {$pf = array( 1700.787, 2267.717);
break;}
811 case 'FR_DOUBLE_CARRE' : {$pf = array( 1587.402, 2551.181);
break;}
812 case 'FR_DOUBLE_COQUILLE' : {$pf = array( 1587.402, 2494.488);
break;}
813 case 'FR_JESUS' : {$pf = array( 1587.402, 2154.331);
break;}
814 case 'FR_RAISIN' : {$pf = array( 1417.323, 1842.520);
break;}
815 case 'FR_CAVALIER' : {$pf = array( 1303.937, 1757.480);
break;}
816 case 'FR_DOUBLE_COURONNE' : {$pf = array( 1303.937, 2040.945);
break;}
817 case 'FR_CARRE' : {$pf = array( 1275.591, 1587.402);
break;}
818 case 'FR_COQUILLE' : {$pf = array( 1247.244, 1587.402);
break;}
819 case 'FR_DOUBLE_TELLIERE' : {$pf = array( 1247.244, 1927.559);
break;}
820 case 'FR_DOUBLE_CLOCHE' : {$pf = array( 1133.858, 1700.787);
break;}
821 case 'FR_DOUBLE_POT' : {$pf = array( 1133.858, 1757.480);
break;}
822 case 'FR_ECU' : {$pf = array( 1133.858, 1474.016);
break;}
823 case 'FR_COURONNE' : {$pf = array( 1020.472, 1303.937);
break;}
824 case 'FR_TELLIERE' : {$pf = array( 963.780, 1247.244);
break;}
825 case 'FR_POT' : {$pf = array( 878.740, 1133.858);
break;}
827 default: {$pf = array( 595.276, 841.890);
break;}
847 public static function setPageBoxes($page, $type, $llx, $lly, $urx, $ury, $points=
false, $k, $pagedim=array()) {
848 if (!isset($pagedim[$page])) {
850 $pagedim[$page] = array();
852 if (!in_array($type, self::$pageboxes)) {
858 $pagedim[$page][$type][
'llx'] = ($llx * $k);
859 $pagedim[$page][$type][
'lly'] = ($lly * $k);
860 $pagedim[$page][$type][
'urx'] = ($urx * $k);
861 $pagedim[$page][$type][
'ury'] = ($ury * $k);
874 foreach (self::$pageboxes as $type) {
876 if (isset($pagedim[$page][$type])) {
877 $tmp = $pagedim[$page][$type][
'llx'];
878 $pagedim[$page][$type][
'llx'] = $pagedim[$page][$type][
'lly'];
879 $pagedim[$page][$type][
'lly'] = $tmp;
880 $tmp = $pagedim[$page][$type][
'urx'];
881 $pagedim[$page][$type][
'urx'] = $pagedim[$page][$type][
'ury'];
882 $pagedim[$page][$type][
'ury'] = $tmp;
899 $layout_mode =
'SinglePage';
904 $layout_mode =
'OneColumn';
908 case 'TwoColumnLeft': {
909 $layout_mode =
'TwoColumnLeft';
912 case 'TwoColumnRight': {
913 $layout_mode =
'TwoColumnRight';
916 case 'TwoPageLeft': {
917 $layout_mode =
'TwoPageLeft';
920 case 'TwoPageRight': {
921 $layout_mode =
'TwoPageRight';
925 $layout_mode =
'SinglePage';
940 $page_mode =
'UseNone';
943 case 'UseOutlines': {
944 $page_mode =
'UseOutlines';
948 $page_mode =
'UseThumbs';
952 $page_mode =
'FullScreen';
956 $page_mode =
'UseOC';
960 $page_mode =
'UseAttachments';
964 $page_mode =
'UseNone';
978 $headers = @get_headers($url);
979 return (strpos($headers[0],
'200') !==
false);
1000 $txt = preg_replace(
'/([\\xc2]{1}[\\xad]{1})/',
'',
$txt);
1002 $txt = preg_replace(
'/([\\xad]{1})/',
'',
$txt);
1018 if ((!$opencell) OR empty($brd)) {
1024 if (is_string($brd)) {
1026 $slen = strlen($brd);
1028 for ($i = 0; $i < $slen; ++$i) {
1029 $newbrd[$brd[$i]] = array(
'cap' =>
'square',
'join' =>
'miter');
1033 foreach ($brd as $border => $style) {
1034 switch ($position) {
1036 if (strpos($border,
'B') !==
false) {
1038 $newkey = str_replace(
'B',
'', $border);
1039 if (strlen($newkey) > 0) {
1040 $brd[$newkey] = $style;
1042 unset($brd[$border]);
1047 if (strpos($border,
'B') !==
false) {
1049 $newkey = str_replace(
'B',
'', $border);
1050 if (strlen($newkey) > 0) {
1051 $brd[$newkey] = $style;
1053 unset($brd[$border]);
1056 if (strpos($border,
'T') !==
false) {
1058 $newkey = str_replace(
'T',
'', $border);
1059 if (strlen($newkey) > 0) {
1060 $brd[$newkey] = $style;
1062 unset($brd[$border]);
1067 if (strpos($border,
'T') !==
false) {
1069 $newkey = str_replace(
'T',
'', $border);
1070 if (strlen($newkey) > 0) {
1071 $brd[$newkey] = $style;
1073 unset($brd[$border]);
1090 return (is_null($str) OR (is_string($str) AND (strlen($str) == 0)));
1101 return tempnam(K_PATH_CACHE, $name.
'_');
1112 return strtr($s, array(
')' =>
'\\)',
'(' =>
'\\(',
'\\' =>
'\\\\', chr(13) =>
'\r'));
1123 $replaceTable = array(
"\0" =>
'',
'&' =>
'&',
'<' =>
'<',
'>' =>
'>');
1124 $str = strtr($str, $replaceTable);
1136 if (($object instanceof Imagick) AND (version_compare(phpversion(
'imagick'),
'3.0.1') !== 1)) {
1138 return @$object->clone();
1140 return @clone($object);
1151 if (!isset($_SERVER[
'HTTP_ACCEPT_ENCODING']) OR empty($_SERVER[
'HTTP_ACCEPT_ENCODING'])) {
1153 header(
'Content-Length: '.$length);
1167 foreach ($replace as $rep) {
1168 foreach ($rep[3] as $a) {
1169 if (strpos($page, $a) !==
false) {
1170 $page = str_replace($a, $rep[0], $page);
1171 $diff += ($rep[2] - $rep[1]);
1175 return array($page, $diff);
1186 if (($date[0] ==
'D') AND ($date[1] ==
':')) {
1188 $date = substr($date, 2);
1190 return strtotime($date);
1201 return substr_replace(date(
'YmdHisO', intval($time)),
'\'', (0 - 2), 0).
'\'';
1214 $v = unpack(
'Ni', substr($str, $offset, 4));
1228 $v = unpack(
'ni', substr($str, $offset, 2));
1242 $v = unpack(
'si', substr($str, $offset, 2));
1291 $v = floatval(
''.$m.
'.'.$f.
'');
1305 $v = unpack(
'Ci', substr($str, $offset, 1));
1318 public static function rfread($handle, $length) {
1319 $data = fread($handle, $length);
1320 if ($data ===
false) {
1323 $rest = ($length - strlen($data));
1337 $a = unpack(
'Ni', fread($f, 4));
1350 $seed .= microtime();
1351 if (function_exists(
'openssl_random_pseudo_bytes') AND (strtoupper(substr(PHP_OS, 0, 3)) !==
'WIN')) {
1353 $seed .= openssl_random_pseudo_bytes(512);
1355 for ($i = 0; $i < 23; ++$i) {
1356 $seed .= uniqid(
'',
true);
1359 $seed .= uniqid(
'',
true);
1361 $seed .= getmypid();
1363 if (isset($_SERVER[
'REMOTE_ADDR'])) {
1364 $seed .= $_SERVER[
'REMOTE_ADDR'];
1366 if (isset($_SERVER[
'HTTP_USER_AGENT'])) {
1367 $seed .= $_SERVER[
'HTTP_USER_AGENT'];
1369 if (isset($_SERVER[
'HTTP_ACCEPT'])) {
1370 $seed .= $_SERVER[
'HTTP_ACCEPT'];
1372 if (isset($_SERVER[
'HTTP_ACCEPT_ENCODING'])) {
1373 $seed .= $_SERVER[
'HTTP_ACCEPT_ENCODING'];
1375 if (isset($_SERVER[
'HTTP_ACCEPT_LANGUAGE'])) {
1376 $seed .= $_SERVER[
'HTTP_ACCEPT_LANGUAGE'];
1378 if (isset($_SERVER[
'HTTP_ACCEPT_CHARSET'])) {
1379 $seed .= $_SERVER[
'HTTP_ACCEPT_CHARSET'];
1382 $seed .= uniqid(
'',
true);
1383 $seed .= microtime();
1395 return pack(
'H*', md5($str));
1408 public static function _AES($key, $text) {
1410 $padding = 16 - (strlen($text) % 16);
1411 $text .= str_repeat(chr($padding), $padding);
1412 $iv = mcrypt_create_iv(mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC), MCRYPT_RAND);
1413 $text = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $key, $text, MCRYPT_MODE_CBC, $iv);
1430 public static function _RC4($key, $text, &$last_enc_key, &$last_enc_key_c) {
1431 if (function_exists(
'mcrypt_decrypt') AND (
$out = @mcrypt_decrypt(MCRYPT_ARCFOUR, $key, $text, MCRYPT_MODE_STREAM,
''))) {
1435 if ($last_enc_key != $key) {
1436 $k = str_repeat($key, ((256 / strlen($key)) + 1));
1437 $rc4 = range(0, 255);
1439 for ($i = 0; $i < 256; ++$i) {
1441 $j = ($j +
$t + ord($k[$i])) % 256;
1442 $rc4[$i] = $rc4[$j];
1445 $last_enc_key = $key;
1446 $last_enc_key_c = $rc4;
1448 $rc4 = $last_enc_key_c;
1450 $len = strlen($text);
1454 for ($i = 0; $i < $len; ++$i) {
1455 $a = ($a + 1) % 256;
1457 $b = ($b +
$t) % 256;
1458 $rc4[$a] = $rc4[$b];
1460 $k = $rc4[($rc4[$a] + $rc4[$b]) % 256];
1461 $out .= chr(ord($text[$i]) ^ $k);
1480 'annot-forms' => 32,
1481 'fill-forms' => 256,
1484 'print-high' => 2048
1486 $protection = 2147422012;
1487 foreach ($permissions as $permission) {
1488 if (isset(
$options[$permission])) {
1489 if (($mode > 0) OR (
$options[$permission] <= 32)) {
1493 $protection +=
$options[$permission];
1495 $protection -=
$options[$permission];
1513 $bslength = strlen($bs);
1514 if (($bslength % 2) != 0) {
1519 for ($i = 0; $i < $bslength; $i += 2) {
1520 $string .= chr(hexdec($bs[$i].$bs[($i + 1)]));
1535 $chars = preg_split(
'//', $s, -1, PREG_SPLIT_NO_EMPTY);
1536 foreach ($chars as $c) {
1537 $bs .= sprintf(
'%02s', dechex(ord($c)));
1551 $binprot = sprintf(
'%032b', $protection);
1552 $str = chr(bindec(substr($binprot, 24, 8)));
1553 $str .= chr(bindec(substr($binprot, 16, 8)));
1554 $str .= chr(bindec(substr($binprot, 8, 8)));
1555 $str .= chr(bindec(substr($binprot, 0, 8)));
1569 $length = strlen($name);
1570 for ($i = 0; $i < $length; ++$i) {
1572 if (preg_match(
'/[0-9a-zA-Z]/', $chr) == 1) {
1575 $escname .= sprintf(
'#%02X', ord($chr));
1592 if (isset($prop[
'aopt']) AND is_array($prop[
'aopt'])) {
1594 return $prop[
'aopt'];
1598 if (isset($prop[
'alignment'])) {
1599 switch ($prop[
'alignment']) {
1613 $opt[
'q'] = ($rtl)?2:0;
1619 if (isset($prop[
'lineWidth'])) {
1620 $linewidth = intval($prop[
'lineWidth']);
1625 if (isset($prop[
'borderStyle'])) {
1626 switch ($prop[
'borderStyle']) {
1629 $opt[
'border'] = array(0, 0, $linewidth, array(3, 2));
1630 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'D',
'd'=>array(3, 2));
1635 $opt[
'border'] = array(0, 0, $linewidth);
1636 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'B');
1641 $opt[
'border'] = array(0, 0, $linewidth);
1642 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'I');
1647 $opt[
'border'] = array(0, 0, $linewidth);
1648 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'U');
1653 $opt[
'border'] = array(0, 0, $linewidth);
1654 $opt[
'bs'] = array(
'w'=>$linewidth,
's'=>
'S');
1662 if (isset($prop[
'border']) AND is_array($prop[
'border'])) {
1663 $opt[
'border'] = $prop[
'border'];
1665 if (!isset($opt[
'mk'])) {
1666 $opt[
'mk'] = array();
1668 if (!isset($opt[
'mk'][
'if'])) {
1669 $opt[
'mk'][
'if'] = array();
1671 $opt[
'mk'][
'if'][
'a'] = array(0.5, 0.5);
1673 if (isset($prop[
'buttonAlignX'])) {
1674 $opt[
'mk'][
'if'][
'a'][0] = $prop[
'buttonAlignX'];
1677 if (isset($prop[
'buttonAlignY'])) {
1678 $opt[
'mk'][
'if'][
'a'][1] = $prop[
'buttonAlignY'];
1681 if (isset($prop[
'buttonFitBounds']) AND ($prop[
'buttonFitBounds'] ==
'true')) {
1682 $opt[
'mk'][
'if'][
'fb'] =
true;
1685 if (isset($prop[
'buttonScaleHow'])) {
1686 switch ($prop[
'buttonScaleHow']) {
1687 case 'scaleHow.proportional': {
1688 $opt[
'mk'][
'if'][
's'] =
'P';
1691 case 'scaleHow.anamorphic': {
1692 $opt[
'mk'][
'if'][
's'] =
'A';
1698 if (isset($prop[
'buttonScaleWhen'])) {
1699 switch ($prop[
'buttonScaleWhen']) {
1700 case 'scaleWhen.always': {
1701 $opt[
'mk'][
'if'][
'sw'] =
'A';
1704 case 'scaleWhen.never': {
1705 $opt[
'mk'][
'if'][
'sw'] =
'N';
1708 case 'scaleWhen.tooBig': {
1709 $opt[
'mk'][
'if'][
'sw'] =
'B';
1712 case 'scaleWhen.tooSmall': {
1713 $opt[
'mk'][
'if'][
'sw'] =
'S';
1719 if (isset($prop[
'buttonPosition'])) {
1720 switch ($prop[
'buttonPosition']) {
1722 case 'position.textOnly': {
1723 $opt[
'mk'][
'tp'] = 0;
1727 case 'position.iconOnly': {
1728 $opt[
'mk'][
'tp'] = 1;
1732 case 'position.iconTextV': {
1733 $opt[
'mk'][
'tp'] = 2;
1737 case 'position.textIconV': {
1738 $opt[
'mk'][
'tp'] = 3;
1742 case 'position.iconTextH': {
1743 $opt[
'mk'][
'tp'] = 4;
1747 case 'position.textIconH': {
1748 $opt[
'mk'][
'tp'] = 5;
1752 case 'position.overlay': {
1753 $opt[
'mk'][
'tp'] = 6;
1759 if (isset($prop[
'fillColor'])) {
1760 if (is_array($prop[
'fillColor'])) {
1761 $opt[
'mk'][
'bg'] = $prop[
'fillColor'];
1767 if (isset($prop[
'strokeColor'])) {
1768 if (is_array($prop[
'strokeColor'])) {
1769 $opt[
'mk'][
'bc'] = $prop[
'strokeColor'];
1775 if (isset($prop[
'rotation'])) {
1776 $opt[
'mk'][
'r'] = $prop[
'rotation'];
1779 if (isset($prop[
'charLimit'])) {
1780 $opt[
'maxlen'] = intval($prop[
'charLimit']);
1786 if (isset($prop[
'readonly']) AND ($prop[
'readonly'] ==
'true')) {
1790 if (isset($prop[
'required']) AND ($prop[
'required'] ==
'true')) {
1794 if (isset($prop[
'multiline']) AND ($prop[
'multiline'] ==
'true')) {
1798 if (isset($prop[
'password']) AND ($prop[
'password'] ==
'true')) {
1802 if (isset($prop[
'NoToggleToOff']) AND ($prop[
'NoToggleToOff'] ==
'true')) {
1806 if (isset($prop[
'Radio']) AND ($prop[
'Radio'] ==
'true')) {
1810 if (isset($prop[
'Pushbutton']) AND ($prop[
'Pushbutton'] ==
'true')) {
1814 if (isset($prop[
'Combo']) AND ($prop[
'Combo'] ==
'true')) {
1818 if (isset($prop[
'editable']) AND ($prop[
'editable'] ==
'true')) {
1822 if (isset($prop[
'Sort']) AND ($prop[
'Sort'] ==
'true')) {
1826 if (isset($prop[
'fileSelect']) AND ($prop[
'fileSelect'] ==
'true')) {
1830 if (isset($prop[
'multipleSelection']) AND ($prop[
'multipleSelection'] ==
'true')) {
1834 if (isset($prop[
'doNotSpellCheck']) AND ($prop[
'doNotSpellCheck'] ==
'true')) {
1838 if (isset($prop[
'doNotScroll']) AND ($prop[
'doNotScroll'] ==
'true')) {
1842 if (isset($prop[
'comb']) AND ($prop[
'comb'] ==
'true')) {
1846 if (isset($prop[
'radiosInUnison']) AND ($prop[
'radiosInUnison'] ==
'true')) {
1850 if (isset($prop[
'richText']) AND ($prop[
'richText'] ==
'true')) {
1854 if (isset($prop[
'commitOnSelChange']) AND ($prop[
'commitOnSelChange'] ==
'true')) {
1859 if (isset($prop[
'defaultValue'])) {
1860 $opt[
'dv'] = $prop[
'defaultValue'];
1864 if (isset($prop[
'readonly']) AND ($prop[
'readonly'] ==
'true')) {
1868 if (isset($prop[
'display'])) {
1869 if ($prop[
'display'] ==
'display.visible') {
1871 } elseif ($prop[
'display'] ==
'display.hidden') {
1873 } elseif ($prop[
'display'] ==
'display.noPrint') {
1875 } elseif ($prop[
'display'] ==
'display.noView') {
1881 if (isset($prop[
'currentValueIndices']) AND is_array($prop[
'currentValueIndices'])) {
1882 $opt[
'i'] = $prop[
'currentValueIndices'];
1885 if (isset($prop[
'value'])) {
1886 if (is_array($prop[
'value'])) {
1887 $opt[
'opt'] = array();
1888 foreach ($prop[
'value'] AS $key => $optval) {
1890 if (isset($prop[
'exportValues'][$key])) {
1891 $opt[
'opt'][$key] = array($prop[
'exportValues'][$key], $prop[
'value'][$key]);
1893 $opt[
'opt'][$key] = $prop[
'value'][$key];
1897 $opt[
'v'] = $prop[
'value'];
1901 if (isset($prop[
'richValue'])) {
1902 $opt[
'rv'] = $prop[
'richValue'];
1905 if (isset($prop[
'submitName'])) {
1906 $opt[
'tm'] = $prop[
'submitName'];
1909 if (isset($prop[
'name'])) {
1910 $opt[
't'] = $prop[
'name'];
1913 if (isset($prop[
'userName'])) {
1914 $opt[
'tu'] = $prop[
'userName'];
1917 if (isset($prop[
'highlight'])) {
1918 switch ($prop[
'highlight']) {
1920 case 'highlight.n': {
1925 case 'highlight.i': {
1930 case 'highlight.p': {
1935 case 'highlight.o': {
1958 return number_format((
float)$num, 0,
'',
'.');
1970 return number_format((
float)$num, 0,
'',
'.');
1982 if (empty($cssdata)) {
1986 $cssdata = preg_replace(
'/\/\*[^\*]*\*\//',
'', $cssdata);
1988 $cssdata = preg_replace(
'/[\s]+/',
' ', $cssdata);
1990 $cssdata = preg_replace(
'/[\s]*([;:\{\}]{1})[\s]*/',
'\\1', $cssdata);
1992 $cssdata = preg_replace(
'/([^\}\{]+)\{\}/',
'', $cssdata);
1994 $cssdata = preg_replace(
'/@media[\s]+([^\{]*)\{/i',
'@media \\1§', $cssdata);
1995 $cssdata = preg_replace(
'/\}\}/si',
'}§', $cssdata);
1997 $cssdata = trim($cssdata);
1999 $cssblocks = array();
2001 if (preg_match_all(
'/@media[\s]+([^\§]*)§([^§]*)§/i', $cssdata, $matches) > 0) {
2002 foreach ($matches[1] as $key => $type) {
2003 $cssblocks[$type] = $matches[2][$key];
2006 $cssdata = preg_replace(
'/@media[\s]+([^\§]*)§([^§]*)§/i',
'', $cssdata);
2009 if (isset($cssblocks[
'all']) AND !empty($cssblocks[
'all'])) {
2010 $cssdata .= $cssblocks[
'all'];
2012 if (isset($cssblocks[
'print']) AND !empty($cssblocks[
'print'])) {
2013 $cssdata .= $cssblocks[
'print'];
2016 $cssblocks = array();
2019 if (substr($cssdata, -1) ==
'}') {
2021 $cssdata = substr($cssdata, 0, -1);
2023 $matches = explode(
'}', $cssdata);
2024 foreach ($matches as $key => $block) {
2026 $cssblocks[$key] = explode(
'{', $block);
2027 if (!isset($cssblocks[$key][1])) {
2029 unset($cssblocks[$key]);
2033 foreach ($cssblocks as $key => $block) {
2034 if (strpos($block[0],
',') > 0) {
2035 $selectors = explode(
',', $block[0]);
2036 foreach ($selectors as $sel) {
2037 $cssblocks[] = array(0 => trim($sel), 1 => $block[1]);
2039 unset($cssblocks[$key]);
2044 foreach ($cssblocks as $block) {
2045 $selector = $block[0];
2049 $b = intval(preg_match_all(
'/[\#]/', $selector, $matches));
2050 $c = intval(preg_match_all(
'/[\[\.]/', $selector, $matches));
2051 $c += intval(preg_match_all(
'/[\:]link|visited|hover|active|focus|target|lang|enabled|disabled|checked|indeterminate|root|nth|first|last|only|empty|contains|not/i', $selector, $matches));
2052 $d = intval(preg_match_all(
'/[>\+\~\s]{1}[a-zA-Z0-9]+/',
' '.$selector, $matches));
2053 $d += intval(preg_match_all(
'/[\:][\:]/', $selector, $matches));
2054 $specificity = $a.$b.$c.$d;
2056 $cssdata[$specificity.
' '.$selector] = $block[1];
2059 ksort($cssdata, SORT_STRING);
2077 public static function fixHTMLCode($html, $default_css=
'', $tagvs=
'', $tidy_options=
'', &$tagvspaces) {
2079 if ($tidy_options ===
'') {
2080 $tidy_options = array (
2082 'drop-empty-paras' => 0,
2083 'drop-proprietary-attributes' => 1,
2084 'fix-backslash' => 1,
2085 'hide-comments' => 1,
2087 'lower-literals' => 1,
2090 'output-xhtml' => 1,
2100 $tidy = tidy_parse_string($html, $tidy_options);
2102 $tidy->cleanRepair();
2104 $tidy_head = tidy_get_head($tidy);
2105 $css = $tidy_head->value;
2106 $css = preg_replace(
'/<style([^>]+)>/ims',
'<style>', $css);
2107 $css = preg_replace(
'/<\/style>(.*)<style>/ims',
"\n", $css);
2108 $css = str_replace(
'/*<![CDATA[*/',
'', $css);
2109 $css = str_replace(
'/*]]>*/',
'', $css);
2110 preg_match(
'/<style>(.*)<\/style>/ims', $css, $matches);
2111 if (isset($matches[1])) {
2112 $css = strtolower($matches[1]);
2117 $css =
'<style>'.$default_css.$css.
'</style>';
2119 $tidy_body = tidy_get_body($tidy);
2120 $html = $tidy_body->value;
2122 $html = str_replace(
'<br>',
'<br />', $html);
2124 $html = preg_replace(
'/<div([^>]*)><\/div>/',
'', $html);
2125 $html = preg_replace(
'/<p([^>]*)><\/p>/',
'', $html);
2126 if ($tagvs !==
'') {
2128 $tagvspaces = $tagvs;
2145 $tag = $dom[$key][
'value'];
2147 if (isset($dom[$key][
'attribute'][
'class']) AND !empty($dom[$key][
'attribute'][
'class'])) {
2148 $class = explode(
' ', strtolower($dom[$key][
'attribute'][
'class']));
2151 if (isset($dom[$key][
'attribute'][
'id']) AND !empty($dom[$key][
'attribute'][
'id'])) {
2152 $id = strtolower($dom[$key][
'attribute'][
'id']);
2154 $selector = preg_replace(
'/([>\+\~\s]{1})([\.]{1})([^>\+\~\s]*)/si',
'\\1*.\\3', $selector);
2156 if (preg_match_all(
'/([>\+\~\s]{1})([a-zA-Z0-9\*]+)([^>\+\~\s]*)/si', $selector, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) > 0) {
2157 $parentop = array_pop($matches[1]);
2158 $operator = $parentop[0];
2159 $offset = $parentop[1];
2160 $lasttag = array_pop($matches[2]);
2161 $lasttag = strtolower(trim($lasttag[0]));
2162 if (($lasttag ==
'*') OR ($lasttag == $tag)) {
2164 $attrib = array_pop($matches[3]);
2170 if (in_array(substr(
$attrib, 1), $class)) {
2176 if (substr(
$attrib, 1) == $id) {
2182 $attrmatch = array();
2183 if (preg_match(
'/\[([a-zA-Z0-9]*)[\s]*([\~\^\$\*\|\=]*)[\s]*["]?([^"\]]*)["]?\]/i',
$attrib, $attrmatch) > 0) {
2184 $att = strtolower($attrmatch[1]);
2185 $val = $attrmatch[3];
2186 if (isset($dom[$key][
'attribute'][$att])) {
2187 switch ($attrmatch[2]) {
2189 if ($dom[$key][
'attribute'][$att] == $val) {
2195 if (in_array($val, explode(
' ', $dom[$key][
'attribute'][$att]))) {
2201 if ($val == substr($dom[$key][
'attribute'][$att], 0, strlen($val))) {
2207 if ($val == substr($dom[$key][
'attribute'][$att], -strlen($val))) {
2213 if (strpos($dom[$key][
'attribute'][$att], $val) !==
false) {
2219 if ($dom[$key][
'attribute'][$att] == $val) {
2221 } elseif (preg_match(
'/'.$val.
'[\-]{1}/i', $dom[$key][
'attribute'][$att]) > 0) {
2248 if (
$valid AND ($offset > 0)) {
2251 $selector = substr($selector, 0, $offset);
2252 switch ($operator) {
2254 while ($dom[$key][
'parent'] > 0) {
2255 if (self::isValidCSSSelectorForTag($dom, $dom[$key][
'parent'], $selector)) {
2259 $key = $dom[$key][
'parent'];
2269 for ($i = ($key - 1); $i > $dom[$key][
'parent']; --$i) {
2270 if ($dom[$i][
'tag'] AND $dom[$i][
'opening']) {
2278 for ($i = ($key - 1); $i > $dom[$key][
'parent']; --$i) {
2279 if ($dom[$i][
'tag'] AND $dom[$i][
'opening']) {
2280 if (self::isValidCSSSelectorForTag($dom, $i, $selector)) {
2304 $cssarray = array();
2306 $selectors = array();
2307 if (isset($dom[($dom[$key][
'parent'])][
'csssel'])) {
2308 $selectors = $dom[($dom[$key][
'parent'])][
'csssel'];
2311 foreach($css as $selector => $style) {
2312 $pos = strpos($selector,
' ');
2314 $specificity = substr($selector, 0, $pos);
2316 $selector = substr($selector, $pos);
2318 if (self::isValidCSSSelectorForTag($dom, $key, $selector)) {
2319 if (!in_array($selector, $selectors)) {
2321 $cssarray[] = array(
'k' => $selector,
's' => $specificity,
'c' => $style);
2322 $selectors[] = $selector;
2326 if (isset($dom[$key][
'attribute'][
'style'])) {
2328 $cssarray[] = array(
'k' =>
'',
's' =>
'1000',
'c' => $dom[$key][
'attribute'][
'style']);
2331 $cssordered = array();
2332 foreach ($cssarray as $key => $val) {
2333 $skey = sprintf(
'%04d', $key);
2334 $cssordered[$val[
's'].
'_'.$skey] = $val;
2337 ksort($cssordered, SORT_STRING);
2338 return array($selectors, $cssordered);
2350 foreach ($css as $style) {
2352 $csscmds = explode(
';', $style[
'c']);
2353 foreach ($csscmds as
$cmd) {
2355 $pos = strpos($cmd,
':');
2356 if ($pos !==
false) {
2357 $cmd = substr($cmd, 0, ($pos + 1));
2358 if (strpos($tagstyle, $cmd) !==
false) {
2360 $tagstyle = preg_replace(
'/'.$cmd.
'[^;]+/i',
'', $tagstyle);
2365 $tagstyle .=
';'.$style[
'c'];
2368 $tagstyle = preg_replace(
'/[;]+/',
';', $tagstyle);
2381 while ($number >= 1000) {
2385 while ($number >= 900) {
2389 while ($number >= 500) {
2393 while ($number >= 400) {
2397 while ($number >= 100) {
2401 while ($number >= 90) {
2405 while ($number >= 50) {
2409 while ($number >= 40) {
2413 while ($number >= 10) {
2417 while ($number >= 9) {
2421 while ($number >= 5) {
2425 while ($number >= 4) {
2429 while ($number >= 1) {
2445 public static function revstrpos($haystack, $needle, $offset = 0) {
2446 $length = strlen($haystack);
2447 $offset = ($offset > 0)?($length - $offset):abs($offset);
2448 $pos = strpos(strrev($haystack), strrev($needle), $offset);
2449 return ($pos ===
false)?
false:($length - $pos - strlen($needle));
2460 return urlencode(serialize($pararray));
2474 $data = file_get_contents(
$file);
2475 $patterns = array();
2477 $data = preg_replace(
'/\%[^\n]*/',
'', $data);
2479 preg_match(
'/\\\\patterns\{([^\}]*)\}/i', $data, $matches);
2480 $data = trim(substr($matches[0], 10, -1));
2482 $patterns_array = preg_split(
'/[\s]+/', $data);
2484 $patterns = array();
2485 foreach($patterns_array as $val) {
2488 $val = str_replace(
'\'',
'\\\'', $val);
2489 $key = preg_replace(
'/[0-9]+/',
'', $val);
2490 $patterns[$key] = $val;
2577 if (!empty($default)) {
2598 $tm[0] = ($ta[0] * $tb[0]) + ($ta[2] * $tb[1]);
2599 $tm[1] = ($ta[1] * $tb[0]) + ($ta[3] * $tb[1]);
2600 $tm[2] = ($ta[0] * $tb[2]) + ($ta[2] * $tb[3]);
2601 $tm[3] = ($ta[1] * $tb[2]) + ($ta[3] * $tb[3]);
2602 $tm[4] = ($ta[0] * $tb[4]) + ($ta[2] * $tb[5]) + $ta[4];
2603 $tm[5] = ($ta[1] * $tb[4]) + ($ta[3] * $tb[5]) + $ta[5];
2617 $tm = array(1, 0, 0, 1, 0, 0);
2618 $transform = array();
2619 if (preg_match_all(
'/(matrix|translate|scale|rotate|skewX|skewY)[\s]*\(([^\)]+)\)/si', $attribute, $transform, PREG_SET_ORDER) > 0) {
2620 foreach ($transform as $key => $data) {
2621 if (!empty($data[2])) {
2631 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
2642 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
2645 } elseif (preg_match(
'/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
2651 if (preg_match(
'/([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
2654 } elseif (preg_match(
'/([a-z0-9\-\.]+)/si', $data[2], $regs)) {
2661 if (preg_match(
'/([0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)[\,\s]+([a-z0-9\-\.]+)/si', $data[2], $regs)) {
2662 $ang = deg2rad($regs[1]);
2669 $e = ($x * (1 - $a)) - ($y * $c);
2670 $f = ($y * (1 -
$d)) - ($x * $b);
2671 } elseif (preg_match(
'/([0-9\-\.]+)/si', $data[2], $regs)) {
2672 $ang = deg2rad($regs[1]);
2683 if (preg_match(
'/([0-9\-\.]+)/si', $data[2], $regs)) {
2684 $c = tan(deg2rad($regs[1]));
2689 if (preg_match(
'/([0-9\-\.]+)/si', $data[2], $regs)) {
2690 $b = tan(deg2rad($regs[1]));
2713 $dprod = ($x1 * $x2) + ($y1 * $y2);
2714 $dist1 = sqrt(($x1 * $x1) + ($y1 * $y1));
2715 $dist2 = sqrt(($x2 * $x2) + ($y2 * $y2));
2716 $angle = acos($dprod / ($dist1 * $dist2));
2717 if (is_nan($angle)) {
2720 if ((($x1 * $y2) - ($x2 * $y1)) < 0) {