Embedded text editor??

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
MeesterCat
Forum Newbie
Posts: 2
Joined: Sun Nov 21, 2004 3:58 pm

Embedded text editor??

Post by MeesterCat »

For a student project I am creating an online php tutorial.

The idea being that there will be an example snippet of php demonstrating what is to be done (perhaps a very basic array) and then asking the user to have a go at coding it themselves.

Is there a way of allowing the user to write and 'compile' the code within the page and not have to use a separate text editor?

Or is this wishful thinking?!

Any thoughts would be appreciated (I am new to php!)...
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

[php_man]exec()[/php_man]
Watch out, it's VERY dangerous!

For example, what if instead creating and outputting a basic array, the user were to use the unlink() function? Or some other malicious code? What you are saying can be done, but I'd be very careful if I were you.
User avatar
Slippy
Forum Contributor
Posts: 113
Joined: Sat Jul 12, 2003 11:31 pm
Location: Vancouver eh!

Post by Slippy »

I agree with evil monkey; it is very dangerous to do this; you may be able to get away with it if you look for dangerous functions before compiling and return an error if anything is found. Although I can think of creative ways to hose your web server just using an echo function... like echo'ing out the database username and password.

Wishful thinking... or very trusting.
Last edited by Slippy on Mon Nov 22, 2004 6:33 pm, edited 1 time in total.
MeesterCat
Forum Newbie
Posts: 2
Joined: Sun Nov 21, 2004 3:58 pm

Post by MeesterCat »

Cheers guys!

A couple of things i totally hadnt thought of...

Looks like a hasty re-design is in order!
Post Reply