Your IP : 216.73.217.87


Current Path : /hdd/hdd11/www/vlevski/enter/_old_files/
Upload File :
Current File : /hdd/hdd11/www/vlevski/enter/_old_files/t2e.php

<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
?><!DOCTYPE html>
<html lang="bg">
	<head>
		<style>
			@font-face
			{
				font-family:	mf;
				src:			url("/font/calibri.woff");
			}
			@font-face
			{
				font-family:	im;
				src:			url("/font/impact.ttf");
			}
			body, div, span, font
			{
				font-family:	mf;
			}
		</style>
	</head>
	<body>
	<?php
		$i=1;
		if (isset($_GET["p"]))
			{
				$p=$_GET["p"];
				$p--;
			}
		else
			{
				$p=0;
			}
		if ($p<0)
			{
				$p=0;
			}
		$n=$p;
		$p=$p*10;
		include("./conn.php");
		namespace vlevski\Barcode;
		abstract class BarcodeBase
		{
			protected $img = null;
			protected $x = 0;
			protected $y = 0;
			protected $humanText = true;
			protected $jpgQuality = 100;
			abstract public function setData($data);
			abstract public function draw();
			public function setDimensions($x, $y)
			{
				$this->x = (int) $x;
				$this->y = (int) $y;

				return $this;
			}
			public function setQuality($q)
			{
				$this->jpgQuality = (int) $q;
				return $this;
			}
			public function enableHumanText($enable = true)
			{
				$this->humanText = (boolean) $enable;
				return $this;
			}
			public function output($type = 'png')
			{
				switch($type)
				{
					case 'jpg':
					case 'jpeg':
						imagejpeg($this->img, NULL, $this->jpgQuality);
					break;
					case 'gif':
						imagegif($this->img);
					break;
					case 'png':
					default:
						imagepng($this->img);
					break;
				}
			}
			public function save($filename)
			{
				$type = strtolower(substr(strrchr($filename, '.'), 1));
				switch($type)
				{
					case 'jpg':
					case 'jpeg':
						imagejpeg($this->img, $filename, $this->jpgQuality);
					break;
					case 'gif':
						imagegif($this->img, $filename);
					break;
					case 'png':
						imagepng($this->img, $filename);
					break;
					default:
						throw new \RuntimeException("Could not determine file type.");
					break;
				}
			}
			public function base64()
			{
				ob_start();
				$this->output();
				return base64_encode(ob_get_clean());
			}
		}
		class Code128 extends BarcodeBase
		{
			private $data = '';
			private $type = self::TYPE_AUTO;
			private static $barMap = array(
				11011001100, 11001101100, 11001100110, 10010011000, 10010001100, // 4 (end)
				10001001100, 10011001000, 10011000100, 10001100100, 11001001000, // 9
				11001000100, 11000100100, 10110011100, 10011011100, 10011001110, // 14
				10111001100, 10011101100, 10011100110, 11001110010, 11001011100, // 19
				11001001110, 11011100100, 11001110100, 11101101110, 11101001100, // 24
				11100101100, 11100100110, 11101100100, 11100110100, 11100110010, // 29
				11011011000, 11011000110, 11000110110, 10100011000,	10001011000, // 34
				10001000110, 10110001000, 10001101000, 10001100010,	11010001000, // 39
				11000101000, 11000100010, 10110111000, 10110001110, 10001101110, // 44
				10111011000, 10111000110, 10001110110, 11101110110, 11010001110, // 49
				11000101110, 11011101000, 11011100010, 11011101110, 11101011000, // 54
				11101000110, 11100010110, 11101101000, 11101100010, 11100011010, // 59
				11101111010, 11001000010, 11110001010, 10100110000, 10100001100, // 64
				10010110000, 10010000110, 10000101100, 10000100110, 10110010000, // 69
				10110000100, 10011010000, 10011000010, 10000110100, 10000110010, // 74
				11000010010, 11001010000, 11110111010, 11000010100, 10001111010, // 79
				10100111100, 10010111100, 10010011110, 10111100100, 10011110100, // 84
				10011110010, 11110100100, 11110010100, 11110010010, 11011011110, // 89
				11011110110, 11110110110, 10101111000, 10100011110, 10001011110, // 94
				10111101000, 10111100010, 11110101000, 11110100010, 10111011110, // 99
				10111101110, 11101011110, 11110101110, 11010000100, 11010010000, // 104
				11010011100, 1100011101011 // 106 (last char, also one bit longer)
			);
			private static $mapA = array(
				' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', // 9 (end)
				'*', '+', ',', '-', '.', '/', '0', '1', '2', '3', // 19
				'4', '5', '6', '7', '8', '9', ':', ';', '<', '=', // 29
				'>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', // 39
				'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', // 49
				'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', // 59
				'\\', ']', '^', '_', // 63 (We're going into the weird bytes next)

				"\x00", "\x01", "\x02", "\x03", "\x04", "\x05", // 69
				"\x06", "\x07", "\x08", "\x09", "\x0A", "\x0B", // 75
				"\x0C", "\x0D", "\x0E", "\x0F", "\x10", "\x11", // 81
				"\x12", "\x13", "\x14", "\x15", "\x16", "\x17", // 87
				"\x18", "\x19", "\x1A", "\x1B", "\x1C", "\x1D", // 93
				"\x1E", "\x1F", // 95
				
				'FNC_3', 'FNC_2', 'SHIFT_B', 'CODE_C', 'CODE_B', // 100
				'FNC_4', 'FNC_1', 'START_A', 'START_B', 'START_C', // 105
				'STOP',	// 106
			);
			private static $mapB = array(
				' ', '!', '"', '#', '$', '%', '&', "'", '(', ')', // 9 (end)
				'*', '+', ',', '-', '.', '/', '0', '1', '2', '3', // 19
				'4', '5', '6', '7', '8', '9', ':', ';', '<', '=', // 29
				'>', '?', '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', // 39
				'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', // 49
				'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', // 59
				'\\', ']', '^', '_', '`', 'a', 'b', 'c', 'd', 'e', // 69
				'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', // 79
				'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', // 89
				'z', '{', '|', '}', '~', "\x7F", // 95

				'FNC_3', 'FNC_2', 'SHIFT_A', 'CODE_C', 'FNC_4', // 100
				'CODE_A', 'FNC_1', 'START_A', 'START_B', 'START_C', // 105
				'STOP',	// 106
			);
			private static $mapC = array(
				100 => 
				'CODE_B', 'CODE_A', 'FNC_1', 'START_A', 'START_B', 
				'START_C', 'STOP', // 106
			);
			const TYPE_AUTO	= 0; // Automatically detect the best code
			const TYPE_A	= 1; // ASCII 00-95 (0-9, A-Z, Control codes, and some special chars)
			const TYPE_B	= 2; // ASCII 32-127 (0-9, A-Z, a-z, special chars)
			const TYPE_C	= 3; // Numbers 00-99 (two digits per code)
			public function setData($data)
			{
				$this->data = $data;
			}
			public function setSubType($type)
			{
				$this->type = ($type < 1 || $type > 3) ? self::TYPE_AUTO : (int) $type;
			}
			private function getKey($char)
			{
				switch ($this->type)
				{
					case self::TYPE_A:
						return array_search($char, self::$mapA);
					break;
					case self::TYPE_B:
						return array_search($char, self::$mapB);			
					break;
					case self::TYPE_C:
						$charInt = (int) $char;
						if (strlen($char) == 2 && $charInt <= 99 && $charInt >= 0)
						{
							return $charInt;
						}
						return array_search($char, self::$mapC);
					break;
					default:
						$this->resolveSubtype();
						return $this->getKey($char); // recursion!
					break;
				}
			}
			private function getBar($char)
			{
				$key = $this->getKey($char);
				return self::$barMap[($key !== false) ? $key : 0];
			}
			private function resolveSubtype()
			{
				if ($this->type == self::TYPE_AUTO)
				{
					if (is_numeric($this->data))
					{
						$this->type = self::TYPE_C;
					}
					else if(strtoupper($this->data) == $this->data)
					{
						$this->type = self::TYPE_A;
					}
					else
					{
						$this->type = self::TYPE_B;
					}
				}
			}
			private function getStartChar()
			{
				$this->resolveSubtype();
				switch($this->type)
				{
					case self::TYPE_A: return 'START_A'; break;
					case self::TYPE_B: return 'START_B'; break;
					case self::TYPE_C: return 'START_C'; break;
				}
			}
			public function draw()
			{
				$this->resolveSubtype();
				$charAry = str_split($this->data);
				$numBarsRequired = ($this->type != self::TYPE_C) ? (sizeof($charAry) * 11) + 35 : ((sizeof($charAry)/2) * 11) + 35;
				$pxPerBar = (int) ($this->x / $numBarsRequired);
				$currentX = ($this->x - ($numBarsRequired  * $pxPerBar)) / 2;
				if ($pxPerBar < 1)
				{
					throw new LogicException("Not enough space on this barcode for this message, increase the width of the barcode");
				}
				if ($this->type == self::TYPE_C)
				{
					if (sizeof($charAry) % 2)
					{
						array_unshift($charAry, '0');
					}

					$pairs = '';
					$newAry = array();
					foreach($charAry as $k => $char)
					{
						if (($k % 2) == 0 && $k != 0)
						{
							$newAry[] = $pairs;
							$pairs = '';
						}
						$pairs .= $char;
					}
					$newAry[] = $pairs;
					$charAry = $newAry;
				}
				array_unshift($charAry, $this->getStartChar());
				$checkSumCollector = $this->getKey($this->getStartChar());
				$this->img = @imagecreate($this->x, $this->y);
				$white = imagecolorallocate($this->img, 255, 255, 255);
				$black = imagecolorallocate($this->img, 0, 0, 0);
				foreach($charAry as $k => $char)
				{
					$code = $this->getBar($char);
					$checkSumCollector += $this->getKey($char) * $k; // $k will be 0 for our first
					foreach(str_split((string) $code) as $bit)
					{
						imagefilledrectangle($this->img, $currentX, 0, ($currentX + $pxPerBar), ($this->y - 1), (($bit == '1') ? $black : $white));
						$currentX += $pxPerBar;
					}
				}
				$ending[] = self::$barMap[$checkSumCollector % 103];
				$ending[] = self::$barMap[106]; // STOP.
				foreach($ending as $code)
				{
					foreach(str_split((string) $code) as $bit)
					{
						imagefilledrectangle($this->img, $currentX, 0, ($currentX + $pxPerBar), ($this->y - 1), (($bit == '1') ? $black : $white));
						$currentX += $pxPerBar;
					}
				}
			}
		}
		$cards=mysqli_query($db, "SELECT * FROM `stuff` WHERE `a`='1' ORDER BY `i` ASC LIMIT ".$p.", 10");
		while ($singlecard=mysqli_fetch_row($cards))
				{
					print("<div style=\"position: relative; width: 86mm; height: 50mm; border: 1px solid black; margin-right: 1.5mm; margin-bottom: 2mm; float: left; background-color: transparent; z-index: 0;\">");
					print("<img src=\"./gb.jpg\" style=\"position: absolute; top: 0mm; left: 0mm; width: 86mm; height: 50mm; z-index: 1;\" alt=\"\" />");
					print("	<div style=\"position: absolute; top: 0mm; right: 1mm; font-size: 4mm; font-weight: bold; font-style: italic; text-align: right; z-index: 2;\">служебна карта</div>");
					print("	<img src=\"./logo.png\" style=\"position: absolute; top: 1mm; left: 1mm; width: 24mm; float: left; z-index: 2;\">");
					print("	<img src=\"./gdpr.png\" style=\"position: absolute; top: 25mm; left: 1mm; width: 20mm; float: left; z-index: 2;\">");
					print("		<div>");
					print("		<div style=\"position: absolute; top: 4.5mm; right: 1mm; text-align: right; font-weight: bold; font-family: im; font-size: 7.5mm; z-index: 2;\">СУ „Васил Левски“</div>");
					print("		<div style=\"position: absolute; top: 17mm; left: 17mm; width: 45mm; height: 12mm; background-color: transparent; text-align: center; font-weight: bold; font-family: im; font-size: 10mm; color: #FFFFFF; -webkit-transform: rotate(-18deg); -moz-transform: rotate(-18deg); -ms-transform: rotate(-18deg); -o-transform: rotate(-18deg); opacity: 0.6; text-shadow: 0.5mm 0.5mm #999999; z-index: 2;\">ПРОПУСК</div>");
					print("		<div style=\"position: absolute; top: 25mm; left: 19.5mm; text-align: right; width: 65mm; font-size: 4.5mm; line-height: 4.5mm; font-weight: bold; z-index: 3;\">");
					print("			".$singlecard[2]."<br />".$singlecard[4]."");
					print("		</div>");
					print("		<div style=\"position: absolute; top: 35mm; left: 38mm; width: 46mm; height: 13mm; border: 0.5mm solid #000000; background-color: #ffffff; z-index: 2;\">");
					print("		</div>");
					$barcode=array();
					$bcode["c128"]	= array('name' => 'Code128', 'obj' => new vlevski\Barcode\Code128());
					$bcode['c128']['obj']->setData("".$singlecard[1]."");
					$bcode['c128']['obj']->setDimensions(800, 120);
					$bcode['c128']['obj']->draw();
					$b64 = $bcode['c128']['obj']->base64();
					print("		<img src=\"data:image/png;base64,".$b64."\" style=\"position: absolute; top: 36mm; left: 39mm; width: 45mm; height: 12mm; z-index: 3;\" />");
					print("		<div style=\"position: absolute; top: 12mm; left: 57.5mm; font-size: 4mm; font-weight: bold; font-style: italic; z-index: 2;\">enter.vlevski.eu</div>");
					$prefix="T-SUVLTR-";
					$current_code=str_replace($prefix, "", $singlecard[1]);
					$prefix="T-SUVLTR";
					$current_code1=substr($current_code, 0, 1);
					$current_code2=substr($current_code, 1, 3);
					$current_code3=substr($current_code, 4, 3);
					$current_code4=substr($current_code, 7, 3);
					$current_code="".$current_code1." ".$current_code2." ".$current_code3." ".$current_code4."";
					print("		<div style=\"position: absolute; width: 30mm; top: 35mm; left: 6.5mm; font-size: 4mm; line-height: 4.5mm; font-style: italic; text-align: right; z-index: 2;\"><b style=\"font-size: 5mm;\">GDPR</b><br /><b style=\"font-size: 2.5mm;\">".$prefix.", код:</b><br />".$current_code."</div>");
					print("	</div>");
					print("</div>");
				}
		print("<div style=\"position: relative; clear: both; width: 100%;\">");
		if ($p<=90)
		{
			$b=$n;
			$n=$n+2;
			$c=$n-1;
			if ($c<=9)
				{
					$c="0".$c;
				}
			if ($b<=0)
			{
				print("<center>« предишна</a> | стр. ".$c." от общо 10 | ");
			}
			else
			{
				if ($b==1)
				{
					print("<center><a href=\"./t.php\">« предишна</a> | стр. ".$c." от общо 10 | ");
				}
				else
				{
					print("<center><a href=\"./t.php?p=".$b."\">« предишна</a> | стр. ".$c." от общо 10 | ");
				}
			}
			if ($p>=90)
			{
				print("следваща »</center></div>");
			}
			else
			{
				print("<a href=\"./t.php?p=".$n."\">следваща »</a></center></div>");
			}
		}
	?>
	</body>
</html>