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-- registerCancelCallback --EXTENSIONS-- zip --SKIPIF-- <?php /* $Id$ */ if (!method..
Decoded Output download
--TEST--
registerCancelCallback
--EXTENSIONS--
zip
--SKIPIF--
<?php
/* $Id$ */
if (!method_exists('ZipArchive', 'registerCancelCallback')) die('skip libzip too old');
?>
--INI--
date.timezone=UTC
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
$file = $dirname . '__tmp_oo_cancel.zip';
@unlink($file);
$zip = new ZipArchive;
if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
exit('failed');
}
var_dump($zip->registerCancelCallback(function () {
// Always cancel
return -1;
}));
var_dump($zip->addFromString(PHP_BINARY, 'entry #1'));
var_dump($zip->close());
var_dump($zip->status == ZipArchive::ER_CANCELLED);
var_dump($zip->getStatusString());
@unlink($file);
?>
Done
--EXPECTF--
bool(true)
bool(true)
Warning: ZipArchive::close(): Operation cancelled in %s
bool(false)
bool(true)
string(19) "Operation cancelled"
Done
Did this file decode correctly?
Original Code
--TEST--
registerCancelCallback
--EXTENSIONS--
zip
--SKIPIF--
<?php
/* $Id$ */
if (!method_exists('ZipArchive', 'registerCancelCallback')) die('skip libzip too old');
?>
--INI--
date.timezone=UTC
--FILE--
<?php
$dirname = dirname(__FILE__) . '/';
$file = $dirname . '__tmp_oo_cancel.zip';
@unlink($file);
$zip = new ZipArchive;
if (!$zip->open($file, ZIPARCHIVE::CREATE)) {
exit('failed');
}
var_dump($zip->registerCancelCallback(function () {
// Always cancel
return -1;
}));
var_dump($zip->addFromString(PHP_BINARY, 'entry #1'));
var_dump($zip->close());
var_dump($zip->status == ZipArchive::ER_CANCELLED);
var_dump($zip->getStatusString());
@unlink($file);
?>
Done
--EXPECTF--
bool(true)
bool(true)
Warning: ZipArchive::close(): Operation cancelled in %s
bool(false)
bool(true)
string(19) "Operation cancelled"
Done
Function Calls
method_exists | 1 |
Stats
MD5 | 65a7292a1ae3952e852a0b4df0270af7 |
Eval Count | 0 |
Decode Time | 79 ms |