PageRenderTime 56ms CodeModel.GetById 31ms RepoModel.GetById 1ms app.codeStats 0ms

/administrator/components/com_akeeba/akeeba/abstract/postproc.php

https://bitbucket.org/kraymitchell/apex
PHP | 127 lines | 39 code | 15 blank | 73 comment | 2 complexity | fe3300d99bf4be36cbce87c4ca6eb0ed MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, BSD-3-Clause, LGPL-2.1, GPL-3.0
  1. <?php
  2. /**
  3. * Akeeba Engine
  4. * The modular PHP5 site backup engine
  5. * @copyright Copyright (c)2009-2012 Nicholas K. Dionysopoulos
  6. * @license GNU GPL version 3 or, at your option, any later version
  7. * @package akeebaengine
  8. *
  9. */
  10. // Protection against direct access
  11. defined('AKEEBAENGINE') or die('Restricted access');
  12. /**
  13. * Akeeba Engine post processing abstract class
  14. * @author Nicholas
  15. *
  16. */
  17. abstract class AEAbstractPostproc extends AEAbstractObject
  18. {
  19. /** @var bool Should we break the step before post-processing? */
  20. public $break_before = true;
  21. /** @var bool Should we break the step after post-processing? */
  22. public $break_after = true;
  23. /** @var bool Does this engine processes the files in a way that makes deleting the originals safe? */
  24. public $allow_deletes = true;
  25. /** @var bool Does this engine support remote file deletes? */
  26. public $can_delete = false;
  27. /** @var bool Does this engine support downloads to files? */
  28. public $can_download_to_file = false;
  29. /** @var bool Does this engine support downloads to browser? */
  30. public $can_download_to_browser = false;
  31. /** @var bool Set to true if raw data will be dumped to the browser when downloading the file to the browser. Set to false if a URL is returned instead. */
  32. public $downloads_to_browser_inline = false;
  33. /**
  34. * The remote absolute path to the file which was just processed. Leave null if the file is meant to
  35. * be non-retrievable, i.e. sent to email or any other one way service.
  36. * @var string
  37. */
  38. public $remote_path = null;
  39. /**
  40. * This function takes care of post-processing a backup archive's part, or the
  41. * whole backup archive if it's not a split archive type. If the process fails
  42. * it should return false. If it succeeds and the entirety of the file has been
  43. * processed, it should return true. If only a part of the file has been uploaded,
  44. * it must return 1.
  45. * @param string $absolute_filename Absolute path to the part we'll have to process
  46. * @return bool|int False on failure, true on success, 1 if more work is required
  47. */
  48. public abstract function processPart($absolute_filename);
  49. /**
  50. * Deletes a remote file
  51. * @param $path string Absolute path to the file we're deleting
  52. * @return bool|int False on failure, true on success, 1 if more work is required
  53. */
  54. public function delete($path)
  55. {
  56. return false;
  57. }
  58. /**
  59. * Downloads a remote file to a local file, optionally doing a range download. If the
  60. * download fails we return false. If the download succeeds we return true. If range
  61. * downloads are not supported, -1 is returned and nothing is written to disk.
  62. *
  63. * @param $remotePath string The path to the remote file
  64. * @param $localFile string The absolute path to the local file we're writing to
  65. * @param $fromOffset int|null The offset (in bytes) to start downloading from
  66. * @param $toOffset int|null The amount of data (in bytes) to download
  67. * @return bool|int True on success, false on failure, -1 if ranges are not supported
  68. */
  69. public function downloadToFile($remotePath, $localFile, $fromOffset = null, $length = null)
  70. {
  71. return false;
  72. }
  73. /**
  74. * Returns a public download URL or starts a browser-side download of a remote file.
  75. * In the case of a public download URL, a string is returned. If a browser-side
  76. * download is initiated, it returns true. In any other case (e.g. unsupported, not
  77. * found, etc) it returns false.
  78. *
  79. * @param $remotePath string The file to download
  80. * @return string|bool
  81. */
  82. public function downloadToBrowser($remotePath)
  83. {
  84. return false;
  85. }
  86. /**
  87. * Used to call arbitrary methods in this engine through an AJAX call
  88. *
  89. * @param string $method The method to call.
  90. * @param array $params Any parameters to send to the method, in array format
  91. * @return mixed Whatever the method has to return. It will be JSON encoded by the AJAX handler.
  92. */
  93. public function customAPICall($method, $params = array())
  94. {
  95. if(!method_exists($this, $method)) {
  96. header('HTTP/1.0 501 Not Implemented');
  97. exit();
  98. } else {
  99. return call_user_func_array(array($this, $method), $params);
  100. }
  101. }
  102. /**
  103. * Opens an OAuth window (perform redirection), or return false if this is not supported
  104. *
  105. * @param array $params Any parameters required to launch OAuth
  106. * @return boolean|void False if not supported, or nothing (redirection performed) otherwise.
  107. */
  108. public function oauthOpen($params = array())
  109. {
  110. return false;
  111. }
  112. }