<?php $root=$_SERVER['DOCUMENT_ROOT'];$wroot=dirname($_SERVER['SCRIPT_NAME']);while((strlen($wroot)>1)&&(!file_exists($root.$wroot.'/main')))$wroot=dirname($wroot);if($wroot=='/')$wroot='';require_once($root.$wroot.'/main/app/App.php');
if (!$app->privileged('social')) $app->nopage('This page can only be accessed if you are logged in.');
else{
	$app->imageCatcher('avatar',"/main/users/{$app->user['user']}/avatar.png");
	$ppcfg=json_decode(file_get_contents($app->froot.'/main/modules/paypalPaywall/config.json'),true);
	if ($ppcfg){
		$clientId=$ppcfg['livemode']?$ppcfg['live_clientId']:$ppcfg['sbox_clientId'];
		$app->addStyle($app->wroot.'/main/modules/paypalPaywall/PaypalPaywall.css');
		$app->addScript($app->wroot.'/main/modules/paypalPaywall/PaypalPaywall.js');
	}
	$app->heads('Dashboard');
	$app->header();
?>			
<section>

<?php	if ($ppcfg){ ?>
	<article>
		<h1 class='article'>Dashboard</h1>
		<h1>Buy grains</h1>
		<?php $app->chainElement('paypalPaywall','min-width:320px;width:50%;display:inline-block;',$clientId); ?>
	</article>
<?php } //$ppcfg ?>

	<article>
		<h1>[<?php echo $app->user['user']; ?>]</h1>
		<p class='center'>(<?php echo $app->user['type']; ?>)</p>
		<?php $app->imageDropper('avatar',"/main/users/{$app->user['user']}/avatar.png"); ?>
		<h5>Credits</h5>
		<p class='center'>You have <b><?php echo $app->user['cred']; ?></b> grains of credit.</p>
	</article>

</section>
<?php
	$app->footer();
	$app->tails();
}
?>
