<?php

	include "library.php";

	$cxn = start_code( true );


		/* get variables */

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

	if (! has_paypal( $cxn ))
	{
		echo black( "A monthly membership offers you unlimited use of the site<br><br>" );
		echo black( "The only payment option for your country is Western Union.<br><br>" );
		echo black( "If you could like a monthly membership you must pay for 2 months at a time for a total of US $50 dollars.<br><br>" );
		echo black( "For details see " ).show_link( "western&nbsp;union", "western_union.php" );

		
		exit();
	}

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

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

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

		exit();
	}


	page_header( "Start Monthly Membership", $cxn );


		/* get current credits balance */

	$query = "SELECT credits_balance FROM profile WHERE id = ".$id;

	$result = run_query( $query, $cxn );

	$data = get_row( $result );


		/* setup variables */

	$credits_code = md5(time());

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

//	$custom = "credits,".$id.",".$credits_code.",".$magic;

	$custom_subs = "subscription,".$id.",".$credits_code.",".$magic;


		/* save the credits check code */

	$query = "UPDATE profile SET credits_code = '".$credits_code."' WHERE id = ".$id;

	$result = run_query( $query, $cxn );

	echo "<br><br><br>";

	echo black( "A subscription membership offers you unlimited use of the site" );

	echo "<br><br><br>";

	echo "<table width='100%'><tr><td width='10%'></td><td width='15%' valign='center'>";

	generate_subscription_button( $custom_subs, button_filename( "subscribe" ) );

	echo "</td><td valign='top'>".sp(3).black( "US $25 per month" )."</td></tr><tr><td></td><td valign='center' align='center'>";

	echo "</table>";

	echo "<br><br>";

?>
