本文整理汇总了PHP中Akeeba\Engine\Factory::getSecureSettings方法的典型用法代码示例。如果您正苦于以下问题:PHP Factory::getSecureSettings方法的具体用法?PHP Factory::getSecureSettings怎么用?PHP Factory::getSecureSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akeeba\Engine\Factory
的用法示例。
在下文中一共展示了Factory::getSecureSettings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onAdd
public function onAdd($tpl = null)
{
$media_folder = JUri::base() . '../media/com_akeeba/';
// Get a JSON representation of GUI data
$json = AkeebaHelperEscape::escapeJS(Factory::getEngineParamsProvider()->getJsonGuiDefinition(), '"\\');
$this->json = $json;
// Get profile ID
$profileid = Platform::getInstance()->get_active_profile();
$this->profileid = $profileid;
// Get profile name
$profileName = F0FModel::getTmpInstance('Profiles', 'AkeebaModel')->setId($profileid)->getItem()->description;
$this->profilename = $profileName;
// Get the root URI for media files
$this->mediadir = AkeebaHelperEscape::escapeJS($media_folder . 'theme/');
// Are the settings secured?
if (Platform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) {
$this->securesettings = -1;
} elseif (!Factory::getSecureSettings()->supportsEncryption()) {
$this->securesettings = 0;
} else {
JLoader::import('joomla.filesystem.file');
$filename = JPATH_COMPONENT_ADMINISTRATOR . '/engine/serverkey.php';
if (JFile::exists($filename)) {
$this->securesettings = 1;
} else {
$this->securesettings = 0;
}
}
// Add live help
AkeebaHelperIncludes::addHelp('config');
}
示例2: getSecureSettingsOption
/**
* Returns the support status of settings encryption. The possible values are:
* -1 Disabled by the user
* 0 Enabled by inactive (not supported by the server)
* 1 Enabled and active
*
* @return int
*/
private function getSecureSettingsOption()
{
// Encryption is disabled by the user
if (Platform::getInstance()->get_platform_configuration_option('useencryption', -1) == 0) {
return -1;
}
// Encryption is not supported by this server
if (!Factory::getSecureSettings()->supportsEncryption()) {
return 0;
}
$filename = JPATH_COMPONENT_ADMINISTRATOR . '/BackupEngine/serverkey.php';
// Encryption enabled, supported and a key file is present: encryption enabled
if (is_file($filename)) {
return 1;
}
// Encryption enabled, supported but and a key file is NOT present: encryption not available
return 0;
}
示例3: execute
/**
* 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']);
}
示例4: json_encode
<?php
/**
* @package AkeebaBackup
* @copyright Copyright (c)2009-2016 Nicholas K. Dionysopoulos
* @license GNU General Public License version 3, or later
* @since 1.3
*/
defined('_JEXEC') or die;
use Akeeba\Engine\Factory;
$data = $this->item->getData();
if (substr($data['configuration'], 0, 12) == '###AES128###') {
// Load the server key file if necessary
JLoader::import('joomla.filesystem.file');
if (!defined('AKEEBA_SERVERKEY')) {
$filename = JPATH_COMPONENT_ADMINISTRATOR . '/engine/serverkey.php';
include_once $filename;
}
$key = Factory::getSecureSettings()->getKey();
$data['configuration'] = Factory::getSecureSettings()->decryptSettings($data['configuration'], $key);
}
$defaultName = $this->input->get('view', 'joomla', 'cmd');
$filename = $this->input->get('basename', $defaultName, 'cmd');
$document = JFactory::getDocument();
$document->setName($filename);
echo json_encode($data);
示例5: load_configuration
/**
* Loads the current configuration off the database table
*
* @param int $profile_id The profile where to read the configuration from, defaults to current profile
*
* @return bool True if everything was read properly
*
* @throws DecryptionException When the settings cannot be decrypted
*/
public function load_configuration($profile_id = null)
{
// Load the database class
$db = Factory::getDatabase($this->get_platform_database_options());
// Get the active profile number, if no profile was specified
if (is_null($profile_id)) {
$profile_id = $this->get_active_profile();
}
// Initialize the registry
$registry = Factory::getConfiguration();
$registry->reset();
// Is the database connected?
if (!$db->connected()) {
return false;
}
// Load the INI format local configuration dump off the database
$sql = $db->getQuery(true)->select($db->qn('configuration'))->from($db->qn($this->tableNameProfiles))->where($db->qn('id') . ' = ' . $db->q($profile_id));
$db->setQuery($sql);
$databaseData = $db->loadResult();
if (empty($databaseData) || is_null($databaseData)) {
// No configuration was saved yet - store the defaults
$saved = $this->save_configuration($profile_id);
// If this is the case we probably don't have the necesary table. Throw an exception.
if (!$saved) {
throw new \RuntimeException("Could not save data to backup profile #{$profile_id}", 500);
}
return $this->load_configuration($profile_id);
}
// Configuration found. Convert to array format.
if (function_exists('get_magic_quotes_runtime')) {
if (@get_magic_quotes_runtime()) {
$databaseData = stripslashes($databaseData);
}
}
// Decrypt the data if required
$secureSettings = Factory::getSecureSettings();
$noData = empty($databaseData);
$databaseData = $secureSettings->decryptSettings($databaseData);
$dataArray = ParseIni::parse_ini_file($databaseData, true, true);
$parsedData = array();
// Did the decryption fail and we were asked to throw an exception?
if ($this->decryptionException && !$noData) {
// No decrypted data
if (empty($databaseData)) {
throw new DecryptionException();
}
// Corrupt data
if (!strstr($databaseData, '[akeeba]')) {
throw new DecryptionException();
}
}
unset($databaseData);
foreach ($dataArray as $section => $row) {
if ($section == 'volatile') {
continue;
}
if (is_array($row) && !empty($row)) {
foreach ($row as $key => $value) {
$parsedData["{$section}.{$key}"] = $value;
}
}
}
unset($dataArray);
// Import the configuration array
$protected_keys = $registry->getProtectedKeys();
$registry->resetProtectedKeys();
$registry->mergeArray($parsedData, false, false);
// Old profiles have advanced.proc_engine instead of advanced.postproc_engine. Migrate them.
$procEngine = $registry->get('akeeba.advanced.proc_engine', null);
if (!empty($procEngine)) {
$registry->set('akeeba.advanced.postproc_engine', $procEngine);
$registry->set('akeeba.advanced.proc_engine', null);
}
// Apply config overrides
if (is_array($this->configOverrides) && !empty($this->configOverrides)) {
$registry->mergeArray($this->configOverrides, false, false);
}
$registry->setProtectedKeys($protected_keys);
$registry->activeProfile = $profile_id;
}
示例6: enableSettingsEncryption
private function enableSettingsEncryption()
{
$key = $this->createSettingsKey();
if (empty($key) || $key == false) {
return;
}
// Loop all profiles and encrypt their settings
$profilesModel = F0FModel::getTmpInstance('Profiles', 'AkeebaModel');
$profiles = $profilesModel->getList(true);
$db = $this->getDBO();
if (!empty($profiles)) {
foreach ($profiles as $profile) {
$id = $profile->id;
$config = Factory::getSecureSettings()->encryptSettings($profile->configuration, $key);
$sql = $db->getQuery(true)->update($db->qn('#__ak_profiles'))->set($db->qn('configuration') . ' = ' . $db->q($config))->where($db->qn('id') . ' = ' . $db->q($id));
$db->setQuery($sql);
$db->execute();
}
}
}
示例7: enableSettingsEncryption
/**
* Enabled the encryption of profile settings. Existing settings are automatically encrypted.
*
* @return void
*/
private function enableSettingsEncryption()
{
$key = $this->createSettingsKey();
if (empty($key) || $key == false) {
return;
}
// Loop all profiles and encrypt their settings
/** @var Akeeba\Backup\Admin\Model\Profiles $profilesModel */
$profilesModel = $this->container->factory->model('Profiles')->tmpInstance();
$profiles = $profilesModel->get(true);
$db = $this->container->db;
if (!empty($profiles)) {
foreach ($profiles as $profile) {
$id = $profile->id;
$config = Factory::getSecureSettings()->encryptSettings($profile->configuration, $key);
$sql = $db->getQuery(true)->update($db->qn('#__ak_profiles'))->set($db->qn('configuration') . ' = ' . $db->q($config))->where($db->qn('id') . ' = ' . $db->q($id));
$db->setQuery($sql);
$db->execute();
}
}
}
示例8: load_configuration
/**
* Loads the current configuration off the database table
*
* @param int $profile_id The profile where to read the configuration from, defaults to current profile
*
* @return bool True if everything was read properly
*/
public function load_configuration($profile_id = null)
{
// Load the database class
$db = Factory::getDatabase($this->get_platform_database_options());
// Get the active profile number, if no profile was specified
if (is_null($profile_id)) {
$profile_id = $this->get_active_profile();
}
// Initialize the registry
$registry = Factory::getConfiguration();
$registry->reset();
// Load the INI format local configuration dump off the database
if ($db->connected()) {
$sql = $db->getQuery(true)->select($db->qn('configuration'))->from($db->qn($this->tableNameProfiles))->where($db->qn('id') . ' = ' . $db->q($profile_id));
$db->setQuery($sql);
$ini_data_local = $db->loadResult();
if (empty($ini_data_local) || is_null($ini_data_local)) {
// No configuration was saved yet - store the defaults
$this->save_configuration($profile_id);
} else {
// Configuration found. Convert to array format.
if (function_exists('get_magic_quotes_runtime')) {
if (@get_magic_quotes_runtime()) {
$ini_data_local = stripslashes($ini_data_local);
}
}
// Decrypt the data if required
$secureSettings = Factory::getSecureSettings();
$ini_data_local = $secureSettings->decryptSettings($ini_data_local);
$ini_data_local = ParseIni::parse_ini_file($ini_data_local, true, true);
$ini_data = array();
foreach ($ini_data_local as $section => $row) {
if ($section == 'volatile') {
continue;
}
if (is_array($row) && !empty($row)) {
foreach ($row as $key => $value) {
$ini_data["{$section}.{$key}"] = $value;
}
}
}
unset($ini_data_local);
// Import the configuration array
$protected_keys = $registry->getProtectedKeys();
$registry->resetProtectedKeys();
$registry->mergeArray($ini_data, false, false);
// Old profiles have advanced.proc_engine instead of advanced.postproc_engine. Migrate them.
$procEngine = $registry->get('akeeba.advanced.proc_engine', null);
if (!empty($procEngine)) {
$registry->set('akeeba.advanced.postproc_engine', $procEngine);
$registry->set('akeeba.advanced.proc_engine', null);
}
$registry->setProtectedKeys($protected_keys);
}
}
// Apply config overrides
if (is_array($this->configOverrides) && !empty($this->configOverrides)) {
$protected_keys = $registry->getProtectedKeys();
$registry->resetProtectedKeys();
$registry->mergeArray($this->configOverrides, false, false);
$registry->setProtectedKeys($protected_keys);
}
$registry->activeProfile = $profile_id;
}
示例9: load_configuration
/**
* Loads the current configuration off the database table
*
* @param int $profile_id The profile where to read the configuration from, defaults to current profile
*
* @return bool True if everything was read properly
*/
public function load_configuration($profile_id = null)
{
// Load the database class
$db = Factory::getDatabase($this->get_platform_database_options());
// Initialize the registry
$registry = Factory::getConfiguration();
$registry->reset();
// 1) Load the INI format local configuration dump:
$filename = realpath(dirname(__FILE__) . '/Config/config.ini');
$ini_data_local = file_get_contents($filename);
// Configuration found. Convert to array format.
$ini_data_local = \Akeeba\Engine\Util\ParseIni::parse_ini_file_php($ini_data_local, true, true);
$ini_data = array();
foreach ($ini_data_local as $section => $row) {
if (!empty($row)) {
foreach ($row as $key => $value) {
$ini_data["{$section}.{$key}"] = $value;
}
}
}
unset($ini_data_local);
// Import the configuration array
$protected_keys = $registry->getProtectedKeys();
$registry->resetProtectedKeys();
$registry->mergeArray($ini_data, false, false);
$registry->setProtectedKeys($protected_keys);
// 2) Load the INI format local configuration dump off the database:
$db = \Akeeba\Engine\Factory::getDatabase($this->get_platform_database_options());
$sql = $db->getQuery(true)->select($db->qn('configuration'))->from($db->qn($this->tableNameProfiles))->where($db->qn('id') . ' = ' . $db->q(1));
$db->setQuery($sql);
$ini_data_local = $db->loadResult();
if (empty($ini_data_local) || is_null($ini_data_local)) {
// No configuration was saved yet - store the defaults
$this->save_configuration($profile_id);
} else {
// Configuration found. Convert to array format.
if (function_exists('get_magic_quotes_runtime')) {
if (@get_magic_quotes_runtime()) {
$ini_data_local = stripslashes($ini_data_local);
}
}
// Decrypt the data if required
$ini_data_local = \Akeeba\Engine\Factory::getSecureSettings()->decryptSettings($ini_data_local);
$ini_data_local = \Akeeba\Engine\Util\ParseIni::parse_ini_file_php($ini_data_local, true, true);
$ini_data = array();
foreach ($ini_data_local as $section => $row) {
if (is_array($row) && !empty($row)) {
foreach ($row as $key => $value) {
$ini_data["{$section}.{$key}"] = $value;
}
}
}
unset($ini_data_local);
$allowedOverrides = array('akeeba.basic.clientsidewait', 'akeeba.basic.file_extensions', 'akeeba.basic.exclude_folders', 'akeeba.basic.exclude_files', 'akeeba.tuning.min_exec_time', 'akeeba.tuning.max_exec_time', 'akeeba.tuning.run_time_bias');
foreach ($allowedOverrides as $key) {
if (isset($ini_data[$key])) {
$registry->setKeyProtection($key, false);
$registry->set($key, $ini_data[$key]);
$registry->setKeyProtection($key, true);
}
}
}
$registry->activeProfile = 1;
// Apply config overrides
if (is_array($this->configOverrides) && !empty($this->configOverrides)) {
$protected_keys = $registry->getProtectedKeys();
$registry->resetProtectedKeys();
$registry->mergeArray($this->configOverrides, false, false);
$registry->setProtectedKeys($protected_keys);
}
$registry->activeProfile = $profile_id;
}