Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

--TEST-- Check for eio fork support using pcntl --SKIPIF-- <?php if (!extension_loaded('pc..

Decoded Output download

--TEST--
Check for eio fork support using pcntl
--SKIPIF--
<?php
if (!extension_loaded('pcntl')) {
	die('SKIP The pcntl extension is not loaded');
}
?>
--FILE--
<?php
$str      = str_repeat('1', 20);
$filename = '/tmp/tmp_file' .uniqid();
$filename2 = '/tmp/tmp_file2' .uniqid();
@unlink($filename);
@unlink($filename2);
touch($filename);
touch($filename2);

$pid = pcntl_fork();
if ($pid == -1) {
	die('could not fork');
} else if ($pid) {
	eio_open($filename, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename, $fd) use ($str) {
		eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename) {
			printf("w: %d l: %d f: %d c: %d
",
				$written,
				strlen($str),
				filesize($filename),
				substr_count(file_get_contents($filename), '1'));
		}, $fd);
	}, $filename);
	eio_event_loop();

	// we are the parent
	pcntl_wait($status); //Protect against Zombie children

} else {
	// we are the child
	eio_open($filename2, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename2, $fd) use ($str) {
		eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename2) {
			printf("w: %d l: %d f: %d c: %d
",
				$written,
				strlen($str),
				filesize($filename2),
				substr_count(file_get_contents($filename2), '1'));
		}, $fd);
	}, $filename2);
	eio_event_loop();
}

@unlink($filename);
@unlink($filename2);
?>
--EXPECT--
w: 20 l: 20 f: 20 c: 20
w: 20 l: 20 f: 20 c: 20

Did this file decode correctly?

Original Code

--TEST--
Check for eio fork support using pcntl
--SKIPIF--
<?php
if (!extension_loaded('pcntl')) {
	die('SKIP The pcntl extension is not loaded');
}
?>
--FILE--
<?php
$str      = str_repeat('1', 20);
$filename = '/tmp/tmp_file' .uniqid();
$filename2 = '/tmp/tmp_file2' .uniqid();
@unlink($filename);
@unlink($filename2);
touch($filename);
touch($filename2);

$pid = pcntl_fork();
if ($pid == -1) {
	die('could not fork');
} else if ($pid) {
	eio_open($filename, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename, $fd) use ($str) {
		eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename) {
			printf("w: %d l: %d f: %d c: %d\n",
				$written,
				strlen($str),
				filesize($filename),
				substr_count(file_get_contents($filename), '1'));
		}, $fd);
	}, $filename);
	eio_event_loop();

	// we are the parent
	pcntl_wait($status); //Protect against Zombie children

} else {
	// we are the child
	eio_open($filename2, EIO_O_RDWR, 0, EIO_PRI_DEFAULT, function($filename2, $fd) use ($str) {
		eio_write($fd, $str, strlen($str), 0, 0, function($fd, $written) use ($str, $filename2) {
			printf("w: %d l: %d f: %d c: %d\n",
				$written,
				strlen($str),
				filesize($filename2),
				substr_count(file_get_contents($filename2), '1'));
		}, $fd);
	}, $filename2);
	eio_event_loop();
}

@unlink($filename);
@unlink($filename2);
?>
--EXPECT--
w: 20 l: 20 f: 20 c: 20
w: 20 l: 20 f: 20 c: 20

Function Calls

str_repeat 1
extension_loaded 1

Variables

None

Stats

MD5 b54a09af2daec0e12878ef4d707f85ea
Eval Count 0
Decode Time 115 ms