Skip to content

Commit

Permalink
Fixed a bug where Geeklog Configuration - Changing Paths can cause Is…
Browse files Browse the repository at this point in the history
…sues (bug #1061)
  • Loading branch information
mystralkk committed Jun 13, 2020
1 parent c06c767 commit 8bdf969
Show file tree
Hide file tree
Showing 6 changed files with 891 additions and 851 deletions.
104 changes: 51 additions & 53 deletions public_html/admin/configuration.php
Expand Up @@ -2,13 +2,13 @@

/* Reminder: always indent with 4 spaces (no tabs). */
// +---------------------------------------------------------------------------+
// | Geeklog 2.1 |
// | Geeklog 2.2 |
// +---------------------------------------------------------------------------+
// | configuration.php |
// | |
// | Loads the administration UI and sends input to config.class |
// +---------------------------------------------------------------------------+
// | Copyright (C) 2007-2011 by the following authors: |
// | Copyright (C) 2007-2020 by the following authors: |
// | |
// | Authors: Aaron Blankstein - kantai AT gmail DOT com |
// | Akeda Bagus - admin AT gedex DOT web DOT id |
Expand All @@ -31,6 +31,7 @@
// | |
// +---------------------------------------------------------------------------+

use Geeklog\Input;
/**
* Geeklog common function library
*/
Expand Down Expand Up @@ -58,14 +59,15 @@ function configmanager_select_language_helper()
*/
function configmanager_select_theme_helper()
{
$themes = array();
$themes = [];

$themeFiles = COM_getThemes(true);
usort($themeFiles, 'strcasecmp');

foreach ($themeFiles as $theme) {
$words = explode('_', $theme);
$bwords = array();
$bwords = [];

foreach ($words as $th) {
if ((strtolower($th[0]) == $th[0]) &&
(strtolower($th[1]) == $th[1])
Expand Down Expand Up @@ -105,13 +107,13 @@ function configmanager_select_default_perm_cookie_timeout_helper()
{
global $_TABLES, $LANG_cookiecodes;

$retval = array();
$retval = [];

$result = DB_query("SELECT cc_value,cc_descr FROM {$_TABLES['cookiecodes']}");
$num_values = DB_numRows($result);

for ($i = 0; $i < $num_values; $i++) {
list($cc_value, $cc_descr) = DB_fetchArray($result);
list($cc_value, ) = DB_fetchArray($result);
$cc_descr = $LANG_cookiecodes[$cc_value];
$retval[$cc_descr] = $cc_value;
}
Expand All @@ -128,12 +130,13 @@ function configmanager_select_advanced_editor_name_helper()
{
global $_CONF;

$editors = array();
$editors = [];

// gets all installed Advanced Editors
$editorFiles = array();
$editorFiles = [];
$fd = opendir($_CONF['path_editors']);
clearstatcache();

while (($dir = @readdir($fd)) == true) {
if (is_dir($_CONF['path_editors'] . $dir) &&
$dir <> '.' &&
Expand All @@ -159,7 +162,8 @@ function configmanager_select_advanced_editor_name_helper()
}
if (empty($name)) {
$words = explode('_', $editor);
$bwords = array();
$bwords = [];

foreach ($words as $th) {
if ((strtolower($th[0]) == $th[0]) &&
(strtolower($th[1]) == $th[1])
Expand Down Expand Up @@ -188,7 +192,7 @@ function custom_validation_copyrightyear($rule, $ruleParams)
{
$year = $ruleParams[0]['copyrightyear'];

return preg_match('/^\d{1,4}\s{0,1}\-{0,1}\s{0,1}\d{0,4}$/', $year);
return preg_match('/^\d{1,4}\s?\-?\-\d{0,4}$/', $year);
}

/**
Expand Down Expand Up @@ -222,6 +226,7 @@ function custom_validation_arrayElementString($rule, $ruleParams)
function custom_validation_arrayLeastOneElementString($rule, $ruleParams)
{
$ret = false;

// Array in array so if count less than 2 then no elements in base rule
if (count($ruleParams) > 2) {
// Now make sure at element is not empty
Expand All @@ -245,6 +250,7 @@ function custom_validation_arrayLeastOneElementString($rule, $ruleParams)
function custom_validation_mail_settings_sendmail_path($rule, $ruleParams)
{
$ret = true;

if (isset($ruleParams[2]['backend']) && $ruleParams[2]['backend'] == 'sendmail') {
if (isset($ruleParams[0]['mail_settings[sendmail_path]']) &&
empty($ruleParams[0]['mail_settings[sendmail_path]'])
Expand All @@ -268,6 +274,7 @@ function custom_validation_mail_settings_sendmail_path($rule, $ruleParams)
function custom_validation_rdf_limit($rule, $ruleParams)
{
$ret = false;

if (isset($ruleParams[0]['rdf_limit'])) {
$ret = preg_match('/^[\d]+h?$/i', $ruleParams[0]['rdf_limit']);
}
Expand All @@ -285,11 +292,12 @@ function custom_validation_rdf_limit($rule, $ruleParams)
function custom_validation_path($rule, $ruleParams)
{
$ret = false;

if (isset($ruleParams[0])) {
foreach ($ruleParams[0] as $paramName => $paramValue) {
$ret = is_dir($ruleParams[0][$paramName]);
break;
}
$ret = is_dir($ruleParams[0][$paramName]);
}

return $ret;
Expand All @@ -305,11 +313,12 @@ function custom_validation_path($rule, $ruleParams)
function custom_validation_file($rule, $ruleParams)
{
$ret = false;

if (isset($ruleParams[0])) {
foreach ($ruleParams[0] as $paramName => $paramValue) {
$ret = file_exists($ruleParams[0][$paramName]);
break;
}
$ret = file_exists($ruleParams[0][$paramName]);
}

return $ret;
Expand Down Expand Up @@ -349,7 +358,7 @@ function custom_validation_search_limits($rule, $ruleParams)
}

/**
* Custom validation rule for number of searh results
* Custom validation rule for number of search results
*
* @param string $rule String of rule name
* @param array $ruleParams Parameter of validation
Expand Down Expand Up @@ -427,16 +436,8 @@ function custom_validation_path_themes($rule, $ruleParams)
*/
function custom_validation_path_to_mogrify($rule, $ruleParams)
{
global $_CONF;

$ret = false;
if (isset($ruleParams[0]['path_to_mogrify']) &&
file_exists($ruleParams[0]['path_to_mogrify'])
) {
$ret = true;
}

return $ret;
return isset($ruleParams[0]['path_to_mogrify']) &&
file_exists($ruleParams[0]['path_to_mogrify']);
}

/**
Expand All @@ -448,16 +449,8 @@ function custom_validation_path_to_mogrify($rule, $ruleParams)
*/
function custom_validation_path_to_netpbm($rule, $ruleParams)
{
global $_CONF;

$ret = false;
if (isset($ruleParams[0]['path_to_netpbm']) &&
is_dir($ruleParams[0]['path_to_netpbm'])
) {
$ret = true;
}

return $ret;
return isset($ruleParams[0]['path_to_netpbm']) &&
is_dir($ruleParams[0]['path_to_netpbm']);
}

/**
Expand All @@ -473,9 +466,7 @@ function custom_validation_language($rule, $ruleParams)

$ret = false;
$languages = array_flip(MBYTE_languageList($_CONF['default_charset']));
if (isset($ruleParams[0]['language']) &&
in_array($ruleParams[0]['language'], $languages)
) {
if (isset($ruleParams[0]['language']) && in_array($ruleParams[0]['language'], $languages)) {
$ret = true;
}

Expand All @@ -497,9 +488,7 @@ function custom_validation_timezone($rule, $ruleParams)
$timezones = array_flip(TimeZoneConfig::listAvailableTimeZones());

$ret = false;
if (isset($ruleParams[0]['timezone']) &&
in_array($ruleParams[0]['timezone'], $timezones)
) {
if (isset($ruleParams[0]['timezone']) && in_array($ruleParams[0]['timezone'], $timezones)) {
$ret = true;
}

Expand All @@ -519,11 +508,11 @@ function custom_validation_noTags($rule, $ruleParams)

if (isset($ruleParams[0])) {
foreach ($ruleParams[0] as $paramName => $paramValue) {
if ($ruleParams[0][$paramName] == GLText::stripTags($ruleParams[0][$paramName])) {
$ret = true;
}
break;
}
if ($ruleParams[0][$paramName] == GLText::stripTags($ruleParams[0][$paramName])) {
$ret = true;
}
}

return $ret;
Expand All @@ -542,12 +531,11 @@ function custom_validation_single_char($rule, $ruleParams)

if (isset($ruleParams[0])) {
foreach ($ruleParams[0] as $paramName => $paramValue) {
if (preg_match('/^[\s\w.,;\-]$/i', $paramValue)) {
$ret = true;
}
break;
}

if (preg_match('/^[\s\w.,;\-]{1}$/i', $paramValue)) {
$ret = true;
}
}

return $ret;
Expand Down Expand Up @@ -608,24 +596,24 @@ function custom_validation_hash_function($rule, $ruleParams)
exit;
}
}
$conf_group = Geeklog\Input::fPost('conf_group', $default_conf_group);
$conf_group = Input::fPost('conf_group', $default_conf_group);

if (array_key_exists('set_action', $_POST) && SEC_checkToken()) {
if ($_POST['set_action'] == 'restore') {
$config->restore_param(
Geeklog\Input::post('name'), $conf_group, Geeklog\Input::post('subgroup'), Geeklog\Input::post('tab')
Input::post('name'), $conf_group, Input::post('subgroup'), Input::post('tab')
);
} elseif ($_POST['set_action'] == 'unset') {
$config->unset_param(
Geeklog\Input::post('name'), $conf_group, Geeklog\Input::post('subgroup'), Geeklog\Input::post('tab')
Input::post('name'), $conf_group, Input::post('subgroup'), Input::post('tab')
);
}

// notify plugins when config item enabled or disabled
$config_item[] = Geeklog\Input::post('name');
$config_item[] = Input::post('name');
PLG_configChange($conf_group, $config_item);

$subgroup = Geeklog\Input::fPost('subgroup', null);
$subgroup = Input::fPost('subgroup', null);
$display = $config->get_ui($conf_group, $subgroup);
} elseif (array_key_exists('form_submit', $_POST) && SEC_checkToken()) {
$result = null;
Expand All @@ -648,12 +636,22 @@ function custom_validation_hash_function($rule, $ruleParams)
}
}
//$display = $config->get_ui($conf_group, $_POST['sub_group'], $result);
$sub_group = Geeklog\Input::fPost('sub_group', '0');
$sub_group = Input::fPost('sub_group', '0');
$display = $config->get_ui($conf_group, $sub_group, $result);
} else {
//$display = $config->get_ui($conf_group, array_key_exists('subgroup', $_POST)
// ? $_POST['subgroup'] : null);
$subgroup = Geeklog\Input::fPost('subgroup', null);
if ($conf_group === 'Core') {
require_once 'configuration_validation.php';
} else {
// Retrieve plugin config validation if found
$filename = $_CONF['path'] . 'plugins/' . $conf_group . '/configuration_validation.php';
if (file_exists($filename)) {
require_once $filename;
}
}

$subgroup = Input::fPost('subgroup', null);
$display = $config->get_ui($conf_group, $subgroup);
}

Expand Down

0 comments on commit 8bdf969

Please sign in to comment.