<?php
if ( !defined( 'SMARTY_DIR' ) ) {
	include_once( '../init.php' );
}

include ( 'sessioninc.php' );

define( 'PAGE_ID', 'pages_mgt' );

if ( !checkAdminPermission( PAGE_ID ) ) {

	header( 'location: not_authorize.php' );
	exit;
}

$page = $_POST['txtpage'];

$t->assign('curpage', $page);

if ($_SESSION['modifiedpage'] != '') {

	$t->assign('pagerec', $_SESSION['modifiedpage']);

	$t->assign('curpage', $_SESSION['modifiedpage']['id']);

	$_SESSION['modifiedpage'] = '';

} elseif ( $page != '0' ) {

	if ($_REQUEST['delpage'] == get_lang('delete')) {

		$osDB->query('delete FROM ! WHERE id = ?', array( PAGES_TABLE, $page));

		$_GET['errid'] = 5;

	} else {

		$t->assign( 'pagerec',$osDB->getRow( 'SELECT id, lang, pagekey, title, pagetext FROM ! WHERE id = ?', array( PAGES_TABLE, $page ) ) );

	}
}

$rs =& $osDB->getAll( 'SELECT id, title as answer FROM !', array( PAGES_TABLE ) );

$t->assign ( 'error_msg', get_lang('pages_errormsgs',$_GET['errid']) );

$t->assign( 'pagedata', makeOptions( $rs ) );

unset($rs);

$t->assign('rendered_page', $t->fetch('admin/managepages.tpl'));

$t->display ( 'admin/index.tpl' );



?>