Создать новый тип метки для компании $companyname";
// echo "";
echo "Создать метку, закодированную в QR код:
";
//set it to writable location, a place for temp generated PNG files
$PNG_TEMP_DIR = dirname(__FILE__).DIRECTORY_SEPARATOR.'temp'.DIRECTORY_SEPARATOR;
//html PNG location prefix
$PNG_WEB_DIR = 'temp/';
include "phpqrcode/qrlib.php";
//ofcourse we need rights to create temp dir
if (!file_exists($PNG_TEMP_DIR))
mkdir($PNG_TEMP_DIR);
$filename = $PNG_TEMP_DIR.'test.png';
//processing form input
//remember to sanitize user input in real-life solution !!!
$errorCorrectionLevel = 'L';
if (isset($_REQUEST['level']) && in_array($_REQUEST['level'], array('L','M','Q','H')))
$errorCorrectionLevel = $_REQUEST['level'];
$matrixPointSize = 6;
if (isset($_REQUEST['size']))
$matrixPointSize = min(max((int)$_REQUEST['size'], 1), 10);
if (isset($_REQUEST['data'])) {
//it's very important!
if (trim($_REQUEST['data']) == '')
echo('Данные не должны быть пустыми!
');
else {
if ($type == '3')
$hex_string = $_REQUEST['data'];
else {
$buf = pack("lll", $type, $_REQUEST['objtype'], $_REQUEST['data']); //заголовок - номер пакета 1б и длина 2б. v-ushort, c- byte, C- ubyte, s - short, L - int, l - uint
$hex_string = base64_encode($buf);
}
//echo "type $type";
echo "
data: $hex_string
";
// user data
$filename = $PNG_TEMP_DIR . 'test' . md5($hex_string . '|' . $errorCorrectionLevel . '|' . $matrixPointSize) . '.png';
//$filename = $PNG_TEMP_DIR.'test'.md5($_REQUEST['data'].'|'.$errorCorrectionLevel.'|'.$matrixPointSize).'.png';
QRcode::png($hex_string, $filename, $errorCorrectionLevel, $matrixPointSize, 2);
}
} else {
//default data
//echo 'You can provide data in GET parameter: like that
';
QRcode::png('PHP QR Code :)', $filename, $errorCorrectionLevel, $matrixPointSize, 2);
}
//display generated file
echo '
';
//config form
$sel1 = '';
$sel2 = '';
$sel3 = '';
if ($type == '1')
$sel1 = 'selected';
if ($type == '2')
$sel2 = 'selected';
if ($type == '3')
$sel3 = 'selected';
echo '
';
// benchmark
// QRtools::timeBenchmark();