38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
header('Content-type: image/jpeg');
|
|
|
|
$mysql_host = 'localhost';
|
|
$mysql_user = 'example_user';
|
|
$mysql_pass = 'Kolosnjaj4321!';
|
|
$mysql_db = 'example_database';
|
|
$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass);
|
|
mysqli_select_db($con, $mysql_db);
|
|
|
|
if (isset($_GET['id'])) {
|
|
$id = $_GET['id'];
|
|
|
|
$query = mysqli_query($con, "SELECT `email` FROM `users` WHERE `id` ='" . mysqli_real_escape_string($con, $id) . "'");
|
|
if (mysqli_num_rows($query) >= 1) {
|
|
$query_result = mysqli_fetch_assoc($query);
|
|
$email = $query_result['email'];
|
|
} else {
|
|
$email = 'ID not found';
|
|
}
|
|
} else {
|
|
$email = 'No id specified.';
|
|
}
|
|
$email_length = strlen($email);
|
|
|
|
$font_size = 4;
|
|
|
|
$image_height = imagefontheight($font_size);
|
|
$image_width = imagefontwidth($font_size) * $email_length;
|
|
|
|
$image = imagecreate($image_width, $image_height); // Stvaranje prazne slike
|
|
|
|
imagecolorallocate($image, 255, 255, 255); // boja pozadine podesena na belo
|
|
$font_color = imagecolorallocate($image, 0, 0, 0); // boja fonta podesena na belo
|
|
|
|
imagestring($image, $font_size, 0, 0, $email, $font_color);
|
|
imagejpeg($image);
|