Chciałbym się zapytać czy podany poniżej skrypt jest dobrze zabezpieczony przed atakiem SQL Injection?
<?php
if (!isset($_GET['id'])) { //Sprawdzanie czy wpisano cos do id }
$sql = mysql_query("SELECT * FROM `mybb_users` WHERE username='$id'") or
die(mysql_error()); //Pobieranie informacji z bazy sql
if (empty($num['username'])) { exit("Nie ma takiego użytkownika!"); } //Sprawdzanie czy podany użytkownik w ogóle istnieje
$Font_File = 'sans.ttf';
$Background_Picture = 'syg1.png';
$final_image = imageCreateFromPng($Background_Picture);
$white = imagecolorallocate($final_image, 255, 255, 255);
// Kolor reputacji w zależności od ilości
if($num['reputation'] == 0){
$rep_color = $white; // Kolor Biały
}elseif($num['reputation'] > 0){
$rep_color = imagecolorallocate($final_image, 0, 255, 0); // Kolor Zielony
}elseif($num['reputation'] < 0){
$rep_color = imagecolorallocate($final_image, 255, 0, 0); // Kolor Czerwony
}
// Kolor nicku w zależności od grupy (Admin = Czerwony, Mod = Zielony, Reszta = Biały)
if($num['usergroup'] == 4){
$user_color = imagecolorallocate($final_image, 255, 0, 0); // Kolor Czerwony - Admin
}elseif($num['usergroup'] == 3){
$user_color = imagecolorallocate($final_image, 0, 255, 0); // Kolor Zielony - Mod
}else{
$user_color = $white; // Kolor Biały - Reszta
}
// Tekst
imagettftext($final_image, 8, 0, 160, 55, $user_color, $Font_File, $num['username']);
imagettftext($final_image, 8, 0, 160, 65, $white, $Font_File, $num['postnum']);
imagettftext($final_image, 8, 0, 160, 75, $rep_color, $Font_File, $num['reputation']);
// Wynik
imagettftext($final_image, 8, 0, 85, 55, $white, $Font_File, 'Nick:');
imagettftext($final_image, 8, 0, 85, 65, $white, $Font_File, 'Posty:');
imagettftext($final_image, 8, 0, 85, 75, $white, $Font_File, 'Reputacja:');
header("Content-type: image/png"); imagePng($final_image);
?>