Código PHP:
<?php
function Conectarse(){
if (!($link=mysql_connect("127.0.0.1","root","valladares"))){
echo 'error user o pass incorrectos';
exit();
}
if (!mysql_select_db("gbwc",$link)){
echo 'base de datos no existe';
exit();
}
return $link;
}
Conectarse();
function clean_variable($var=NULL,$r=NULL) {
$newvar = @preg_replace('/[^a-zA-Z0-9\_]/', '', $var);
if (!preg_match('/^[a-zA-Z0-9\_\s]*$/i',stripslashes($var))) {
if ($r != NULL) { return true; } else { return $newvar; }
writelog("$var", 'VARIABLE_ERROR');
}
if ($r == NULL) { return $newvar; }
}
// Cambia esto x tus variables
$nickname=clean_variable($_GET['nick']);
$qmnews = @mysql_query("SELECT game.NickName AS NickName, game.Guild AS Guild, game.GuildRank AS GuildRank, game.MemberCount AS MemberCount, game.TotalGrade AS TotalGrade, game.TotalRank AS TotalRank, game.CountryGrade AS CountryGrade, game.Country AS Country, game.CountryRank AS CountryRank, user.Gender AS Gender, game.Id AS Id FROM game, user where game.NickName='$nickname' limit 1");
if($r = @mysql_fetch_array($qmnews)){
$IDjuego = $r["NickName"];
$clan = $r["Guild"];
$puestoclan = "".$r['GuildRank']."/".$r['MemberCount']."";
$imgLVLmundial = imagecreatefromgif("../ranks/rank_".$r['TotalGrade'].".gif");
$puestomundial = $r["TotalRank"];
$imgLVLNacional = imagecreatefromgif("../ranks/rank_".$r['CountryGrade'].".gif");
$imgpais = imagecreatefrompng("../flags/".$r['Country'].".png");
$puestoPais = $r["CountryRank"];
if($r['Gender']==1){
$imgfondo='Girl.jpg';
}
if($r['Gender']==0){
$imgfondo='Boy.jpg';
}
// cabezera para el navegador
header('Content-type: image/png');
// variables de color de texto, tamaño, fuente e imagen d fondo
$background = imagecreatefromjpeg("$imgfondo");
$black = imagecolorallocate($background, 0, 0, 0);
$tamanio = 9;
$fuente = 'ft60.ttf';
// insertando las imagenes
//imagecopymerge($background, imagen, x, y, zomx, zomy, largo, alto, transparencia);
imagecopymerge($background, $imgLVLmundial, 95, 70, 0, 0, 25, 15, 100);
imagecopymerge($background, $imgLVLNacional, 106, 89, 0, 0, 25, 15, 100);
imagecopymerge($background, $imgpais, 150, 10, 0, 0, 25, 15, 100);
// Escribiendo en la imagen
imagettftext($background, $tamanio, 0, 82, 47, $black, $fuente, $IDjuego);
imagettftext($background, $tamanio, 0, 47, 60, $black, $fuente, $clan);
imagettftext($background, $tamanio, 0, 195, 60, $black, $fuente, $puestoclan);
imagettftext($background, $tamanio, 0, 200, 81, $black, $fuente, $puestomundial);
imagettftext($background, $tamanio, 0, 201, 99, $black, $fuente, $puestoPais);
// mostrar la imagen
imagepng($background);
// borrar la imagen del cache
imagedestroy($background);
}else{
?>
<script type="text/javascript">alert('Error: Copia bien la URL de tu firma');</script>
<meta HTTP-EQUIV="Refresh" CONTENT="0; URL=<?="http://".$_SERVER['HTTP_HOST']?>?op=firmas">
<?
}
?>