public static function uniqueBarcode($mac = NULL, $min = 11111111111, $max = 99999999999) { if ($mac == NULL) { $mac = Util::getCONNECTED_MAC(NULL); } if ($mac == NULL) { return Proximus::barcode(); } $identifier = "" . mt_rand($min, $max); try { $res = Proximus::onetimeUniqueUser("./uniqueBarcode.txt", $mac, $identifier); if ($res != NULL || isset($res[2])) { $identifier = trim($res[2]); } } catch (Exception $e) { $identifier = trim($identifier); } Logger::barcode('UPC-A', $identifier, $mac); $font = new BCGFontFile('/home/proximus/bin/php/barcode/font/Arial.ttf', 18); $color_black = new BCGColor(0, 0, 0); $color_white = new BCGColor(255, 255, 255); $drawException = null; try { $code = new BCGupca(); $code->setScale(2); // Resolution $code->setThickness(30); // Thickness $code->setForegroundColor($color_black); // Color of bars $code->setBackgroundColor($color_white); // Color of spaces $code->setFont($font); // Font (or 0) $code->parse($identifier); // Text } catch (Exception $exception) { $drawException = $exception; } $drawing = new BCGDrawing('', $color_white); if ($drawException) { $drawing->drawException($drawException); } else { $drawing->setBarcode($code); $drawing->draw(); } header('Content-Type: image/png'); $drawing->finish(BCGDrawing::IMG_FORMAT_PNG); }