<?php

	include "library.php";

	$cxn = start_code( true );


		/* get variables */

	$id = val( $_SESSION, "id" );


		/* if the user is not logged in them direct them to the login page then back to here */

	if ($id == "")
	{
		$_SESSION['nextpage'] = url_encode( "donate.php" );

		jump_to_page( "login.php" );		/* must happen before print output */

		exit();
	}


	page_header( "Donate", $cxn );


		/* setup variables */

	$credits_code = md5(time());

	$magic = md5( $id."|".$credits_code );

	$custom = "donation,".$id.",".$credits_code.",".$magic;

	echo "<br>";

	echo black( "Click the button below to donate to the site<br><br>" );

	echo black( "Please Note: You will need a credit card or bank account in a country that is supported by PayPal to donate." );

	echo black( "<br><br><br>" );

	echo "<table width='100%'><tr><td width='10%'></td><td width='90%' align='left'>";

	generate_button( $custom );

	echo "</td></tr>";

	echo "</table>";


	function generate_button( $custom )
	{

		echo "<form action='https://www.paypal.com/cgi-bin/webscr' method='post'>";
		echo "<input type='hidden' name='cmd' value='_xclick'>";
		echo "<input type='hidden' name='business' value='enquiries@academicdating.net'>";
		echo "<input type='hidden' name='item_name' value='".$_SESSION['sitename']." (donation)'>";
		echo "<input type='hidden' name='no_shipping' value='0'>";
		echo "<input type='hidden' name='return' value='http://www.academicdating.net/payment_successful.php'>";
		echo "<input type='hidden' name='no_note' value='1'>";
		echo "<input type='hidden' name='currency_code' value='USD'>";
		echo "<input type='hidden' name='custom' value='".$custom."'>";
		echo "<input type='hidden' name='tax' value='0'>";
		echo "<input type='hidden' name='lc' value='AU'>";
		echo "<input type='hidden' name='bn' value='PP-DonationsBF'>";
		echo "<input type='image' src='/buttons/donate.gif' border='0' name='submit' alt='Donate'>";
		echo "<img alt='' border='0' src='https://www.paypal.com/en_AU/i/scr/pixel.gif' width='1' height='1'>";
		echo "</form>";
	}

?>
