Files
BE_IBL/application/controllers/Imgtoken.php
2026-04-15 15:24:53 +07:00

40 lines
1.0 KiB
PHP

<?php
class Imgtoken extends MY_Controller
{
function __construct()
{
parent::__construct();
}
function show($number)
{
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(200, 100);
// Create some colors
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
// Draw the background rectangles
imagefilledrectangle($im, 0, 0, 200, 50, $black);
imagefilledrectangle($im, 0, 50, 200, 100, $white);
// Set the text colors
$text_color_white = $white;
$text_color_black = $black;
// Set the path to the font you want to use
$font_path = APPPATH . 'controllers/Arial_Narrow.ttf'; // Make sure this path is correct
// Add the text
imagettftext($im, 20, 0, 50, 30, $text_color_white, $font_path, 'Token Anda');
imagettftext($im, 20, 0, 70, 80, $text_color_black, $font_path, $number);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
}
}