| @@ -30,8 +30,14 @@ | ||
| 30 | 30 | |
| 31 | 31 | return $default; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | + /** | |
| 35 | + * @param object|array $element | |
| 36 | + * | |
| 37 | + * @Deprecated 10.6.0 No longer used because of type mismatch. | |
| 38 | + * @See ConfigurationClass::saveConfig() as a replacement. | |
| 39 | + */ | |
| 34 | 40 | public function save($element): ?int |
| 35 | 41 | { |
| 36 | 42 | $this->saveConfig((array)$element); |
| 37 | 43 | |
| @@ -45,8 +51,9 @@ | ||
| 45 | 51 | $previousCronSecurity = $this->get('cron_security', 0); |
| 46 | 52 | $previousCronSecurityKey = $this->get('cron_key'); |
| 47 | 53 | $params = []; |
| 48 | 54 | foreach ($newConfig as $name => $value) { |
| 55 | + //If it's a password containing only * then we just consider the user saved again the config but there is no modification on the password | |
| 49 | 56 | if (!empty($value)) { |
| 50 | 57 | if (strpos($name, 'password') !== false && trim($value, '*') === '') { |
| 51 | 58 | continue; |
| 52 | 59 | } |
| @@ -66,15 +73,17 @@ | ||
| 66 | 73 | if (is_array($value)) { |
| 67 | 74 | $value = implode(',', $value); |
| 68 | 75 | } |
| 69 | 76 | |
| 77 | + //We update the current instance in the same time | |
| 70 | 78 | if (empty($this->values[$name])) { |
| 71 | 79 | $this->values[$name] = new \stdClass(); |
| 72 | 80 | } |
| 73 | 81 | $this->values[$name]->value = $value; |
| 74 | 82 | |
| 83 | + // We do a strip tags to avoid HTML injections | |
| 75 | 84 | if ($escape && !is_null($value)) { |
| 76 | - $params[] = '('.acym_escapeDB(strip_tags($name)).','.acym_escapeDB(strip_tags($value)).')'; | |
| 85 | + $params[] = '('.acym_escapeDB(acym_stripTags($name)).','.acym_escapeDB(acym_stripTags($value)).')'; | |
| 77 | 86 | } else { |
| 78 | 87 | $params[] = '('.acym_escapeDB($name).','.acym_escapeDB($value).')'; |
| 79 | 88 | } |
| 80 | 89 | } |
| @@ -81,8 +90,9 @@ | ||
| 81 | 90 | |
| 82 | 91 | $activeCron = $this->get('active_cron', 0); |
| 83 | 92 | $newCronSecurity = $this->get('cron_security', 0); |
| 84 | 93 | $newCronSecurityKey = $this->get('cron_key'); |
| 94 | + // Handle cron key activation or modification while automated tasks are active | |
| 85 | 95 | if (!empty($activeCron) && !empty($newCronSecurity) && (empty($previousCronSecurity) || $previousCronSecurityKey !== $newCronSecurityKey)) { |
| 86 | 96 | $configurationController = new ConfigurationController(); |
| 87 | 97 | $deactivationResult = $configurationController->modifyCron('deactivateCron'); |
| 88 | 98 | if (!empty($deactivationResult)) { |
| @@ -94,8 +104,9 @@ | ||
| 94 | 104 | return true; |
| 95 | 105 | } |
| 96 | 106 | |
| 97 | 107 | try { |
| 108 | + // We do a replace so that values are always kept up to date and added if necessary in the mean time | |
| 98 | 109 | $status = acym_query('REPLACE INTO #__acym_configuration (`name`, `value`) VALUES '.implode(',', $params)); |
| 99 | 110 | } catch (\Exception $e) { |
| 100 | 111 | $status = false; |
| 101 | 112 | } |
| @@ -100,9 +111,9 @@ | ||
| 100 | 111 | $status = false; |
| 101 | 112 | } |
| 102 | 113 | |
| 103 | 114 | if ($status === false) { |
| 104 | - acym_display(isset($e) ? $e->getMessage() : substr(strip_tags(acym_getDBError()), 0, 200).'...', 'error'); | |
| 115 | + acym_display(isset($e) ? $e->getMessage() : substr(acym_stripTags(acym_getDBError()), 0, 200).'...', 'error'); | |
| 105 | 116 | } |
| 106 | 117 | |
| 107 | 118 | $newFollowupPriority = $this->get('followup_max_priority', 0) == 1; |
| 108 | 119 | |