PageRenderTime 62ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 1ms

/administrator/components/com_joomlaupdate/restore.php

https://bitbucket.org/asosso/joomla25
PHP | 5744 lines | 3936 code | 669 blank | 1139 comment | 678 complexity | ec97629bbbfd771985a3bbd699df18e5 MD5 | raw file
Possible License(s): LGPL-2.1

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

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