| Current Path : /home/digilove/www/41423/ |
| Current File : /home/digilove/www/41423/Json.tar |
Encapsulation/Base.php 0000644 00000010443 15235163322 0010740 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Encapsulation;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Json\EncapsulationInterface;
use Akeeba\Engine\Factory;
use Akeeba\Engine\Util\Encrypt;
abstract class Base implements EncapsulationInterface
{
/**
* The numeric ID of this encapsulation
*
* @var int
*/
protected $id = 0;
/**
* The code of this encapsulation
*
* @var string
*/
protected $code = 'ENCAPSULATION_VOID';
/**
* The description of this encapsulation
*
* @var string
*/
protected $description = 'Invalid encapsulation';
/**
* The encryption object which is set up for use with the JSON API
*
* @var Encrypt
*/
private $encryption;
/**
* Public constructor. Called by children to customise the encapsulation handler object
*
* @param int $id Numeric ID
* @param string $code Code
* @param string $description Human readable description
*/
function __construct($id, $code, $description)
{
$this->id = $id;
$this->code = strtoupper($code);
$this->description = $description;
}
/**
* Returns information about the encapsulation supported by this class. The return array has the following keys:
* id: The numeric ID of the encapsulation, e.g. 3
* code: The short code of the encapsulation, e.g. ENCAPSULATION_AESCTR256
* description: A human readable descriptions, e.g. "Data in AES-256 stream (CTR) mode encrypted JSON"
*
* @return array See above
*/
public function getInformation()
{
return array(
'id' => $this->id,
'code' => $this->code,
'description' => $this->description,
);
}
/**
* Checks if the request body authorises the user to use the API. Each encapsulation can implement its own
* authorisation method. This method is only called after the request body has been successfully decoded, therefore
* encrypted encapsulations can simply return true.
*
* @param string $serverKey The server key we need to check the authorisation
* @param array $body The decoded body (as returned by the decode() method)
*
* @return bool True if authorised
*/
public function isAuthorised($serverKey, $body)
{
return true;
}
/**
* Is the provided encapsulation type supported by this class?
*
* @param int $encapsulation Encapsulation type
*
* @return bool True if supported
*/
public function isSupported($encapsulation)
{
return $encapsulation == $this->id;
}
/**
* Decodes the data. For encrypted encapsulations this means base64-decoding the data, decrypting it and then JSON-
* decoding the result. If any error occurs along the way the appropriate exception is thrown.
*
* The data being decoded corresponds to the Request Body described in the API documentation
*
* @param string $serverKey The server key we need to decode data
* @param string $data Encoded data
*
* @return string The decoded data.
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be decoded successfully
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02.html
*/
public function decode($serverKey, $data)
{
return $data;
}
/**
* Encodes the data. The data is JSON encoded by this method before encapsulation takes place. Encrypted
* encapsulations will then encrypt the data and base64-encode it before returning it.
*
* The data being encoded correspond to the body > data structure described in the API documentation
*
* @param string $serverKey The server key we need to encode data
* @param mixed $data The data to encode, typically a string, array or object
*
* @return string The encapsulated data
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02s02.html
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be converted to JSON
*/
public function encode($serverKey, $data)
{
return $data;
}
}
Encapsulation/Raw.php 0000644 00000006053 15235163322 0010621 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Encapsulation;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Raw (plain text) encapsulation
*/
class Raw extends Base
{
/**
* Constructs the encapsulation handler object
*/
function __construct()
{
parent::__construct(1, 'ENCAPSULATION_RAW', 'Data in plain-text JSON');
}
/**
* Decodes the data. For encrypted encapsulations this means base64-decoding the data, decrypting it and then JSON-
* decoding the result. If any error occurs along the way the appropriate exception is thrown.
*
* The data being decoded corresponds to the Request Body described in the API documentation
*
* @param string $serverKey The server key we need to decode data
* @param string $data Encoded data
*
* @return string The decoded data.
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be decoded successfully
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02.html
*/
public function decode($serverKey, $data)
{
return $data;
}
/**
* Encodes the data. The data is JSON encoded by this method before encapsulation takes place. Encrypted
* encapsulations will then encrypt the data and base64-encode it before returning it.
*
* The data being encoded correspond to the body > data structure described in the API documentation
*
* @param string $serverKey The server key we need to encode data
* @param mixed $data The data to encode, typically a string, array or object
*
* @return string The encapsulated data
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02s02.html
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be converted to JSON
*/
public function encode($serverKey, $data)
{
return $data;
}
/**
* Checks if the request body authorises the user to use the API. Each encapsulation can implement its own
* authorisation method. This method is only called after the request body has been successfully decoded, therefore
* encrypted encapsulations can simply return true.
*
* @param string $serverKey The server key we need to check the authorisation
* @param array $body The decoded body (as returned by the decode() method)
*
* @return bool True if authorised
*/
public function isAuthorised($serverKey, $body)
{
$authenticated = false;
if (isset($body['challenge']) && (strpos($body['challenge'], ':') >= 2) && (strlen($body['challenge']) >= 3))
{
[$challengeData, $providedHash] = explode(':', $body['challenge']);
$computedHash = strtolower(md5($challengeData . $serverKey));
$authenticated = ($computedHash == $providedHash);
}
return $authenticated;
}
}
Task/AbstractTask.php 0000644 00000002743 15235163322 0010555 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
// Protect from unauthorized access
use Akeeba\Backup\Site\Model\Json\TaskInterface;
use FOF40\Container\Container;
class AbstractTask implements TaskInterface
{
/**
* The container of the component we belong to
*
* @var Container
*/
protected $container = null;
/**
* The method name
*
* @var string
*/
protected $methodName = '';
/**
* Public constructor
*
* @param Container $container The container of the component we belong to
*/
public function __construct(Container $container)
{
$this->container = $container;
$path = explode('\\', get_class($this));
$shortName = array_pop($path);
$this->methodName = lcfirst($shortName);
}
/**
* Return the JSON API task's name ("method" name). Remote clients will use it to call us.
*
* @return string
*/
public function getMethodName()
{
return $this->methodName;
}
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \LogicException(__CLASS__ . ' has not implemented its execute() method yet.');
}
}
Task/Browse.php 0000644 00000001377 15235163322 0007432 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Return folder browser results
*
* @deprecated
*/
class Browse extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/Delete.php 0000644 00000002174 15235163322 0007367 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Statistics;
use Akeeba\Engine\Platform;
/**
* Delete a backup record
*/
class Delete extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'backup_id' => 0,
);
$defConfig = array_merge($defConfig, $parameters);
$backup_id = (int)$defConfig['backup_id'];
/** @var Statistics $model */
$model = $this->container->factory->model('Statistics')->tmpInstance();
$model->setState('id', $backup_id);
try
{
$model->delete();
}
catch (\Exception $e)
{
throw new \RuntimeException($e->getMessage(), 500);
}
return true;
}
}
Task/DeleteFiles.php 0000644 00000002234 15235163322 0010347 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Statistics;
use Akeeba\Engine\Platform;
/**
* Delete the backup archives of a backup record
*/
class DeleteFiles extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'backup_id' => 0,
);
$defConfig = array_merge($defConfig, $parameters);
$backup_id = (int)$defConfig['backup_id'];
/** @var Statistics $model */
$model = $this->container->factory->model('Statistics')->tmpInstance();
$model->setState('id', $backup_id);
try
{
$model->deleteFile();
}
catch (\Exception $e)
{
throw new \RuntimeException($e->getMessage(), 500);
}
return true;
}
}
Task/DeleteProfile.php 0000644 00000001337 15235163322 0010710 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Delete a backup profile
*
* @deprecated
*/
class DeleteProfile extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/Download.php 0000644 00000004376 15235163322 0007742 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
/**
* Download a chunk of a backup archive over HTTP
*/
class Download extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'backup_id' => 0,
'part_id' => 1,
'segment' => 1,
'chunk_size' => 1
);
$defConfig = array_merge($defConfig, $parameters);
$backup_id = (int)$defConfig['backup_id'];
$part_id = (int)$defConfig['part_id'];
$segment = (int)$defConfig['segment'];
$chunk_size = (int)$defConfig['chunk_size'];
$backup_stats = Platform::getInstance()->get_statistics($backup_id);
if (empty($backup_stats))
{
// Backup record doesn't exist
throw new \RuntimeException('Invalid backup record identifier', 404);
}
$files = Factory::getStatistics()->get_all_filenames($backup_stats);
if ((($files === null ? 0 : count($files)) < $part_id) || ($part_id <= 0))
{
// Invalid part
throw new \RuntimeException('Invalid backup part', 404);
}
$file = $files[ $part_id - 1 ];
$filesize = @filesize($file);
$seekPos = $chunk_size * 1048576 * ($segment - 1);
if ($seekPos > $filesize)
{
// Trying to seek past end of file
throw new \RuntimeException('Invalid segment', 404);
}
$fp = fopen($file, 'r');
if ($fp === false)
{
// Could not read file
throw new \RuntimeException('Error reading backup archive', 500);
}
rewind($fp);
if (fseek($fp, $seekPos, SEEK_SET) === -1)
{
// Could not seek to position
throw new \RuntimeException('Error reading specified segment', 500);
}
$buffer = fread($fp, 1048576);
if ($buffer === false)
{
throw new \RuntimeException('Error reading specified segment', 500);
}
fclose($fp);
return base64_encode($buffer);
}
}
Task/DownloadDirect.php 0000644 00000007123 15235163322 0011066 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
/**
* Download an entire backup archive directly over HTTP
*/
class DownloadDirect extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'backup_id' => 0,
'part_id' => 1,
);
$defConfig = array_merge($defConfig, $parameters);
$backup_id = (int)$defConfig['backup_id'];
$part_id = (int)$defConfig['part_id'];
$backup_stats = Platform::getInstance()->get_statistics($backup_id);
if (empty($backup_stats))
{
// Backup record doesn't exist
@ob_end_clean();
header('HTTP/1.1 500 Invalid backup record identifier');
flush();
$this->container->platform->closeApplication();
}
$files = Factory::getStatistics()->get_all_filenames($backup_stats);
if ((($files === null ? 0 : count($files)) < $part_id) || ($part_id <= 0))
{
// Invalid part
@ob_end_clean();
header('HTTP/1.1 500 Invalid backup part');
flush();
$this->container->platform->closeApplication();
}
$filename = $files[ $part_id - 1 ];
@clearstatcache();
// For a certain unmentionable browser
if (function_exists('ini_get') && function_exists('ini_set'))
{
if (ini_get('zlib.output_compression'))
{
ini_set('zlib.output_compression', 'Off');
}
}
// Remove php's time limit
if (function_exists('ini_get') && function_exists('set_time_limit'))
{
if (!ini_get('safe_mode'))
{
@set_time_limit(0);
}
}
$basename = @basename($filename);
$fileSize = @filesize($filename);
$extension = strtolower(str_replace(".", "", strrchr($filename, ".")));
while (@ob_end_clean())
{
;
}
@clearstatcache();
// Send MIME headers
header('MIME-Version: 1.0');
header('Content-Disposition: attachment; filename="' . $basename . '"');
header('Content-Transfer-Encoding: binary');
header('Accept-Ranges: bytes');
switch ($extension)
{
case 'zip':
// ZIP MIME type
header('Content-Type: application/zip');
break;
default:
// Generic binary data MIME type
header('Content-Type: application/octet-stream');
break;
}
// Notify of file size, if this info is available
if ($fileSize > 0)
{
header('Content-Length: ' . @filesize($filename));
}
// Disable caching
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Expires: 0");
header('Pragma: no-cache');
flush();
if ($fileSize > 0)
{
// If the filesize is reported, use 1M chunks for echoing the data to the browser
$blockSize = 1048576; //1M chunks
$handle = @fopen($filename, "r");
// Now we need to loop through the file and echo out chunks of file data
if ($handle !== false)
{
while (!@feof($handle))
{
echo @fread($handle, $blockSize);
@ob_flush();
flush();
}
}
if ($handle !== false)
{
@fclose($handle);
}
}
else
{
// If the filesize is not reported, hope that readfile works
@readfile($filename);
}
flush();
$this->container->platform->closeApplication();
// Totally ignored, only added to make static analysis happy
return null;
}
}
Task/ExportConfiguration.php 0000644 00000003220 15235163322 0012167 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Profiles;
use Akeeba\Engine\Factory;
/**
* Export the profile's configuration
*/
class ExportConfiguration extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'profile' => 0,
);
$defConfig = array_merge($defConfig, $parameters);
$profile_id = (int)$defConfig['profile'];
if ($profile_id <= 0)
{
$profile_id = 1;
}
/** @var Profiles $profile */
$profile = $this->container->factory->model('Profiles')->tmpInstance();
$data = $profile->findOrFail($profile_id)->getData();
if (substr($data['configuration'], 0, 12) == '###AES128###')
{
// Load the server key file if necessary
if (!defined('AKEEBA_SERVERKEY'))
{
$filename = JPATH_COMPONENT_ADMINISTRATOR . '/BackupEngine/serverkey.php';
include_once $filename;
}
$key = Factory::getSecureSettings()->getKey();
$data['configuration'] = Factory::getSecureSettings()->decryptSettings($data['configuration'], $key);
}
return array(
'description' => $data['description'],
'configuration' => $data['configuration'],
'filters' => $data['filters'],
);
}
}
Task/GetBackupInfo.php 0000644 00000003361 15235163322 0010645 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
/**
* Get information for a given backup record
*/
class GetBackupInfo extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'backup_id' => 0,
);
$defConfig = array_merge($defConfig, $parameters);
$backup_id = (int)$defConfig['backup_id'];
// Get the basic statistics
$record = Platform::getInstance()->get_statistics($backup_id);
// Backup record doesn't exist
if (empty($record))
{
throw new \RuntimeException('Invalid backup record identifier', 404);
}
// Get a list of filenames
$filenames = Factory::getStatistics()->get_all_filenames($record);
if (empty($filenames))
{
// Archives are not stored on the server or no files produced
$record['filenames'] = array();
}
else
{
$filedata = array();
$i = 0;
// Get file sizes per part
foreach ($filenames as $file)
{
$i++;
$size = @filesize($file);
$size = is_numeric($size) ? $size : 0;
$filedata[] = array(
'part' => $i,
'name' => basename($file),
'size' => $size
);
}
// Add the file info to $record['filenames']
$record['filenames'] = $filedata;
}
return $record;
}
}
Task/GetDBEntities.php 0000644 00000001504 15235163322 0010613 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the database entities along with their filtering status (typically for rendering a GUI)
*
* @deprecated
*/
class GetDBEntities extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetDBFilters.php 0000644 00000001403 15235163322 0010435 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the database filters
*
* @deprecated
*/
class GetDBFilters extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetDBRoots.php 0000644 00000001362 15235163322 0010137 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Get the database roots (database definitions)
*
* @deprecated
*/
class GetDBRoots extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetFSEntities.php 0000644 00000001506 15235163322 0010640 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the filesystem entities along with their filtering status (typically for rendering a GUI)
*
* @deprecated
*/
class GetFSEntities extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetFSFilters.php 0000644 00000001402 15235163322 0010457 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the filesystem filters
*
* @deprecated
*/
class GetFSFilters extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetFSRoots.php 0000644 00000001410 15235163322 0010154 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Get the filesystem roots (site root and extra included directories)
*
* @deprecated
*/
class GetFSRoots extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetGUIConfiguration.php 0000644 00000001400 15235163322 0011770 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Get the GUI definitions for the configuration page
*
* @deprecated
*/
class GetGUIConfiguration extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetIncludedDBs.php 0000644 00000001351 15235163322 0010741 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Get the extra included databases
*
* @deprecated
*/
class GetIncludedDBs extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetIncludedDirectories.php 0000644 00000001363 15235163322 0012550 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Get the extra included directories
*
* @deprecated
*/
class GetIncludedDirectories extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetProfiles.php 0000644 00000002031 15235163322 0010400 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Profiles;
/**
* Get a list of known backup profiles
*/
class GetProfiles extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
/** @var Profiles $model */
$model = $this->container->factory->model('Profiles')->tmpInstance();
$profiles = $model->get(true);
$ret = array();
if (count($profiles))
{
foreach ($profiles as $profile)
{
$temp = new \stdClass();
$temp->id = $profile->id;
$temp->name = $profile->description;
$ret[] = $temp;
}
}
return $ret;
}
}
Task/GetRegexDBFilters.php 0000644 00000001413 15235163322 0011431 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the regex database filters
*
* @deprecated
*/
class GetRegexDBFilters extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetRegexFSFilters.php 0000644 00000001415 15235163322 0011456 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the regex filesystem filters
*
* @deprecated
*/
class GetRegexFSFilters extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/GetVersion.php 0000644 00000002300 15235163322 0010241 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Updates;
/**
* Get the version information of Akeeba Backup
*/
class GetVersion extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
/** @var Updates $model */
$model = $this->container->factory->model('Updates')->tmpInstance();
$updateInformation = $model->getUpdates();
if (is_array($updateInformation) && array_key_exists('releasenotes', $updateInformation))
{
unset ($updateInformation['releasenotes']);
}
$edition = AKEEBA_PRO ? 'pro' : 'core';
return (object)array(
'api' => AKEEBA_JSON_API_VERSION,
'component' => AKEEBA_VERSION,
'date' => AKEEBA_DATE,
'edition' => $edition,
'updateinfo' => $updateInformation,
);
}
}
Task/ImportConfiguration.php 0000644 00000002254 15235163322 0012166 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Profiles;
use Akeeba\Engine\Factory;
/**
* Import the profile's configuration
*/
class ImportConfiguration extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'profile' => 0,
'data' => null,
);
$defConfig = array_merge($defConfig, $parameters);
$profile_id = (int)$defConfig['profile'];
$data = $defConfig['data'];
if ($profile_id <= 0)
{
$profile_id = 0;
}
/** @var Profiles $profile */
$profile = $this->container->factory->model('Profiles')->tmpInstance();
if ($profile_id)
{
$profile->find($profile_id);
}
$profile->import($data);
return true;
}
}
Task/ListBackups.php 0000644 00000002174 15235163322 0010411 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Backup\Site\Model\Statistics;
use Akeeba\Engine\Platform;
/**
* List the backup records
*/
class ListBackups extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
// Get the passed configuration values
$defConfig = array(
'from' => 0,
'limit' => 50
);
$defConfig = array_merge($defConfig, $parameters);
$from = (int)$defConfig['from'];
$limit = (int)$defConfig['limit'];
/** @var Statistics $model */
$model = $this->container->factory->model('Statistics')->tmpInstance();
$model->setState('limitstart', $from);
$model->setState('limit', $limit);
return $model->getStatisticsListWithMeta(false);
}
}
Task/Log.php 0000644 00000001317 15235163322 0006704 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Get the log contents
*
* @deprecated
*/
class Log extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/RemoveIncludedDB.php 0000644 00000001417 15235163322 0011277 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Remove an extra database definition
*
* @deprecated
*/
class RemoveIncludedDB extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/RemoveIncludedDirectory.php 0000644 00000001454 15235163322 0012757 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
use RuntimeException;
/**
* Remove an extra directory definition
*
* @deprecated
*/
class RemoveIncludedDirectory extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SaveConfiguration.php 0000644 00000001366 15235163322 0011615 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Save the configuration for a given profile
*
* @deprecated
*/
class SaveConfiguration extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SaveProfile.php 0000644 00000001334 15235163322 0010401 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Saves a backup profile
*
* @deprecated
*/
class SaveProfile extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array())
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SetDBFilter.php 0000644 00000001405 15235163322 0010270 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Set or unset a database filter
*
* @deprecated
*/
class SetDBFilter extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SetFSFilter.php 0000644 00000001407 15235163322 0010315 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Set or unset a filesystem filter
*
* @deprecated
*/
class SetFSFilter extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SetIncludedDB.php 0000644 00000001424 15235163322 0010573 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Set up or edit an extra database definition
*
* @deprecated
*/
class SetIncludedDB extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SetIncludedDirectory.php 0000644 00000001434 15235163322 0012253 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Set up or edit an extra directory definition
*
* @deprecated
*/
class SetIncludedDirectory extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SetRegexDBFilter.php 0000644 00000001420 15235163322 0011260 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Set or unset a Regex database filter
*
* @deprecated
*/
class SetRegexDBFilter extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/SetRegexFSFilter.php 0000644 00000001422 15235163322 0011305 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Set or unset a Regex filesystem filter
*
* @deprecated
*/
class SetRegexFSFilter extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/StartBackup.php 0000644 00000005603 15235163322 0010410 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
use Joomla\CMS\Filter\InputFilter;
/**
* Start a backup job
*/
class StartBackup extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
$filter = InputFilter::getInstance();
// Get the passed configuration values
$defConfig = [
'profile' => 1,
'description' => '',
'comment' => '',
'backupid' => null,
'overrides' => [],
];
$defConfig = array_merge($defConfig, $parameters);
$profile = (int) $defConfig['profile'];
$profile = max(1, $profile); // Make sure $profile is a positive integer >= 1
$description = $filter->clean($defConfig['description'], 'string');
$comment = $filter->clean($defConfig['comment'], 'string');
$overrides = $filter->clean($defConfig['overrides'], 'array');
if (empty($description))
{
$description = $this->container->factory->model('Backup')->getDefaultDescription() . ' (JSON API)';
}
$this->container->platform->setSessionVar('profile', $profile, 'akeeba');
define('AKEEBA_PROFILE', $profile);
/**
* DO NOT REMOVE!
*
* The Model will only try to load the configuration after nuking the factory. This causes Profile 1 to be
* loaded first. Then it figures out it needs to load a different profile and it does – but the protected keys
* are NOT replaced, meaning that certain configuration parameters are not replaced. Most notably, the chain.
* This causes backups to behave weirdly. So, DON'T REMOVE THIS UNLESS WE REFACTOR THE MODEL.
*/
Platform::getInstance()->load_configuration($profile);
/** @var \Akeeba\Backup\Site\Model\Backup $model */
$model = $this->container->factory->model('Backup')->tmpInstance();
$model->setState('tag', 'json');
$model->setState('description', $description);
$model->setState('comment', $comment);
$model->setState('profile', $profile);
$array = $model->startBackup($overrides);
if ($array['Error'] != '')
{
throw new \RuntimeException('A backup error has occurred: ' . $array['Error'], 500);
}
// BackupID contains the numeric backup record ID. backupid contains the backup id (usually in the form id123)
$statistics = Factory::getStatistics();
$array['BackupID'] = $statistics->getId();
// Remote clients expect a boolean, not an integer.
$array['HasRun'] = ($array['HasRun'] === 0);
$array['Profile'] = Platform::getInstance()->get_active_profile();
return $array;
}
}
Task/StepBackup.php 0000644 00000004341 15235163322 0010224 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Akeeba\Engine\Factory;
use Akeeba\Engine\Platform;
use Joomla\CMS\Filter\InputFilter;
/**
* Step through a backup job
*/
class StepBackup extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
$filter = InputFilter::getInstance();
// Get the passed configuration values
$defConfig = [
'tag' => 'json',
'backupid' => null,
];
$defConfig = array_merge($defConfig, $parameters);
$tag = $filter->clean($defConfig['tag'], 'cmd');
$backupid = $filter->clean($defConfig['backupid'], 'cmd');
if (empty($backupid))
{
throw new \RuntimeException("JSON API :: stepBackup -- You have not provided the required backupid parameter. This parameter is MANDATORY since May 2016. Please update your client software to include this parameter.");
}
/** @var \Akeeba\Backup\Site\Model\Backup $model */
$model = $this->container->factory->model('Backup')->tmpInstance();
$profile = max(1, (int) $model->getLastBackupProfile($tag, $backupid));
$this->container->platform->setSessionVar('profile', $profile, 'akeeba');
define('AKEEBA_PROFILE', $profile);
$model->setState('tag', $tag);
$model->setState('backupid', $backupid);
$model->setState('profile', $profile);
$array = $model->stepBackup(true);
if ($array['Error'] != '')
{
throw new \RuntimeException('A backup error has occurred: ' . $array['Error'], 500);
}
// BackupID contains the numeric backup record ID. backupid contains the backup id (usually in the form id123)
$statistics = Factory::getStatistics();
$array['BackupID'] = $statistics->getId();
// Remote clients expect a boolean, not an integer.
$array['HasRun'] = ($array['HasRun'] === 0);
$array['Profile'] = Platform::getInstance()->get_active_profile();
return $array;
}
}
Task/TestDBConnection.php 0000644 00000001415 15235163322 0011327 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Test an extra database definition
*
* @deprecated
*/
class TestDBConnection extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Task/UpdateGetInformation.php 0000644 00000001412 15235163322 0012247 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json\Task;
// Protect from unauthorized access
defined('_JEXEC') || die();
use Joomla\CMS\Filter\InputFilter;
/**
* Get the update information
*
* @deprecated
*/
class UpdateGetInformation extends AbstractTask
{
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = [])
{
throw new \RuntimeException('This method is no longer supported by the Akeeba Remote JSON API', 501);
}
}
Encapsulation.php 0000644 00000015450 15235163322 0010071 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Handles data encapsulation
*/
class Encapsulation
{
/**
* Known encapsulation handlers
*
* @var EncapsulationInterface[]
*/
protected $handlers = array();
/**
* List of encapsulation types
*
* @var array
*/
protected $encapsulations = array();
/**
* The server key used to decrypt / encrypt data and check the authorisation
*
* @var string
*/
protected $serverKey;
/**
* Public constructor
*
* @param string $serverKey The server key used for data encyrption/decryption and authorisation checks
*/
public function __construct($serverKey)
{
$this->serverKey = $serverKey;
// Populate the list of encapsulation handlers
$this->initialiseHandlers();
}
/**
* Returns the encapsulation ID given its code. For example given $code == 'ENCAPSULATION_AESCTR256' it will return
* the ID integer 3.
*
* @param string $code The encapsulation code, e.g. ENCAPSULATION_AESCTR256
*
* @return int The numeric ID, e.g. 3
*/
public function getEncapsulationByCode($code)
{
$info = $this->getEncapsulationInfoByCode($code);
return $info['id'];
}
/**
* Returns the encapsulation information array given its code. For example given $code == 'ENCAPSULATION_AESCTR256'
* it will return the information for the data in AES-256 stream (CTR) mode encrypted JSON type.
*
* @param string $code The encapsulation code, e.g. ENCAPSULATION_AESCTR256
*
* @return array The information of the encapsulation handler
*/
public function getEncapsulationInfoByCode($code)
{
// Normalise the code
$code = strtoupper($code);
// If we have no idea what the encapsulation should be revert to raw (plain text)
if (!isset($this->encapsulations[$code]))
{
return $this->encapsulations['ENCAPSULATION_RAW'];
}
return $this->encapsulations[$code];
}
/**
* Decodes the data. For encrypted encapsulations this means base64-decoding the data, decrypting it and then JSON-
* decoding the result. If any error occurs along the way the appropriate exception is thrown.
*
* The data being decoded corresponds to the Request Body described in the API documentation
*
* @param int $encapsulation The encapsulation type
* @param string $data Encoded data
*
* @return array The decoded data.
*
* @throw \RuntimeException When the server capabilities don't match the requested encapsulation
* @throw \InvalidArgumentException When $data cannot be decoded successfully
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02.html
*/
public function decode($encapsulation, $data)
{
$body = null;
// Find the suitable handler and encode the data
foreach ($this->handlers as $handler)
{
if ($handler->isSupported($encapsulation))
{
$body = $handler->decode($this->serverKey, $data);
break;
}
}
// If the data cannot be encoded throw an exception
if (!isset($handler) || is_null($body))
{
throw new \RuntimeException('The requested encapsulation type is not supported', 503);
}
$authorised = true;
$body = rtrim($body, chr(0));
// Make sure it looks like a valid JSON string and is at least 12 characters (minimum valid message length)
if ((strlen($body) < 12) || (substr($body, 0, 1) != '{') || (substr($body, -1) != '}'))
{
$authorised = false;
}
// Try to JSON decode the body
if ($authorised)
{
$body = json_decode($body, true);
if (is_null($body))
{
$authorised = false;
}
elseif (!is_array($body))
{
$authorised = false;
}
}
// Make sure there is a requested method
if ($authorised)
{
if (!isset($body['method']) || empty($body['method']))
{
$authorised = false;
}
}
if ($authorised)
{
$authorised = $handler->isAuthorised($this->serverKey, $body);
}
if (!$authorised)
{
throw new \InvalidArgumentException('Authentication failed', 401);
}
return (array)$body;
}
/**
* Encodes the data. The data is JSON encoded by this method before encapsulation takes place. Encrypted
* encapsulations will then encrypt the data and base64-encode it before returning it.
*
* The data being encoded correspond to the body > data structure described in the API documentation
*
* @param int $encapsulation The encapsulation type
* @param mixed $data The data to encode, typically a string, array or object
* @param string $key Key to use for encoding. If not provided we revert to $this->serverKey
*
* @return string The encapsulated data
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02s02.html
*
* @throw \RuntimeException When the server capabilities don't match the requested encapsulation
* @throw \InvalidArgumentException When $data cannot be converted to JSON
*/
public function encode($encapsulation, $data, $key = null)
{
// Try to JSON-encode the data
$data = json_encode($data);
// If the data cannot be JSON-encoded throw an exception
if ($data === false)
{
throw new \InvalidArgumentException('Empty data cannot be encapsulated', 500);
}
// Make sure we have a valid key
if (empty($key))
{
$key = $this->serverKey;
}
// Find the suitable handler and encode the data
foreach ($this->handlers as $handler)
{
if ($handler->isSupported($encapsulation))
{
return $handler->encode($key, $data);
}
}
// If the data cannot be encoded throw an exception
$format = print_r($encapsulation, true);
throw new \RuntimeException("Data cannot be encapsulated in the requested format ($format)", 500);
}
/**
* Initialises the encapsulation handlers
*
* @return void
*/
protected function initialiseHandlers()
{
// Reset the arrays
$this->handlers = array();
$this->encapsulations = array();
// Look all files in the Encapsulation handlers' directory
$dh = new \DirectoryIterator(__DIR__ . '/Encapsulation');
/** @var \DirectoryIterator $entry */
foreach ($dh as $entry)
{
$fileName = $entry->getFilename();
// Ignore non-PHP files
if (substr($fileName, -4) != '.php')
{
continue;
}
// Ignore the Base class
if ($fileName == 'Base.php')
{
continue;
}
// Get the class name
$className = '\\Akeeba\\Backup\\Site\\Model\\Json\\Encapsulation\\' . substr($fileName, 0, -4);
// Check if the class really exists
if (!class_exists($className, true))
{
continue;
}
/** @var EncapsulationInterface $o */
$o = new $className;
$info = $o->getInformation();
$this->encapsulations[$info['code']] = $info;
$this->handlers[] = $o;
}
}
}
EncapsulationInterface.php 0000644 00000006176 15235163322 0011717 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json;
// Protect from unauthorized access
defined('_JEXEC') || die();
/**
* Interface for Encapsulation data handlers
*/
interface EncapsulationInterface
{
/**
* Is the provided encapsulation type supported by this class?
*
* @param int $encapsulation Encapsulation type
*
* @return bool True if supported
*/
public function isSupported($encapsulation);
/**
* Returns information about the encapsulation supported by this class. The return array has the following keys:
* id: The numeric ID of the encapsulation, e.g. 3
* code: The short code of the encapsulation, e.g. ENCAPSULATION_AESCTR256
* description: A human readable descriptions, e.g. "Data in AES-256 stream (CTR) mode encrypted JSON"
*
* @return array See above
*/
public function getInformation();
/**
* Decodes the data. For encrypted encapsulations this means base64-decoding the data, decrypting it but *NOT* JSON-
* decoding the result. If any error occurs along the way the appropriate exception is thrown.
*
* The data being decoded corresponds to the Request Body described in the API documentation
*
* @param string $serverKey The server key we need to decode data
* @param string $data Encoded data
*
* @return string The decoded data.
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be decoded successfully
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02.html
*/
public function decode($serverKey, $data);
/**
* Encodes the data. The data is JSON encoded by this method before encapsulation takes place. Encrypted
* encapsulations will then encrypt the data and base64-encode it before returning it.
*
* The data being encoded correspond to the body > data structure described in the API documentation
*
* @param string $serverKey The server key we need to encode data
* @param mixed $data The data to encode, typically a string, array or object
*
* @return string The encapsulated data
*
* @see https://www.akeeba.com/documentation/json-api/ar01s02s02.html
*
* @throws \RuntimeException When the server capabilities don't match the requested encapsulation
* @throws \InvalidArgumentException When $data cannot be converted to JSON
*/
public function encode($serverKey, $data);
/**
* Checks if the request body authorises the user to use the API. Each encapsulation can implement its own
* authorisation method. This method is only called after the request body has been successfully decoded, therefore
* encrypted encapsulations can simply return true.
*
* @param string $serverKey The server key we need to check the authorisation
* @param array $body The decoded body (as returned by the decode() method)
*
* @return bool True if authorised
*/
public function isAuthorised($serverKey, $body);
}
Task.php 0000644 00000005170 15235163322 0006164 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json;
// Protect from unauthorized access
defined('_JEXEC') || die();
use FOF40\Container\Container;
/**
* Handles task execution
*/
class Task
{
/**
* The component's container
*
* @var Container
*/
protected $container = null;
/** @var TaskInterface[] The task handlers known to us */
protected $handlers = array();
/**
* Public constructor. Populates the list of task handlers.
*/
public function __construct(Container $container)
{
$this->container = $container;
// Populate the list of task handlers
$this->initialiseHandlers();
}
/**
* Do I have a specific task handling method?
*
* @param string $method The method to check for
*
* @return bool
*/
public function hasMethod($method)
{
$method = strtolower($method);
return isset($this->handlers[$method]);
}
/**
* Execute a JSON API method
*
* @param string $method The method's name
* @param array $parameters The parameters to the method (optional)
*
* @return mixed
*
* @throws \RuntimeException When the method requested is not known to us
*/
public function execute($method, $parameters = array())
{
if ((!defined('AKEEBA_PRO') || !AKEEBA_PRO) && (time() >= 1583020800))
{
throw new \RuntimeException('Access denied', 503);
}
if (!$this->hasMethod($method))
{
throw new \RuntimeException("Invalid method $method", 405);
}
$method = strtolower($method);
return $this->handlers[$method]->execute($parameters);
}
/**
* Initialises the encapsulation handlers
*
* @return void
*/
protected function initialiseHandlers()
{
// Reset the array
$this->handlers = array();
// Look all files in the Task handlers' directory
$dh = new \DirectoryIterator(__DIR__ . '/Task');
/** @var \DirectoryIterator $entry */
foreach ($dh as $entry)
{
$fileName = $entry->getFilename();
// Ignore non-PHP files
if (substr($fileName, -4) != '.php')
{
continue;
}
// Ignore the Base class
if ($fileName == 'AbstractTask.php')
{
continue;
}
// Get the class name
$className = '\\Akeeba\\Backup\\Site\\Model\\Json\\Task\\' . substr($fileName, 0, -4);
// Check if the class really exists
if (!class_exists($className, true))
{
continue;
}
/** @var TaskInterface $o */
$o = new $className($this->container);
$name = $o->getMethodName();
$name = strtolower($name);
$this->handlers[$name] = $o;
}
}
}
TaskInterface.php 0000644 00000001674 15235163322 0010012 0 ustar 00 <?php
/**
* @package akeebabackup
* @copyright Copyright (c)2006-2023 Nicholas K. Dionysopoulos / Akeeba Ltd
* @license GNU General Public License version 3, or later
*/
namespace Akeeba\Backup\Site\Model\Json;
// Protect from unauthorized access
defined('_JEXEC') || die();
use FOF40\Container\Container;
/**
* Interface for JSON API tasks
*/
interface TaskInterface
{
/**
* Public constructor
*
* @param Container $container The container of the component we belong to
*/
public function __construct(Container $container);
/**
* Return the JSON API task's name ("method" name). Remote clients will use it to call us.
*
* @return string
*/
public function getMethodName();
/**
* Execute the JSON API task
*
* @param array $parameters The parameters to this task
*
* @return mixed
*
* @throws \RuntimeException In case of an error
*/
public function execute(array $parameters = array());
}