RE: [PHP] Word Wrap on highlight_file

2008-01-20 Thread Shelley Shyan

One solution I can think of is:
  $showCode = highlight_file($fileWithPath, true);
  echo str_replace('', "\n", $showCode);

It may not be the best one. But it's not recommanded to use
   echo wordwrap($showCode, 70);
Because you may break  into something like


Regards,
Shelley

-Original Message-
From: Tom Chubb [mailto:[EMAIL PROTECTED]
Sent: Wednesday, January 16, 2008 9:02 PM
To: PHP General List
Subject: [PHP] Word Wrap on highlight_file

Can anyone tell me how to wrap the results of highlight_file so it doesn't mess 
up the size of my table div?
I tried the following and doesn't work!


if ($ext == "phps") {
   $showcode = highlight_file($pathtoscripts . $_GET['file']);
   echo wordwrap($showcode, 70);
} else {
   echo "Nice try, but you are not authorised to view the source of files with 
a $ext extension! ;)\n"; }

Thanks,

Tom

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: 
http://www.php.net/unsub.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Word Wrap on highlight_file

2008-01-16 Thread Jochem Maas

Tom Chubb schreef:

On 16/01/2008, Jochem Maas <[EMAIL PROTECTED]> wrote:

Tom Chubb schreef:


...






Jochem,
Thanks for that. So presumably it's not possible to do it in PHP?


there probably is but I can't tell what the problem is exactly without
seeing the output source and rendering, that said I still recommend
CSS given the adage "use the right tool for the job"



Haven't come across array_pop before - that's much quicker than what I
was doing before. Thanks :)

And thanks for the pointers about sanitizing. That was my next step!



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Word Wrap on highlight_file

2008-01-16 Thread Tom Chubb
On 16/01/2008, Jochem Maas <[EMAIL PROTECTED]> wrote:
> Tom Chubb schreef:
> > Can anyone tell me how to wrap the results of highlight_file so it
> > doesn't mess up the size of my table div?
>
> use CSS to control the visual display in the browser.
> not to mention that 'table div' doesn't make much sense as a concept.
>
> probably you'll want to do something with the CSS property 'overflow'.
>
> > I tried the following and doesn't work!
> >
> >
> > if ($ext == "phps") {
> >$showcode = highlight_file($pathtoscripts . $_GET['file']);
>
> you are not santizing the request data, you need to be doing something
> like the following (maybe someone else can check my example and
> offer even better sanitizing code?):
>
>
> $file = basename($_GET['file']);
>
> if (!$file) die('nice try');
>
> $ext  = explode('.', $file);
> $ext  = array_pop($ext);
>
> if ($ext != 'phps') die('nice try');
>
> $file = $pathtoscripts . basename($_GET['file']);
>
> if (is_dir($file) || !is_readable($file)) die('nice try');
>
>
>
> >echo wordwrap($showcode, 70);x
> > } else {
> >echo "Nice try, but you are not authorised to view the source of
> > files with a $ext extension! ;)\n";
> > }
> >
> > Thanks,
> >
> > Tom
> >
>
>
Jochem,
Thanks for that. So presumably it's not possible to do it in PHP?

Haven't come across array_pop before - that's much quicker than what I
was doing before. Thanks :)

And thanks for the pointers about sanitizing. That was my next step!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Word Wrap on highlight_file

2008-01-16 Thread Jochem Maas

Tom Chubb schreef:

Can anyone tell me how to wrap the results of highlight_file so it
doesn't mess up the size of my table div?


use CSS to control the visual display in the browser.
not to mention that 'table div' doesn't make much sense as a concept.

probably you'll want to do something with the CSS property 'overflow'.


I tried the following and doesn't work!


if ($ext == "phps") {
   $showcode = highlight_file($pathtoscripts . $_GET['file']);


you are not santizing the request data, you need to be doing something
like the following (maybe someone else can check my example and
offer even better sanitizing code?):


$file = basename($_GET['file']);

if (!$file) die('nice try');

$ext  = explode('.', $file);
$ext  = array_pop($ext);

if ($ext != 'phps') die('nice try');

$file = $pathtoscripts . basename($_GET['file']);

if (is_dir($file) || !is_readable($file)) die('nice try');




   echo wordwrap($showcode, 70);x
} else {
   echo "Nice try, but you are not authorised to view the source of
files with a $ext extension! ;)\n";
}

Thanks,

Tom



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Word Wrap on highlight_file

2008-01-16 Thread Tom Chubb
Can anyone tell me how to wrap the results of highlight_file so it
doesn't mess up the size of my table div?
I tried the following and doesn't work!


if ($ext == "phps") {
   $showcode = highlight_file($pathtoscripts . $_GET['file']);
   echo wordwrap($showcode, 70);
} else {
   echo "Nice try, but you are not authorised to view the source of
files with a $ext extension! ;)\n";
}

Thanks,

Tom

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] word wrap

2001-09-12 Thread nayco

http://php.net/manual/en/function.wordwrap.php


(°-Nayco,
//\[EMAIL PROTECTED]
v_/_ http://nayco.free.fr


- Original Message -
From: Justin French <[EMAIL PROTECTED]>
To: php <[EMAIL PROTECTED]>
Sent: Wednesday, September 12, 2001 3:39 AM
Subject: [PHP] word wrap


> Hi,
>
> I'm having trouble with some email clients not wrapping text.  So, what
> I'd like to do is create a wrap function which enables me to wrap a long
> text string at say 60 characters, by inserting a \n.  Of course I don't
> want to wrap RIGHT ON 60 chars, I want to wrap at the space just before
> the 60 characters, so I don't break words.
>
> Any advice welcome!!
>
>
> Justin French
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] word wrap

2001-09-11 Thread Justin French

Hi,

I'm having trouble with some email clients not wrapping text.  So, what
I'd like to do is create a wrap function which enables me to wrap a long
text string at say 60 characters, by inserting a \n.  Of course I don't
want to wrap RIGHT ON 60 chars, I want to wrap at the space just before
the 60 characters, so I don't break words.

Any advice welcome!!


Justin French

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]