<?php
require("mysql.php");

$id = (isset($_GET['id'])) ? mysql_real_escape_string(trim($_GET['id'])) : '';
$row = mysql_fetch_array(mysql_query("SELECT `name` FROM `accounts` WHERE `name` = '".$id."'"));

if(!$row['name']){
	header("location:error");
	die();
}
$punkte = 5;
$titel = 'ThiefGame - '.$row['name'];
$styles = '<link href="/sf/m/boxes/boxes.css" rel="stylesheet" type="text/css"><link href="/sf/f/registration/registration.css" rel="stylesheet" type="text/css"><link href="/sf/m/buttons/buttons.css" rel="stylesheet" type="text/css"><link href="/sf/f/index/index.css" rel="stylesheet" type="text/css">';
$inhalt = '<div class="box blogentry"><div class="hd"><div class="tl"></div><div class="tr"></div><div class="tm"></div><div class="m"><div class="mi"><div class="h h2"><div class="hbegin"></div><h2>ThiefGame - '.$row['name'].'</h2></div></div></div></div><div class="bd fade bd-fade"><div class="m"><div class="mi">';

if(!$_POST['submit']) {
	$inhalt .= 'Bitte dr&uuml;cke auf Spenden um '.$row['name'].' zu spenden:<br><br><form method="POST" action="thiefgame.php?id='.$row['name'].'">';
	$inhalt .= '<input type="submit" name="submit" value="Spenden"></form>';
                         
} else {
		$don = mysql_fetch_array(mysql_query("SELECT `name` FROM `donations` WHERE `name` = '".$id."' AND `ipAddress` = '".ip()."'"));

		if(!$don['name']) {
			$inhalt .= 'Du hast '.$row['name'].' <b>'.$punkte.' Punkte</b> gespendet.<br><br>Mach mit und <a href="registrieren">registriere</a> dich jetzt!';

			mysql_query("UPDATE `accounts` SET thiefgame=thiefgame+5,priviMessage='9',priviMessage2='".$punkte."' WHERE `name` = '".$row['name']."'");
			mysql_query("INSERT INTO `donations` SET `ipAddress` = '".ip()."', `name` = '".$row['name']."'");
		} else {
			$inhalt .= 'Du hast '.$row['name'].' bereits gespendet.';
		}
	}


$inhalt .= '</div></div><div class="bl"></div><div class="br"></div><div class="bm"></div></div></div></div>';
echo str_replace(array('<?url?>','<?inhalt?>', '<?titel?>', '<?fotonavi?>', '<?registrieren?>', '<?styles?>', '<?fotos?>'),array($_SERVER[SERVER_NAME], $inhalt, $titel, $fotonavi, $registrieren, $styles, $fotos),implode("",file("sf/b/style.tpl")));

?>  