Re: Handling exit in eval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 14 March 2011 12:14, DELiTH <tb@xxxxxxxxxxx> wrote:
> Richard Quadling wrote:
>
>> 2011/3/14 Richard Quadling <rquadling@xxxxxxxxx>:
>>
>> And where is my UNDO button.
>>
>> Essentially, having exit in the eval code is no different to having it
>> in non-eval code. eval isn't a separate entity which can be
>> terminated.
>>
>> So, code the eval code differently.
>>
>> If you can provide some examples, maybe we can come up with a better solution.
>>
>>
>>
>
> I'm developing a kind of sandbox where you will be able to run a script
> without affecting your current context. The script is loaded and parsed
> which gives me the opportunity to allow or deny functions and classes
> used in the script.
> The only problem I have so far is the exit function which, it if is
> allowed, terminates the calling script as well as the eval'ed script.
>
> By using a return the problem is solved as long as the user doesn't
> write a function containing an exit.
>
> Here is a simple script thet the user might write (probably as useful as
> a "Hello, world!".
>
> <?php
> function DoSomethingOrExit($test) {
> Âif($test == 1) {
> Â Âexit;
> Â}
> Âreturn;
> }
>
> DoSomethingOrExit(0);
> echo "Hello";
> DoSomethingOrExit(1);
> echo ", world!";
> exit;
> echo "Bye";
> ?>
>
> By replacing exit with return this code will echo "Hello, world!" before
> returning without echoing "Bye".
>
>
> Another perfect solution would be if there was a way to trigger an error
> within the eval'ed script that "crashes" it and returns to the calling
> script. But then it just comes back to the entity-problem as you pointed
> out.
>
>
> /Thomas
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Why not just invoke a separate instance of PHP using exec() ?

Or take a look at runkit/runkit_Sandbox :
http://uk.php.net/manual/en/book.runkit.php

-- 
Richard Quadling
Twitter : EE : Zend
@RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

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




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux