⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.23
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
usr
/
local
/
src
/
mongodb-1.11.1
/
tests
/
bson
/
View File Name :
bson-toPHP-001.phpt
--TEST-- MongoDB\BSON\toPHP(): __pclass must be both instantiatable and Persistable --FILE-- <?php require_once __DIR__ . '/../utils/basic.inc'; abstract class MyAbstractDocument implements MongoDB\BSON\Persistable { } class MyDocument implements MongoDB\BSON\Unserializable { public function bsonUnserialize(array $data) { $this->unserialized = true; } } // Create base64-encoded class names for __pclass field's binary data $bMyAbstractDocument = base64_encode('MyAbstractDocument'); $bMyDocument = base64_encode('MyDocument'); $bUnserializable = base64_encode('MongoDB\BSON\Unserializable'); $bPersistable = base64_encode('MongoDB\BSON\Persistable'); $tests = array( '{ "foo": "yes", "__pclass": { "$binary": "' . $bMyAbstractDocument . '", "$type": "80" } }', '{ "foo": "yes", "__pclass": { "$binary": "' . $bMyDocument . '", "$type": "80" } }', '{ "foo": "yes", "__pclass": { "$binary": "' . $bUnserializable . '", "$type": "80" } }', '{ "foo": "yes", "__pclass": { "$binary": "' . $bPersistable . '", "$type": "44" } }', ); foreach ($tests as $test) { echo $test, "\n"; var_dump(toPHP(fromJSON($test))); echo "\n"; } ?> ===DONE=== <?php exit(0); ?> --EXPECTF-- { "foo": "yes", "__pclass": { "$binary": "TXlBYnN0cmFjdERvY3VtZW50", "$type": "80" } } object(stdClass)#%d (2) { ["foo"]=> string(3) "yes" ["__pclass"]=> object(MongoDB\BSON\Binary)#%d (2) { ["data"]=> string(18) "MyAbstractDocument" ["type"]=> int(128) } } { "foo": "yes", "__pclass": { "$binary": "TXlEb2N1bWVudA==", "$type": "80" } } object(stdClass)#%d (2) { ["foo"]=> string(3) "yes" ["__pclass"]=> object(MongoDB\BSON\Binary)#%d (2) { ["data"]=> string(10) "MyDocument" ["type"]=> int(128) } } { "foo": "yes", "__pclass": { "$binary": "TW9uZ29EQlxCU09OXFVuc2VyaWFsaXphYmxl", "$type": "80" } } object(stdClass)#%d (2) { ["foo"]=> string(3) "yes" ["__pclass"]=> object(MongoDB\BSON\Binary)#%d (2) { ["data"]=> string(27) "MongoDB\BSON\Unserializable" ["type"]=> int(128) } } { "foo": "yes", "__pclass": { "$binary": "TW9uZ29EQlxCU09OXFBlcnNpc3RhYmxl", "$type": "44" } } object(stdClass)#%d (2) { ["foo"]=> string(3) "yes" ["__pclass"]=> object(MongoDB\BSON\Binary)#%d (2) { ["data"]=> string(24) "MongoDB\BSON\Persistable" ["type"]=> int(68) } } ===DONE===