[PHP] Question about ereg_replace and urlencode...

2007-10-02 Thread Venkatesh M. S.
Hello!

i am trying to make links clickable on a page. I would like to
urlencode the URL so that it is well passed to a redirect.php file,
which would do somethings and then also do a meta http refresh

I am trying to use a function like the following, but it doesn't work.
I would like to apply urlencode on the link that is there in $str, so
that i have the link to redirect.php?url=<>

With the following, "1" gets hardcoded in my link! How do i urlencode it please?

Any thoughts would help

Regards

Venky

http://www.someserver.com/indexn12.asp?main_variable=EDITS&file_name=edit3%2Etxt&counter_img=3
blah blah';


function b_make_clickable ($str) {
  $str = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
'http://www.myserver.com/redirect.php?url=' . urlencode(1) .
'" target="_blank">\1', $str);
  $str = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
'\1http://www.myserver.com/redirect.php?url=http://' .
urlencode(2) . '" target="_blank">\2', $str);
  $str = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})','mailto:\1";>\1', $str);
  return $str;
}

?>

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



Re: [PHP] Question about ereg_replace and urlencode...

2007-10-02 Thread Venkatesh M. S.
Many thanks Stut

The problem is that the rest of the $str is actually a big post from a
blog, which will have many other text and info apart from the URL, and
i don't want to urlencode everything in there!

Venky

On 02/10/2007, Stut <[EMAIL PROTECTED]> wrote:
> Venkatesh M. S. wrote:
> > Hello!
> >
> > i am trying to make links clickable on a page. I would like to
> > urlencode the URL so that it is well passed to a redirect.php file,
> > which would do somethings and then also do a meta http refresh
> >
> > I am trying to use a function like the following, but it doesn't work.
> > I would like to apply urlencode on the link that is there in $str, so
> > that i have the link to redirect.php?url=<>
> >
> > With the following, "1" gets hardcoded in my link! How do i urlencode it 
> > please?
> >
> > Any thoughts would help
> >
> > Regards
> >
> > Venky
> >
> >  >
> > $str='blah blah
> > http://www.someserver.com/indexn12.asp?main_variable=EDITS&file_name=edit3%2Etxt&counter_img=3
> > blah blah';
> >
> >
> > function b_make_clickable ($str) {
> >   $str = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~#?&//=]+)',
> > 'http://www.myserver.com/redirect.php?url=' . urlencode(1) .
> > '" target="_blank">\1', $str);
> >   $str = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_+.~#?&//=]+)',
> > '\1http://www.myserver.com/redirect.php?url=http://' .
> > urlencode(2) . '" target="_blank">\2', $str);
> >   $str = eregi_replace('([_.0-9a-z-]+@([0-9a-z][0-9a-z-]+.)+[a-z]{2,3})',' > href="mailto:\1";>\1', $str);
> >   return $str;
> > }
> >
> > ?>
>
> That would be the bit where you use urlencode(1) to put the URL into the
> URL. I think you want urlencode($str) instead.
>
> -Stut
>
> --
> http://stut.net/
>

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



[PHP] popen and pclose. Something changed in 4.4.2 !

2006-06-12 Thread Venkatesh M. S.

Greetings!

I was using popen and pclose on a previous version of PHP on Windows with an
older version of Apache (2.x). ( I think it was 4.4.1 but will need to check
as i am not sure).

pclose(popen("start " . $exe . " " . $args, "r"))

Where $exe is my path to the batch file and $args are the arguments for the
batch file. The batch file, in turn calls other batch files on a shared
folder on a different PC

On Windows, it would open up the dos window and run commands there and exit
and the PHP script that called the pclose would terminate loading on the
users' browsers.

Now, with PHP 4.4.2, the pclose and popen send the tasks to the background
and the dos window does not show up! As a result, killing the dos process is
not possible (i get access denied in windows...) and the users cannot see
the dos window when it runs.

I would like the php script to send the commands to a dos window, and the
php script to finish executing. I tried passthru, system, exec and
proc_open... and none of them work. None of them bring up the dos window.

Please help!


Regards


Venkat


[PHP] popen and pclose. Something changed in 4.4.2 ! ....Fixed

2006-06-21 Thread Venkatesh M. S.

On windows, allow Apache service "to interact with the desktop"... in
the services manager GUI

Rgds

Venkat

**

Greetings!

I was using popen and pclose on a previous version of PHP on Windows with an
older version of Apache (2.x). ( I think it was 4.4.1 but will need to check
as i am not sure).

pclose(popen("start " . $exe . " " . $args, "r"))

Where $exe is my path to the batch file and $args are the arguments for the
batch file. The batch file, in turn calls other batch files on a shared
folder on a different PC

On Windows, it would open up the dos window and run commands there and exit
and the PHP script that called the pclose would terminate loading on the
users' browsers.

Now, with PHP 4.4.2, the pclose and popen send the tasks to the background
and the dos window does not show up! As a result, killing the dos process is
not possible (i get access denied in windows...) and the users cannot see
the dos window when it runs.

I would like the php script to send the commands to a dos window, and the
php script to finish executing. I tried passthru, system, exec and
proc_open... and none of them work. None of them bring up the dos window.

Please help!


Regards


Venkat