EzDevInfo.com

RunKit

A Swift Wrapper for Grand Central Dispatch (GCD) Framework that supports method chaining

PHP Runkit Sandbox in iFrame

Would it be possible for me to make an iFrame run PHP using Runkit_Sandbox so that its safe and doesn't effect the server. For example if I update the contents of the iFrame with php code, it will be run through Runkit Sandbox making it not part of the server essentially.

Is this possible and what would the code be like?


Source: (StackOverflow)

How do I disable runkit?

I want to temporarily disable runkit (or temporarily disable a PECL extension). Do somebody know how to do that?


Source: (StackOverflow)

Advertisements

PHP - Alternatives to runkit for intercepting method calls

I have some very test-unfriendly code (to say the least) that I need to test. Refactoring unfortunately is not an option. I have to test the code as it is, without the possibility of changing it.

To do that, I was thinking of intercepting function calls and dynamically change what they do so I can run my tests, as I need some functions and methods to return known values, and I need others that make requests, connect to the database, etc, to stop doing that and return what I need them to return. Is there any way to do this without runkit_method_redefine(), which is preferably not "EXPERIMENTAL" and still maintained? Maybe an alternative to runkit? Maybe a better way?

Edit: will use PHPUnit's test doubles and PHP 5.3.2's features for making private methods accessible, if I need that functionality.


Source: (StackOverflow)

Can someone compile PHP runkit DLL extension for me?

I give up. I've asked this question some time ago but I'm again into that issue. I'm still stuck with compilation errors / missing files / other stuff that I can't / don't have time to fix. Don't get me wrong - I've compiled it several times, but none of the DLL files I've got worked. I use WAMPServer 2.1e [Apache 2.2.17, PHP 5.3.5] - after enabling php_runkit it does not start. Even already compiled DLLs from the Internet haven't worked. Another time Windows seems to be simply against me.

Now as a programmer I feel really, really lame to ask you the following: can someone compile PHP runkit DLL extension for me or point me to the WORKING one? Please test if it works and provide your WAMP stack configuration, so I can adjust mine.

You would be my hero.


Source: (StackOverflow)

Where can I get runkit DLL extensions for PHP 5.3+?

That is a quick question: Where can I get PHP's runkit extension for version 5.3+? Manual for it:

http://php.net/manual/en/book.runkit.php

I am searching for DLL version, as I am trying to play with it on Windows. I've searched snaps.php.net, Googled it, but no luck.

Can you point me to the right location or upload it somewhere?


Source: (StackOverflow)

Execute user request in a runkit sandbox session

I have an environment where users upload php projects, something similar to that for a shared hosting.

User's code will have nothing to do with Runkit. Their code has to be executed in my runkit environment.

Is it possible to have a Request handler for lighttpd where I can create an runkit sandbox and execute user's request.


Source: (StackOverflow)

Use Runkit_Sandbox in lampp

I want to use the sandboxing of the extension runkit. From README file

Sandboxing is ONLY AVAILABLE in PHP 5.1 (release version, or snapshot dated
after April 28th, 2005) when thread safety has been enabled.

The version of PHP in my lampp is 5.4.7 which should be OK but its Thread Safety is disabled. From phpinfo() we can see the runkit is installed but its Sandbox Support is disabled or unavailable. So when I try to use the Runkit_Sandbox class, an error came out

Fatal error: Class 'Runkit_Sandbox' not found 

I don't really what to do now.. Is it possible to use Runkit_Sandbox class in my lampp?


Source: (StackOverflow)

runkit compile error against php 5.3.8?

It gives me a compile error against 5.3.8. I run phpize, then configure and then make:

/bin/sh /root/runkit/runkit-0.9/libtool --mode=compile cc  -I. -I/root/runkit/runkit-0.9 -DPHP_ATOM_INC -I/root/runkit/runkit-0.9/include -I/root/runkit/runkit-0.9/main -I/root/runkit/runkit-0.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/runkit/runkit-0.9/runkit.c -o runkit.lo 
mkdir .libs
 cc -I. -I/root/runkit/runkit-0.9 -DPHP_ATOM_INC -I/root/runkit/runkit-0.9/include -I/root/runkit/runkit-0.9/main -I/root/runkit/runkit-0.9 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/runkit/runkit-0.9/runkit.c  -fPIC -DPIC -o .libs/runkit.o
