Re: Executing php code within a string
| From: | Julio Nobrega Trabalhando | Date: | Thu, 08 Nov 2001 20:28:09 +0000 |
| Subject: | Re: Executing php code within a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-73946@lists.php.net to get a copy of this message | ||
eval();
But you should be VERY careful, limiting what things they can put inside
<?php ?>.
It's easier to allow just some functions to run.
Or, you could do somekind of an interpreter. Allow them to put things
inside a special tag, and special commands.
Say for example your opening tag is:
<|CH
Closing:
|>
Then you make available to them certain 'functions'. For example:
<|CH current_date |>
Would display the current date.
It's more secure, and I mean MUCH more secure than using eval(); since you
will have control of what appears inside <|CH |>, but a little workier to
implemet.
Or maybe I am reinventing the wheel on this....
--
Julio Nobrega
A hora está chegando:
http://toca.sourceforge.net
"Chris Hobbs" <chobbs@silvervalley.k12.ca.us> wrote in message
news:3BEAE760.5070604@silvervalley.k12.ca.us...
> I've a simple content management system which allows users to use full
> html within their submitted items. I then output the data by pulling the
> info out of a db and simply echo'ing it to the browser.
>
> Anyway, I'd like to make some php functionality available to them, so I
> would like them to be able to enter something like the following:
>
> <h2> The date is <? echo date("m-d-Y")?>.</h2>
>
> This would later be pulled out from the database and sent to the browser
as:
>
> <h2> The date is 11-08-2001.</h2>
>
> Right now, of course, I simply echo the <? ... ?> and not the result.
>
> Any ideas on how to process the php component before I echo it?
>
> --
> _______ ___ _ ____ _____
> Chris Hobbs / ____\ \ / / | | |/ ___\| __ \
> Head Geek | (___ \ \ / /| | | | (___ | | | |
> WebMaster \___ \ \ \/ / | | | |\___ \| | | |
> PostMaster ____) | \ / | |__| |____) | |__| |
> \____/ \/ \____/ \____/|_____/
> http://www.silvervalley.k12.ca.us
> chobbs@silvervalley.k12.ca.us
>