<?php

session_start();

include ("includes/db.php");
include ("functions/login.php");
include ("functions/date_format.php");
include ("functions/curPageURL.php");

if (isset ($_GET['searchbox']) and $_GET['searchbox'] != 'Search Pages...' ) {
	$search = mysql_escape_string($_GET['searchbox']);
} else {
	$search = '';
}

if (isset ($_GET['id'])) {
	$id = $_GET['id'];
} else {
	$id = 0;
}

if (isset($_GET['my'])) {
	$my = $_GET['my'];
} else {
	$my = 0;	
}

if (isset ($_GET['uid']) and $_GET['uid']!=NULL) {
	if ($_SESSION['priv'] != 'Admin' and $_SESSION['priv'] != 'Superadmin') {
		$uid = $_SESSION['id'];
	} else {
		$uid = $_GET['uid'];
	}
	if ($my == 1) {
		$viewUserPages = " AND p.Id IN (SELECT PageId FROM user_page_submission WHERE UserId =  '$uid' ) ";	
	} else {
		$viewUserPages = " AND p.Id IN (SELECT PageId FROM user_page WHERE UserId =  '$uid' ) ";
	}
} else if (isset($_SESSION['id'])) {
	if ($_SESSION['priv']=='Superadmin') {
		$viewUserPages == " ";
	} else {
		$uid = NULL;
		$us_id = $_SESSION['id'];
		$viewUserPages = " AND ( p.Public = 1 OR p.Id IN (SELECT PageId FROM user_page_submission WHERE UserId =  '$us_id' ) ) ";	
	}
} else {
	
}

if (isset($_GET['sbm'])) {
	$sbm = $_GET['sbm'];
} else {
	$sbm = '';	
}


if (isset($_GET['orby'])) {
	$orby = $_GET['orby'];
} else {
	$orby = '';	
}



include ("includes/priviledge.php");

if (isset($_REQUEST['page']) and file_exists("pages/".$_REQUEST['page'].".php") and  in_array($_REQUEST['page'], $availablePages)) {
	$page = $_REQUEST['page'];
} else {
	$page = 'home';
}


include ("includes/misc.php");

include ("includes/header.php");


include ("pages/".$page.".php");


include ("includes/footer.php"); 


?>



