case 'w': ImageLine($image, $position, $dispcod, $position, 18 + $dispcod, $black); ImageLine($image, $position + 1, $dispcod, $position + 1, 18 + $dispcod, $black); break; } $position += 4; } } header('Content-type: image/png'); //send image-header ImagePNG($image); ImageDestroy($image); } elseif (preg_match("/^(\\d\\d)+\$/", $_GET['barcode']) && ($coding == 'DWIM' || $coding == '128C')) { $barcode = 'ST' . $_GET['barcode'] . 'OP'; //include START and STOP-bars CreateImage(strlen($barcode) * 11 / 2 + 2, 42 + $dispcod); //11 pixels per 2 digits, except for the last one, which has 13 (11 + 2) if ($dispcod) { ImageString($image, 3, strlen($barcode) * 11 / 4 - 11, 0, '128C', $black); } $pos = 0; //draw bars (including START and STOP) for ($digit = 0; $digit < strlen($barcode); $digit += 2) { $bars = $bar128c[substr($barcode, $digit, 2)]; //something like '113141' (BWBWBW) for ($bar = 0; $bar < strlen($bars); $bar++) { for ($counter = 0; $counter < substr($bars, $bar, 1); $counter++) { ImageLine($image, $pos, $dispcod, $pos++, 42 + $dispcod, $bar % 2 ? $white : $black); } } }
<?php require "../settings.php"; session_save_path("../tmp"); session_name(SESSION_NAME_SHOP); session_start(); CreateImage(); function CreateImage() { // cria o c�digo $md5Hash = md5(rand(0, 999)); $securityCode = substr($md5Hash, 0, 6); // define a sess�o $_SESSION["SecurityCode"] = $securityCode; // dimens�es $width = 134; $height = 40; // cria imagem $image = @imagecreate($width, $height); // cores $white = imagecolorallocate($image, 0xff, 0xff, 0xff); $black = imagecolorallocate($image, 0x0, 0x0, 0x0); $grey = imagecolorallocate($image, 0x33, 0x33, 0x33); $blue = imagecolorallocate($image, 0x0, 0x0, 0xff); $red = imagecolorallocate($image, 0xff, 0x0, 0x0); $yellow = imagecolorallocate($image, 0xff, 0xff, 0x0); $arrayColors = array($grey, $black, $red, $blue); imagefill($image, 0, 0, $white); // escreve na imagem $arrayFonts = array("fonts/calibri.ttf", "fonts/berlin.ttf"); for ($i = 0, $y = strlen($securityCode); $i < $y; $i++) {