"UPC-A / EAN-13", "UPCE" => "UPC-E", "EAN2" => "EAN-2", "EAN5" => "EAN-5", "EAN8" => "EAN-8", "CODE39" => "Code 39", "CODE93" => "Code 93", "CODE39M43" => "Code 39 modulo 43", "CODE93M47" => "Code 93 modulo 47", // "CODE128" => "Code 128" ); //$code = "79006927557"; $type = "UPC"; //+chksum //$code = "03600029145"; $type = "UPC-A"; //$code = "654321"; $type = "UPC-E"; //$code = "425261"; $type = "UPC-E"; //$code = "53"; $type = "EAN-2"; //$code = "52495"; $type = "EAN-5"; //$code = "90200"; $type = "EAN-5"; //$code = "73513537"; $type = "EAN-8"; //+chksum //$code = "9638507"; $type = "EAN-8"; //$code = "4770070392058"; $type = "EAN-13"; //+chksum //$code = "301426022884"; $type = "EAN-13"; $code = "This is code 93 modulo 47"; $type = "CODE93M47"; //$code = "This is code 128"; $type = "CODE128"; //isset($_GET["x"]) ? $test = true : $test = false; echo ($test) ? '
':'';

if (isset($_GET["code"])) $code = $_GET["code"]; 
if (isset($_GET["type"])) $type = $_GET["type"]; 
$type = str_replace(array("-", " "), "", strtoupper($type));

