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

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

require_once ( 'paypal.class.php' );

$h=fopen ( "buy_log.txt" , "a+" );

fwrite ( $h, "||Inizio nuova sessione----------\n" );

date_default_timezone_set ( 'Europe/Belgrade' );

$today=date('Y-m-d H:i:s');

$p = new paypal_class;

$p->paypal_url = 'https://www.paypal.com/cgi-bin/webscr';

$this_script = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];

if ( $p->validate_ipn ( ) ) {

$id=escape ( $_POST['item_number'] );

mysql_select_db ( 'shop' );

$query=mysql_query ( "UPDATE shop_log SET status='ok' WHERE id='$id';" );
	
if ( $query ) {

fwrite ( $h, "$today $user $id ACQUISTO CONFERMATO\n" );

} else {

fwrite($h, "$today $user $id ERRORE QUERY: ".mysql_error()."\n");

}

fclose($h);

} else {

fwrite ( $h, "$today $user $id ACQUISTO NON CONFERMATO\n" );

}
?>