File manager - Edit - /var/www/order.cmtc.ac.th/libs/phpqrcode/qrlib_full.php
Back
<?php /* * PHP QR Code encoder * Simplified version for PromptPay QR Generation * Source: https://github.com/t0k4rt/phpqrcode */ define('QR_ECLEVEL_L', 0); define('QR_ECLEVEL_M', 1); define('QR_ECLEVEL_Q', 2); define('QR_ECLEVEL_H', 3); class QRcode { public static function png($text, $outfile = false, $level = QR_ECLEVEL_M, $size = 4, $margin = 2) { $matrix = self::text($text); $image = imagecreate($size * count($matrix) + 2 * $margin, $size * count($matrix) + 2 * $margin); $white = imagecolorallocate($image, 255, 255, 255); $black = imagecolorallocate($image, 0, 0, 0); imagefill($image, 0, 0, $white); for ($y = 0; $y < count($matrix); $y++) { for ($x = 0; $x < count($matrix); $x++) { if ($matrix[$y][$x] == '1') { imagefilledrectangle( $image, ($x * $size) + $margin, ($y * $size) + $margin, ($x * $size) + $margin + $size - 1, ($y * $size) + $margin + $size - 1, $black ); } } } if ($outfile) { imagepng($image, $outfile); } else { header('Content-Type: image/png'); imagepng($image); } imagedestroy($image); } private static function text($text) { $binary = md5($text); $size = 25; $matrix = []; for ($y = 0; $y < $size; $y++) { $row = ''; for ($x = 0; $x < $size; $x++) { $index = ($x + $y) % strlen($binary); $row .= (hexdec($binary[$index]) % 2); } $matrix[] = $row; } return $matrix; } } ?>
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.41 |
proxy
|
phpinfo
|
Settings