<?php
require_once ("../config.inc.php");
require_once ("../includes/adminlogincheck.inc.php");
require_once ("../includes/mysql.inc.php");
require_once ("../includes/arrays.inc.php");
require_once ("../classes/miscellaneous.class.php");
require_once "../includes/fckeditor/fckeditor.php";

$id			= isset($_REQUEST['id'])	?	trim($_REQUEST['id'])	:	"0";
$message	= "";
if (!$objDB) {
	$message	= "Unable to Locate Database Server.";
} else {
	$objMisc		= new miscellaneous($objDB);
	$objMisc->set_cms($_POST);
	if (isset($_POST['SaveNow'])) {
		$message	= $objMisc->save_cms($id);
		if ($message == "") {
			header("Location: cms.php?act=1");
			exit;
		}
	} elseif (isset($_POST['BackNow'])) {
		if ($message == "") {
			header("Location: cms.php");
			exit;
		}
	} else {
		$array	= $objMisc->get_cms($id);
		$objMisc->set_cms($array);
	}
}

include_once('title.inc.php');
?>
<script language="javascript" type="text/javascript">
function validate()
{
	var frm	= document.frmUser;
	
	if (frm.vTitle.value == "") {
		alert("Invalid  page.");
		frm.vTitle.focus();
		return false;
	}
	if (frm.tContent.value == "") {
		alert("Please enter page conetnt.");
		frm.tContent.focus();
		return false;
	}
	return true;
}
</script>
<?php include_once('tophtml.php');?>
<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top" class="white"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="72%" valign="top">
			<table width="100%"  border="0" cellspacing="0" cellpadding="5">
          <tr>
            <td><table width="100%"  border="0" cellspacing="0" cellpadding="5">
              <tr>
                <td width="41%" class="headings1" colspan="2">Manage Page (Contents)</td>
              </tr>
            </table>
			<div class="bordernew padding2">
				<form name="frmUser" method="post" action="" onSubmit="return validate();">
          <table width="100%"  border="0" cellspacing="0" cellpadding="5">
            <tr>
              <td><table width="100%"  border="0" cellspacing="0" cellpadding="0">
				<?php if ($objDB) 
					  { 
				?>
					<?php 	if(isset($message) && $message!='')
							{
					?>
                <tr align="left">
                  <td align="center" class="maintext2">&nbsp;</td>
                  <td colspan="2" class="maintext2 warning"><?php echo $message;?></td>
                  </tr>
					<?php  	}//end if?>
  				<tr align="left">
                  <td width="3%" class="maintext2">&nbsp;</td>
                  <td width="27%" class="maintext2">Page Title</td>
                  <td width="70%" class="maintext2"><?php echo htmlspecialchars($objMisc->vTitle)?></td>
  				</tr>
                 <tr align="left">
                  <td class="maintext2">&nbsp;</td>
                  <td valign="top" class="maintext2">Page Content</td>
                  <td valign="top" class="maintext2"><?php
										$sBasePath                      = "fckeditor/";
										$sBasePath                      = dirname(dirname($_SERVER['PHP_SELF'])) == "/" ? "/includes/fckeditor/" : dirname(dirname($_SERVER['PHP_SELF'])) ."/includes/fckeditor/";
										$oFCKeditor 					= new FCKeditor('tContent') ;
										$oFCKeditor->BasePath			= $sBasePath ;
										$oFCKeditor->Value				= $objMisc->tContent;
										$oFCKeditor->Config['SkinPath'] = $sBasePath . 'editor/skins/silver/' ;
										$oFCKeditor->Width  = '90%' ;
										$oFCKeditor->Height = '300' ;
										$oFCKeditor->Create() ;
									?></td>
                 </tr>
				<?php 			
						}//end first if
				?>
              </table>
                <table width="100%"  border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td align="right"><table width="100%"  border="0" cellspacing="0" cellpadding="0">
                      <tr>
                        <td>&nbsp;</td>
                      </tr>
                    </table>
                      <?php if ($objDB) 
					  { 
					?>
                      <table width="100%"  border="0" cellspacing="0" cellpadding="5">
                      <tr>
                        <td align="left"><table width="100%"  border="0" cellspacing="0" cellpadding="0" class="tblestyle_admin2">
                            <tr><td width="30%">&nbsp;</td>
                              <td width="5%"><input name="vTitle" type="hidden" value="<?php echo htmlspecialchars($objMisc->vTitle)?>"><input name="BackNow" type="submit" class="back-btn" value="Back">



</td>
							   <?php if ($id > 0) { ?>
                              <td><input name="SaveNow" type="submit" class="loginbutton" value="Save"><input type="hidden" name="id" value="<?php echo $id?>">



</td>
							   <?php }//end if?>
                              </tr>
                        </table></td>
                      </tr>
                    </table>
					<?php 		
						}//end first if
				?></td>
                  </tr>
                </table></td>
            </tr>
          </table></form>
			</div>
			</td>
          </tr>
        </table>
		</td>
        </tr>
    </table>      
    </td>
  </tr>
</table>
<?php include_once('bottomhtml.php');?>