4 * Copyright (C) 2011 Thomas Mudrunka
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Affero General Public License as
8 * published by the Free Software Foundation, either version 3 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Affero General Public License for more details.
16 * You should have received a copy of the GNU Affero General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * Trida implementuje funkce pro praci s carovymi kody
24 * @author Tomas Mudrunka
27 static function test() {
28 system('barcode -b test | convert - /dev/null', $ret);
32 trigger_error('Barcode-related features are disabled. Please install GNU Barcode and ImageMagick.');
37 static function generate_barcode($string='EXAMPLE', $convert='png', $enctype='code128b') {
38 $string = escapeshellarg($string);
39 $enctype = escapeshellarg($enctype);
40 $convert = $convert ?
" | convert - -crop 0x60+0+30\\! -background white -flatten $convert:-" : '';
41 return shell_exec("barcode -e $enctype -E -b $string$convert");
44 static function cached_barcode($string='EXAMPLE', $convert='png', $enctype='code128b') {
45 $ext = $convert ?
$convert : 'ps';
46 $filename=DIR_BARCODES
."/$enctype-".urlencode($string).".$ext";
47 if(is_file($filename)) return file_get_contents($filename);
48 $barcode = self
::generate_barcode($string,$convert,$enctype);
49 file_put_contents($filename,$barcode);
53 static function download_barcode($string='EXAMPLE', $convert='png', $enctype='code128b') {
55 header('Content-Type: image/png');
56 header('Cache-Control: max-age=604800, public'); //1week caching
58 die(self
::cached_barcode($string,$convert,$enctype));
This page took 0.458585 seconds and 4 git commands to generate.