<?php
include('check.php');

include('../inc/settings.php');

if ( $status ) {

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

mysql_select_db ( 'shop' );

$query= mysql_query ("SELECT * FROM shop WHERE id='$id'");

if ( $query ) {

$query2=mysql_query ( "INSERT INTO shop_log (shopitem_id,user,status) VALUES ('$id','$user','pending')" );
$oid=mysql_insert_id ( );

if ( $query2 ) {

$f=mysql_fetch_array($query);
$prezzo=$f['prezzo'];
$nome=$f['nome'];
$monete = $f['monete'];
require_once('paypal.class.php');
$p = new paypal_class;             
$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; 
$this_script = 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF'])."/";
$p->add_field('business', $paypal_id);
$p->add_field('currency_code', 'EUR');
$p->add_field('cmd','_donations');
$p->add_field('item_number', $oid);
$p->add_field('return', $this_script.'confBuy.php?id='.$oid);
$p->add_field('cancel_return', $this_script.'deleteBuy.php?id='.$oid);
$p->add_field('notify_url', $this_script.'validateBuy.php');
$p->add_field('item_name', $nome);
$p->add_field('amount', $prezzo);
$p->submit_paypal_post();

}

}

} else {

header('location: login.php');

}
?>