PageRenderTime 69ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_akeeba/restore.php

https://bitbucket.org/kraymitchell/saiu
PHP | 5865 lines | 4044 code | 679 blank | 1142 comment | 684 complexity | 1c93f78666664f6f5e8702e6f1b6d316 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * Akeeba Restore
  4. * A JSON-powered JPA, JPS and ZIP archive extraction library
  5. *
  6. * @copyright 2010-2012 Nicholas K. Dionysopoulos / AkeebaBackup.com
  7. * @license GNU GPL v2 or - at your option - any later version
  8. * @package akeebabackup
  9. * @subpackage kickstart
  10. */
  11. define('_AKEEBA_RESTORATION', 1);
  12. defined('DS') or define('DS', DIRECTORY_SEPARATOR);
  13. // Unarchiver run states
  14. define('AK_STATE_NOFILE', 0); // File header not read yet
  15. define('AK_STATE_HEADER', 1); // File header read; ready to process data
  16. define('AK_STATE_DATA', 2); // Processing file data
  17. define('AK_STATE_DATAREAD', 3); // Finished processing file data; ready to post-process
  18. define('AK_STATE_POSTPROC', 4); // Post-processing
  19. define('AK_STATE_DONE', 5); // Done with post-processing
  20. /* Windows system detection */
  21. if(!defined('_AKEEBA_IS_WINDOWS'))
  22. {
  23. if (function_exists('php_uname'))
  24. define('_AKEEBA_IS_WINDOWS', stristr(php_uname(), 'windows'));
  25. else
  26. define('_AKEEBA_IS_WINDOWS', DIRECTORY_SEPARATOR == '\\');
  27. }
  28. // Make sure the locale is correct for basename() to work
  29. if(function_exists('setlocale'))
  30. {
  31. @setlocale(LC_ALL, 'en_US.UTF8');
  32. }
  33. // fnmatch not available on non-POSIX systems
  34. // Thanks to soywiz@php.net for this usefull alternative function [http://gr2.php.net/fnmatch]
  35. if (!function_exists('fnmatch')) {
  36. function fnmatch($pattern, $string) {
  37. return @preg_match(
  38. '/^' . strtr(addcslashes($pattern, '/\\.+^$(){}=!<>|'),
  39. array('*' => '.*', '?' => '.?')) . '$/i', $string
  40. );
  41. }
  42. }
  43. // Unicode-safe binary data length function
  44. if(function_exists('mb_strlen')) {
  45. function akstringlen($string) { return mb_strlen($string,'8bit'); }
  46. } else {
  47. function akstringlen($string) { return strlen($string); }
  48. }
  49. /**
  50. * Gets a query parameter from GET or POST data
  51. * @param $key
  52. * @param $default
  53. */
  54. function getQueryParam( $key, $default = null )
  55. {
  56. $value = null;
  57. if(array_key_exists($key, $_REQUEST)) {
  58. $value = $_REQUEST[$key];
  59. } elseif(array_key_exists($key, $_POST)) {
  60. $value = $_POST[$key];
  61. } elseif(array_key_exists($key, $_GET)) {
  62. $value = $_GET[$key];
  63. } else {
  64. return $default;
  65. }
  66. if(get_magic_quotes_gpc() && !is_null($value)) $value=stripslashes($value);
  67. return $value;
  68. }
  69. // Debugging function
  70. function debugMsg($msg)
  71. {
  72. if(!defined('KSDEBUG')) return;
  73. $fp = fopen('debug.txt','at');
  74. fwrite($fp, $msg."\n");
  75. fclose($fp);
  76. }
  77. /**
  78. * Akeeba Backup's JSON compatibility layer
  79. *
  80. * On systems where json_encode and json_decode are not available, Akeeba
  81. * Backup will attempt to use PEAR's Services_JSON library to emulate them.
  82. * A copy of this library is included in this file and will be used if and
  83. * only if it isn't already loaded, e.g. due to PEAR's auto-loading, or a
  84. * 3PD extension loading it for its own purposes.
  85. */
  86. /**
  87. * Converts to and from JSON format.
  88. *
  89. * JSON (JavaScript Object Notation) is a lightweight data-interchange
  90. * format. It is easy for humans to read and write. It is easy for machines
  91. * to parse and generate. It is based on a subset of the JavaScript
  92. * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
  93. * This feature can also be found in Python. JSON is a text format that is
  94. * completely language independent but uses conventions that are familiar
  95. * to programmers of the C-family of languages, including C, C++, C#, Java,
  96. * JavaScript, Perl, TCL, and many others. These properties make JSON an
  97. * ideal data-interchange language.
  98. *
  99. * This package provides a simple encoder and decoder for JSON notation. It
  100. * is intended for use with client-side Javascript applications that make
  101. * use of HTTPRequest to perform server communication functions - data can
  102. * be encoded into JSON notation for use in a client-side javascript, or
  103. * decoded from incoming Javascript requests. JSON format is native to
  104. * Javascript, and can be directly eval()'ed with no further parsing
  105. * overhead
  106. *
  107. * All strings should be in ASCII or UTF-8 format!
  108. *
  109. * LICENSE: Redistribution and use in source and binary forms, with or
  110. * without modification, are permitted provided that the following
  111. * conditions are met: Redistributions of source code must retain the
  112. * above copyright notice, this list of conditions and the following
  113. * disclaimer. Redistributions in binary form must reproduce the above
  114. * copyright notice, this list of conditions and the following disclaimer
  115. * in the documentation and/or other materials provided with the
  116. * distribution.
  117. *
  118. * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  119. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  120. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  121. * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  122. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  123. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  124. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  125. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  126. * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
  127. * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  128. * DAMAGE.
  129. *
  130. * @category
  131. * @package Services_JSON
  132. * @author Michal Migurski <mike-json@teczno.com>
  133. * @author Matt Knapp <mdknapp[at]gmail[dot]com>
  134. * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
  135. * @copyright 2005 Michal Migurski
  136. * @version CVS: $Id: restore.php 612 2011-05-19 08:26:26Z nikosdion $
  137. * @license http://www.opensource.org/licenses/bsd-license.php
  138. * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
  139. */
  140. if(!defined('JSON_FORCE_OBJECT'))
  141. {
  142. define('JSON_FORCE_OBJECT', 1);
  143. }
  144. if(!defined('SERVICES_JSON_SLICE'))
  145. {
  146. /**
  147. * Marker constant for Services_JSON::decode(), used to flag stack state
  148. */
  149. define('SERVICES_JSON_SLICE', 1);
  150. /**
  151. * Marker constant for Services_JSON::decode(), used to flag stack state
  152. */
  153. define('SERVICES_JSON_IN_STR', 2);
  154. /**
  155. * Marker constant for Services_JSON::decode(), used to flag stack state
  156. */
  157. define('SERVICES_JSON_IN_ARR', 3);
  158. /**
  159. * Marker constant for Services_JSON::decode(), used to flag stack state
  160. */
  161. define('SERVICES_JSON_IN_OBJ', 4);
  162. /**
  163. * Marker constant for Services_JSON::decode(), used to flag stack state
  164. */
  165. define('SERVICES_JSON_IN_CMT', 5);
  166. /**
  167. * Behavior switch for Services_JSON::decode()
  168. */
  169. define('SERVICES_JSON_LOOSE_TYPE', 16);
  170. /**
  171. * Behavior switch for Services_JSON::decode()
  172. */
  173. define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
  174. }
  175. /**
  176. * Converts to and from JSON format.
  177. *
  178. * Brief example of use:
  179. *
  180. * <code>
  181. * // create a new instance of Services_JSON
  182. * $json = new Services_JSON();
  183. *
  184. * // convert a complexe value to JSON notation, and send it to the browser
  185. * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
  186. * $output = $json->encode($value);
  187. *
  188. * print($output);
  189. * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
  190. *
  191. * // accept incoming POST data, assumed to be in JSON notation
  192. * $input = file_get_contents('php://input', 1000000);
  193. * $value = $json->decode($input);
  194. * </code>
  195. */
  196. if(!class_exists('Akeeba_Services_JSON'))
  197. {
  198. class Akeeba_Services_JSON
  199. {
  200. /**
  201. * constructs a new JSON instance
  202. *
  203. * @param int $use object behavior flags; combine with boolean-OR
  204. *
  205. * possible values:
  206. * - SERVICES_JSON_LOOSE_TYPE: loose typing.
  207. * "{...}" syntax creates associative arrays
  208. * instead of objects in decode().
  209. * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
  210. * Values which can't be encoded (e.g. resources)
  211. * appear as NULL instead of throwing errors.
  212. * By default, a deeply-nested resource will
  213. * bubble up with an error, so all return values
  214. * from encode() should be checked with isError()
  215. */
  216. function Akeeba_Services_JSON($use = 0)
  217. {
  218. $this->use = $use;
  219. }
  220. /**
  221. * convert a string from one UTF-16 char to one UTF-8 char
  222. *
  223. * Normally should be handled by mb_convert_encoding, but
  224. * provides a slower PHP-only method for installations
  225. * that lack the multibye string extension.
  226. *
  227. * @param string $utf16 UTF-16 character
  228. * @return string UTF-8 character
  229. * @access private
  230. */
  231. function utf162utf8($utf16)
  232. {
  233. // oh please oh please oh please oh please oh please
  234. if(function_exists('mb_convert_encoding')) {
  235. return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
  236. }
  237. $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
  238. switch(true) {
  239. case ((0x7F & $bytes) == $bytes):
  240. // this case should never be reached, because we are in ASCII range
  241. // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  242. return chr(0x7F & $bytes);
  243. case (0x07FF & $bytes) == $bytes:
  244. // return a 2-byte UTF-8 character
  245. // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  246. return chr(0xC0 | (($bytes >> 6) & 0x1F))
  247. . chr(0x80 | ($bytes & 0x3F));
  248. case (0xFFFF & $bytes) == $bytes:
  249. // return a 3-byte UTF-8 character
  250. // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  251. return chr(0xE0 | (($bytes >> 12) & 0x0F))
  252. . chr(0x80 | (($bytes >> 6) & 0x3F))
  253. . chr(0x80 | ($bytes & 0x3F));
  254. }
  255. // ignoring UTF-32 for now, sorry
  256. return '';
  257. }
  258. /**
  259. * convert a string from one UTF-8 char to one UTF-16 char
  260. *
  261. * Normally should be handled by mb_convert_encoding, but
  262. * provides a slower PHP-only method for installations
  263. * that lack the multibye string extension.
  264. *
  265. * @param string $utf8 UTF-8 character
  266. * @return string UTF-16 character
  267. * @access private
  268. */
  269. function utf82utf16($utf8)
  270. {
  271. // oh please oh please oh please oh please oh please
  272. if(function_exists('mb_convert_encoding')) {
  273. return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
  274. }
  275. switch(strlen($utf8)) {
  276. case 1:
  277. // this case should never be reached, because we are in ASCII range
  278. // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  279. return $utf8;
  280. case 2:
  281. // return a UTF-16 character from a 2-byte UTF-8 char
  282. // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  283. return chr(0x07 & (ord($utf8{0}) >> 2))
  284. . chr((0xC0 & (ord($utf8{0}) << 6))
  285. | (0x3F & ord($utf8{1})));
  286. case 3:
  287. // return a UTF-16 character from a 3-byte UTF-8 char
  288. // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  289. return chr((0xF0 & (ord($utf8{0}) << 4))
  290. | (0x0F & (ord($utf8{1}) >> 2)))
  291. . chr((0xC0 & (ord($utf8{1}) << 6))
  292. | (0x7F & ord($utf8{2})));
  293. }
  294. // ignoring UTF-32 for now, sorry
  295. return '';
  296. }
  297. /**
  298. * encodes an arbitrary variable into JSON format
  299. *
  300. * @param mixed $var any number, boolean, string, array, or object to be encoded.
  301. * see argument 1 to Services_JSON() above for array-parsing behavior.
  302. * if var is a strng, note that encode() always expects it
  303. * to be in ASCII or UTF-8 format!
  304. *
  305. * @return mixed JSON string representation of input var or an error if a problem occurs
  306. * @access public
  307. */
  308. function encode($var)
  309. {
  310. switch (gettype($var)) {
  311. case 'boolean':
  312. return $var ? 'true' : 'false';
  313. case 'NULL':
  314. return 'null';
  315. case 'integer':
  316. return (int) $var;
  317. case 'double':
  318. case 'float':
  319. return (float) $var;
  320. case 'string':
  321. // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
  322. $ascii = '';
  323. $strlen_var = strlen($var);
  324. /*
  325. * Iterate over every character in the string,
  326. * escaping with a slash or encoding to UTF-8 where necessary
  327. */
  328. for ($c = 0; $c < $strlen_var; ++$c) {
  329. $ord_var_c = ord($var{$c});
  330. switch (true) {
  331. case $ord_var_c == 0x08:
  332. $ascii .= '\b';
  333. break;
  334. case $ord_var_c == 0x09:
  335. $ascii .= '\t';
  336. break;
  337. case $ord_var_c == 0x0A:
  338. $ascii .= '\n';
  339. break;
  340. case $ord_var_c == 0x0C:
  341. $ascii .= '\f';
  342. break;
  343. case $ord_var_c == 0x0D:
  344. $ascii .= '\r';
  345. break;
  346. case $ord_var_c == 0x22:
  347. case $ord_var_c == 0x2F:
  348. case $ord_var_c == 0x5C:
  349. // double quote, slash, slosh
  350. $ascii .= '\\'.$var{$c};
  351. break;
  352. case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
  353. // characters U-00000000 - U-0000007F (same as ASCII)
  354. $ascii .= $var{$c};
  355. break;
  356. case (($ord_var_c & 0xE0) == 0xC0):
  357. // characters U-00000080 - U-000007FF, mask 110XXXXX
  358. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  359. $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
  360. $c += 1;
  361. $utf16 = $this->utf82utf16($char);
  362. $ascii .= sprintf('\u%04s', bin2hex($utf16));
  363. break;
  364. case (($ord_var_c & 0xF0) == 0xE0):
  365. // characters U-00000800 - U-0000FFFF, mask 1110XXXX
  366. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  367. $char = pack('C*', $ord_var_c,
  368. ord($var{$c + 1}),
  369. ord($var{$c + 2}));
  370. $c += 2;
  371. $utf16 = $this->utf82utf16($char);
  372. $ascii .= sprintf('\u%04s', bin2hex($utf16));
  373. break;
  374. case (($ord_var_c & 0xF8) == 0xF0):
  375. // characters U-00010000 - U-001FFFFF, mask 11110XXX
  376. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  377. $char = pack('C*', $ord_var_c,
  378. ord($var{$c + 1}),
  379. ord($var{$c + 2}),
  380. ord($var{$c + 3}));
  381. $c += 3;
  382. $utf16 = $this->utf82utf16($char);
  383. $ascii .= sprintf('\u%04s', bin2hex($utf16));
  384. break;
  385. case (($ord_var_c & 0xFC) == 0xF8):
  386. // characters U-00200000 - U-03FFFFFF, mask 111110XX
  387. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  388. $char = pack('C*', $ord_var_c,
  389. ord($var{$c + 1}),
  390. ord($var{$c + 2}),
  391. ord($var{$c + 3}),
  392. ord($var{$c + 4}));
  393. $c += 4;
  394. $utf16 = $this->utf82utf16($char);
  395. $ascii .= sprintf('\u%04s', bin2hex($utf16));
  396. break;
  397. case (($ord_var_c & 0xFE) == 0xFC):
  398. // characters U-04000000 - U-7FFFFFFF, mask 1111110X
  399. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  400. $char = pack('C*', $ord_var_c,
  401. ord($var{$c + 1}),
  402. ord($var{$c + 2}),
  403. ord($var{$c + 3}),
  404. ord($var{$c + 4}),
  405. ord($var{$c + 5}));
  406. $c += 5;
  407. $utf16 = $this->utf82utf16($char);
  408. $ascii .= sprintf('\u%04s', bin2hex($utf16));
  409. break;
  410. }
  411. }
  412. return '"'.$ascii.'"';
  413. case 'array':
  414. /*
  415. * As per JSON spec if any array key is not an integer
  416. * we must treat the the whole array as an object. We
  417. * also try to catch a sparsely populated associative
  418. * array with numeric keys here because some JS engines
  419. * will create an array with empty indexes up to
  420. * max_index which can cause memory issues and because
  421. * the keys, which may be relevant, will be remapped
  422. * otherwise.
  423. *
  424. * As per the ECMA and JSON specification an object may
  425. * have any string as a property. Unfortunately due to
  426. * a hole in the ECMA specification if the key is a
  427. * ECMA reserved word or starts with a digit the
  428. * parameter is only accessible using ECMAScript's
  429. * bracket notation.
  430. */
  431. // treat as a JSON object
  432. if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
  433. $properties = array_map(array($this, 'name_value'),
  434. array_keys($var),
  435. array_values($var));
  436. foreach($properties as $property) {
  437. if(Akeeba_Services_JSON::isError($property)) {
  438. return $property;
  439. }
  440. }
  441. return '{' . join(',', $properties) . '}';
  442. }
  443. // treat it like a regular array
  444. $elements = array_map(array($this, 'encode'), $var);
  445. foreach($elements as $element) {
  446. if(Akeeba_Services_JSON::isError($element)) {
  447. return $element;
  448. }
  449. }
  450. return '[' . join(',', $elements) . ']';
  451. case 'object':
  452. $vars = get_object_vars($var);
  453. $properties = array_map(array($this, 'name_value'),
  454. array_keys($vars),
  455. array_values($vars));
  456. foreach($properties as $property) {
  457. if(Akeeba_Services_JSON::isError($property)) {
  458. return $property;
  459. }
  460. }
  461. return '{' . join(',', $properties) . '}';
  462. default:
  463. return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
  464. ? 'null'
  465. : new Akeeba_Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
  466. }
  467. }
  468. /**
  469. * array-walking function for use in generating JSON-formatted name-value pairs
  470. *
  471. * @param string $name name of key to use
  472. * @param mixed $value reference to an array element to be encoded
  473. *
  474. * @return string JSON-formatted name-value pair, like '"name":value'
  475. * @access private
  476. */
  477. function name_value($name, $value)
  478. {
  479. $encoded_value = $this->encode($value);
  480. if(Akeeba_Services_JSON::isError($encoded_value)) {
  481. return $encoded_value;
  482. }
  483. return $this->encode(strval($name)) . ':' . $encoded_value;
  484. }
  485. /**
  486. * reduce a string by removing leading and trailing comments and whitespace
  487. *
  488. * @param $str string string value to strip of comments and whitespace
  489. *
  490. * @return string string value stripped of comments and whitespace
  491. * @access private
  492. */
  493. function reduce_string($str)
  494. {
  495. $str = preg_replace(array(
  496. // eliminate single line comments in '// ...' form
  497. '#^\s*//(.+)$#m',
  498. // eliminate multi-line comments in '/* ... */' form, at start of string
  499. '#^\s*/\*(.+)\*/#Us',
  500. // eliminate multi-line comments in '/* ... */' form, at end of string
  501. '#/\*(.+)\*/\s*$#Us'
  502. ), '', $str);
  503. // eliminate extraneous space
  504. return trim($str);
  505. }
  506. /**
  507. * decodes a JSON string into appropriate variable
  508. *
  509. * @param string $str JSON-formatted string
  510. *
  511. * @return mixed number, boolean, string, array, or object
  512. * corresponding to given JSON input string.
  513. * See argument 1 to Akeeba_Services_JSON() above for object-output behavior.
  514. * Note that decode() always returns strings
  515. * in ASCII or UTF-8 format!
  516. * @access public
  517. */
  518. function decode($str)
  519. {
  520. $str = $this->reduce_string($str);
  521. switch (strtolower($str)) {
  522. case 'true':
  523. return true;
  524. case 'false':
  525. return false;
  526. case 'null':
  527. return null;
  528. default:
  529. $m = array();
  530. if (is_numeric($str)) {
  531. // Lookie-loo, it's a number
  532. // This would work on its own, but I'm trying to be
  533. // good about returning integers where appropriate:
  534. // return (float)$str;
  535. // Return float or int, as appropriate
  536. return ((float)$str == (integer)$str)
  537. ? (integer)$str
  538. : (float)$str;
  539. } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
  540. // STRINGS RETURNED IN UTF-8 FORMAT
  541. $delim = substr($str, 0, 1);
  542. $chrs = substr($str, 1, -1);
  543. $utf8 = '';
  544. $strlen_chrs = strlen($chrs);
  545. for ($c = 0; $c < $strlen_chrs; ++$c) {
  546. $substr_chrs_c_2 = substr($chrs, $c, 2);
  547. $ord_chrs_c = ord($chrs{$c});
  548. switch (true) {
  549. case $substr_chrs_c_2 == '\b':
  550. $utf8 .= chr(0x08);
  551. ++$c;
  552. break;
  553. case $substr_chrs_c_2 == '\t':
  554. $utf8 .= chr(0x09);
  555. ++$c;
  556. break;
  557. case $substr_chrs_c_2 == '\n':
  558. $utf8 .= chr(0x0A);
  559. ++$c;
  560. break;
  561. case $substr_chrs_c_2 == '\f':
  562. $utf8 .= chr(0x0C);
  563. ++$c;
  564. break;
  565. case $substr_chrs_c_2 == '\r':
  566. $utf8 .= chr(0x0D);
  567. ++$c;
  568. break;
  569. case $substr_chrs_c_2 == '\\"':
  570. case $substr_chrs_c_2 == '\\\'':
  571. case $substr_chrs_c_2 == '\\\\':
  572. case $substr_chrs_c_2 == '\\/':
  573. if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
  574. ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
  575. $utf8 .= $chrs{++$c};
  576. }
  577. break;
  578. case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
  579. // single, escaped unicode character
  580. $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
  581. . chr(hexdec(substr($chrs, ($c + 4), 2)));
  582. $utf8 .= $this->utf162utf8($utf16);
  583. $c += 5;
  584. break;
  585. case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
  586. $utf8 .= $chrs{$c};
  587. break;
  588. case ($ord_chrs_c & 0xE0) == 0xC0:
  589. // characters U-00000080 - U-000007FF, mask 110XXXXX
  590. //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  591. $utf8 .= substr($chrs, $c, 2);
  592. ++$c;
  593. break;
  594. case ($ord_chrs_c & 0xF0) == 0xE0:
  595. // characters U-00000800 - U-0000FFFF, mask 1110XXXX
  596. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  597. $utf8 .= substr($chrs, $c, 3);
  598. $c += 2;
  599. break;
  600. case ($ord_chrs_c & 0xF8) == 0xF0:
  601. // characters U-00010000 - U-001FFFFF, mask 11110XXX
  602. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  603. $utf8 .= substr($chrs, $c, 4);
  604. $c += 3;
  605. break;
  606. case ($ord_chrs_c & 0xFC) == 0xF8:
  607. // characters U-00200000 - U-03FFFFFF, mask 111110XX
  608. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  609. $utf8 .= substr($chrs, $c, 5);
  610. $c += 4;
  611. break;
  612. case ($ord_chrs_c & 0xFE) == 0xFC:
  613. // characters U-04000000 - U-7FFFFFFF, mask 1111110X
  614. // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
  615. $utf8 .= substr($chrs, $c, 6);
  616. $c += 5;
  617. break;
  618. }
  619. }
  620. return $utf8;
  621. } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
  622. // array, or object notation
  623. if ($str{0} == '[') {
  624. $stk = array(SERVICES_JSON_IN_ARR);
  625. $arr = array();
  626. } else {
  627. if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
  628. $stk = array(SERVICES_JSON_IN_OBJ);
  629. $obj = array();
  630. } else {
  631. $stk = array(SERVICES_JSON_IN_OBJ);
  632. $obj = new stdClass();
  633. }
  634. }
  635. array_push($stk, array('what' => SERVICES_JSON_SLICE,
  636. 'where' => 0,
  637. 'delim' => false));
  638. $chrs = substr($str, 1, -1);
  639. $chrs = $this->reduce_string($chrs);
  640. if ($chrs == '') {
  641. if (reset($stk) == SERVICES_JSON_IN_ARR) {
  642. return $arr;
  643. } else {
  644. return $obj;
  645. }
  646. }
  647. //print("\nparsing {$chrs}\n");
  648. $strlen_chrs = strlen($chrs);
  649. for ($c = 0; $c <= $strlen_chrs; ++$c) {
  650. $top = end($stk);
  651. $substr_chrs_c_2 = substr($chrs, $c, 2);
  652. if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
  653. // found a comma that is not inside a string, array, etc.,
  654. // OR we've reached the end of the character list
  655. $slice = substr($chrs, $top['where'], ($c - $top['where']));
  656. array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
  657. //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
  658. if (reset($stk) == SERVICES_JSON_IN_ARR) {
  659. // we are in an array, so just push an element onto the stack
  660. array_push($arr, $this->decode($slice));
  661. } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
  662. // we are in an object, so figure
  663. // out the property name and set an
  664. // element in an associative array,
  665. // for now
  666. $parts = array();
  667. if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
  668. // "name":value pair
  669. $key = $this->decode($parts[1]);
  670. $val = $this->decode($parts[2]);
  671. if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
  672. $obj[$key] = $val;
  673. } else {
  674. $obj->$key = $val;
  675. }
  676. } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
  677. // name:value pair, where name is unquoted
  678. $key = $parts[1];
  679. $val = $this->decode($parts[2]);
  680. if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
  681. $obj[$key] = $val;
  682. } else {
  683. $obj->$key = $val;
  684. }
  685. }
  686. }
  687. } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
  688. // found a quote, and we are not inside a string
  689. array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
  690. //print("Found start of string at {$c}\n");
  691. } elseif (($chrs{$c} == $top['delim']) &&
  692. ($top['what'] == SERVICES_JSON_IN_STR) &&
  693. ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
  694. // found a quote, we're in a string, and it's not escaped
  695. // we know that it's not escaped becase there is _not_ an
  696. // odd number of backslashes at the end of the string so far
  697. array_pop($stk);
  698. //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
  699. } elseif (($chrs{$c} == '[') &&
  700. in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
  701. // found a left-bracket, and we are in an array, object, or slice
  702. array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
  703. //print("Found start of array at {$c}\n");
  704. } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
  705. // found a right-bracket, and we're in an array
  706. array_pop($stk);
  707. //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
  708. } elseif (($chrs{$c} == '{') &&
  709. in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
  710. // found a left-brace, and we are in an array, object, or slice
  711. array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
  712. //print("Found start of object at {$c}\n");
  713. } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
  714. // found a right-brace, and we're in an object
  715. array_pop($stk);
  716. //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
  717. } elseif (($substr_chrs_c_2 == '/*') &&
  718. in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
  719. // found a comment start, and we are in an array, object, or slice
  720. array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
  721. $c++;
  722. //print("Found start of comment at {$c}\n");
  723. } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
  724. // found a comment end, and we're in one now
  725. array_pop($stk);
  726. $c++;
  727. for ($i = $top['where']; $i <= $c; ++$i)
  728. $chrs = substr_replace($chrs, ' ', $i, 1);
  729. //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
  730. }
  731. }
  732. if (reset($stk) == SERVICES_JSON_IN_ARR) {
  733. return $arr;
  734. } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
  735. return $obj;
  736. }
  737. }
  738. }
  739. }
  740. function isError($data, $code = null)
  741. {
  742. if (class_exists('pear')) {
  743. return PEAR::isError($data, $code);
  744. } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
  745. is_subclass_of($data, 'services_json_error'))) {
  746. return true;
  747. }
  748. return false;
  749. }
  750. }
  751. class Akeeba_Services_JSON_Error
  752. {
  753. function Akeeba_Services_JSON_Error($message = 'unknown error', $code = null,
  754. $mode = null, $options = null, $userinfo = null)
  755. {
  756. }
  757. }
  758. }
  759. if(!function_exists('json_encode'))
  760. {
  761. function json_encode($value, $options = 0) {
  762. $flags = SERVICES_JSON_LOOSE_TYPE;
  763. if( $options & JSON_FORCE_OBJECT ) $flags = 0;
  764. $encoder = new Akeeba_Services_JSON($flags);
  765. return $encoder->encode($value);
  766. }
  767. }
  768. if(!function_exists('json_decode'))
  769. {
  770. function json_decode($value, $assoc = false)
  771. {
  772. $flags = 0;
  773. if($assoc) $flags = SERVICES_JSON_LOOSE_TYPE;
  774. $decoder = new Akeeba_Services_JSON($flags);
  775. return $decoder->decode($value);
  776. }
  777. }
  778. /**
  779. * The base class of Akeeba Engine objects. Allows for error and warnings logging
  780. * and propagation. Largely based on the Joomla! 1.5 JObject class.
  781. */
  782. abstract class AKAbstractObject
  783. {
  784. /** @var array An array of errors */
  785. private $_errors = array();
  786. /** @var array The queue size of the $_errors array. Set to 0 for infinite size. */
  787. protected $_errors_queue_size = 0;
  788. /** @var array An array of warnings */
  789. private $_warnings = array();
  790. /** @var array The queue size of the $_warnings array. Set to 0 for infinite size. */
  791. protected $_warnings_queue_size = 0;
  792. /**
  793. * Public constructor, makes sure we are instanciated only by the factory class
  794. */
  795. public function __construct()
  796. {
  797. /*
  798. // Assisted Singleton pattern
  799. if(function_exists('debug_backtrace'))
  800. {
  801. $caller=debug_backtrace();
  802. if(
  803. ($caller[1]['class'] != 'AKFactory') &&
  804. ($caller[2]['class'] != 'AKFactory') &&
  805. ($caller[3]['class'] != 'AKFactory') &&
  806. ($caller[4]['class'] != 'AKFactory')
  807. ) {
  808. var_dump(debug_backtrace());
  809. trigger_error("You can't create direct descendants of ".__CLASS__, E_USER_ERROR);
  810. }
  811. }
  812. */
  813. }
  814. /**
  815. * Get the most recent error message
  816. * @param integer $i Optional error index
  817. * @return string Error message
  818. */
  819. public function getError($i = null)
  820. {
  821. return $this->getItemFromArray($this->_errors, $i);
  822. }
  823. /**
  824. * Return all errors, if any
  825. * @return array Array of error messages
  826. */
  827. public function getErrors()
  828. {
  829. return $this->_errors;
  830. }
  831. /**
  832. * Add an error message
  833. * @param string $error Error message
  834. */
  835. public function setError($error)
  836. {
  837. if($this->_errors_queue_size > 0)
  838. {
  839. if(count($this->_errors) >= $this->_errors_queue_size)
  840. {
  841. array_shift($this->_errors);
  842. }
  843. }
  844. array_push($this->_errors, $error);
  845. }
  846. /**
  847. * Resets all error messages
  848. */
  849. public function resetErrors()
  850. {
  851. $this->_errors = array();
  852. }
  853. /**
  854. * Get the most recent warning message
  855. * @param integer $i Optional warning index
  856. * @return string Error message
  857. */
  858. public function getWarning($i = null)
  859. {
  860. return $this->getItemFromArray($this->_warnings, $i);
  861. }
  862. /**
  863. * Return all warnings, if any
  864. * @return array Array of error messages
  865. */
  866. public function getWarnings()
  867. {
  868. return $this->_warnings;
  869. }
  870. /**
  871. * Add an error message
  872. * @param string $error Error message
  873. */
  874. public function setWarning($warning)
  875. {
  876. if($this->_warnings_queue_size > 0)
  877. {
  878. if(count($this->_warnings) >= $this->_warnings_queue_size)
  879. {
  880. array_shift($this->_warnings);
  881. }
  882. }
  883. array_push($this->_warnings, $warning);
  884. }
  885. /**
  886. * Resets all warning messages
  887. */
  888. public function resetWarnings()
  889. {
  890. $this->_warnings = array();
  891. }
  892. /**
  893. * Propagates errors and warnings to a foreign object. The foreign object SHOULD
  894. * implement the setError() and/or setWarning() methods but DOESN'T HAVE TO be of
  895. * AKAbstractObject type. For example, this can even be used to propagate to a
  896. * JObject instance in Joomla!. Propagated items will be removed from ourself.
  897. * @param object $object The object to propagate errors and warnings to.
  898. */
  899. public function propagateToObject(&$object)
  900. {
  901. // Skip non-objects
  902. if(!is_object($object)) return;
  903. if( method_exists($object,'setError') )
  904. {
  905. if(!empty($this->_errors))
  906. {
  907. foreach($this->_errors as $error)
  908. {
  909. $object->setError($error);
  910. }
  911. $this->_errors = array();
  912. }
  913. }
  914. if( method_exists($object,'setWarning') )
  915. {
  916. if(!empty($this->_warnings))
  917. {
  918. foreach($this->_warnings as $warning)
  919. {
  920. $object->setWarning($warning);
  921. }
  922. $this->_warnings = array();
  923. }
  924. }
  925. }
  926. /**
  927. * Propagates errors and warnings from a foreign object. Each propagated list is
  928. * then cleared on the foreign object, as long as it implements resetErrors() and/or
  929. * resetWarnings() methods.
  930. * @param object $object The object to propagate errors and warnings from
  931. */
  932. public function propagateFromObject(&$object)
  933. {
  934. if( method_exists($object,'getErrors') )
  935. {
  936. $errors = $object->getErrors();
  937. if(!empty($errors))
  938. {
  939. foreach($errors as $error)
  940. {
  941. $this->setError($error);
  942. }
  943. }
  944. if(method_exists($object,'resetErrors'))
  945. {
  946. $object->resetErrors();
  947. }
  948. }
  949. if( method_exists($object,'getWarnings') )
  950. {
  951. $warnings = $object->getWarnings();
  952. if(!empty($warnings))
  953. {
  954. foreach($warnings as $warning)
  955. {
  956. $this->setWarning($warning);
  957. }
  958. }
  959. if(method_exists($object,'resetWarnings'))
  960. {
  961. $object->resetWarnings();
  962. }
  963. }
  964. }
  965. /**
  966. * Sets the size of the error queue (acts like a LIFO buffer)
  967. * @param int $newSize The new queue size. Set to 0 for infinite length.
  968. */
  969. protected function setErrorsQueueSize($newSize = 0)
  970. {
  971. $this->_errors_queue_size = (int)$newSize;
  972. }
  973. /**
  974. * Sets the size of the warnings queue (acts like a LIFO buffer)
  975. * @param int $newSize The new queue size. Set to 0 for infinite length.
  976. */
  977. protected function setWarningsQueueSize($newSize = 0)
  978. {
  979. $this->_warnings_queue_size = (int)$newSize;
  980. }
  981. /**
  982. * Returns the last item of a LIFO string message queue, or a specific item
  983. * if so specified.
  984. * @param array $array An array of strings, holding messages
  985. * @param int $i Optional message index
  986. * @return mixed The message string, or false if the key doesn't exist
  987. */
  988. private function getItemFromArray($array, $i = null)
  989. {
  990. // Find the item
  991. if ( $i === null) {
  992. // Default, return the last item
  993. $item = end($array);
  994. }
  995. else
  996. if ( ! array_key_exists($i, $array) ) {
  997. // If $i has been specified but does not exist, return false
  998. return false;
  999. }
  1000. else
  1001. {
  1002. $item = $array[$i];
  1003. }
  1004. return $item;
  1005. }
  1006. }
  1007. /**
  1008. * File post processor engines base class
  1009. */
  1010. abstract class AKAbstractPostproc extends AKAbstractObject
  1011. {
  1012. /** @var string The current (real) file path we'll have to process */
  1013. protected $filename = null;
  1014. /** @var int The requested permissions */
  1015. protected $perms = 0755;
  1016. /** @var string The temporary file path we gave to the unarchiver engine */
  1017. protected $tempFilename = null;
  1018. /** @var int The UNIX timestamp of the file's desired modification date */
  1019. public $timestamp = 0;
  1020. /**
  1021. * Processes the current file, e.g. moves it from temp to final location by FTP
  1022. */
  1023. abstract public function process();
  1024. /**
  1025. * The unarchiver tells us the path to the filename it wants to extract and we give it
  1026. * a different path instead.
  1027. * @param string $filename The path to the real file
  1028. * @param int $perms The permissions we need the file to have
  1029. * @return string The path to the temporary file
  1030. */
  1031. abstract public function processFilename($filename, $perms = 0755);
  1032. /**
  1033. * Recursively creates a directory if it doesn't exist
  1034. * @param string $dirName The directory to create
  1035. * @param int $perms The permissions to give to that directory
  1036. */
  1037. abstract public function createDirRecursive( $dirName, $perms );
  1038. abstract public function chmod( $file, $perms );
  1039. abstract public function unlink( $file );
  1040. abstract public function rmdir( $directory );
  1041. abstract public function rename( $from, $to );
  1042. }
  1043. /**
  1044. * The base class of unarchiver classes
  1045. */
  1046. abstract class AKAbstractUnarchiver extends AKAbstractPart
  1047. {
  1048. /** @var string Archive filename */
  1049. protected $filename = null;
  1050. /** @var array List of the names of all archive parts */
  1051. public $archiveList = array();
  1052. /** @var int The total size of all archive parts */
  1053. public $totalSize = array();
  1054. /** @var integer Current archive part number */
  1055. protected $currentPartNumber = -1;
  1056. /** @var integer The offset inside the current part */
  1057. protected $currentPartOffset = 0;
  1058. /** @var bool Should I restore permissions? */
  1059. protected $flagRestorePermissions = false;
  1060. /** @var AKAbstractPostproc Post processing class */
  1061. protected $postProcEngine = null;
  1062. /** @var string Absolute path to prepend to extracted files */
  1063. protected $addPath = '';
  1064. /** @var array Which files to rename */
  1065. public $renameFiles = array();
  1066. /** @var array Which directories to rename */
  1067. public $renameDirs = array();
  1068. /** @var array Which files to skip */
  1069. public $skipFiles = array();
  1070. /** @var integer Chunk size for processing */
  1071. protected $chunkSize = 524288;
  1072. /** @var resource File pointer to the current archive part file */
  1073. protected $fp = null;
  1074. /** @var int Run state when processing the current archive file */
  1075. protected $runState = null;
  1076. /** @var stdClass File header data, as read by the readFileHeader() method */
  1077. protected $fileHeader = null;
  1078. /** @var int How much of the uncompressed data we've read so far */
  1079. protected $dataReadLength = 0;
  1080. /**
  1081. * Public constructor
  1082. */
  1083. public function __construct()
  1084. {
  1085. parent::__construct();
  1086. }
  1087. /**
  1088. * Wakeup function, called whenever the class is unserialized
  1089. */
  1090. public function __wakeup()
  1091. {
  1092. if($this->currentPartNumber >= 0)
  1093. {
  1094. $this->fp = @fopen($this->archiveList[$this->currentPartNumber], 'rb');
  1095. if( (is_resource($this->fp)) && ($this->currentPartOffset > 0) )
  1096. {
  1097. @fseek($this->fp, $this->currentPartOffset);
  1098. }
  1099. }
  1100. }
  1101. /**
  1102. * Sleep function, called whenever the class is serialized
  1103. */
  1104. public function shutdown()
  1105. {
  1106. if(is_resource($this->fp))
  1107. {
  1108. $this->currentPartOffset = @ftell($this->fp);
  1109. @fclose($this->fp);
  1110. }
  1111. }
  1112. /**
  1113. * Implements the abstract _prepare() method
  1114. */
  1115. final protected function _prepare()
  1116. {
  1117. parent::__construct();
  1118. if( count($this->_parametersArray) > 0 )
  1119. {
  1120. foreach($this->_parametersArray as $key => $value)
  1121. {
  1122. switch($key)
  1123. {
  1124. case 'filename': // Archive's absolute filename
  1125. $this->filename = $value;
  1126. break;
  1127. case 'restore_permissions': // Should I restore permissions?
  1128. $this->flagRestorePermissions = $value;
  1129. break;
  1130. case 'post_proc': // Should I use FTP?
  1131. $this->postProcEngine = AKFactory::getpostProc($value);
  1132. break;
  1133. case 'add_path': // Path to prepend
  1134. $this->addPath = $value;
  1135. $this->addPath = str_replace('\\','/',$this->addPath);
  1136. $this->addPath = rtrim($this->addPath,'/');
  1137. if(!empty($this->addPath)) $this->addPath .= '/';
  1138. break;
  1139. case 'rename_files': // Which files to rename (hash array)
  1140. $this->renameFiles = $value;
  1141. break;
  1142. case 'rename_dirs': // Which files to rename (hash array)
  1143. $this->renameDirs = $value;
  1144. break;
  1145. case 'skip_files': // Which files to skip (indexed array)
  1146. $this->skipFiles = $value;
  1147. break;
  1148. }
  1149. }
  1150. }
  1151. $this->scanArchives();
  1152. $this->readArchiveHeader();
  1153. $errMessage = $this->getError();
  1154. if(!empty($errMessage))
  1155. {
  1156. $this->setState('error', $errMessage);
  1157. }
  1158. else
  1159. {
  1160. $this->runState = AK_STATE_NOFILE;
  1161. $this->setState('prepared');
  1162. }
  1163. }
  1164. protected function _run()
  1165. {
  1166. if($this->getState() == 'postrun') return;
  1167. $this->setState('running');
  1168. $timer = AKFactory::getTimer();
  1169. $status = true;
  1170. while( $status && ($timer->getTimeLeft() > 0) )
  1171. {
  1172. switch( $this->runState )
  1173. {
  1174. case AK_STATE_NOFILE:
  1175. debugMsg(__CLASS__.'::_run() - Reading file header');
  1176. $status = $this->readFileHeader();
  1177. if($status)
  1178. {
  1179. debugMsg(__CLASS__.'::_run() - Preparing to extract '.$this->fileHeader->realFile);
  1180. // Send start of file notification
  1181. $message = new stdClass;
  1182. $message->type = 'startfile';
  1183. $message->content = new stdClass;
  1184. if( array_key_exists('realfile', get_object_vars($this->fileHeader)) ) {
  1185. $message->content->realfile = $this->fileHeader->realFile;
  1186. } else {
  1187. $message->content->realfile = $this->fileHeader->file;
  1188. }
  1189. $message->content->file = $this->fileHeader->file;
  1190. if( array_key_exists('compressed', get_object_vars($this->fileHeader)) ) {
  1191. $message->content->compressed = $this->fileHeader->compressed;
  1192. } else {
  1193. $message->content->compressed = 0;
  1194. }
  1195. $message->content->uncompressed = $this->fileHeader->uncompressed;
  1196. $this->notify($message);
  1197. } else {
  1198. debugMsg(__CLASS__.'::_run() - Could not read file header');
  1199. }
  1200. break;
  1201. case AK_STATE_HEADER:
  1202. case AK_STATE_DATA:
  1203. debugMsg(__CLASS__.'::_run() - Processing file data');
  1204. $status = $this->processFileData();
  1205. break;
  1206. case AK_STATE_DATAREAD:
  1207. case AK_STATE_POSTPROC:
  1208. debugMsg(__CLASS__.'::_run() - Calling post-processing class');
  1209. $this->postProcEngine->timestamp = $this->fileHeader->timestamp;
  1210. $status = $this->postProcEngine->process();
  1211. $this->propagateFromObject( $

Large files files are truncated, but you can click here to view the full file