Menu

#71 Site Editor

Version 2.x
open
nobody
None
5
2005-02-13
2005-02-13
Nate Mendel
No

Sorry if I did something wrong; I couldn't really find
anywhere to upload.
I built a PHP file to edit a site with FCKEditor; you
just specify page names and a few paths, and your users
can edit pages with FCKEditor, restore them to your
original form, and more.
Just unzip inside root FCKEditor directory and follow
instructions in edit.php. There is a problem with
quotes that hopefully someone can solve.
Comments appreciated.

Discussion

  • Nate Mendel

    Nate Mendel - 2005-02-13

    Site Editor

     
  • Nobody/Anonymous

    Logged In: NO

    I cannot get it working...

     
  • Stefan Baader

    Stefan Baader - 2005-08-31

    Logged In: YES
    user_id=715666

    Great script. I added a small feature: after selecting the
    page, the select field now remembers which page was selected:

    <?php
    /*
    * FCKeditor - The text editor for internet
    * Copyright (C) 2003-2004 Frederico Caldeira Knabben
    *
    * Licensed under the terms of the GNU Lesser General Public
    License:
    * http://www.opensource.org/licenses/lgpl-license.php
    *
    * For further information visit:
    * http://www.fckeditor.net/
    *
    * File Name: edit.php
    * Example of using FCKEditor to modify web pages.
    *
    * File Author:
    * Nathan Mendel (natesneat2000@hotmail.com)
    * Based on the PHP sample files written by Frederico
    Caldeira Knabben (fredck@fckeditor.net)
    */

    /* Instructions:
    1. Upload edit.php, editor.css, and pages.txt in the root
    FCKEditor directory. You can delete the _docs and _samples
    folders.
    2. In pages.txt, put the names of all your pages, each on
    seperate lines, in this format: FriendlyName-filename.htm.
    3. Change the two variables below to the directory where
    your editable (content) pages and original copies of these
    pages are.
    4. Password protect the FCKEditor directory.
    5. CHMOD the content pages 777.
    */

    $contentDir = "../FCKeditor_2.0_content/";
    $contentOrigDir = "../FCKeditor_2.0_contentOrig/";

    include("fckeditor.php") ;

    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
    Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta name="robots" content="noindex, nofollow">
    <meta http-equiv="Content-Type" content="text/html;
    charset=iso-8859-1">
    <title>Site Editor</title>
    <link href="editor.css" rel="stylesheet" type="text/css">
    </head>

    <body>
    <p class="title">Site Editor</p>
    <form name="pageSelect" method="post" action="edit.php">
    <input type="hidden" name="edit" value="set">
    <p>First, select the page you wish to modify:
    <select name="page" class="nav">
    <?php
    // Adapted from http://us2.php.net/file
    $lines = file('pages.txt');
    // Loop through our array, show HTML source as HTML
    source; and line numbers too.
    foreach ($lines as $line_num => $line) {
    $thisline=explode("-",$line);
    if($_POST['page']==$thisline[1]){
    $selected=" selected";
    }else{
    $selected="";
    }
    echo "<option value='".$thisline[1]."'
    ".$selected.">".$thisline[0]."</option>";
    }
    ?>
    </select>
    <input name="Submit" type="submit" class="dingbat"
    value="Submit">
    </p>
    <p>Notes:</p>
    <ul><li>After submitting, FCKEditor will take a few
    moments to load. </li>
    <li>If you navigate away from this page, you may need to
    push Submit again to load it. </li>
    <li>Quotes and apostrophes (' and &quot;) are currently
    escaped with a / in front of them; this is a known issue.</li>
    </ul>
    </form>

    <?php
    if (isset($_POST['page'])) {
    if (isset($_POST['edit'])) {
    ?>
    <form name="FCKEditor" method="post" action="edit.php">
    <p>
    <input type="hidden" name="save" value="<?php echo
    $_POST['page'];?>">
    <?php
    $oFCKeditor = new FCKeditor('FCKeditor1') ;
    $oFCKeditor->BasePath = '' ;
    $oFCKeditor->Value = implode('', file($contentDir .
    $_POST['page']));
    $oFCKeditor->Create() ;
    ?>
    </p>
    <p>
    <input name="Submit" type="submit" class="dingbat"
    value="Save Page Modifications">

    </p>
    </form>

    <SCRIPT LANGUAGE=JAVASCRIPT>
    // Code adapted from
    http://www.webreference.com/programming/javascript/confirm/2.html
    function verify(){
    msg = "This will delete all modifications to the page
    selected; are you sure? This cannot be undone!";
    //all we have to do is return the return value of the
    confirm() method
    return confirm(msg);
    }
    </SCRIPT>
    <p>To save your changes, press the either the Save button
    on the FCKEditor toolbar above or the Save Page
    Modifications button.</p>
    <p>An original copy of each page was made during the setup
    of you website, with none of your changes made. This is
    helpful if you made unrecoverable changes to a page. You can
    <a href="<?php echo $contentOrigDir.$_POST['page'];?>">view
    the original copy</a> (will not make any changes to your
    site), or restore the page to the original state, deleting
    any changes you've made, below. </p>
    <form name="restore" method="post" action=""
    onSubmit="return verify()">
    <input type="hidden" name="restore" value="<?php echo
    $_POST['page'];?>">
    <input name="Submit" type="submit" class="dingbat"
    value="Restore page">
    </form>
    <p>
    <?php
    }} // if editing
    ?>

    <?php
    if (isset($_POST['save'])) {
    $html = $_POST['FCKeditor1'] ;

    $myfile = fopen($contentDir.$_POST['save'],"w");
    fwrite($myfile, $html);
    fclose($myfile);
    ?>
    Assuming you see no errors above, your <a href="<?php echo
    $contentDir.$_POST['save'];?>">file</a> should now be
    modified. To edit another file, select it above.
    <?php
    } //if saving
    ?>

    <?php
    if (isset($_POST['restore'])) {
    $html = implode('', file($contentOrigDir .
    $_POST['restore']));

    $myfile = fopen($contentDir.$_POST['restore'],"w");
    fwrite($myfile, $html);
    fclose($myfile);
    ?>
    Assuming you see no errors above, your <a href="<?php echo
    $contentDir.$_POST['page'];?>">file</a> should now be
    restored to its original state. To edit or restore a file,
    select it above.
    <?php
    } //if restoring
    ?>

    </p>
    <p>&nbsp;</p>
    </body>
    </html>

     
  • Nobody/Anonymous

    Logged In: NO

    Hi, i think your quote bug is the magicquotes setting in PHP.

    Try using:

    $html = stripslashes($_POST['FCKeditor1']);

    instead of:

    $html = $_POST['FCKeditor1'] ;

    Then it should work!

    Great script by the way. Simple but effective! Nice work.

     
  • Nate Mendel

    Nate Mendel - 2006-12-11

    Logged In: YES
    user_id=683890
    Originator: YES

    Wow, I didn't notice the e-mails about this patch until now. I'm very glad that you all like my little patch!
    If I have time, I will make a new zip with these 2 patches applied, and maybe some other minor improvements.
    Thank you all for your comments!

     

Log in to post a comment.

MongoDB Logo MongoDB