client edidit of text inlcude

Found it…

The space and feed are in (between) the script PHP quotes. And I did not spot it.

It’s the way HTML writes the content for a text area. Plain text before closing with

all fixed


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Walt,

print nl2br(htmlentities(file_get_contents($fn)));

Does not work, it creates (adds)
to every line ending, at every read/save of the text area contents of the file. Read five times, add and saves x5
's to every line.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’m confused here, then. Are you using print() to display to the
page, or to write into your text file?

Here’s how a form should be used to write into a file:

//set your text variable to nothing
$text = '';
if(isset($_POST['your_textarea'])){
	//get the textarea into your variable
	$text = trim(strip_tags($_POST['your_textarea']));
	if(strlen($text > 0 && $text_file = fopen('yourtextfile.txt',w)){
		//open the text file for OVERWRITE
		//only if there is something to write
		fwrite($text_file,$text,strlen($text));
		fclose($text_file);
		//redirect to self (clears the form input from the buffer)
		header("Location: http://" . $_SERVER['HTTP_HOST'] . $_SERVER 

[‘REQUEST_URI’]);
}
}

Then go ahead and read in the file and output it with breaks added to
the newlines. But don’t write the breaks into your file! They’re only
meaningful in the context of HTML, not text.

Walter

On Jan 21, 2008, at 10:42 AM, dwn wrote:

Walt,

print nl2br(htmlentities(file_get_contents($fn)));

Does not work, it creates (adds)
to every line ending, at
every read/save of the text area contents of the file. Read five
times, add and saves x5
's to every line.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Both, I’m using Print () to populate the textarea, and I think it deletes all content in the file. Then when the form button is pressed the content of the textarea is written to the file.

I’ve amended the code I was originally using to include this:

function nl2br2($content) {
$content = str_replace(array("rn", "r", "n"), "<br />", $content);
return $content;
}

Which correctly tidies up the display of line feeds of the text.txt file in the textarea.

But…

Just need to do the same in the other web page where the text.txt file is shown as a PHP include. Here the line feed do not appear unless I add
back in the textarea edit

How do I convert the text.txt file line ending to meaningful viewable HTML line returns? (without having to write HTML code in the textarea used for editing)


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I’ll try this as well

On 21 Jan. 2008, 3:05 pm, waltd wrote:

Here’s how a form should be used to write into a file:


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks Walter.

$text = file_get_contents('file.txt');
$text = nl2br($text);
print $text;

Works perfectly.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Interestingly as a spin off - this method can be used to edit page title, meta tag, page description etc. By leaving PHP <? print $text; ?> in various places in Freeway (it works by the way although a bit odd having a Freeway Page called <? print $text; ?>). It plugs a gap in WebYep, which lacks these features so far.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

At 09:37 -0500 21/1/08, Walter Lee Davis wrote:

This and the other errors you are seeing sound a lot like you have
Mac line-endings on your file, and are running this on a Unix server.
Mac line-endings are rn (return + newline) while Unix line-endings
are simply n (newline).

Actually, Mac is r.
rn is Windows and systems that were designed to drive teletypes.

David


David Ledger - Freelance Unix Sysadmin in the UK.
HP-UX specialist of hpUG technical user group (www.hpug.org.uk)
email@hidden
www.ivdcs.co.uk


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options