summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/classes/PlanetConfig.php12
-rwxr-xr-xinstall.php28
2 files changed, 15 insertions, 25 deletions
diff --git a/app/classes/PlanetConfig.php b/app/classes/PlanetConfig.php
index 4348524..f3928bc 100644
--- a/app/classes/PlanetConfig.php
+++ b/app/classes/PlanetConfig.php
@@ -6,9 +6,9 @@
class PlanetConfig
{
- protected $conf = array();
+ protected $conf = [];
- protected $defaultConfig = array(
+ public static $defaultConfig = [
'url' => 'http://www.example.com/',
'name' => '',
'locale' => 'en',
@@ -22,7 +22,7 @@ class PlanetConfig
'cachedir' => './cache',
'debug' => false,
'checkcerts' => true,
- );
+ ];
/**
* PlanetConfig constructor.
@@ -31,7 +31,7 @@ class PlanetConfig
*/
public function __construct($userConfig = [], $useDefaultConfig = true)
{
- $default = $useDefaultConfig ? $this->defaultConfig : array();
+ $default = $useDefaultConfig ? self::$defaultConfig : array();
$this->conf = $this->merge($default, $userConfig);
}
@@ -42,7 +42,7 @@ class PlanetConfig
* @param array $user
* @return array
*/
- protected function merge($default, $user)
+ protected function merge($default = [], $user = [])
{
return array_merge($default, $this->normalizeArrayKeys($user));
}
@@ -131,7 +131,7 @@ class PlanetConfig
*/
public function getDefaultConfig()
{
- return $this->defaultConfig;
+ return self::$defaultConfig;
}
/**
diff --git a/install.php b/install.php
index 46b2c1c..86e1123 100755
--- a/install.php
+++ b/install.php
@@ -9,33 +9,23 @@ function installStatus($str, $msg, $result) {
}
// If the config file exists and the auth variables are set, moonmoon is already installed
-include __DIR__ . '/admin/inc/pwd.inc.php';
-if (file_exists(__DIR__ . '/custom/config.yml') && isset($login) && isset($password)) {
+if (is_installed()) {
$status = 'installed';
-} elseif (isset($_REQUEST['url'])) {
+} elseif (isset($_POST['url'])) {
// Do no try to use the file of an invalid locale
- if (strstr($_REQUEST['locale'], '..') !== false
+ if (strstr($_POST['locale'], '..') !== false
|| !file_exists(__DIR__ . "/app/l10n/${_REQUEST['locale']}.lang")) {
- $_REQUEST['locale'] = 'en';
+ $_POST['locale'] = 'en';
}
$save = array();
//Save config file
- $config = array(
- 'url' => $_REQUEST['url'],
- 'name' => filter_var($_REQUEST['title'], FILTER_SANITIZE_SPECIAL_CHARS),
- 'locale' => $_REQUEST['locale'],
- 'items' => 10,
- 'shuffle' => 0,
- 'refresh' => 240,
- 'cache' => 10,
- 'nohtml' => 0,
- 'postmaxlength' => 0,
- 'cachedir' => './cache',
- 'debug' => false,
- 'checkcerts' => true,
- );
+ $config = array_merge(PlanetConfig::$defaultConfig, [
+ 'url' => $_POST['url'],
+ 'name' => filter_var($_POST['title'], FILTER_SANITIZE_SPECIAL_CHARS),
+ 'locale' => $_POST['locale'],
+ ]);
$CreatePlanetConfig = new PlanetConfig($config);
$save['config'] = file_put_contents(custom_path('config.yml'), $CreatePlanetConfig->toYaml());