<?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']))
{
	if(strlen(strip_tags($_POST['FCKeditor1']))>435 && $_POST["cms_id"]==1)
	{
		$update_message = CNTNT_LEN_RESTRCTN."<br>".UR_CONTENT.strlen(strip_tags($_POST['FCKeditor1'])).CHARACTERS." !!!";
		header("Location:".$_SERVER['HTTP_REFERER']."&msg=".$update_message);		
		exit;
	}else
	{
	$update_cms_content = "UPDATE ".$tableprefix."content_management
							SET content_heading = ".GetSQLValueString($_POST['FCKeditor2'],"text").",
						    content_text = " .GetSQLValueString($_POST['FCKeditor1'],"text").
						  " WHERE content_id = ".GetSQLValueString($_POST['cms_id'],"text");
	mysql_query($update_cms_content) or die(mysql_error());			
	
	$update_message = CONTENTS_UPDATED_SUCCESSFULLY." !!";
	header("Location:list_content_management.php?msg=".$update_message);		
	exit;
	}
	
	   

}

if($_GET['edit_id'] != "")
{

	$select_cms_details = "SELECT content_heading,content_text FROM ".$tableprefix."content_management 
							WHERE content_id = ".GetSQLValueString($_GET['edit_id'],"text");
	$result_cms_details = mysql_query($select_cms_details);
	
	$cms_row = mysql_fetch_assoc($result_cms_details);						

}

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

include "../includes/htmltop.php";
?>
<script type="text/javascript" src="<?php echo SITE_URL?>/ckeditor/ckeditor.js"></script>
<script type="text/javascript">
	window.onload = function()
	{
		CKEDITOR.replace( 'editor1' );
		CKEDITOR.replace( 'editor2' );
	};
   function formcheck()
   {
       if ( CKEDITOR.instances.editor1.getData() == '' ){
                        alert("Please enter a heading");
                        CKEDITOR.instances.editor1.focus();
                        return false;
                    }
      if ( CKEDITOR.instances.editor2.getData() == '' ){
                        alert("Please enter the content");
                        CKEDITOR.instances.editor2.focus();
                        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");
	switch($_GET['edit_id'])
	{
		case 1 : $contentHeading = HOME;
				  break;
		case 2 : $contentHeading = TC;
				  break;
		case 3 : $contentHeading = ABOUT_US;
				  break;
		case 4 : $contentHeading = CONTACT_US;
				  break;
		case 5 : $contentHeading = FAQ;
				  break;
	}
?>		
			
			<form name="frmProfile" action="<?php echo $_SERVER["PHP_SELF"]?>" method="POST" onSubmit="return formcheck();">
			
			<div align="left" class="content_area">
			<!--content area start -->
									
			
			<div align="left" class="page_title"><?php echo CNTN_MGT;?> - <?php echo $contentHeading; ?></div>
			<div align="center" class="text_information grey_tr"><?php echo $message?></div>
            <br>
									
			<div align="right">
				
																									
			<table cellpadding="2" cellspacing="2" width="70%" align="center">
				
				<tr><td colspan="3"></tr>
				<tr>
					<td colspan="3">
						<fieldset>
							<legend class=''><?php echo HEADING_EDIT_SEC;?></legend>
								<table width="100%" cellspacing="2" cellpadding="2">
									<tr>
										<td align="left">
									<?php 	
									
										$cms_text_heading = stripslashes($cms_row['content_heading']);
										//ContentManagementHeading(700,100,$cms_text_heading);
									?>
									
					  <textarea id="editor1" name="FCKeditor2"><?php echo $cms_text_heading;?></textarea>

										</td>
									</tr>
									
								</table>
						</fieldset>
					</td>
				</tr>
				
				
				<tr>
					<td colspan="3">
						<fieldset>
							<legend class=''><?php echo CONTENT_EDIT_SEC;?></legend>
								<table width="100%" cellspacing="2" cellpadding="2">
									<tr>
										<td align="left">
									<?php 	
										
										$cms_text = stripslashes($cms_row['content_text']);
										//ContentManagement($newWidth,$newHeight,$cms_text);
										
									?>
							 <textarea id="editor2" name="FCKeditor1"><?php echo $cms_text;?></textarea>

										</td>
									</tr>
									<tr>
										<td align="center">
											<input type="submit" class="button" value="<?php echo UPDATE;?>" name="btnUpdate">
											<input type="hidden" name="cms_id" value="<?php echo $_GET['edit_id']?>">
										</td>
									</tr>
								</table>
						</fieldset>
					</td>
				</tr>																								
				
				
				
			</table>
			
			</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();
?>