96 header(
'Content-Type: application/svg+xml');
97 header(
'Cache-Control: public, must-revalidate, max-age=0');
98 header(
'Pragma: public');
99 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
100 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
101 header(
'Content-Disposition: inline; filename="'.md5(
$code).
'.svg";');
116 $repstr = array(
"\0" =>
'',
'&' =>
'&',
'<' =>
'<',
'>' =>
'>');
117 $svg =
'<'.
'?'.
'xml version="1.0" standalone="no"'.
'?'.
'>'.
"\n";
118 $svg .=
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">'.
"\n";
119 $svg .=
'<svg width="'.round(($this->barcode_array[
'maxw'] *
$w), 3).
'" height="'.
$h.
'" version="1.1" xmlns="http://www.w3.org/2000/svg">'.
"\n";
120 $svg .=
"\t".
'<desc>'.strtr($this->barcode_array[
'code'], $repstr).
'</desc>'.
"\n";
121 $svg .=
"\t".
'<g id="bars" fill="'.$color.
'" stroke="none">'.
"\n";
124 foreach ($this->barcode_array[
'bcode'] as $k => $v) {
125 $bw = round(($v[
'w'] * $w), 3);
126 $bh = round(($v[
'h'] *
$h / $this->barcode_array[
'maxh']), 3);
128 $y = round(($v[
'p'] *
$h / $this->barcode_array[
'maxh']), 3);
130 $svg .=
"\t\t".
'<rect x="'.
$x.
'" y="'.
$y.
'" width="'.$bw.
'" height="'.$bh.
'" />'.
"\n";
134 $svg .=
"\t".
'</g>'.
"\n";
135 $svg .=
'</svg>'.
"\n";
148 $html =
'<div style="font-size:0;position:relative;width:'.($this->barcode_array[
'maxw'] *
$w).
'px;height:'.(
$h).
'px;">'.
"\n";
151 foreach ($this->barcode_array[
'bcode'] as $k => $v) {
152 $bw = round(($v[
'w'] *
$w), 3);
153 $bh = round(($v[
'h'] *
$h / $this->barcode_array[
'maxh']), 3);
155 $y = round(($v[
'p'] *
$h / $this->barcode_array[
'maxh']), 3);
157 $html .=
'<div style="background-color:'.$color.
';width:'.$bw.
'px;height:'.$bh.
'px;position:absolute;left:'.
$x.
'px;top:'.
$y.
'px;"> </div>'.
"\n";
161 $html .=
'</div>'.
"\n";
175 header(
'Content-Type: image/png');
176 header(
'Cache-Control: public, must-revalidate, max-age=0');
177 header(
'Pragma: public');
178 header(
'Expires: Sat, 26 Jul 1997 05:00:00 GMT');
179 header(
'Last-Modified: '.gmdate(
'D, d M Y H:i:s').
' GMT');
194 $width = ($this->barcode_array[
'maxw'] *
$w);
196 if (function_exists(
'imagecreate')) {
199 $png = imagecreate($width, $height);
200 $bgcol = imagecolorallocate($png, 255, 255, 255);
201 imagecolortransparent($png, $bgcol);
202 $fgcol = imagecolorallocate($png, $color[0], $color[1], $color[2]);
203 } elseif (extension_loaded(
'imagick')) {
205 $bgcol =
new imagickpixel(
'rgb(255,255,255');
206 $fgcol =
new imagickpixel(
'rgb('.$color[0].
','.$color[1].
','.$color[2].
')');
207 $png =
new Imagick();
208 $png->newImage($width, $height,
'none',
'png');
209 $bar =
new imagickdraw();
210 $bar->setfillcolor($fgcol);
216 foreach ($this->barcode_array[
'bcode'] as $k => $v) {
217 $bw = round(($v[
'w'] *
$w), 3);
218 $bh = round(($v[
'h'] *
$h / $this->barcode_array[
'maxh']), 3);
220 $y = round(($v[
'p'] *
$h / $this->barcode_array[
'maxh']), 3);
223 $bar->rectangle(
$x,
$y, (
$x + $bw - 1), (
$y + $bh - 1));
225 imagefilledrectangle($png,
$x,
$y, (
$x + $bw - 1), (
$y + $bh - 1), $fgcol);
231 $png->drawimage($bar);
236 $imagedata = ob_get_clean();
250 switch (strtoupper(
$type)) {
376 $this->barcode_array =
false;
381 $this->barcode_array = $arrcode;
394 $chr[
'0'] =
'111331311';
395 $chr[
'1'] =
'311311113';
396 $chr[
'2'] =
'113311113';
397 $chr[
'3'] =
'313311111';
398 $chr[
'4'] =
'111331113';
399 $chr[
'5'] =
'311331111';
400 $chr[
'6'] =
'113331111';
401 $chr[
'7'] =
'111311313';
402 $chr[
'8'] =
'311311311';
403 $chr[
'9'] =
'113311311';
404 $chr[
'A'] =
'311113113';
405 $chr[
'B'] =
'113113113';
406 $chr[
'C'] =
'313113111';
407 $chr[
'D'] =
'111133113';
408 $chr[
'E'] =
'311133111';
409 $chr[
'F'] =
'113133111';
410 $chr[
'G'] =
'111113313';
411 $chr[
'H'] =
'311113311';
412 $chr[
'I'] =
'113113311';
413 $chr[
'J'] =
'111133311';
414 $chr[
'K'] =
'311111133';
415 $chr[
'L'] =
'113111133';
416 $chr[
'M'] =
'313111131';
417 $chr[
'N'] =
'111131133';
418 $chr[
'O'] =
'311131131';
419 $chr[
'P'] =
'113131131';
420 $chr[
'Q'] =
'111111333';
421 $chr[
'R'] =
'311111331';
422 $chr[
'S'] =
'113111331';
423 $chr[
'T'] =
'111131331';
424 $chr[
'U'] =
'331111113';
425 $chr[
'V'] =
'133111113';
426 $chr[
'W'] =
'333111111';
427 $chr[
'X'] =
'131131113';
428 $chr[
'Y'] =
'331131111';
429 $chr[
'Z'] =
'133131111';
430 $chr[
'-'] =
'131111313';
431 $chr[
'.'] =
'331111311';
432 $chr[
' '] =
'133111311';
433 $chr[
'$'] =
'131313111';
434 $chr[
'/'] =
'131311131';
435 $chr[
'+'] =
'131113131';
436 $chr[
'%'] =
'111313131';
437 $chr[
'*'] =
'131131311';
443 if (
$code ===
false) {
451 $code =
'*'.$code.
'*';
452 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
454 $clen = strlen(
$code);
455 for (
$i = 0;
$i < $clen; ++
$i) {
457 if(!isset($chr[$char])) {
461 for ($j = 0; $j < 9; ++$j) {
467 $w = $chr[$char]{$j};
468 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
469 $bararray[
'maxw'] +=
$w;
473 $bararray[
'bcode'][$k] = array(
't' =>
false,
'w' => 1,
'h' => 1,
'p' => 0);
474 $bararray[
'maxw'] += 1;
488 chr(0) =>
'%U', chr(1) =>
'$A', chr(2) =>
'$B', chr(3) =>
'$C',
489 chr(4) =>
'$D', chr(5) =>
'$E', chr(6) =>
'$F', chr(7) =>
'$G',
490 chr(8) =>
'$H', chr(9) =>
'$I', chr(10) =>
'$J', chr(11) =>
'£K',
491 chr(12) =>
'$L', chr(13) =>
'$M', chr(14) =>
'$N', chr(15) =>
'$O',
492 chr(16) =>
'$P', chr(17) =>
'$Q', chr(18) =>
'$R', chr(19) =>
'$S',
493 chr(20) =>
'$T', chr(21) =>
'$U', chr(22) =>
'$V', chr(23) =>
'$W',
494 chr(24) =>
'$X', chr(25) =>
'$Y', chr(26) =>
'$Z', chr(27) =>
'%A',
495 chr(28) =>
'%B', chr(29) =>
'%C', chr(30) =>
'%D', chr(31) =>
'%E',
496 chr(32) =>
' ', chr(33) =>
'/A', chr(34) =>
'/B', chr(35) =>
'/C',
497 chr(36) =>
'/D', chr(37) =>
'/E', chr(38) =>
'/F', chr(39) =>
'/G',
498 chr(40) =>
'/H', chr(41) =>
'/I', chr(42) =>
'/J', chr(43) =>
'/K',
499 chr(44) =>
'/L', chr(45) =>
'-', chr(46) =>
'.', chr(47) =>
'/O',
500 chr(48) =>
'0', chr(49) =>
'1', chr(50) =>
'2', chr(51) =>
'3',
501 chr(52) =>
'4', chr(53) =>
'5', chr(54) =>
'6', chr(55) =>
'7',
502 chr(56) =>
'8', chr(57) =>
'9', chr(58) =>
'/Z', chr(59) =>
'%F',
503 chr(60) =>
'%G', chr(61) =>
'%H', chr(62) =>
'%I', chr(63) =>
'%J',
504 chr(64) =>
'%V', chr(65) =>
'A', chr(66) =>
'B', chr(67) =>
'C',
505 chr(68) =>
'D', chr(69) =>
'E', chr(70) =>
'F', chr(71) =>
'G',
506 chr(72) =>
'H', chr(73) =>
'I', chr(74) =>
'J', chr(75) =>
'K',
507 chr(76) =>
'L', chr(77) =>
'M', chr(78) =>
'N', chr(79) =>
'O',
508 chr(80) =>
'P', chr(81) =>
'Q', chr(82) =>
'R', chr(83) =>
'S',
509 chr(84) =>
'T', chr(85) =>
'U', chr(86) =>
'V', chr(87) =>
'W',
510 chr(88) =>
'X', chr(89) =>
'Y', chr(90) =>
'Z', chr(91) =>
'%K',
511 chr(92) =>
'%L', chr(93) =>
'%M', chr(94) =>
'%N', chr(95) =>
'%O',
512 chr(96) =>
'%W', chr(97) =>
'+A', chr(98) =>
'+B', chr(99) =>
'+C',
513 chr(100) =>
'+D', chr(101) =>
'+E', chr(102) =>
'+F', chr(103) =>
'+G',
514 chr(104) =>
'+H', chr(105) =>
'+I', chr(106) =>
'+J', chr(107) =>
'+K',
515 chr(108) =>
'+L', chr(109) =>
'+M', chr(110) =>
'+N', chr(111) =>
'+O',
516 chr(112) =>
'+P', chr(113) =>
'+Q', chr(114) =>
'+R', chr(115) =>
'+S',
517 chr(116) =>
'+T', chr(117) =>
'+U', chr(118) =>
'+V', chr(119) =>
'+W',
518 chr(120) =>
'+X', chr(121) =>
'+Y', chr(122) =>
'+Z', chr(123) =>
'%P',
519 chr(124) =>
'%Q', chr(125) =>
'%R', chr(126) =>
'%S', chr(127) =>
'%T');
521 $clen = strlen(
$code);
522 for (
$i = 0 ;
$i < $clen; ++
$i) {
526 $code_ext .= $encode[
$code{
$i}];
539 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
540 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
541 'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
542 'W',
'X',
'Y',
'Z',
'-',
'.',
' ',
'$',
'/',
'+',
'%');
544 $clen = strlen(
$code);
545 for (
$i = 0 ;
$i < $clen; ++
$i) {
546 $k = array_keys($chars,
$code{
$i});
604 $chr[128] =
'121221';
605 $chr[129] =
'311121';
606 $chr[130] =
'122211';
607 $chr[131] =
'312111';
611 chr(0) => chr(131).
'U', chr(1) => chr(128).
'A', chr(2) => chr(128).
'B', chr(3) => chr(128).
'C',
612 chr(4) => chr(128).
'D', chr(5) => chr(128).
'E', chr(6) => chr(128).
'F', chr(7) => chr(128).
'G',
613 chr(8) => chr(128).
'H', chr(9) => chr(128).
'I', chr(10) => chr(128).
'J', chr(11) =>
'£K',
614 chr(12) => chr(128).
'L', chr(13) => chr(128).
'M', chr(14) => chr(128).
'N', chr(15) => chr(128).
'O',
615 chr(16) => chr(128).
'P', chr(17) => chr(128).
'Q', chr(18) => chr(128).
'R', chr(19) => chr(128).
'S',
616 chr(20) => chr(128).
'T', chr(21) => chr(128).
'U', chr(22) => chr(128).
'V', chr(23) => chr(128).
'W',
617 chr(24) => chr(128).
'X', chr(25) => chr(128).
'Y', chr(26) => chr(128).
'Z', chr(27) => chr(131).
'A',
618 chr(28) => chr(131).
'B', chr(29) => chr(131).
'C', chr(30) => chr(131).
'D', chr(31) => chr(131).
'E',
619 chr(32) =>
' ', chr(33) => chr(129).
'A', chr(34) => chr(129).
'B', chr(35) => chr(129).
'C',
620 chr(36) => chr(129).
'D', chr(37) => chr(129).
'E', chr(38) => chr(129).
'F', chr(39) => chr(129).
'G',
621 chr(40) => chr(129).
'H', chr(41) => chr(129).
'I', chr(42) => chr(129).
'J', chr(43) => chr(129).
'K',
622 chr(44) => chr(129).
'L', chr(45) =>
'-', chr(46) =>
'.', chr(47) => chr(129).
'O',
623 chr(48) =>
'0', chr(49) =>
'1', chr(50) =>
'2', chr(51) =>
'3',
624 chr(52) =>
'4', chr(53) =>
'5', chr(54) =>
'6', chr(55) =>
'7',
625 chr(56) =>
'8', chr(57) =>
'9', chr(58) => chr(129).
'Z', chr(59) => chr(131).
'F',
626 chr(60) => chr(131).
'G', chr(61) => chr(131).
'H', chr(62) => chr(131).
'I', chr(63) => chr(131).
'J',
627 chr(64) => chr(131).
'V', chr(65) =>
'A', chr(66) =>
'B', chr(67) =>
'C',
628 chr(68) =>
'D', chr(69) =>
'E', chr(70) =>
'F', chr(71) =>
'G',
629 chr(72) =>
'H', chr(73) =>
'I', chr(74) =>
'J', chr(75) =>
'K',
630 chr(76) =>
'L', chr(77) =>
'M', chr(78) =>
'N', chr(79) =>
'O',
631 chr(80) =>
'P', chr(81) =>
'Q', chr(82) =>
'R', chr(83) =>
'S',
632 chr(84) =>
'T', chr(85) =>
'U', chr(86) =>
'V', chr(87) =>
'W',
633 chr(88) =>
'X', chr(89) =>
'Y', chr(90) =>
'Z', chr(91) => chr(131).
'K',
634 chr(92) => chr(131).
'L', chr(93) => chr(131).
'M', chr(94) => chr(131).
'N', chr(95) => chr(131).
'O',
635 chr(96) => chr(131).
'W', chr(97) => chr(130).
'A', chr(98) => chr(130).
'B', chr(99) => chr(130).
'C',
636 chr(100) => chr(130).
'D', chr(101) => chr(130).
'E', chr(102) => chr(130).
'F', chr(103) => chr(130).
'G',
637 chr(104) => chr(130).
'H', chr(105) => chr(130).
'I', chr(106) => chr(130).
'J', chr(107) => chr(130).
'K',
638 chr(108) => chr(130).
'L', chr(109) => chr(130).
'M', chr(110) => chr(130).
'N', chr(111) => chr(130).
'O',
639 chr(112) => chr(130).
'P', chr(113) => chr(130).
'Q', chr(114) => chr(130).
'R', chr(115) => chr(130).
'S',
640 chr(116) => chr(130).
'T', chr(117) => chr(130).
'U', chr(118) => chr(130).
'V', chr(119) => chr(130).
'W',
641 chr(120) => chr(130).
'X', chr(121) => chr(130).
'Y', chr(122) => chr(130).
'Z', chr(123) => chr(131).
'P',
642 chr(124) => chr(131).
'Q', chr(125) => chr(131).
'R', chr(126) => chr(131).
'S', chr(127) => chr(131).
'T');
644 $clen = strlen(
$code);
645 for (
$i = 0 ;
$i < $clen; ++
$i) {
649 $code_ext .= $encode[
$code{
$i}];
654 $code =
'*'.$code_ext.
'*';
655 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
657 $clen = strlen(
$code);
658 for (
$i = 0;
$i < $clen; ++
$i) {
660 if(!isset($chr[$char])) {
664 for ($j = 0; $j < 6; ++$j) {
670 $w = $chr[$char]{$j};
671 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
672 $bararray[
'maxw'] +=
$w;
676 $bararray[
'bcode'][$k] = array(
't' =>
true,
'w' => 1,
'h' => 1,
'p' => 0);
677 $bararray[
'maxw'] += 1;
690 '0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
691 'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
692 'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
693 'W',
'X',
'Y',
'Z',
'-',
'.',
' ',
'$',
'/',
'+',
'%',
696 $code = strtr(
$code, chr(128).chr(131).chr(129).chr(130),
'<=>?');
697 $len = strlen(
$code);
701 for (
$i = ($len - 1);
$i >= 0; --
$i) {
702 $k = array_keys($chars,
$code{
$i});
703 $check += ($k[0] * $p);
715 for (
$i = $len;
$i >= 0; --
$i) {
716 $k = array_keys($chars,
$code{
$i});
717 $check += ($k[0] * $p);
727 $checksum = strtr($checksum,
'<=>?', chr(128).chr(131).chr(129).chr(130));
738 $len = strlen(
$code);
740 for (
$i = 0;
$i < $len;
$i+=2) {
744 for (
$i = 1;
$i < $len;
$i+=2) {
764 $chr[
'0'] =
'100100100100';
765 $chr[
'1'] =
'100100100110';
766 $chr[
'2'] =
'100100110100';
767 $chr[
'3'] =
'100100110110';
768 $chr[
'4'] =
'100110100100';
769 $chr[
'5'] =
'100110100110';
770 $chr[
'6'] =
'100110110100';
771 $chr[
'7'] =
'100110110110';
772 $chr[
'8'] =
'110100100100';
773 $chr[
'9'] =
'110100100110';
774 $chr[
'A'] =
'110100110100';
775 $chr[
'B'] =
'110100110110';
776 $chr[
'C'] =
'110110100100';
777 $chr[
'D'] =
'110110100110';
778 $chr[
'E'] =
'110110110100';
779 $chr[
'F'] =
'110110110110';
782 $clen = strlen(
$code);
785 for (
$i = ($clen - 1);
$i >= 0; --
$i) {
786 $check += (hexdec(
$code{
$i}) * $p);
794 $check = 11 - $check;
799 $clen = strlen(
$code);
800 for (
$i = 0;
$i < $clen; ++
$i) {
802 if (!isset($chr[$digit])) {
806 $seq .= $chr[$digit];
809 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
823 $chr[
'0'] =
'10101110111010';
824 $chr[
'1'] =
'11101010101110';
825 $chr[
'2'] =
'10111010101110';
826 $chr[
'3'] =
'11101110101010';
827 $chr[
'4'] =
'10101110101110';
828 $chr[
'5'] =
'11101011101010';
829 $chr[
'6'] =
'10111011101010';
830 $chr[
'7'] =
'10101011101110';
831 $chr[
'8'] =
'10101110111010';
832 $chr[
'9'] =
'10111010111010';
837 if((strlen(
$code) % 2) != 0) {
842 $clen = strlen(
$code);
843 for (
$i = 0;
$i < $clen; ++
$i) {
845 if (!isset($chr[$digit])) {
849 $seq .= $chr[$digit];
852 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
868 for (
$i = 0;
$i < $len; ++
$i) {
870 if ((
$i == ($len - 1)) OR ((
$i < ($len - 1)) AND ($seq{
$i} != $seq{(
$i+1)}))) {
871 if ($seq{
$i} ==
'1') {
876 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
877 $bararray[
'maxw'] +=
$w;
911 if((strlen(
$code) % 2) != 0) {
918 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
920 $clen = strlen(
$code);
921 for (
$i = 0;
$i < $clen;
$i = (
$i + 2)) {
924 if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) {
930 $chrlen = strlen($chr[$char_bar]);
931 for (
$s = 0;
$s < $chrlen;
$s++){
932 $seq .= $chr[$char_bar]{
$s} . $chr[$char_space]{
$s};
934 $seqlen = strlen($seq);
935 for ($j = 0; $j < $seqlen; ++$j) {
942 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
943 $bararray[
'maxw'] +=
$w;
1070 $keys_a =
' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_';
1071 $keys_a .= chr(0).chr(1).chr(2).chr(3).chr(4).chr(5).chr(6).chr(7).chr(8).chr(9);
1072 $keys_a .= chr(10).chr(11).chr(12).chr(13).chr(14).chr(15).chr(16).chr(17).chr(18).chr(19);
1073 $keys_a .= chr(20).chr(21).chr(22).chr(23).chr(24).chr(25).chr(26).chr(27).chr(28).chr(29);
1074 $keys_a .= chr(30).chr(31);
1076 $keys_b =
' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'.chr(127);
1078 $fnc_a = array(241 => 102, 242 => 97, 243 => 96, 244 => 101);
1079 $fnc_b = array(241 => 102, 242 => 97, 243 => 96, 244 => 100);
1081 $code_data = array();
1083 $len = strlen(
$code);
1084 switch(strtoupper(
$type)) {
1087 for (
$i = 0;
$i < $len; ++
$i) {
1089 $char_id = ord($char);
1090 if (($char_id >= 241) AND ($char_id <= 244)) {
1091 $code_data[] = $fnc_a[$char_id];
1092 } elseif (($char_id >= 0) AND ($char_id <= 95)) {
1093 $code_data[] = strpos($keys_a, $char);
1102 for (
$i = 0;
$i < $len; ++
$i) {
1104 $char_id = ord($char);
1105 if (($char_id >= 241) AND ($char_id <= 244)) {
1106 $code_data[] = $fnc_b[$char_id];
1107 } elseif (($char_id >= 32) AND ($char_id <= 127)) {
1108 $code_data[] = strpos($keys_b, $char);
1117 if (ord(
$code[0]) == 241) {
1122 if (($len % 2) != 0) {
1126 for (
$i = 0;
$i < $len;
$i+=2) {
1128 if (preg_match(
'/([0-9]{2})/', $chrnum) > 0) {
1129 $code_data[] = intval($chrnum);
1138 $sequence = array();
1141 preg_match_all(
'/([0-9]{4,})/',
$code, $numseq, PREG_OFFSET_CAPTURE);
1142 if (isset($numseq[1]) AND !empty($numseq[1])) {
1144 foreach ($numseq[1] as $val) {
1146 if ($offset > $end_offset) {
1148 $sequence = array_merge($sequence, $this->
get128ABsequence(substr(
$code, $end_offset, ($offset - $end_offset))));
1151 $slen = strlen($val[0]);
1152 if (($slen % 2) != 0) {
1156 $sequence[] = array(
'C', substr(
$code, $offset, $slen), $slen);
1157 $end_offset = $offset + $slen;
1159 if ($end_offset < $len) {
1167 foreach ($sequence as
$key => $seq) {
1172 } elseif ($sequence[(
$key - 1)][0] !=
'A') {
1173 if (($seq[2] == 1) AND (
$key > 0) AND ($sequence[(
$key - 1)][0] ==
'B') AND (!isset($sequence[(
$key - 1)][3]))) {
1177 $sequence[
$key][3] =
true;
1178 } elseif (!isset($sequence[(
$key - 1)][3])) {
1182 for (
$i = 0;
$i < $seq[2]; ++
$i) {
1183 $char = $seq[1]{
$i};
1184 $char_id = ord($char);
1185 if (($char_id >= 241) AND ($char_id <= 244)) {
1186 $code_data[] = $fnc_a[$char_id];
1188 $code_data[] = strpos($keys_a, $char);
1195 $tmpchr = ord($seq[1][0]);
1196 if (($seq[2] == 1) AND ($tmpchr >= 241) AND ($tmpchr <= 244) AND isset($sequence[(
$key + 1)]) AND ($sequence[(
$key + 1)][0] !=
'B')) {
1197 switch ($sequence[(
$key + 1)][0]) {
1200 $sequence[
$key][0] =
'A';
1201 $code_data[] = $fnc_a[$tmpchr];
1206 $sequence[
$key][0] =
'C';
1207 $code_data[] = $fnc_a[$tmpchr];
1215 } elseif ($sequence[(
$key - 1)][0] !=
'B') {
1216 if (($seq[2] == 1) AND (
$key > 0) AND ($sequence[(
$key - 1)][0] ==
'A') AND (!isset($sequence[(
$key - 1)][3]))) {
1220 $sequence[
$key][3] =
true;
1221 } elseif (!isset($sequence[(
$key - 1)][3])) {
1225 for (
$i = 0;
$i < $seq[2]; ++
$i) {
1226 $char = $seq[1]{
$i};
1227 $char_id = ord($char);
1228 if (($char_id >= 241) AND ($char_id <= 244)) {
1229 $code_data[] = $fnc_b[$char_id];
1231 $code_data[] = strpos($keys_b, $char);
1239 } elseif ($sequence[(
$key - 1)][0] !=
'C') {
1242 for (
$i = 0;
$i < $seq[2];
$i+=2) {
1243 $chrnum = $seq[1]{
$i}.$seq[1]{
$i+1};
1244 $code_data[] = intval($chrnum);
1254 foreach ($code_data as
$key => $val) {
1255 $sum += ($val * (
$key + 1));
1258 $code_data[] = ($sum % 103);
1263 array_unshift($code_data, $startid);
1265 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1266 foreach ($code_data as $val) {
1268 for ($j = 0; $j < 6; ++$j) {
1269 if (($j % 2) == 0) {
1275 $bararray[
'bcode'][] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
1276 $bararray[
'maxw'] +=
$w;
1289 $len = strlen(
$code);
1290 $sequence = array();
1293 preg_match_all(
'/([\0-\31])/',
$code, $numseq, PREG_OFFSET_CAPTURE);
1294 if (isset($numseq[1]) AND !empty($numseq[1])) {
1296 foreach ($numseq[1] as $val) {
1298 if ($offset > $end_offset) {
1300 $sequence[] = array(
'B', substr(
$code, $end_offset, ($offset - $end_offset)), ($offset - $end_offset));
1303 $slen = strlen($val[0]);
1304 $sequence[] = array(
'A', substr(
$code, $offset, $slen), $slen);
1305 $end_offset = $offset + $slen;
1307 if ($end_offset < $len) {
1308 $sequence[] = array(
'B', substr(
$code, $end_offset), ($len - $end_offset));
1312 $sequence[] = array(
'B',
$code, $len);
1333 $data_len = $len - 1;
1335 $code = str_pad(
$code, $data_len,
'0', STR_PAD_LEFT);
1336 $code_len = strlen(
$code);
1339 for (
$i = 1;
$i < $data_len;
$i+=2) {
1346 for (
$i = 0;
$i < $data_len;
$i+=2) {
1352 $r = ($sum_a + $sum_b) % 10;
1356 if ($code_len == $data_len) {
1359 } elseif (
$r !== intval(
$code{$data_len})) {
1370 $tmp = substr(
$code, 4, 3);
1371 if (($tmp ==
'000') OR ($tmp ==
'100') OR ($tmp ==
'200')) {
1373 $upce_code = substr(
$code, 2, 2).substr(
$code, 9, 3).substr(
$code, 4, 1);
1375 $tmp = substr(
$code, 5, 2);
1378 $upce_code = substr(
$code, 2, 3).substr(
$code, 10, 2).
'3';
1380 $tmp = substr(
$code, 6, 1);
1383 $upce_code = substr(
$code, 2, 4).substr(
$code, 11, 1).
'4';
1386 $upce_code = substr(
$code, 2, 5).substr(
$code, 11, 1);
1428 '0'=>array(
'A',
'A',
'A',
'A',
'A',
'A'),
1429 '1'=>array(
'A',
'A',
'B',
'A',
'B',
'B'),
1430 '2'=>array(
'A',
'A',
'B',
'B',
'A',
'B'),
1431 '3'=>array(
'A',
'A',
'B',
'B',
'B',
'A'),
1432 '4'=>array(
'A',
'B',
'A',
'A',
'B',
'B'),
1433 '5'=>array(
'A',
'B',
'B',
'A',
'A',
'B'),
1434 '6'=>array(
'A',
'B',
'B',
'B',
'A',
'A'),
1435 '7'=>array(
'A',
'B',
'A',
'B',
'A',
'B'),
1436 '8'=>array(
'A',
'B',
'A',
'B',
'B',
'A'),
1437 '9'=>array(
'A',
'B',
'B',
'A',
'B',
'A')
1439 $upce_parities = array();
1440 $upce_parities[0] = array(
1441 '0'=>array(
'B',
'B',
'B',
'A',
'A',
'A'),
1442 '1'=>array(
'B',
'B',
'A',
'B',
'A',
'A'),
1443 '2'=>array(
'B',
'B',
'A',
'A',
'B',
'A'),
1444 '3'=>array(
'B',
'B',
'A',
'A',
'A',
'B'),
1445 '4'=>array(
'B',
'A',
'B',
'B',
'A',
'A'),
1446 '5'=>array(
'B',
'A',
'A',
'B',
'B',
'A'),
1447 '6'=>array(
'B',
'A',
'A',
'A',
'B',
'B'),
1448 '7'=>array(
'B',
'A',
'B',
'A',
'B',
'A'),
1449 '8'=>array(
'B',
'A',
'B',
'A',
'A',
'B'),
1450 '9'=>array(
'B',
'A',
'A',
'B',
'A',
'B')
1452 $upce_parities[1] = array(
1453 '0'=>array(
'A',
'A',
'A',
'B',
'B',
'B'),
1454 '1'=>array(
'A',
'A',
'B',
'A',
'B',
'B'),
1455 '2'=>array(
'A',
'A',
'B',
'B',
'A',
'B'),
1456 '3'=>array(
'A',
'A',
'B',
'B',
'B',
'A'),
1457 '4'=>array(
'A',
'B',
'A',
'A',
'B',
'B'),
1458 '5'=>array(
'A',
'B',
'B',
'A',
'A',
'B'),
1459 '6'=>array(
'A',
'B',
'B',
'B',
'A',
'A'),
1460 '7'=>array(
'A',
'B',
'A',
'B',
'A',
'B'),
1461 '8'=>array(
'A',
'B',
'A',
'B',
'B',
'A'),
1462 '9'=>array(
'A',
'B',
'B',
'A',
'B',
'A')
1467 $bararray = array(
'code' => $upce_code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1468 $p = $upce_parities[
$code[1]][
$r];
1469 for (
$i = 0;
$i < 6; ++
$i) {
1470 $seq .= $codes[$p[
$i]][$upce_code{
$i}];
1474 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1475 $half_len = intval(ceil($len / 2));
1477 for (
$i = 0;
$i < $half_len; ++
$i) {
1478 $seq .= $codes[
'A'][
$code{
$i}];
1481 $p = $parities[
$code[0]];
1482 for (
$i = 1;
$i < $half_len; ++
$i) {
1483 $seq .= $codes[$p[
$i-1]][$code{
$i}];
1487 for (
$i = $half_len;
$i < $len; ++
$i) {
1488 $seq .= $codes[
'C'][
$code{
$i}];
1492 $clen = strlen($seq);
1494 for (
$i = 0;
$i < $clen; ++
$i) {
1496 if ((
$i == ($clen - 1)) OR ((
$i < ($clen - 1)) AND ($seq{
$i} != $seq{(
$i+1)}))) {
1497 if ($seq{
$i} ==
'1') {
1502 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
1503 $bararray[
'maxw'] +=
$w;
1522 $code = str_pad(
$code, $len,
'0', STR_PAD_LEFT);
1526 } elseif ($len == 5) {
1557 $parities = array();
1558 $parities[2] = array(
1559 '0'=>array(
'A',
'A'),
1560 '1'=>array(
'A',
'B'),
1561 '2'=>array(
'B',
'A'),
1564 $parities[5] = array(
1565 '0'=>array(
'B',
'B',
'A',
'A',
'A'),
1566 '1'=>array(
'B',
'A',
'B',
'A',
'A'),
1567 '2'=>array(
'B',
'A',
'A',
'B',
'A'),
1568 '3'=>array(
'B',
'A',
'A',
'A',
'B'),
1569 '4'=>array(
'A',
'B',
'B',
'A',
'A'),
1570 '5'=>array(
'A',
'A',
'B',
'B',
'A'),
1571 '6'=>array(
'A',
'A',
'A',
'B',
'B'),
1572 '7'=>array(
'A',
'B',
'A',
'B',
'A'),
1573 '8'=>array(
'A',
'B',
'A',
'A',
'B'),
1574 '9'=>array(
'A',
'A',
'B',
'A',
'B')
1576 $p = $parities[$len][
$r];
1578 $seq .= $codes[$p[0]][
$code[0]];
1579 for (
$i = 1;
$i < $len; ++
$i) {
1581 $seq .= $codes[$p[
$i]][$code{
$i}];
1583 $bararray = array(
'code' => $code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1599 0 => Array(1,1,2,2,2),
1600 1 => Array(2,2,2,1,1),
1601 2 => Array(2,2,1,2,1),
1602 3 => Array(2,2,1,1,2),
1603 4 => Array(2,1,2,2,1),
1604 5 => Array(2,1,2,1,2),
1605 6 => Array(2,1,1,2,2),
1606 7 => Array(1,2,2,2,1),
1607 8 => Array(1,2,2,1,2),
1608 9 => Array(1,2,1,2,2)
1612 0 => Array(2,2,1,1,1),
1613 1 => Array(1,1,1,2,2),
1614 2 => Array(1,1,2,1,2),
1615 3 => Array(1,1,2,2,1),
1616 4 => Array(1,2,1,1,2),
1617 5 => Array(1,2,1,2,1),
1618 6 => Array(1,2,2,1,1),
1619 7 => Array(2,1,1,1,2),
1620 8 => Array(2,1,1,2,1),
1621 9 => Array(2,1,2,1,1)
1624 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 2,
'bcode' => array());
1628 $len = strlen(
$code);
1631 for (
$i = 0;
$i < $len; ++
$i) {
1634 $chkd = ($sum % 10);
1636 $chkd = (10 - $chkd);
1639 $len = strlen(
$code);
1641 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' => 2,
'p' => 0);
1642 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
1643 $bararray[
'maxw'] += 2;
1644 for (
$i = 0;
$i < $len; ++
$i) {
1645 for ($j = 0; $j < 5; ++$j) {
1648 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' =>
$h,
'p' => $p);
1649 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
1650 $bararray[
'maxw'] += 2;
1654 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' => 2,
'p' => 0);
1655 $bararray[
'maxw'] += 1;
1676 '0' => array(3,3,2,2),
1677 '1' => array(3,4,1,2),
1678 '2' => array(3,4,2,1),
1679 '3' => array(4,3,1,2),
1680 '4' => array(4,3,2,1),
1681 '5' => array(4,4,1,1),
1682 '6' => array(3,1,4,2),
1683 '7' => array(3,2,3,2),
1684 '8' => array(3,2,4,1),
1685 '9' => array(4,1,3,2),
1686 'A' => array(4,1,4,1),
1687 'B' => array(4,2,3,1),
1688 'C' => array(3,1,2,4),
1689 'D' => array(3,2,1,4),
1690 'E' => array(3,2,2,3),
1691 'F' => array(4,1,1,4),
1692 'G' => array(4,1,2,3),
1693 'H' => array(4,2,1,3),
1694 'I' => array(1,3,4,2),
1695 'J' => array(1,4,3,2),
1696 'K' => array(1,4,4,1),
1697 'L' => array(2,3,3,2),
1698 'M' => array(2,3,4,1),
1699 'N' => array(2,4,3,1),
1700 'O' => array(1,3,2,4),
1701 'P' => array(1,4,1,4),
1702 'Q' => array(1,4,2,3),
1703 'R' => array(2,3,1,4),
1704 'S' => array(2,3,2,3),
1705 'T' => array(2,4,1,3),
1706 'U' => array(1,1,4,4),
1707 'V' => array(1,2,3,4),
1708 'W' => array(1,2,4,3),
1709 'X' => array(2,1,3,4),
1710 'Y' => array(2,1,4,3),
1711 'Z' => array(2,2,3,3)
1714 $len = strlen(
$code);
1715 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 3,
'bcode' => array());
1718 $checktable = array(
1758 for (
$i = 0;
$i < $len; ++
$i) {
1760 $col += $checktable[
$code{
$i}][1];
1764 $chk = array_keys($checktable, array(
$row,$col));
1771 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' => 2,
'p' => 0);
1772 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
1773 $bararray[
'maxw'] += 2;
1775 for (
$i = 0;
$i < $len; ++
$i) {
1776 for ($j = 0; $j < 4; ++$j) {
1777 switch ($barmode[
$code{
$i}][$j]) {
1799 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' =>
$h,
'p' => $p);
1800 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
1801 $bararray[
'maxw'] += 2;
1806 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' => 3,
'p' => 0);
1807 $bararray[
'maxw'] += 1;
1842 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1847 $len = strlen(
$code);
1848 for (
$i = 0;
$i < $len; ++
$i) {
1849 if (!isset($chr[
$code{
$i}])) {
1852 $seq = $chr[$code{
$i}];
1853 for ($j = 0; $j < 8; ++$j) {
1854 if (($j % 2) == 0) {
1860 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
1861 $bararray[
'maxw'] +=
$w;
1890 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1894 $len = strlen(
$code);
1898 for (
$i = ($len - 1);
$i >= 0; --
$i) {
1900 if ($digit ==
'-') {
1903 $dval = intval($digit);
1905 $check += ($dval * $p);
1920 for (
$i = $len;
$i >= 0; --
$i) {
1922 if ($digit ==
'-') {
1925 $dval = intval($digit);
1927 $check += ($dval * $p);
1937 $code =
'S'.$code.
'S';
1939 for (
$i = 0;
$i < $len; ++
$i) {
1940 if (!isset($chr[
$code{
$i}])) {
1943 $seq = $chr[$code{
$i}];
1944 for ($j = 0; $j < 6; ++$j) {
1945 if (($j % 2) == 0) {
1951 $bararray[
'bcode'][$k] = array(
't' =>
$t,
'w' =>
$w,
'h' => 1,
'p' => 0);
1952 $bararray[
'maxw'] +=
$w;
1970 if ((
$code % 2) == 0) {
1979 $seq = substr($seq, 0, -2);
1980 $seq = strrev($seq);
1981 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 1,
'bcode' => array());
1996 switch (
$code % 3) {
2013 }
while(
$code != 0);
2014 $seq = strrev($seq);
2016 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 2,
'bcode' => array());
2017 $len = strlen($seq);
2018 for (
$i = 0;
$i < $len; ++
$i) {
2036 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' =>
$h,
'p' => $p);
2037 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
2038 $bararray[
'maxw'] += 2;
2040 unset($bararray[
'bcode'][($k - 1)]);
2041 --$bararray[
'maxw'];
2055 $asc_chr = array(4,0,2,6,3,5,1,9,8,7,1,2,0,6,4,8,2,9,5,3,0,1,3,7,4,6,8,9,2,0,5,1,9,4,3,8,6,7,1,2,4,3,9,5,7,8,3,0,2,1,4,0,9,1,7,0,2,4,6,3,7,1,9,5,8);
2056 $dsc_chr = array(7,1,9,5,8,0,2,4,6,3,5,8,9,7,3,0,6,1,7,4,6,8,9,2,5,1,7,5,4,3,8,7,6,0,2,5,4,9,3,0,1,6,8,2,0,4,5,9,6,7,5,2,6,3,8,5,1,9,8,7,4,0,2,6,3);
2057 $asc_pos = array(3,0,8,11,1,12,8,11,10,6,4,12,2,7,9,6,7,9,2,8,4,0,12,7,10,9,0,7,10,5,7,9,6,8,2,12,1,4,2,0,1,5,4,6,12,1,0,9,4,7,5,10,2,6,9,11,2,12,6,7,5,11,0,3,2);
2058 $dsc_pos = array(2,10,12,5,9,1,5,4,3,9,11,5,10,1,6,3,4,1,10,0,2,11,8,6,1,12,3,8,6,4,4,11,0,6,1,9,11,5,3,7,3,10,7,11,8,2,10,3,5,8,0,3,12,11,8,4,5,1,3,0,7,12,9,8,10);
2059 $code_arr = explode(
'-',
$code);
2060 $tracking_number = $code_arr[0];
2061 if (isset($code_arr[1])) {
2062 $routing_code = $code_arr[1];
2067 switch (strlen($routing_code)) {
2073 $binary_code = bcadd($routing_code,
'1');
2077 $binary_code = bcadd($routing_code,
'100001');
2081 $binary_code = bcadd($routing_code,
'1000100001');
2089 $binary_code = bcmul($binary_code, 10);
2090 $binary_code = bcadd($binary_code, $tracking_number[0]);
2091 $binary_code = bcmul($binary_code, 5);
2092 $binary_code = bcadd($binary_code, $tracking_number[1]);
2093 $binary_code .= substr($tracking_number, 2, 18);
2095 $binary_code = $this->
dec_to_hex($binary_code);
2097 $binary_code = str_pad($binary_code, 26,
'0', STR_PAD_LEFT);
2099 $binary_code_arr = chunk_split($binary_code, 2,
"\r");
2100 $binary_code_arr = substr($binary_code_arr, 0, -1);
2101 $binary_code_arr = explode(
"\r", $binary_code_arr);
2105 $first_byte = sprintf(
'%2s', dechex((hexdec($binary_code_arr[0]) << 2) >> 2));
2106 $binary_code_102bit = $first_byte.substr($binary_code, 2);
2108 $codewords = array();
2110 $codewords[0] = bcmod(
$data, 636) * 2;
2112 for (
$i = 1;
$i < 9; ++
$i) {
2113 $codewords[
$i] = bcmod(
$data, 1365);
2116 $codewords[9] =
$data;
2117 if (($fcs >> 10) == 1) {
2118 $codewords[9] += 659;
2124 $characters = array();
2126 foreach($codewords as $k => $val) {
2128 $chrcode = $table5of13[$val];
2130 $chrcode = $table2of13[($val - 1287)];
2132 if (($fcs & $bitmask) > 0) {
2134 $chrcode = ((~$chrcode) & 8191);
2136 $characters[] = $chrcode;
2139 $characters = array_reverse($characters);
2142 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 3,
'bcode' => array());
2143 for (
$i = 0;
$i < 65; ++
$i) {
2144 $asc = (($characters[$asc_chr[
$i]] & pow(2, $asc_pos[
$i])) > 0);
2145 $dsc = (($characters[$dsc_chr[
$i]] & pow(2, $dsc_pos[$i])) > 0);
2146 if ($asc AND $dsc) {
2163 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' =>
$h,
'p' => $p);
2164 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
2165 $bararray[
'maxw'] += 2;
2167 unset($bararray[
'bcode'][($k - 1)]);
2168 --$bararray[
'maxw'];
2180 if (!preg_match(
'/^[fadtFADT]{65}$/',
$code) == 1) {
2183 $characters = str_split(strtolower(
$code), 1);
2186 $bararray = array(
'code' =>
$code,
'maxw' => 0,
'maxh' => 3,
'bcode' => array());
2187 for (
$i = 0;
$i < 65; ++
$i) {
2188 switch($characters[
$i]) {
2214 $bararray[
'bcode'][$k++] = array(
't' => 1,
'w' => 1,
'h' =>
$h,
'p' => $p);
2215 $bararray[
'bcode'][$k++] = array(
't' => 0,
'w' => 1,
'h' => 2,
'p' => 0);
2216 $bararray[
'maxw'] += 2;
2218 unset($bararray[
'bcode'][($k - 1)]);
2219 --$bararray[
'maxw'];
2235 while($number > 0) {
2237 array_push($hex,
'0');
2239 array_push($hex, strtoupper(dechex(bcmod($number,
'16'))));
2240 $number = bcdiv($number,
'16', 0);
2243 $hex = array_reverse($hex);
2244 return implode($hex);
2256 $len = strlen($hex);
2257 for($pos = ($len - 1); $pos >= 0; --$pos) {
2258 $dec = bcadd($dec, bcmul(hexdec($hex{$pos}), $bitval));
2259 $bitval = bcmul($bitval, 16);
2274 $data = hexdec($code_arr[0]) << 5;
2275 for ($bit = 2; $bit < 8; ++$bit) {
2276 if (($fcs ^
$data) & 0x400) {
2277 $fcs = ($fcs << 1) ^ $genpoly;
2285 for ($byte = 1; $byte < 13; ++$byte) {
2286 $data = hexdec($code_arr[$byte]) << 3;
2287 for ($bit = 0; $bit < 8; ++$bit) {
2288 if (($fcs ^
$data) & 0x400) {
2289 $fcs = ($fcs << 1) ^ $genpoly;
2308 for (
$i = 0;
$i < 16; ++
$i) {
2327 for ($count = 0; $count < 8192; ++$count) {
2329 for ($bit_index = 0; $bit_index < 13; ++$bit_index) {
2330 $bit_count += intval(($count & (1 << $bit_index)) != 0);
2333 if ($bit_count ==
$n) {
2336 if ($reverse >= $count) {
2339 if ($reverse == $count) {
barcode_i25($code, $checksum=false)
Interleaved 2 of 5 barcodes.
getBarcodeArray()
Return an array representations of barcode.
checksum_code93($code)
Calculate CODE 93 checksum (modulo 47).
barcode_eanext($code, $len=5)
UPC-Based Extensions 2-Digit Ext.
checksum_code39($code)
Calculate CODE 39 checksum (modulo 43).
get128ABsequence($code)
Split text code in A/B sequence for 128 code.
imb_crc11fcs($code_arr)
Intelligent Mail Barcode calculation of Frame Check Sequence.
hex_to_dec($hex)
Convert large hexadecimal number to decimal representation (string).
barcode_code39($code, $extended=false, $checksum=false)
CODE 39 - ANSI MH10.8M-1983 - USD-3 - 3 of 9.
getBarcodeHTML($w=2, $h=30, $color='black')
Return an HTML representation of barcode.
barcode_postnet($code, $planet=false)
POSTNET and PLANET barcodes.
getBarcodePNG($w=2, $h=30, $color=array(0, 0, 0))
Send a PNG image representation of barcode (requires GD or Imagick library).
barcode_codabar($code)
CODABAR barcodes.
$barcode_array
Array representation of barcode.
barcode_rms4cc($code, $kix=false)
RMS4CC - CBC - KIX RMS4CC (Royal Mail 4-state Customer Code) - CBC (Customer Bar Code) - KIX (Klant i...
getBarcodeSVG($w=2, $h=30, $color='black')
Send barcode as SVG image object to the standard output.
imb_reverse_us($num)
Reverse unsigned short value.
__construct($code, $type)
This is the class constructor.
setBarcode($code, $type)
Set the barcode.
barcode_imb($code)
IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200 (requires PHP bcmath extension) Intelligent Ma...
barcode_imb_pre($code)
IMB - Intelligent Mail Barcode - Onecode - USPS-B-3200.
barcode_msi($code, $checksum=false)
MSI.
barcode_pharmacode($code)
Pharmacode Contains digits (0 to 9)
PHP class to creates array representations for common 1D barcodes to be used with TCPDF (http://www...
barcode_s25($code, $checksum=false)
Standard 2 of 5 barcodes.
getBarcodePngData($w=2, $h=30, $color=array(0, 0, 0))
Return a PNG image representation of barcode (requires GD or Imagick library).
barcode_eanupc($code, $len=13)
EAN13 and UPC-A barcodes.
barcode_c128($code, $type='')
C128 barcodes.
binseq_to_array($seq, $bararray)
Convert binary barcode sequence to TCPDF barcode array.
barcode_pharmacode2t($code)
Pharmacode two-track Contains digits (0 to 9)
getBarcodeSVGcode($w=2, $h=30, $color='black')
Return a SVG string representation of barcode.
imb_tables($n, $size)
generate Nof13 tables used for Intelligent Mail Barcode
if(empty($password)) $table
dec_to_hex($number)
Convert large integer number to hexadecimal representation.
checksum_s25($code)
Checksum for standard 2 of 5 barcodes.
barcode_code11($code)
CODE11 barcodes.
barcode_code93($code)
CODE 93 - USS-93 Compact code similar to Code 39.
encode_code39_ext($code)
Encode a string to be used for CODE 39 Extended mode.