v50 Steam/Premium information for editors
- v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
- Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.
Editing User:Quietust/wtf23a.php
Jump to navigation
Jump to search
Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
− | <nowiki><?php | + | <nowiki><? |
+ | <?php | ||
function readByte ($file) | function readByte ($file) | ||
{ | { | ||
Line 57: | Line 58: | ||
} | } | ||
− | function | + | function _decrypt ($file, $len, $rngstate) |
{ | { | ||
− | + | $rng = new rng; | |
− | $ | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
$data = range(0, $len - 1); | $data = range(0, $len - 1); | ||
− | |||
− | |||
// read data, skipping dummy bytes | // read data, skipping dummy bytes | ||
− | $rng->init($ | + | $rng->init($rngstate); |
for ($i = $len - 1; $i >= 0; $i--) | for ($i = $len - 1; $i >= 0; $i--) | ||
{ | { | ||
Line 85: | Line 76: | ||
// decode data | // decode data | ||
− | $rng->init($ | + | $rng->init($rngstate); |
for ($i = $len - 1; $i >= 0; $i--) | for ($i = $len - 1; $i >= 0; $i--) | ||
$data[$i] -= $rng->get(10); | $data[$i] -= $rng->get(10); | ||
Line 94: | Line 85: | ||
$out .= chr($data[$i] & 0xFF); | $out .= chr($data[$i] & 0xFF); | ||
return $out; | return $out; | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
} | } | ||
Line 117: | Line 92: | ||
{ | { | ||
$data = fread($in, 20000); | $data = fread($in, 20000); | ||
+ | for ($i = 0; $i < 625; $i++) | ||
+ | writeLong($out, 0); | ||
$comp = gzcompress($data, 9); | $comp = gzcompress($data, 9); | ||
if ($comp === FALSE) | if ($comp === FALSE) | ||
return false; | return false; | ||
− | + | $len = strlen($comp); | |
− | + | writeLong($out, $len); | |
+ | for ($i = $len; $i > 0; $i--) | ||
+ | fwrite($out, $comp[$i-1], 1); | ||
if (feof($in)) | if (feof($in)) | ||
break; | break; | ||
Line 132: | Line 111: | ||
while (1) | while (1) | ||
{ | { | ||
− | $ | + | $rng = array(); |
− | if ($ | + | for ($i = 0; $i < 625; $i++) |
+ | $rng[$i] = readLong($in); | ||
+ | if (feof($in)) | ||
break; | break; | ||
+ | $len = readLong($in); | ||
+ | $block = _decrypt($in, $len, $rng); | ||
$decomp = gzuncompress($block); | $decomp = gzuncompress($block); | ||
if ($decomp === FALSE) | if ($decomp === FALSE) | ||
Line 309: | Line 292: | ||
} | } | ||
} | } | ||
+ | |||
if ($argc < 2) | if ($argc < 2) |