From e3de9d7dd1331f9718e04cc98e9ca7cfa27cf4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C3=A9cureuil?= Date: Sun, 17 May 2020 14:46:00 +0200 Subject: Sync with master of moonmoon ( version 9.0.0-rc) Source from https://github.com/Emmafrs/moonmoon/ --- common/install.php | 170 +++++++++-------------------------------------------- 1 file changed, 28 insertions(+), 142 deletions(-) (limited to 'common/install.php') diff --git a/common/install.php b/common/install.php index 3a3eae7..86e1123 100755 --- a/common/install.php +++ b/common/install.php @@ -1,6 +1,6 @@ ' . $str . '' . $msg . ''; } -// If the password and config files exist, moonmoon is already installed -if (file_exists(dirname(__FILE__) . '/custom/config.yml') - && file_exists(dirname(__FILE__) . '/admin/inc/pwd.inc.php')) { +// If the config file exists and the auth variables are set, moonmoon is already installed +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($_POST['locale'], '..') !== false + || !file_exists(__DIR__ . "/app/l10n/${_REQUEST['locale']}.lang")) { + $_POST['locale'] = 'en'; + } + $save = array(); //Save config file - $config = array( - 'url' => filter_var($_REQUEST['url'], FILTER_SANITIZE_ENCODED), - 'name' => filter_var($_REQUEST['title'], FILTER_SANITIZE_SPECIAL_CHARS), - 'locale' => filter_var($_REQUEST['locale'], FILTER_SANITIZE_SPECIAL_CHARS), - 'items' => 10, - 'shuffle' => 0, - 'refresh' => 240, - 'cache' => 10, - 'nohtml' => 0, - 'postmaxlength' => 0, - 'cachedir' => './cache' - ); + $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(dirname(__FILE__).'/custom/config.yml', $CreatePlanetConfig->toYaml()); + $save['config'] = file_put_contents(custom_path('config.yml'), $CreatePlanetConfig->toYaml()); + + OpmlManager::save(new Opml(), custom_path('people.opml')); //Save password - $save['password'] = file_put_contents(dirname(__FILE__).'/admin/inc/pwd.inc.php', ''); + $save['password'] = file_put_contents(admin_path('inc/pwd.inc.php'), ''); if (0 != ($save['config'] + $save['password'])) { $status = 'installed'; @@ -40,12 +41,12 @@ if (file_exists(dirname(__FILE__) . '/custom/config.yml') } else { // We start by malking sure we have PHP5 as a base requirement - if(phpversion() >= 5) { - $strInstall = installStatus('Server is running PHP5', 'OK',true); + if(version_compare(PHP_VERSION, '5.6.0') >= 0) { + $strInstall = installStatus('Server is running at least PHP 5.6', 'OK',true); $strRecommendation = ''; } else { - $strInstall = installStatus('Server is running PHP5', 'FAIL',false); - $strRecommendation = '
  • Check your server documentation to activate PHP5
  • '; + $strInstall = installStatus('Server is running at least PHP 5.6', 'FAIL',false); + $strRecommendation = '
  • Check your server documentation to activate at least PHP 5.6
  • '; } // Writable file requirements @@ -56,10 +57,11 @@ if (file_exists(dirname(__FILE__) . '/custom/config.yml') '/cache', ); - // We now test that all required files are writable + // We now test that all required files and directories are writable. foreach ($tests as $v) { - if(is_writable(dirname(__FILE__) . $v)) { + if(touch(__DIR__ . $v)) { $strInstall .= installStatus("$v is writable", 'OK', true); + unlink(__DIR__.$v); } else { $strInstall .= installStatus("$v is writable", 'FAIL',false); $strRecommendation .= "
  • Make $v writable with CHMOD
  • "; @@ -70,121 +72,5 @@ if (file_exists(dirname(__FILE__) . '/custom/config.yml') $status = ($strRecommendation != '') ? 'error' : 'install'; } -?> - - - - - <?=_g('moonmoon installation')?> - - - - -

    - - -
    -

    Sorry, your server is not compatible with moonmoon.

    - -

    Your server does not fulfill the requirements

    - - - - - - - - - - -
    TestResult
    - -

    Troubleshooting

    -

    To install moonmoon, try the following changes:

    - -
    - - -
    -
    -
    - - - -

    - - -

    - -

    - - -

    -

    - - -

    -

    - -

    -
    -
    -
    - - -

    -

    -
      -
    1. - Delete install.php with your FTP software.')?> -
    2. -
    3. - administration panel')?> -
    4. -
    - - - +require_once views_path('install.tpl.php'); \ No newline at end of file -- cgit v1.2.1