Recent Topics

1 Aug 06, 2004 23:06    

Hi,

I would like to display in _main.php an external .txt file from another domain/server.
To achieve this I used the code below :


<a href="<?php $Blog->disp('staticurl', 'raw') ?>?disp=extratext">ExtraText</a>

<?php
switch($disp)
{case 'extratext':
include("http://www.domain.com/extratext.txt");
break;}
?>

But this displays a brut unformatted text, mean without lines/double-lines breaks.
I did a quick search on php.net functions list but I really don't know what function to use or if it's even possible.

2 Aug 07, 2004 00:45

Well, yeah... It's displaying a text file. That's how they display.

Why are you linking to the staticurl, and not to the regular url? (Better yet, use the add_param function.)

By the way, including a remote file based on the url parameter can be HIGHLY insecure. Make sure you're careful!

3 Aug 07, 2004 01:41

isaac wrote:

Well, yeah... It's displaying a text file. That's how they display.

huh ? .txt files displays without lines breaks ?
When my browser displays that file :
http://turtle.ee.ncku.edu.tw/openwebmail/doc/readme.txt
I see the line breaks and it's quite an easy to read document,
so I don't understand what you meant.

How can I keep the line breaks in the skin ?

Better like this ?

<?php echo url_add_param(get_bloginfo('blogurl'),'disp=extratext');?>

The file is remote for now but at the end both the file and the skin will be on the same server.

4 Aug 07, 2004 02:31

When you use an include, all it does is add the text to the source exactly as it is in the file. Carriage returns and blank lines are ignored in html, which is why you use the <br> tag to start a new line. Someone cleverer than me could possibly write a function to substitute a blank line with <br><br>, or else you'll need to save the file in html format.

5 Aug 07, 2004 09:42

<?php
switch($disp)
{
	case 'extratext':
	echo '<pre>';
	include("http://www.domain.com/extratext.txt");
	echo '</pre>';
	break;
}
?> 

7 Aug 09, 2004 08:08

Just another FYI:
You could also wrap it in any element that had the "white-space:pre" CSS property applied to it. The PRE tag has this by default. (PRE stands for PRE-formatted - i.e., "I already formatted this in the source, just spit it out as-is.")


Form is loading...