<?php
/* All Right Reserved (C) 2010;
  MyTickets;
  Writed By Fahad S. Al-ghudaier;
  faha1ad2@hotmail.com;
  www.phpx3.com;
*/
	include('start.php');

	#if the pages system has been disabled
	if(! $options['allow_pages'] == 1){
		$page['title']	= $language['lang_31'];
		$page['allow_metas']	= 2;
		$page['show_header']	= 1;
		include('content_head.php');
		$smarty->assign('msg',$language['lang_43']);
		$smarty->display('error_msg.htm');
		include('content_foot.php');
		die();
	}
	
	$id		= intval($_GET['p']);
	// if there is no id or the id is empty
	if(empty($id) OR !is_numeric($id)){
		header("Location: index.php");
		die();
	}
	
	// get the page
	$query	= mysql_query("SELECT * FROM `pages` WHERE `id`='".$id."'");
	
	// if the page doesn't exist
	if(mysql_num_rows($query) == 0){
		$page['title']	= $language['lang_31'];
		$page['allow_metas']	= 2;
		$page['show_header']	= 1;
		include('content_head.php');
		$smarty->assign('msg',$language['lang_31']);
		$smarty->display('error_msg.htm');
		include('content_foot.php');
		die();
	}
	$mypage	= mysql_fetch_array($query);
	$mypage['languages_ids'] = explode(',',$mypage['languages_ids']);

	
	// if the language not like the used languages
	if(! in_array($Language_ID,$mypage['languages_ids']) AND $mypage['languages_ids'] != 'all' AND ! in_array('all',$mypage['languages_ids']) AND $_GET['ok'] != 'ok'){
		$page['title']	= $language['lang_31'];
		$page['allow_metas']	= 2;
		$page['show_header']	= 1;
		include('content_head.php');
		$smarty->assign('msg',str_replace('[link]','pages.php?ok=ok&p='.$id,$language['lang_44']));
		$smarty->display('error_msg.htm');
		include('content_foot.php');
		die();
	}

	// if he can't see the page
	if($mypage['group_id'] != $permission['id'] AND $mypage['group_id'] != 'all'){
		$page['title']	= $language['lang_31'];
		$page['allow_metas']	= 2;
		$page['show_header']	= 1;
		include('content_head.php');
		$smarty->assign('msg',$language['lang_45']);
		$smarty->display('error_msg.htm');
		include('content_foot.php');
		die();
	}
	
	// the page info.
	$page['title']			= $mypage['title'];
	$page['allow_metas']	= 1;
	$page['meta_open']		= $mypage['meta_open'];
	$page['meta_desc']		= $mypage['meta_desc'];
	$page['show_header']	= 1;
	include('content_head.php');

	// show the page
	$smarty->assign('mypage',$mypage);
	$smarty->display('page.htm');
	
	$db->query("UPDATE `pages` SET `hits`=hits+1 WHERE `id`='".$id."'");
	
	include('content_foot.php');
?>