Subversion Repositories Web Services

Compare Revisions

Ignore whitespace Rev 56957 → Rev 56961

/OpenBarcode/trunk/FreeSansBold.ttf
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/OpenBarcode/trunk/FreeSansBold.ttf
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: OpenBarcode/trunk/barcode.php
===================================================================
--- OpenBarcode/trunk/barcode.php (revision 56957)
+++ OpenBarcode/trunk/barcode.php (revision 56961)
@@ -2,11 +2,11 @@
/*
* Image-Creator / Sample
- * Part of PHP-Barcode 0.3pl1
+ * Part of PHP-Barcode 0.4
* (C) 2001,2002,2003,2004 by Folke Ashberg
- * The newest version can be found at http://www.ashberg.de/bar
+ * The newest version can be found at http://www.ashberg.de/php-barcode
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -39,8 +39,9 @@
$code=getvar('code');
}
if (!$code) $code='123456789012';
-barcode_print($code,getvar('encoding'),getvar('scale'),getvar('mode'), getvar('checksum'));
+barcode_print($code,getvar('encoding'),getvar('scale'),getvar('mode'));
+
/*
* call
* http://........./barcode.php?code=012345678901
/OpenBarcode/trunk/CHANGELOG
0,0 → 1,12
Version 0.4, 2011-08-15, Folke Ashberg <folke@ashberg.de>
* Bugfix: Correct Shell-Escaping calling genbarcode
* Use of preg functions instead of ereg
* Shipping Free-TTF file
* several fixups
 
Version 0.3pl1, Folke Ashberg <folke@ashberg.de>
+ support for magic_quotes_gpc set to off
 
Version 0.3, Folke Ashberg <folke@ashberg.de>
+ Windows compatible
+ various code-fixes
/OpenBarcode/trunk/encode_bars.php
2,11 → 2,11
/*
 
* Built-In Encoders
* Part of PHP-Barcode 0.3pl1
* Part of PHP-Barcode 0.4
* (C) 2001,2002,2003,2004 by Folke Ashberg <folke@ashberg.de>
* (C) 2001,2002,2003,2004,2011 by Folke Ashberg <folke@ashberg.de>
* The newest version can be found at http://www.ashberg.de/bar
* The newest version can be found at http://www.ashberg.de/php-barcode
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
47,14 → 47,14
$guards=array("9a1a","1a1a1","a1a");
 
$ean=trim($ean);
if (eregi("[^0-9]",$ean)){
if (preg_match("#[^0-9]#i",$ean)){
return array("text"=>"Invalid EAN-Code");
}
$encoding=strtoupper($encoding);
if ($encoding=="ISBN"){
if (!ereg("^978", $ean)) $ean="978".$ean;
if (!preg_match("#^978#", $ean)) $ean="978".$ean;
}
if (ereg("^978", $ean)) $encoding="ISBN";
if (preg_match("#^978#", $ean)) $encoding="ISBN";
if (strlen($ean)<12 || strlen($ean)>13){
return array("text"=>"Invalid $encoding Code (must have 12/13 numbers)");
}
/OpenBarcode/trunk/php-barcode.php
1,6 → 1,6
<?
/*
* PHP-Barcode 0.3pl1
* PHP-Barcode 0.4
* PHP-Barcode generates
* - Barcode-Images using libgd2 (png, jpg, gif)
13,11 → 13,11
* barcode-encoder which uses GNU-Barcode
* genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c),
* I25, 128RAW, CBR, MSI, PLS
* genbarcode is available at www.ashberg.de/bar
* genbarcode is available at www.ashberg.de/php-barcode
* (C) 2001,2002,2003,2004 by Folke Ashberg <folke@ashberg.de>
* (C) 2001,2002,2003,2004,2011 by Folke Ashberg <folke@ashberg.de>
* The newest version can be found at http://www.ashberg.de/bar
* The newest version can be found at http://www.ashberg.de/php-barcode
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
50,24 → 50,9
/* FONT FILE */
/* ******************************************************************** */
/* location the the ttf-font */
/* the file arialbd.ttf isn't included! */
 
/* SAMPLE1 :
* use arialbd.ttf located in same directory like the script
* which includes/requires php-barcode.php
*/
$font_loc=dirname(__FILE__)."/"."FreeSansBold.ttf";
 
// Set the enviroment variable for GD
putenv('GDFONTPATH=' . realpath('.'));
$font_loc="OCR-B_2010_BT.ttf";
 
 
/* Automatic-Detection of Font if running Windows
* kick this lines if you don't need them! */
if (isset($_ENV['windir']) && file_exists($_ENV['windir'])){
$font_loc=$_ENV['windir']."\Fonts\arialbd.ttf";
}
 
