<?php
ob_start();
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts Multicart                     |
// +----------------------------------------------------------------------+
// | Authors: Programmer<programmer@armia.com>        		              |
// +----------------------------------------------------------------------+
// | Copyrights Armia Systems, Inc and iScripts.com © 2005                |
// | All rights reserved                                                  |
// +----------------------------------------------------------------------+
// | This script may not be distributed, sold, given away for free to     |
// | third party, or used as a part of any internet services such as      |
// | webdesign etc.                                                       |
// +----------------------------------------------------------------------+
?>
<?php
include "../includes/config.php";
include "../includes/session.php";
include "../includes/functions.php";

if(isset( $_SESSION["sess_adminname"]) and $_SESSION["sess_adminname"]!= ""){
	$adminname = $_SESSION["sess_adminname"];
}else{
	header("Location:login.php");
	exit;
}

if(isset($_POST['btnUpdate']))
{
	
	$message = "";
	$metaid		= $_POST['txtMetaId'];
	
	$txtTitle	= addslashes($_POST['txtTitle']);
	
	$txtKeywords	= addslashes($_POST['txtKeywords']);
	
	$txtDescription	= addslashes($_POST['txtDescription']);
	
	if($txtTitle=='')
	{
		$message .= "*".ENTER_TITLE."! <br>";
	}
	
	if($txtKeywords=='')
	{
		$message .= "*".ENTER_KYWDS."! <br>";
	}
	
	if($txtDescription=='')
	{
		$message .= "*".ENTER_DESCRPTN."! <br>";
	}
	
	
	if($metaid!='')
	{
	
		if($message=='')
		{
		
		
					$sql_update_meta	= "UPDATE ".$tableprefix."metatags SET 
										vTitle = '".$txtTitle."' ,
										vKeywords = '".$txtKeywords."' ,
										vDescription = '".$txtDescription."' 
										where nId = '".$metaid."' ";
										
				  $rs_update_meta	= mysql_query($sql_update_meta) or die(mysql_error());	
				  
				  $update_message = CONTENTS_UPDATED_SUCCESSFULLY. "!!";
				  header("Location:meta_tags.php?msg=".$update_message);		
				  exit;					
		}		  
										
	}
	
	
	
	

}

if($_GET["msg"])
$success_message = $_GET["msg"];


$sql_meta= "SELECT * from ".$tableprefix."metatags ORDER BY nId ASC   ";

$rs_meta_tags = mysql_query($sql_meta) or die(mysql_error());

$metaRows	 =mysql_num_rows($rs_meta_tags);

include "../includes/htmltop.php";
?>

<script language="javascript">

function Validate()
{

	
	if($('.txtMetaId').val()=='')
	{
		return confirm("<?php echo SELECT_A_PAGE;?>")
		return false;
	}
	if($('.txtTitle').val()=='')
	{
		return confirm("<?php echo ENTER_TITLE;?>")
		return false;
	}
	
	if($('.txtKeywords').val()=='')
	{
		return confirm("<?php echo ENTER_KYWDS;?>")
		return false;
	}
	if($('.txtDescription').val()=='')
	{
		return confirm("<?php echo ENTER_DESCRPTN;?>")
		return false;
	}
	else
	{
		return true;
	}	
}

function ShowMetatags(nId)

{	

	if(nId=='')
	{
		$('.txtTitle').val('');
		$('.txtKeywords').val('');
		$('.txtDescription').val('');
	}
 	var dataString = {"meataid":nId}; 

	  $.ajax({

		url			:"list_meta_tags.php",

		type		:"post",

		data		:dataString,

		dataType 	: "json",

		success		:function(data){

					if(data.metatitle)

					{
						$('.txtTitle').val(data.metatitle);
						/*/$('.txtTitle').val($('.txtTitle').html());
						$('#mT').html(data.metatitle);
						
						$('.txtTitle').val($('#mT').html());
						$('#mT').hide();*/
					}
					if(data.metakeyword)

					{
						$('.txtKeywords').val(data.metakeyword);
						/*$('#mT1').html(data.metakeyword);
						
						$('.txtKeywords').val($('#mT1').html());
						$('#mT1').hide();*/
					}
					
					if(data.metadescription)
					{
						$('.txtDescription').val(data.metadescription);
						/*$('#mT2').html(data.metadescription);
						
						$('.txtDescription').val($('#mT1').html());
						$('#mT2').hide();*/
					}



					  return false;

					}

		});

}
</script>
<body>
		
		<center>
		
		<div align="left" id="layout">
		
		
				
				
				<!--header area start -->