if (!$_GET && !$test) {
	$local_hosts = array(
		'localhost',
		'127.0.0.1'
		);
	$hostname = $_SERVER['HTTP_HOST'];
	$host_is_local = false;
	foreach ($local_hosts as $host)
		if ($host == $hostname) $host_is_local = true;
	
	header("Content-type: text/html;charset=utf-8");
?>


	
		Home of the U-D13 - The BaarKode Project
		
		
		
    
	
	
		
		
The BaarKode Project
barcode
> 30 "11011000110", // ? ? 31 "11000110110", // @ @ 32 "10100011000", // A A 33 "10001011000", // B B 34 "10001000110", // C C 35 "10110001000", // D D 36 "10001101000", // E E 37 "10001100010", // F F 38 "11010001000", // G G 39 "11000101000", // H H 40 "11000100010", // I I 41 "10110111000", // J J 42 "10110001110", // K K 43 "10001101110", // L L 44 "10111011000", // M M 45 "10111000110", // N N 46 "10001110110", // O O 47 "11101110110", // P P 48 "11010001110", // Q Q 49 "11000101110", // R R 50 "11011101000", // S S 51 "11011100010", // T T 52 "11011101110", // U U 53 "11101011000", // V V 54 "11101000110", // W W 55 "11100010110", // X X 56 "11101101000", // Y Y 57 "11101100010", // Z Z 58 "11100011010", // [ [ 59 "11101111010", // \ \ 60 "11001000010", // ] ] 61 "11110001010", // ^ ^ 62 "10100110000", // _ _ 63 "10100001100", // NUL ` 64 "10010110000", // SOH a 65 "10010000110", // STX b 66 "10000101100", // ETX c 67 "10000100110", // EOT d 68 "10110010000", // ENQ e 69 "10110000100", // ACK f 70 "10011010000", // BEL g 71 "10011000010", // BS h 72 "10000110100", // HT i 73 "10000110010", // LF j 74 "11000010010", // VT k 75 "11001010000", // FF l 76 "11110111010", // CR m 77 "11000010100", // SO n 78 "10001111010", // SI o 79 "10100111100", // DLE p 80 "10010111100", // DC1 q 81 "10010011110", // DC2 r 82 "10111100100", // DC3 s 83 "10011110100", // DC4 t 84 "10011110010", // NAK u 85 "11110100100", // SYN v 86 "11110010100", // ETB w 87 "11110010010", // CAN x 88 "11011011110", // EM y 89 "11011110110", // SUB z 90 "11110110110", // ESC { 91 "10101111000", // FS | 92 "10100011110", // GS } 93 "10001011110", // RS ~ 94 "10111101000", // US DEL 95 "10111100010", // FNC3 FNC3 96 "11110101000", // FNC2 FNC2 97 "11110100010", // SHIFT SHIFT 98 "10111011110", // Code C Code C 99 "10111101110", // Code B FNC4 Code B "11101011110", // FNC4 Code A Code A "11110101110", // FNC1 FNC1 FNC1 "11010000100", // START A START A START A "11010010000", // START B START B START B "11010011100", // START C START C START C "11000111010" // STOP STOP STOP ); } if (!$code = checksumBC($code, $type)) errimg ("Invalid checksum!"); if ($test) echo "code = $code; type = $type;\n"; //$code = "4770070392058"; // Barcode data. Formated for encoding (checksums calculated etc.) if (!$xode = stringBC($code, $type)) errimg ("Could not generate binary barcode string!"); if ($test) echo "code = $code; type = $type;\n"; //$code = "101011 false11 011111"; // Binary barcode string. "1" accepted as true, anything else - false. $thickness = 2; // Thickness of code bars (in pixels). Default: 2 $heigth = 100; // Heigth of code bars (in pixels). Default: 100 $span = array( 0, 0, 0, 0); // Spanning ("quite zone") (left, top, right, bottom). Default: ( 15, 15, 15, 15) $color[0] = array(255, 176, 0); // Background ("false") color (red, green, blue). Default: (255, 255, 255) $color[1] = array( 26, 26, 26); // Foreground ("true") color (red, green, blue). Default: ( 0, 0, 0) if (isset($_GET["thickness"])) $thickness = (int)$_GET["thickness"]; if (isset($_GET["heigth"])) $heigth = (int)$_GET["heigth"]; if (isset($_GET["span"])) $span = (int)$_GET["span"]; if (isset($_GET["color"])) $color = json_decode($_GET["color"]); $img = drawBC($xode, $thickness, $heigth);//, $span, $color); if ($img) { if (!$test) header("Content-Type: image/png"); ImagePNG($img); } else errimg ("Could not draw the barcode!"); // ------------------------------------------------------------------------------------------------- function checksumBC ($code, $type = "UPC") { global $test; $checksum = null; $type = str_replace(array("-", " "), "", strtoupper($type)); $typ3 = substr($type, 0, 3); $typ6 = substr($type, 0, 6); if ($typ3=="EAN" || $typ3=="UPC") $n = 13; if ($type=="EAN8") $n = 8; if ($type=="EAN5") $n = 5; if ($type=="EAN2") $n = 2; if ($type=="UPCE") { $code = sprintf("%07.8s", $code); $xcode = substr($code, 1, 6); if ($code[5] < 3) $code = substr($xcode, 0, 2).$xcode[5]."0000".substr($xcode, 2, 3); elseif ($code[5] == 3) $code = substr($xcode, 0, 3)."00000".substr($xcode, 3, 2); elseif ($code[5] == 4) $code = substr($xcode, 0, 4)."00000".$xcode[4]; elseif ($code[5] > 4) $code = substr($xcode, 0, 5)."0000".$xcode[5]; } if ($typ3=="EAN" || $typ3=="UPC") { $fstr = "%0".(($n>5)?$n-1:$n).".".$n."s"; $code = sprintf($fstr, $code); $pcode = ($n>5)?substr($code, 0, $n-1):""; } if ($type=="EAN13" || $type=="EAN8" || $typ3=="UPC") { $checksum = 0; for ($i=0; $i $value) $binary[$key] = str_replace($search, $replace, $value); $literal .= "*"; } if ($typ6=="CODE93") { $binary = array("100010100","101001000","101000100","101000010","100101000","100100100", "100100010","101010000","100010010","100001010","110101000","110100100","110100010", "110010100","110010010","110001010","101101000","101100100","101100010","100110100", "100011010","101011000","101001100","101000110","100101100","100010110","110110100", "110110010","110101100","110100110","110010110","110011010","101101100","101100110", "100110110","100111010","100101110","111010100","111010010","111001010","101101110", "101110110","110101110","100100110","111011010","111010110","100110010","101011110"); for ($i=0; $i<5; $i++) $literal .= chr(128+$i); //($)(%)(/)(+)(*) } if ($typ6=="CODE39" || $typ6=="CODE93") { for ($i=0; $i