/* ******************************************************************** */
/* GENBARCODE */
/* ******************************************************************** */
76,7 → 61,7
* genbarcode is needed to render encodings other than EAN-12/EAN-13/ISBN
*/
//$genbarcode_loc="c:\winnt\genbarcode.exe";
$genbarcode_loc="/var/www/php_exec/genbarcode";
$genbarcode_loc="/usr/local/bin/genbarcode";
 
 
/* CONFIGURATION ENDS HERE */
109,8 → 94,7
global $bar_color, $bg_color, $text_color;
global $font_loc;
/* set defaults */
if ($scale<1) $scale=1;
if ($scale>20) $scale=20;
if ($scale<1) $scale=2;
$total_y=(int)($total_y);
if ($total_y<1) $total_y=(int)$scale * 60;
if (!$space)
126,7 → 110,7
$width=false;
continue;
}
if (ereg("[a-z]", $val)){
if (preg_match("#[a-z]#", $val)){
/* tall bar */
$val=ord($val)-ord('a')+1;
}
138,8 → 122,25
$total_x=( $xpos )+$space['right']+$space['right'];
$xpos=$space['left'];
if (!function_exists("imagecreate")){
print "gd2 extension not enabled<BR>\n";
return "";
print "You don't have the gd2 extension enabled<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "Short HOWTO<BR>\n";
print "<BR>\n";
print "Debian: # apt-get install php4-gd2<BR>\n";
print "<BR>\n";
print "SuSE: ask YaST<BR>\n";
print "<BR>\n";
print "OpenBSD: # pkg_add /path/php4-gd-4.X.X.tgz (read output, you have to enable it)<BR>\n";
print "<BR>\n";
print "Windows: Download the PHP zip package from <A href=\"http://www.php.net/downloads.php\">php.net</A>, NOT the windows-installer, unzip the php_gd2.dll to C:\PHP (this is the default install dir) and uncomment 'extension=php_gd2.dll' in C:\WINNT\php.ini (or where ever your os is installed)<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "The author of php-barcode will give not support on this topic!<BR>\n";
print "<BR>\n";
print "<BR>\n";
print "<A HREF=\"http://www.ashberg.de/php-barcode/\">Folke Ashberg's OpenSource PHP-Barcode</A><BR>\n";
return "";
}
$im=imagecreate($total_x, $total_y);
/* create two images */
159,7 → 160,7
$width=false;
continue;
}
if (ereg("[a-z]", $val)){
if (preg_match("#[a-z]#", $val)){
/* tall bar */
$val=ord($val)-ord('a')+1;
$h=$height2;
177,7 → 178,7
$inf=explode(":", $v);
$fontsize=$scale*($inf[1]/1.8);
$fontheight=$total_y-($fontsize/2.7)+2;
imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2,
@imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2,
$fontheight, $col_text, $font_loc, $inf[2]);
}
}
219,7 → 220,7
for ($a=0;$a<$val;$a++) $bar_line.="-";
continue;
}
if (ereg("[a-z]", $val)){
if (preg_match("#[a-z]#", $val)){
$val=ord($val)-ord('a')+1;
$h=$heigh2;
for ($a=0;$a<$val;$a++) $bar_line.="I";
264,10 → 265,10
$height=round($total_y-($scale*10));
$height2=round($total_y)-$space['bottom'];
$out=
'<Table border=0 cellspacing=0 cellpadding=0 bgcolor="white">'."\n".
'<TR><TD><img src=white.png height="'.$space['top'].'" width=1></TD></TR>'."\n".
'<TR><TD>'."\n".
'<IMG src=white.png height="'.$height2.'" width="'.$space['left'].'">';
'<table border=0 cellspacing=0 cellpadding=0 bgcolor="white">'."\n".
'<tr><td><img src="white.png" height="'.$space['top'].'" width="1" alt=" "></td></tr>'."\n".
'<tr><td>'."\n".
'<img src="white.png" height="'.$height2.'" width="'.$space['left'].'" alt="#"/>';
$width=true;
for ($i=0;$i<strlen($bars);$i++){
274,30 → 275,30
$val=strtolower($bars[$i]);
if ($width){
$w=$val*$scale;
if ($w>0) $out.="<IMG src=white.png height=\"$total_y\" width=\"$w\" align=top>";
if ($w>0) $out.='<img src="white.png" height="'.$total_y.'" width="'.$w.'" align="top" alt="" />';
$width=false;
continue;
}
if (ereg("[a-z]", $val)){
if (preg_match("#[a-z]#", $val)){
//hoher strich
$val=ord($val)-ord('a')+1;
$h=$height2;
}else $h=$height;
$w=$val*$scale;
if ($w>0) $out.='<IMG src="black.png" height="'.$h.'" width="'.$w.'" align=top>';
if ($w>0) $out.='<img src="black.png" height="'.$h.'" width="'.$w.'" align="top" />';
$width=true;
}
$out.=
'<IMG src=white.png height="'.$height2.'" width=".'.$space['right'].'">'.
'</TD></TR>'."\n".
'<TR><TD><img src="white.png" height="'.$space['bottom'].'" width="1"></TD></TR>'."\n".
'</TABLE>'."\n";
'<img src="white.png" height="'.$height2.'" width=".'.$space['right'].'" />'.
'</td></tr>'."\n".
'<tr><td><img src="white.png" height="'.$space['bottom'].'" width="1"></td></tr>'."\n".
'</table>'."\n";
//for ($i=0;$i<strlen($bars);$i+=2) print $line[$i]."<B>".$line[$i+1]."</B>&nbsp;";
return $out;
}
 
 
/* barcode_encode_genbarcode(code, encoding, checksum)
/* barcode_encode_genbarcode(code, encoding)
* encodes $code with $encoding using genbarcode
*
* return:
305,19 → 306,17
* array[bars] : the bars
* array[text] : text-positioning info
*/
function barcode_encode_genbarcode($code,$encoding, $checksum=1){
function barcode_encode_genbarcode($code,$encoding){
global $genbarcode_loc;
/* delete EAN-13 checksum */
if (eregi("^ean$", $encoding) && strlen($code)==13) $code=substr($code,0,12);
if (preg_match("#^ean$#i", $encoding) && strlen($code)==13) $code=substr($code,0,12);
if (!$encoding) $encoding="ANY";
$encoding=ereg_replace("[|\\]", "_", $encoding);
$code=ereg_replace("[|\\]", "_", $code);
$cmd=$genbarcode_loc." \""
.str_replace("\"", "\\\"",$code)."\" \""
.str_replace("\"", "\\\"",strtoupper($encoding))."\"";
if($checksum=="0") { $cmd=$cmd." BARCODE_NO_CHECKSUM"; }
#print "'$cmd'<BR>\n";
$encoding=preg_replace("#[|\\\\]#", "_", $encoding);
$code=preg_replace("#[|\\\\]#", "_", $code);
$cmd=$genbarcode_loc." "
.escapeshellarg($code)." "
.escapeshellarg(strtoupper($encoding))."";
//print "'$cmd'<BR>\n";
$fp=popen($cmd, "r");
if ($fp){
$bars=fgets($fp, 1024);
336,7 → 335,7
return $ret;
}
 
/* barcode_encode(code, encoding, checksum)
/* barcode_encode(code, encoding)
* encodes $code with $encoding using genbarcode OR built-in encoder
* if you don't have genbarcode only EAN-13/ISBN is possible
*
360,30 → 359,38
* array[bars] : the bars
* array[text] : text-positioning info
*/
function barcode_encode($code,$encoding, $checksum=1){
function barcode_encode($code,$encoding){
global $genbarcode_loc;
if (
((eregi("^ean$", $encoding)
((preg_match("#^ean$#i", $encoding)
&& ( strlen($code)==12 || strlen($code)==13)))
|| (($encoding) && (eregi("^isbn$", $encoding))
|| (($encoding) && (preg_match("#^isbn$#i", $encoding))
&& (( strlen($code)==9 || strlen($code)==10) ||
(((ereg("^978", $code) && strlen($code)==12) ||
(((preg_match("#^978#", $code) && strlen($code)==12) ||
(strlen($code)==13)))))
 
|| (( !isset($encoding) || !$encoding || (eregi("^ANY$", $encoding) ))
&& (ereg("^[0-9]{12,13}$", $code)))
|| (( !isset($encoding) || !$encoding || (preg_match("#^ANY$#i", $encoding) ))
&& (preg_match("#^[0-9]{12,13}$#", $code)))
){
/* use built-in EAN-Encoder */
$bars=barcode_encode_ean($code, $encoding);
} else if (file_exists($genbarcode_loc)){
/* use genbarcode */
$bars=barcode_encode_genbarcode($code, $encoding);
} else {
if (file_exists($genbarcode_loc)){
$bars=barcode_encode_genbarcode($code, $encoding, $checksum);
} else {
print "genbarcode and/or barcode (gnu-barcode) not found, or wrong UID/GID because of safemode - modes EAN/ISBN are the only available\n";
return false;
}
print "php-barcode needs an external programm for encodings other then EAN/ISBN<BR>\n";
print "<ul>\n";
print "<li>download gnu-barcode from <a href=\"http://www.gnu.org/software/barcode/\">www.gnu.org/software/barcode/</a></li>\n";
print "<li>compile and install them</li>\n";
print "<li>download genbarcode from <a href=\"http://www.ashberg.de/php-barcode/\">www.ashberg.de/php-barcode/</a></li>\n";
print "<li>compile and install them</li>\n";
print "<li>specify path to genbarcode in php-barcode.php</li>\n";
print "</ul>\n";
print "<br />\n";
print "<a href=\"http://www.ashberg.de/php-barcode/\">Folke Ashberg's OpenSource PHP-Barcode</a><br />\n";
return false;
}
return $bars;
}
399,13 → 406,12
*/
 
 
function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png", $checksum=1){
$bars=barcode_encode($code,$encoding, $checksum);
function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png" ){
$bars=barcode_encode($code,$encoding);
if (!$bars) return;
if (!$mode) $mode="png";
if (eregi($mode,"^(text|txt|plain)$")) print barcode_outtext($bars['text'],$bars['bars']);
elseif (eregi($mode,"^(html|htm)$")) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
if (preg_match("#^(text|txt|plain)$#i", $mode)) print barcode_outtext($bars['text'],$bars['bars']);
elseif (preg_match("#^(html|htm)$#i", $mode)) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
else barcode_outimage($bars['text'],$bars['bars'],$scale, $mode);
return $bars;
}
/OpenBarcode/trunk/README
1,4 → 1,4
PHP-Barcode 0.3pl1
PHP-Barcode 0.4
 
PHP-Barcode generates
- Barcode-Images using libgd (png, jpg,gif),
11,11 → 11,11
barcode-encoder which uses GNU-Barcode
genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c),
I25, 128RAW, CBR, MSI, PLS
genbarcode is available at www.ashberg.de/bar
genbarcode is available at www.ashberg.de/php-barcode
 
(C) 2001,2002,2003,2004 by Folke Ashberg <folke@ashberg.de>
(C) 2001,2002,2003,2004,2011 by Folke Ashberg <folke@ashberg.de>
 
The newest version can be found at http://www.ashberg.de/bar
The newest version can be found at http://www.ashberg.de/php-barcode
 
 
INSTALLATION:
24,7 → 24,7
You need php>4 on your system.
You need the gd2-extension to be able to render images.
You need a TrueTypeFont if you want to see the CODE below the bars.
You need genbarcode (from www.ashberg.de/bar) in you want to use
You need genbarcode (from www.ashberg.de/php-barcode) in you want to use
another encoding than EAN-12/EAN-12/ISBN
 
Copy the following files into your html/php-directory
48,7 → 48,7
OPTIONAL - genbarcode:
If you want to generate not only EAN-12/EAN-13/ISBN-Codes you have to install
genbarcode, a small unix-commandline tool which uses GNU-Barcode.
genbarcode is available http://www.ashberg.de/bar , read genbarcodes
genbarcode is available http://www.ashberg.de/php-barcode , read genbarcodes
README for installation.
If you have installed genbarcode not to /usr/bin set the $genbarcode_loc
in php-barcode.php .
/OpenBarcode/tags/0.3pl1/black.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
/OpenBarcode/tags/0.3pl1/black.png
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: OpenBarcode/tags/0.3pl1/white.png
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: OpenBarcode/tags/0.3pl1/white.png
===================================================================
--- OpenBarcode/tags/0.3pl1/white.png (nonexistent)
+++ OpenBarcode/tags/0.3pl1/white.png (revision 56961)
/OpenBarcode/tags/0.3pl1/white.png
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: OpenBarcode/tags/0.3pl1/OCR-B_2010_BT.ttf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Index: OpenBarcode/tags/0.3pl1/OCR-B_2010_BT.ttf
===================================================================
--- OpenBarcode/tags/0.3pl1/OCR-B_2010_BT.ttf (nonexistent)
+++ OpenBarcode/tags/0.3pl1/OCR-B_2010_BT.ttf (revision 56961)
/OpenBarcode/tags/0.3pl1/OCR-B_2010_BT.ttf
Property changes:
Added: svn:mime-type
## -0,0 +1 ##
+application/octet-stream
\ No newline at end of property
Index: OpenBarcode/tags/0.3pl1/barcode.php
===================================================================
--- OpenBarcode/tags/0.3pl1/barcode.php (nonexistent)
+++ OpenBarcode/tags/0.3pl1/barcode.php (revision 56961)
@@ -0,0 +1,52 @@
+
+/*
+
+ * Image-Creator / Sample
+ * Part of PHP-Barcode 0.3pl1
+
+ * (C) 2001,2002,2003,2004 by Folke Ashberg
+
+ * The newest version can be found at http://www.ashberg.de/bar
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+require("php-barcode.php");
+
+function getvar($name){
+ global $_GET, $_POST;
+ if (isset($_GET[$name])) return $_GET[$name];
+ else if (isset($_POST[$name])) return $_POST[$name];
+ else return false;
+}
+
+if (get_magic_quotes_gpc()){
+ $code=stripslashes(getvar('code'));
+} else {
+ $code=getvar('code');
+}
+if (!$code) $code='123456789012';
+barcode_print($code,getvar('encoding'),getvar('scale'),getvar('mode'), getvar('checksum'));
+
+/*
+ * call
+ * http://........./barcode.php?code=012345678901
+ * or
+ * http://........./barcode.php?code=012345678901&encoding=EAN&scale=4&mode=png
+ *
+ */
+
+?>
Index: OpenBarcode/tags/0.3pl1/encode_bars.php
===================================================================
--- OpenBarcode/tags/0.3pl1/encode_bars.php (nonexistent)
+++ OpenBarcode/tags/0.3pl1/encode_bars.php (revision 56961)
@@ -0,0 +1,91 @@
+
+/*
+
+ * Built-In Encoders
+ * Part of PHP-Barcode 0.3pl1
+
+ * (C) 2001,2002,2003,2004 by Folke Ashberg
+
+ * The newest version can be found at http://www.ashberg.de/bar
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+function barcode_gen_ean_sum($ean){
+ $even=true; $esum=0; $osum=0;
+ for ($i=strlen($ean)-1;$i>=0;$i--){
+ if ($even) $esum+=$ean[$i]; else $osum+=$ean[$i];
+ $even=!$even;
+ }
+ return (10-((3*$esum+$osum)%10))%10;
+}
+
+/* barcode_encode_ean(code [, encoding])
+ * encodes $ean with EAN-13 using builtin functions
+ *
+ * return:
+ * array[encoding] : the encoding which has been used (EAN-13)
+ * array[bars] : the bars
+ * array[text] : text-positioning info
+ */
+function barcode_encode_ean($ean, $encoding = "EAN-13"){
+ $digits=array(3211,2221,2122,1411,1132,1231,1114,1312,1213,3112);
+ $mirror=array("000000","001011","001101","001110","010011","011001","011100","010101","010110","011010");
+ $guards=array("9a1a","1a1a1","a1a");
+
+ $ean=trim($ean);
+ if (eregi("[^0-9]",$ean)){
+ return array("text"=>"Invalid EAN-Code");
+ }
+ $encoding=strtoupper($encoding);
+ if ($encoding=="ISBN"){
+ if (!ereg("^978", $ean)) $ean="978".$ean;
+ }
+ if (ereg("^978", $ean)) $encoding="ISBN";
+ if (strlen($ean)<12 || strlen($ean)>13){
+ return array("text"=>"Invalid $encoding Code (must have 12/13 numbers)");
+ }
+
+ $ean=substr($ean,0,12);
+ $eansum=barcode_gen_ean_sum($ean);
+ $ean.=$eansum;
+ $line=$guards[0];
+ for ($i=1;$i<13;$i++){
+ $str=$digits[$ean[$i]];
+ if ($i<7 && $mirror[$ean[0]][$i-1]==1) $line.=strrev($str); else $line.=$str;
+ if ($i==6) $line.=$guards[1];
+ }
+ $line.=$guards[2];
+
+ /* create text */
+ $pos=0;
+ $text="";
+ for ($a=0;$a<13;$a++){
+ if ($a>0) $text.=" ";
+ $text.="$pos:12:{$ean[$a]}";
+ if ($a==0) $pos+=12;
+ else if ($a==6) $pos+=12;
+ else $pos+=7;
+ }
+
+ return array(
+ "encoding" => $encoding,
+ "bars" => $line,
+ "text" => $text
+ );
+}
+
+?>
Index: OpenBarcode/tags/0.3pl1/php-barcode.php
===================================================================
--- OpenBarcode/tags/0.3pl1/php-barcode.php (nonexistent)
+++ OpenBarcode/tags/0.3pl1/php-barcode.php (revision 56961)
@@ -0,0 +1,413 @@
+
+/*
+ * PHP-Barcode 0.3pl1
+
+ * PHP-Barcode generates
+ * - Barcode-Images using libgd2 (png, jpg, gif)
+ * - HTML-Images (using 1x1 pixel and html-table)
+ * - silly Text-Barcodes
+ *
+ * PHP-Barcode encodes using
+ * - a built-in EAN-13/ISBN Encoder
+ * - genbarcode (by Folke Ashberg), a command line
+ * barcode-encoder which uses GNU-Barcode
+ * genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c),
+ * I25, 128RAW, CBR, MSI, PLS
+ * genbarcode is available at www.ashberg.de/bar
+
+ * (C) 2001,2002,2003,2004 by Folke Ashberg
+
+ * The newest version can be found at http://www.ashberg.de/bar
+
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ */
+
+
+/* CONFIGURATION */
+
+/* ******************************************************************** */
+/* COLORS */
+/* ******************************************************************** */
+$bar_color=Array(0,0,0);
+$bg_color=Array(255,255,255);
+$text_color=Array(0,0,0);
+
+
+/* ******************************************************************** */
+/* FONT FILE */
+/* ******************************************************************** */
+/* location the the ttf-font */
+/* the file arialbd.ttf isn't included! */
+
+/* SAMPLE1 :
+ * use arialbd.ttf located in same directory like the script
+ * which includes/requires php-barcode.php
+ */
+
+// Set the enviroment variable for GD
+putenv('GDFONTPATH=' . realpath('.'));
+$font_loc="OCR-B_2010_BT.ttf";
+
+
+/* Automatic-Detection of Font if running Windows
+ * kick this lines if you don't need them! */
+if (isset($_ENV['windir']) && file_exists($_ENV['windir'])){
+ $font_loc=$_ENV['windir']."\Fonts\arialbd.ttf";
+}
+
+/* ******************************************************************** */
+/* GENBARCODE */
+/* ******************************************************************** */
+/* location of 'genbarcode'
+ * leave blank if you don't have them :(
+ * genbarcode is needed to render encodings other than EAN-12/EAN-13/ISBN
+ */
+//$genbarcode_loc="c:\winnt\genbarcode.exe";
+$genbarcode_loc="/var/www/php_exec/genbarcode";
+
+
+/* CONFIGURATION ENDS HERE */
+
+require("encode_bars.php"); /* build-in encoders */
+
+/*
+ * barcode_outimage(text, bars [, scale [, mode [, total_y [, space ]]]] )
+ *
+ * Outputs an image using libgd
+ *
+ * text : the text-line (:: ...)
+ * bars : where to place the bars (...)
+ * scale : scale factor ( 1 < scale < unlimited (scale 50 will produce
+ * 5400x300 pixels when
+ * using EAN-13!!!))
+ * mode : png,gif,jpg, depending on libgd ! (default='png')
+ * total_y: the total height of the image ( default: scale * 60 )
+ * space : space
+ * default:
+ * $space[top] = 2 * $scale;
+ * $space[bottom]= 2 * $scale;
+ * $space[left] = 2 * $scale;
+ * $space[right] = 2 * $scale;
+ */
+
+
+function barcode_outimage($text, $bars, $scale = 1, $mode = "png",
+ $total_y = 0, $space = ''){
+ global $bar_color, $bg_color, $text_color;
+ global $font_loc;
+ /* set defaults */
+ if ($scale<1) $scale=1;
+ if ($scale>20) $scale=20;
+ $total_y=(int)($total_y);
+ if ($total_y<1) $total_y=(int)$scale * 60;
+ if (!$space)
+ $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale);
+
+ /* count total width */
+ $xpos=0;
+ $width=true;
+ for ($i=0;$i
+ $val=strtolower($bars[$i]);
+ if ($width){
+ $xpos+=$val*$scale;
+ $width=false;
+ continue;
+ }
+ if (ereg("[a-z]", $val)){
+ /* tall bar */
+ $val=ord($val)-ord('a')+1;
+ }
+ $xpos+=$val*$scale;
+ $width=true;
+ }
+
+ /* allocate the image */
+ $total_x=( $xpos )+$space['right']+$space['right'];
+ $xpos=$space['left'];
+ if (!function_exists("imagecreate")){
+ print "gd2 extension not enabled
\n";
+ return "";
+ }
+ $im=imagecreate($total_x, $total_y);
+ /* create two images */
+ $col_bg=ImageColorAllocate($im,$bg_color[0],$bg_color[1],$bg_color[2]);
+ $col_bar=ImageColorAllocate($im,$bar_color[0],$bar_color[1],$bar_color[2]);
+ $col_text=ImageColorAllocate($im,$text_color[0],$text_color[1],$text_color[2]);
+ $height=round($total_y-($scale*10));
+ $height2=round($total_y-$space['bottom']);
+
+
+ /* paint the bars */
+ $width=true;
+ for ($i=0;$i
+ $val=strtolower($bars[$i]);
+ if ($width){
+ $xpos+=$val*$scale;
+ $width=false;
+ continue;
+ }
+ if (ereg("[a-z]", $val)){
+ /* tall bar */
+ $val=ord($val)-ord('a')+1;
+ $h=$height2;
+ } else $h=$height;
+ imagefilledrectangle($im, $xpos, $space['top'], $xpos+($val*$scale)-1, $h, $col_bar);
+ $xpos+=$val*$scale;
+ $width=true;
+ }
+ /* write out the text */
+ global $_SERVER;
+ $chars=explode(" ", $text);
+ reset($chars);
+ while (list($n, $v)=each($chars)){
+ if (trim($v)){
+ $inf=explode(":", $v);
+ $fontsize=$scale*($inf[1]/1.8);
+ $fontheight=$total_y-($fontsize/2.7)+2;
+ imagettftext($im, $fontsize, 0, $space['left']+($scale*$inf[0])+2,
+ $fontheight, $col_text, $font_loc, $inf[2]);
+ }
+ }
+
+ /* output the image */
+ $mode=strtolower($mode);
+ if ($mode=='jpg' || $mode=='jpeg'){
+ header("Content-Type: image/jpeg; name=\"barcode.jpg\"");
+ imagejpeg($im);
+ } else if ($mode=='gif'){
+ header("Content-Type: image/gif; name=\"barcode.gif\"");
+ imagegif($im);
+ } else {
+ header("Content-Type: image/png; name=\"barcode.png\"");
+ imagepng($im);
+ }
+
+}
+
+/*
+ * barcode_outtext(code, bars)
+ *
+ * Returns (!) a barcode as plain-text
+ * ATTENTION: this is very silly!
+ *
+ * text : the text-line (:: ...)
+ * bars : where to place the bars (...)
+ */
+
+function barcode_outtext($code,$bars){
+ $width=true;
+ $xpos=$heigh2=0;
+ $bar_line="";
+ for ($i=0;$i
+ $val=strtolower($bars[$i]);
+ if ($width){
+ $xpos+=$val;
+ $width=false;
+ for ($a=0;$a<$val;$a++) $bar_line.="-";
+ continue;
+ }
+ if (ereg("[a-z]", $val)){
+ $val=ord($val)-ord('a')+1;
+ $h=$heigh2;
+ for ($a=0;$a<$val;$a++) $bar_line.="I";
+ } else for ($a=0;$a<$val;$a++) $bar_line.="#";
+ $xpos+=$val;
+ $width=true;
+ }
+ return $bar_line;
+}
+
+/*
+ * barcode_outhtml(text, bars [, scale [, total_y [, space ]]] )
+ *
+ * returns(!) HTML-Code for barcode-image using html-code (using a table and with black.png and white.png)
+ *
+ * text : the text-line (:: ...)
+ * bars : where to place the bars (...)
+ * scale : scale factor ( 1 < scale < unlimited (scale 50 will produce
+ * 5400x300 pixels when
+ * using EAN-13!!!))
+ * total_y: the total height of the image ( default: scale * 60 )
+ * space : space
+ * default:
+ * $space[top] = 2 * $scale;
+ * $space[bottom]= 2 * $scale;
+ * $space[left] = 2 * $scale;
+ * $space[right] = 2 * $scale;
+ */
+
+
+
+function barcode_outhtml($code, $bars, $scale = 1, $total_y = 0, $space = ''){
+ /* set defaults */
+ $total_y=(int)($total_y);
+ if ($scale<1) $scale=2;
+ if ($total_y<1) $total_y=(int)$scale * 60;
+ if (!$space)
+ $space=array('top'=>2*$scale,'bottom'=>2*$scale,'left'=>2*$scale,'right'=>2*$scale);
+
+
+ /* generate html-code */
+ $height=round($total_y-($scale*10));
+ $height2=round($total_y)-$space['bottom'];
+ $out=
+ ''."\n".'."\n".'."\n".'."\n".
+ '
+ '
'."\n".
+ '';
+
+ $width=true;
+ for ($i=0;$i
+ $val=strtolower($bars[$i]);
+ if ($width){
+ $w=$val*$scale;
+ if ($w>0) $out.="";
+ $width=false;
+ continue;
+ }
+ if (ereg("[a-z]", $val)){
+ //hoher strich
+ $val=ord($val)-ord('a')+1;
+ $h=$height2;
+ }else $h=$height;
+ $w=$val*$scale;
+ if ($w>0) $out.='';
+ $width=true;
+ }
+ $out.=
+ ''.
+ '
+ '
+ '
'."\n";
+ //for ($i=0;$i".$line[$i+1]." ";
+ return $out;
+}
+
+
+/* barcode_encode_genbarcode(code, encoding, checksum)
+ * encodes $code with $encoding using genbarcode
+ *
+ * return:
+ * array[encoding] : the encoding which has been used
+ * array[bars] : the bars
+ * array[text] : text-positioning info
+ */
+function barcode_encode_genbarcode($code,$encoding, $checksum=1){
+ global $genbarcode_loc;
+ /* delete EAN-13 checksum */
+ if (eregi("^ean$", $encoding) && strlen($code)==13) $code=substr($code,0,12);
+ if (!$encoding) $encoding="ANY";
+ $encoding=ereg_replace("[|\\]", "_", $encoding);
+ $code=ereg_replace("[|\\]", "_", $code);
+ $cmd=$genbarcode_loc." \""
+ .str_replace("\"", "\\\"",$code)."\" \""
+ .str_replace("\"", "\\\"",strtoupper($encoding))."\"";
+ if($checksum=="0") { $cmd=$cmd." BARCODE_NO_CHECKSUM"; }
+ #print "'$cmd'
\n";
+
+ $fp=popen($cmd, "r");
+ if ($fp){
+ $bars=fgets($fp, 1024);
+ $text=fgets($fp, 1024);
+ $encoding=fgets($fp, 1024);
+ pclose($fp);
+ } else return false;
+ $ret=array(
+ "encoding" => trim($encoding),
+ "bars" => trim($bars),
+ "text" => trim($text)
+ );
+ if (!$ret['encoding']) return false;
+ if (!$ret['bars']) return false;
+ if (!$ret['text']) return false;
+ return $ret;
+}
+
+/* barcode_encode(code, encoding, checksum)
+ * encodes $code with $encoding using genbarcode OR built-in encoder
+ * if you don't have genbarcode only EAN-13/ISBN is possible
+ *
+ * You can use the following encodings (when you have genbarcode):
+ * ANY choose best-fit (default)
+ * EAN 8 or 13 EAN-Code
+ * UPC 12-digit EAN
+ * ISBN isbn numbers (still EAN-13)
+ * 39 code 39
+ * 128 code 128 (a,b,c: autoselection)
+ * 128C code 128 (compact form for digits)
+ * 128B code 128, full printable ascii
+ * I25 interleaved 2 of 5 (only digits)
+ * 128RAW Raw code 128 (by Leonid A. Broukhis)
+ * CBR Codabar (by Leonid A. Broukhis)
+ * MSI MSI (by Leonid A. Broukhis)
+ * PLS Plessey (by Leonid A. Broukhis)
+ *
+ * return:
+ * array[encoding] : the encoding which has been used
+ * array[bars] : the bars
+ * array[text] : text-positioning info
+ */
+function barcode_encode($code,$encoding, $checksum=1){
+ global $genbarcode_loc;
+ if (
+ ((eregi("^ean$", $encoding)
+ && ( strlen($code)==12 || strlen($code)==13)))
+
+ || (($encoding) && (eregi("^isbn$", $encoding))
+ && (( strlen($code)==9 || strlen($code)==10) ||
+ (((ereg("^978", $code) && strlen($code)==12) ||
+ (strlen($code)==13)))))
+
+ || (( !isset($encoding) || !$encoding || (eregi("^ANY$", $encoding) ))
+ && (ereg("^[0-9]{12,13}$", $code)))
+
+ ){
+ /* use built-in EAN-Encoder */
+ $bars=barcode_encode_ean($code, $encoding);
+ } else {
+ if (file_exists($genbarcode_loc)){
+ $bars=barcode_encode_genbarcode($code, $encoding, $checksum);
+ } else {
+ print "genbarcode and/or barcode (gnu-barcode) not found, or wrong UID/GID because of safemode - modes EAN/ISBN are the only available\n";
+ return false;
+ }
+ }
+ return $bars;
+}
+
+/* barcode_print(code [, encoding [, scale [, mode ]]] );
+ *
+ * encodes and prints a barcode
+ *
+ * return:
+ * array[encoding] : the encoding which has been used
+ * array[bars] : the bars
+ * array[text] : text-positioning info
+ */
+
+
+function barcode_print($code, $encoding="ANY", $scale = 2 ,$mode = "png", $checksum=1){
+
+ $bars=barcode_encode($code,$encoding, $checksum);
+ if (!$bars) return;
+ if (!$mode) $mode="png";
+ if (eregi($mode,"^(text|txt|plain)$")) print barcode_outtext($bars['text'],$bars['bars']);
+ elseif (eregi($mode,"^(html|htm)$")) print barcode_outhtml($bars['text'],$bars['bars'], $scale,0, 0);
+ else barcode_outimage($bars['text'],$bars['bars'],$scale, $mode);
+ return $bars;
+}
+
+?>
Index: OpenBarcode/tags/0.3pl1/README
===================================================================
--- OpenBarcode/tags/0.3pl1/README (nonexistent)
+++ OpenBarcode/tags/0.3pl1/README (revision 56961)
@@ -0,0 +1,162 @@
+PHP-Barcode 0.3pl1
+
+PHP-Barcode generates
+ - Barcode-Images using libgd (png, jpg,gif),
+ - HTML-Images (using 1x1 pixel and html-table)
+ - silly Text-Barcodes
+
+PHP-Barcode encodes using
+ - a built-in EAN-13/ISBN Encoder
+ - genbarcode (by Folke Ashberg), a command line
+ barcode-encoder which uses GNU-Barcode
+ genbarcode can encode EAN-13, EAN-8, UPC, ISBN, 39, 128(a,b,c),
+ I25, 128RAW, CBR, MSI, PLS
+ genbarcode is available at www.ashberg.de/bar
+
+(C) 2001,2002,2003,2004 by Folke Ashberg
+
+The newest version can be found at http://www.ashberg.de/bar
+
+
+INSTALLATION:
+
+ WHAT YOU NEED TO BE ABLE TO USE PHP-BARCODE
+ You need php>4 on your system.
+ You need the gd2-extension to be able to render images.
+ You need a TrueTypeFont if you want to see the CODE below the bars.
+ You need genbarcode (from www.ashberg.de/bar) in you want to use
+ another encoding than EAN-12/EAN-12/ISBN
+
+ Copy the following files into your html/php-directory
+ - php-barcode.php - main library
+ - encode_bars.php - built-in encoders
+ optional:
+ - barcode.php - Sample-File
+ - white.png - for HTML-Images
+ - black.png - for HTML-Images
+
+ FONT-Installation
+ UNIX:
+ A TrueTypeFont isn't included in this distribution!
+ Copy one into the html/php-directory and change in php-barcode.php
+ $font_loc (change the arialbd.tff to your font name).
+ arialbd.ttf from Windows looks great.
+
+ WINDOWS:
+ If you use Windows the font should be located automatically.
+
+ OPTIONAL - genbarcode:
+ If you want to generate not only EAN-12/EAN-13/ISBN-Codes you have to install
+ genbarcode, a small unix-commandline tool which uses GNU-Barcode.
+ genbarcode is available http://www.ashberg.de/bar , read genbarcodes
+ README for installation.
+ If you have installed genbarcode not to /usr/bin set the $genbarcode_loc
+ in php-barcode.php .
+
+ TESTING
+ If everything works fine you should see an image if you call
+ http://localhost/path/barcode.php
+
+ Or call http://localhost/path/barcode.php?code=&encoding=&mode=&size=<1,2,3,...>
+
+
+
+If you need more then the sample barcode.php can do, you need to build your own.
+
+FUNCTIONS - API-Reference
+
+--------------------------------------------------------------------------
+function barcode_encode(code, encoding)
+ encodes $code with $encoding using genbarcode OR built-in encoder
+ if you don't have genbarcode only EAN-13/ISBN is possible
+
+You can use the following encodings (when you have genbarcode):
+ ANY choose best-fit (default)
+ EAN 8 or 13 EAN-Code
+ UPC 12-digit EAN
+ ISBN isbn numbers (still EAN-13)
+ 39 code 39
+ 128 code 128 (a,b,c: autoselection)
+ 128C code 128 (compact form for digits)
+ 128B code 128, full printable ascii
+ I25 interleaved 2 of 5 (only digits)
+ 128RAW Raw code 128 (by Leonid A. Broukhis)
+ CBR Codabar (by Leonid A. Broukhis)
+ MSI MSI (by Leonid A. Broukhis)
+ PLS Plessey (by Leonid A. Broukhis)
+
+ return:
+ array[encoding] : the encoding which has been used
+ array[bars] : the bars
+ array[text] : text-positioning info
+
+--------------------------------------------------------------------------
+function barcode_outimage(text, bars [, scale [, mode [, total_y [, space ]]]] )
+
+ Outputs an image using libgd
+
+ text : the text-line (:: ...)
+ bars : where to place the bars (...)
+ scale : scale factor ( 1 < scale < unlimited (scale 50 will produce
+ 5400x300 pixels when
+ using EAN-13!!!))
+ mode : png,gif,jpg, depending on libgd ! (default='png')
+ total_y: the total height of the image ( default: scale * 60 )
+ space : space
+ default:
+ $space[top] = 2 * $scale;
+ $space[bottom]= 2 * $scale;
+ $space[left] = 2 * $scale;
+ $space[right] = 2 * $scale;
+
+--------------------------------------------------------------------------
+function barcode_outhtml(text, bars [, scale [, total_y [, space ]]] )
+
+ returns(!) HTML-Code for barcode-image using html-code (using a table and with black.png and white.png)
+
+ text : the text-line (:: ...)
+ bars : where to place the bars (...)
+ scale : scale factor ( 1 < scale < unlimited (scale 50 will produce
+ 5400x300 pixels when
+ using EAN-13!!!))
+ total_y: the total height of the image ( default: scale * 60 )
+ space : space
+ default:
+ $space[top] = 2 * $scale;
+ $space[bottom]= 2 * $scale;
+ $space[left] = 2 * $scale;
+ $space[right] = 2 * $scale;
+
+--------------------------------------------------------------------------
+function barcode_outtext(code, bars)
+
+ Returns (!) a barcode as plain-text
+ ATTENTION: this is very silly!
+
+ text : the text-line (:: ...)
+ bars : where to place the bars (...)
+
+--------------------------------------------------------------------------
+For more function see php-barcode.php
+Also see barcode.php or just use them :)
+
+
+
+
+
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
Index: OpenFormat/trunk/xml/response_m21iso2709/bog_hans_engell.xml
===================================================================
--- OpenFormat/trunk/xml/response_m21iso2709/bog_hans_engell.xml (nonexistent)
+++ OpenFormat/trunk/xml/response_m21iso2709/bog_hans_engell.xml (revision 56961)
@@ -0,0 +1,2 @@
+
+MDA0MTVuYW0gYTIyMDAxNDUwYyA0NTAgMDAxMDAyMjAwMDAwMDA4MDA0MTAwMDIyMDIwMDAzMzAwMDYzMDI5MDAzMzAwMDk2MDQwMDAyMjAwMTI5MTAwMDAxNzAwMTUxMjQ1MDAzNDAwMTY4MjUwMDAxNDAwMjAyMjYwMDAzMTAwMjE2MzAwMDAyMjAwMjQ3Hjg3MDk3MC1iYXNpczoyMTkyMTE3Mx45NzExMThyMTk5NzE5OTdkayB8fHx8fHx8fHx8IDAwfHx1YWRhbnx8HiAgH2E4NzExMTUwNjUzIChoZi4pH2Nrci4gMjQ4LDAwHjEgH2FES0RMQR9iODcwOTcwLWJhc2lzOjIxOTIxMTczHiAgH2FES0RMQR9iZGFuH2NES0RMQR4xIB9hRW5nZWxsLCBIYW5zHjEwH2FQ5SBTbG90c2hvbG1lbiAvH2NIYW5zIEVuZ2VsHiAgH2ExLiB1ZGdhdmUeICAfYVtLYmguXSA6H2JBc2NoZWhvdWcsH2MxOTk3HiAgH2E0NTUgc2lkZXIgOh9iaWxsLh4d