mirror of
https://github.com/friendica/friendica
synced 2025-04-28 21:04:22 +02:00
Hardening save method in BaseURL
This commit is contained in:
parent
40c075cf47
commit
1dd1684885
2 changed files with 92 additions and 12 deletions
|
@ -137,35 +137,54 @@ class BaseURL
|
|||
*/
|
||||
public function save($hostname = null, $sslPolicy = null, $urlPath = null)
|
||||
{
|
||||
$success = true;
|
||||
$currHostname = $this->hostname;
|
||||
$currSSLPolicy = $this->sslPolicy;
|
||||
$currURLPath = $this->urlPath;
|
||||
|
||||
if (!empty($hostname) && $hostname !== $this->hostname) {
|
||||
$this->hostname = $hostname;
|
||||
if (!$this->config->set('config', 'hostname', $this->hostname)) {
|
||||
$success = false;
|
||||
if ($this->config->set('config', 'hostname', $hostname)) {
|
||||
$this->hostname = $hostname;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($sslPolicy) && $sslPolicy !== $this->sslPolicy) {
|
||||
$this->sslPolicy = $sslPolicy;
|
||||
if (!$this->config->set('system', 'ssl_policy', $this->sslPolicy)) {
|
||||
$success = false;
|
||||
if ($this->config->set('system', 'ssl_policy', $sslPolicy)) {
|
||||
$this->sslPolicy = $sslPolicy;
|
||||
} else {
|
||||
$this->hostname = $currHostname;
|
||||
$this->config->set('config', 'hostname', $this->hostname);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($urlPath) && $urlPath !== $this->urlPath) {
|
||||
$this->urlPath = $urlPath;
|
||||
if (!$this->config->set('system', 'urlpath', $this->urlPath)) {
|
||||
$success = false;
|
||||
if ($this->config->set('system', 'urlpath', $urlPath)) {
|
||||
$this->urlPath = $urlPath;
|
||||
} else {
|
||||
$this->hostname = $currHostname;
|
||||
$this->sslPolicy = $currSSLPolicy;
|
||||
$this->config->set('config', 'hostname', $this->hostname);
|
||||
$this->config->set('system', 'ssl_policy', $this->sslPolicy);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$this->determineBaseUrl();
|
||||
if (!$this->config->set('system', 'url', $this->url)) {
|
||||
$success = false;
|
||||
$this->hostname = $currHostname;
|
||||
$this->sslPolicy = $currSSLPolicy;
|
||||
$this->urlPath = $currURLPath;
|
||||
$this->determineBaseUrl();
|
||||
|
||||
$this->config->set('config', 'hostname', $this->hostname);
|
||||
$this->config->set('system', 'ssl_policy', $this->sslPolicy);
|
||||
$this->config->set('system', 'urlpath', $this->urlPath);
|
||||
return false;
|
||||
}
|
||||
|
||||
return $success;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue