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);
 }
 /**
  * Draws the barcode
  *
  * @param resource $im
  */
 function draw(&$im)
 {
     $error_stop = false;
     // Checking if all chars are allowed
     $c = strlen($this->text);
     for ($i = 0; $i < $c; $i++) {
         if (array_search($this->text[$i], $this->keys) === false) {
             $this->drawError($im, 'Char \'' . $this->text[$i] . '\' not allowed.');
             $error_stop = true;
         }
     }
     if ($error_stop === false) {
         // Must contain 11 chars
         if ($c !== 11) {
             $this->drawError($im, 'Must contain 11 chars, the 12th digit is automatically added.');
             $error_stop = true;
         }
         if ($error_stop === false) {
             // The following code is exactly the same as EAN13. We just add a 0 in front of the code !
             $this->text = '0' . $this->text;
             // We will remove it at the end... don't worry
             // Checksum
             $this->calculateChecksum();
             $temp_text = $this->text . $this->keys[$this->checksumValue];
             // Starting Code
             $this->drawChar($im, '000', true);
             // Draw Second Code
             $this->drawChar($im, $this->findCode($temp_text[1]), false);
             // Draw Manufacturer Code
             for ($i = 0; $i < 5; $i++) {
                 $this->drawChar($im, BCGupca::inverse($this->findCode($temp_text[$i + 2]), $this->codeParity[$temp_text[0]][$i]), false);
             }
             // Draw Center Guard Bar
             $this->drawChar($im, '00000', false);
             // Draw Product Code
             for ($i = 7; $i < 13; $i++) {
                 $this->drawChar($im, $this->findCode($temp_text[$i]), true);
             }
             // Draw Right Guard Bar
             $this->drawChar($im, '000', true);
             $this->drawText($im);
             // We remove the 0 in front, as we said :)
             $this->text = substr($this->text, 1);
         }
     }
 }