mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-03 16:51:40 +09:00
Move remainder of system config actions to respective controller classes
This commit is contained in:
parent
ba18143dd6
commit
b9e55c05e6
11 changed files with 921 additions and 1026 deletions
|
|
@ -10,7 +10,6 @@
|
|||
*/
|
||||
class AdminAdminController extends Admin
|
||||
{
|
||||
|
||||
/**
|
||||
* initialization
|
||||
* @return void
|
||||
|
|
@ -334,47 +333,6 @@ class AdminAdminController extends Admin
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviroment gathering agreement
|
||||
* @return void
|
||||
*/
|
||||
public function procAdminEnviromentGatheringAgreement()
|
||||
{
|
||||
$isAgree = Context::get('is_agree');
|
||||
if($isAgree == 'true')
|
||||
{
|
||||
$_SESSION['enviroment_gather'] = 'Y';
|
||||
}
|
||||
else
|
||||
{
|
||||
$_SESSION['enviroment_gather'] = 'N';
|
||||
}
|
||||
|
||||
$redirectUrl = getNotEncodedUrl('', 'module', 'admin');
|
||||
$this->setRedirectUrl($redirectUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin config update
|
||||
* @return void
|
||||
*/
|
||||
public function procAdminUpdateConfig()
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
$oAdminConfig = $oModuleModel->getModuleConfig('admin');
|
||||
if(!is_object($oAdminConfig))
|
||||
{
|
||||
$oAdminConfig = new stdClass();
|
||||
}
|
||||
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->insertModuleConfig('admin', $oAdminConfig);
|
||||
$this->setMessage('success_updated', 'info');
|
||||
|
||||
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminSetup');
|
||||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Admin logo delete
|
||||
* @return void
|
||||
|
|
@ -396,33 +354,6 @@ class AdminAdminController extends Admin
|
|||
$this->setRedirectUrl($returnUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert favorite
|
||||
* @return object query result
|
||||
*/
|
||||
public function _insertFavorite($site_srl, $module, $type = 'module')
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::insertFavorite($module, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete favorite
|
||||
* @return object query result
|
||||
*/
|
||||
public function _deleteFavorite($favoriteSrl)
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteFavorite($favoriteSrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all favorite
|
||||
* @return object query result
|
||||
*/
|
||||
public function _deleteAllFavorite()
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteAllFavorites();
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove admin icon
|
||||
* @return object|void
|
||||
|
|
@ -444,608 +375,79 @@ class AdminAdminController extends Admin
|
|||
}
|
||||
else
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('fail_to_delete');
|
||||
throw new Exception('fail_to_delete');
|
||||
}
|
||||
$this->setMessage('success_deleted');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update notification configuration.
|
||||
*/
|
||||
public function procAdminUpdateNotification()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Load advanced mailer module (for lang).
|
||||
$oAdvancedMailerAdminView = getAdminView('advanced_mailer');
|
||||
|
||||
// Validate the mail sender's information.
|
||||
if (!$vars->mail_default_name)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sender_name_is_empty');
|
||||
}
|
||||
if (!$vars->mail_default_from)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sender_email_is_empty');
|
||||
}
|
||||
if (!Mail::isVaildMailAddress($vars->mail_default_from))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sender_email_is_invalid');
|
||||
}
|
||||
if ($vars->mail_default_reply_to && !Mail::isVaildMailAddress($vars->mail_default_reply_to))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_reply_to_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the mail driver.
|
||||
$mail_drivers = Rhymix\Framework\Mail::getSupportedDrivers();
|
||||
$mail_driver = $vars->mail_driver;
|
||||
if (!array_key_exists($mail_driver, $mail_drivers))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the mail driver settings.
|
||||
$mail_driver_config = array();
|
||||
foreach ($mail_drivers[$mail_driver]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{'mail_' . $mail_driver . '_' . $conf_name} ?: null;
|
||||
if (!$conf_value)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_smtp_host_is_invalid');
|
||||
}
|
||||
$mail_driver_config[$conf_name] = $conf_value;
|
||||
}
|
||||
|
||||
// Validate the SMS driver.
|
||||
$sms_drivers = Rhymix\Framework\SMS::getSupportedDrivers();
|
||||
$sms_driver = $vars->sms_driver;
|
||||
if (!array_key_exists($sms_driver, $sms_drivers))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the SMS driver settings.
|
||||
$sms_driver_config = array();
|
||||
foreach ($sms_drivers[$sms_driver]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null;
|
||||
if (!$conf_value)
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sms_config_invalid');
|
||||
}
|
||||
$sms_driver_config[$conf_name] = $conf_value;
|
||||
}
|
||||
foreach ($sms_drivers[$sms_driver]['optional'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null;
|
||||
$sms_driver_config[$conf_name] = $conf_value;
|
||||
}
|
||||
|
||||
// Validate the selected Push drivers.
|
||||
$push_config = array('types' => array());
|
||||
$push_config['allow_guest_device'] = $vars->allow_guest_device === 'Y' ? true : false;
|
||||
$push_drivers = Rhymix\Framework\Push::getSupportedDrivers();
|
||||
$push_driver_list = $vars->push_driver ?: [];
|
||||
foreach ($push_driver_list as $driver_name)
|
||||
{
|
||||
if (array_key_exists($driver_name, $push_drivers))
|
||||
{
|
||||
$push_config['types'][$driver_name] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the Push driver settings.
|
||||
foreach ($push_drivers as $driver_name => $driver_definition)
|
||||
{
|
||||
foreach ($push_drivers[$driver_name]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = utf8_trim($vars->{'push_' . $driver_name . '_' . $conf_name}) ?: null;
|
||||
if (!$conf_value && in_array($driver_name, $push_driver_list))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_advanced_mailer_push_config_invalid');
|
||||
}
|
||||
$push_config[$driver_name][$conf_name] = $conf_value;
|
||||
|
||||
// Save certificates in a separate file and only store the filename in config.php.
|
||||
if ($conf_name === 'certificate')
|
||||
{
|
||||
$filename = Rhymix\Framework\Config::get('push.' . $driver_name . '.certificate');
|
||||
if (!$filename)
|
||||
{
|
||||
$filename = './files/config/' . $driver_name . '/cert-' . Rhymix\Framework\Security::getRandom(32) . '.pem';
|
||||
}
|
||||
|
||||
if ($conf_value !== null)
|
||||
{
|
||||
Rhymix\Framework\Storage::write($filename, $conf_value);
|
||||
$push_config[$driver_name][$conf_name] = $filename;
|
||||
}
|
||||
elseif (Rhymix\Framework\Storage::exists($filename))
|
||||
{
|
||||
Rhymix\Framework\Storage::delete($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($push_drivers[$driver_name]['optional'] as $conf_name)
|
||||
{
|
||||
$conf_value = utf8_trim($vars->{'push_' . $driver_name . '_' . $conf_name}) ?: null;
|
||||
$push_config[$driver_name][$conf_name] = $conf_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Save advanced mailer config.
|
||||
getController('module')->updateModuleConfig('advanced_mailer', (object)array(
|
||||
'sender_name' => trim($vars->mail_default_name),
|
||||
'sender_email' => trim($vars->mail_default_from),
|
||||
'force_sender' => toBool($vars->mail_force_default_sender),
|
||||
'reply_to' => trim($vars->mail_default_reply_to),
|
||||
));
|
||||
|
||||
// Save member config.
|
||||
getController('module')->updateModuleConfig('member', (object)array(
|
||||
'webmaster_name' => trim($vars->mail_default_name),
|
||||
'webmaster_email' => trim($vars->mail_default_from),
|
||||
));
|
||||
|
||||
// Save system config.
|
||||
Rhymix\Framework\Config::set("mail.default_name", trim($vars->mail_default_name));
|
||||
Rhymix\Framework\Config::set("mail.default_from", trim($vars->mail_default_from));
|
||||
Rhymix\Framework\Config::set("mail.default_force", toBool($vars->mail_force_default_sender));
|
||||
Rhymix\Framework\Config::set("mail.default_reply_to", trim($vars->mail_default_reply_to));
|
||||
Rhymix\Framework\Config::set("mail.type", $mail_driver);
|
||||
Rhymix\Framework\Config::set("mail.$mail_driver", $mail_driver_config);
|
||||
Rhymix\Framework\Config::set("sms.default_from", trim($vars->sms_default_from));
|
||||
Rhymix\Framework\Config::set("sms.default_force", toBool($vars->sms_force_default_sender));
|
||||
Rhymix\Framework\Config::set("sms.type", $sms_driver);
|
||||
Rhymix\Framework\Config::set("sms.$sms_driver", $sms_driver_config);
|
||||
Rhymix\Framework\Config::set("sms.allow_split.sms", toBool($vars->allow_split_sms));
|
||||
Rhymix\Framework\Config::set("sms.allow_split.lms", toBool($vars->allow_split_lms));
|
||||
Rhymix\Framework\Config::set("push", $push_config);
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigNotification'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update security configuration.
|
||||
*/
|
||||
public function procAdminUpdateSecurity()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Media Filter iframe/embed whitelist
|
||||
$whitelist = $vars->mediafilter_whitelist;
|
||||
$whitelist = array_filter(array_map('trim', preg_split('/[\r\n]/', $whitelist)), function($item) {
|
||||
return $item !== '';
|
||||
});
|
||||
$whitelist = array_unique(array_map(function($item) {
|
||||
return Rhymix\Framework\Filters\MediaFilter::formatPrefix($item);
|
||||
}, $whitelist));
|
||||
natcasesort($whitelist);
|
||||
Rhymix\Framework\Config::set('mediafilter.whitelist', array_values($whitelist));
|
||||
Rhymix\Framework\Config::set('mediafilter.iframe', []);
|
||||
Rhymix\Framework\Config::set('mediafilter.object', []);
|
||||
|
||||
// HTML classes
|
||||
$classes = $vars->mediafilter_classes;
|
||||
$classes = array_filter(array_map('trim', preg_split('/[\r\n]/', $classes)), function($item) {
|
||||
return preg_match('/^[a-zA-Z0-9_-]+$/u', $item);
|
||||
});
|
||||
natcasesort($classes);
|
||||
Rhymix\Framework\Config::set('mediafilter.classes', array_values($classes));
|
||||
|
||||
// Robot user agents
|
||||
$robot_user_agents = $vars->robot_user_agents;
|
||||
$robot_user_agents = array_filter(array_map('trim', preg_split('/[\r\n]/', $robot_user_agents)), function($item) {
|
||||
return $item !== '';
|
||||
});
|
||||
Rhymix\Framework\Config::set('security.robot_user_agents', array_values($robot_user_agents));
|
||||
|
||||
// Remove old embed filter
|
||||
$config = Rhymix\Framework\Config::getAll();
|
||||
unset($config['embedfilter']);
|
||||
Rhymix\Framework\Config::setAll($config);
|
||||
|
||||
// Admin IP access control
|
||||
$allowed_ip = array_map('trim', preg_split('/[\r\n]/', $vars->admin_allowed_ip));
|
||||
$allowed_ip = array_unique(array_filter($allowed_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip)) {
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_ip');
|
||||
}
|
||||
|
||||
$denied_ip = array_map('trim', preg_split('/[\r\n]/', $vars->admin_denied_ip));
|
||||
$denied_ip = array_unique(array_filter($denied_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
if (!Rhymix\Framework\Filters\IpFilter::validateRanges($denied_ip)) {
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_ip');
|
||||
}
|
||||
|
||||
$oMemberAdminModel = getAdminModel('member');
|
||||
if (!$oMemberAdminModel->getMemberAdminIPCheck($allowed_ip, $denied_ip))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_current_ip_will_be_denied');
|
||||
}
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
$vars->use_samesite = preg_replace('/[^a-zA-Z]/', '', $vars->use_samesite);
|
||||
if ($vars->use_samesite === 'None' && ($vars->use_session_ssl !== 'Y' || $site_module_info->security !== 'always'))
|
||||
{
|
||||
$vars->use_samesite = '';
|
||||
}
|
||||
|
||||
Rhymix\Framework\Config::set('admin.allow', array_values($allowed_ip));
|
||||
Rhymix\Framework\Config::set('admin.deny', array_values($denied_ip));
|
||||
Rhymix\Framework\Config::set('session.samesite', $vars->use_samesite);
|
||||
Rhymix\Framework\Config::set('session.use_keys', $vars->use_session_keys === 'Y');
|
||||
Rhymix\Framework\Config::set('session.use_ssl', $vars->use_session_ssl === 'Y');
|
||||
Rhymix\Framework\Config::set('session.use_ssl_cookies', $vars->use_cookies_ssl === 'Y');
|
||||
Rhymix\Framework\Config::set('security.check_csrf_token', $vars->check_csrf_token === 'Y');
|
||||
Rhymix\Framework\Config::set('security.nofollow', $vars->use_nofollow === 'Y');
|
||||
|
||||
// Save
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSecurity'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update advanced configuration.
|
||||
*/
|
||||
public function procAdminUpdateAdvanced()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Object cache
|
||||
if ($vars->object_cache_type)
|
||||
{
|
||||
if ($vars->object_cache_type === 'memcached' || $vars->object_cache_type === 'redis')
|
||||
{
|
||||
if (starts_with('unix:/', $vars->object_cache_host))
|
||||
{
|
||||
$cache_servers = array(substr($vars->object_cache_host, 5));
|
||||
}
|
||||
elseif (starts_with('/', $vars->object_cache_host))
|
||||
{
|
||||
$cache_servers = array($vars->object_cache_host);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (trim($vars->object_cache_user) !== '' || trim($vars->object_cache_pass) !== '')
|
||||
{
|
||||
$auth = sprintf('%s:%s@', urlencode(trim($vars->object_cache_user)), urlencode(trim($vars->object_cache_pass)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$auth = '';
|
||||
}
|
||||
$cache_servers = array($vars->object_cache_type . '://' . $auth . $vars->object_cache_host . ':' . intval($vars->object_cache_port));
|
||||
}
|
||||
|
||||
if ($vars->object_cache_type === 'redis')
|
||||
{
|
||||
$cache_servers[0] .= '#' . intval($vars->object_cache_dbnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_servers = array();
|
||||
}
|
||||
if (!Rhymix\Framework\Cache::getDriverInstance($vars->object_cache_type, $cache_servers))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_cache_handler_not_supported');
|
||||
}
|
||||
Rhymix\Framework\Config::set('cache', array(
|
||||
'type' => $vars->object_cache_type,
|
||||
'ttl' => intval($vars->cache_default_ttl ?: 86400),
|
||||
'servers' => $cache_servers,
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
Rhymix\Framework\Config::set('cache', array());
|
||||
}
|
||||
|
||||
// Cache truncate method
|
||||
if (in_array($vars->cache_truncate_method, array('delete', 'empty')))
|
||||
{
|
||||
Rhymix\Framework\Config::set('cache.truncate_method', $vars->cache_truncate_method);
|
||||
}
|
||||
|
||||
// Thumbnail settings
|
||||
$oDocumentModel = getModel('document');
|
||||
$document_config = $oDocumentModel->getDocumentConfig();
|
||||
$document_config->thumbnail_target = $vars->thumbnail_target ?: 'all';
|
||||
$document_config->thumbnail_type = $vars->thumbnail_type ?: 'fill';
|
||||
$document_config->thumbnail_quality = intval($vars->thumbnail_quality) ?: 75;
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->insertModuleConfig('document', $document_config);
|
||||
|
||||
// Mobile view
|
||||
Rhymix\Framework\Config::set('mobile.enabled', $vars->use_mobile_view === 'Y');
|
||||
Rhymix\Framework\Config::set('mobile.tablets', $vars->tablets_as_mobile === 'Y');
|
||||
Rhymix\Framework\Config::set('mobile.viewport', utf8_trim($vars->mobile_viewport));
|
||||
if (Rhymix\Framework\Config::get('use_mobile_view') !== null)
|
||||
{
|
||||
Rhymix\Framework\Config::set('use_mobile_view', $vars->use_mobile_view === 'Y');
|
||||
}
|
||||
|
||||
// Languages and time zone
|
||||
$enabled_lang = $vars->enabled_lang;
|
||||
if (!in_array($vars->default_lang, $enabled_lang ?: []))
|
||||
{
|
||||
$enabled_lang[] = $vars->default_lang;
|
||||
}
|
||||
Rhymix\Framework\Config::set('locale.default_lang', $vars->default_lang);
|
||||
Rhymix\Framework\Config::set('locale.enabled_lang', array_values($enabled_lang));
|
||||
Rhymix\Framework\Config::set('locale.auto_select_lang', $vars->auto_select_lang === 'Y');
|
||||
Rhymix\Framework\Config::set('locale.default_timezone', $vars->default_timezone);
|
||||
|
||||
// Other settings
|
||||
Rhymix\Framework\Config::set('url.rewrite', intval($vars->use_rewrite));
|
||||
Rhymix\Framework\Config::set('use_rewrite', $vars->use_rewrite > 0);
|
||||
Rhymix\Framework\Config::set('session.delay', $vars->delay_session === 'Y');
|
||||
Rhymix\Framework\Config::set('session.use_db', $vars->use_db_session === 'Y');
|
||||
Rhymix\Framework\Config::set('view.manager_layout', $vars->manager_layout ?: 'module');
|
||||
Rhymix\Framework\Config::set('view.minify_scripts', $vars->minify_scripts ?: 'common');
|
||||
Rhymix\Framework\Config::set('view.concat_scripts', $vars->concat_scripts ?: 'none');
|
||||
Rhymix\Framework\Config::set('view.server_push', $vars->use_server_push === 'Y');
|
||||
Rhymix\Framework\Config::set('view.use_gzip', $vars->use_gzip === 'Y');
|
||||
|
||||
// Save
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigAdvanced'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update debug configuration.
|
||||
*/
|
||||
public function procAdminUpdateDebug()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Save display type settings
|
||||
$display_type = array_values(array_filter($vars->debug_display_type ?: [], function($str) {
|
||||
return in_array($str, ['panel', 'comment', 'file']);
|
||||
}));
|
||||
|
||||
// Debug settings
|
||||
Rhymix\Framework\Config::set('debug.enabled', $vars->debug_enabled === 'Y');
|
||||
Rhymix\Framework\Config::set('debug.log_slow_queries', max(0, floatval($vars->debug_log_slow_queries)));
|
||||
Rhymix\Framework\Config::set('debug.log_slow_triggers', max(0, floatval($vars->debug_log_slow_triggers)));
|
||||
Rhymix\Framework\Config::set('debug.log_slow_widgets', max(0, floatval($vars->debug_log_slow_widgets)));
|
||||
Rhymix\Framework\Config::set('debug.log_slow_remote_requests', max(0, floatval($vars->debug_log_slow_remote_requests)));
|
||||
Rhymix\Framework\Config::set('debug.display_type', $display_type);
|
||||
Rhymix\Framework\Config::set('debug.display_to', strval($vars->debug_display_to) ?: 'admin');
|
||||
Rhymix\Framework\Config::set('debug.query_comment', $vars->debug_query_comment === 'Y');
|
||||
Rhymix\Framework\Config::set('debug.query_full_stack', $vars->debug_query_full_stack === 'Y');
|
||||
Rhymix\Framework\Config::set('debug.write_error_log', strval($vars->debug_write_error_log) ?: 'fatal');
|
||||
|
||||
// Debug content
|
||||
$debug_content = array_values($vars->debug_display_content ?: array());
|
||||
Rhymix\Framework\Config::set('debug.display_content', $debug_content);
|
||||
|
||||
// Log filename
|
||||
$log_filename = strval($vars->debug_log_filename);
|
||||
$log_filename_today = str_replace(array('YYYY', 'YY', 'MM', 'DD'), array(
|
||||
getInternalDateTime(RX_TIME, 'Y'),
|
||||
getInternalDateTime(RX_TIME, 'y'),
|
||||
getInternalDateTime(RX_TIME, 'm'),
|
||||
getInternalDateTime(RX_TIME, 'd'),
|
||||
), $log_filename);
|
||||
if (file_exists(RX_BASEDIR . $log_filename_today) && !is_writable(RX_BASEDIR . $log_filename_today))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_debug_log_filename_not_writable');
|
||||
}
|
||||
if (!file_exists(dirname(RX_BASEDIR . $log_filename)) && !FileHandler::makeDir(dirname(RX_BASEDIR . $log_filename)))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_debug_log_filename_not_writable');
|
||||
}
|
||||
if (!is_writable(dirname(RX_BASEDIR . $log_filename)))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_debug_log_filename_not_writable');
|
||||
}
|
||||
Rhymix\Framework\Config::set('debug.log_filename', $log_filename);
|
||||
|
||||
// IP access control
|
||||
$allowed_ip = array_map('trim', preg_split('/[\r\n]/', $vars->debug_allowed_ip));
|
||||
$allowed_ip = array_unique(array_filter($allowed_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip)) {
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_ip');
|
||||
}
|
||||
Rhymix\Framework\Config::set('debug.allow', array_values($allowed_ip));
|
||||
|
||||
// Save
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigDebug'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update SEO configuration.
|
||||
*/
|
||||
public function procAdminUpdateSEO()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
$args = new stdClass;
|
||||
$args->meta_keywords = $vars->site_meta_keywords ? implode(', ', array_map('trim', explode(',', $vars->site_meta_keywords))) : '';
|
||||
$args->meta_description = trim(utf8_normalize_spaces($vars->site_meta_description));
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->updateModuleConfig('module', $args);
|
||||
|
||||
Rhymix\Framework\Config::set('seo.main_title', trim(utf8_normalize_spaces($vars->seo_main_title)));
|
||||
Rhymix\Framework\Config::set('seo.subpage_title', trim(utf8_normalize_spaces($vars->seo_subpage_title)));
|
||||
Rhymix\Framework\Config::set('seo.document_title', trim(utf8_normalize_spaces($vars->seo_document_title)));
|
||||
|
||||
Rhymix\Framework\Config::set('seo.og_enabled', $vars->og_enabled === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_extract_description', $vars->og_extract_description === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_extract_images', $vars->og_extract_images === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_extract_hashtags', $vars->og_extract_hashtags === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_use_nick_name', $vars->og_use_nick_name === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.og_use_timestamps', $vars->og_use_timestamps === 'Y');
|
||||
Rhymix\Framework\Config::set('seo.twitter_enabled', $vars->twitter_enabled === 'Y');
|
||||
|
||||
// Save
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSEO'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sitelock configuration.
|
||||
*/
|
||||
public function procAdminUpdateSitelock()
|
||||
{
|
||||
$vars = Context::gets('sitelock_locked', 'sitelock_allowed_ip', 'sitelock_title', 'sitelock_message');
|
||||
|
||||
$allowed_ip = array_map('trim', preg_split('/[\r\n]/', $vars->sitelock_allowed_ip));
|
||||
$allowed_ip = array_unique(array_filter($allowed_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
|
||||
if (!Rhymix\Framework\Filters\IpFilter::validateRanges($allowed_ip))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_invalid_ip');
|
||||
}
|
||||
|
||||
Rhymix\Framework\Config::set('lock.locked', $vars->sitelock_locked === 'Y');
|
||||
Rhymix\Framework\Config::set('lock.title', trim($vars->sitelock_title));
|
||||
Rhymix\Framework\Config::set('lock.message', trim($vars->sitelock_message));
|
||||
Rhymix\Framework\Config::set('lock.allow', array_values($allowed_ip));
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSitelock'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update FTP configuration.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminUpdateFTPInfo()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
$vars->ftp_path = str_replace('\\', '/', rtrim(trim($vars->ftp_path), '/\\')) . '/';
|
||||
if (strlen($vars->ftp_pass) === 0)
|
||||
{
|
||||
$vars->ftp_pass = Rhymix\Framework\Config::get('ftp.pass');
|
||||
}
|
||||
|
||||
// Test FTP connection.
|
||||
if ($vars->ftp_sftp !== 'Y')
|
||||
{
|
||||
if (!($conn = @ftp_connect($vars->ftp_host, $vars->ftp_port, 3)))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_not_connected');
|
||||
}
|
||||
if (!@ftp_login($conn, $vars->ftp_user, $vars->ftp_pass))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_invalid_auth_info');
|
||||
}
|
||||
if (!@ftp_pasv($conn, $vars->ftp_pasv === 'Y'))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_cannot_set_passive_mode');
|
||||
}
|
||||
if (!@ftp_chdir($conn, $vars->ftp_path))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_invalid_path');
|
||||
}
|
||||
ftp_close($conn);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!function_exists('ssh2_connect'))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('disable_sftp_support');
|
||||
}
|
||||
if (!($conn = ssh2_connect($vars->ftp_host, $vars->ftp_port)))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_not_connected');
|
||||
}
|
||||
if (!@ssh2_auth_password($conn, $vars->ftp_user, $vars->ftp_pass))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_invalid_auth_info');
|
||||
}
|
||||
if (!@($sftp = ssh2_sftp($conn)))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_sftp_error');
|
||||
}
|
||||
if (!@ssh2_sftp_stat($sftp, $vars->ftp_path . 'common/defaults/config.php'))
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_ftp_invalid_path');
|
||||
}
|
||||
unset($sftp, $conn);
|
||||
}
|
||||
|
||||
// Save settings.
|
||||
Rhymix\Framework\Config::set('ftp.host', $vars->ftp_host);
|
||||
Rhymix\Framework\Config::set('ftp.port', $vars->ftp_port);
|
||||
Rhymix\Framework\Config::set('ftp.user', $vars->ftp_user);
|
||||
Rhymix\Framework\Config::set('ftp.pass', $vars->ftp_pass);
|
||||
Rhymix\Framework\Config::set('ftp.path', $vars->ftp_path);
|
||||
Rhymix\Framework\Config::set('ftp.pasv', $vars->ftp_pasv === 'Y');
|
||||
Rhymix\Framework\Config::set('ftp.sftp', $vars->ftp_sftp === 'Y');
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigFtp'));
|
||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove FTP configuration.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminRemoveFTPInfo()
|
||||
{
|
||||
Rhymix\Framework\Config::set('ftp.host', null);
|
||||
Rhymix\Framework\Config::set('ftp.port', null);
|
||||
Rhymix\Framework\Config::set('ftp.user', null);
|
||||
Rhymix\Framework\Config::set('ftp.pass', null);
|
||||
Rhymix\Framework\Config::set('ftp.path', null);
|
||||
Rhymix\Framework\Config::set('ftp.pasv', true);
|
||||
Rhymix\Framework\Config::set('ftp.sftp', false);
|
||||
if (!Rhymix\Framework\Config::save())
|
||||
{
|
||||
throw new Rhymix\Framework\Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_deleted');
|
||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enviroment gathering agreement
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminEnviromentGatheringAgreement()
|
||||
{
|
||||
$redirectUrl = getNotEncodedUrl('', 'module', 'admin');
|
||||
$this->setRedirectUrl($redirectUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update admin module config
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function procAdminUpdateConfig()
|
||||
{
|
||||
return new BaseObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert favorite.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function _insertFavorite($site_srl, $module, $type = 'module')
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::insertFavorite($module, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete favorite.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function _deleteFavorite($favoriteSrl)
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteFavorite($favoriteSrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all favorites.
|
||||
*
|
||||
* @deprecated
|
||||
*/
|
||||
public function _deleteAllFavorite()
|
||||
{
|
||||
return Rhymix\Modules\Admin\Models\Favorite::deleteAllFavorites();
|
||||
}
|
||||
}
|
||||
/* End of file admin.admin.controller.php */
|
||||
/* Location: ./modules/admin/admin.admin.controller.php */
|
||||
|
|
|
|||
|
|
@ -18,272 +18,6 @@ class AdminAdminView extends Admin
|
|||
{
|
||||
Rhymix\Modules\Admin\Controllers\Base::getInstance()->loadAdminMenu($module);
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Notification Settings page
|
||||
* @return void
|
||||
*/
|
||||
public function dispAdminConfigNotification()
|
||||
{
|
||||
// Load advanced mailer module (for lang).
|
||||
$oAdvancedMailerAdminView = getAdminView('advanced_mailer');
|
||||
|
||||
// Load advanced mailer config.
|
||||
$advanced_mailer_config = $oAdvancedMailerAdminView->getConfig();
|
||||
Context::set('advanced_mailer_config', $advanced_mailer_config);
|
||||
|
||||
// Load member config.
|
||||
$member_config = getModel('module')->getModuleConfig('member');
|
||||
Context::set('member_config', $member_config);
|
||||
Context::set('webmaster_name', !empty($member_config->webmaster_name) ? $member_config->webmaster_name : 'webmaster');
|
||||
Context::set('webmaster_email', $member_config->webmaster_email ?? '');
|
||||
|
||||
// Load module config.
|
||||
$module_config = getModel('module')->getModuleConfig('module');
|
||||
Context::set('module_config', $module_config);
|
||||
|
||||
// Load mail drivers.
|
||||
$mail_drivers = Rhymix\Framework\Mail::getSupportedDrivers();
|
||||
uasort($mail_drivers, function($a, $b) {
|
||||
if ($a['name'] === 'Dummy') return -1;
|
||||
if ($b['name'] === 'Dummy') return 1;
|
||||
return strnatcasecmp($a['name'], $b['name']);
|
||||
});
|
||||
Context::set('mail_drivers', $mail_drivers);
|
||||
Context::set('mail_driver', config('mail.type') ?: 'mailfunction');
|
||||
|
||||
// Load SMS drivers.
|
||||
$sms_drivers = Rhymix\Framework\SMS::getSupportedDrivers();
|
||||
uasort($sms_drivers, function($a, $b) {
|
||||
if ($a['name'] === 'Dummy') return -1;
|
||||
if ($b['name'] === 'Dummy') return 1;
|
||||
return strnatcasecmp($a['name'], $b['name']);
|
||||
});
|
||||
Context::set('sms_drivers', $sms_drivers);
|
||||
Context::set('sms_driver', config('sms.type') ?: 'dummy');
|
||||
|
||||
// Load Push drivers.
|
||||
$push_drivers = Rhymix\Framework\Push::getSupportedDrivers();
|
||||
uasort($push_drivers, function($a, $b) { return strcmp($a['name'], $b['name']); });
|
||||
Context::set('push_drivers', $push_drivers);
|
||||
Context::set('push_config', config('push') ?: []);
|
||||
$apns_certificate = false;
|
||||
if ($apns_certificate_filename = config('push.apns.certificate'))
|
||||
{
|
||||
$apns_certificate = Rhymix\Framework\Storage::read($apns_certificate_filename);
|
||||
}
|
||||
Context::set('apns_certificate', $apns_certificate);
|
||||
|
||||
// Workaround for compatibility with older version of Amazon SES driver.
|
||||
config('mail.ses.api_key', config('mail.ses.api_user'));
|
||||
config('mail.ses.api_secret', config('mail.ses.api_pass'));
|
||||
|
||||
$this->setTemplateFile('config_notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Security Settings page
|
||||
* @return void
|
||||
*/
|
||||
public function dispAdminConfigSecurity()
|
||||
{
|
||||
// Load embed filter.
|
||||
context::set('mediafilter_whitelist', implode(PHP_EOL, Rhymix\Framework\Filters\MediaFilter::getWhitelist()));
|
||||
context::set('mediafilter_classes', implode(PHP_EOL, Rhymix\Framework\Config::get('mediafilter.classes') ?: array()));
|
||||
|
||||
// Load robot user agents.
|
||||
$robot_user_agents = Rhymix\Framework\Config::get('security.robot_user_agents') ?: array();
|
||||
Context::set('robot_user_agents', implode(PHP_EOL, $robot_user_agents));
|
||||
|
||||
// Admin IP access control
|
||||
$allowed_ip = Rhymix\Framework\Config::get('admin.allow');
|
||||
Context::set('admin_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
||||
$denied_ip = Rhymix\Framework\Config::get('admin.deny');
|
||||
Context::set('admin_denied_ip', implode(PHP_EOL, $denied_ip));
|
||||
Context::set('remote_addr', RX_CLIENT_IP);
|
||||
|
||||
// Session and cookie security settings
|
||||
Context::set('use_samesite', Rhymix\Framework\Config::get('session.samesite'));
|
||||
Context::set('use_session_keys', Rhymix\Framework\Config::get('session.use_keys'));
|
||||
Context::set('use_session_ssl', Rhymix\Framework\Config::get('session.use_ssl'));
|
||||
Context::set('use_cookies_ssl', Rhymix\Framework\Config::get('session.use_ssl_cookies'));
|
||||
Context::set('check_csrf_token', Rhymix\Framework\Config::get('security.check_csrf_token'));
|
||||
Context::set('use_nofollow', Rhymix\Framework\Config::get('security.nofollow'));
|
||||
|
||||
$this->setTemplateFile('config_security');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Advanced Settings page
|
||||
* @return void
|
||||
*/
|
||||
public function dispAdminConfigAdvanced()
|
||||
{
|
||||
// Object cache
|
||||
$object_cache_types = Rhymix\Framework\Cache::getSupportedDrivers();
|
||||
$object_cache_type = Rhymix\Framework\Config::get('cache.type');
|
||||
if ($object_cache_type)
|
||||
{
|
||||
$cache_default_ttl = Rhymix\Framework\Config::get('cache.ttl');
|
||||
$cache_servers = Rhymix\Framework\Config::get('cache.servers');
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_config = array_first(Rhymix\Framework\Config::get('cache'));
|
||||
if ($cache_config)
|
||||
{
|
||||
$object_cache_type = preg_replace('/^memcache$/', 'memcached', preg_replace('/:.+$/', '', $cache_config));
|
||||
}
|
||||
else
|
||||
{
|
||||
$object_cache_type = 'dummy';
|
||||
}
|
||||
$cache_default_ttl = 86400;
|
||||
$cache_servers = Rhymix\Framework\Config::get('cache');
|
||||
}
|
||||
|
||||
Context::set('object_cache_types', $object_cache_types);
|
||||
Context::set('object_cache_type', $object_cache_type);
|
||||
Context::set('cache_default_ttl', $cache_default_ttl);
|
||||
|
||||
if ($cache_servers)
|
||||
{
|
||||
if (preg_match('!^(/.+)(#[0-9]+)?$!', array_first($cache_servers), $matches))
|
||||
{
|
||||
Context::set('object_cache_host', $matches[1]);
|
||||
Context::set('object_cache_port', 0);
|
||||
Context::set('object_cache_dbnum', $matches[2] ? substr($matches[2], 1) : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('object_cache_host', parse_url(array_first($cache_servers), PHP_URL_HOST) ?: null);
|
||||
Context::set('object_cache_port', parse_url(array_first($cache_servers), PHP_URL_PORT) ?: null);
|
||||
Context::set('object_cache_user', parse_url(array_first($cache_servers), PHP_URL_USER) ?? '');
|
||||
Context::set('object_cache_pass', parse_url(array_first($cache_servers), PHP_URL_PASS) ?? '');
|
||||
$cache_dbnum = preg_replace('/[^\d]/', '', parse_url(array_first($cache_servers), PHP_URL_FRAGMENT) ?: parse_url(array_first($cache_servers), PHP_URL_PATH));
|
||||
Context::set('object_cache_dbnum', $cache_dbnum === '' ? 1 : intval($cache_dbnum));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('object_cache_host', null);
|
||||
Context::set('object_cache_port', null);
|
||||
Context::set('object_cache_dbnum', 1);
|
||||
}
|
||||
Context::set('cache_truncate_method', Rhymix\Framework\Config::get('cache.truncate_method'));
|
||||
|
||||
// Thumbnail settings
|
||||
$oDocumentModel = getModel('document');
|
||||
$config = $oDocumentModel->getDocumentConfig();
|
||||
Context::set('thumbnail_target', $config->thumbnail_target ?: 'all');
|
||||
Context::set('thumbnail_type', $config->thumbnail_type ?: 'fill');
|
||||
Context::set('thumbnail_quality', $config->thumbnail_quality ?: 75);
|
||||
if ($config->thumbnail_type === 'none')
|
||||
{
|
||||
Context::set('thumbnail_target', 'none');
|
||||
Context::set('thumbnail_type', 'fill');
|
||||
}
|
||||
|
||||
// Default and enabled languages
|
||||
Context::set('supported_lang', Rhymix\Framework\Lang::getSupportedList());
|
||||
Context::set('default_lang', Rhymix\Framework\Config::get('locale.default_lang'));
|
||||
Context::set('enabled_lang', Rhymix\Framework\Config::get('locale.enabled_lang'));
|
||||
Context::set('auto_select_lang', Rhymix\Framework\Config::get('locale.auto_select_lang'));
|
||||
|
||||
// Default time zone
|
||||
Context::set('timezones', Rhymix\Framework\DateTime::getTimezoneList());
|
||||
Context::set('selected_timezone', Rhymix\Framework\Config::get('locale.default_timezone'));
|
||||
|
||||
// Other settings
|
||||
Context::set('use_rewrite', Rhymix\Framework\Router::getRewriteLevel());
|
||||
Context::set('use_mobile_view', (config('mobile.enabled') !== null ? config('mobile.enabled') : config('use_mobile_view')) ? true : false);
|
||||
Context::set('tablets_as_mobile', config('mobile.tablets') ? true : false);
|
||||
Context::set('mobile_viewport', config('mobile.viewport') ?? HTMLDisplayHandler::DEFAULT_VIEWPORT);
|
||||
Context::set('use_ssl', Rhymix\Framework\Config::get('url.ssl'));
|
||||
Context::set('delay_session', Rhymix\Framework\Config::get('session.delay'));
|
||||
Context::set('use_db_session', Rhymix\Framework\Config::get('session.use_db'));
|
||||
Context::set('manager_layout', Rhymix\Framework\Config::get('view.manager_layout'));
|
||||
Context::set('minify_scripts', Rhymix\Framework\Config::get('view.minify_scripts'));
|
||||
Context::set('concat_scripts', Rhymix\Framework\Config::get('view.concat_scripts'));
|
||||
Context::set('use_server_push', Rhymix\Framework\Config::get('view.server_push'));
|
||||
Context::set('use_gzip', Rhymix\Framework\Config::get('view.use_gzip'));
|
||||
|
||||
$this->setTemplateFile('config_advanced');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Debug Settings page
|
||||
* @return void
|
||||
*/
|
||||
public function dispAdminConfigDebug()
|
||||
{
|
||||
// Load debug settings.
|
||||
Context::set('debug_enabled', Rhymix\Framework\Config::get('debug.enabled'));
|
||||
Context::set('debug_log_slow_queries', Rhymix\Framework\Config::get('debug.log_slow_queries'));
|
||||
Context::set('debug_log_slow_triggers', Rhymix\Framework\Config::get('debug.log_slow_triggers'));
|
||||
Context::set('debug_log_slow_widgets', Rhymix\Framework\Config::get('debug.log_slow_widgets'));
|
||||
Context::set('debug_log_slow_remote_requests', Rhymix\Framework\Config::get('debug.log_slow_remote_requests'));
|
||||
Context::set('debug_log_filename', Rhymix\Framework\Config::get('debug.log_filename') ?: 'files/debug/YYYYMMDD.php');
|
||||
Context::set('debug_display_type', (array)Rhymix\Framework\Config::get('debug.display_type'));
|
||||
Context::set('debug_display_content', Rhymix\Framework\Config::get('debug.display_content'));
|
||||
Context::set('debug_display_to', Rhymix\Framework\Config::get('debug.display_to'));
|
||||
Context::set('debug_query_comment', Rhymix\Framework\Config::get('debug.query_comment'));
|
||||
Context::set('debug_query_full_stack', Rhymix\Framework\Config::get('debug.query_full_stack'));
|
||||
Context::set('debug_write_error_log', Rhymix\Framework\Config::get('debug.write_error_log'));
|
||||
|
||||
// IP access control
|
||||
$allowed_ip = Rhymix\Framework\Config::get('debug.allow');
|
||||
Context::set('debug_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
||||
Context::set('remote_addr', RX_CLIENT_IP);
|
||||
|
||||
$this->setTemplateFile('config_debug');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Debug Settings page
|
||||
* @return void
|
||||
*/
|
||||
public function dispAdminConfigSEO()
|
||||
{
|
||||
// Meta keywords and description
|
||||
$oModuleModel = getModel('module');
|
||||
$config = $oModuleModel->getModuleConfig('module');
|
||||
Context::set('site_meta_keywords', escape($config->meta_keywords ?? ''));
|
||||
Context::set('site_meta_description', escape($config->meta_description ?? ''));
|
||||
|
||||
// Titles
|
||||
Context::set('seo_main_title', escape(Rhymix\Framework\Config::get('seo.main_title') ?: '$SITE_TITLE - $SITE_SUBTITLE'));
|
||||
Context::set('seo_subpage_title', escape(Rhymix\Framework\Config::get('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE'));
|
||||
Context::set('seo_document_title', escape(Rhymix\Framework\Config::get('seo.document_title') ?: '$SITE_TITLE - $DOCUMENT_TITLE'));
|
||||
|
||||
// OpenGraph metadata
|
||||
Context::set('og_enabled', Rhymix\Framework\Config::get('seo.og_enabled'));
|
||||
Context::set('og_extract_description', Rhymix\Framework\Config::get('seo.og_extract_description'));
|
||||
Context::set('og_extract_images', Rhymix\Framework\Config::get('seo.og_extract_images'));
|
||||
Context::set('og_extract_hashtags', Rhymix\Framework\Config::get('seo.og_extract_hashtags'));
|
||||
Context::set('og_use_nick_name', Rhymix\Framework\Config::get('seo.og_use_nick_name'));
|
||||
Context::set('og_use_timestamps', Rhymix\Framework\Config::get('seo.og_use_timestamps'));
|
||||
Context::set('twitter_enabled', Rhymix\Framework\Config::get('seo.twitter_enabled'));
|
||||
|
||||
$this->setTemplateFile('config_seo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display Sitelock Settings page
|
||||
* @return void
|
||||
*/
|
||||
public function dispAdminConfigSitelock()
|
||||
{
|
||||
Context::set('sitelock_locked', Rhymix\Framework\Config::get('lock.locked'));
|
||||
Context::set('sitelock_title', escape(Rhymix\Framework\Config::get('lock.title')));
|
||||
Context::set('sitelock_message', escape(Rhymix\Framework\Config::get('lock.message')));
|
||||
|
||||
$allowed_ip = Rhymix\Framework\Config::get('lock.allow') ?: array();
|
||||
Context::set('sitelock_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
||||
Context::set('remote_addr', \RX_CLIENT_IP);
|
||||
|
||||
$this->setTemplateFile('config_sitelock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display FTP Configuration(settings) page
|
||||
|
|
@ -291,10 +25,7 @@ class AdminAdminView extends Admin
|
|||
*/
|
||||
public function dispAdminConfigFtp()
|
||||
{
|
||||
Context::set('ftp_info', Rhymix\Framework\Config::get('ftp'));
|
||||
Context::set('sftp_support', function_exists('ssh2_sftp'));
|
||||
|
||||
$this->setTemplateFile('config_ftp');
|
||||
throw new Rhymix\Framework\Exceptions\FeatureDisabled;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -17,28 +17,24 @@
|
|||
<action name="procAdminUpdateDomainConfig" class="Controllers\SystemConfig\Domains" />
|
||||
<action name="procAdminInsertDomain" class="Controllers\SystemConfig\Domains" />
|
||||
<action name="procAdminDeleteDomain" class="Controllers\SystemConfig\Domains" />
|
||||
<!-- System Config:: Other -->
|
||||
<action name="dispAdminConfigNotification" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="dispAdminConfigSecurity" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="dispAdminConfigAdvanced" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="dispAdminConfigDebug" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="dispAdminConfigSEO" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="dispAdminConfigSitelock" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateNotification" type="controller" />
|
||||
<action name="procAdminUpdateSecurity" type="controller" />
|
||||
<action name="procAdminUpdateAdvanced" type="controller" />
|
||||
<action name="procAdminUpdateDebug" type="controller" />
|
||||
<action name="procAdminUpdateSEO" type="controller" />
|
||||
<action name="procAdminUpdateSitelock" type="controller" />
|
||||
<!-- System Config: Other -->
|
||||
<action name="dispAdminConfigNotification" class="Controllers\SystemConfig\Notification" type="view" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateNotification" class="Controllers\SystemConfig\Notification" />
|
||||
<action name="dispAdminConfigSecurity" class="Controllers\SystemConfig\Security" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateSecurity" class="Controllers\SystemConfig\Security" />
|
||||
<action name="dispAdminConfigAdvanced" class="Controllers\SystemConfig\Advanced" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateAdvanced" class="Controllers\SystemConfig\Advanced" />
|
||||
<action name="dispAdminConfigDebug" class="Controllers\SystemConfig\Debug" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateDebug" class="Controllers\SystemConfig\Debug" />
|
||||
<action name="dispAdminConfigSEO" class="Controllers\SystemConfig\SEO" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateSEO" class="Controllers\SystemConfig\SEO" />
|
||||
<action name="dispAdminConfigSitelock" class="Controllers\SystemConfig\SiteLock" menu_name="adminConfigurationGeneral" />
|
||||
<action name="procAdminUpdateSitelock" class="Controllers\SystemConfig\SiteLock" />
|
||||
|
||||
<action name="procAdminRemoveIcons" type="controller" />
|
||||
<action name="procAdminRecompileCacheFile" type="controller" />
|
||||
<action name="procAdminInsertDefaultDesignInfo" type="controller" />
|
||||
<action name="procAdminToggleFavorite" type="controller" />
|
||||
<action name="procAdminUpdateConfig" type="controller" />
|
||||
|
||||
<action name="procAdminUpdateFTPInfo" type="controller" />
|
||||
<action name="procAdminRemoveFTPInfo" type="controller" />
|
||||
<action name="procAdminFaviconUpload" type="controller" />
|
||||
<!-- Admin Interface Config -->
|
||||
<action name="dispAdminSetup" type="view" menu_name="adminMenuSetup" menu_index="true" />
|
||||
|
|
@ -46,7 +42,10 @@
|
|||
<action name="procAdminMenuReset" type="controller" />
|
||||
<!-- Legacy API -->
|
||||
<action name="dispAdminConfigFtp" type="view" menu_name="adminConfigurationFtp" menu_index="true" />
|
||||
<action name="procAdminUpdateFTPInfo" type="controller" />
|
||||
<action name="procAdminRemoveFTPInfo" type="controller" />
|
||||
<action name="procAdminEnviromentGatheringAgreement" type="controller" />
|
||||
<action name="procAdminUpdateConfig" type="controller" />
|
||||
<action name="getSiteAllList" type="model" permission="root" />
|
||||
</actions>
|
||||
<menus>
|
||||
|
|
|
|||
226
modules/admin/controllers/systemconfig/Advanced.php
Normal file
226
modules/admin/controllers/systemconfig/Advanced.php
Normal file
|
|
@ -0,0 +1,226 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Admin\Controllers\SystemConfig;
|
||||
|
||||
use Context;
|
||||
use HTMLDisplayHandler;
|
||||
use Rhymix\Framework\Cache;
|
||||
use Rhymix\Framework\Config;
|
||||
use Rhymix\Framework\DateTime;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\Lang;
|
||||
use Rhymix\Framework\Router;
|
||||
use Rhymix\Modules\Admin\Controllers\Base;
|
||||
|
||||
class Advanced extends Base
|
||||
{
|
||||
/**
|
||||
* Display Advanced Settings page
|
||||
*/
|
||||
public function dispAdminConfigAdvanced()
|
||||
{
|
||||
// Object cache
|
||||
$object_cache_types = Cache::getSupportedDrivers();
|
||||
$object_cache_type = Config::get('cache.type');
|
||||
if ($object_cache_type)
|
||||
{
|
||||
$cache_default_ttl = Config::get('cache.ttl');
|
||||
$cache_servers = Config::get('cache.servers');
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_config = array_first(Config::get('cache'));
|
||||
if ($cache_config)
|
||||
{
|
||||
$object_cache_type = preg_replace('/^memcache$/', 'memcached', preg_replace('/:.+$/', '', $cache_config));
|
||||
}
|
||||
else
|
||||
{
|
||||
$object_cache_type = 'dummy';
|
||||
}
|
||||
$cache_default_ttl = 86400;
|
||||
$cache_servers = Config::get('cache');
|
||||
}
|
||||
|
||||
Context::set('object_cache_types', $object_cache_types);
|
||||
Context::set('object_cache_type', $object_cache_type);
|
||||
Context::set('cache_default_ttl', $cache_default_ttl);
|
||||
|
||||
if ($cache_servers)
|
||||
{
|
||||
if (preg_match('!^(/.+)(#[0-9]+)?$!', array_first($cache_servers), $matches))
|
||||
{
|
||||
Context::set('object_cache_host', $matches[1]);
|
||||
Context::set('object_cache_port', 0);
|
||||
Context::set('object_cache_dbnum', $matches[2] ? substr($matches[2], 1) : 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('object_cache_host', parse_url(array_first($cache_servers), PHP_URL_HOST) ?: null);
|
||||
Context::set('object_cache_port', parse_url(array_first($cache_servers), PHP_URL_PORT) ?: null);
|
||||
Context::set('object_cache_user', parse_url(array_first($cache_servers), PHP_URL_USER) ?? '');
|
||||
Context::set('object_cache_pass', parse_url(array_first($cache_servers), PHP_URL_PASS) ?? '');
|
||||
$cache_dbnum = preg_replace('/[^\d]/', '', parse_url(array_first($cache_servers), PHP_URL_FRAGMENT) ?: parse_url(array_first($cache_servers), PHP_URL_PATH));
|
||||
Context::set('object_cache_dbnum', $cache_dbnum === '' ? 1 : intval($cache_dbnum));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Context::set('object_cache_host', null);
|
||||
Context::set('object_cache_port', null);
|
||||
Context::set('object_cache_dbnum', 1);
|
||||
}
|
||||
Context::set('cache_truncate_method', Config::get('cache.truncate_method'));
|
||||
|
||||
// Thumbnail settings
|
||||
$oDocumentModel = getModel('document');
|
||||
$config = $oDocumentModel->getDocumentConfig();
|
||||
Context::set('thumbnail_target', $config->thumbnail_target ?: 'all');
|
||||
Context::set('thumbnail_type', $config->thumbnail_type ?: 'fill');
|
||||
Context::set('thumbnail_quality', $config->thumbnail_quality ?: 75);
|
||||
if ($config->thumbnail_type === 'none')
|
||||
{
|
||||
Context::set('thumbnail_target', 'none');
|
||||
Context::set('thumbnail_type', 'fill');
|
||||
}
|
||||
|
||||
// Default and enabled languages
|
||||
Context::set('supported_lang', Lang::getSupportedList());
|
||||
Context::set('default_lang', Config::get('locale.default_lang'));
|
||||
Context::set('enabled_lang', Config::get('locale.enabled_lang'));
|
||||
Context::set('auto_select_lang', Config::get('locale.auto_select_lang'));
|
||||
|
||||
// Default time zone
|
||||
Context::set('timezones', DateTime::getTimezoneList());
|
||||
Context::set('selected_timezone', Config::get('locale.default_timezone'));
|
||||
|
||||
// Other settings
|
||||
Context::set('use_rewrite', Router::getRewriteLevel());
|
||||
Context::set('use_mobile_view', (config('mobile.enabled') !== null ? config('mobile.enabled') : config('use_mobile_view')) ? true : false);
|
||||
Context::set('tablets_as_mobile', config('mobile.tablets') ? true : false);
|
||||
Context::set('mobile_viewport', config('mobile.viewport') ?? HTMLDisplayHandler::DEFAULT_VIEWPORT);
|
||||
Context::set('use_ssl', Config::get('url.ssl'));
|
||||
Context::set('delay_session', Config::get('session.delay'));
|
||||
Context::set('use_db_session', Config::get('session.use_db'));
|
||||
Context::set('manager_layout', Config::get('view.manager_layout'));
|
||||
Context::set('minify_scripts', Config::get('view.minify_scripts'));
|
||||
Context::set('concat_scripts', Config::get('view.concat_scripts'));
|
||||
Context::set('use_server_push', Config::get('view.server_push'));
|
||||
Context::set('use_gzip', Config::get('view.use_gzip'));
|
||||
|
||||
$this->setTemplateFile('config_advanced');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update advanced configuration.
|
||||
*/
|
||||
public function procAdminUpdateAdvanced()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Object cache
|
||||
if ($vars->object_cache_type)
|
||||
{
|
||||
if ($vars->object_cache_type === 'memcached' || $vars->object_cache_type === 'redis')
|
||||
{
|
||||
if (starts_with('unix:/', $vars->object_cache_host))
|
||||
{
|
||||
$cache_servers = array(substr($vars->object_cache_host, 5));
|
||||
}
|
||||
elseif (starts_with('/', $vars->object_cache_host))
|
||||
{
|
||||
$cache_servers = array($vars->object_cache_host);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (trim($vars->object_cache_user) !== '' || trim($vars->object_cache_pass) !== '')
|
||||
{
|
||||
$auth = sprintf('%s:%s@', urlencode(trim($vars->object_cache_user)), urlencode(trim($vars->object_cache_pass)));
|
||||
}
|
||||
else
|
||||
{
|
||||
$auth = '';
|
||||
}
|
||||
$cache_servers = array($vars->object_cache_type . '://' . $auth . $vars->object_cache_host . ':' . intval($vars->object_cache_port));
|
||||
}
|
||||
|
||||
if ($vars->object_cache_type === 'redis')
|
||||
{
|
||||
$cache_servers[0] .= '#' . intval($vars->object_cache_dbnum);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$cache_servers = array();
|
||||
}
|
||||
if (!Cache::getDriverInstance($vars->object_cache_type, $cache_servers))
|
||||
{
|
||||
throw new Exception('msg_cache_handler_not_supported');
|
||||
}
|
||||
Config::set('cache', array(
|
||||
'type' => $vars->object_cache_type,
|
||||
'ttl' => intval($vars->cache_default_ttl ?: 86400),
|
||||
'servers' => $cache_servers,
|
||||
));
|
||||
}
|
||||
else
|
||||
{
|
||||
Config::set('cache', array());
|
||||
}
|
||||
|
||||
// Cache truncate method
|
||||
if (in_array($vars->cache_truncate_method, array('delete', 'empty')))
|
||||
{
|
||||
Config::set('cache.truncate_method', $vars->cache_truncate_method);
|
||||
}
|
||||
|
||||
// Thumbnail settings
|
||||
$oDocumentModel = getModel('document');
|
||||
$document_config = $oDocumentModel->getDocumentConfig();
|
||||
$document_config->thumbnail_target = $vars->thumbnail_target ?: 'all';
|
||||
$document_config->thumbnail_type = $vars->thumbnail_type ?: 'fill';
|
||||
$document_config->thumbnail_quality = intval($vars->thumbnail_quality) ?: 75;
|
||||
$oModuleController = getController('module');
|
||||
$oModuleController->insertModuleConfig('document', $document_config);
|
||||
|
||||
// Mobile view
|
||||
Config::set('mobile.enabled', $vars->use_mobile_view === 'Y');
|
||||
Config::set('mobile.tablets', $vars->tablets_as_mobile === 'Y');
|
||||
Config::set('mobile.viewport', utf8_trim($vars->mobile_viewport));
|
||||
if (Config::get('use_mobile_view') !== null)
|
||||
{
|
||||
Config::set('use_mobile_view', $vars->use_mobile_view === 'Y');
|
||||
}
|
||||
|
||||
// Languages and time zone
|
||||
$enabled_lang = $vars->enabled_lang;
|
||||
if (!in_array($vars->default_lang, $enabled_lang ?: []))
|
||||
{
|
||||
$enabled_lang[] = $vars->default_lang;
|
||||
}
|
||||
Config::set('locale.default_lang', $vars->default_lang);
|
||||
Config::set('locale.enabled_lang', array_values($enabled_lang));
|
||||
Config::set('locale.auto_select_lang', $vars->auto_select_lang === 'Y');
|
||||
Config::set('locale.default_timezone', $vars->default_timezone);
|
||||
|
||||
// Other settings
|
||||
Config::set('url.rewrite', intval($vars->use_rewrite));
|
||||
Config::set('use_rewrite', $vars->use_rewrite > 0);
|
||||
Config::set('session.delay', $vars->delay_session === 'Y');
|
||||
Config::set('session.use_db', $vars->use_db_session === 'Y');
|
||||
Config::set('view.manager_layout', $vars->manager_layout ?: 'module');
|
||||
Config::set('view.minify_scripts', $vars->minify_scripts ?: 'common');
|
||||
Config::set('view.concat_scripts', $vars->concat_scripts ?: 'none');
|
||||
Config::set('view.server_push', $vars->use_server_push === 'Y');
|
||||
Config::set('view.use_gzip', $vars->use_gzip === 'Y');
|
||||
|
||||
// Save
|
||||
if (!Config::save())
|
||||
{
|
||||
throw new Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigAdvanced'));
|
||||
}
|
||||
}
|
||||
110
modules/admin/controllers/systemconfig/Debug.php
Normal file
110
modules/admin/controllers/systemconfig/Debug.php
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Admin\Controllers\SystemConfig;
|
||||
|
||||
use Context;
|
||||
use FileHandler;
|
||||
use Rhymix\Framework\Config;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\Filters\IpFilter;
|
||||
use Rhymix\Modules\Admin\Controllers\Base;
|
||||
|
||||
class Debug extends Base
|
||||
{
|
||||
/**
|
||||
* Display Debug Settings page
|
||||
*/
|
||||
public function dispAdminConfigDebug()
|
||||
{
|
||||
// Load debug settings.
|
||||
Context::set('debug_enabled', Config::get('debug.enabled'));
|
||||
Context::set('debug_log_slow_queries', Config::get('debug.log_slow_queries'));
|
||||
Context::set('debug_log_slow_triggers', Config::get('debug.log_slow_triggers'));
|
||||
Context::set('debug_log_slow_widgets', Config::get('debug.log_slow_widgets'));
|
||||
Context::set('debug_log_slow_remote_requests', Config::get('debug.log_slow_remote_requests'));
|
||||
Context::set('debug_log_filename', Config::get('debug.log_filename') ?: 'files/debug/YYYYMMDD.php');
|
||||
Context::set('debug_display_type', (array)Config::get('debug.display_type'));
|
||||
Context::set('debug_display_content', Config::get('debug.display_content'));
|
||||
Context::set('debug_display_to', Config::get('debug.display_to'));
|
||||
Context::set('debug_query_comment', Config::get('debug.query_comment'));
|
||||
Context::set('debug_query_full_stack', Config::get('debug.query_full_stack'));
|
||||
Context::set('debug_write_error_log', Config::get('debug.write_error_log'));
|
||||
|
||||
// IP access control
|
||||
$allowed_ip = Config::get('debug.allow');
|
||||
Context::set('debug_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
||||
Context::set('remote_addr', RX_CLIENT_IP);
|
||||
|
||||
$this->setTemplateFile('config_debug');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update debug configuration.
|
||||
*/
|
||||
public function procAdminUpdateDebug()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Save display type settings
|
||||
$display_type = array_values(array_filter($vars->debug_display_type ?: [], function($str) {
|
||||
return in_array($str, ['panel', 'comment', 'file']);
|
||||
}));
|
||||
|
||||
// Debug settings
|
||||
Config::set('debug.enabled', $vars->debug_enabled === 'Y');
|
||||
Config::set('debug.log_slow_queries', max(0, floatval($vars->debug_log_slow_queries)));
|
||||
Config::set('debug.log_slow_triggers', max(0, floatval($vars->debug_log_slow_triggers)));
|
||||
Config::set('debug.log_slow_widgets', max(0, floatval($vars->debug_log_slow_widgets)));
|
||||
Config::set('debug.log_slow_remote_requests', max(0, floatval($vars->debug_log_slow_remote_requests)));
|
||||
Config::set('debug.display_type', $display_type);
|
||||
Config::set('debug.display_to', strval($vars->debug_display_to) ?: 'admin');
|
||||
Config::set('debug.query_comment', $vars->debug_query_comment === 'Y');
|
||||
Config::set('debug.query_full_stack', $vars->debug_query_full_stack === 'Y');
|
||||
Config::set('debug.write_error_log', strval($vars->debug_write_error_log) ?: 'fatal');
|
||||
|
||||
// Debug content
|
||||
$debug_content = array_values($vars->debug_display_content ?: array());
|
||||
Config::set('debug.display_content', $debug_content);
|
||||
|
||||
// Log filename
|
||||
$log_filename = strval($vars->debug_log_filename);
|
||||
$log_filename_today = str_replace(array('YYYY', 'YY', 'MM', 'DD'), array(
|
||||
getInternalDateTime(RX_TIME, 'Y'),
|
||||
getInternalDateTime(RX_TIME, 'y'),
|
||||
getInternalDateTime(RX_TIME, 'm'),
|
||||
getInternalDateTime(RX_TIME, 'd'),
|
||||
), $log_filename);
|
||||
if (file_exists(RX_BASEDIR . $log_filename_today) && !is_writable(RX_BASEDIR . $log_filename_today))
|
||||
{
|
||||
throw new Exception('msg_debug_log_filename_not_writable');
|
||||
}
|
||||
if (!file_exists(dirname(RX_BASEDIR . $log_filename)) && !FileHandler::makeDir(dirname(RX_BASEDIR . $log_filename)))
|
||||
{
|
||||
throw new Exception('msg_debug_log_filename_not_writable');
|
||||
}
|
||||
if (!is_writable(dirname(RX_BASEDIR . $log_filename)))
|
||||
{
|
||||
throw new Exception('msg_debug_log_filename_not_writable');
|
||||
}
|
||||
Config::set('debug.log_filename', $log_filename);
|
||||
|
||||
// IP access control
|
||||
$allowed_ip = array_map('trim', preg_split('/[\r\n]/', $vars->debug_allowed_ip));
|
||||
$allowed_ip = array_unique(array_filter($allowed_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
if (!IpFilter::validateRanges($allowed_ip)) {
|
||||
throw new Exception('msg_invalid_ip');
|
||||
}
|
||||
Config::set('debug.allow', array_values($allowed_ip));
|
||||
|
||||
// Save
|
||||
if (!Config::save())
|
||||
{
|
||||
throw new Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigDebug'));
|
||||
}
|
||||
}
|
||||
243
modules/admin/controllers/systemconfig/Notification.php
Normal file
243
modules/admin/controllers/systemconfig/Notification.php
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Admin\Controllers\SystemConfig;
|
||||
|
||||
use Context;
|
||||
use ModuleModel;
|
||||
use Rhymix\Framework\Config;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\Mail;
|
||||
use Rhymix\Framework\Push;
|
||||
use Rhymix\Framework\SMS;
|
||||
use Rhymix\Framework\Storage;
|
||||
use Rhymix\Modules\Admin\Controllers\Base;
|
||||
|
||||
class Notification extends Base
|
||||
{
|
||||
/**
|
||||
* Display Notification Settings page
|
||||
*/
|
||||
public function dispAdminConfigNotification()
|
||||
{
|
||||
// Load advanced mailer module (for lang).
|
||||
$oAdvancedMailerAdminView = \Advanced_mailerAdminView::getInstance();
|
||||
|
||||
// Load advanced mailer config.
|
||||
$advanced_mailer_config = $oAdvancedMailerAdminView->getConfig();
|
||||
Context::set('advanced_mailer_config', $advanced_mailer_config);
|
||||
|
||||
// Load member config.
|
||||
$member_config = ModuleModel::getModuleConfig('member');
|
||||
Context::set('member_config', $member_config);
|
||||
Context::set('webmaster_name', !empty($member_config->webmaster_name) ? $member_config->webmaster_name : 'webmaster');
|
||||
Context::set('webmaster_email', $member_config->webmaster_email ?? '');
|
||||
|
||||
// Load module config.
|
||||
$module_config = ModuleModel::getModuleConfig('module');
|
||||
Context::set('module_config', $module_config);
|
||||
|
||||
// Load mail drivers.
|
||||
$mail_drivers = Mail::getSupportedDrivers();
|
||||
uasort($mail_drivers, function($a, $b) {
|
||||
if ($a['name'] === 'Dummy') return -1;
|
||||
if ($b['name'] === 'Dummy') return 1;
|
||||
return strnatcasecmp($a['name'], $b['name']);
|
||||
});
|
||||
Context::set('mail_drivers', $mail_drivers);
|
||||
Context::set('mail_driver', config('mail.type') ?: 'mailfunction');
|
||||
|
||||
// Load SMS drivers.
|
||||
$sms_drivers = SMS::getSupportedDrivers();
|
||||
uasort($sms_drivers, function($a, $b) {
|
||||
if ($a['name'] === 'Dummy') return -1;
|
||||
if ($b['name'] === 'Dummy') return 1;
|
||||
return strnatcasecmp($a['name'], $b['name']);
|
||||
});
|
||||
Context::set('sms_drivers', $sms_drivers);
|
||||
Context::set('sms_driver', config('sms.type') ?: 'dummy');
|
||||
|
||||
// Load Push drivers.
|
||||
$push_drivers = Push::getSupportedDrivers();
|
||||
uasort($push_drivers, function($a, $b) { return strcmp($a['name'], $b['name']); });
|
||||
Context::set('push_drivers', $push_drivers);
|
||||
Context::set('push_config', config('push') ?: []);
|
||||
$apns_certificate = false;
|
||||
if ($apns_certificate_filename = config('push.apns.certificate'))
|
||||
{
|
||||
$apns_certificate = Storage::read($apns_certificate_filename);
|
||||
}
|
||||
Context::set('apns_certificate', $apns_certificate);
|
||||
|
||||
// Workaround for compatibility with older version of Amazon SES driver.
|
||||
config('mail.ses.api_key', config('mail.ses.api_user'));
|
||||
config('mail.ses.api_secret', config('mail.ses.api_pass'));
|
||||
|
||||
$this->setTemplateFile('config_notification');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update notification configuration.
|
||||
*/
|
||||
public function procAdminUpdateNotification()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Load advanced mailer module (for lang).
|
||||
$oAdvancedMailerAdminView = \Advanced_mailerAdminView::getInstance();
|
||||
|
||||
// Validate the mail sender's information.
|
||||
if (!$vars->mail_default_name)
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sender_name_is_empty');
|
||||
}
|
||||
if (!$vars->mail_default_from)
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sender_email_is_empty');
|
||||
}
|
||||
if (!\Mail::isVaildMailAddress($vars->mail_default_from))
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sender_email_is_invalid');
|
||||
}
|
||||
if ($vars->mail_default_reply_to && !\Mail::isVaildMailAddress($vars->mail_default_reply_to))
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_reply_to_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the mail driver.
|
||||
$mail_drivers = Mail::getSupportedDrivers();
|
||||
$mail_driver = $vars->mail_driver;
|
||||
if (!array_key_exists($mail_driver, $mail_drivers))
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the mail driver settings.
|
||||
$mail_driver_config = array();
|
||||
foreach ($mail_drivers[$mail_driver]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{'mail_' . $mail_driver . '_' . $conf_name} ?: null;
|
||||
if (!$conf_value)
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_smtp_host_is_invalid');
|
||||
}
|
||||
$mail_driver_config[$conf_name] = $conf_value;
|
||||
}
|
||||
|
||||
// Validate the SMS driver.
|
||||
$sms_drivers = SMS::getSupportedDrivers();
|
||||
$sms_driver = $vars->sms_driver;
|
||||
if (!array_key_exists($sms_driver, $sms_drivers))
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
|
||||
// Validate the SMS driver settings.
|
||||
$sms_driver_config = array();
|
||||
foreach ($sms_drivers[$sms_driver]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null;
|
||||
if (!$conf_value)
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sms_config_invalid');
|
||||
}
|
||||
$sms_driver_config[$conf_name] = $conf_value;
|
||||
}
|
||||
foreach ($sms_drivers[$sms_driver]['optional'] as $conf_name)
|
||||
{
|
||||
$conf_value = $vars->{'sms_' . $sms_driver . '_' . $conf_name} ?: null;
|
||||
$sms_driver_config[$conf_name] = $conf_value;
|
||||
}
|
||||
|
||||
// Validate the selected Push drivers.
|
||||
$push_config = array('types' => array());
|
||||
$push_config['allow_guest_device'] = $vars->allow_guest_device === 'Y' ? true : false;
|
||||
$push_drivers = Push::getSupportedDrivers();
|
||||
$push_driver_list = $vars->push_driver ?: [];
|
||||
foreach ($push_driver_list as $driver_name)
|
||||
{
|
||||
if (array_key_exists($driver_name, $push_drivers))
|
||||
{
|
||||
$push_config['types'][$driver_name] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_sending_method_is_invalid');
|
||||
}
|
||||
}
|
||||
|
||||
// Validate the Push driver settings.
|
||||
foreach ($push_drivers as $driver_name => $driver_definition)
|
||||
{
|
||||
foreach ($push_drivers[$driver_name]['required'] as $conf_name)
|
||||
{
|
||||
$conf_value = utf8_trim($vars->{'push_' . $driver_name . '_' . $conf_name}) ?: null;
|
||||
if (!$conf_value && in_array($driver_name, $push_driver_list))
|
||||
{
|
||||
throw new Exception('msg_advanced_mailer_push_config_invalid');
|
||||
}
|
||||
$push_config[$driver_name][$conf_name] = $conf_value;
|
||||
|
||||
// Save certificates in a separate file and only store the filename in config.php.
|
||||
if ($conf_name === 'certificate')
|
||||
{
|
||||
$filename = Config::get('push.' . $driver_name . '.certificate');
|
||||
if (!$filename)
|
||||
{
|
||||
$filename = './files/config/' . $driver_name . '/cert-' . \Rhymix\Framework\Security::getRandom(32) . '.pem';
|
||||
}
|
||||
|
||||
if ($conf_value !== null)
|
||||
{
|
||||
Storage::write($filename, $conf_value);
|
||||
$push_config[$driver_name][$conf_name] = $filename;
|
||||
}
|
||||
elseif (Storage::exists($filename))
|
||||
{
|
||||
Storage::delete($filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($push_drivers[$driver_name]['optional'] as $conf_name)
|
||||
{
|
||||
$conf_value = utf8_trim($vars->{'push_' . $driver_name . '_' . $conf_name}) ?: null;
|
||||
$push_config[$driver_name][$conf_name] = $conf_value;
|
||||
}
|
||||
}
|
||||
|
||||
// Save advanced mailer config.
|
||||
getController('module')->updateModuleConfig('advanced_mailer', (object)array(
|
||||
'sender_name' => trim($vars->mail_default_name),
|
||||
'sender_email' => trim($vars->mail_default_from),
|
||||
'force_sender' => toBool($vars->mail_force_default_sender),
|
||||
'reply_to' => trim($vars->mail_default_reply_to),
|
||||
));
|
||||
|
||||
// Save member config.
|
||||
getController('module')->updateModuleConfig('member', (object)array(
|
||||
'webmaster_name' => trim($vars->mail_default_name),
|
||||
'webmaster_email' => trim($vars->mail_default_from),
|
||||
));
|
||||
|
||||
// Save system config.
|
||||
Config::set("mail.default_name", trim($vars->mail_default_name));
|
||||
Config::set("mail.default_from", trim($vars->mail_default_from));
|
||||
Config::set("mail.default_force", toBool($vars->mail_force_default_sender));
|
||||
Config::set("mail.default_reply_to", trim($vars->mail_default_reply_to));
|
||||
Config::set("mail.type", $mail_driver);
|
||||
Config::set("mail.$mail_driver", $mail_driver_config);
|
||||
Config::set("sms.default_from", trim($vars->sms_default_from));
|
||||
Config::set("sms.default_force", toBool($vars->sms_force_default_sender));
|
||||
Config::set("sms.type", $sms_driver);
|
||||
Config::set("sms.$sms_driver", $sms_driver_config);
|
||||
Config::set("sms.allow_split.sms", toBool($vars->allow_split_sms));
|
||||
Config::set("sms.allow_split.lms", toBool($vars->allow_split_lms));
|
||||
Config::set("push", $push_config);
|
||||
if (!Config::save())
|
||||
{
|
||||
throw new Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigNotification'));
|
||||
}
|
||||
}
|
||||
75
modules/admin/controllers/systemconfig/SEO.php
Normal file
75
modules/admin/controllers/systemconfig/SEO.php
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Admin\Controllers\SystemConfig;
|
||||
|
||||
use Context;
|
||||
use ModuleController;
|
||||
use ModuleModel;
|
||||
use Rhymix\Framework\Config;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Modules\Admin\Controllers\Base;
|
||||
|
||||
class SEO extends Base
|
||||
{
|
||||
/**
|
||||
* Display Debug Settings page
|
||||
*/
|
||||
public function dispAdminConfigSEO()
|
||||
{
|
||||
// Meta keywords and description
|
||||
$config = ModuleModel::getModuleConfig('module');
|
||||
Context::set('site_meta_keywords', escape($config->meta_keywords ?? ''));
|
||||
Context::set('site_meta_description', escape($config->meta_description ?? ''));
|
||||
|
||||
// Titles
|
||||
Context::set('seo_main_title', escape(Config::get('seo.main_title') ?: '$SITE_TITLE - $SITE_SUBTITLE'));
|
||||
Context::set('seo_subpage_title', escape(Config::get('seo.subpage_title') ?: '$SITE_TITLE - $SUBPAGE_TITLE'));
|
||||
Context::set('seo_document_title', escape(Config::get('seo.document_title') ?: '$SITE_TITLE - $DOCUMENT_TITLE'));
|
||||
|
||||
// OpenGraph metadata
|
||||
Context::set('og_enabled', Config::get('seo.og_enabled'));
|
||||
Context::set('og_extract_description', Config::get('seo.og_extract_description'));
|
||||
Context::set('og_extract_images', Config::get('seo.og_extract_images'));
|
||||
Context::set('og_extract_hashtags', Config::get('seo.og_extract_hashtags'));
|
||||
Context::set('og_use_nick_name', Config::get('seo.og_use_nick_name'));
|
||||
Context::set('og_use_timestamps', Config::get('seo.og_use_timestamps'));
|
||||
Context::set('twitter_enabled', Config::get('seo.twitter_enabled'));
|
||||
|
||||
$this->setTemplateFile('config_seo');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update SEO configuration.
|
||||
*/
|
||||
public function procAdminUpdateSEO()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
$args = new \stdClass;
|
||||
$args->meta_keywords = $vars->site_meta_keywords ? implode(', ', array_map('trim', explode(',', $vars->site_meta_keywords))) : '';
|
||||
$args->meta_description = trim(utf8_normalize_spaces($vars->site_meta_description));
|
||||
$oModuleController = ModuleController::getInstance();
|
||||
$oModuleController->updateModuleConfig('module', $args);
|
||||
|
||||
Config::set('seo.main_title', trim(utf8_normalize_spaces($vars->seo_main_title)));
|
||||
Config::set('seo.subpage_title', trim(utf8_normalize_spaces($vars->seo_subpage_title)));
|
||||
Config::set('seo.document_title', trim(utf8_normalize_spaces($vars->seo_document_title)));
|
||||
|
||||
Config::set('seo.og_enabled', $vars->og_enabled === 'Y');
|
||||
Config::set('seo.og_extract_description', $vars->og_extract_description === 'Y');
|
||||
Config::set('seo.og_extract_images', $vars->og_extract_images === 'Y');
|
||||
Config::set('seo.og_extract_hashtags', $vars->og_extract_hashtags === 'Y');
|
||||
Config::set('seo.og_use_nick_name', $vars->og_use_nick_name === 'Y');
|
||||
Config::set('seo.og_use_timestamps', $vars->og_use_timestamps === 'Y');
|
||||
Config::set('seo.twitter_enabled', $vars->twitter_enabled === 'Y');
|
||||
|
||||
// Save
|
||||
if (!Config::save())
|
||||
{
|
||||
throw new Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSEO'));
|
||||
}
|
||||
}
|
||||
133
modules/admin/controllers/systemconfig/Security.php
Normal file
133
modules/admin/controllers/systemconfig/Security.php
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Admin\Controllers\SystemConfig;
|
||||
|
||||
use Context;
|
||||
use Rhymix\Framework\Config;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\Filters\IpFilter;
|
||||
use Rhymix\Framework\Filters\MediaFilter;
|
||||
use Rhymix\Modules\Admin\Controllers\Base;
|
||||
|
||||
class Security extends Base
|
||||
{
|
||||
/**
|
||||
* Display Security Settings page
|
||||
*/
|
||||
public function dispAdminConfigSecurity()
|
||||
{
|
||||
// Load embed filter.
|
||||
context::set('mediafilter_whitelist', implode(PHP_EOL, MediaFilter::getWhitelist()));
|
||||
context::set('mediafilter_classes', implode(PHP_EOL, Config::get('mediafilter.classes') ?: array()));
|
||||
|
||||
// Load robot user agents.
|
||||
$robot_user_agents = Config::get('security.robot_user_agents') ?: array();
|
||||
Context::set('robot_user_agents', implode(PHP_EOL, $robot_user_agents));
|
||||
|
||||
// Admin IP access control
|
||||
$allowed_ip = Config::get('admin.allow');
|
||||
Context::set('admin_allowed_ip', implode(PHP_EOL, $allowed_ip));
|
||||
$denied_ip = Config::get('admin.deny');
|
||||
Context::set('admin_denied_ip', implode(PHP_EOL, $denied_ip));
|
||||
Context::set('remote_addr', RX_CLIENT_IP);
|
||||
|
||||
// Session and cookie security settings
|
||||
Context::set('use_samesite', Config::get('session.samesite'));
|
||||
Context::set('use_session_keys', Config::get('session.use_keys'));
|
||||
Context::set('use_session_ssl', Config::get('session.use_ssl'));
|
||||
Context::set('use_cookies_ssl', Config::get('session.use_ssl_cookies'));
|
||||
Context::set('check_csrf_token', Config::get('security.check_csrf_token'));
|
||||
Context::set('use_nofollow', Config::get('security.nofollow'));
|
||||
|
||||
$this->setTemplateFile('config_security');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update security configuration.
|
||||
*/
|
||||
public function procAdminUpdateSecurity()
|
||||
{
|
||||
$vars = Context::getRequestVars();
|
||||
|
||||
// Media Filter iframe/embed whitelist
|
||||
$whitelist = $vars->mediafilter_whitelist;
|
||||
$whitelist = array_filter(array_map('trim', preg_split('/[\r\n]/', $whitelist)), function($item) {
|
||||
return $item !== '';
|
||||
});
|
||||
$whitelist = array_unique(array_map(function($item) {
|
||||
return MediaFilter::formatPrefix($item);
|
||||
}, $whitelist));
|
||||
natcasesort($whitelist);
|
||||
Config::set('mediafilter.whitelist', array_values($whitelist));
|
||||
Config::set('mediafilter.iframe', []);
|
||||
Config::set('mediafilter.object', []);
|
||||
|
||||
// HTML classes
|
||||
$classes = $vars->mediafilter_classes;
|
||||
$classes = array_filter(array_map('trim', preg_split('/[\r\n]/', $classes)), function($item) {
|
||||
return preg_match('/^[a-zA-Z0-9_-]+$/u', $item);
|
||||
});
|
||||
natcasesort($classes);
|
||||
Config::set('mediafilter.classes', array_values($classes));
|
||||
|
||||
// Robot user agents
|
||||
$robot_user_agents = $vars->robot_user_agents;
|
||||
$robot_user_agents = array_filter(array_map('trim', preg_split('/[\r\n]/', $robot_user_agents)), function($item) {
|
||||
return $item !== '';
|
||||
});
|
||||
Config::set('security.robot_user_agents', array_values($robot_user_agents));
|
||||
|
||||
// Remove old embed filter
|
||||
$config = Config::getAll();
|
||||
unset($config['embedfilter']);
|
||||
Config::setAll($config);
|
||||
|
||||
// Admin IP access control
|
||||
$allowed_ip = array_map('trim', preg_split('/[\r\n]/', $vars->admin_allowed_ip));
|
||||
$allowed_ip = array_unique(array_filter($allowed_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
if (!IpFilter::validateRanges($allowed_ip)) {
|
||||
throw new Exception('msg_invalid_ip');
|
||||
}
|
||||
|
||||
$denied_ip = array_map('trim', preg_split('/[\r\n]/', $vars->admin_denied_ip));
|
||||
$denied_ip = array_unique(array_filter($denied_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
if (!IpFilter::validateRanges($denied_ip)) {
|
||||
throw new Exception('msg_invalid_ip');
|
||||
}
|
||||
|
||||
$oMemberAdminModel = getAdminModel('member');
|
||||
if (!$oMemberAdminModel->getMemberAdminIPCheck($allowed_ip, $denied_ip))
|
||||
{
|
||||
throw new Exception('msg_current_ip_will_be_denied');
|
||||
}
|
||||
|
||||
$site_module_info = Context::get('site_module_info');
|
||||
$vars->use_samesite = preg_replace('/[^a-zA-Z]/', '', $vars->use_samesite);
|
||||
if ($vars->use_samesite === 'None' && ($vars->use_session_ssl !== 'Y' || $site_module_info->security !== 'always'))
|
||||
{
|
||||
$vars->use_samesite = '';
|
||||
}
|
||||
|
||||
Config::set('admin.allow', array_values($allowed_ip));
|
||||
Config::set('admin.deny', array_values($denied_ip));
|
||||
Config::set('session.samesite', $vars->use_samesite);
|
||||
Config::set('session.use_keys', $vars->use_session_keys === 'Y');
|
||||
Config::set('session.use_ssl', $vars->use_session_ssl === 'Y');
|
||||
Config::set('session.use_ssl_cookies', $vars->use_cookies_ssl === 'Y');
|
||||
Config::set('security.check_csrf_token', $vars->check_csrf_token === 'Y');
|
||||
Config::set('security.nofollow', $vars->use_nofollow === 'Y');
|
||||
|
||||
// Save
|
||||
if (!Config::save())
|
||||
{
|
||||
throw new Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSecurity'));
|
||||
}
|
||||
}
|
||||
58
modules/admin/controllers/systemconfig/SiteLock.php
Normal file
58
modules/admin/controllers/systemconfig/SiteLock.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Rhymix\Modules\Admin\Controllers\SystemConfig;
|
||||
|
||||
use Context;
|
||||
use Rhymix\Framework\Config;
|
||||
use Rhymix\Framework\Exception;
|
||||
use Rhymix\Framework\Filters\IpFilter;
|
||||
use Rhymix\Modules\Admin\Controllers\Base;
|
||||
|
||||
class SiteLock extends Base
|
||||
{
|
||||
/**
|
||||
* Display Sitelock Settings page
|
||||
*/
|
||||
public function dispAdminConfigSitelock()
|
||||
{
|
||||
Context::set('sitelock_locked', Config::get('lock.locked'));
|
||||
Context::set('sitelock_title', escape(Config::get('lock.title')));
|
||||
Context::set('sitelock_message', escape(Config::get('lock.message')));
|
||||
|
||||
$allowed_ip = Config::get('lock.allow') ?: array();
|
||||
Context::set('sitelock_allowed_ip', implode(\PHP_EOL, $allowed_ip));
|
||||
Context::set('remote_addr', \RX_CLIENT_IP);
|
||||
|
||||
$this->setTemplateFile('config_sitelock');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update sitelock configuration.
|
||||
*/
|
||||
public function procAdminUpdateSitelock()
|
||||
{
|
||||
$vars = Context::gets('sitelock_locked', 'sitelock_allowed_ip', 'sitelock_title', 'sitelock_message');
|
||||
|
||||
$allowed_ip = array_map('trim', preg_split('/[\r\n]/', $vars->sitelock_allowed_ip));
|
||||
$allowed_ip = array_unique(array_filter($allowed_ip, function($item) {
|
||||
return $item !== '';
|
||||
}));
|
||||
|
||||
if (!IpFilter::validateRanges($allowed_ip))
|
||||
{
|
||||
throw new Exception('msg_invalid_ip');
|
||||
}
|
||||
|
||||
Config::set('lock.locked', $vars->sitelock_locked === 'Y');
|
||||
Config::set('lock.title', trim($vars->sitelock_title));
|
||||
Config::set('lock.message', trim($vars->sitelock_message));
|
||||
Config::set('lock.allow', array_values($allowed_ip));
|
||||
if (!Config::save())
|
||||
{
|
||||
throw new Exception('msg_failed_to_save_config');
|
||||
}
|
||||
|
||||
$this->setMessage('success_updated');
|
||||
$this->setRedirectUrl(Context::get('success_return_url') ?: getNotEncodedUrl('', 'module', 'admin', 'act', 'dispAdminConfigSitelock'));
|
||||
}
|
||||
}
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
<h2>{$lang->cmd_multidomain_configuration}</h2>
|
||||
<form action="./" method="post" class="x_form-horizontal">
|
||||
<input type="hidden" name="module" value="admin" />
|
||||
<input type="hidden" name="act" value="procAdminUpdateDomains" />
|
||||
<input type="hidden" name="act" value="procAdminUpdateDomainConfig" />
|
||||
<input type="hidden" name="xe_validator_id" value="modules/admin/tpl/config_domains/1" />
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->cmd_unregistered_domain_action}</label>
|
||||
|
|
|
|||
|
|
@ -1,82 +0,0 @@
|
|||
<config autoescape="on" />
|
||||
|
||||
<load target="./js/config.js" />
|
||||
<load target="../../session/tpl/js/session.js" />
|
||||
|
||||
<div class="x_page-header">
|
||||
<h1>{$lang->menu_gnb_sub['adminConfigurationFtp']}</h1>
|
||||
</div>
|
||||
|
||||
<div class="message">
|
||||
<p>{$lang->ftp_deprecated}</p>
|
||||
</div>
|
||||
|
||||
<!--@if(FALSE)-->
|
||||
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/admin/tpl/config_ftp/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
|
||||
<p>{$XE_VALIDATOR_MESSAGE}</p>
|
||||
</div>
|
||||
<form action="./" id="ftp_form" method="post" class="x_form-horizontal" ruleset="installFtpInfo">
|
||||
<input type="hidden" name="module" value="admin" />
|
||||
<input type="hidden" name="act" value="procAdminUpdateFTPInfo" />
|
||||
<input type="hidden" name="success_return_url" value="{$success_return_url}" />
|
||||
<input type="hidden" name="xe_validator_id" value="modules/admin/tpl/config_ftp/1" />
|
||||
<section class="section">
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_host">{$lang->ftp_host}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_host" id="ftp_host" value="{$ftp_info['host'] ?: 'localhost'}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_port">{$lang->ftp_port}</label>
|
||||
<div class="x_controls">
|
||||
<input type="number" name="ftp_port" id="ftp_port" value="{$ftp_info['port'] ?: '21'}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_user">{$lang->user_id}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_user" id="ftp_user" value="{$ftp_info['user']}" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_pass">{$lang->password}</label>
|
||||
<div class="x_controls">
|
||||
<input type="password" name="ftp_pass" id="ftp_pass" value="" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label" for="ftp_path">{$lang->msg_ftp_installed_ftp_realpath}</label>
|
||||
<div class="x_controls">
|
||||
<input type="text" name="ftp_path" id="ftp_path" style="min-width:90%" value="{$ftp_info['path'] ?: \RX_BASEDIR}" />
|
||||
<br />
|
||||
<p class="x_help-block">{$lang->msg_ftp_autodetected_ftp_realpath} : {\RX_BASEDIR}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<div class="x_control-label">{$lang->use_ftp_passive_mode}</div>
|
||||
<div class="x_controls">
|
||||
<label class="x_inline" for="ftp_pasv_y">
|
||||
<input type="radio" name="ftp_pasv" id="ftp_pasv_y" value="Y" checked="checked"|cond="$ftp_info['pasv']" />
|
||||
{$lang->cmd_yes}
|
||||
</label>
|
||||
<label class="x_inline" for="ftp_pasv_n">
|
||||
<input type="radio" name="ftp_pasv" id="ftp_pasv_n" value="N" checked="checked"|cond="!$ftp_info['pasv']" />
|
||||
{$lang->cmd_no}
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->use_sftp_support}</label>
|
||||
<div class="x_controls">
|
||||
<label class="x_inline" for="ftp_sftp_y"><input type="radio" name="ftp_sftp" id="ftp_sftp_y" value="Y" checked="checked"|cond="$ftp_info['sftp']" disabled|cond="!$sftp_support" /> {$lang->cmd_yes}</label>
|
||||
<label class="x_inline" for="ftp_sftp_n"><input type="radio" name="ftp_sftp" id="ftp_sftp_n" value="N" checked="checked"|cond="!$ftp_info['sftp']" /> {$lang->cmd_no}</label>
|
||||
<p class="x_help-black" cond="!$sftp_support">{$lang->disable_sftp_support}</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div class="btnArea" style="margin-top:0">
|
||||
<input type="submit" value="{$lang->cmd_save}" class="x_btn x_btn-primary x_pull-right" />
|
||||
</div>
|
||||
</form>
|
||||
<!--@end-->
|
||||
Loading…
Add table
Add a link
Reference in a new issue