Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php function sub($i, $ch) { for (;;) { // receive the message from $ch ..
Decoded Output download
<?php
function sub($i, $ch) {
for (;;) {
// receive the message from $ch
$a = thread_message_queue_poll($ch);
// TRIPLE COMPARISION IS IMPORTANT!!!!
if($a === 'PHP_THREAD_POLL_STOP') {
break;
}
printf("thread %02d: %02s
", $i, $a * 2);
}
sleep(2);
printf("thread %02s is done.
", $i);
}
$ch = thread_message_queue_create();
for ($i = 0; $i < 20; $i++) {
$rs[] = thread_create('sub', $i, $ch);
}
for ($i = 0; $i < 20;$i++) {
// send $i to $ch
thread_message_queue_post($ch, $i);
usleep(200000);
}
// threads are still waiting for a message. tell them that we are stopping
thread_message_queue_stop($ch);
// after threads recieve the stop message, they break out of the for loop and sleep
echo "Done sending messages. Threads are sleeping for 2 seconds.
";
foreach ($rs as $val) {
// thread_join waits for the the thread to finish before continuing
thread_join($val);
}
echo "All threads are complete."; ?>
Did this file decode correctly?
Original Code
<?php
function sub($i, $ch) {
for (;;) {
// receive the message from $ch
$a = thread_message_queue_poll($ch);
// TRIPLE COMPARISION IS IMPORTANT!!!!
if($a === 'PHP_THREAD_POLL_STOP') {
break;
}
printf("thread %02d: %02s\n", $i, $a * 2);
}
sleep(2);
printf("thread %02s is done.\n", $i);
}
$ch = thread_message_queue_create();
for ($i = 0; $i < 20; $i++) {
$rs[] = thread_create('sub', $i, $ch);
}
for ($i = 0; $i < 20;$i++) {
// send $i to $ch
thread_message_queue_post($ch, $i);
usleep(200000);
}
// threads are still waiting for a message. tell them that we are stopping
thread_message_queue_stop($ch);
// after threads recieve the stop message, they break out of the for loop and sleep
echo "Done sending messages. Threads are sleeping for 2 seconds.\n";
foreach ($rs as $val) {
// thread_join waits for the the thread to finish before continuing
thread_join($val);
}
echo "All threads are complete.";
Function Calls
thread_message_queue_create | 1 |
Stats
MD5 | 9c496f005af833216b5e64bb366a9240 |
Eval Count | 0 |
Decode Time | 82 ms |