NYCPHP Meetup

NYPHP.org

[nycphp-talk] Fw: I need my PHP script to call a TCL proc

Hans Zaunere zaunere at yahoo.com
Mon Jan 27 10:47:49 EST 2003


--- Tracy <tech_learner at yahoo.com> wrote:
> 
> No reply to tis mail and my mail too....
> If u can call a tcl prog from a phpscript, can u also call c programs?

http://www.php.net/manual/en/ref.exec.php

Just be careful with cleaning any user data that you pass to the shell -
people can do some real nasty things, and in fact, I never pass things
directly to a command line, even with proper escaping.  I generally push it
through some strcmp() or switch() statements, so I know exactly what's up.

> like i already posted, does any one know how to go about cgi programming in
> php?

Sure.. just like you would in Perl or anything else.  Compile PHP with
--enable-cgi (although you should double-check ./configure --help that I'm
correct) and off you go.  There's loads of documentation on the web
concerning CGI techniques, etc., of which I'm not familiar with.  I always
use mod_php, which I recommend if the environment permits.

>  Phil Powell <soazine at erols.com> wrote:
> > It's either that my PHP script call a working TCL proc that converts
> > all string text that looks like a URL ("http://...") into a hyperlink,
> > or does someone have a PHP equivalent to do it? My PHP function
> > VALIDATE_URL fails to do any conversion in its regexp, however, the
> > TCL proc works every time, and the matching pattern is nearly
> > identical in both!
> >
> > TCL:
> >
> > proc VALIDATE_URL {contents} {
> > regsub -all "\\\
" $contents "
> " contents
> > regsub -all {\\.{2,}} $contents {. .} contents
> > regsub -all
> {(http://([a-zA-Z0-9_\\-]+\\.)+(/[a-zA-Z0-9_\\-\\.\\~\\^,%\\+]+)*[^<\\(\\)>
> > ]+)} $contents "> style='text-decoration:none'>\\\\1" contents
> > regsub -all {\\. \\.} $contents {..} contents
> > return $contents
> > }
> >
> > PHP:
> >
> > function VALIDATE_URL($contents) {
> > $contents = preg_replace("/\\\
/e", '
> ', $contents);
> > $contents = preg_replace('/\\.{2,}/e', '. .', $contents);
> > $contents =
>
preg_replace('/http[s]?:\\/\\/\\([a-zA-Z0-9_\\-]+\\.\\)+\\(\\/[a-zA-Z0-9_\\-\\.\\~\\^,%\\
> +]+\\)*[^<\\\\(\\\\)>
> > ]+\\)/ei', "\\\\\\\\1", $contents);
> > return preg_replace('/\\. \\./e', '..', $contents);
> > }
> >
> > So who wins, TCL or PHP?

Whew, no idea.  Icky regular expressions, but see link above for external
program execution.


=====
Hans Zaunere
President, New York PHP
http://nyphp.org
hans at nyphp.org



More information about the talk mailing list