<?php
require('page_core/common.php');

$n = intval( $_POST['s'] );
#$n = intval( $_GET['s'] );

switch ( $n ) {
	case ADMIN_SEC: # Admin
		$c = intval( $_GET['c'] );
		$secured = secure($c);
		if (is_numeric($c) && $secured) {
			switch ($c) {
				case 1:
					$show = new cAdmin();
					$show->create_menu();
					break;
				default:
					$show = new cLogin();
					$show->show();
			}
		}
		break;
	case 1:
		$clean = true;
		$exec = intval( $_POST['exec'] );
		#$exec = intval( $_GET['exec'] );
		
		$show = new cFbManager( false, $exec != 0 );
		
		$show->execute( intval( $_POST['exec'] ), $_POST['fbid'], intval( $_POST['game'] ), $_POST['hash'], $_POST['val'] );
		#$show->execute( intval( $_GET['exec'] ), $_GET['fbid'], intval( $_GET['game'] ), $_GET['hash'], $_GET['val'] );
		break;
	default:		# Index
		$show = new cFbManager();
		$show->show();
}

if ( ! ( $clean == true ) ) {
	if ( !( $n==ADMIN_SEC && !$secured ) )
		cPage::adddata($show->data);
	
	cPage::pp();
} else {
	if ( isset($show) ) {
		echo $show->data;
		trace( 'pritned: '.$show->data );
	}
}
?>
