<?php
///////////////////////////////////////////////////////////////////////////////////////////
///Script PHP/MYSQL of management of classifieds ads developed by Script PAG
///Script PAG all rights reserved. Use under license. http://www.script-pag.com
///////////////////////////////////////////////////////////////////////////////////////////

############################################################

require_once __DIR__.'/includes/all_fns.php';

///////////////////////////////////
//Validation of the page
//////////////////////////////////

if(!empty($_GET['id']))
$id_page = (int) $_GET['id'];

else redirect('index.php');

///////////////////////////////////
//Info of the page
//////////////////////////////////

foreach($cache_pages as $v)
{
	if($id_page == $v['id_page'])
	{
		$edition = (int) $v['edition'];
		$title = htmlspecialchars($v['name_page_'. $_SESSION['code_lang']]);
		$text = stripslashes($v['text_page_'. $_SESSION['code_lang']]);
				
		if($edition == 0)
		$text = nl2br(htmlspecialchars($text));
		
		break;
	}
}

if(!isset($title)) 
redirect('index.php');

///////////////////////////////////
//Get all page slug language
//////////////////////////////////

$lang_slug = get_page_slugs(array('router_slug_page'));

///////////////////////////////////
//Variables of elements
//////////////////////////////////

$index = 0;
$account = 0;
$page = 1;

///////////////////////////////////
//Title and Meta 
//////////////////////////////////

$title = $title;
$description = ($edition == 0) ? substr($text, 0, 300) : '';
$words = '';
$info_page = $title;
	
///////////////////////////////////
//Display view
//////////////////////////////////

pool::execute('beforestart');

$view = array();
$view[] = 'template/tpl_txt.php';

if(isset($_POST['is_ajax']) && $_POST['is_ajax'] == true) require_once __DIR__.'/template/tpl_txt.php';
else require_once __DIR__.'/template/tpl_layout.php';