<?php

require 'admin/facebook.php';

$getPage = "reveal";

// REVEAL CHECK...
	
	$getReveal = file_get_contents("admin/pages/$getPage/reveal.txt", true);
	$getRevealURL = "likepage";
	$getAppID = file_get_contents("admin/fb/id.txt", true);
	$getAppCode = file_get_contents("admin/fb/secret.txt", true);

	if($getReveal == "1"){
	
		$app_id = "$getAppID";
		$app_secret = "$getAppCode";
		$facebook = new Facebook(array(
				'appId' => $app_id,
				'secret' => $app_secret,
				'cookie' => true
		));
		
		
		$signed_request = $facebook->getSignedRequest();
		
		$page_id = $signed_request["page"]["id"];
		$page_admin = $signed_request["page"]["admin"];
		$like_status = $signed_request["page"]["liked"];
		$country = $signed_request["user"]["country"];
		$locale = $signed_request["user"]["locale"];
		
		if ($like_status) {
				header('Location: view.php?p=reveal&sp=0');
			}
			else {
				header('Location: view.php?p='.$getRevealURL.'&sp=0');
		}

	}


?>
