Stating the obvious:
1: Many people are asking how to use FCKeditor to edit their web pages and implement the editor.
2: They don't want to use a database or can't.
3: There is no real clear documentation on how to do this (the Wiki should have examples… I say no more).
4: I AM NOT A PHP CODE GURU. My coding is very bad; so do not beat up on me! I am only trying to help…
What I needed and what I came up with:
I needed an editor that would let me edit existing pages and not use a database. I have a customer who has a site that needs a 'points' page updated daily throughout the summer (it is a racing site) and a DB would be overkill.
My solution and mini tutorial:
The following code is NOT PERFECT and just a starting point! If a real code guru could clean this up or shorten the steps that would be great. Also, this document was very helpful (PDF); http://www.linux-magazine.com/issue/59/FCKEditor.pdf
And you might want an activity spinner: http://mentalized.net/activity-indicators/
1: I created four pages (call them what you want, my names are for clarity):
public.php (the page that the world will see)
editor.php (this is the FCKeditor page - the one that no one sees but the editor/admin person)
saved-data.php (the actual page that gets edited - it needs to be totally blank and make sure you have 'write permissions'.
compiler.php (it has the code that saves the web page edits to the 'saved-data.php' page and has a cool spinner on it)
How it all works:
The 'public' page has a php include call in it that pulls the 'saved-date' page like this: <?php include stripslashes('saved-data.php'); ?>
The 'saved-data' page is also pulled into the 'editor' page, edited and then saved by the 'compiler' page. The 'compiler' page has an 'activity spinner' on it and a refresh that takes you back to the 'editor'. It also has a 'div' tag that is hidden so no one has to look at the uglyhtml/web code as it saves.
Confused? Well so am I…
The code for my pages:
public.php
---------------------------------------------------
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="fck_editorarea.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="1" cellpadding="2" cellspacing="2" bordercolor="#999999">
<tr>
<td><?php include stripslashes('saved-data.php'); ?></td>
</tr>
</table>
</body>
</html>
----------------------------------------------------
editor.php
---------------------------------------------------
<?php
include("FCKeditor/fckeditor.php") ;
?>
<html>
<head>
<title>FCKeditor - Sample</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<form action="compiler.php" method="post" name="FCKeditor1" id="FCKeditor1">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = file_get_contents (stripslashes("saved-data.php"));
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '600' ;
$oFCKeditor->Create() ;
?>
<input type="submit" value="Submit">
</form>
</body>
</html>
<html>
<head>
<title>Please wait...</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="refresh" content="5;URL=editor.php">
<link href="../sample.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#Layer1 {
position:absolute;
left:48px;
top:139px;
width:368px;
height:117px;
z-index:1;
visibility: hidden;
}
-->
</style>
</head>
<body>
<div id="Layer1">
<?php
if ( isset( $_POST ) )
$postArray = &$_POST ;// 4.1.0 or later, use $_POST
else
$postArray = &$HTTP_POST_VARS ;// prior to 4.1.0, use HTTP_POST_VARS
foreach ( $postArray as $sForm => $value )
{
$postedValue = htmlspecialchars( stripslashes( $value ) ) ;
?>
<?=$sForm?><br>
<?=$postedValue?>
<?php
}
?>
</div>
<center>
<img src="web_images/indicator_big.gif" width="128" height="128">
<br>
Please wait...
</center>
</body>
</html>
-----------------------------------------------------------
saved-data.php
------------------------------------------------------------
//totally blank - your edits will be kept here
----------------------------------------------------------
compiler.php
-----------------------------------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<?php
$filename = stripslashes ("saved-data.php"); //or a variable
$fp = fopen ("$filename", "w");
fwrite($fp, trim(stripslashes ($_REQUEST['FCKeditor1'])). "\n". "\n");
fclose($fp);
?>
----------------------------------------------------------
Possible changes or ideas:
Everything happening in the 'editor' window (AJAX like) or cutting down the steps.
The ability to choose what pages are edited.
Re: How to Edit a Web Page - No DB Tutorial
Hello,

First, thank you for this solution, wich was helpfull with Fckeditor.
But, as the function Create() is no longer usable in CKeditor, can someone explain how to do it in CKEditor ?
Tks.
Regards.
Re: How to Edit a Web Page - No DB Tutorial
In CKEditor, th function cerate() no longer exists

So does someone knows how to do that :
<body>
<form action="compiler.php" method="post" name="FCKeditor1" id="FCKeditor1">
<?php
$oFCKeditor = new FCKeditor('FCKeditor1') ;
$oFCKeditor->BasePath = '/FCKeditor/';
$oFCKeditor->Value = file_get_contents (stripslashes("saved-data.php"));
$oFCKeditor->Width = '100%' ;
$oFCKeditor->Height = '600' ;
$oFCKeditor->Create() ;?>
<input type="submit" value="Submit">
</form>
Tks.