<?php
if ( !eregi("admin.php", $PHP_SELF) ) {
	die ("Access Denied"); 
}
if ( $xoopsUser->isAdmin($xoopsModule->mid()) ) {

function saveMetaFooter($metacode,$footer){
	global $xoopsDB, $xoopsConfig;
	$myts =& MyTextSanitizer::getInstance();
	$metacode = $myts->makeTareaData4Save($metacode);
	$footer = $myts->makeTareaData4Save($footer);
	$sql = "DELETE FROM ".$xoopsDB->prefix("metafooter")." WHERE (1=1)";
	$result = $xoopsDB->query($sql);
	if (!$result) {
		xoops_cp_header();
		echo _AM_ERRDELOLD;
		xoops_cp_footer();
		exit();
	}
	$sql = "INSERT INTO ".$xoopsDB->prefix("metafooter")." (meta, footer) VALUES ('$metacode', '$footer')";
	$result = $xoopsDB->query($sql);
	if(!$result) {
		xoops_cp_header();
		echo _AM_ERRINSERT;
		xoops_cp_footer();
		exit();
	}
	redirect_header("admin.php",1,_AM_DBUPDATED);
}

function editMetaFooter(){
	global $xoopsDB, $xoopsConfig;
	$sql = "SELECT * FROM ".$xoopsDB->prefix("metafooter")." WHERE (1=1)";
	$result = $xoopsDB->query($sql);
	if (!$result) {
		echo "Error doing DB query";
		CloseTable();
		xoops_cp_footer();
		exit();
	}
	$row = $xoopsDB->fetchArray($result);
	$myts =& MyTextSanitizer::getInstance();
	$currMeta = $myts->makeTareaData4Edit($row['meta']);
	$currFooter = $myts->makeTareaData4Edit($row['footer']);
	echo "<h4 style='text-align:left;'>"._AM_EDITMKF."</h4>";
?>
<form action='admin.php' method='post'>
<table border='0' cellpadding='0' cellspacing='0' align='center' valign='top' width='100%'><tr><td class='bg2'>
<table border='0' cellpadding='4' cellspacing='1' width='100%'>

<tr align='left'>
	<td class='bg3' nowrap='nowrap'><b><?php echo _AM_METAKEY;?></b></td>
	<td class='bg1'><textarea name='metacode' rows='15' cols='45' wrap='virtual'><?php echo $currMeta?></textarea><br /><?php echo _AM_TYPEBYCOM;?><br /><br /></td>
</tr>
<tr align="left">
	<td class='bg3' nowrap='nowrap'><b><?php echo _AM_FOOTER;?></b></td>
	<td class='bg1'><textarea name='footer' rows='15' cols='45' wrap='virtual'><?php echo $currFooter?></textarea>
	<br /><br /><span style='color:#ff0000'><?php echo _AM_BESURELINK;?></span><br /><br /></td>
</tr>
<tr align='left'>
	<td class='bg3'>&nbsp</td>
	<td class='bg1'>
		<input type='hidden' name='fct' value='metafooter' />
		<input type='hidden' name='op' value='save' />
		<input type='submit' name='submit' value='<?php echo _AM_ADDCODE;?>' />
	</td>
</tr>
</table></td></tr></table>
</form>
<?php
}

} else {
    echo "Access Denied";
}

?>