<?php

	include_once("../includes/topheader_admin.php")

?>
				
				<!--header area end -->
				
				
				
				
				<div align="left" class="main_body">
				<!--main body start -->
				
				
				
<?php
	include_once("../includes/admintopmenu.php");
	
?>		
			
			<form name="frmContentMgmt" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST" >
			
			<div align="left" class="content_area">
			<!--content area start -->
									
			
			<div align="left" class="page_title"><?php echo META_TAGS_MANAGEMENT;?></div>
			<div align="center" class="text_information grey_tr"><?php echo $message?></div>
                        <div align="center" class="text_information_success grey_tr"><?php echo $success_message; ?></div>
            <br>
									
			<div align="left">
				
				<div> <p> <?php echo SELECT_A_PAGE_FROM_BELOW;?>. </p></div>
																									
			<table width="100%"  border="0" cellspacing="1" cellpadding="4" class="manage_table">

                              <tr bgcolor="#FFFFFF">
									<td width="25%" height="27" align="left" valign="top"><?php echo PAGE_NAME;?></td>
                                    <td width="75%" align="left" valign="top">
									<?php //echo select_tag('ddlContent','textboxadmin3','onChange="ShowTitle(this.value);showMetaHint(this.value);"',$Rootpage,$ddlContent);?>
                                      <select name="txtMetaId" id="txtMetaId" onChange="ShowMetatags(this.value)" class="txtMetaId">
									  <option value="">--<?php echo SELECT;?>--</option>
									  <?php while($rowsMetaObj=mysql_fetch_object($rs_meta_tags))
									  {
									  ?>
									  		<option value="<?php echo $rowsMetaObj->nId;?>"><?php echo $rowsMetaObj->vPageName;?></option>
									  <?php  } ?>
                                    </select></td>
                              </tr>
							  
                            </table>
<span id="showContent">
					   <table width="100%"  border="0" cellspacing="1" cellpadding="4" class="manage_table">
						  <tr bgcolor="#FFFFFF">
						    <td width="25%" bgcolor="#FFFFFF" class="factlisting"><?php echo PAGE_TITLE;?> </td>
						    <td width="75%" class="factlisting"><input type="text" name="txtTitle" class="textarea txtTitle" value="<?php echo html_entity_decode($txtPName);?>" size="75" id="txtTitle"><span id="mT"></span></td>
					     </tr>
                        <tr bgcolor="#FFFFFF">
                          <td align="left" valign="top" class="factlisting"><?php echo KEYWORDS;?></td>
                          <td class="factlisting"><textarea name="txtKeywords" cols="50" rows="10" class="textarea txtKeywords" id="txtKeywords"><?php echo html_entity_decode($txtDes);?></textarea><span id="mT1"></span></td>
                        </tr>
                        <tr bgcolor="#FFFFFF">
                          <td align="left" valign="top" class="factlisting"><?php echo DESCRIPTION;?></td>
                          <td class="factlisting"><textarea name="txtDescription" cols="50" rows="10" class="textarea txtDescription"  id="txtDescription"><?php echo html_entity_decode($txtDes2);?></textarea><span id="mT2"></span></td>
                        </tr>
                        <tr bgcolor="#FFFFFF">
                          <td class="factlisting">&nbsp;</td>
                          <td class="factlisting"><input type="submit" name="btnUpdate" value="<?php echo UPDATE;?>"  onClick="return Validate();" class="button"></td>
                        </tr>
                      </table>
</span>
			
			</div>
						
						
				<!--content area end-->
								
				</div>
				
				</form>
				
					<div align="left" class="clear_float"><img src="../images/clear.gif" alt="" width="1" height="1" /></div>
				<!--main body end -->
				</div>
				
				
<?php
	include "../includes/footer.php";
	ob_end_flush();
?>