<?
mysql_select_db ( 'account' );

$query_monete = mysql_query ( "SELECT * FROM account WHERE login='$username_session'" );

$fetch = mysql_fetch_array ( $query_monete );

$monete = $fetch ['monete'];

$id_buyer = $fetch ['id'];


mysql_select_db ( 'shop' );

$get_id_buy = escape ( $_GET['id'] );

$get_cat_buy = escape ( $_GET['cat'] );

$query = mysql_query ( "SELECT * FROM item WHERE id='$get_id_buy' and id_cat='$get_cat_buy'" );

if ( $num = mysql_num_rows ( $query ) < 2 ) {

$pre = mysql_fetch_array ( $query );

$prezzo = $pre ['prezzo'];

$value = $pre ['value'];

if ( $monete < $prezzo ) {

echo "<center>Errore, Keine<i>".$prezzo."</i> Points</center>";

} else {

mysql_select_db ( 'player' );

$calcola_pos = mysql_query ( "SELECT pos FROM item WHERE owner_id='$id_buyer' and window='MALL'" );

$calcolato = mysql_num_rows ( $calcola_pos );

$ok = ( $calcolato+1 );

$insert_item = mysql_query ( "INSERT INTO `item` VALUES ('', '$id_buyer', 'MALL', '$ok', '1', '$value', '1', '1', '1', '1', '1', '1', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0')" );

if ( $insert_item == true ) {

$trovo = mysql_query ( "SELECT * FROM item WHERE owner_id='$id_buyer' and vnum='$value' and pos='$ok'" );

$makk = mysql_fetch_array ( $trovo );

$oooode = $makk ['id'];
/*

if ( $value == "72703" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='3000' WHERE id='$oooode'" );

}

if ( $value == "72704" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='3000' WHERE id='$oooode'" );

}

if ( $value == "72705" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='3000' WHERE id='$oooode'" );

}

if ( $value == "72706" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='3000' WHERE id='$oooode'" );

}

if ( $value == "72001" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='600' WHERE id='$oooode'" );

}

if ( $value == "72049" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='1800' WHERE id='$oooode'" );

}

if ( $value == "72050" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='3600' WHERE id='$oooode'" );

}

if ( $value == "70005" ) {

$uppo_socket = mysql_query ( "UPDATE item SET socket2='60' WHERE id='$oooode'" );

}
*/

mysql_select_db ( 'account' );

$ultimo = ( $monete - $prezzo );

$uppo_monete = mysql_query ( "UPDATE account SET monete='$ultimo' WHERE login='$username_session'" );

echo "<center>Item Erfolgreich erworben, finden Sie das Element ingame, <a href='javascript:history.back()'>zurück</a></center>";

} else {

echo "<center>Fehler in den Kauf von Artikel! <a href='javascript:history.back()'>zurück</a></center>";

}

}

} else {

echo "<center>Kontaktieren Sie einen [GF] Problem mit der Datenbank!</center>";

}
?>		
