Flatfile editinplace CMS (SOLVED)

I recently made a flatfile cms (+ edit in place). Here’s an example of how it shows the
's when hitting enter. The password is demo.

Now when you click inside (in any text field - there are 4), when hitting enter it makes a new line without showing a
tag. Clicking outside and inside the textarea, it will show all the line breaks you’ve made.

My question is how to hide the
tag. What I’ve searched, found and tried the following:

$content=nl2br($content); and $content = str_replace("<br>", "\n", $content);

Neither worked.

Also when using this code

$file1 = include '/ccms/files/edit.txt'; echo $file1; // This outputs the file.

to show the content on another page, it adds a number 1 to every textarea I have on the original page. You can see the number 1 error here.

Hi there,

I’m assuming you’ve called htmlentities() - in this case you way want to use:

$content = str_replace("&lt;br&gt;","\n",$content);

Let me know how it goes.

Thanks for the suggestion, but this still doesn’t solve my problem. Even after entering that the
's are still visible in the textarea.

Does this help you? If that’s what you meant by the html thingy.

[php]$fieldname = htmlspecialchars($_GET[‘fieldname’]);
[/php]
Any other suggestion?

Is $fieldname the data that’s being outputted into the textarea? If not what is that variable? And it’s origins?

Basically I’m assuming you have a setup like:

<?php
$area_contents = htmlspecialchars($content);
?>
<textarea><?php echo $area_contents; ?></textarea>

Long story short, what is the breakdown of variables and PHP used to output into that textarea (if I know the origin of the string, it’s much easier to work out where’s best to manipulate, and how).

What I’m using is:

[php]<?
$thefile = “files/edit.txt”; /THIS IS THE FIRST TEXT FILE/
$thefile2 = “files/edit2.txt”; /THIS IS THE SECOND TEXT FILE/
$thefile3 = “files/edit3.txt”; /THIS IS THE THIRD TEXT FILE/
$thefile4 = “files/edit4.txt”; /THIS IS THE THIRD TEXT FILE/

$textInfile = file_get_contents($thefile); /THIS IS THE FIRST TEXT FILE/
$textInfile2 = file_get_contents($thefile2); /THIS IS THE SECOND TEXT FILE/
$textInfile3 = file_get_contents($thefile3); /THIS IS THE THIRD TEXT FILE/
$textInfile4 = file_get_contents($thefile4); /THIS IS THE FOURTH TEXT FILE/

<? echo $textInfile; ?><>
<? echo $textInfile2; ?><>
<? echo $textInfile3; ?><>
<? echo $textInfile4; ?><> ?>[/php]

Everything put into the textarea is getting saved to http://krneky.com/ccms/files/edit.txt (there are 4 files and 4 text areas).

In the text area is says
. But when you look at the file lets say http://krneky.com/ccms/files/edit3.txt you can see there’s a
.

And this is kinda the setup:

[php]$fieldname = htmlspecialchars($_GET[‘fieldname’]);
$content = stripslashes(strip_tags($_GET[‘content’],"

  • "));
    $content = trim($content);
    $content=nl2br($content);[/php]

    I’m confused.

  • Hey, I tried your code:

    $content = stripslashes(strip_tags($_GET['content'],"<p><img><i></i></p><h1></h1><h2></h2></a><li></li><a><strong><em><strike><b>"));
    $content = trim($content);
    $content = nl2br($content);

    I got
    tags, but they went as soon as I commented out the nl2br() function. As for getting
    instead of
    - I was unable to replicate this issue. See if removing nl2br fixes it, if not i would be tempted to suggest re-coding the outputting/fetching of the data (taking note of the output as you do certain things to it)

    I’ve tried this in different variations, maybe this info will help you?

    How it all really works:
    It makes a textarea that is writable to a .txt file. I display this text area with: <div id="change"><span id="a1" class="editText"><? echo $textInfile; ?></span><>.
    This goes trough: [php]<?
    $thefile = “files/edit.txt”;
    $textInfile = file_get_contents($thefile);
    ?>[/php]
    This saves the file to edit.txt
    User enters content into the text area and it writes it directly to the txt file once the user clicks out of the area.

    So far the most efficient thing that worked (or not) is : [php]str_replace("
    ", “\n”, $content);[/php] This would be perfect if it didn’t disable
    's completely.

    Also another thing, when you click on the text area on http://krneky.com/ccms (password demo) the text area shows normal
    tags, while the ones saved in http://krneky.com/ccms/files/edit3.txt (the text files), shows
    .

    I have no idea what else is there to try.

    I’m also using

    Do you think any one of these may be causing problems?

    I also tried [php]<?php
    echo “

    ”;
    echo $file1;
    echo “
    ”;
    ?>[/php] but still no luck.

    Everyone, this cms is coming close to being published. Here we go: WonderCMS (password for the demo: admin)

    The problem was fixed by changing

    function editBox(actual) { if(!changing){ width = widthEl(actual.id) + 20; height =heightEl(actual.id) + 2; actual.innerHTML = "<textarea…" changing = true; } actual.firstChild.focus(); }

    to

    function editBox(actual) { if(!changing){ width = widthEl(actual.id) + 20; height =heightEl(actual.id) + 2; str = actual.innerHTML; actual.innerHTML = str.replace(/<br>/gi, ""); actual.innerHTML = "<textarea…" changing = true; } actual.firstChild.focus(); }

    The WonderCMS is now available for download: WonderCMS

    Cool, glad you got it sorted!

    Where’s it available from?

    I am not supposed to link it, (administrator marks it at spam). What can I say, just google wondercms krneky, I hope you find it. :slight_smile:

    Cheers…

    Sponsor our Newsletter | Privacy Policy | Terms of Service