private static function _pack_bootstrap($packed, $keywords) { $ENCODE = self::_pack_safe_regex('$encode\\($count\\)'); // $packed: the packed script $packed = "'" . self::_pack_escape($packed) . "'"; // $ascii: base for encoding $ascii = min(count($keywords['sorted']), self::$_PEN); if ($ascii == 0) { $ascii = 1; } // $count: number of words contained in the script $count = count($keywords['sorted']); // $keywords: list of words contained in the script foreach ($keywords['protected'] as $i => $value) { $keywords['sorted'][$i] = ''; } // convert from a string to an array ksort($keywords['sorted']); $keywords = "'" . implode('|', $keywords['sorted']) . "'.split('|')"; $encode = self::$_PEN > 62 ? '_pack_encode95' : self::_pack_get_encoder($ascii); $encode = self::get('_encode' . self::$_PEN); $encode = preg_replace('/_encoding/', '$ascii', $encode); $encode = preg_replace('/arguments\\.callee/', '$encode', $encode); $inline = '\\$count' . ($ascii > 10 ? '.toString(\\$ascii)' : ''); // $decode: code snippet to speed up decoding if (self::$_PFD) { // create the decoder $decode = self::get('_decode_body'); if (self::$_PEN > 62) { $decode = preg_replace('/\\\\w/', '[\\xa1-\\xff]', $decode); } elseif ($ascii < 36) { $decode = preg_replace($ENCODE, $inline, $decode); } // special case: when $count==0 there are no keywords. I want to keep // the basic shape of the unpacking funcion so i'll frig the code... if ($count == 0) { $decode = preg_replace(self::_pack_safe_regex('($count)\\s*=\\s*1'), '$1=0', $decode, 1); } } // boot function $unpack = self::get('_unpack'); if (self::$_PFD) { // insert the decoder self::$_PBF = $decode; $unpack = preg_replace_callback('/\\{/', array('self', '_pack_put_fdecode'), $unpack, 1); } $unpack = preg_replace('/"/', "'", $unpack); if (self::$_PEN > 62) { // high-ascii // get rid of the word-boundaries for regexp matches $unpack = preg_replace('/\'\\\\\\\\b\'\\s*\\+|\\+\\s*\'\\\\\\\\b\'/', '', $unpack); } if ($ascii > 36 || self::$_PEN > 62 || self::$_PFD) { // insert the encode function self::$_PBF = $encode; $unpack = preg_replace_callback('/\\{/', array('self', '_pack_put_fencode'), $unpack, 1); } else { // perform the encoding inline $unpack = preg_replace($ENCODE, $inline, $unpack); } // pack the boot function too self::pack($unpack, 0, true, false, false); // arguments $params = array($packed, $ascii, $count, $keywords); if (self::$_PFD) { $params[] = 0; $params[] = '{}'; } $params = implode(',', $params); // the whole thing return 'eval(' . $unpack . '(' . $params . "))\n"; }