Location: PHPKode > projects > OpenBizMap > openbizmap/odb_barcode.php
<?php

$if_modified_since = preg_replace('/;.*$/', '', $_SERVER["HTTP_IF_MODIFIED_SINCE"]);
if ($if_modified_since)
{
  header("HTTP/1.0 304 Not Modified");
  exit;
}


function CheckBarcodeC($sIn='')
{
  $CheckBarcodeC = 1;
  if($sIn)
    if(strlen($sIn)% 2 != 0)
      $CheckBarcodeC = 0;
    else
      for($ii=0;$ii<strlen($sIn);$ii++)
        if(ord($sIn[$ii]) < 48 or ord($sIn[$ii]) > 57)
          $CheckBarcodeC = 0;
   return $CheckBarcodeC;
}

$f_p = './odb_barcode.txt';

$fp=fopen($f_p,'rb');
while($d=fgetcsv($fp,1000,',')){
  $barcodeAr[$d[0]]=$d[1];
}
fclose($fp);

$val=$_GET['val'];
$sIn=substr("0000000000000000",0,16-strlen($val)) .$val;
  $EC = "";

  if(!CheckBarcodeC($sIn))
  return ('');

  $EC = chr(205);
  $sumcheck = 105;

for($ii=0;$ii<strlen($sIn)/2;$ii++){
      $subs = substr($sIn, $ii * 2, 2);
      $EC = $EC .chr($subs + 100);
      $sumcheck = $sumcheck + ($ii+1) * $subs;
  }
  $EC = $EC .chr($sumcheck % 103 + 100) .chr(206);

$l='';
  for($ii=0;$ii<strlen($EC);$ii++)
    $l.=$barcodeAr[ord($EC[$ii])];

  $im = imagecreate(strlen($l)/2,20);
$white = ImageColorAllocate($im, 255,255,255);
$black = ImageColorAllocate($im, 100,100,100);

//echo strlen($l);
  for($ii=0;$ii<strlen($l);$ii++)
  imageline($im,$ii/2,0,$ii/2,20,$l[$ii]);
//return $EC;

Header("Content-type: image/png");
imagepng($im);
?>
Return current item: OpenBizMap