/root/runkit/runkit-0.9/runkit.c: In function ‘zif_runkit_zval_inspect’:
/root/runkit/runkit-0.9/runkit.c:61: error: ‘zval’ has no member named ‘refcount’
/root/runkit/runkit-0.9/runkit.c:62: error: ‘zval’ has no member named ‘is_ref’
/root/runkit/runkit-0.9/runkit.c: In function ‘zm_deactivate_runkit’:
/root/runkit/runkit-0.9/runkit.c:360: warning: passing argument 2 of ‘zend_hash_apply’ from incompatible pointer type
/root/runkit/runkit-0.9/runkit.c:370: warning: passing argument 2 of ‘zend_hash_apply’ from incompatible pointer type
/root/runkit/runkit-0.9/runkit.c:378: warning: passing argument 2 of ‘zend_hash_apply_with_arguments’ from incompatible pointer type
make: *** [runkit.lo] Fehler 1


Source: (StackOverflow)

Php runkit_import and final classes

I read here: http://osdir.com/ml/php.phpunit.user/2008-05/msg00009.html that changing a class final behaviour may be changed with runkit - I just cant see the way how.

EDIT: dont -1 me pls, I checked the runkit_import() function and also the http://php.net/manual/en/runkit.constants.php still cant find the way


Source: (StackOverflow)

Runkit Sandbox: use parent's class instances?

The following code...

function getInstance() {
  echo "(getInstance() called)\n";

  return new TestClass();
}

class TestClass {
  function someMethod() {
    echo "someMethod called. Awesome!\n";
  }
}

$sandbox = new Runkit_Sandbox();
$sandbox['parent_access'] = true;
$sandbox['parent_call'] = true;

$sandbox->eval(
  '$PARENT = new Runkit_Sandbox_Parent; '.
  '$PARENT->getInstance()->someMethod();'
);

leads to this output on my PHP 5.4.10 build:

(getInstance() called)
PHP Warning:  Runkit_Sandbox::eval(): Error executing sandbox code in /home/projpf/_test/sandbox_test2.php on line 24

Apparently it's not possible to call a method from within the sandbox that has been declared outside the sandbox. Is this a restriction of Runkit or am I doing something wrong?

In case you're wondering what I'm trying to do: I'd like to convert my PHP web scripts to long-running workers accepting HTTP requests via RabbitMQ. Those scripts sometimes have to do heavy initializations that could be cached as variables but not via any external cache. A sandbox would allow the worker process to load the correct handler script without leaving any traces - except for that data that should be explicitely cached, which in this case would be a high number of class instances.


Source: (StackOverflow)

remove non-user constant php

I'm trying to remove the STDIN constant for debugging purposes, however

phpdbg> ev runkit_constant_remove('STDIN')
[PHP Warning:  runkit_constant_remove(): Only user defined constants may be removed. in eval()'d code on line 1]

So I would like to know whether there exists any way in php to remove these non-user constants.


Source: (StackOverflow)

How to rename or overwrite php function?

How i can redefine a function in php with runkit?

$helloWorld = 'echo "Call require_once";';
runkit_function_redefine('require_once', '$word', $helloWorld);
require_once("abc.php");

i seted in php.ini

runkit.internal_override=1

when i run, it show:

Warning: runkit_function_redefine() [function.runkit-function-redefine]: require_once() not found in hhd_debug.php on line 2

Warning: require_once(abc.php) [function.require-once]: failed to open stream: No such file or directory in hhd_debug.php on line 3

Fatal error: require_once() [function.require]: Failed opening required 'abc.php' (include_path='.;xampp\php\PEAR') in hhd_debug.php on line 3

how i can fix it? please help me!


Source: (StackOverflow)

How to restore function overwritten by runkit_function_redefine? Halt running php process mightbe?

Its ok that I redefine a function (lets suppose fsockopen) but I have no idea how to restore it.

EDIT: Im thinking of just halting and restarting the current running PhP process, that might restore everything


Source: (StackOverflow)

PHP Runkit support on shared hosts

I'm trying to decide whether I should use the runkit php extension for my scripts. The problem is that these scripts should work on the majority of hosts, including shared hosts. I couldn't find any numbers about the amount of hosts that support the runkit extension and even though I suspect it won't work on most shared hosts, I'd like to be certain. So does anyone have experience with runkit on (shared) hosts?

Thanks!


Source: (StackOverflow)

using override_function to add utf-8 to all of htmlenteties calls

I have an script that i want to change to Persian but this script has written by my colleague and he used htmlentities without utf-8 as argument.

I decided to use override_function and runkit , i managed to install runkit on my php and it works but cant figure out how to change this

htmlentities(LABEL__MAIN_INDEX_ADMIN, ENT_QUOTES)

to

htmlentities(LABEL__MAIN_INDEX_ADMIN, ENT_QUOTES , "UTF-8")

i know that i can use override to change htmlentities so when i call it utf-8 will be added automatically ! please help me


Source: (StackOverflow)